KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > schema2beansdev > beangraph > SchemaTypeMappingType


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Code is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 /**
20  * This generated bean class SchemaTypeMappingType
21  * matches the schema element 'schemaTypeMappingType'.
22  * The root bean class is BeanGraph
23  *
24  * ===============================================================
25  *
26  * Map between schema types and java types.
27  *
28  * ===============================================================
29  * @Generated
30  */

31
32 package org.netbeans.modules.schema2beansdev.beangraph;
33
34 public class SchemaTypeMappingType implements org.netbeans.modules.schema2beansdev.beangraph.CommonBean {
35     public static final String JavaDoc SCHEMA_TYPE_NAMESPACE = "SchemaTypeNamespace"; // NOI18N
36
public static final String JavaDoc SCHEMA_TYPE_NAME = "SchemaTypeName"; // NOI18N
37
public static final String JavaDoc JAVA_TYPE = "JavaType"; // NOI18N
38
public static final String JavaDoc ROOT = "Root"; // NOI18N
39
public static final String JavaDoc BEAN = "Bean"; // NOI18N
40
public static final String JavaDoc CAN_BE_EMPTY = "CanBeEmpty"; // NOI18N
41

42     private java.lang.String JavaDoc _SchemaTypeNamespace;
43     private java.lang.String JavaDoc _SchemaTypeName;
44     private java.lang.String JavaDoc _JavaType;
45     private boolean _Root;
46     private boolean _isSet_Root = false;
47     private boolean _Bean;
48     private boolean _isSet_Bean = false;
49     private boolean _CanBeEmpty;
50     private boolean _isSet_CanBeEmpty = false;
51
52     /**
53      * Normal starting point constructor.
54      */

55     public SchemaTypeMappingType() {
56         _SchemaTypeName = "";
57         _JavaType = "";
58     }
59
60     /**
61      * Required parameters constructor
62      */

63     public SchemaTypeMappingType(java.lang.String JavaDoc schemaTypeName, java.lang.String JavaDoc javaType) {
64         _SchemaTypeName = schemaTypeName;
65         _JavaType = javaType;
66     }
67
68     /**
69      * Deep copy
70      */

71     public SchemaTypeMappingType(org.netbeans.modules.schema2beansdev.beangraph.SchemaTypeMappingType source) {
72         this(source, false);
73     }
74
75     /**
76      * Deep copy
77      * @param justData just copy the XML relevant data
78      */

79     public SchemaTypeMappingType(org.netbeans.modules.schema2beansdev.beangraph.SchemaTypeMappingType source, boolean justData) {
80         _SchemaTypeNamespace = source._SchemaTypeNamespace;
81         _SchemaTypeName = source._SchemaTypeName;
82         _JavaType = source._JavaType;
83         _Root = source._Root;
84         _isSet_Root = source._isSet_Root;
85         _Bean = source._Bean;
86         _isSet_Bean = source._isSet_Bean;
87         _CanBeEmpty = source._CanBeEmpty;
88         _isSet_CanBeEmpty = source._isSet_CanBeEmpty;
89     }
90
91     // This attribute is optional
92
public void setSchemaTypeNamespace(java.lang.String JavaDoc value) {
93         _SchemaTypeNamespace = value;
94     }
95
96     public java.lang.String JavaDoc getSchemaTypeNamespace() {
97         return _SchemaTypeNamespace;
98     }
99
100     // This attribute is mandatory
101
public void setSchemaTypeName(java.lang.String JavaDoc value) {
102         _SchemaTypeName = value;
103     }
104
105     public java.lang.String JavaDoc getSchemaTypeName() {
106         return _SchemaTypeName;
107     }
108
109     // This attribute is mandatory
110
public void setJavaType(java.lang.String JavaDoc value) {
111         _JavaType = value;
112     }
113
114     public java.lang.String JavaDoc getJavaType() {
115         return _JavaType;
116     }
117
118     // This attribute is optional
119
public void setRoot(boolean value) {
120         _Root = value;
121         _isSet_Root = true;
122     }
123
124     public boolean isRoot() {
125         return _Root;
126     }
127
128     // This attribute is optional
129
public void setBean(boolean value) {
130         _Bean = value;
131         _isSet_Bean = true;
132     }
133
134     public boolean isBean() {
135         return _Bean;
136     }
137
138     // This attribute is optional
139
public void setCanBeEmpty(boolean value) {
140         _CanBeEmpty = value;
141         _isSet_CanBeEmpty = true;
142     }
143
144     public boolean isCanBeEmpty() {
145         return _CanBeEmpty;
146     }
147
148     public void writeNode(java.io.Writer JavaDoc out) throws java.io.IOException JavaDoc {
149         String JavaDoc myName;
150         myName = "schemaTypeMappingType";
151         writeNode(out, myName, ""); // NOI18N
152
}
153
154     public void writeNode(java.io.Writer JavaDoc out, String JavaDoc nodeName, String JavaDoc indent) throws java.io.IOException JavaDoc {
155         writeNode(out, nodeName, null, indent, new java.util.HashMap JavaDoc());
156     }
157
158     /**
159      * It's not recommended to call this method directly.
160      */

161     public void writeNode(java.io.Writer JavaDoc out, String JavaDoc nodeName, String JavaDoc namespace, String JavaDoc indent, java.util.Map JavaDoc namespaceMap) throws java.io.IOException JavaDoc {
162         out.write(indent);
163         out.write("<");
164         if (namespace != null) {
165             out.write((String JavaDoc)namespaceMap.get(namespace));
166             out.write(":");
167         }
168         out.write(nodeName);
169         out.write(">\n");
170         String JavaDoc nextIndent = indent + " ";
171         if (_SchemaTypeNamespace != null) {
172             out.write(nextIndent);
173             out.write("<schema-type-namespace"); // NOI18N
174
out.write(">"); // NOI18N
175
org.netbeans.modules.schema2beansdev.beangraph.BeanGraph.writeXML(out, _SchemaTypeNamespace, false);
176             out.write("</schema-type-namespace>\n"); // NOI18N
177
}
178         if (_SchemaTypeName != null) {
179             out.write(nextIndent);
180             out.write("<schema-type-name"); // NOI18N
181
out.write(">"); // NOI18N
182
org.netbeans.modules.schema2beansdev.beangraph.BeanGraph.writeXML(out, _SchemaTypeName, false);
183             out.write("</schema-type-name>\n"); // NOI18N
184
}
185         if (_JavaType != null) {
186             out.write(nextIndent);
187             out.write("<java-type"); // NOI18N
188
out.write(">"); // NOI18N
189
org.netbeans.modules.schema2beansdev.beangraph.BeanGraph.writeXML(out, _JavaType, false);
190             out.write("</java-type>\n"); // NOI18N
191
}
192         if (_isSet_Root) {
193             out.write(nextIndent);
194             out.write("<root"); // NOI18N
195
out.write(">"); // NOI18N
196
out.write(_Root ? "true" : "false");
197             out.write("</root>\n"); // NOI18N
198
}
199         if (_isSet_Bean) {
200             out.write(nextIndent);
201             out.write("<bean"); // NOI18N
202
out.write(">"); // NOI18N
203
out.write(_Bean ? "true" : "false");
204             out.write("</bean>\n"); // NOI18N
205
}
206         if (_isSet_CanBeEmpty) {
207             out.write(nextIndent);
208             out.write("<can-be-empty"); // NOI18N
209
out.write(">"); // NOI18N
210
out.write(_CanBeEmpty ? "true" : "false");
211             out.write("</can-be-empty>\n"); // NOI18N
212
}
213         out.write(indent);
214         out.write("</");
215         if (namespace != null) {
216             out.write((String JavaDoc)namespaceMap.get(namespace));
217             out.write(":");
218         }
219         out.write(nodeName);
220         out.write(">\n");
221     }
222
223     public void readNode(org.w3c.dom.Node JavaDoc node) {
224         readNode(node, new java.util.HashMap JavaDoc());
225     }
226
227     public void readNode(org.w3c.dom.Node JavaDoc node, java.util.Map JavaDoc namespacePrefixes) {
228         if (node.hasAttributes()) {
229             org.w3c.dom.NamedNodeMap JavaDoc attrs = node.getAttributes();
230             org.w3c.dom.Attr JavaDoc attr;
231             java.lang.String JavaDoc attrValue;
232             boolean firstNamespaceDef = true;
233             for (int attrNum = 0; attrNum < attrs.getLength(); ++attrNum) {
234                 attr = (org.w3c.dom.Attr JavaDoc) attrs.item(attrNum);
235                 String JavaDoc attrName = attr.getName();
236                 if (attrName.startsWith("xmlns:")) {
237                     if (firstNamespaceDef) {
238                         firstNamespaceDef = false;
239                         // Dup prefix map, so as to not write over previous values, and to make it easy to clear out our entries.
240
namespacePrefixes = new java.util.HashMap JavaDoc(namespacePrefixes);
241                     }
242                     String JavaDoc attrNSPrefix = attrName.substring(6, attrName.length());
243                     namespacePrefixes.put(attrNSPrefix, attr.getValue());
244                 }
245             }
246         }
247         org.w3c.dom.NodeList JavaDoc children = node.getChildNodes();
248         for (int i = 0, size = children.getLength(); i < size; ++i) {
249             org.w3c.dom.Node JavaDoc childNode = children.item(i);
250             String JavaDoc childNodeName = (childNode.getLocalName() == null ? childNode.getNodeName().intern() : childNode.getLocalName().intern());
251             String JavaDoc childNodeValue = "";
252             if (childNode.getFirstChild() != null) {
253                 childNodeValue = childNode.getFirstChild().getNodeValue();
254             }
255             if (childNodeName == "schema-type-namespace") {
256                 _SchemaTypeNamespace = childNodeValue;
257             }
258             else if (childNodeName == "schema-type-name") {
259                 _SchemaTypeName = childNodeValue;
260             }
261             else if (childNodeName == "java-type") {
262                 _JavaType = childNodeValue;
263             }
264             else if (childNodeName == "root") {
265                 if (childNode.getFirstChild() == null)
266                     _Root = true;
267                 else
268                     _Root = java.lang.Boolean.valueOf(childNodeValue).booleanValue();
269                 _isSet_Root = true;
270             }
271             else if (childNodeName == "bean") {
272                 if (childNode.getFirstChild() == null)
273                     _Bean = true;
274                 else
275                     _Bean = java.lang.Boolean.valueOf(childNodeValue).booleanValue();
276                 _isSet_Bean = true;
277             }
278             else if (childNodeName == "can-be-empty") {
279                 if (childNode.getFirstChild() == null)
280                     _CanBeEmpty = true;
281                 else
282                     _CanBeEmpty = java.lang.Boolean.valueOf(childNodeValue).booleanValue();
283                 _isSet_CanBeEmpty = true;
284             }
285             else {
286                 // Found extra unrecognized childNode
287
}
288         }
289     }
290
291     public void validate() throws org.netbeans.modules.schema2beansdev.beangraph.BeanGraph.ValidateException {
292         boolean restrictionFailure = false;
293         boolean restrictionPassed = false;
294         // Validating property schemaTypeNamespace
295
// Validating property schemaTypeName
296
if (getSchemaTypeName() == null) {
297             throw new org.netbeans.modules.schema2beansdev.beangraph.BeanGraph.ValidateException("getSchemaTypeName() == null", org.netbeans.modules.schema2beansdev.beangraph.BeanGraph.ValidateException.FailureType.NULL_VALUE, "schemaTypeName", this); // NOI18N
298
}
299         // Validating property javaType
300
if (getJavaType() == null) {
301             throw new org.netbeans.modules.schema2beansdev.beangraph.BeanGraph.ValidateException("getJavaType() == null", org.netbeans.modules.schema2beansdev.beangraph.BeanGraph.ValidateException.FailureType.NULL_VALUE, "javaType", this); // NOI18N
302
}
303         // Validating property root
304
// Validating property bean
305
// Validating property canBeEmpty
306
}
307
308     public void changePropertyByName(String JavaDoc name, Object JavaDoc value) {
309         if (name == null) return;
310         name = name.intern();
311         if (name == "schemaTypeNamespace")
312             setSchemaTypeNamespace((java.lang.String JavaDoc)value);
313         else if (name == "schemaTypeName")
314             setSchemaTypeName((java.lang.String JavaDoc)value);
315         else if (name == "javaType")
316             setJavaType((java.lang.String JavaDoc)value);
317         else if (name == "root")
318             setRoot(((java.lang.Boolean JavaDoc)value).booleanValue());
319         else if (name == "bean")
320             setBean(((java.lang.Boolean JavaDoc)value).booleanValue());
321         else if (name == "canBeEmpty")
322             setCanBeEmpty(((java.lang.Boolean JavaDoc)value).booleanValue());
323         else
324             throw new IllegalArgumentException JavaDoc(name+" is not a valid property name for SchemaTypeMappingType");
325     }
326
327     public Object JavaDoc fetchPropertyByName(String JavaDoc name) {
328         if (name == "schemaTypeNamespace")
329             return getSchemaTypeNamespace();
330         if (name == "schemaTypeName")
331             return getSchemaTypeName();
332         if (name == "javaType")
333             return getJavaType();
334         if (name == "root")
335             return (isRoot() ? java.lang.Boolean.TRUE : java.lang.Boolean.FALSE);
336         if (name == "bean")
337             return (isBean() ? java.lang.Boolean.TRUE : java.lang.Boolean.FALSE);
338         if (name == "canBeEmpty")
339             return (isCanBeEmpty() ? java.lang.Boolean.TRUE : java.lang.Boolean.FALSE);
340         throw new IllegalArgumentException JavaDoc(name+" is not a valid property name for SchemaTypeMappingType");
341     }
342
343     public String JavaDoc nameSelf() {
344         return "SchemaTypeMappingType";
345     }
346
347     public String JavaDoc nameChild(Object JavaDoc childObj) {
348         return nameChild(childObj, false, false);
349     }
350
351     /**
352      * @param childObj The child object to search for
353      * @param returnSchemaName Whether or not the schema name should be returned or the property name
354      * @return null if not found
355      */

356     public String JavaDoc nameChild(Object JavaDoc childObj, boolean returnConstName, boolean returnSchemaName) {
357         return nameChild(childObj, returnConstName, returnSchemaName, false);
358     }
359
360     /**
361      * @param childObj The child object to search for
362      * @param returnSchemaName Whether or not the schema name should be returned or the property name
363      * @return null if not found
364      */

365     public String JavaDoc nameChild(Object JavaDoc childObj, boolean returnConstName, boolean returnSchemaName, boolean returnXPathName) {
366         if (childObj instanceof java.lang.String JavaDoc) {
367             java.lang.String JavaDoc child = (java.lang.String JavaDoc) childObj;
368             if (child == _SchemaTypeNamespace) {
369                 if (returnConstName) {
370                     return SCHEMA_TYPE_NAMESPACE;
371                 } else if (returnSchemaName) {
372                     return "schema-type-namespace";
373                 } else if (returnXPathName) {
374                     return "schema-type-namespace";
375                 } else {
376                     return "SchemaTypeNamespace";
377                 }
378             }
379             if (child == _SchemaTypeName) {
380                 if (returnConstName) {
381                     return SCHEMA_TYPE_NAME;
382                 } else if (returnSchemaName) {
383                     return "schema-type-name";
384                 } else if (returnXPathName) {
385                     return "schema-type-name";
386                 } else {
387                     return "SchemaTypeName";
388                 }
389             }
390             if (child == _JavaType) {
391                 if (returnConstName) {
392                     return JAVA_TYPE;
393                 } else if (returnSchemaName) {
394                     return "java-type";
395                 } else if (returnXPathName) {
396                     return "java-type";
397                 } else {
398                     return "JavaType";
399                 }
400             }
401         }
402         if (childObj instanceof java.lang.Boolean JavaDoc) {
403             java.lang.Boolean JavaDoc child = (java.lang.Boolean JavaDoc) childObj;
404             if (((java.lang.Boolean JavaDoc)child).booleanValue() == _Root) {
405                 if (returnConstName) {
406                     return ROOT;
407                 } else if (returnSchemaName) {
408                     return "root";
409                 } else if (returnXPathName) {
410                     return "root";
411                 } else {
412                     return "Root";
413                 }
414             }
415             if (((java.lang.Boolean JavaDoc)child).booleanValue() == _Bean) {
416                 if (returnConstName) {
417                     return BEAN;
418                 } else if (returnSchemaName) {
419                     return "bean";
420                 } else if (returnXPathName) {
421                     return "bean";
422                 } else {
423                     return "Bean";
424                 }
425             }
426             if (((java.lang.Boolean JavaDoc)child).booleanValue() == _CanBeEmpty) {
427                 if (returnConstName) {
428                     return CAN_BE_EMPTY;
429                 } else if (returnSchemaName) {
430                     return "can-be-empty";
431                 } else if (returnXPathName) {
432                     return "can-be-empty";
433                 } else {
434                     return "CanBeEmpty";
435                 }
436             }
437         }
438         return null;
439     }
440
441     /**
442      * Return an array of all of the properties that are beans and are set.
443      */

444     public org.netbeans.modules.schema2beansdev.beangraph.CommonBean[] childBeans(boolean recursive) {
445         java.util.List JavaDoc children = new java.util.LinkedList JavaDoc();
446         childBeans(recursive, children);
447         org.netbeans.modules.schema2beansdev.beangraph.CommonBean[] result = new org.netbeans.modules.schema2beansdev.beangraph.CommonBean[children.size()];
448         return (org.netbeans.modules.schema2beansdev.beangraph.CommonBean[]) children.toArray(result);
449     }
450
451     /**
452      * Put all child beans into the beans list.
453      */

454     public void childBeans(boolean recursive, java.util.List JavaDoc beans) {
455     }
456
457     public boolean equals(Object JavaDoc o) {
458         return o instanceof org.netbeans.modules.schema2beansdev.beangraph.SchemaTypeMappingType && equals((org.netbeans.modules.schema2beansdev.beangraph.SchemaTypeMappingType) o);
459     }
460
461     public boolean equals(org.netbeans.modules.schema2beansdev.beangraph.SchemaTypeMappingType inst) {
462         if (inst == this) {
463             return true;
464         }
465         if (inst == null) {
466             return false;
467         }
468         if (!(_SchemaTypeNamespace == null ? inst._SchemaTypeNamespace == null : _SchemaTypeNamespace.equals(inst._SchemaTypeNamespace))) {
469             return false;
470         }
471         if (!(_SchemaTypeName == null ? inst._SchemaTypeName == null : _SchemaTypeName.equals(inst._SchemaTypeName))) {
472             return false;
473         }
474         if (!(_JavaType == null ? inst._JavaType == null : _JavaType.equals(inst._JavaType))) {
475             return false;
476         }
477         if (_isSet_Root != inst._isSet_Root) {
478             return false;
479         }
480         if (_isSet_Root) {
481             if (!(_Root == inst._Root)) {
482                 return false;
483             }
484         }
485         if (_isSet_Bean != inst._isSet_Bean) {
486             return false;
487         }
488         if (_isSet_Bean) {
489             if (!(_Bean == inst._Bean)) {
490                 return false;
491             }
492         }
493         if (_isSet_CanBeEmpty != inst._isSet_CanBeEmpty) {
494             return false;
495         }
496         if (_isSet_CanBeEmpty) {
497             if (!(_CanBeEmpty == inst._CanBeEmpty)) {
498                 return false;
499             }
500         }
501         return true;
502     }
503
504     public int hashCode() {
505         int result = 17;
506         result = 37*result + (_SchemaTypeNamespace == null ? 0 : _SchemaTypeNamespace.hashCode());
507         result = 37*result + (_SchemaTypeName == null ? 0 : _SchemaTypeName.hashCode());
508         result = 37*result + (_JavaType == null ? 0 : _JavaType.hashCode());
509         result = 37*result + (_isSet_Root ? 0 : (_Root ? 0 : 1));
510         result = 37*result + (_isSet_Bean ? 0 : (_Bean ? 0 : 1));
511         result = 37*result + (_isSet_CanBeEmpty ? 0 : (_CanBeEmpty ? 0 : 1));
512         return result;
513     }
514
515     public String JavaDoc toString() {
516         java.io.StringWriter JavaDoc sw = new java.io.StringWriter JavaDoc();
517         try {
518             writeNode(sw);
519         } catch (java.io.IOException JavaDoc e) {
520             // How can we actually get an IOException on a StringWriter?
521
throw new RuntimeException JavaDoc(e);
522         }
523         return sw.toString();
524     }
525
526 }
527
528
529 /*
530         The following schema file has been used for generation:
531
532 <?xml version="1.0" ?>
533
534 <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
535   <xsd:element name="bean-graph">
536     <xsd:complexType>
537       <xsd:sequence>
538         <xsd:element name="schema-type-mapping" type="schemaTypeMappingType"
539           minOccurs="0" maxOccurs="unbounded"/>
540       </xsd:sequence>
541     </xsd:complexType>
542   </xsd:element>
543
544   <xsd:complexType name="schemaTypeMappingType">
545     <xsd:annotation>
546       <xsd:documentation>
547         Map between schema types and java types.
548       </xsd:documentation>
549     </xsd:annotation>
550     <xsd:sequence>
551       <xsd:element name="schema-type-namespace" type="xsd:string" minOccurs="0"/>
552       <xsd:element name="schema-type-name" type="xsd:string">
553         <xsd:annotation>
554           <xsd:documentation>
555             The schema type; for instance, "string"
556           </xsd:documentation>
557         </xsd:annotation>
558       </xsd:element>
559       <xsd:element name="java-type" type="xsd:string">
560         <xsd:annotation>
561           <xsd:documentation>
562             The java type; for instance, "java.lang.String", or "int"
563           </xsd:documentation>
564         </xsd:annotation>
565       </xsd:element>
566       <xsd:element name="root" type="xsd:boolean" minOccurs="0"/>
567       <xsd:element name="bean" type="xsd:boolean" minOccurs="0"/>
568       <xsd:element name="can-be-empty" type="xsd:boolean" minOccurs="0"/>
569     </xsd:sequence>
570   </xsd:complexType>
571 </xsd:schema>
572
573 */

574
Popular Tags