]> gerrit.simantics Code Review - simantics/interop.git/blob - org.simantics.xml.sax/src/org/simantics/xml/sax/SchemaElement.java
XML Schema converter
[simantics/interop.git] / org.simantics.xml.sax / src / org / simantics / xml / sax / SchemaElement.java
1 package org.simantics.xml.sax;\r
2 \r
3 import org.w3._2001.xmlschema.Any;\r
4 import org.w3._2001.xmlschema.Element;\r
5 import org.w3._2001.xmlschema.Group;\r
6 \r
7 public class SchemaElement {\r
8 \r
9         public enum ElementType{CHOICE,SEQUENCE,ALL,ANY,ELEMENT}\r
10 \r
11         private Group gelement;\r
12         private Any aelement;\r
13         private Element eelement;\r
14         private MultiplicityRestriction restriction;\r
15         private SchemaElement.ElementType type;\r
16         \r
17         private SchemaElement parent;\r
18         \r
19         public SchemaElement(Group element, ElementType indicator) {\r
20                 this.gelement = element;\r
21                 this.type = indicator;\r
22                 this.restriction = new MultiplicityRestriction(element);\r
23         }\r
24         \r
25         public SchemaElement(Any element, ElementType indicator) {\r
26                 this.aelement = element;\r
27                 this.type = indicator;\r
28                 this.restriction = new MultiplicityRestriction(element);\r
29         }\r
30         \r
31         public SchemaElement(Element element, ElementType indicator) {\r
32                 this.eelement = element;\r
33                 this.type = indicator;\r
34                 this.restriction = new MultiplicityRestriction(element);\r
35         }\r
36         \r
37         public SchemaElement(SchemaElement parent, Group element, ElementType indicator) {\r
38                 this.parent = parent;\r
39                 this.gelement = element;\r
40                 this.type = indicator;\r
41                 this.restriction = new MultiplicityRestriction(element);\r
42         }\r
43         \r
44         public SchemaElement(SchemaElement parent, Any element, ElementType indicator) {\r
45                 this.parent = parent;\r
46                 this.aelement = element;\r
47                 this.type = indicator;\r
48                 this.restriction = new MultiplicityRestriction(element);\r
49         }\r
50         \r
51         public SchemaElement(SchemaElement parent, Element element, ElementType indicator) {\r
52                 this.parent = parent;\r
53                 this.eelement = element;\r
54                 this.type = indicator;\r
55                 this.restriction = new MultiplicityRestriction(element);\r
56         }\r
57         \r
58         public Group getGroup() {\r
59                 return gelement;\r
60         }\r
61         \r
62         public Any getAny() {\r
63                 return aelement;\r
64         }\r
65         \r
66         public Element getElement() {\r
67                 return eelement;\r
68         }\r
69         \r
70         public MultiplicityRestriction getRestriction() {\r
71                 return restriction;\r
72         }\r
73         \r
74         public ElementType getType() {\r
75                 return type;\r
76         }\r
77         \r
78         public SchemaElement getParent() {\r
79                 return parent;\r
80         }\r
81         \r
82         \r
83         public boolean order() {\r
84                 if (type == ElementType.ELEMENT) {\r
85                         if (restriction.many())\r
86                                 return true;\r
87                         return false;\r
88                 }\r
89                 if (type == ElementType.SEQUENCE)\r
90                         return true;\r
91                 return false;\r
92         }\r
93         \r
94         public boolean many() {\r
95                 if (restriction.many())\r
96                         return true;\r
97                 if (parent != null)\r
98                         return parent.many();\r
99                 return false;\r
100         }\r
101         \r
102 }\r