8bdde867c512e4fd7a0bd4aaefa581cb39e53ef6
[jalview.git] / src / jalview / schemabinding / version2 / descriptors / GroupDescriptor.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8)
3  * Copyright (C) 2012 J Procter, AM Waterhouse, LM Lui, J Engelhardt, G Barton, M Clamp, S Searle
4  * 
5  * This file is part of Jalview.
6  * 
7  * Jalview is free software: you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License 
9  * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
10  *  
11  * Jalview is distributed in the hope that it will be useful, but 
12  * WITHOUT ANY WARRANTY; without even the implied warranty 
13  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
14  * PURPOSE.  See the GNU General Public License for more details.
15  * 
16  * You should have received a copy of the GNU General Public License along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
17  */
18 package jalview.schemabinding.version2.descriptors;
19
20 //---------------------------------/
21 //- Imported classes and packages -/
22 //---------------------------------/
23
24 import jalview.schemabinding.version2.Group;
25
26 /**
27  * Class GroupDescriptor.
28  * 
29  * @version $Revision$ $Date$
30  */
31 public class GroupDescriptor extends
32         org.exolab.castor.xml.util.XMLClassDescriptorImpl
33 {
34
35   // --------------------------/
36   // - Class/Member Variables -/
37   // --------------------------/
38
39   /**
40    * Field _elementDefinition.
41    */
42   private boolean _elementDefinition;
43
44   /**
45    * Field _nsPrefix.
46    */
47   private java.lang.String _nsPrefix;
48
49   /**
50    * Field _nsURI.
51    */
52   private java.lang.String _nsURI;
53
54   /**
55    * Field _xmlName.
56    */
57   private java.lang.String _xmlName;
58
59   // ----------------/
60   // - Constructors -/
61   // ----------------/
62
63   public GroupDescriptor()
64   {
65     super();
66     _nsURI = "www.jalview.org";
67     _xmlName = "group";
68     _elementDefinition = true;
69     org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null;
70     org.exolab.castor.mapping.FieldHandler handler = null;
71     org.exolab.castor.xml.FieldValidator fieldValidator = null;
72     // -- initialize attribute descriptors
73
74     // -- _name
75     desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
76             java.lang.String.class, "_name", "name",
77             org.exolab.castor.xml.NodeType.Attribute);
78     desc.setImmutable(true);
79     handler = new org.exolab.castor.xml.XMLFieldHandler()
80     {
81       public java.lang.Object getValue(java.lang.Object object)
82               throws IllegalStateException
83       {
84         Group target = (Group) object;
85         return target.getName();
86       }
87
88       public void setValue(java.lang.Object object, java.lang.Object value)
89               throws IllegalStateException, IllegalArgumentException
90       {
91         try
92         {
93           Group target = (Group) object;
94           target.setName((java.lang.String) value);
95         } catch (java.lang.Exception ex)
96         {
97           throw new IllegalStateException(ex.toString());
98         }
99       }
100
101       public java.lang.Object newInstance(java.lang.Object parent)
102       {
103         return null;
104       }
105     };
106     desc.setHandler(handler);
107     desc.setRequired(true);
108     desc.setMultivalued(false);
109     addFieldDescriptor(desc);
110
111     // -- validation code for: _name
112     fieldValidator = new org.exolab.castor.xml.FieldValidator();
113     fieldValidator.setMinOccurs(1);
114     { // -- local scope
115       org.exolab.castor.xml.validators.StringValidator typeValidator;
116       typeValidator = new org.exolab.castor.xml.validators.StringValidator();
117       fieldValidator.setValidator(typeValidator);
118       typeValidator.setWhiteSpace("preserve");
119     }
120     desc.setValidator(fieldValidator);
121     // -- _display
122     desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
123             java.lang.Boolean.TYPE, "_display", "display",
124             org.exolab.castor.xml.NodeType.Attribute);
125     handler = new org.exolab.castor.xml.XMLFieldHandler()
126     {
127       public java.lang.Object getValue(java.lang.Object object)
128               throws IllegalStateException
129       {
130         Group target = (Group) object;
131         if (!target.hasDisplay())
132         {
133           return null;
134         }
135         return (target.getDisplay() ? java.lang.Boolean.TRUE
136                 : java.lang.Boolean.FALSE);
137       }
138
139       public void setValue(java.lang.Object object, java.lang.Object value)
140               throws IllegalStateException, IllegalArgumentException
141       {
142         try
143         {
144           Group target = (Group) object;
145           // ignore null values for non optional primitives
146           if (value == null)
147           {
148             return;
149           }
150
151           target.setDisplay(((java.lang.Boolean) value).booleanValue());
152         } catch (java.lang.Exception ex)
153         {
154           throw new IllegalStateException(ex.toString());
155         }
156       }
157
158       public java.lang.Object newInstance(java.lang.Object parent)
159       {
160         return null;
161       }
162     };
163     desc.setHandler(handler);
164     desc.setRequired(true);
165     desc.setMultivalued(false);
166     addFieldDescriptor(desc);
167
168     // -- validation code for: _display
169     fieldValidator = new org.exolab.castor.xml.FieldValidator();
170     fieldValidator.setMinOccurs(1);
171     { // -- local scope
172       org.exolab.castor.xml.validators.BooleanValidator typeValidator;
173       typeValidator = new org.exolab.castor.xml.validators.BooleanValidator();
174       fieldValidator.setValidator(typeValidator);
175     }
176     desc.setValidator(fieldValidator);
177     // -- initialize element descriptors
178
179   }
180
181   // -----------/
182   // - Methods -/
183   // -----------/
184
185   /**
186    * Method getAccessMode.
187    * 
188    * @return the access mode specified for this class.
189    */
190   public org.exolab.castor.mapping.AccessMode getAccessMode()
191   {
192     return null;
193   }
194
195   /**
196    * Method getIdentity.
197    * 
198    * @return the identity field, null if this class has no identity.
199    */
200   public org.exolab.castor.mapping.FieldDescriptor getIdentity()
201   {
202     return super.getIdentity();
203   }
204
205   /**
206    * Method getJavaClass.
207    * 
208    * @return the Java class represented by this descriptor.
209    */
210   public java.lang.Class getJavaClass()
211   {
212     return jalview.schemabinding.version2.Group.class;
213   }
214
215   /**
216    * Method getNameSpacePrefix.
217    * 
218    * @return the namespace prefix to use when marshaling as XML.
219    */
220   public java.lang.String getNameSpacePrefix()
221   {
222     return _nsPrefix;
223   }
224
225   /**
226    * Method getNameSpaceURI.
227    * 
228    * @return the namespace URI used when marshaling and unmarshaling as XML.
229    */
230   public java.lang.String getNameSpaceURI()
231   {
232     return _nsURI;
233   }
234
235   /**
236    * Method getValidator.
237    * 
238    * @return a specific validator for the class described by this
239    *         ClassDescriptor.
240    */
241   public org.exolab.castor.xml.TypeValidator getValidator()
242   {
243     return this;
244   }
245
246   /**
247    * Method getXMLName.
248    * 
249    * @return the XML Name for the Class being described.
250    */
251   public java.lang.String getXMLName()
252   {
253     return _xmlName;
254   }
255
256   /**
257    * Method isElementDefinition.
258    * 
259    * @return true if XML schema definition of this Class is that of a global
260    *         element or element with anonymous type definition.
261    */
262   public boolean isElementDefinition()
263   {
264     return _elementDefinition;
265   }
266
267 }