From 682c69b6a050a742d20f643459d8d8fbfecf40e1 Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Tue, 1 May 2007 10:04:43 +0000 Subject: [PATCH] Save seqset properties --- src/jalview/gui/Jalview2XML.java | 20 ++ .../schemabinding/version2/SequenceSet.java | 151 ++++++++++++ .../version2/SequenceSetDescriptor.java | 35 +++ .../version2/SequenceSetProperties.java | 173 ++++++++++++++ .../version2/SequenceSetPropertiesDescriptor.java | 242 ++++++++++++++++++++ 5 files changed, 621 insertions(+) create mode 100644 src/jalview/schemabinding/version2/SequenceSetProperties.java create mode 100644 src/jalview/schemabinding/version2/SequenceSetPropertiesDescriptor.java diff --git a/src/jalview/gui/Jalview2XML.java b/src/jalview/gui/Jalview2XML.java index 45c76ee..49b022c 100755 --- a/src/jalview/gui/Jalview2XML.java +++ b/src/jalview/gui/Jalview2XML.java @@ -209,6 +209,19 @@ public class Jalview2XML vamsasSet.setGapChar(jal.getGapCharacter() + ""); + if(jal.getProperties()!=null) + { + Enumeration en = jal.getProperties().keys(); + while(en.hasMoreElements()) + { + String key = en.nextElement().toString(); + SequenceSetProperties ssp = new SequenceSetProperties(); + ssp.setKey(key); + ssp.setValue(jal.getProperties().get(key).toString()); + vamsasSet.addSequenceSetProperties(ssp); + } + } + JSeq jseq; //SAVE SEQUENCES @@ -1207,6 +1220,13 @@ public class Jalview2XML jalview.datamodel.Alignment al = new jalview.datamodel.Alignment(orderedSeqs); + for(int i=0; i _sequenceSetPropertiesList.size())) { + throw new IndexOutOfBoundsException(); + } + + return (jalview.schemabinding.version2.SequenceSetProperties) _sequenceSetPropertiesList.elementAt(index); + } //-- jalview.schemabinding.version2.SequenceSetProperties getSequenceSetProperties(int) + + /** + * Method getSequenceSetProperties + * + * + * + * @return SequenceSetProperties + */ + public jalview.schemabinding.version2.SequenceSetProperties[] getSequenceSetProperties() + { + int size = _sequenceSetPropertiesList.size(); + jalview.schemabinding.version2.SequenceSetProperties[] mArray = new jalview.schemabinding.version2.SequenceSetProperties[size]; + for (int index = 0; index < size; index++) { + mArray[index] = (jalview.schemabinding.version2.SequenceSetProperties) _sequenceSetPropertiesList.elementAt(index); + } + return mArray; + } //-- jalview.schemabinding.version2.SequenceSetProperties[] getSequenceSetProperties() + + /** + * Method getSequenceSetPropertiesCount + * + * + * + * @return int + */ + public int getSequenceSetPropertiesCount() + { + return _sequenceSetPropertiesList.size(); + } //-- int getSequenceSetPropertiesCount() + + /** * Method isValid * * @@ -316,6 +409,15 @@ public class SequenceSet implements java.io.Serializable { } //-- void removeAllSequence() /** + * Method removeAllSequenceSetProperties + * + */ + public void removeAllSequenceSetProperties() + { + _sequenceSetPropertiesList.removeAllElements(); + } //-- void removeAllSequenceSetProperties() + + /** * Method removeAnnotation * * @@ -346,6 +448,21 @@ public class SequenceSet implements java.io.Serializable { } //-- jalview.schemabinding.version2.Sequence removeSequence(int) /** + * Method removeSequenceSetProperties + * + * + * + * @param index + * @return SequenceSetProperties + */ + public jalview.schemabinding.version2.SequenceSetProperties removeSequenceSetProperties(int index) + { + java.lang.Object obj = _sequenceSetPropertiesList.elementAt(index); + _sequenceSetPropertiesList.removeElementAt(index); + return (jalview.schemabinding.version2.SequenceSetProperties) obj; + } //-- jalview.schemabinding.version2.SequenceSetProperties removeSequenceSetProperties(int) + + /** * Method setAnnotation * * @@ -424,6 +541,40 @@ public class SequenceSet implements java.io.Serializable { } //-- void setSequence(jalview.schemabinding.version2.Sequence) /** + * Method setSequenceSetProperties + * + * + * + * @param index + * @param vSequenceSetProperties + */ + public void setSequenceSetProperties(int index, jalview.schemabinding.version2.SequenceSetProperties vSequenceSetProperties) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _sequenceSetPropertiesList.size())) { + throw new IndexOutOfBoundsException(); + } + _sequenceSetPropertiesList.setElementAt(vSequenceSetProperties, index); + } //-- void setSequenceSetProperties(int, jalview.schemabinding.version2.SequenceSetProperties) + + /** + * Method setSequenceSetProperties + * + * + * + * @param sequenceSetPropertiesArray + */ + public void setSequenceSetProperties(jalview.schemabinding.version2.SequenceSetProperties[] sequenceSetPropertiesArray) + { + //-- copy array + _sequenceSetPropertiesList.removeAllElements(); + for (int i = 0; i < sequenceSetPropertiesArray.length; i++) { + _sequenceSetPropertiesList.addElement(sequenceSetPropertiesArray[i]); + } + } //-- void setSequenceSetProperties(jalview.schemabinding.version2.SequenceSetProperties) + + /** * Method unmarshal * * diff --git a/src/jalview/schemabinding/version2/SequenceSetDescriptor.java b/src/jalview/schemabinding/version2/SequenceSetDescriptor.java index 70ad2dc..22e00c3 100755 --- a/src/jalview/schemabinding/version2/SequenceSetDescriptor.java +++ b/src/jalview/schemabinding/version2/SequenceSetDescriptor.java @@ -175,6 +175,41 @@ public class SequenceSetDescriptor extends org.exolab.castor.xml.util.XMLClassDe { //-- local scope } desc.setValidator(fieldValidator); + //-- _sequenceSetPropertiesList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(jalview.schemabinding.version2.SequenceSetProperties.class, "_sequenceSetPropertiesList", "sequenceSetProperties", org.exolab.castor.xml.NodeType.Element); + handler = (new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + SequenceSet target = (SequenceSet) object; + return target.getSequenceSetProperties(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + SequenceSet target = (SequenceSet) object; + target.addSequenceSetProperties( (jalview.schemabinding.version2.SequenceSetProperties) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new jalview.schemabinding.version2.SequenceSetProperties(); + } + } ); + desc.setHandler(handler); + desc.setNameSpaceURI("www.vamsas.ac.uk/jalview/version2"); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + //-- validation code for: _sequenceSetPropertiesList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { //-- local scope + } + desc.setValidator(fieldValidator); } //-- jalview.schemabinding.version2.SequenceSetDescriptor() diff --git a/src/jalview/schemabinding/version2/SequenceSetProperties.java b/src/jalview/schemabinding/version2/SequenceSetProperties.java new file mode 100644 index 0000000..8fd310f --- /dev/null +++ b/src/jalview/schemabinding/version2/SequenceSetProperties.java @@ -0,0 +1,173 @@ +/* + * This class was automatically generated with + * Castor 0.9.6, using an XML + * Schema. + * $Id$ + */ + +package jalview.schemabinding.version2; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import java.io.IOException; +import java.io.Reader; +import java.io.Serializable; +import java.io.Writer; +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 SequenceSetProperties. + * + * @version $Revision$ $Date$ + */ +public class SequenceSetProperties implements java.io.Serializable { + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field _key + */ + private java.lang.String _key; + + /** + * Field _value + */ + private java.lang.String _value; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public SequenceSetProperties() { + super(); + } //-- jalview.schemabinding.version2.SequenceSetProperties() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Returns the value of field 'key'. + * + * @return String + * @return the value of field 'key'. + */ + public java.lang.String getKey() + { + return this._key; + } //-- java.lang.String getKey() + + /** + * Returns the value of field 'value'. + * + * @return String + * @return the value of field 'value'. + */ + public java.lang.String getValue() + { + return this._value; + } //-- java.lang.String getValue() + + /** + * 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) + + /** + * Sets the value of field 'key'. + * + * @param key the value of field 'key'. + */ + public void setKey(java.lang.String key) + { + this._key = key; + } //-- void setKey(java.lang.String) + + /** + * Sets the value of field 'value'. + * + * @param value the value of field 'value'. + */ + public void setValue(java.lang.String value) + { + this._value = value; + } //-- void setValue(java.lang.String) + + /** + * Method unmarshal + * + * + * + * @param reader + * @return Object + */ + public static java.lang.Object unmarshal(java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + return (jalview.schemabinding.version2.SequenceSetProperties) Unmarshaller.unmarshal(jalview.schemabinding.version2.SequenceSetProperties.class, reader); + } //-- java.lang.Object 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() + +} diff --git a/src/jalview/schemabinding/version2/SequenceSetPropertiesDescriptor.java b/src/jalview/schemabinding/version2/SequenceSetPropertiesDescriptor.java new file mode 100644 index 0000000..7d45070 --- /dev/null +++ b/src/jalview/schemabinding/version2/SequenceSetPropertiesDescriptor.java @@ -0,0 +1,242 @@ +/* + * This class was automatically generated with + * Castor 0.9.6, using an XML + * Schema. + * $Id$ + */ + +package jalview.schemabinding.version2; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import org.exolab.castor.mapping.AccessMode; +import org.exolab.castor.xml.TypeValidator; +import org.exolab.castor.xml.XMLFieldDescriptor; +import org.exolab.castor.xml.validators.*; + +/** + * Class SequenceSetPropertiesDescriptor. + * + * @version $Revision$ $Date$ + */ +public class SequenceSetPropertiesDescriptor extends org.exolab.castor.xml.util.XMLClassDescriptorImpl { + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field nsPrefix + */ + private java.lang.String nsPrefix; + + /** + * Field nsURI + */ + private java.lang.String nsURI; + + /** + * Field xmlName + */ + private java.lang.String xmlName; + + /** + * Field identity + */ + private org.exolab.castor.xml.XMLFieldDescriptor identity; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public SequenceSetPropertiesDescriptor() { + super(); + nsURI = "www.vamsas.ac.uk/jalview/version2"; + xmlName = "sequenceSetProperties"; + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.xml.XMLFieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + //-- initialize attribute descriptors + + //-- _key + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_key", "key", org.exolab.castor.xml.NodeType.Attribute); + desc.setImmutable(true); + handler = (new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + SequenceSetProperties target = (SequenceSetProperties) object; + return target.getKey(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + SequenceSetProperties target = (SequenceSetProperties) object; + target.setKey( (java.lang.String) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + } ); + desc.setHandler(handler); + addFieldDescriptor(desc); + + //-- validation code for: _key + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + StringValidator typeValidator = new StringValidator(); + typeValidator.setWhiteSpace("preserve"); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- _value + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_value", "value", org.exolab.castor.xml.NodeType.Attribute); + desc.setImmutable(true); + handler = (new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + SequenceSetProperties target = (SequenceSetProperties) object; + return target.getValue(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + SequenceSetProperties target = (SequenceSetProperties) object; + target.setValue( (java.lang.String) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + } ); + desc.setHandler(handler); + addFieldDescriptor(desc); + + //-- validation code for: _value + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + StringValidator typeValidator = new StringValidator(); + typeValidator.setWhiteSpace("preserve"); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- initialize element descriptors + + } //-- jalview.schemabinding.version2.SequenceSetPropertiesDescriptor() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method getAccessMode + * + * + * + * @return AccessMode + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() + { + return null; + } //-- org.exolab.castor.mapping.AccessMode getAccessMode() + + /** + * Method getExtends + * + * + * + * @return ClassDescriptor + */ + public org.exolab.castor.mapping.ClassDescriptor getExtends() + { + return null; + } //-- org.exolab.castor.mapping.ClassDescriptor getExtends() + + /** + * Method getIdentity + * + * + * + * @return FieldDescriptor + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() + { + return identity; + } //-- org.exolab.castor.mapping.FieldDescriptor getIdentity() + + /** + * Method getJavaClass + * + * + * + * @return Class + */ + public java.lang.Class getJavaClass() + { + return jalview.schemabinding.version2.SequenceSetProperties.class; + } //-- java.lang.Class getJavaClass() + + /** + * Method getNameSpacePrefix + * + * + * + * @return String + */ + public java.lang.String getNameSpacePrefix() + { + return nsPrefix; + } //-- java.lang.String getNameSpacePrefix() + + /** + * Method getNameSpaceURI + * + * + * + * @return String + */ + public java.lang.String getNameSpaceURI() + { + return nsURI; + } //-- java.lang.String getNameSpaceURI() + + /** + * Method getValidator + * + * + * + * @return TypeValidator + */ + public org.exolab.castor.xml.TypeValidator getValidator() + { + return this; + } //-- org.exolab.castor.xml.TypeValidator getValidator() + + /** + * Method getXMLName + * + * + * + * @return String + */ + public java.lang.String getXMLName() + { + return xmlName; + } //-- java.lang.String getXMLName() + +} -- 1.7.10.2