KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * The Apache Software License, Version 1.1
3  *
4  *
5  * Copyright (c) 2002-2003 The Apache Software Foundation. All rights
6  * reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in
17  * the documentation and/or other materials provided with the
18  * distribution.
19  *
20  * 3. The end-user documentation included with the redistribution,
21  * if any, must include the following acknowledgment:
22  * "This product includes software developed by the
23  * Apache Software Foundation (http://www.apache.org/)."
24  * Alternately, this acknowledgment may appear in the software itself,
25  * if and wherever such third-party acknowledgments normally appear.
26  *
27  * 4. The names "Axis" and "Apache Software Foundation" must
28  * not be used to endorse or promote products derived from this
29  * software without prior written permission. For written
30  * permission, please contact apache@apache.org.
31  *
32  * 5. Products derived from this software may not be called "Apache",
33  * nor may "Apache" appear in their name, without prior written
34  * permission of the Apache Software Foundation.
35  *
36  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
37  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
38  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
39  * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
40  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
42  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
43  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
44  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
45  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
46  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47  * SUCH DAMAGE.
48  * ====================================================================
49  *
50  * This software consists of voluntary contributions made by many
51  * individuals on behalf of the Apache Software Foundation. For more
52  * information on the Apache Software Foundation, please see
53  * <http://www.apache.org/>.
54  */

55
56 package org.jboss.axis.description;
57
58 import javax.xml.namespace.QName JavaDoc;
59
60 /**
61  * FieldDescs are metadata objects which control the mapping of a given
62  * Java field to/from XML.
63  *
64  * @author Glen Daniels (gdaniels@apache.org)
65  */

66 public abstract class FieldDesc
67 {
68    /**
69     * The name of the Java field in question
70     */

71    private String JavaDoc fieldName;
72    /**
73     * The XML QName this field maps to
74     */

75    private QName JavaDoc xmlName;
76    /**
77     * The XML Type this field maps to/from
78     */

79    private QName JavaDoc xmlType;
80    /**
81     * The Java type of this field
82     */

83    private Class JavaDoc javaType;
84
85    /**
86     * An indication that minoccurs is zero
87     */

88    private boolean minOccursIs0 = false;
89
90    /**
91     * Obtain the field name.
92     */

93    public String JavaDoc getFieldName()
94    {
95       return fieldName;
96    }
97
98    /**
99     * Set the field name.
100     */

101    public void setFieldName(String JavaDoc fieldName)
102    {
103       this.fieldName = fieldName;
104    }
105
106    /**
107     * Obtain the XML QName for this field
108     */

109    public QName JavaDoc getXmlName()
110    {
111       return xmlName;
112    }
113
114    /**
115     * Set the XML QName for this field
116     */

117    public void setXmlName(QName JavaDoc xmlName)
118    {
119       this.xmlName = xmlName;
120    }
121
122    public Class JavaDoc getJavaType()
123    {
124       return javaType;
125    }
126
127    public void setJavaType(Class JavaDoc javaType)
128    {
129       this.javaType = javaType;
130    }
131
132    /**
133     * Returns the XML type (e.g. xsd:string) for this field
134     */

135    public QName JavaDoc getXmlType()
136    {
137       return xmlType;
138    }
139
140    /**
141     * Returns the XML type (e.g. xsd:string) for this field
142     */

143    public void setXmlType(QName JavaDoc xmlType)
144    {
145       this.xmlType = xmlType;
146    }
147
148    /**
149     * Check if this is an element
150     *
151     * @return true if this is an ElementDesc
152     */

153    public boolean isElement()
154    {
155       return (this instanceof ElementDesc);
156    }
157
158    /**
159     * Check if this is an attribute.
160     *
161     * @return true if an AttributeDesc
162     */

163    public boolean isAttribute()
164    {
165       return (this instanceof AttributeDesc);
166    }
167
168    public boolean isIndexed()
169    {
170       return false;
171    }
172
173    /**
174     * Check if this field can be omitted.
175     */

176    public boolean isMinOccursZero()
177    {
178       return minOccursIs0;
179    }
180
181    /**
182     * @param minOccursIs0
183     * @deprecated this functionality, which is only relevant to ElementDescs,
184     * now lives in ElementDesc and is more flexible (you can set
185     * minOccurs and maxOccurs as you please)
186     */

187    public void setMinOccursIs0(boolean minOccursIs0)
188    {
189       this.minOccursIs0 = minOccursIs0;
190    }
191 }
192
Popular Tags