View Javadoc
1   /*
2    * Redistribution and use of this software and associated documentation
3    * ("Software"), with or without modification, are permitted provided
4    * that the following conditions are met:
5    *
6    * 1. Redistributions of source code must retain copyright
7    *    statements and notices.  Redistributions must also contain a
8    *    copy of this document.
9    *
10   * 2. Redistributions in binary form must reproduce the
11   *    above copyright notice, this list of conditions and the
12   *    following disclaimer in the documentation and/or other
13   *    materials provided with the distribution.
14   *
15   * 3. The name "Exolab" must not be used to endorse or promote
16   *    products derived from this Software without prior written
17   *    permission of Intalio, Inc.  For written permission,
18   *    please contact info@exolab.org.
19   *
20   * 4. Products derived from this Software may not be called "Exolab"
21   *    nor may "Exolab" appear in their names without prior written
22   *    permission of Intalio, Inc. Exolab is a registered
23   *    trademark of Intalio, Inc.
24   *
25   * 5. Due credit should be given to the Exolab Project
26   *    (http://www.exolab.org/).
27   *
28   * THIS SOFTWARE IS PROVIDED BY INTALIO, INC. AND CONTRIBUTORS
29   * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
30   * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
31   * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
32   * INTALIO, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
33   * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
34   * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
35   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
37   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
38   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
39   * OF THE POSSIBILITY OF SUCH DAMAGE.
40   *
41   * Copyright 1999-2004 (C) Intalio, Inc. All Rights Reserved.
42   *
43   * $Id$
44   */
45  package org.exolab.castor.xml.descriptors;
46  
47  import org.exolab.castor.mapping.AccessMode;
48  import org.exolab.castor.mapping.ClassDescriptor;
49  import org.exolab.castor.mapping.FieldDescriptor;
50  import org.exolab.castor.xml.NodeType;
51  import org.exolab.castor.xml.TypeValidator;
52  import org.exolab.castor.xml.XMLFieldDescriptor;
53  import org.exolab.castor.xml.validators.StringValidator;
54  
55  /**
56   * The default String class descriptor.
57   * @author <a href="mailto:kvisco-at-intalio.com">Keith Visco</a>
58   * @version $Revision$ $Date: 2004-12-16 22:49:25 -0700 (Thu, 16 Dec 2004) $
59   */
60  public class StringClassDescriptor extends BaseDescriptor {
61  
62      /** The set of element descriptors. */
63      private static final XMLFieldDescriptor[] NO_ELEMENTS   = new XMLFieldDescriptor[0];
64      /** The set of attribute descriptors. */
65      private static final XMLFieldDescriptor[] NO_ATTRIBUTES = new XMLFieldDescriptor[0];
66      /** The content descriptor. */
67      private static final XMLFieldDescriptor   NO_CONTENT    = null;
68      /** Our field descriptor array. Lists the fields we describe. */
69      private static final FieldDescriptor[]    NO_FIELDS     = new FieldDescriptor[0];
70  
71        //--------------------/
72       //- Member Variables -/
73      //--------------------/
74  
75      /** The XML name for the described object. */
76      private String                            _xmlName      = null;
77      /** The desired namespace for the described object. */
78      private String                            _nsURI        = null;
79      /** Type validator to use to validate an instance of this type. */
80      private StringValidator                   _validator    = null;
81  
82        //----------------/
83       //- Constructors -/
84      //----------------/
85  
86      /**
87       * No-arg constructor.
88       */
89      public StringClassDescriptor() {
90          super();
91      } //-- StringClassDescriptor()
92  
93        //-----------/
94       //- Methods -/
95      //-----------/
96  
97      /**
98       * Returns the set of attribute XMLFieldDescriptors.
99       *
100      * @return an array of XMLFieldDescriptors for all members that should be
101      *         marshaled as attributes
102      */
103     public XMLFieldDescriptor[] getAttributeDescriptors() {
104         return NO_ATTRIBUTES;
105     } //-- getAttributeDescriptors()
106 
107     /**
108      * Returns the Class that this ClassDescriptor describes.
109      * @return the Class that this ClassDescriptor describes.
110      */
111     public Class getJavaClass() {
112         return java.lang.String.class;
113     } //-- getClassType()
114 
115     /**
116      * Returns the set of element MarshalDescriptors.
117      *
118      * @return an array of MarshalDescriptors for all members that should be
119      *         marshaled as Elements
120      */
121     public XMLFieldDescriptor[] getElementDescriptors() {
122         return NO_ELEMENTS;
123     } //-- getElementDescriptors()
124 
125     /**
126      * Returns the class descriptor of the class extended by this class.
127      *
128      * @return The extended class descriptor
129      */
130     public ClassDescriptor getExtends() {
131         return null;
132     } //-- getExtends
133 
134     /**
135      * Returns a list of fields represented by this descriptor.
136      *
137      * @return A list of fields
138      */
139     public FieldDescriptor[] getFields() {
140         return NO_FIELDS;
141     } //-- getFields
142 
143     /**
144      * Returns the descriptor for dealing with Text content.
145      * @return the XMLFieldDescriptor for dealing with Text content
146      */
147     public XMLFieldDescriptor getContentDescriptor() {
148         return NO_CONTENT;
149     } //-- getContentDescriptor()
150 
151     /**
152      * Returns the XML field descriptor matching the given xml name and
153      * nodeType. If NodeType is null, then either an AttributeDescriptor, or
154      * ElementDescriptor may be returned. Null is returned if no matching
155      * descriptor is available.
156      *
157      * @param name the xml name to match against
158      * @param namespace the namespace uri
159      * @param nodeType the NodeType to match against, or null if the node type
160      *        is not known.
161      * @return the matching descriptor, or null if no matching descriptor is
162      *         available.
163      */
164     public XMLFieldDescriptor getFieldDescriptor(final String name,
165             final String namespace, final NodeType nodeType) {
166         return null;
167     } //-- getFieldDescriptor
168 
169     /**
170      * @return the namespace prefix to use when marshaling as XML.
171      */
172     public String getNameSpacePrefix() {
173         return null;
174     } //-- getNameSpacePrefix
175 
176     /**
177      * @return the namespace URI used when marshaling and unmarshaling as XML.
178      */
179     public String getNameSpaceURI() {
180         return _nsURI;
181     } //-- getNameSpaceURI
182 
183     /**
184      * Returns the identity field, null if this class has no identity.
185      *
186      * @return The identity field
187      */
188     public FieldDescriptor getIdentity() {
189         return null;
190     } //-- getIdentity
191 
192     /**
193      * Returns the access mode specified for this class.
194      *
195      * @return The access mode
196      */
197     public AccessMode getAccessMode() {
198         return null;
199     } //-- getAccessMode
200 
201     /**
202      * Returns a specific validator for the class described by this
203      * ClassDescriptor. A null value may be returned if no specific validator
204      * exists.
205      *
206      * @return the type validator for the class described by this
207      *         ClassDescriptor.
208      */
209     public TypeValidator getValidator() {
210         return _validator;
211     } //-- getValidator
212 
213     /**
214      * Returns the XML Name for the Class being described.
215      *
216      * @return the XML name.
217      */
218     public String getXMLName() {
219         return _xmlName;
220     } //-- getXMLName
221 
222     /**
223      * Sets the type validator to use to validate an instance of this type.
224      * @param validator the type validator to use.
225      */
226     public void setValidator(final StringValidator validator) {
227         this._validator = validator;
228     } //-- setValidator
229 
230     /**
231      * Sets the XML Name for the described object.
232      *
233      * @param xmlName the XML name to use for the described object.
234      */
235     public void setXMLName(final String xmlName) {
236         this._xmlName = xmlName;
237     } //-- setXMLName
238 
239     /**
240      * Sets the desired namespace URI for the described object.
241      *
242      * @param nsURI is the desired namespace URI
243      */
244     public void setNameSpaceURI(final String nsURI) {
245         this._nsURI = nsURI;
246     } //-- setNameSpaceURI
247 
248 } //-- StringMarshalInfo