2 * This file is part of the Vamsas Client version 0.1.
\r
3 * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite,
\r
4 * Andrew Waterhouse and Dominik Lindner.
\r
6 * Earlier versions have also been incorporated into Jalview version 2.4
\r
7 * since 2008, and TOPALi version 2 since 2007.
\r
9 * The Vamsas Client is free software: you can redistribute it and/or modify
\r
10 * it under the terms of the GNU Lesser General Public License as published by
\r
11 * the Free Software Foundation, either version 3 of the License, or
\r
12 * (at your option) any later version.
\r
14 * The Vamsas Client is distributed in the hope that it will be useful,
\r
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
17 * GNU Lesser General Public License for more details.
\r
19 * You should have received a copy of the GNU Lesser General Public License
\r
20 * along with the Vamsas Client. If not, see <http://www.gnu.org/licenses/>.
\r
22 package uk.ac.vamsas.objects.core.descriptors;
\r
24 //---------------------------------/
\r
25 //- Imported classes and packages -/
\r
26 //---------------------------------/
\r
28 import uk.ac.vamsas.objects.core.Score;
\r
31 * Class ScoreDescriptor.
\r
33 * @version $Revision$ $Date$
\r
35 public class ScoreDescriptor extends
\r
36 org.exolab.castor.xml.util.XMLClassDescriptorImpl {
\r
38 // --------------------------/
\r
39 // - Class/Member Variables -/
\r
40 // --------------------------/
\r
43 * Field _elementDefinition.
\r
45 private boolean _elementDefinition;
\r
50 private java.lang.String _nsPrefix;
\r
55 private java.lang.String _nsURI;
\r
60 private java.lang.String _xmlName;
\r
62 // ----------------/
\r
63 // - Constructors -/
\r
64 // ----------------/
\r
66 public ScoreDescriptor() {
\r
68 _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes";
\r
70 _elementDefinition = true;
\r
71 org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null;
\r
72 org.exolab.castor.mapping.FieldHandler handler = null;
\r
73 org.exolab.castor.xml.FieldValidator fieldValidator = null;
\r
75 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
\r
76 java.lang.Float.TYPE, "_content", "PCDATA",
\r
77 org.exolab.castor.xml.NodeType.Text);
\r
78 handler = new org.exolab.castor.xml.XMLFieldHandler() {
\r
79 public java.lang.Object getValue(java.lang.Object object)
\r
80 throws IllegalStateException {
\r
81 Score target = (Score) object;
\r
82 if (!target.hasContent()) {
\r
85 return new java.lang.Float(target.getContent());
\r
88 public void setValue(java.lang.Object object, java.lang.Object value)
\r
89 throws IllegalStateException, IllegalArgumentException {
\r
91 Score target = (Score) object;
\r
92 // if null, use delete method for optional primitives
\r
93 if (value == null) {
\r
94 target.deleteContent();
\r
97 target.setContent(((java.lang.Float) value).floatValue());
\r
98 } catch (java.lang.Exception ex) {
\r
99 throw new IllegalStateException(ex.toString());
\r
103 public java.lang.Object newInstance(java.lang.Object parent) {
\r
107 desc.setHandler(handler);
\r
108 addFieldDescriptor(desc);
\r
110 // -- validation code for: _content
\r
111 fieldValidator = new org.exolab.castor.xml.FieldValidator();
\r
112 { // -- local scope
\r
113 org.exolab.castor.xml.validators.FloatValidator typeValidator;
\r
114 typeValidator = new org.exolab.castor.xml.validators.FloatValidator();
\r
115 fieldValidator.setValidator(typeValidator);
\r
116 typeValidator.setMinInclusive((float) -3.4028235E38);
\r
117 typeValidator.setMaxInclusive((float) 3.4028235E38);
\r
119 desc.setValidator(fieldValidator);
\r
120 // -- initialize attribute descriptors
\r
123 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
\r
124 java.lang.String.class, "_name", "name",
\r
125 org.exolab.castor.xml.NodeType.Attribute);
\r
126 desc.setImmutable(true);
\r
127 handler = new org.exolab.castor.xml.XMLFieldHandler() {
\r
128 public java.lang.Object getValue(java.lang.Object object)
\r
129 throws IllegalStateException {
\r
130 Score target = (Score) object;
\r
131 return target.getName();
\r
134 public void setValue(java.lang.Object object, java.lang.Object value)
\r
135 throws IllegalStateException, IllegalArgumentException {
\r
137 Score target = (Score) object;
\r
138 target.setName((java.lang.String) value);
\r
139 } catch (java.lang.Exception ex) {
\r
140 throw new IllegalStateException(ex.toString());
\r
144 public java.lang.Object newInstance(java.lang.Object parent) {
\r
148 desc.setHandler(handler);
\r
149 desc.setMultivalued(false);
\r
150 addFieldDescriptor(desc);
\r
152 // -- validation code for: _name
\r
153 fieldValidator = new org.exolab.castor.xml.FieldValidator();
\r
154 { // -- local scope
\r
155 org.exolab.castor.xml.validators.StringValidator typeValidator;
\r
156 typeValidator = new org.exolab.castor.xml.validators.StringValidator();
\r
157 fieldValidator.setValidator(typeValidator);
\r
158 typeValidator.setWhiteSpace("preserve");
\r
160 desc.setValidator(fieldValidator);
\r
161 // -- initialize element descriptors
\r
170 * Method getAccessMode.
\r
172 * @return the access mode specified for this class.
\r
174 public org.exolab.castor.mapping.AccessMode getAccessMode() {
\r
179 * Method getIdentity.
\r
181 * @return the identity field, null if this class has no identity.
\r
183 public org.exolab.castor.mapping.FieldDescriptor getIdentity() {
\r
184 return super.getIdentity();
\r
188 * Method getJavaClass.
\r
190 * @return the Java class represented by this descriptor.
\r
192 public java.lang.Class getJavaClass() {
\r
193 return uk.ac.vamsas.objects.core.Score.class;
\r
197 * Method getNameSpacePrefix.
\r
199 * @return the namespace prefix to use when marshaling as XML.
\r
201 public java.lang.String getNameSpacePrefix() {
\r
206 * Method getNameSpaceURI.
\r
208 * @return the namespace URI used when marshaling and unmarshaling as XML.
\r
210 public java.lang.String getNameSpaceURI() {
\r
215 * Method getValidator.
\r
217 * @return a specific validator for the class described by this
\r
220 public org.exolab.castor.xml.TypeValidator getValidator() {
\r
225 * Method getXMLName.
\r
227 * @return the XML Name for the Class being described.
\r
229 public java.lang.String getXMLName() {
\r
234 * Method isElementDefinition.
\r
236 * @return true if XML schema definition of this Class is that of a global
\r
237 * element or element with anonymous type definition.
\r
239 public boolean isElementDefinition() {
\r
240 return _elementDefinition;
\r