2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1)
3 * Copyright (C) 2014 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 of the License, or (at your option) any later version.
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.
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.
19 package jalview.schemabinding.version2.descriptors;
21 //---------------------------------/
22 //- Imported classes and packages -/
23 //---------------------------------/
25 import jalview.schemabinding.version2.Property;
28 * Class PropertyDescriptor.
30 * @version $Revision$ $Date$
32 public class PropertyDescriptor extends
33 org.exolab.castor.xml.util.XMLClassDescriptorImpl
36 // --------------------------/
37 // - Class/Member Variables -/
38 // --------------------------/
41 * Field _elementDefinition.
43 private boolean _elementDefinition;
48 private java.lang.String _nsPrefix;
53 private java.lang.String _nsURI;
58 private java.lang.String _xmlName;
64 public PropertyDescriptor()
67 _nsURI = "www.jalview.org";
68 _xmlName = "property";
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
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()
82 public java.lang.Object getValue(java.lang.Object object)
83 throws IllegalStateException
85 Property target = (Property) object;
86 return target.getName();
89 public void setValue(java.lang.Object object, java.lang.Object value)
90 throws IllegalStateException, IllegalArgumentException
94 Property target = (Property) object;
95 target.setName((java.lang.String) value);
96 } catch (java.lang.Exception ex)
98 throw new IllegalStateException(ex.toString());
102 public java.lang.Object newInstance(java.lang.Object parent)
107 desc.setHandler(handler);
108 desc.setRequired(true);
109 desc.setMultivalued(false);
110 addFieldDescriptor(desc);
112 // -- validation code for: _name
113 fieldValidator = new org.exolab.castor.xml.FieldValidator();
114 fieldValidator.setMinOccurs(1);
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");
121 desc.setValidator(fieldValidator);
123 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
124 java.lang.String.class, "_value", "value",
125 org.exolab.castor.xml.NodeType.Attribute);
126 desc.setImmutable(true);
127 handler = new org.exolab.castor.xml.XMLFieldHandler()
129 public java.lang.Object getValue(java.lang.Object object)
130 throws IllegalStateException
132 Property target = (Property) object;
133 return target.getValue();
136 public void setValue(java.lang.Object object, java.lang.Object value)
137 throws IllegalStateException, IllegalArgumentException
141 Property target = (Property) object;
142 target.setValue((java.lang.String) value);
143 } catch (java.lang.Exception ex)
145 throw new IllegalStateException(ex.toString());
149 public java.lang.Object newInstance(java.lang.Object parent)
154 desc.setHandler(handler);
155 desc.setRequired(true);
156 desc.setMultivalued(false);
157 addFieldDescriptor(desc);
159 // -- validation code for: _value
160 fieldValidator = new org.exolab.castor.xml.FieldValidator();
161 fieldValidator.setMinOccurs(1);
163 org.exolab.castor.xml.validators.StringValidator typeValidator;
164 typeValidator = new org.exolab.castor.xml.validators.StringValidator();
165 fieldValidator.setValidator(typeValidator);
166 typeValidator.setWhiteSpace("preserve");
168 desc.setValidator(fieldValidator);
169 // -- initialize element descriptors
178 * Method getAccessMode.
180 * @return the access mode specified for this class.
182 public org.exolab.castor.mapping.AccessMode getAccessMode()
188 * Method getIdentity.
190 * @return the identity field, null if this class has no identity.
192 public org.exolab.castor.mapping.FieldDescriptor getIdentity()
194 return super.getIdentity();
198 * Method getJavaClass.
200 * @return the Java class represented by this descriptor.
202 public java.lang.Class getJavaClass()
204 return jalview.schemabinding.version2.Property.class;
208 * Method getNameSpacePrefix.
210 * @return the namespace prefix to use when marshaling as XML.
212 public java.lang.String getNameSpacePrefix()
218 * Method getNameSpaceURI.
220 * @return the namespace URI used when marshaling and unmarshaling as XML.
222 public java.lang.String getNameSpaceURI()
228 * Method getValidator.
230 * @return a specific validator for the class described by this
233 public org.exolab.castor.xml.TypeValidator getValidator()
241 * @return the XML Name for the Class being described.
243 public java.lang.String getXMLName()
249 * Method isElementDefinition.
251 * @return true if XML schema definition of this Class is that of a global
252 * element or element with anonymous type definition.
254 public boolean isElementDefinition()
256 return _elementDefinition;