View Javadoc

1   /*
2    wsmo4j - a WSMO API and Reference Implementation
3    Copyright (c) 2005, University of Innsbruck, Austria
4    This library is free software; you can redistribute it and/or modify it under
5    the terms of the GNU Lesser General Public License as published by the Free
6    Software Foundation; either version 2.1 of the License, or (at your option)
7    any later version.
8    This library is distributed in the hope that it will be useful, but WITHOUT
9    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10   FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
11   details.
12   You should have received a copy of the GNU Lesser General Public License along
13   with this library; if not, write to the Free Software Foundation, Inc.,
14   59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15   */
16  package org.deri.wsmo4j.io.serializer.xml;
17  
18  
19  import org.w3c.dom.*;
20  
21  import org.omwg.logicalexpression.*;
22  
23  
24  /**
25   * This class is used to serialize logical expressions to XML.
26   * @author retkru
27   * @see org.omwg.logicalexpression.io.Serializer
28   */
29  public class LogExprSerializerXML {
30  
31      private VisitorSerializeXML xml;
32  
33      /**
34       * @param doc Document that will be filled with the xml structure
35       * @see org.w3c.dom.Document
36       */
37      public LogExprSerializerXML(Document doc) {
38          xml = new VisitorSerializeXML(doc);
39      }
40  
41      /**
42       * @param logExpr Logical expression object model to be serialized
43       * @return XML Node of the Document tree
44       * @see org.omwg.logicalexpression.io.Serializer#serialize(org.omwg.logicalexpression.LogicalExpression)
45       * @see org.w3c.dom.Node
46       */
47      public Node serialize(LogicalExpression logExpr) {
48          logExpr.accept(xml);
49          return (Node)xml.getSerializedObject();
50      }
51  
52  }