|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
NodeInterface.java | 0% | 0% | 0% | 0% |
|
1 | /* | |
2 | wsmo4j - a WSMO API and Reference Implementation | |
3 | ||
4 | Copyright (c) 2004-2005, OntoText Lab. / SIRMA | |
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 | package com.ontotext.wsmo4j.parser.xml; | |
19 | ||
20 | /** | |
21 | * <p>Title: WSMO4J</p> | |
22 | * <p>Description: WSMO API and a Reference Implementation</p> | |
23 | * <p>Copyright: Copyright (c) 2004-2005</p> | |
24 | * <p>Company: OntoText Lab. / SIRMA </p> | |
25 | * @author not attributable | |
26 | * @version 1.0 | |
27 | * | |
28 | */ | |
29 | ||
30 | import org.w3c.dom.*; | |
31 | import org.wsmo.common.*; | |
32 | import org.wsmo.common.exception.*; | |
33 | import org.wsmo.service.*; | |
34 | ||
35 | import com.ontotext.wsmo4j.serializer.xml.*; | |
36 | ||
37 | /** | |
38 | * Helper type to serialize/deserialize xml element interface | |
39 | * | |
40 | * @author not attributable | |
41 | */ | |
42 | class NodeInterface { | |
43 | 0 | static Interface deserialize(Node xmlNode, WsmlXmlParser parser) |
44 | throws InvalidModelException { | |
45 | 0 | if (xmlNode == null || parser == null || xmlNode.getNodeName() != "interface") { |
46 | 0 | throw new IllegalArgumentException(); |
47 | } | |
48 | ||
49 | 0 | IRI iriInterface = parser.getFactory().createIRI( |
50 | WsmlXmlHelper.getAttrValue(xmlNode, "name")); | |
51 | 0 | Interface intrface = parser.getFactory().createInterface(iriInterface); |
52 | 0 | NodeTopEntity.processTopEntityNode(intrface, xmlNode, parser); |
53 | ||
54 | 0 | NodeList nodes = xmlNode.getChildNodes(); |
55 | 0 | for (int i = 0; i < nodes.getLength(); i++) { |
56 | 0 | Node node = nodes.item(i); |
57 | ||
58 | 0 | if (node.getNodeType() == Node.ELEMENT_NODE |
59 | && node.getNodeName() == "nonFunctionalProperties") { | |
60 | 0 | NodeNFP.deserialize(intrface, node, parser); |
61 | } | |
62 | else { | |
63 | // TODO: Handle choreography and orchestration | |
64 | } | |
65 | } | |
66 | ||
67 | 0 | return intrface; |
68 | } | |
69 | ||
70 | 0 | static Element serialize(Interface intrface, WsmlXmlSerializer serializer) { |
71 | 0 | Element interfaceElement = serializer.createElement("interface"); |
72 | 0 | NodeTopEntity.serializeTopEntity(interfaceElement, intrface, serializer); |
73 | ||
74 | 0 | if (!intrface.listNFPValues().isEmpty()) { |
75 | 0 | NodeNFP.serialize(interfaceElement, intrface, serializer); |
76 | } | |
77 | ||
78 | //TODO: Handle choreography and orchestration | |
79 | ||
80 | 0 | return interfaceElement; |
81 | } | |
82 | } | |
83 | ||
84 | /* | |
85 | * $Log$ | |
86 | * Revision 1.2 2006/03/29 11:20:51 vassil_momtchev | |
87 | * mediator support added; some code refactored; minor bugs fixed | |
88 | * | |
89 | * Revision 1.1 2005/11/28 14:03:48 vassil_momtchev | |
90 | * package refactored from com.ontotext.wsmo4j.xmlparser to com.ontotext.wsmo4j.parser.xml | |
91 | * | |
92 | * Revision 1.4 2005/09/16 14:02:45 alex_simov | |
93 | * Identifier.asString() removed, use Object.toString() instead | |
94 | * (Implementations MUST override toString()) | |
95 | * | |
96 | * Revision 1.3 2005/08/08 08:24:40 vassil_momtchev | |
97 | * javadoc added, bugfixes | |
98 | * | |
99 | */ |
|