View Javadoc

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      													public String toString(){return "";}
55      													public void accept(Visitor v) { throw new UnsupportedOperationException(); }												
56      												});
57      
58      //to serialize terms especially values
59      protected VisitorSerializeWSMLTerms visitorSerializeTerm;
60  
61      public WSMLTextExportHelper(Writer writer) {
62          this.writer = writer;
63      }
64  
65      WSMLTextExportHelper outnl() {
66          return out("\n");
67      }
68      WSMLTextExportHelper outnl(String str) {
69          return out(str).outnl();
70      }
71      WSMLTextExportHelper out(String str) {
72          try {
73              writer.write(str);
74          }
75          catch (IOException ioe) {
76              throw new RuntimeException("while writing", ioe);
77          }
78          return this;
79      }
80  
81  
82      String transformUri(Identifier id) {
83          id.accept(visitorSerializeTerm);
84          return visitorSerializeTerm.getSerializedObject().toString();
85      }
86      
87      public void process(Entity[] items) {
88          boolean hasNS = false;
89          String lastWsmlVariant = null; 
90          for (int i = 0; i < items.length; i++) {
91              if (items[i] instanceof TopEntity) {
92                  TopEntity nsC = (TopEntity)items[i];
93                  if (nsC.getWsmlVariant()!=null){
94                      if (lastWsmlVariant != null && !lastWsmlVariant.equals(nsC.getWsmlVariant())) {
95                          throw new RuntimeException("Cannot serialize multiple TopEntity type " +
96                                  "with different wsml variants in one document!");
97                      }
98                      if (lastWsmlVariant == null) {
99                          lastWsmlVariant = nsC.getWsmlVariant();
100                         out("wsmlVariant " + Constants.IRI_DEL_START + 
101                             nsC.getWsmlVariant() + Constants.IRI_DEL_END + "\n");
102                     }
103                 }
104                 Iterator iter = nsC.listNamespaces().iterator();
105                 while (iter.hasNext()) {
106                     Namespace ns = (Namespace)iter.next();
107                     nsContainer.addNamespace(ns);
108                     hasNS = true;
109                 }
110                 if (nsContainer.getDefaultNamespace() == null || nsContainer.getDefaultNamespace().getIRI().toString().length() == 0) {
111                     nsContainer.setDefaultNamespace(nsC.getDefaultNamespace());
112                 }
113             }
114         } // enum namespaces
115         visitorSerializeTerm = new VisitorSerializeWSMLTerms(nsContainer);
116         
117         boolean bHasDefNS = nsContainer.getDefaultNamespace() != null;
118         if (hasNS || bHasDefNS) {
119             out("namespace { ");
120             boolean bComma = false;
121             if (bHasDefNS) {
122                 out("_\"").out(nsContainer.getDefaultNamespace().getIRI().toString()).outnl("\"");
123                 bComma = true;
124             }
125             Iterator iter = nsContainer.listNamespaces().iterator();
126             while (iter.hasNext()) {
127                 Namespace ns = (Namespace)iter.next();
128 //                nsContainer.addNamespace(ns.getPrefix(), ns.getURI());
129                 if (bComma)
130                     out(", ").outnl();
131                 bComma = true;
132                 out(elementPadder 
133                         + VisitorSerializeWSMLTerms.escapeNonSQNameSymbols(ns.getPrefix()))
134                         .out(" _\"")
135                         .out(ns.getIRI().toString())
136                         .out("\"");
137                 hasNS = true;
138             }
139 //            if (nsContainer.getTargetNamespace().length() > 0) {
140 //                outnl(elementPadder + "targetNamespace" + ": " + "<<" + nsContainer.getTargetNamespace() + ">>");
141 //            }
142             outnl(" }");
143         }
144         visitorSerializeTerm = new VisitorSerializeWSMLTerms(nsContainer);
145 
146         for (int i = 0; i < items.length; i++) {
147             if (items[i] instanceof TopEntity) {
148                 TopEntity nsC = (TopEntity)items[i];
149                 nsContainer.setDefaultNamespace(nsC.getDefaultNamespace());
150 //                nsContainer.setTargetNamespace(nsC.getTargetNamespace());
151             }
152             new WSMLItem(items[i]).apply(this);
153         }
154         outnl();
155         
156         try {
157             writer.flush();
158         }
159         catch (IOException e) {
160             throw new RuntimeException("Error while flushing the writer!", e);
161         }
162     }
163 // -------- NFPs ------------
164     public void inEntity(Entity item) {
165         outnl().out(elementPadder + "nonFunctionalProperties");
166     }
167     public void onNFPKeyValues(IRI key, Set vals) {
168         if (vals.size() == 0) {
169             return;
170         }
171         outnl().out(subElementPadder + transformUri(key)).out(" ");
172         if (vals.size() == 1) {
173             Object obj = vals.iterator().next();
174             if (obj instanceof Identifier) {
175                 out("hasValue ").out(transformUri((Identifier)obj));
176             }
177             if (obj instanceof Instance) {
178                 out("hasValue ").out(transformUri(((Instance)obj).getIdentifier()));
179             }
180             else if (obj instanceof DataValue){
181                 ((DataValue)obj).accept(visitorSerializeTerm);
182                 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                     out("hasValue ").out(ss);
190 //                }
191             }
192 //                out("hasValue ").out(obj.toString()).outnl();
193         }
194         else {
195             out("hasValue {");
196             Iterator iter = vals.iterator();
197             boolean bComma = false;
198             while (iter.hasNext()) {
199                 if (bComma) {
200                     out(", ");
201                 }
202                 Object obj = iter.next();
203                 if (obj instanceof Identifier) {
204                     out(transformUri((Identifier)obj));
205                 }
206                 if (obj instanceof Instance) {
207                    out(transformUri(((Instance)obj).getIdentifier()));
208                 }
209                 else  if (obj instanceof DataValue) {
210                     ((DataValue)obj).accept(visitorSerializeTerm);
211                     String ss = visitorSerializeTerm.getSerializedObject();
212 //                    if (ss.length() >= 4 && ss.startsWith("<<") && ss.endsWith(">>")) {
213                         out(ss);
214 //                    }
215 //                    else {
216 //                        out("\"").out(ss).out("\"");
217 //                    }
218                 }
219                 bComma = true;
220             }
221             out("}");
222         }
223     }
224     public void outEntity(Entity item) {
225         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     public void inImportsOntologies(TopEntity _) {
249         outnl().outnl().out(elementPadder + "importsOntology");
250     }
251     public void onImportedOntologies(Set list) {
252         outnl();
253         if (list.size() > 1) {
254             out(subElementPadder + "{ ");
255         }
256         boolean bComma = false;
257         boolean onlyOne = list.size() == 1;
258         Iterator iter = list.iterator();
259         while (iter.hasNext()) {
260             String pad = "";
261             if (bComma) {
262                 outnl(", ");
263             }
264             if (bComma || onlyOne){
265                 pad = subElementPadder + "  ";
266             }
267             Identifier entityID = ((Entity)iter.next()).getIdentifier();
268             out(pad + "_\"" +  entityID.toString() + "\"");
269             bComma = true;
270         }
271         if (list.size() > 1) {
272             out("}");
273         }
274     }
275 
276     public void inUsesMediators(TopEntity item) {
277         outnl().out(elementPadder + "usesMediator");
278     }
279 
280     public void onUsedMediators(Set list) {
281         outnl();
282         if (list.size() > 1) {
283             out(subElementPadder + "{ ");
284         }
285         boolean bComma = false;
286         Iterator iter = list.iterator();
287         while (iter.hasNext()) {
288             String pad = subElementPadder;
289             if (bComma) {
290                 outnl(", ");
291                 pad = subElementPadder + "  ";
292             }
293             Identifier id = ((Identifier)iter.next());
294             out(pad + transformUri(id));
295             bComma = true;
296         }
297         if (list.size() > 1) {
298             out("}");
299         }
300     }
301 
302     public void inOntology(Ontology item) {
303         outnl().out("ontology ").out(transformUri(item.getIdentifier()));
304     }
305 
306     public void inAxiom(Axiom item) {
307         outnl().outnl().out("axiom ").out(transformUri(item.getIdentifier()));
308     }
309     public void inLogExpressionDefinition(Axiom item) {
310         outnl().out(elementPadder).out("definedBy ");
311     }
312     public void onLogExpression(LogicalExpression item) {
313         LogExprSerializerWSML leSerializer = new LogExprSerializerWSML(nsContainer);
314         outnl().out(subElementPadder).out(leSerializer.serialize(item));
315     }
316 
317     public void inConcept(Concept item) {
318         outnl().outnl().out("concept ").out(transformUri(item.getIdentifier()));
319     }
320     public void onSuperConcepts(Set list) {
321         out(" subConceptOf ");
322         boolean bComma = false;
323         boolean bAddBrackets = list.size() > 1;
324         if (bAddBrackets) {
325             out("{ ");
326         }
327         Iterator iter = list.iterator();
328         while (iter.hasNext()) {
329             if (bComma) {
330                 out(", ");
331             }
332             Entity sc = (Entity)iter.next();
333             out(transformUri(sc.getIdentifier()));
334             bComma = true;
335         }
336         if (bAddBrackets) {
337             out("}");
338         }
339     }
340     public void inAttribute(Attribute item) {
341         outnl().out(elementPadder + transformUri(item.getIdentifier()));
342         if (item.isTransitive()) {
343             out(" transitive ");
344         }
345         if (item.isReflexive()) {
346             out(" reflexive ");
347         }
348         if (item.isSymmetric()) {
349             out(" symmetric ");
350         }
351         Identifier invAttr = item.getInverseOf();
352         if (invAttr != null) {
353             out(" inverseOf(").out(transformUri(invAttr)).out(")");
354         }
355         if (item.isConstraining()) {
356             out(" ofType ");
357         } else {
358             out(" impliesType ");
359         }
360         // cardinality only if not default
361         if (!(item.getMinCardinality()==0 && item.getMaxCardinality()==Integer.MAX_VALUE)){
362             out(" ("+item.getMinCardinality());
363             if (item.getMaxCardinality() == Integer.MAX_VALUE) {
364                 out(" *) ");
365             } else {
366                 out(" "+item.getMaxCardinality()+") ");
367             }
368         }
369         Set list = item.listTypes();
370         if (list.size() > 1) {
371             out("{ ");
372         }
373         boolean bComma = false;
374         Iterator iter = list.iterator();
375         while (iter.hasNext()) {
376             Type c = (Type)iter.next();
377             if (bComma)
378                 out(", ");
379             bComma = true;
380             if (c instanceof Concept) {
381                 out(transformUri(((Concept)c).getIdentifier()));
382             }else {
383                 String iri = ((WsmlDataType)c).getIRI().toString();
384                 out (ConstantTransformer.getInstance().findNotation(iri));
385             }
386         }
387         if (list.size() > 1) {
388             out("}");
389         }
390     }
391 
392 
393     public void inRelation(Relation item) {
394         outnl().outnl().out("relation ").out(transformUri(item.getIdentifier()));
395     }
396     public void onSuperRelations(Set list) {
397         out(" subRelationOf ");
398         boolean bComma = false;
399         if (list.size() > 1) {
400             out("{ ");
401         }
402         Iterator iter = list.iterator();
403         while (iter.hasNext()) {
404             if (bComma) {
405                 out(", ");
406             }
407             Entity sc = (Entity)iter.next();
408             out(transformUri(sc.getIdentifier()));
409             bComma = true;
410         }
411         if (list.size() > 1) {
412             out("}");
413         }
414     }
415     public void onParameters(List list) {
416         boolean bComma = false;
417         Iterator iter = list.iterator();
418         //dont print parameters if all don't have types (then it just has arity
419         boolean arityOnly=true;
420         while (iter.hasNext()){
421             if (((Parameter)iter.next()).listTypes().size()!=0){
422                 arityOnly=false;
423             }
424         }
425         if (arityOnly){
426             out("/"+(list.size()));
427             return;
428         }
429         
430         out("(");
431         // enum the relation parameters
432         iter = list.iterator();
433         while (iter.hasNext()) {
434             if (bComma)
435                 out(", ");
436             bComma = true;
437             Parameter param = (Parameter)iter.next();
438             // range semantics
439             if (param.isConstraining()) {
440                 out(" ofType ");
441             } else {
442                 out(" impliesType ");
443             }
444 
445             // parameter range(s)
446             Set types = param.listTypes();
447             if (types.size() > 1)
448                 out("{");
449             Iterator typesIter = types.iterator();
450             boolean bTypesComma = false;
451             while (typesIter.hasNext()) {
452                 if (bTypesComma)
453                     out(", ");
454                 bTypesComma = true;
455                 Type theType = (Type)typesIter.next();
456                 if (! (theType instanceof WsmlDataType)){
457                     out(transformUri(((Entity)theType).getIdentifier()));
458                 }else {
459                     out(ConstantTransformer.getInstance().findNotation(
460                             ((WsmlDataType)theType).getIRI().toString()));
461                 }
462             }
463             if (types.size() > 1)
464                 out("}");
465         }
466         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     public void inInstance(Instance item) {
478         outnl().outnl().out("instance ").out(transformUri(item.getIdentifier()));
479     }
480     public void onInstanceMemberOf(Set list) {
481         if (0 == list.size())
482             return;
483         out(" memberOf ");
484 
485         if (list.size() > 1)
486             out("{ ");
487         boolean bComma = false;
488         Iterator iter = list.iterator();
489         while (iter.hasNext()) {
490             if (bComma) {
491                 out(", ");
492             }
493             bComma = true;
494             Concept c = (Concept)iter.next();
495             out(transformUri(c.getIdentifier()));
496         }
497         if (list.size() > 1)
498             out("} ");
499     }
500     public void onAttributeKeyValue(Identifier key, Set values) {
501         if (values.size() == 0) {
502             return;
503         }
504         outnl().out(elementPadder + transformUri(key));
505         out(" hasValue ");
506         if (values.size() > 1) {
507             out("{");
508         }
509         Iterator iter = values.iterator();
510         boolean bComma = false;
511         while (iter.hasNext()) {
512             if (bComma) {
513                 out(", ");
514             }
515             Object o = iter.next();
516             if (o instanceof DataValue){
517                 ((DataValue)o).accept(visitorSerializeTerm);
518                 String ss = visitorSerializeTerm.getSerializedObject();
519                 out(ss);
520             }else if (o instanceof Entity)
521                 out(transformUri(((Entity)o).getIdentifier()));
522             bComma = true;
523         }
524         if (values.size() > 1) {
525             out(" }");
526         }
527     }
528     // relation instance
529     public void inRelationInstance(RelationInstance item) {
530         //do not print _# for anonymous relation instances (standard case)
531         String id = "";
532         if (! (item.getIdentifier() instanceof UnnumberedAnonymousID)){
533             id = " "+transformUri(item.getIdentifier());
534         }
535         outnl().outnl().out("relationInstance").out(id);
536     }
537     public void onRelationInstanceMemberOf(Relation relation) {
538         out(" ").out(transformUri(relation.getIdentifier()));
539     }
540     public void onParameterValues(List list) {
541         out("(");
542         boolean bComma = false;
543         Iterator iter = list.iterator();
544         while (iter.hasNext()) {
545             Object val = iter.next();
546             if (bComma)
547                 out(", ");
548             if (val instanceof DataValue) {
549                 ((DataValue)val).accept(visitorSerializeTerm);
550                 String ss = visitorSerializeTerm.getSerializedObject();
551                 out(ss);
552                 bComma = true;
553             } else if (val instanceof Entity) {
554                 Identifier id = ((Entity)val).getIdentifier();
555                 out(transformUri(id));
556                 bComma = true;
557             }
558         }
559         out(")");
560     }
561     // ----- webservice
562     public void inWebService(WebService item) {
563         outnl().outnl().out("webService ").out(transformUri(item.getIdentifier()));
564     }
565     public void inCapability(Capability item) {
566         outnl().outnl().out("capability ").out(transformUri(item.getIdentifier()));
567     }
568     public void onSharedVariables(Set list) {
569         outnl().outnl().out("sharedVariables ");
570         if (list.size() > 1)
571             out("{");
572         boolean bComma = false;
573 
574         Iterator iter = list.iterator();
575         while (iter.hasNext()) {
576             if (bComma)
577                 out(", ");
578             bComma = true;
579             Variable en = (Variable)iter.next();
580             out("?");
581             out(en.getName());
582         }
583 
584         if (list.size() > 1)
585             out("}");
586     }
587     public void onHasAssumptions(Entity item) {
588         outnl().outnl().out("assumption ");
589         if (item.getIdentifier() instanceof IRI)
590         	out(transformUri(item.getIdentifier()));
591     }
592     public void onHasEffects(Entity item) {
593         outnl().outnl().out("effect ");
594         if (item.getIdentifier() instanceof IRI)
595         	out(transformUri(item.getIdentifier()));
596     }
597     public void onHasPreconditions(Entity item) {
598         outnl().outnl().out("precondition ");
599         if (item.getIdentifier() instanceof IRI)
600         	out(transformUri(item.getIdentifier()));
601     }
602     public void onHasPostconditions(Entity item) {
603         outnl().outnl().out("postcondition ");
604         if (item.getIdentifier() instanceof IRI)
605         	out(transformUri(item.getIdentifier()));
606     }
607 
608     public void inInterface(Interface item) {
609         outnl().outnl().out("interface ").out(transformUri(item.getIdentifier()));
610     }
611 
612     public void onMultipleInterfaces(Set list) {
613         outnl().outnl().out("interface {");
614 
615         boolean bComma = false;
616 
617         Iterator iter = list.iterator();
618         while (iter.hasNext()) {
619             if (bComma)
620                 out(", ");
621             bComma = true;
622             Entity en = (Entity)iter.next();
623             out(transformUri(en.getIdentifier()));
624         }
625 
626         outnl().out("}");
627     }
628 
629     public void inOrchestration(Orchestration item) {
630         outnl().out("orchestration ").out(transformUri(item.getIdentifier()));
631     }
632     public void inChoreography(Choreography item) {
633         outnl().outnl().out("choreography ").out(transformUri(item.getIdentifier()));
634     }
635     // --- goals
636     public void inGoal(Goal item) {
637         outnl().outnl().out("goal ").out(transformUri(item.getIdentifier()));
638     }
639     // --- mediators
640     public void onMediatorSources(Set list) {
641         outnl().out(" source ");
642         if (list.size() > 1)
643             out("{ ");
644         boolean bComma = false;
645         Iterator iter = list.iterator();
646         while (iter.hasNext()) {
647             if (bComma)
648                 out(", ");
649             bComma = true;
650             out(transformUri((Identifier)iter.next()));
651         }
652         if (list.size() > 1)
653             out(" }");
654     }
655     public void onMediatorTarget(Identifier item) {
656         outnl().out(" target ");
657         out(transformUri(item));
658     }
659     public void onMediatorUseService(Identifier item) {
660         outnl().out(" usesService ");
661         out(transformUri(item));
662     }
663 
664     public void inOOMediator(OOMediator item) {
665         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     public void inWGMediator(WGMediator item) {
683         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     public void inWWMediator(WWMediator item) {
699         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     public void inGGMediator(GGMediator item) {
716         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  */