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