2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
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
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.schemabinding.version2.descriptors;
23 //---------------------------------/
24 //- Imported classes and packages -/
25 //---------------------------------/
27 import jalview.schemabinding.version2.Property;
30 * Class PropertyDescriptor.
32 * @version $Revision$ $Date$
34 public class PropertyDescriptor extends org.exolab.castor.xml.util.XMLClassDescriptorImpl {
37 //--------------------------/
38 //- Class/Member Variables -/
39 //--------------------------/
42 * Field _elementDefinition.
44 private boolean _elementDefinition;
49 private java.lang.String _nsPrefix;
54 private java.lang.String _nsURI;
59 private java.lang.String _xmlName;
66 public PropertyDescriptor() {
68 _nsURI = "www.jalview.org";
69 _xmlName = "property";
70 _elementDefinition = true;
71 org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null;
72 org.exolab.castor.mapping.FieldHandler handler = null;
73 org.exolab.castor.xml.FieldValidator fieldValidator = null;
74 //-- initialize attribute descriptors
77 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_name", "name", org.exolab.castor.xml.NodeType.Attribute);
78 desc.setImmutable(true);
79 handler = new org.exolab.castor.xml.XMLFieldHandler() {
80 public java.lang.Object getValue( java.lang.Object object )
81 throws IllegalStateException
83 Property target = (Property) object;
84 return target.getName();
86 public void setValue( java.lang.Object object, java.lang.Object value)
87 throws IllegalStateException, IllegalArgumentException
90 Property target = (Property) object;
91 target.setName( (java.lang.String) value);
92 } catch (java.lang.Exception ex) {
93 throw new IllegalStateException(ex.toString());
96 public java.lang.Object newInstance(java.lang.Object parent) {
100 desc.setHandler(handler);
101 desc.setRequired(true);
102 desc.setMultivalued(false);
103 addFieldDescriptor(desc);
105 //-- validation code for: _name
106 fieldValidator = new org.exolab.castor.xml.FieldValidator();
107 fieldValidator.setMinOccurs(1);
109 org.exolab.castor.xml.validators.StringValidator typeValidator;
110 typeValidator = new org.exolab.castor.xml.validators.StringValidator();
111 fieldValidator.setValidator(typeValidator);
112 typeValidator.setWhiteSpace("preserve");
114 desc.setValidator(fieldValidator);
116 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_value", "value", org.exolab.castor.xml.NodeType.Attribute);
117 desc.setImmutable(true);
118 handler = new org.exolab.castor.xml.XMLFieldHandler() {
119 public java.lang.Object getValue( java.lang.Object object )
120 throws IllegalStateException
122 Property target = (Property) object;
123 return target.getValue();
125 public void setValue( java.lang.Object object, java.lang.Object value)
126 throws IllegalStateException, IllegalArgumentException
129 Property target = (Property) object;
130 target.setValue( (java.lang.String) value);
131 } catch (java.lang.Exception ex) {
132 throw new IllegalStateException(ex.toString());
135 public java.lang.Object newInstance(java.lang.Object parent) {
139 desc.setHandler(handler);
140 desc.setRequired(true);
141 desc.setMultivalued(false);
142 addFieldDescriptor(desc);
144 //-- validation code for: _value
145 fieldValidator = new org.exolab.castor.xml.FieldValidator();
146 fieldValidator.setMinOccurs(1);
148 org.exolab.castor.xml.validators.StringValidator typeValidator;
149 typeValidator = new org.exolab.castor.xml.validators.StringValidator();
150 fieldValidator.setValidator(typeValidator);
151 typeValidator.setWhiteSpace("preserve");
153 desc.setValidator(fieldValidator);
154 //-- initialize element descriptors
164 * Method getAccessMode.
166 * @return the access mode specified for this class.
168 public org.exolab.castor.mapping.AccessMode getAccessMode(
174 * Method getIdentity.
176 * @return the identity field, null if this class has no
179 public org.exolab.castor.mapping.FieldDescriptor getIdentity(
181 return super.getIdentity();
185 * Method getJavaClass.
187 * @return the Java class represented by this descriptor.
189 public java.lang.Class getJavaClass(
191 return jalview.schemabinding.version2.Property.class;
195 * Method getNameSpacePrefix.
197 * @return the namespace prefix to use when marshaling as XML.
199 public java.lang.String getNameSpacePrefix(
205 * Method getNameSpaceURI.
207 * @return the namespace URI used when marshaling and
208 * unmarshaling as XML.
210 public java.lang.String getNameSpaceURI(
216 * Method getValidator.
218 * @return a specific validator for the class described by this
221 public org.exolab.castor.xml.TypeValidator getValidator(
229 * @return the XML Name for the Class being described.
231 public java.lang.String getXMLName(
237 * Method isElementDefinition.
239 * @return true if XML schema definition of this Class is that
241 * element or element with anonymous type definition.
243 public boolean isElementDefinition(
245 return _elementDefinition;