KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis > description > FieldDesc


1 /*
2  * Copyright 2002-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.axis.description;
18
19 import javax.xml.namespace.QName JavaDoc;
20 import java.io.Serializable JavaDoc;
21
22 /**
23  * FieldDescs are metadata objects which control the mapping of a given
24  * Java field to/from XML.
25  *
26  * @author Glen Daniels (gdaniels@apache.org)
27  */

28 public class FieldDesc implements Serializable JavaDoc {
29     /** The name of the Java field in question */
30     private String JavaDoc fieldName;
31     /** The XML QName this field maps to */
32     private QName JavaDoc xmlName;
33     /** The XML Type this field maps to/from */
34     private QName JavaDoc xmlType;
35     /** The Java type of this field */
36     private Class JavaDoc javaType;
37
38     /** An indication of whether this should be an element or an attribute */
39     // Q : should this be a boolean, or just "instanceof ElementDesc", etc.
40
private boolean _isElement = true;
41
42     /** An indication that minoccurs is zero */
43     private boolean minOccursIs0 = false;
44     
45     /**
46      * Can't construct the base class directly, must construct either an
47      * ElementDesc or an AttributeDesc.
48      */

49     protected FieldDesc(boolean isElement)
50     {
51         _isElement = isElement;
52     }
53
54     /**
55      * Obtain the field name.
56      */

57     public String JavaDoc getFieldName() {
58         return fieldName;
59     }
60
61     /**
62      * Set the field name.
63      */

64     public void setFieldName(String JavaDoc fieldName) {
65         this.fieldName = fieldName;
66     }
67
68     /**
69      * Obtain the XML QName for this field
70      */

71     public QName JavaDoc getXmlName() {
72         return xmlName;
73     }
74
75     /**
76      * Set the XML QName for this field
77      */

78     public void setXmlName(QName JavaDoc xmlName) {
79         this.xmlName = xmlName;
80     }
81
82     public Class JavaDoc getJavaType() {
83         return javaType;
84     }
85
86     public void setJavaType(Class JavaDoc javaType) {
87         this.javaType = javaType;
88     }
89
90     /**
91      * Returns the XML type (e.g. xsd:string) for this field
92      */

93     public QName JavaDoc getXmlType() {
94         return xmlType;
95     }
96
97     /**
98      * Returns the XML type (e.g. xsd:string) for this field
99      */

100     public void setXmlType(QName JavaDoc xmlType) {
101         this.xmlType = xmlType;
102     }
103
104     /**
105      * Check if this is an element or an attribute.
106      *
107      * @return true if this is an ElementDesc, or false if an AttributeDesc
108      */

109     public boolean isElement() {
110         return _isElement;
111     }
112
113     public boolean isIndexed() {
114         return false;
115     }
116
117     /**
118      * Check if this field can be omitted.
119      */

120     public boolean isMinOccursZero() {
121         return minOccursIs0;
122     }
123
124     /**
125      *
126      *
127      * @param minOccursIs0
128      * @deprecated this functionality, which is only relevant to ElementDescs,
129      * now lives in ElementDesc and is more flexible (you can set
130      * minOccurs and maxOccurs as you please)
131      */

132     public void setMinOccursIs0(boolean minOccursIs0) {
133         this.minOccursIs0 = minOccursIs0;
134     }
135 }
136
Popular Tags