Clover coverage report - Maven Clover report
Coverage timestamp: Tue Sep 16 2008 01:16:37 EEST
file stats: LOC: 880   Methods: 50
NCLOC: 552   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
WSMLTextExportHelper.java 0% 0% 0% 0%
coverage
 1    /*
 2    wsmo4j - a WSMO API and Reference Implementation
 3   
 4    Copyright (c) 2004-2006, Ontotext Lab. / SIRMA, DERI Innsbruck
 5   
 6    This library is free software; you can redistribute it and/or modify it under
 7    the terms of the GNU Lesser General Public License as published by the Free
 8    Software Foundation; either version 2.1 of the License, or (at your option)
 9    any later version.
 10    This library is distributed in the hope that it will be useful, but WITHOUT
 11    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 12    FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 13    details.
 14    You should have received a copy of the GNU Lesser General Public License along
 15    with this library; if not, write to the Free Software Foundation, Inc.,
 16    59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 17    */
 18   
 19    package com.ontotext.wsmo4j.serializer.wsml;
 20   
 21    import java.io.*;
 22    import java.util.*;
 23   
 24    import org.deri.wsmo4j.io.serializer.wsml.*;
 25    import org.deri.wsmo4j.logicalexpression.*;
 26    import org.omwg.logicalexpression.*;
 27    import org.omwg.logicalexpression.terms.Visitor;
 28    import org.omwg.ontology.*;
 29    import org.wsmo.common.*;
 30    import org.wsmo.mediator.*;
 31    import org.wsmo.service.*;
 32   
 33    import com.ontotext.wsmo4j.common.*;
 34   
 35   
 36    /**
 37    * <p>Title: WSMO4J</p>
 38    * <p>Description: WSMO API and a Reference Implementation</p>
 39    * <p>Copyright: Copyright (c) 2004-2005</p>
 40    * <p>Company: OntoText Lab. / SIRMA </p>
 41    * @author not attributable
 42    * @version 1.0
 43    *
 44    */
 45    public class WSMLTextExportHelper extends WSMLEnumerator {
 46   
 47    //padders to give some decent formatting to output
 48    String elementPadder = " ";
 49    String subElementPadder = elementPadder + " ";
 50   
 51    protected Writer writer;
 52   
 53    private TopEntity nsContainer = new TopEntityImpl(new Identifier() {
 54  0 public String toString(){return "";}
 55  0 public void accept(Visitor v) { throw new UnsupportedOperationException(); }
 56    });
 57   
 58    //to serialize terms especially values
 59    protected VisitorSerializeWSMLTerms visitorSerializeTerm;
 60   
 61  0 public WSMLTextExportHelper(Writer writer) {
 62  0 this.writer = writer;
 63    }
 64   
 65  0 WSMLTextExportHelper outnl() {
 66  0 return out("\n");
 67    }
 68  0 WSMLTextExportHelper outnl(String str) {
 69  0 return out(str).outnl();
 70    }
 71  0 WSMLTextExportHelper out(String str) {
 72  0 try {
 73  0 writer.write(str);
 74    }
 75    catch (IOException ioe) {
 76  0 throw new RuntimeException("while writing", ioe);
 77    }
 78  0 return this;
 79    }
 80   
 81   
 82  0 String transformUri(Identifier id) {
 83  0 id.accept(visitorSerializeTerm);
 84  0 return visitorSerializeTerm.getSerializedObject().toString();
 85    }
 86   
 87  0 public void process(Entity[] items) {
 88  0 boolean hasNS = false;
 89  0 String lastWsmlVariant = null;
 90  0 for (int i = 0; i < items.length; i++) {
 91  0 if (items[i] instanceof TopEntity) {
 92  0 TopEntity nsC = (TopEntity)items[i];
 93  0 if (nsC.getWsmlVariant()!=null){
 94  0 if (lastWsmlVariant != null && !lastWsmlVariant.equals(nsC.getWsmlVariant())) {
 95  0 throw new RuntimeException("Cannot serialize multiple TopEntity type " +
 96    "with different wsml variants in one document!");
 97    }
 98  0 if (lastWsmlVariant == null) {
 99  0 lastWsmlVariant = nsC.getWsmlVariant();
 100  0 out("wsmlVariant " + Constants.IRI_DEL_START +
 101    nsC.getWsmlVariant() + Constants.IRI_DEL_END + "\n");
 102    }
 103    }
 104  0 Iterator iter = nsC.listNamespaces().iterator();
 105  0 while (iter.hasNext()) {
 106  0 Namespace ns = (Namespace)iter.next();
 107  0 nsContainer.addNamespace(ns);
 108  0 hasNS = true;
 109    }
 110  0 if (nsContainer.getDefaultNamespace() == null || nsContainer.getDefaultNamespace().getIRI().toString().length() == 0) {
 111  0 nsContainer.setDefaultNamespace(nsC.getDefaultNamespace());
 112    }
 113    }
 114    } // enum namespaces
 115  0 visitorSerializeTerm = new VisitorSerializeWSMLTerms(nsContainer);
 116   
 117  0 boolean bHasDefNS = nsContainer.getDefaultNamespace() != null;
 118  0 if (hasNS || bHasDefNS) {
 119  0 out("namespace { ");
 120  0 boolean bComma = false;
 121  0 if (bHasDefNS) {
 122  0 out("_\"").out(nsContainer.getDefaultNamespace().getIRI().toString()).outnl("\"");
 123  0 bComma = true;
 124    }
 125  0 Iterator iter = nsContainer.listNamespaces().iterator();
 126  0 while (iter.hasNext()) {
 127  0 Namespace ns = (Namespace)iter.next();
 128    // nsContainer.addNamespace(ns.getPrefix(), ns.getURI());
 129  0 if (bComma)
 130  0 out(", ").outnl();
 131  0 bComma = true;
 132  0 out(elementPadder
 133    + VisitorSerializeWSMLTerms.escapeNonSQNameSymbols(ns.getPrefix()))
 134    .out(" _\"")
 135    .out(ns.getIRI().toString())
 136    .out("\"");
 137  0 hasNS = true;
 138    }
 139    // if (nsContainer.getTargetNamespace().length() > 0) {
 140    // outnl(elementPadder + "targetNamespace" + ": " + "<<" + nsContainer.getTargetNamespace() + ">>");
 141    // }
 142  0 outnl(" }");
 143    }
 144  0 visitorSerializeTerm = new VisitorSerializeWSMLTerms(nsContainer);
 145   
 146  0 for (int i = 0; i < items.length; i++) {
 147  0 if (items[i] instanceof TopEntity) {
 148  0 TopEntity nsC = (TopEntity)items[i];
 149  0 nsContainer.setDefaultNamespace(nsC.getDefaultNamespace());
 150    // nsContainer.setTargetNamespace(nsC.getTargetNamespace());
 151    }
 152  0 new WSMLItem(items[i]).apply(this);
 153    }
 154  0 outnl();
 155   
 156  0 try {
 157  0 writer.flush();
 158    }
 159    catch (IOException e) {
 160  0 throw new RuntimeException("Error while flushing the writer!", e);
 161    }
 162    }
 163    // -------- NFPs ------------
 164  0 public void inEntity(Entity item) {
 165  0 outnl().out(elementPadder + "nonFunctionalProperties");
 166    }
 167  0 public void onNFPKeyValues(IRI key, Set vals) {
 168  0 if (vals.size() == 0) {
 169  0 return;
 170    }
 171  0 outnl().out(subElementPadder + transformUri(key)).out(" ");
 172  0 if (vals.size() == 1) {
 173  0 Object obj = vals.iterator().next();
 174  0 if (obj instanceof Identifier) {
 175  0 out("hasValue ").out(transformUri((Identifier)obj));
 176    }
 177  0 if (obj instanceof Instance) {
 178  0 out("hasValue ").out(transformUri(((Instance)obj).getIdentifier()));
 179    }
 180  0 else if (obj instanceof DataValue){
 181  0 ((DataValue)obj).accept(visitorSerializeTerm);
 182  0 String ss = visitorSerializeTerm.getSerializedObject();
 183   
 184    //String ss = ((DataValue)obj).asString();
 185    // if (ss.length() >= 4 && ss.startsWith("<<") && ss.endsWith(">>")) {
 186    // out("hasValue ").outnl(ss);
 187    // }
 188    // else {
 189  0 out("hasValue ").out(ss);
 190    // }
 191    }
 192    // out("hasValue ").out(obj.toString()).outnl();
 193    }
 194    else {
 195  0 out("hasValue {");
 196  0 Iterator iter = vals.iterator();
 197  0 boolean bComma = false;
 198  0 while (iter.hasNext()) {
 199  0 if (bComma) {
 200  0 out(", ");
 201    }
 202  0 Object obj = iter.next();
 203  0 if (obj instanceof Identifier) {
 204  0 out(transformUri((Identifier)obj));
 205    }
 206  0 if (obj instanceof Instance) {
 207  0 out(transformUri(((Instance)obj).getIdentifier()));
 208    }
 209  0 else if (obj instanceof DataValue) {
 210  0 ((DataValue)obj).accept(visitorSerializeTerm);
 211  0 String ss = visitorSerializeTerm.getSerializedObject();
 212    // if (ss.length() >= 4 && ss.startsWith("<<") && ss.endsWith(">>")) {
 213  0 out(ss);
 214    // }
 215    // else {
 216    // out("\"").out(ss).out("\"");
 217    // }
 218    }
 219  0 bComma = true;
 220    }
 221  0 out("}");
 222    }
 223    }
 224  0 public void outEntity(Entity item) {
 225  0 outnl().out(elementPadder + "endNonFunctionalProperties");
 226    }
 227    // -------- log expression
 228    // public void inLogExpression(LogicalExpression item) {
 229    // if (item != null) {
 230    // outnl().out(elementPadder + "definedBy");
 231    // }
 232    // else {
 233    // int i = 0;
 234    // }
 235    // }
 236    // public void onLogExpression(LogicalExpression item) {
 237    // String expr = item.asString();
 238    // int pos = -1;
 239    // while (-1 != (pos = expr.indexOf(" . "))) {
 240    // expr = expr.substring(0, pos) + "." + expr.substring(pos + 3);
 241    // }
 242    // outnl().out(subElementPadder + expr);
 243    // }
 244    // -------- imports ontology
 245    /* public void inOntologyContainer(OntologyContainer item) {
 246    outnl().outnl().out(elementPadder + "importedOntologies");
 247    } */
 248  0 public void inImportsOntologies(TopEntity _) {
 249  0 outnl().outnl().out(elementPadder + "importsOntology");
 250    }
 251  0 public void onImportedOntologies(Set list) {
 252  0 outnl();
 253  0 if (list.size() > 1) {
 254  0 out(subElementPadder + "{ ");
 255    }
 256  0 boolean bComma = false;
 257  0 boolean onlyOne = list.size() == 1;
 258  0 Iterator iter = list.iterator();
 259  0 while (iter.hasNext()) {
 260  0 String pad = "";
 261  0 if (bComma) {
 262  0 outnl(", ");
 263    }
 264  0 if (bComma || onlyOne){
 265  0 pad = subElementPadder + " ";
 266    }
 267  0 Identifier entityID = ((Entity)iter.next()).getIdentifier();
 268  0 out(pad + "_\"" + entityID.toString() + "\"");
 269  0 bComma = true;
 270    }
 271  0 if (list.size() > 1) {
 272  0 out("}");
 273    }
 274    }
 275   
 276  0 public void inUsesMediators(TopEntity item) {
 277  0 outnl().out(elementPadder + "usesMediator");
 278    }
 279   
 280  0 public void onUsedMediators(Set list) {
 281  0 outnl();
 282  0 if (list.size() > 1) {
 283  0 out(subElementPadder + "{ ");
 284    }
 285  0 boolean bComma = false;
 286  0 Iterator iter = list.iterator();
 287  0 while (iter.hasNext()) {
 288  0 String pad = subElementPadder;
 289  0 if (bComma) {
 290  0 outnl(", ");
 291  0 pad = subElementPadder + " ";
 292    }
 293  0 Identifier id = ((Identifier)iter.next());
 294  0 out(pad + transformUri(id));
 295  0 bComma = true;
 296    }
 297  0 if (list.size() > 1) {
 298  0 out("}");
 299    }
 300    }
 301   
 302  0 public void inOntology(Ontology item) {
 303  0 outnl().out("ontology ").out(transformUri(item.getIdentifier()));
 304    }
 305   
 306  0 public void inAxiom(Axiom item) {
 307  0 outnl().outnl().out("axiom ").out(transformUri(item.getIdentifier()));
 308    }
 309  0 public void inLogExpressionDefinition(Axiom item) {
 310  0 outnl().out(elementPadder).out("definedBy ");
 311    }
 312  0 public void onLogExpression(LogicalExpression item) {
 313  0 LogExprSerializerWSML leSerializer = new LogExprSerializerWSML(nsContainer);
 314  0 outnl().out(subElementPadder).out(leSerializer.serialize(item));
 315    }
 316   
 317  0 public void inConcept(Concept item) {
 318  0 outnl().outnl().out("concept ").out(transformUri(item.getIdentifier()));
 319    }
 320  0 public void onSuperConcepts(Set list) {
 321  0 out(" subConceptOf ");
 322  0 boolean bComma = false;
 323  0 boolean bAddBrackets = list.size() > 1;
 324  0 if (bAddBrackets) {
 325  0 out("{ ");
 326    }
 327  0 Iterator iter = list.iterator();
 328  0 while (iter.hasNext()) {
 329  0 if (bComma) {
 330  0 out(", ");
 331    }
 332  0 Entity sc = (Entity)iter.next();
 333  0 out(transformUri(sc.getIdentifier()));
 334  0 bComma = true;
 335    }
 336  0 if (bAddBrackets) {
 337  0 out("}");
 338    }
 339    }
 340  0 public void inAttribute(Attribute item) {
 341  0 outnl().out(elementPadder + transformUri(item.getIdentifier()));
 342  0 if (item.isTransitive()) {
 343  0 out(" transitive ");
 344    }
 345  0 if (item.isReflexive()) {
 346  0 out(" reflexive ");
 347    }
 348  0 if (item.isSymmetric()) {
 349  0 out(" symmetric ");
 350    }
 351  0 Identifier invAttr = item.getInverseOf();
 352  0 if (invAttr != null) {
 353  0 out(" inverseOf(").out(transformUri(invAttr)).out(")");
 354    }
 355  0 if (item.isConstraining()) {
 356  0 out(" ofType ");
 357    } else {
 358  0 out(" impliesType ");
 359    }
 360    // cardinality only if not default
 361  0 if (!(item.getMinCardinality()==0 && item.getMaxCardinality()==Integer.MAX_VALUE)){
 362  0 out(" ("+item.getMinCardinality());
 363  0 if (item.getMaxCardinality() == Integer.MAX_VALUE) {
 364  0 out(" *) ");
 365    } else {
 366  0 out(" "+item.getMaxCardinality()+") ");
 367    }
 368    }
 369  0 Set list = item.listTypes();
 370  0 if (list.size() > 1) {
 371  0 out("{ ");
 372    }
 373  0 boolean bComma = false;
 374  0 Iterator iter = list.iterator();
 375  0 while (iter.hasNext()) {
 376  0 Type c = (Type)iter.next();
 377  0 if (bComma)
 378  0 out(", ");
 379  0 bComma = true;
 380  0 if (c instanceof Concept) {
 381  0 out(transformUri(((Concept)c).getIdentifier()));
 382    }else {
 383  0 String iri = ((WsmlDataType)c).getIRI().toString();
 384  0 out (ConstantTransformer.getInstance().findNotation(iri));
 385    }
 386    }
 387  0 if (list.size() > 1) {
 388  0 out("}");
 389    }
 390    }
 391   
 392   
 393  0 public void inRelation(Relation item) {
 394  0 outnl().outnl().out("relation ").out(transformUri(item.getIdentifier()));
 395    }
 396  0 public void onSuperRelations(Set list) {
 397  0 out(" subRelationOf ");
 398  0 boolean bComma = false;
 399  0 if (list.size() > 1) {
 400  0 out("{ ");
 401    }
 402  0 Iterator iter = list.iterator();
 403  0 while (iter.hasNext()) {
 404  0 if (bComma) {
 405  0 out(", ");
 406    }
 407  0 Entity sc = (Entity)iter.next();
 408  0 out(transformUri(sc.getIdentifier()));
 409  0 bComma = true;
 410    }
 411  0 if (list.size() > 1) {
 412  0 out("}");
 413    }
 414    }
 415  0 public void onParameters(List list) {
 416  0 boolean bComma = false;
 417  0 Iterator iter = list.iterator();
 418    //dont print parameters if all don't have types (then it just has arity
 419  0 boolean arityOnly=true;
 420  0 while (iter.hasNext()){
 421  0 if (((Parameter)iter.next()).listTypes().size()!=0){
 422  0 arityOnly=false;
 423    }
 424    }
 425  0 if (arityOnly){
 426  0 out("/"+(list.size()));
 427  0 return;
 428    }
 429   
 430  0 out("(");
 431    // enum the relation parameters
 432  0 iter = list.iterator();
 433  0 while (iter.hasNext()) {
 434  0 if (bComma)
 435  0 out(", ");
 436  0 bComma = true;
 437  0 Parameter param = (Parameter)iter.next();
 438    // range semantics
 439  0 if (param.isConstraining()) {
 440  0 out(" ofType ");
 441    } else {
 442  0 out(" impliesType ");
 443    }
 444   
 445    // parameter range(s)
 446  0 Set types = param.listTypes();
 447  0 if (types.size() > 1)
 448  0 out("{");
 449  0 Iterator typesIter = types.iterator();
 450  0 boolean bTypesComma = false;
 451  0 while (typesIter.hasNext()) {
 452  0 if (bTypesComma)
 453  0 out(", ");
 454  0 bTypesComma = true;
 455  0 Type theType = (Type)typesIter.next();
 456  0 if (! (theType instanceof WsmlDataType)){
 457  0 out(transformUri(((Entity)theType).getIdentifier()));
 458    }else {
 459  0 out(ConstantTransformer.getInstance().findNotation(
 460    ((WsmlDataType)theType).getIRI().toString()));
 461    }
 462    }
 463  0 if (types.size() > 1)
 464  0 out("}");
 465    }
 466  0 out(")");
 467    /*
 468    outnl().out(elementPadder + transformUri(item.getIdentifier()));
 469    Concept range = item.getRange();
 470    if (range != null) {
 471    out(" ofType ").out(transformUri(range.getIdentifier()));
 472    }
 473    */
 474    }
 475   
 476   
 477  0 public void inInstance(Instance item) {
 478  0 outnl().outnl().out("instance ").out(transformUri(item.getIdentifier()));
 479    }
 480  0 public void onInstanceMemberOf(Set list) {
 481  0 if (0 == list.size())
 482  0 return;
 483  0 out(" memberOf ");
 484   
 485  0 if (list.size() > 1)
 486  0 out("{ ");
 487  0 boolean bComma = false;
 488  0 Iterator iter = list.iterator();
 489  0 while (iter.hasNext()) {
 490  0 if (bComma) {
 491  0 out(", ");
 492    }
 493  0 bComma = true;
 494  0 Concept c = (Concept)iter.next();
 495  0 out(transformUri(c.getIdentifier()));
 496    }
 497  0 if (list.size() > 1)
 498  0 out("} ");
 499    }
 500  0 public void onAttributeKeyValue(Identifier key, Set values) {
 501  0 if (values.size() == 0) {
 502  0 return;
 503    }
 504  0 outnl().out(elementPadder + transformUri(key));
 505  0 out(" hasValue ");
 506  0 if (values.size() > 1) {
 507  0 out("{");
 508    }
 509  0 Iterator iter = values.iterator();
 510  0 boolean bComma = false;
 511  0 while (iter.hasNext()) {
 512  0 if (bComma) {
 513  0 out(", ");
 514    }
 515  0 Object o = iter.next();
 516  0 if (o instanceof DataValue){
 517  0 ((DataValue)o).accept(visitorSerializeTerm);
 518  0 String ss = visitorSerializeTerm.getSerializedObject();
 519  0 out(ss);
 520  0 }else if (o instanceof Entity)
 521  0 out(transformUri(((Entity)o).getIdentifier()));
 522  0 bComma = true;
 523    }
 524  0 if (values.size() > 1) {
 525  0 out(" }");
 526    }
 527    }
 528    // relation instance
 529  0 public void inRelationInstance(RelationInstance item) {
 530    //do not print _# for anonymous relation instances (standard case)
 531  0 String id = "";
 532  0 if (! (item.getIdentifier() instanceof UnnumberedAnonymousID)){
 533  0 id = " "+transformUri(item.getIdentifier());
 534    }
 535  0 outnl().outnl().out("relationInstance").out(id);
 536    }
 537  0 public void onRelationInstanceMemberOf(Relation relation) {
 538  0 out(" ").out(transformUri(relation.getIdentifier()));
 539    }
 540  0 public void onParameterValues(List list) {
 541  0 out("(");
 542  0 boolean bComma = false;
 543  0 Iterator iter = list.iterator();
 544  0 while (iter.hasNext()) {
 545  0 Object val = iter.next();
 546  0 if (bComma)
 547  0 out(", ");
 548  0 if (val instanceof DataValue) {
 549  0 ((DataValue)val).accept(visitorSerializeTerm);
 550  0 String ss = visitorSerializeTerm.getSerializedObject();
 551  0 out(ss);
 552  0 bComma = true;
 553  0 } else if (val instanceof Entity) {
 554  0 Identifier id = ((Entity)val).getIdentifier();
 555  0 out(transformUri(id));
 556  0 bComma = true;
 557    }
 558    }
 559  0 out(")");
 560    }
 561    // ----- webservice
 562  0 public void inWebService(WebService item) {
 563  0 outnl().outnl().out("webService ").out(transformUri(item.getIdentifier()));
 564    }
 565  0 public void inCapability(Capability item) {
 566  0 outnl().outnl().out("capability ").out(transformUri(item.getIdentifier()));
 567    }
 568  0 public void onSharedVariables(Set list) {
 569  0 outnl().outnl().out("sharedVariables ");
 570  0 if (list.size() > 1)
 571  0 out("{");
 572  0 boolean bComma = false;
 573   
 574  0 Iterator iter = list.iterator();
 575  0 while (iter.hasNext()) {
 576  0 if (bComma)
 577  0 out(", ");
 578  0 bComma = true;
 579  0 Variable en = (Variable)iter.next();
 580  0 out("?");
 581  0 out(en.getName());
 582    }
 583   
 584  0 if (list.size() > 1)
 585  0 out("}");
 586    }
 587  0 public void onHasAssumptions(Entity item) {
 588  0 outnl().outnl().out("assumption ");
 589  0 if (item.getIdentifier() instanceof IRI)
 590  0 out(transformUri(item.getIdentifier()));
 591    }
 592  0 public void onHasEffects(Entity item) {
 593  0 outnl().outnl().out("effect ");
 594  0 if (item.getIdentifier() instanceof IRI)
 595  0 out(transformUri(item.getIdentifier()));
 596    }
 597  0 public void onHasPreconditions(Entity item) {
 598  0 outnl().outnl().out("precondition ");
 599  0 if (item.getIdentifier() instanceof IRI)
 600  0 out(transformUri(item.getIdentifier()));
 601    }
 602  0 public void onHasPostconditions(Entity item) {
 603  0 outnl().outnl().out("postcondition ");
 604  0 if (item.getIdentifier() instanceof IRI)
 605  0 out(transformUri(item.getIdentifier()));
 606    }
 607   
 608  0 public void inInterface(Interface item) {
 609  0 outnl().outnl().out("interface ").out(transformUri(item.getIdentifier()));
 610    }
 611   
 612  0 public void onMultipleInterfaces(Set list) {
 613  0 outnl().outnl().out("interface {");
 614   
 615  0 boolean bComma = false;
 616   
 617  0 Iterator iter = list.iterator();
 618  0 while (iter.hasNext()) {
 619  0 if (bComma)
 620  0 out(", ");
 621  0 bComma = true;
 622  0 Entity en = (Entity)iter.next();
 623  0 out(transformUri(en.getIdentifier()));
 624    }
 625   
 626  0 outnl().out("}");
 627    }
 628   
 629  0 public void inOrchestration(Orchestration item) {
 630  0 outnl().out("orchestration ").out(transformUri(item.getIdentifier()));
 631    }
 632  0 public void inChoreography(Choreography item) {
 633  0 outnl().outnl().out("choreography ").out(transformUri(item.getIdentifier()));
 634    }
 635    // --- goals
 636  0 public void inGoal(Goal item) {
 637  0 outnl().outnl().out("goal ").out(transformUri(item.getIdentifier()));
 638    }
 639    // --- mediators
 640  0 public void onMediatorSources(Set list) {
 641  0 outnl().out(" source ");
 642  0 if (list.size() > 1)
 643  0 out("{ ");
 644  0 boolean bComma = false;
 645  0 Iterator iter = list.iterator();
 646  0 while (iter.hasNext()) {
 647  0 if (bComma)
 648  0 out(", ");
 649  0 bComma = true;
 650  0 out(transformUri((Identifier)iter.next()));
 651    }
 652  0 if (list.size() > 1)
 653  0 out(" }");
 654    }
 655  0 public void onMediatorTarget(Identifier item) {
 656  0 outnl().out(" target ");
 657  0 out(transformUri(item));
 658    }
 659  0 public void onMediatorUseService(Identifier item) {
 660  0 outnl().out(" usesService ");
 661  0 out(transformUri(item));
 662    }
 663   
 664  0 public void inOOMediator(OOMediator item) {
 665  0 outnl().outnl().out("ooMediator ").out(transformUri(item.getIdentifier()));
 666    }
 667   
 668    // public void outOOMediator(OOMediator item) {
 669    // Set list = item.listSourceComponents();
 670    // Iterator iter = list.iterator();
 671    // while (iter.hasNext()) {
 672    // outnl().out(elementPadder + "source ").out("<<" + ((MediatableReference) iter.next()).getIdentifier() + ">>");
 673    // }
 674    // if (item.getTargetComponent() != null) {
 675    // outnl().out(elementPadder + "target ").out("<<" + ((MediatableReference) item.getTargetComponent()).getIdentifier() + ">>");
 676    // }
 677    // if (item.getMediationServiceID() != null) {
 678    // outnl().out(elementPadder + "useService ").out(item.getMediationServiceID().toString());
 679    // }
 680    // }
 681   
 682  0 public void inWGMediator(WGMediator item) {
 683  0 outnl().outnl().out("wgMediator ").out(transformUri(item.getIdentifier()));
 684    }
 685    // public void outWGMediator(WGMediator item) {
 686    // Set list = item.listSourceComponents();
 687    // Iterator iter = list.iterator();
 688    // while (iter.hasNext()) {
 689    // outnl().out(elementPadder + "source ").out("<<" + ((MediatableReference) iter.next()).getIdentifier() + ">>");
 690    // }
 691    // if (item.getTargetComponent() != null) {
 692    // outnl().out(elementPadder + "target ").out("<<" + ((MediatableReference) item.getTargetComponent()).getIdentifier() + ">>");
 693    // }
 694    // if (item.getMediationServiceID() != null) {
 695    // outnl().out(elementPadder + "useService ").out(item.getMediationServiceID().toString());
 696    // }
 697    // }
 698  0 public void inWWMediator(WWMediator item) {
 699  0 outnl().outnl().out("wwMediator ").out(transformUri(item.getIdentifier()));
 700    }
 701    // public void outWWMediator(WWMediator item) {
 702    // Set list = item.listSourceComponents();
 703    // Iterator iter = list.iterator();
 704    // while (iter.hasNext()) {
 705    // outnl().out(elementPadder + "source ").out("<<" + ((MediatableReference) iter.next()).getIdentifier() + ">>");
 706    // }
 707    // if (item.getTargetComponent() != null) {
 708    // outnl().out(elementPadder + "target ").out("<<" + ((MediatableReference) item.getTargetComponent()).getIdentifier() + ">>");
 709    // }
 710    // if (item.getMediationServiceID() != null) {
 711    // outnl().out(elementPadder + "useService ").out(item.getMediationServiceID().toString());
 712    // }
 713    // }
 714   
 715  0 public void inGGMediator(GGMediator item) {
 716  0 outnl().outnl().out("ggMediator ").out(transformUri(item.getIdentifier()));
 717    }
 718    // public void outGGMediator(GGMediator item) {
 719    // Set list = item.listSourceComponents();
 720    // Iterator iter = list.iterator();
 721    // while (iter.hasNext()) {
 722    // outnl().out(elementPadder + "source ").out("<<" + ((MediatableReference) iter.next()).getIdentifier() + ">>");
 723    // }
 724    // if (item.getTargetComponent() != null) {
 725    // outnl().out(elementPadder + "target ").out("<<" + ((MediatableReference) item.getTargetComponent()).getIdentifier() + ">>");
 726    // }
 727    // if (item.getMediationServiceID() != null) {
 728    // outnl().out(elementPadder + "useService ").out(item.getMediationServiceID().toString());
 729    // }
 730    // }
 731    }
 732   
 733    /*
 734    * $Log$
 735    * Revision 1.14 2007/06/03 13:07:29 alex_simov
 736    * bugfix: nfp values of type Instance were not serialized properly,
 737    * causing invalid wsml
 738    *
 739    * Revision 1.13 2007/04/02 12:13:27 morcen
 740    * Generics support added to wsmo-api, wsmo4j and wsmo-test
 741    *
 742    * Revision 1.12 2006/06/28 11:14:06 alex_simov
 743    * bugfix: instance references set as values in NFPs were not serialized
 744    *
 745    * Revision 1.11 2006/05/04 14:17:09 alex_simov
 746    * bugfix: invalid sQName parsing/serializing - illegal symbols not escaped
 747    *
 748    * Revision 1.10 2006/04/27 10:33:41 holgerlausen
 749    * improved readability of serialzation of relation instances
 750    *
 751    * Revision 1.9 2006/04/13 14:40:24 alex_simov
 752    * bugfix: mediator's sources were still handled like Entities
 753    *
 754    * Revision 1.8 2006/04/05 13:26:32 vassil_momtchev
 755    * usesMediator now refer mediators by IRI instead of handle to object
 756    *
 757    * Revision 1.7 2006/02/16 09:56:50 vassil_momtchev
 758    * setInverseOf(Attribute) changed to setInverseOf(Identifier)
 759    *
 760    * Revision 1.6 2006/02/10 14:39:49 vassil_momtchev
 761    * serializer addapted to the new api changes
 762    *
 763    * Revision 1.5 2006/02/01 15:23:54 vassil_momtchev
 764    * duplicated usage of two VisitorSerializeWSMLTerms, only one used now; write field changed from private to protected
 765    *
 766    * Revision 1.4 2006/01/23 11:01:56 vassil_momtchev
 767    * wsml line was added N times for each topentity with specified wsml variant; topentities with different wsml variants are not allowed in one document
 768    *
 769    * Revision 1.3 2005/12/13 11:13:37 holgerlausen
 770    * fixed serialization of IRIs that contain keywords
 771    *
 772    * Revision 1.2 2005/11/28 14:51:37 vassil_momtchev
 773    * moved from com.ontotext.wsmo4j.parser
 774    *
 775    * Revision 1.1.2.1 2005/11/28 13:59:35 vassil_momtchev
 776    * package refactored from com.ontotext.wsmo4j.parser to com.ontotext.wsmo4j.serializer.wsml
 777    *
 778    * Revision 1.17 2005/10/06 17:57:34 holgerlausen
 779    * fixed anon id bug in serializing
 780    *
 781    * Revision 1.16 2005/09/23 07:09:51 holgerlausen
 782    * moved constanttransformer from API to implementation, removed dublicated constants in logicalexpression.constants
 783    *
 784    * Revision 1.15 2005/09/20 19:41:01 holgerlausen
 785    * removed superflouis interfaces for IO in logical expression (since intgeration not necessary)
 786    *
 787    * Revision 1.14 2005/09/16 14:02:44 alex_simov
 788    * Identifier.asString() removed, use Object.toString() instead
 789    * (Implementations MUST override toString())
 790    *
 791    * Revision 1.13 2005/09/15 11:57:09 holgerlausen
 792    * call le Serializer explicit with nscontainer to resolve existing namespaces
 793    *
 794    * Revision 1.12 2005/09/14 09:43:43 alex_simov
 795    * bugfix: relation paramenters not serialized correctly
 796    *
 797    * Revision 1.11 2005/09/13 10:18:42 holgerlausen
 798    * fixed bug 1237280
 799    * parse/serialize of relation with arity only
 800    *
 801    * Revision 1.10 2005/09/09 10:00:15 holgerlausen
 802    * fixed serializing problem eported by jan (for data types in relations)
 803    *
 804    * Revision 1.9 2005/09/08 16:28:30 holgerlausen
 805    * bug1252521 support for parsing / serializing wsmlVariant
 806    *
 807    * Revision 1.8 2005/09/08 15:16:27 holgerlausen
 808    * fixes for parsing and serializing datatypes
 809    *
 810    * Revision 1.7 2005/09/02 13:32:45 ohamano
 811    * move logicalexpression packages from ext to core
 812    * move tests from logicalexpression.test to test module
 813    *
 814    * Revision 1.6 2005/09/02 09:43:32 ohamano
 815    * integrate wsmo-api and le-api on api and reference implementation level; full parser, serializer and validator integration will be next step
 816    *
 817    * Revision 1.5 2005/08/31 08:36:14 alex_simov
 818    * bugfix: Variable.getName() now returns the name without leading '?'
 819    *
 820    * Revision 1.4 2005/08/10 10:43:08 vassil_momtchev
 821    * always flush the output writer
 822    *
 823    * Revision 1.3 2005/07/08 12:45:59 alex_simov
 824    * fix
 825    *
 826    * Revision 1.2 2005/07/05 12:45:51 alex_simov
 827    * attributes refactored
 828    *
 829    * Revision 1.1 2005/06/27 08:32:00 alex_simov
 830    * refactoring: *.io.parser -> *.parser
 831    *
 832    * Revision 1.22 2005/06/23 08:41:10 damyan_rm
 833    * constuctor made public to ease showing partial entities in textual form
 834    *
 835    * Revision 1.21 2005/06/23 08:18:17 damyan_rm
 836    * fix: serialization of multiple interfaces was using wrong kind of brackets
 837    *
 838    * Revision 1.20 2005/06/22 15:53:36 alex_simov
 839    * capability parse bug fix
 840    *
 841    * Revision 1.19 2005/06/22 14:49:27 alex_simov
 842    * Copyright header added/updated
 843    *
 844    * Revision 1.18 2005/06/22 14:40:27 ohamano
 845    * elementPadder for definedBy is enough. subElementPadder introduces too many empty spaces
 846    *
 847    * Revision 1.17 2005/06/02 14:41:57 alex_simov
 848    * bug fix
 849    *
 850    * Revision 1.16 2005/06/02 14:19:19 alex_simov
 851    * v0.4.0
 852    *
 853    * Revision 1.2 2005/06/02 12:33:09 damian
 854    * fixes
 855    *
 856    * Revision 1.1 2005/05/26 09:36:03 damian
 857    * io package
 858    *
 859    * Revision 1.15 2005/04/27 07:49:49 damyan_rm
 860    * handling of the default datatypes (string, integer, decimal**) for literals
 861    *
 862    * Revision 1.14 2005/04/12 13:20:24 damyan_rm
 863    * bug [1180672] - parser print only the first instacne attribute value - removed attribute valency check within onAttributeKeyValue()
 864    *
 865    * Revision 1.13 2005/03/02 10:56:41 morcen
 866    * fixed bugs 1154273, 1154263, 1154190 with the serializers
 867    *
 868    * Revision 1.12 2005/02/24 12:57:29 morcen
 869    * accidentally committed a System.out statement. removed it
 870    *
 871    * Revision 1.11 2005/02/24 12:49:26 morcen
 872    * fixes to indentation missed the range of a function.
 873    *
 874    * Revision 1.10 2005/02/20 18:01:25 morcen
 875    * fixed bug 1144912 added indentation and consistent new lines to serializer
 876    *
 877    * Revision 1.9 2005/01/12 15:20:18 alex_simov
 878    * checkstyle formatting
 879    *
 880    */