/* * This class was automatically generated with * Castor 0.9.9M2, using an XML * Schema. * $Id:AnnotationElement.java 264 2006-12-14 17:42:54Z JimP $ */ package uk.ac.vamsas.objects.core; //---------------------------------/ //- Imported classes and packages -/ //---------------------------------/ import java.io.IOException; import java.io.Reader; import java.io.Serializable; import java.io.Writer; import java.util.Enumeration; import java.util.Vector; import org.exolab.castor.xml.MarshalException; import org.exolab.castor.xml.Marshaller; import org.exolab.castor.xml.Unmarshaller; import org.exolab.castor.xml.ValidationException; import org.xml.sax.ContentHandler; /** * Class AnnotationElement. * * @version $Revision:264 $ $Date:2006-12-14 17:42:54 +0000 (Thu, 14 Dec 2006) $ */ public class AnnotationElement extends uk.ac.vamsas.client.Vobject implements java.io.Serializable { //--------------------------/ //- Class/Member Variables -/ //--------------------------/ /** * position with respect to the coordinate frame defined by a * rangeType specification */ private int _position; /** * keeps track of state for field: _position */ private boolean _has_position; /** * true means the annotation element appears between the * specified position and the next */ private boolean _after = false; /** * keeps track of state for field: _after */ private boolean _has_after; /** * Primary Key for vamsas object referencing */ private java.lang.String _id; /** * Free text at this position */ private java.lang.String _description; /** * Discrete symbol - possibly graphically represented * */ private java.util.Vector _glyphList; /** * Ordered set of float values - an application may treat * the values together as a vector with common support for a * set of * annotation elements - but this is, again, not validated so * applications * should deal gracefully with varying numbers of dimensions * */ private java.util.Vector _valueList; //----------------/ //- Constructors -/ //----------------/ public AnnotationElement() { super(); _glyphList = new Vector(); _valueList = new Vector(); } //-- uk.ac.vamsas.objects.core.AnnotationElement() //-----------/ //- Methods -/ //-----------/ /** * Method addGlyph * * * * @param vGlyph */ public void addGlyph(uk.ac.vamsas.objects.core.Glyph vGlyph) throws java.lang.IndexOutOfBoundsException { _glyphList.addElement(vGlyph); } //-- void addGlyph(uk.ac.vamsas.objects.core.Glyph) /** * Method addGlyph * * * * @param index * @param vGlyph */ public void addGlyph(int index, uk.ac.vamsas.objects.core.Glyph vGlyph) throws java.lang.IndexOutOfBoundsException { _glyphList.insertElementAt(vGlyph, index); } //-- void addGlyph(int, uk.ac.vamsas.objects.core.Glyph) /** * Method addValue * * * * @param vValue */ public void addValue(float vValue) throws java.lang.IndexOutOfBoundsException { _valueList.addElement(new java.lang.Float(vValue)); } //-- void addValue(float) /** * Method addValue * * * * @param index * @param vValue */ public void addValue(int index, float vValue) throws java.lang.IndexOutOfBoundsException { _valueList.insertElementAt(new java.lang.Float(vValue), index); } //-- void addValue(int, float) /** * Method deleteAfter * */ public void deleteAfter() { this._has_after= false; } //-- void deleteAfter() /** * Method deletePosition * */ public void deletePosition() { this._has_position= false; } //-- void deletePosition() /** * Method enumerateGlyph * * * * @return Enumeration */ public java.util.Enumeration enumerateGlyph() { return _glyphList.elements(); } //-- java.util.Enumeration enumerateGlyph() /** * Method enumerateValue * * * * @return Enumeration */ public java.util.Enumeration enumerateValue() { return _valueList.elements(); } //-- java.util.Enumeration enumerateValue() /** * Note: hashCode() has not been overriden * * @param obj * @return boolean */ public boolean equals(java.lang.Object obj) { if ( this == obj ) return true; if (super.equals(obj)==false) return false; if (obj instanceof AnnotationElement) { AnnotationElement temp = (AnnotationElement)obj; if (this._position != temp._position) return false; if (this._has_position != temp._has_position) return false; if (this._after != temp._after) return false; if (this._has_after != temp._has_after) return false; if (this._id != null) { if (temp._id == null) return false; else if (!(this._id.equals(temp._id))) return false; } else if (temp._id != null) return false; if (this._description != null) { if (temp._description == null) return false; else if (!(this._description.equals(temp._description))) return false; } else if (temp._description != null) return false; if (this._glyphList != null) { if (temp._glyphList == null) return false; else if (!(this._glyphList.equals(temp._glyphList))) return false; } else if (temp._glyphList != null) return false; if (this._valueList != null) { if (temp._valueList == null) return false; else if (!(this._valueList.equals(temp._valueList))) return false; } else if (temp._valueList != null) return false; return true; } return false; } //-- boolean equals(java.lang.Object) /** * Returns the value of field 'after'. The field 'after' has * the following description: true means the annotation element * appears between the * specified position and the next * * @return boolean * @return the value of field 'after'. */ public boolean getAfter() { return this._after; } //-- boolean getAfter() /** * Returns the value of field 'description'. The field * 'description' has the following description: Free text at * this position * * @return String * @return the value of field 'description'. */ public java.lang.String getDescription() { return this._description; } //-- java.lang.String getDescription() /** * Method getGlyph * * * * @param index * @return Glyph */ public uk.ac.vamsas.objects.core.Glyph getGlyph(int index) throws java.lang.IndexOutOfBoundsException { //-- check bounds for index if ((index < 0) || (index > _glyphList.size())) { throw new IndexOutOfBoundsException("getGlyph: Index value '"+index+"' not in range [0.."+_glyphList.size()+ "]"); } return (uk.ac.vamsas.objects.core.Glyph) _glyphList.elementAt(index); } //-- uk.ac.vamsas.objects.core.Glyph getGlyph(int) /** * Method getGlyph * * * * @return Glyph */ public uk.ac.vamsas.objects.core.Glyph[] getGlyph() { int size = _glyphList.size(); uk.ac.vamsas.objects.core.Glyph[] mArray = new uk.ac.vamsas.objects.core.Glyph[size]; for (int index = 0; index < size; index++) { mArray[index] = (uk.ac.vamsas.objects.core.Glyph) _glyphList.elementAt(index); } return mArray; } //-- uk.ac.vamsas.objects.core.Glyph[] getGlyph() /** * Method getGlyphCount * * * * @return int */ public int getGlyphCount() { return _glyphList.size(); } //-- int getGlyphCount() /** * Returns the value of field 'id'. The field 'id' has the * following description: Primary Key for vamsas object * referencing * * @return String * @return the value of field 'id'. */ public java.lang.String getId() { return this._id; } //-- java.lang.String getId() /** * Returns the value of field 'position'. The field 'position' * has the following description: position with respect to the * coordinate frame defined by a * rangeType specification * * @return int * @return the value of field 'position'. */ public int getPosition() { return this._position; } //-- int getPosition() /** * Method getValue * * * * @param index * @return float */ public float getValue(int index) throws java.lang.IndexOutOfBoundsException { //-- check bounds for index if ((index < 0) || (index > _valueList.size())) { throw new IndexOutOfBoundsException("getValue: Index value '"+index+"' not in range [0.."+_valueList.size()+ "]"); } return ((java.lang.Float)_valueList.elementAt(index)).floatValue(); } //-- float getValue(int) /** * Method getValue * * * * @return float */ public float[] getValue() { int size = _valueList.size(); float[] mArray = new float[size]; for (int index = 0; index < size; index++) { mArray[index] = ((java.lang.Float)_valueList.elementAt(index)).floatValue(); } return mArray; } //-- float[] getValue() /** * Method getValueCount * * * * @return int */ public int getValueCount() { return _valueList.size(); } //-- int getValueCount() /** * Method hasAfter * * * * @return boolean */ public boolean hasAfter() { return this._has_after; } //-- boolean hasAfter() /** * Method hasPosition * * * * @return boolean */ public boolean hasPosition() { return this._has_position; } //-- boolean hasPosition() /** * Method isValid * * * * @return boolean */ public boolean isValid() { try { validate(); } catch (org.exolab.castor.xml.ValidationException vex) { return false; } return true; } //-- boolean isValid() /** * Method marshal * * * * @param out */ public void marshal(java.io.Writer out) throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { Marshaller.marshal(this, out); } //-- void marshal(java.io.Writer) /** * Method marshal * * * * @param handler */ public void marshal(org.xml.sax.ContentHandler handler) throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { Marshaller.marshal(this, handler); } //-- void marshal(org.xml.sax.ContentHandler) /** * Method removeAllGlyph * */ public void removeAllGlyph() { _glyphList.removeAllElements(); } //-- void removeAllGlyph() /** * Method removeAllValue * */ public void removeAllValue() { _valueList.removeAllElements(); } //-- void removeAllValue() /** * Method removeGlyph * * * * @param index * @return Glyph */ public uk.ac.vamsas.objects.core.Glyph removeGlyph(int index) { java.lang.Object obj = _glyphList.elementAt(index); _glyphList.removeElementAt(index); return (uk.ac.vamsas.objects.core.Glyph) obj; } //-- uk.ac.vamsas.objects.core.Glyph removeGlyph(int) /** * Method removeValue * * * * @param index * @return float */ public float removeValue(int index) { java.lang.Object obj = _valueList.elementAt(index); _valueList.removeElementAt(index); return ((java.lang.Float)obj).floatValue(); } //-- float removeValue(int) /** * Sets the value of field 'after'. The field 'after' has the * following description: true means the annotation element * appears between the * specified position and the next * * @param after the value of field 'after'. */ public void setAfter(boolean after) { this._after = after; this._has_after = true; } //-- void setAfter(boolean) /** * Sets the value of field 'description'. The field * 'description' has the following description: Free text at * this position * * @param description the value of field 'description'. */ public void setDescription(java.lang.String description) { this._description = description; } //-- void setDescription(java.lang.String) /** * Method setGlyph * * * * @param index * @param vGlyph */ public void setGlyph(int index, uk.ac.vamsas.objects.core.Glyph vGlyph) throws java.lang.IndexOutOfBoundsException { //-- check bounds for index if ((index < 0) || (index > _glyphList.size())) { throw new IndexOutOfBoundsException("setGlyph: Index value '"+index+"' not in range [0.."+_glyphList.size()+ "]"); } _glyphList.setElementAt(vGlyph, index); } //-- void setGlyph(int, uk.ac.vamsas.objects.core.Glyph) /** * Method setGlyph * * * * @param glyphArray */ public void setGlyph(uk.ac.vamsas.objects.core.Glyph[] glyphArray) { //-- copy array _glyphList.removeAllElements(); for (int i = 0; i < glyphArray.length; i++) { _glyphList.addElement(glyphArray[i]); } } //-- void setGlyph(uk.ac.vamsas.objects.core.Glyph) /** * Sets the value of field 'id'. The field 'id' has the * following description: Primary Key for vamsas object * referencing * * @param id the value of field 'id'. */ public void setId(java.lang.String id) { this._id = id; } //-- void setId(java.lang.String) /** * Sets the value of field 'position'. The field 'position' has * the following description: position with respect to the * coordinate frame defined by a * rangeType specification * * @param position the value of field 'position'. */ public void setPosition(int position) { this._position = position; this._has_position = true; } //-- void setPosition(int) /** * Method setValue * * * * @param index * @param vValue */ public void setValue(int index, float vValue) throws java.lang.IndexOutOfBoundsException { //-- check bounds for index if ((index < 0) || (index > _valueList.size())) { throw new IndexOutOfBoundsException("setValue: Index value '"+index+"' not in range [0.."+_valueList.size()+ "]"); } _valueList.setElementAt(new java.lang.Float(vValue), index); } //-- void setValue(int, float) /** * Method setValue * * * * @param valueArray */ public void setValue(float[] valueArray) { //-- copy array _valueList.removeAllElements(); for (int i = 0; i < valueArray.length; i++) { _valueList.addElement(new java.lang.Float(valueArray[i])); } } //-- void setValue(float) /** * Method unmarshal * * * * @param reader * @return AnnotationElement */ public static uk.ac.vamsas.objects.core.AnnotationElement unmarshal(java.io.Reader reader) throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { return (uk.ac.vamsas.objects.core.AnnotationElement) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.AnnotationElement.class, reader); } //-- uk.ac.vamsas.objects.core.AnnotationElement unmarshal(java.io.Reader) /** * Method validate * */ public void validate() throws org.exolab.castor.xml.ValidationException { org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); validator.validate(this); } //-- void validate() }