KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > shark > xpdl > elements > DataTypes


1 package org.enhydra.shark.xpdl.elements;
2
3 import java.util.ArrayList JavaDoc;
4 import java.util.Iterator JavaDoc;
5
6 import org.enhydra.shark.xpdl.XMLBaseForCollectionAndComplex;
7 import org.enhydra.shark.xpdl.XMLComplexChoice;
8 import org.enhydra.shark.xpdl.XMLComplexElement;
9 import org.enhydra.shark.xpdl.XMLElement;
10
11 /**
12  * Represents coresponding element from XPDL schema.
13  *
14  * @author Sasa Bojanic
15  */

16 public class DataTypes extends XMLComplexChoice {
17
18    private boolean isInitialized=false;
19    
20    public DataTypes (XMLComplexElement parent) {
21       super(parent,"Type", true);
22       isInitialized=true;
23    }
24
25    protected void fillChoices () {
26       if (isInitialized) {
27          choices=new ArrayList JavaDoc();
28          choices.add(new BasicType(this));
29          choices.add(new DeclaredType(this));
30          choices.add(new SchemaType(this));
31          choices.add(new ExternalReference(this, true));
32          choices.add(new RecordType(this));
33          choices.add(new UnionType(this));
34          choices.add(new EnumerationType(this));
35          choices.add(new ArrayType(this));
36          choices.add(new ListType(this));
37          choosen=(XMLElement)choices.get(0);
38          setReadOnly(isReadOnly);
39          if (cachesInitialized) {
40             initCaches();
41          }
42       }
43    }
44    
45    public void setReadOnly (boolean ro) {
46       this.isReadOnly=ro;
47       if (choices==null) return;
48       super.setReadOnly(ro);
49    }
50
51    public void initCaches () {
52       if (choices!=null) {
53          super.initCaches();
54       } else {
55          cachesInitialized=true;
56       }
57    }
58
59    public void clearCaches () {
60       if (choices!=null) {
61          super.clearCaches();
62       } else {
63          cachesInitialized=false;
64       }
65    }
66    
67    public ArrayList JavaDoc getChoices () {
68       if (choices==null) {
69          fillChoices();
70       }
71       return choices;
72    }
73    
74    public XMLElement getChoosen () {
75       if (choosen==null) {
76          fillChoices();
77       }
78       return choosen;
79    }
80    
81    public BasicType getBasicType () {
82       return (BasicType)getChoices().get(0);
83    }
84
85    public void setBasicType () {
86       choosen=(BasicType)getChoices().get(0);
87    }
88    
89    public DeclaredType getDeclaredType () {
90       return (DeclaredType)getChoices().get(1);
91    }
92
93    public void setDeclaredType () {
94       choosen=(DeclaredType)getChoices().get(1);
95    }
96
97    public SchemaType getSchemaType () {
98       return (SchemaType)getChoices().get(2);
99    }
100
101    public void setSchemaType () {
102       choosen=(SchemaType)getChoices().get(2);
103    }
104
105    public ExternalReference getExternalReference () {
106       return (ExternalReference)getChoices().get(3);
107    }
108
109    public void setExternalReference () {
110       choosen=(ExternalReference)getChoices().get(3);
111    }
112    
113    public RecordType getRecordType () {
114       return (RecordType)getChoices().get(4);
115    }
116
117    public void setRecordType () {
118       choosen=(RecordType)getChoices().get(4);
119    }
120
121    public UnionType getUnionType () {
122       return (UnionType)getChoices().get(5);
123    }
124
125    public void setUnionType () {
126       choosen=(UnionType)getChoices().get(5);
127    }
128
129    public EnumerationType getEnumerationType () {
130       return (EnumerationType)getChoices().get(6);
131    }
132
133    public void setEnumerationType () {
134       choosen=(EnumerationType)getChoices().get(6);
135    }
136    
137    public ArrayType getArrayType () {
138       return (ArrayType)getChoices().get(7);
139    }
140
141    public void setArrayType () {
142       choosen=(ArrayType)getChoices().get(7);
143    }
144
145    public ListType getListType () {
146       return (ListType)getChoices().get(8);
147    }
148
149    public void setListType () {
150       choosen=(ListType)getChoices().get(8);
151    }
152    
153    public Object JavaDoc clone() {
154       DataTypes d = null;
155       if (choices!=null) {
156          d = (DataTypes) super.clone();
157          isInitialized = true;
158       } else {
159          d = new DataTypes((XMLComplexElement)this.parent);
160          d.isReadOnly = this.isReadOnly;
161       }
162       return d;
163    }
164    
165    public boolean equals (Object JavaDoc e) {
166       if (this == e)
167          return true;
168       if (e == null || !(e instanceof DataTypes)) return false;
169       DataTypes dt=(DataTypes)e;
170       if ((choices==null && dt.choices!=null) || (choices!=null && dt.choices==null)) return false;
171       if (choices!=null) {
172          return super.equals(e);
173       } else {
174          return true;
175       }
176    }
177    
178 }
179
180
Popular Tags