From: jprocter Date: Thu, 7 May 2009 15:36:04 +0000 (+0000) Subject: applied LGPLv3 and source code formatting. X-Git-Tag: Release_0.2~25 X-Git-Url: http://source.jalview.org/gitweb/?p=vamsas.git;a=commitdiff_plain;h=844ccad5a3fcbedec17b2af66d460f31abc7cff1 applied LGPLv3 and source code formatting. git-svn-id: https://svn.lifesci.dundee.ac.uk/svn/repository/trunk@496 be28352e-c001-0410-b1a7-c7978e42abec --- diff --git a/CONTRIB b/CONTRIB index 7002346..5bcc490 100644 --- a/CONTRIB +++ b/CONTRIB @@ -15,5 +15,5 @@ castor Source Code Contributions uk.ac.vamsas.utils.Trees and trees: Re-licenced as LGPL from the Jalview program normally available as GPL -org.apache.tools.zip : Modified under the terms of the Apache 2 licence and re-distributed as LGPL (see LICENCE-apache-tools-zip). +org.apache.tools.zip : Modified under the terms of the Apache 2 licence and re-distributed as LGPL (see LICENCE-apache-tools-zip and org.apache.tools.zip.ZipFile class source). diff --git a/COPYING.lesser b/COPYING.lesser new file mode 100644 index 0000000..cca7fc2 --- /dev/null +++ b/COPYING.lesser @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/README b/README new file mode 100644 index 0000000..1d2a32c --- /dev/null +++ b/README @@ -0,0 +1,43 @@ +The VAMSAS Client +================= + +This is an LGPLed Java implementation of the VAMSAS framework for +bioinformatics application data exchange interoperation. +VAMSAS is a pseudo-acronym, and is short for 'Visualization and Analysis +of Molecular Sequences, Alignments and Structures'. +The client is the product of an eScience research project funded by the +UK Biotechnology and Biological Sciences Research Council which +aimed to enable interoperation between visualization and analysis tools +that deal with DNA, protein sequences, alignments, and molecular structures. + +The framework model is language independent - but this +java prototype was developed for incorporation in the +three sister programs (Jalview, TOPALi and AstexViewer@EBI-MSD) +involved in the vamsas project (http://www.vamsas.ac.uk). + +Directory structure and Build Notes +----------------------------------- +Java source lives under src, runtime dependencies under lib and resources, +compile time dependencies (which need to be added to the ant build classpath) +reside in tools, and license details for dependencies are described in CONTRIB. +Ant 1.7 has been verified to work with the provided build.xml. + +API and schema documentation can be found under the docs directory, +along with a variety of (not entirely up to date) notes made during +the development of the code. The schemas directory contains the vamsas document +XML model, plus a couple of legacy XML documents. The demo directory also contains +some older demonstration data. Finally, the test directory is made conspicuous via +its emptiness (sorry!). + +A documented demonstration client (uk.ac.vamsas.test.ExampleApplication) based +on the Jalview/VAMSAS control logic shows how the VAMSAS client code is intended +to be used, but it does not yet demonstrate all aspects of the interchange model. + +For more information, please contact me, or any of the other developers +directly, or via their program's own email discussion list. + +Jim Procter. +7th May 2009. + +The other VAMSAS coders: Dominik Lindner, Pierre Marguerite, Iain Milne, Andrew Waterhouse. +The VAMSAS project researchers: Geoff Barton, David Martin, David Marshall, Tom Oldfield, Frank Wright. diff --git a/build.xml b/build.xml index ab984bb..9302dfc 100644 --- a/build.xml +++ b/build.xml @@ -1,4 +1,25 @@ + @@ -11,7 +32,8 @@ - + + @@ -78,6 +100,7 @@ + @@ -126,7 +149,7 @@ inheritRefs="true"/> --> - + @@ -139,11 +162,25 @@ inheritRefs="true"/> --> + + + + + + + + + + + + + + @@ -161,6 +198,7 @@ inheritRefs="true"/> --> + diff --git a/packages/vamsas-client.jar b/packages/vamsas-client.jar index ce73f8f..ea39a62 100644 Binary files a/packages/vamsas-client.jar and b/packages/vamsas-client.jar differ diff --git a/packages/vamsas-schema-and-doc.jar b/packages/vamsas-schema-and-doc.jar new file mode 100644 index 0000000..a627a03 Binary files /dev/null and b/packages/vamsas-schema-and-doc.jar differ diff --git a/resources/README b/resources/README deleted file mode 100644 index e69de29..0000000 diff --git a/schemas/vamsas.xsd b/schemas/vamsas.xsd index 80f5d91..8b4518b 100644 --- a/schemas/vamsas.xsd +++ b/schemas/vamsas.xsd @@ -1,4 +1,25 @@ + + @@ -23,4 +44,4 @@ - \ No newline at end of file + diff --git a/src/org/apache/tools/zip/AsiExtraField.java b/src/org/apache/tools/zip/AsiExtraField.java index 8d59670..ae72a6d 100644 --- a/src/org/apache/tools/zip/AsiExtraField.java +++ b/src/org/apache/tools/zip/AsiExtraField.java @@ -22,10 +22,12 @@ import java.util.zip.CRC32; import java.util.zip.ZipException; /** - * Adds Unix file permission and UID/GID fields as well as symbolic - * link handling. - * - *

This class uses the ASi extra field in the format: + * Adds Unix file permission and UID/GID fields as well as symbolic link + * handling. + * + *

+ * This class uses the ASi extra field in the format: + * *

  *         Value         Size            Description
  *         -----         ----            -----------
@@ -38,296 +40,330 @@ import java.util.zip.ZipException;
  *         GID           Short           group ID
  *         (var.)        variable        symbolic link filename
  * 
+ * * taken from appnote.iz (Info-ZIP note, 981119) found at ftp://ftp.uu.net/pub/archiving/zip/doc/

- - * - *

Short is two bytes and Long is four bytes in big endian byte and - * word order, device numbers are currently not supported.

- * + * href="ftp://ftp.uu.net/pub/archiving/zip/doc/" + * >ftp://ftp.uu.net/pub/archiving/zip/doc/ + *

+ * + * + *

+ * Short is two bytes and Long is four bytes in big endian byte and word order, + * device numbers are currently not supported. + *

+ * */ public class AsiExtraField implements ZipExtraField, UnixStat, Cloneable { - private static final ZipShort HEADER_ID = new ZipShort(0x756E); - - /** - * Standard Unix stat(2) file mode. - * - * @since 1.1 - */ - private int mode = 0; - /** - * User ID. - * - * @since 1.1 - */ - private int uid = 0; - /** - * Group ID. - * - * @since 1.1 - */ - private int gid = 0; - /** - * File this entry points to, if it is a symbolic link. - * - *

empty string - if entry is not a symbolic link.

- * - * @since 1.1 - */ - private String link = ""; - /** - * Is this an entry for a directory? - * - * @since 1.1 - */ - private boolean dirFlag = false; - - /** - * Instance used to calculate checksums. - * - * @since 1.1 - */ - private CRC32 crc = new CRC32(); - - /** Constructor for AsiExtraField. */ - public AsiExtraField() { - } - - /** - * The Header-ID. - * @return the value for the header id for this extrafield - * @since 1.1 - */ - public ZipShort getHeaderId() { - return HEADER_ID; - } - - /** - * Length of the extra field in the local file data - without - * Header-ID or length specifier. - * @return a ZipShort for the length of the data of this extra field - * @since 1.1 - */ - public ZipShort getLocalFileDataLength() { - return new ZipShort(4 // CRC - + 2 // Mode - + 4 // SizDev - + 2 // UID - + 2 // GID - + getLinkedFile().getBytes().length); - } - - /** - * Delegate to local file data. - * @return the centralDirectory length - * @since 1.1 - */ - public ZipShort getCentralDirectoryLength() { - return getLocalFileDataLength(); - } - - /** - * The actual data to put into local file data - without Header-ID - * or length specifier. - * @return get the data - * @since 1.1 - */ - public byte[] getLocalFileDataData() { - // CRC will be added later - byte[] data = new byte[getLocalFileDataLength().getValue() - 4]; - System.arraycopy(ZipShort.getBytes(getMode()), 0, data, 0, 2); - - byte[] linkArray = getLinkedFile().getBytes(); - System.arraycopy(ZipLong.getBytes(linkArray.length), - 0, data, 2, 4); - - System.arraycopy(ZipShort.getBytes(getUserId()), - 0, data, 6, 2); - System.arraycopy(ZipShort.getBytes(getGroupId()), - 0, data, 8, 2); - - System.arraycopy(linkArray, 0, data, 10, linkArray.length); - - crc.reset(); - crc.update(data); - long checksum = crc.getValue(); - - byte[] result = new byte[data.length + 4]; - System.arraycopy(ZipLong.getBytes(checksum), 0, result, 0, 4); - System.arraycopy(data, 0, result, 4, data.length); - return result; - } - - /** - * Delegate to local file data. - * @return the local file data - * @since 1.1 - */ - public byte[] getCentralDirectoryData() { - return getLocalFileDataData(); - } - - /** - * Set the user id. - * @param uid the user id - * @since 1.1 - */ - public void setUserId(int uid) { - this.uid = uid; - } - - /** - * Get the user id. - * @return the user id - * @since 1.1 - */ - public int getUserId() { - return uid; + private static final ZipShort HEADER_ID = new ZipShort(0x756E); + + /** + * Standard Unix stat(2) file mode. + * + * @since 1.1 + */ + private int mode = 0; + + /** + * User ID. + * + * @since 1.1 + */ + private int uid = 0; + + /** + * Group ID. + * + * @since 1.1 + */ + private int gid = 0; + + /** + * File this entry points to, if it is a symbolic link. + * + *

+ * empty string - if entry is not a symbolic link. + *

+ * + * @since 1.1 + */ + private String link = ""; + + /** + * Is this an entry for a directory? + * + * @since 1.1 + */ + private boolean dirFlag = false; + + /** + * Instance used to calculate checksums. + * + * @since 1.1 + */ + private CRC32 crc = new CRC32(); + + /** Constructor for AsiExtraField. */ + public AsiExtraField() { + } + + /** + * The Header-ID. + * + * @return the value for the header id for this extrafield + * @since 1.1 + */ + public ZipShort getHeaderId() { + return HEADER_ID; + } + + /** + * Length of the extra field in the local file data - without Header-ID or + * length specifier. + * + * @return a ZipShort for the length of the data of this extra + * field + * @since 1.1 + */ + public ZipShort getLocalFileDataLength() { + return new ZipShort(4 // CRC + + 2 // Mode + + 4 // SizDev + + 2 // UID + + 2 // GID + + getLinkedFile().getBytes().length); + } + + /** + * Delegate to local file data. + * + * @return the centralDirectory length + * @since 1.1 + */ + public ZipShort getCentralDirectoryLength() { + return getLocalFileDataLength(); + } + + /** + * The actual data to put into local file data - without Header-ID or length + * specifier. + * + * @return get the data + * @since 1.1 + */ + public byte[] getLocalFileDataData() { + // CRC will be added later + byte[] data = new byte[getLocalFileDataLength().getValue() - 4]; + System.arraycopy(ZipShort.getBytes(getMode()), 0, data, 0, 2); + + byte[] linkArray = getLinkedFile().getBytes(); + System.arraycopy(ZipLong.getBytes(linkArray.length), 0, data, 2, 4); + + System.arraycopy(ZipShort.getBytes(getUserId()), 0, data, 6, 2); + System.arraycopy(ZipShort.getBytes(getGroupId()), 0, data, 8, 2); + + System.arraycopy(linkArray, 0, data, 10, linkArray.length); + + crc.reset(); + crc.update(data); + long checksum = crc.getValue(); + + byte[] result = new byte[data.length + 4]; + System.arraycopy(ZipLong.getBytes(checksum), 0, result, 0, 4); + System.arraycopy(data, 0, result, 4, data.length); + return result; + } + + /** + * Delegate to local file data. + * + * @return the local file data + * @since 1.1 + */ + public byte[] getCentralDirectoryData() { + return getLocalFileDataData(); + } + + /** + * Set the user id. + * + * @param uid + * the user id + * @since 1.1 + */ + public void setUserId(int uid) { + this.uid = uid; + } + + /** + * Get the user id. + * + * @return the user id + * @since 1.1 + */ + public int getUserId() { + return uid; + } + + /** + * Set the group id. + * + * @param gid + * the group id + * @since 1.1 + */ + public void setGroupId(int gid) { + this.gid = gid; + } + + /** + * Get the group id. + * + * @return the group id + * @since 1.1 + */ + public int getGroupId() { + return gid; + } + + /** + * Indicate that this entry is a symbolic link to the given filename. + * + * @param name + * Name of the file this entry links to, empty String if it is not a + * symbolic link. + * + * @since 1.1 + */ + public void setLinkedFile(String name) { + link = name; + mode = getMode(mode); + } + + /** + * Name of linked file + * + * @return name of the file this entry links to if it is a symbolic link, the + * empty string otherwise. + * + * @since 1.1 + */ + public String getLinkedFile() { + return link; + } + + /** + * Is this entry a symbolic link? + * + * @return true if this is a symbolic link + * @since 1.1 + */ + public boolean isLink() { + return getLinkedFile().length() != 0; + } + + /** + * File mode of this file. + * + * @param mode + * the file mode + * @since 1.1 + */ + public void setMode(int mode) { + this.mode = getMode(mode); + } + + /** + * File mode of this file. + * + * @return the file mode + * @since 1.1 + */ + public int getMode() { + return mode; + } + + /** + * Indicate whether this entry is a directory. + * + * @param dirFlag + * if true, this entry is a directory + * @since 1.1 + */ + public void setDirectory(boolean dirFlag) { + this.dirFlag = dirFlag; + mode = getMode(mode); + } + + /** + * Is this entry a directory? + * + * @return true if this entry is a directory + * @since 1.1 + */ + public boolean isDirectory() { + return dirFlag && !isLink(); + } + + /** + * Populate data from this array as if it was in local file data. + * + * @param data + * an array of bytes + * @param offset + * the start offset + * @param length + * the number of bytes in the array from offset + * @since 1.1 + * @throws ZipException + * on error + */ + public void parseFromLocalFileData(byte[] data, int offset, int length) + throws ZipException { + + long givenChecksum = ZipLong.getValue(data, offset); + byte[] tmp = new byte[length - 4]; + System.arraycopy(data, offset + 4, tmp, 0, length - 4); + crc.reset(); + crc.update(tmp); + long realChecksum = crc.getValue(); + if (givenChecksum != realChecksum) { + throw new ZipException("bad CRC checksum " + + Long.toHexString(givenChecksum) + " instead of " + + Long.toHexString(realChecksum)); } - /** - * Set the group id. - * @param gid the group id - * @since 1.1 - */ - public void setGroupId(int gid) { - this.gid = gid; - } - - /** - * Get the group id. - * @return the group id - * @since 1.1 - */ - public int getGroupId() { - return gid; - } - - /** - * Indicate that this entry is a symbolic link to the given filename. - * - * @param name Name of the file this entry links to, empty String - * if it is not a symbolic link. - * - * @since 1.1 - */ - public void setLinkedFile(String name) { - link = name; - mode = getMode(mode); - } - - /** - * Name of linked file - * - * @return name of the file this entry links to if it is a - * symbolic link, the empty string otherwise. - * - * @since 1.1 - */ - public String getLinkedFile() { - return link; - } - - /** - * Is this entry a symbolic link? - * @return true if this is a symbolic link - * @since 1.1 - */ - public boolean isLink() { - return getLinkedFile().length() != 0; - } + int newMode = ZipShort.getValue(tmp, 0); + byte[] linkArray = new byte[(int) ZipLong.getValue(tmp, 2)]; + uid = ZipShort.getValue(tmp, 6); + gid = ZipShort.getValue(tmp, 8); - /** - * File mode of this file. - * @param mode the file mode - * @since 1.1 - */ - public void setMode(int mode) { - this.mode = getMode(mode); + if (linkArray.length == 0) { + link = ""; + } else { + System.arraycopy(tmp, 10, linkArray, 0, linkArray.length); + link = new String(linkArray); } - - /** - * File mode of this file. - * @return the file mode - * @since 1.1 - */ - public int getMode() { - return mode; - } - - /** - * Indicate whether this entry is a directory. - * @param dirFlag if true, this entry is a directory - * @since 1.1 - */ - public void setDirectory(boolean dirFlag) { - this.dirFlag = dirFlag; - mode = getMode(mode); - } - - /** - * Is this entry a directory? - * @return true if this entry is a directory - * @since 1.1 - */ - public boolean isDirectory() { - return dirFlag && !isLink(); - } - - /** - * Populate data from this array as if it was in local file data. - * @param data an array of bytes - * @param offset the start offset - * @param length the number of bytes in the array from offset - * @since 1.1 - * @throws ZipException on error - */ - public void parseFromLocalFileData(byte[] data, int offset, int length) - throws ZipException { - - long givenChecksum = ZipLong.getValue(data, offset); - byte[] tmp = new byte[length - 4]; - System.arraycopy(data, offset + 4, tmp, 0, length - 4); - crc.reset(); - crc.update(tmp); - long realChecksum = crc.getValue(); - if (givenChecksum != realChecksum) { - throw new ZipException("bad CRC checksum " - + Long.toHexString(givenChecksum) - + " instead of " - + Long.toHexString(realChecksum)); - } - - int newMode = ZipShort.getValue(tmp, 0); - byte[] linkArray = new byte[(int) ZipLong.getValue(tmp, 2)]; - uid = ZipShort.getValue(tmp, 6); - gid = ZipShort.getValue(tmp, 8); - - if (linkArray.length == 0) { - link = ""; - } else { - System.arraycopy(tmp, 10, linkArray, 0, linkArray.length); - link = new String(linkArray); - } - setDirectory((newMode & DIR_FLAG) != 0); - setMode(newMode); - } - - /** - * Get the file mode for given permissions with the correct file type. - * @param mode the mode - * @return the type with the mode - * @since 1.1 - */ - protected int getMode(int mode) { - int type = FILE_FLAG; - if (isLink()) { - type = LINK_FLAG; - } else if (isDirectory()) { - type = DIR_FLAG; - } - return type | (mode & PERM_MASK); + setDirectory((newMode & DIR_FLAG) != 0); + setMode(newMode); + } + + /** + * Get the file mode for given permissions with the correct file type. + * + * @param mode + * the mode + * @return the type with the mode + * @since 1.1 + */ + protected int getMode(int mode) { + int type = FILE_FLAG; + if (isLink()) { + type = LINK_FLAG; + } else if (isDirectory()) { + type = DIR_FLAG; } + return type | (mode & PERM_MASK); + } } diff --git a/src/org/apache/tools/zip/ExtraFieldUtils.java b/src/org/apache/tools/zip/ExtraFieldUtils.java index e9811f4..e93b4d3 100644 --- a/src/org/apache/tools/zip/ExtraFieldUtils.java +++ b/src/org/apache/tools/zip/ExtraFieldUtils.java @@ -24,151 +24,163 @@ import java.util.zip.ZipException; /** * ZipExtraField related methods - * + * */ public class ExtraFieldUtils { - /** - * Static registry of known extra fields. - * - * @since 1.1 - */ - private static Hashtable implementations; + /** + * Static registry of known extra fields. + * + * @since 1.1 + */ + private static Hashtable implementations; + + static { + implementations = new Hashtable(); + register(AsiExtraField.class); + register(JarMarker.class); + } - static { - implementations = new Hashtable(); - register(AsiExtraField.class); - register(JarMarker.class); + /** + * Register a ZipExtraField implementation. + * + *

+ * The given class must have a no-arg constructor and implement the + * {@link ZipExtraField ZipExtraField interface}. + *

+ * + * @param c + * the class to register + * + * @since 1.1 + */ + public static void register(Class c) { + try { + ZipExtraField ze = (ZipExtraField) c.newInstance(); + implementations.put(ze.getHeaderId(), c); + } catch (ClassCastException cc) { + throw new RuntimeException(c + " doesn\'t implement ZipExtraField"); + } catch (InstantiationException ie) { + throw new RuntimeException(c + " is not a concrete class"); + } catch (IllegalAccessException ie) { + throw new RuntimeException(c + "\'s no-arg constructor is not public"); } + } - /** - * Register a ZipExtraField implementation. - * - *

The given class must have a no-arg constructor and implement - * the {@link ZipExtraField ZipExtraField interface}.

- * @param c the class to register - * - * @since 1.1 - */ - public static void register(Class c) { - try { - ZipExtraField ze = (ZipExtraField) c.newInstance(); - implementations.put(ze.getHeaderId(), c); - } catch (ClassCastException cc) { - throw new RuntimeException(c + " doesn\'t implement ZipExtraField"); - } catch (InstantiationException ie) { - throw new RuntimeException(c + " is not a concrete class"); - } catch (IllegalAccessException ie) { - throw new RuntimeException(c + "\'s no-arg constructor is not public"); - } + /** + * Create an instance of the approriate ExtraField, falls back to + * {@link UnrecognizedExtraField UnrecognizedExtraField}. + * + * @param headerId + * the header identifier + * @return an instance of the appropiate ExtraField + * @exception InstantiationException + * if unable to instantiate the class + * @exception IllegalAccessException + * if not allowed to instatiate the class + * @since 1.1 + */ + public static ZipExtraField createExtraField(ZipShort headerId) + throws InstantiationException, IllegalAccessException { + Class c = (Class) implementations.get(headerId); + if (c != null) { + return (ZipExtraField) c.newInstance(); } + UnrecognizedExtraField u = new UnrecognizedExtraField(); + u.setHeaderId(headerId); + return u; + } - /** - * Create an instance of the approriate ExtraField, falls back to - * {@link UnrecognizedExtraField UnrecognizedExtraField}. - * @param headerId the header identifier - * @return an instance of the appropiate ExtraField - * @exception InstantiationException if unable to instantiate the class - * @exception IllegalAccessException if not allowed to instatiate the class - * @since 1.1 - */ - public static ZipExtraField createExtraField(ZipShort headerId) - throws InstantiationException, IllegalAccessException { - Class c = (Class) implementations.get(headerId); - if (c != null) { - return (ZipExtraField) c.newInstance(); - } - UnrecognizedExtraField u = new UnrecognizedExtraField(); - u.setHeaderId(headerId); - return u; + /** + * Split the array into ExtraFields and populate them with the give data. + * + * @param data + * an array of bytes + * @return an array of ExtraFields + * @since 1.1 + * @throws ZipException + * on error + */ + public static ZipExtraField[] parse(byte[] data) throws ZipException { + Vector v = new Vector(); + int start = 0; + while (start <= data.length - 4) { + ZipShort headerId = new ZipShort(data, start); + int length = (new ZipShort(data, start + 2)).getValue(); + if (start + 4 + length > data.length) { + throw new ZipException("data starting at " + start + + " is in unknown format"); + } + try { + ZipExtraField ze = createExtraField(headerId); + ze.parseFromLocalFileData(data, start + 4, length); + v.addElement(ze); + } catch (InstantiationException ie) { + throw new ZipException(ie.getMessage()); + } catch (IllegalAccessException iae) { + throw new ZipException(iae.getMessage()); + } + start += (length + 4); + } + if (start != data.length) { // array not exhausted + throw new ZipException("data starting at " + start + + " is in unknown format"); } - /** - * Split the array into ExtraFields and populate them with the - * give data. - * @param data an array of bytes - * @return an array of ExtraFields - * @since 1.1 - * @throws ZipException on error - */ - public static ZipExtraField[] parse(byte[] data) throws ZipException { - Vector v = new Vector(); - int start = 0; - while (start <= data.length - 4) { - ZipShort headerId = new ZipShort(data, start); - int length = (new ZipShort(data, start + 2)).getValue(); - if (start + 4 + length > data.length) { - throw new ZipException("data starting at " + start - + " is in unknown format"); - } - try { - ZipExtraField ze = createExtraField(headerId); - ze.parseFromLocalFileData(data, start + 4, length); - v.addElement(ze); - } catch (InstantiationException ie) { - throw new ZipException(ie.getMessage()); - } catch (IllegalAccessException iae) { - throw new ZipException(iae.getMessage()); - } - start += (length + 4); - } - if (start != data.length) { // array not exhausted - throw new ZipException("data starting at " + start - + " is in unknown format"); - } + ZipExtraField[] result = new ZipExtraField[v.size()]; + v.copyInto(result); + return result; + } - ZipExtraField[] result = new ZipExtraField[v.size()]; - v.copyInto(result); - return result; + /** + * Merges the local file data fields of the given ZipExtraFields. + * + * @param data + * an array of ExtraFiles + * @return an array of bytes + * @since 1.1 + */ + public static byte[] mergeLocalFileDataData(ZipExtraField[] data) { + int sum = 4 * data.length; + for (int i = 0; i < data.length; i++) { + sum += data[i].getLocalFileDataLength().getValue(); } - - /** - * Merges the local file data fields of the given ZipExtraFields. - * @param data an array of ExtraFiles - * @return an array of bytes - * @since 1.1 - */ - public static byte[] mergeLocalFileDataData(ZipExtraField[] data) { - int sum = 4 * data.length; - for (int i = 0; i < data.length; i++) { - sum += data[i].getLocalFileDataLength().getValue(); - } - byte[] result = new byte[sum]; - int start = 0; - for (int i = 0; i < data.length; i++) { - System.arraycopy(data[i].getHeaderId().getBytes(), - 0, result, start, 2); - System.arraycopy(data[i].getLocalFileDataLength().getBytes(), - 0, result, start + 2, 2); - byte[] local = data[i].getLocalFileDataData(); - System.arraycopy(local, 0, result, start + 4, local.length); - start += (local.length + 4); - } - return result; + byte[] result = new byte[sum]; + int start = 0; + for (int i = 0; i < data.length; i++) { + System.arraycopy(data[i].getHeaderId().getBytes(), 0, result, start, 2); + System.arraycopy(data[i].getLocalFileDataLength().getBytes(), 0, result, + start + 2, 2); + byte[] local = data[i].getLocalFileDataData(); + System.arraycopy(local, 0, result, start + 4, local.length); + start += (local.length + 4); } + return result; + } - /** - * Merges the central directory fields of the given ZipExtraFields. - * @param data an array of ExtraFields - * @return an array of bytes - * @since 1.1 - */ - public static byte[] mergeCentralDirectoryData(ZipExtraField[] data) { - int sum = 4 * data.length; - for (int i = 0; i < data.length; i++) { - sum += data[i].getCentralDirectoryLength().getValue(); - } - byte[] result = new byte[sum]; - int start = 0; - for (int i = 0; i < data.length; i++) { - System.arraycopy(data[i].getHeaderId().getBytes(), - 0, result, start, 2); - System.arraycopy(data[i].getCentralDirectoryLength().getBytes(), - 0, result, start + 2, 2); - byte[] local = data[i].getCentralDirectoryData(); - System.arraycopy(local, 0, result, start + 4, local.length); - start += (local.length + 4); - } - return result; + /** + * Merges the central directory fields of the given ZipExtraFields. + * + * @param data + * an array of ExtraFields + * @return an array of bytes + * @since 1.1 + */ + public static byte[] mergeCentralDirectoryData(ZipExtraField[] data) { + int sum = 4 * data.length; + for (int i = 0; i < data.length; i++) { + sum += data[i].getCentralDirectoryLength().getValue(); + } + byte[] result = new byte[sum]; + int start = 0; + for (int i = 0; i < data.length; i++) { + System.arraycopy(data[i].getHeaderId().getBytes(), 0, result, start, 2); + System.arraycopy(data[i].getCentralDirectoryLength().getBytes(), 0, + result, start + 2, 2); + byte[] local = data[i].getCentralDirectoryData(); + System.arraycopy(local, 0, result, start + 4, local.length); + start += (local.length + 4); } + return result; + } } diff --git a/src/org/apache/tools/zip/JarMarker.java b/src/org/apache/tools/zip/JarMarker.java index c063353..70141e9 100644 --- a/src/org/apache/tools/zip/JarMarker.java +++ b/src/org/apache/tools/zip/JarMarker.java @@ -21,88 +21,102 @@ package org.apache.tools.zip; import java.util.zip.ZipException; /** - * If this extra field is added as the very first extra field of the - * archive, Solaris will consider it an executable jar file. - * + * If this extra field is added as the very first extra field of the archive, + * Solaris will consider it an executable jar file. + * * @since Ant 1.6.3 */ public final class JarMarker implements ZipExtraField { - private static final ZipShort ID = new ZipShort(0xCAFE); - private static final ZipShort NULL = new ZipShort(0); - private static final byte[] NO_BYTES = new byte[0]; - private static final JarMarker DEFAULT = new JarMarker(); + private static final ZipShort ID = new ZipShort(0xCAFE); - /** No-arg constructor */ - public JarMarker() { - // empty - } + private static final ZipShort NULL = new ZipShort(0); - /** - * Since JarMarker is stateless we can always use the same instance. - * @return the DEFAULT jarmaker. - */ - public static JarMarker getInstance() { - return DEFAULT; - } + private static final byte[] NO_BYTES = new byte[0]; - /** - * The Header-ID. - * @return the header id - */ - public ZipShort getHeaderId() { - return ID; - } + private static final JarMarker DEFAULT = new JarMarker(); - /** - * Length of the extra field in the local file data - without - * Header-ID or length specifier. - * @return 0 - */ - public ZipShort getLocalFileDataLength() { - return NULL; - } + /** No-arg constructor */ + public JarMarker() { + // empty + } - /** - * Length of the extra field in the central directory - without - * Header-ID or length specifier. - * @return 0 - */ - public ZipShort getCentralDirectoryLength() { - return NULL; - } + /** + * Since JarMarker is stateless we can always use the same instance. + * + * @return the DEFAULT jarmaker. + */ + public static JarMarker getInstance() { + return DEFAULT; + } - /** - * The actual data to put into local file data - without Header-ID - * or length specifier. - * @return the data - * @since 1.1 - */ - public byte[] getLocalFileDataData() { - return NO_BYTES; - } + /** + * The Header-ID. + * + * @return the header id + */ + public ZipShort getHeaderId() { + return ID; + } - /** - * The actual data to put central directory - without Header-ID or - * length specifier. - * @return the data - */ - public byte[] getCentralDirectoryData() { - return NO_BYTES; - } + /** + * Length of the extra field in the local file data - without Header-ID or + * length specifier. + * + * @return 0 + */ + public ZipShort getLocalFileDataLength() { + return NULL; + } + + /** + * Length of the extra field in the central directory - without Header-ID or + * length specifier. + * + * @return 0 + */ + public ZipShort getCentralDirectoryLength() { + return NULL; + } + + /** + * The actual data to put into local file data - without Header-ID or length + * specifier. + * + * @return the data + * @since 1.1 + */ + public byte[] getLocalFileDataData() { + return NO_BYTES; + } + + /** + * The actual data to put central directory - without Header-ID or length + * specifier. + * + * @return the data + */ + public byte[] getCentralDirectoryData() { + return NO_BYTES; + } - /** - * Populate data from this array as if it was in local file data. - * @param data an array of bytes - * @param offset the start offset - * @param length the number of bytes in the array from offset - * - * @throws ZipException on error - */ - public void parseFromLocalFileData(byte[] data, int offset, int length) - throws ZipException { - if (length != 0) { - throw new ZipException("JarMarker doesn't expect any data"); - } + /** + * Populate data from this array as if it was in local file data. + * + * @param data + * an array of bytes + * @param offset + * the start offset + * @param length + * the number of bytes in the array from offset + * + * @throws ZipException + * on error + */ + public void parseFromLocalFileData(byte[] data, int offset, int length) + throws ZipException { + if (length != 0) { + throw new ZipException("JarMarker doesn't expect any data"); } + } } diff --git a/src/org/apache/tools/zip/UnixStat.java b/src/org/apache/tools/zip/UnixStat.java index 3509ec4..a176692 100644 --- a/src/org/apache/tools/zip/UnixStat.java +++ b/src/org/apache/tools/zip/UnixStat.java @@ -20,56 +20,61 @@ package org.apache.tools.zip; /** * Constants from stat.h on Unix systems. - * + * */ public interface UnixStat { - /** - * Bits used for permissions (and sticky bit) - * - * @since 1.1 - */ - int PERM_MASK = 07777; - /** - * Indicates symbolic links. - * - * @since 1.1 - */ - int LINK_FLAG = 0120000; - /** - * Indicates plain files. - * - * @since 1.1 - */ - int FILE_FLAG = 0100000; - /** - * Indicates directories. - * - * @since 1.1 - */ - int DIR_FLAG = 040000; + /** + * Bits used for permissions (and sticky bit) + * + * @since 1.1 + */ + int PERM_MASK = 07777; + + /** + * Indicates symbolic links. + * + * @since 1.1 + */ + int LINK_FLAG = 0120000; + + /** + * Indicates plain files. + * + * @since 1.1 + */ + int FILE_FLAG = 0100000; + + /** + * Indicates directories. + * + * @since 1.1 + */ + int DIR_FLAG = 040000; + + // ---------------------------------------------------------- + // somewhat arbitrary choices that are quite common for shared + // installations + // ----------------------------------------------------------- + + /** + * Default permissions for symbolic links. + * + * @since 1.1 + */ + int DEFAULT_LINK_PERM = 0777; - // ---------------------------------------------------------- - // somewhat arbitrary choices that are quite common for shared - // installations - // ----------------------------------------------------------- + /** + * Default permissions for directories. + * + * @since 1.1 + */ + int DEFAULT_DIR_PERM = 0755; - /** - * Default permissions for symbolic links. - * - * @since 1.1 - */ - int DEFAULT_LINK_PERM = 0777; - /** - * Default permissions for directories. - * - * @since 1.1 - */ - int DEFAULT_DIR_PERM = 0755; - /** - * Default permissions for plain files. - * - * @since 1.1 - */ - int DEFAULT_FILE_PERM = 0644; + /** + * Default permissions for plain files. + * + * @since 1.1 + */ + int DEFAULT_FILE_PERM = 0644; } diff --git a/src/org/apache/tools/zip/UnrecognizedExtraField.java b/src/org/apache/tools/zip/UnrecognizedExtraField.java index 79f2e6e..280a62e 100644 --- a/src/org/apache/tools/zip/UnrecognizedExtraField.java +++ b/src/org/apache/tools/zip/UnrecognizedExtraField.java @@ -19,119 +19,134 @@ package org.apache.tools.zip; /** - * Simple placeholder for all those extra fields we don't want to deal - * with. - * - *

Assumes local file data and central directory entries are - * identical - unless told the opposite.

- * + * Simple placeholder for all those extra fields we don't want to deal with. + * + *

+ * Assumes local file data and central directory entries are identical - unless + * told the opposite. + *

+ * */ public class UnrecognizedExtraField implements ZipExtraField { - /** - * The Header-ID. - * - * @since 1.1 - */ - private ZipShort headerId; + /** + * The Header-ID. + * + * @since 1.1 + */ + private ZipShort headerId; - /** - * Set the header id. - * @param headerId the header id to use - */ - public void setHeaderId(ZipShort headerId) { - this.headerId = headerId; - } + /** + * Set the header id. + * + * @param headerId + * the header id to use + */ + public void setHeaderId(ZipShort headerId) { + this.headerId = headerId; + } - /** - * Get the header id. - * @return the header id - */ - public ZipShort getHeaderId() { - return headerId; - } + /** + * Get the header id. + * + * @return the header id + */ + public ZipShort getHeaderId() { + return headerId; + } - /** - * Extra field data in local file data - without - * Header-ID or length specifier. - * - * @since 1.1 - */ - private byte[] localData; + /** + * Extra field data in local file data - without Header-ID or length + * specifier. + * + * @since 1.1 + */ + private byte[] localData; - /** - * Set the extra field data in the local file data - - * without Header-ID or length specifier. - * @param data the field data to use - */ - public void setLocalFileDataData(byte[] data) { - localData = data; - } + /** + * Set the extra field data in the local file data - without Header-ID or + * length specifier. + * + * @param data + * the field data to use + */ + public void setLocalFileDataData(byte[] data) { + localData = data; + } - /** - * Get the length of the local data. - * @return the length of the local data - */ - public ZipShort getLocalFileDataLength() { - return new ZipShort(localData.length); - } + /** + * Get the length of the local data. + * + * @return the length of the local data + */ + public ZipShort getLocalFileDataLength() { + return new ZipShort(localData.length); + } - /** - * Get the local data. - * @return the local data - */ - public byte[] getLocalFileDataData() { - return localData; - } + /** + * Get the local data. + * + * @return the local data + */ + public byte[] getLocalFileDataData() { + return localData; + } - /** - * Extra field data in central directory - without - * Header-ID or length specifier. - * - * @since 1.1 - */ - private byte[] centralData; + /** + * Extra field data in central directory - without Header-ID or length + * specifier. + * + * @since 1.1 + */ + private byte[] centralData; - /** - * Set the extra field data in central directory. - * @param data the data to use - */ - public void setCentralDirectoryData(byte[] data) { - centralData = data; - } + /** + * Set the extra field data in central directory. + * + * @param data + * the data to use + */ + public void setCentralDirectoryData(byte[] data) { + centralData = data; + } - /** - * Get the central data length. - * If there is no central data, get the local file data length. - * @return the central data length - */ - public ZipShort getCentralDirectoryLength() { - if (centralData != null) { - return new ZipShort(centralData.length); - } - return getLocalFileDataLength(); + /** + * Get the central data length. If there is no central data, get the local + * file data length. + * + * @return the central data length + */ + public ZipShort getCentralDirectoryLength() { + if (centralData != null) { + return new ZipShort(centralData.length); } + return getLocalFileDataLength(); + } - /** - * Get the central data. - * @return the central data if present, else return the local file data - */ - public byte[] getCentralDirectoryData() { - if (centralData != null) { - return centralData; - } - return getLocalFileDataData(); + /** + * Get the central data. + * + * @return the central data if present, else return the local file data + */ + public byte[] getCentralDirectoryData() { + if (centralData != null) { + return centralData; } + return getLocalFileDataData(); + } - /** - * @param data the array of bytes. - * @param offset the source location in the data array. - * @param length the number of bytes to use in the data array. - * @see ZipExtraField#parseFromLocalFileData(byte[], int, int) - */ - public void parseFromLocalFileData(byte[] data, int offset, int length) { - byte[] tmp = new byte[length]; - System.arraycopy(data, offset, tmp, 0, length); - setLocalFileDataData(tmp); - } + /** + * @param data + * the array of bytes. + * @param offset + * the source location in the data array. + * @param length + * the number of bytes to use in the data array. + * @see ZipExtraField#parseFromLocalFileData(byte[], int, int) + */ + public void parseFromLocalFileData(byte[] data, int offset, int length) { + byte[] tmp = new byte[length]; + System.arraycopy(data, offset, tmp, 0, length); + setLocalFileDataData(tmp); + } } diff --git a/src/org/apache/tools/zip/ZipEntry.java b/src/org/apache/tools/zip/ZipEntry.java index fc43e02..ed558fa 100644 --- a/src/org/apache/tools/zip/ZipEntry.java +++ b/src/org/apache/tools/zip/ZipEntry.java @@ -22,347 +22,392 @@ import java.util.Vector; import java.util.zip.ZipException; /** - * Extension that adds better handling of extra fields and provides - * access to the internal and external file attributes. - * + * Extension that adds better handling of extra fields and provides access to + * the internal and external file attributes. + * */ public class ZipEntry extends java.util.zip.ZipEntry implements Cloneable { - private static final int PLATFORM_UNIX = 3; - private static final int PLATFORM_FAT = 0; - - private int internalAttributes = 0; - private int platform = PLATFORM_FAT; - private long externalAttributes = 0; - private Vector/**/ extraFields = null; - private String name = null; - - /** - * Creates a new zip entry with the specified name. - * @param name the name of the entry - * @since 1.1 - */ - public ZipEntry(String name) { - super(name); - } - - /** - * Creates a new zip entry with fields taken from the specified zip entry. - * @param entry the entry to get fields from - * @since 1.1 - * @throws ZipException on error - */ - public ZipEntry(java.util.zip.ZipEntry entry) throws ZipException { - super(entry); - byte[] extra = entry.getExtra(); - if (extra != null) { - setExtraFields(ExtraFieldUtils.parse(extra)); - } else { - // initializes extra data to an empty byte array - setExtra(); - } - } - - /** - * Creates a new zip entry with fields taken from the specified zip entry. - * @param entry the entry to get fields from - * @throws ZipException on error - * @since 1.1 - */ - public ZipEntry(ZipEntry entry) throws ZipException { - this((java.util.zip.ZipEntry) entry); - setInternalAttributes(entry.getInternalAttributes()); - setExternalAttributes(entry.getExternalAttributes()); - setExtraFields(entry.getExtraFields()); - } - - /** - * @since 1.9 - */ - protected ZipEntry() { - super(""); - } - - /** - * Overwrite clone. - * @return a cloned copy of this ZipEntry - * @since 1.1 - */ - public Object clone() { - ZipEntry e = (ZipEntry) super.clone(); - - e.extraFields = extraFields != null ? (Vector) extraFields.clone() : null; - e.setInternalAttributes(getInternalAttributes()); - e.setExternalAttributes(getExternalAttributes()); - e.setExtraFields(getExtraFields()); - return e; - } - - /** - * Retrieves the internal file attributes. - * - * @return the internal file attributes - * @since 1.1 - */ - public int getInternalAttributes() { - return internalAttributes; - } - - /** - * Sets the internal file attributes. - * @param value an int value - * @since 1.1 - */ - public void setInternalAttributes(int value) { - internalAttributes = value; - } - - /** - * Retrieves the external file attributes. - * @return the external file attributes - * @since 1.1 - */ - public long getExternalAttributes() { - return externalAttributes; - } - - /** - * Sets the external file attributes. - * @param value an long value - * @since 1.1 - */ - public void setExternalAttributes(long value) { - externalAttributes = value; - } - - /** - * Sets Unix permissions in a way that is understood by Info-Zip's - * unzip command. - * @param mode an int value - * @since Ant 1.5.2 - */ - public void setUnixMode(int mode) { - setExternalAttributes((mode << 16) - // MS-DOS read-only attribute - | ((mode & 0200) == 0 ? 1 : 0) - // MS-DOS directory flag - | (isDirectory() ? 0x10 : 0)); - platform = PLATFORM_UNIX; - } - - /** - * Unix permission. - * @return the unix permissions - * @since Ant 1.6 - */ - public int getUnixMode() { - return (int) ((getExternalAttributes() >> 16) & 0xFFFF); - } - - /** - * Platform specification to put into the "version made - * by" part of the central file header. - * - * @return 0 (MS-DOS FAT) unless {@link #setUnixMode setUnixMode} - * has been called, in which case 3 (Unix) will be returned. - * - * @since Ant 1.5.2 - */ - public int getPlatform() { - return platform; - } - - /** - * Set the platform (UNIX or FAT). - * @param platform an int value - 0 is FAT, 3 is UNIX - * @since 1.9 - */ - protected void setPlatform(int platform) { - this.platform = platform; - } - - /** - * Replaces all currently attached extra fields with the new array. - * @param fields an array of extra fields - * @since 1.1 - */ - public void setExtraFields(ZipExtraField[] fields) { - extraFields = new Vector(); - for (int i = 0; i < fields.length; i++) { - extraFields.addElement(fields[i]); - } - setExtra(); - } - - /** - * Retrieves extra fields. - * @return an array of the extra fields - * @since 1.1 - */ - public ZipExtraField[] getExtraFields() { - if (extraFields == null) { - return new ZipExtraField[0]; - } - ZipExtraField[] result = new ZipExtraField[extraFields.size()]; - extraFields.copyInto(result); - return result; - } - - /** - * Adds an extra fields - replacing an already present extra field - * of the same type. - * @param ze an extra field - * @since 1.1 - */ - public void addExtraField(ZipExtraField ze) { - if (extraFields == null) { - extraFields = new Vector(); - } - ZipShort type = ze.getHeaderId(); - boolean done = false; - for (int i = 0, fieldsSize = extraFields.size(); !done && i < fieldsSize; i++) { - if (((ZipExtraField) extraFields.elementAt(i)).getHeaderId().equals(type)) { - extraFields.setElementAt(ze, i); - done = true; - } - } - if (!done) { - extraFields.addElement(ze); - } - setExtra(); - } - - /** - * Remove an extra fields. - * @param type the type of extra field to remove - * @since 1.1 - */ - public void removeExtraField(ZipShort type) { - if (extraFields == null) { - extraFields = new Vector(); - } - boolean done = false; - for (int i = 0, fieldsSize = extraFields.size(); !done && i < fieldsSize; i++) { - if (((ZipExtraField) extraFields.elementAt(i)).getHeaderId().equals(type)) { - extraFields.removeElementAt(i); - done = true; - } - } - if (!done) { - throw new java.util.NoSuchElementException(); - } - setExtra(); + private static final int PLATFORM_UNIX = 3; + + private static final int PLATFORM_FAT = 0; + + private int internalAttributes = 0; + + private int platform = PLATFORM_FAT; + + private long externalAttributes = 0; + + private Vector/* */extraFields = null; + + private String name = null; + + /** + * Creates a new zip entry with the specified name. + * + * @param name + * the name of the entry + * @since 1.1 + */ + public ZipEntry(String name) { + super(name); + } + + /** + * Creates a new zip entry with fields taken from the specified zip entry. + * + * @param entry + * the entry to get fields from + * @since 1.1 + * @throws ZipException + * on error + */ + public ZipEntry(java.util.zip.ZipEntry entry) throws ZipException { + super(entry); + byte[] extra = entry.getExtra(); + if (extra != null) { + setExtraFields(ExtraFieldUtils.parse(extra)); + } else { + // initializes extra data to an empty byte array + setExtra(); } - - /** - * Throws an Exception if extra data cannot be parsed into extra fields. - * @param extra an array of bytes to be parsed into extra fields - * @throws RuntimeException if the bytes cannot be parsed - * @since 1.1 - * @throws RuntimeException on error - */ - public void setExtra(byte[] extra) throws RuntimeException { - try { - setExtraFields(ExtraFieldUtils.parse(extra)); - } catch (Exception e) { - throw new RuntimeException(e.getMessage()); - } + } + + /** + * Creates a new zip entry with fields taken from the specified zip entry. + * + * @param entry + * the entry to get fields from + * @throws ZipException + * on error + * @since 1.1 + */ + public ZipEntry(ZipEntry entry) throws ZipException { + this((java.util.zip.ZipEntry) entry); + setInternalAttributes(entry.getInternalAttributes()); + setExternalAttributes(entry.getExternalAttributes()); + setExtraFields(entry.getExtraFields()); + } + + /** + * @since 1.9 + */ + protected ZipEntry() { + super(""); + } + + /** + * Overwrite clone. + * + * @return a cloned copy of this ZipEntry + * @since 1.1 + */ + public Object clone() { + ZipEntry e = (ZipEntry) super.clone(); + + e.extraFields = extraFields != null ? (Vector) extraFields.clone() : null; + e.setInternalAttributes(getInternalAttributes()); + e.setExternalAttributes(getExternalAttributes()); + e.setExtraFields(getExtraFields()); + return e; + } + + /** + * Retrieves the internal file attributes. + * + * @return the internal file attributes + * @since 1.1 + */ + public int getInternalAttributes() { + return internalAttributes; + } + + /** + * Sets the internal file attributes. + * + * @param value + * an int value + * @since 1.1 + */ + public void setInternalAttributes(int value) { + internalAttributes = value; + } + + /** + * Retrieves the external file attributes. + * + * @return the external file attributes + * @since 1.1 + */ + public long getExternalAttributes() { + return externalAttributes; + } + + /** + * Sets the external file attributes. + * + * @param value + * an long value + * @since 1.1 + */ + public void setExternalAttributes(long value) { + externalAttributes = value; + } + + /** + * Sets Unix permissions in a way that is understood by Info-Zip's unzip + * command. + * + * @param mode + * an int value + * @since Ant 1.5.2 + */ + public void setUnixMode(int mode) { + setExternalAttributes((mode << 16) + // MS-DOS read-only attribute + | ((mode & 0200) == 0 ? 1 : 0) + // MS-DOS directory flag + | (isDirectory() ? 0x10 : 0)); + platform = PLATFORM_UNIX; + } + + /** + * Unix permission. + * + * @return the unix permissions + * @since Ant 1.6 + */ + public int getUnixMode() { + return (int) ((getExternalAttributes() >> 16) & 0xFFFF); + } + + /** + * Platform specification to put into the "version made by" part of + * the central file header. + * + * @return 0 (MS-DOS FAT) unless {@link #setUnixMode setUnixMode} has been + * called, in which case 3 (Unix) will be returned. + * + * @since Ant 1.5.2 + */ + public int getPlatform() { + return platform; + } + + /** + * Set the platform (UNIX or FAT). + * + * @param platform + * an int value - 0 is FAT, 3 is UNIX + * @since 1.9 + */ + protected void setPlatform(int platform) { + this.platform = platform; + } + + /** + * Replaces all currently attached extra fields with the new array. + * + * @param fields + * an array of extra fields + * @since 1.1 + */ + public void setExtraFields(ZipExtraField[] fields) { + extraFields = new Vector(); + for (int i = 0; i < fields.length; i++) { + extraFields.addElement(fields[i]); } - - /** - * Unfortunately {@link java.util.zip.ZipOutputStream - * java.util.zip.ZipOutputStream} seems to access the extra data - * directly, so overriding getExtra doesn't help - we need to - * modify super's data directly. - * - * @since 1.1 - */ - protected void setExtra() { - super.setExtra(ExtraFieldUtils.mergeLocalFileDataData(getExtraFields())); + setExtra(); + } + + /** + * Retrieves extra fields. + * + * @return an array of the extra fields + * @since 1.1 + */ + public ZipExtraField[] getExtraFields() { + if (extraFields == null) { + return new ZipExtraField[0]; } - - /** - * Retrieves the extra data for the local file data. - * @return the extra data for local file - * @since 1.1 - */ - public byte[] getLocalFileDataExtra() { - byte[] extra = getExtra(); - return extra != null ? extra : new byte[0]; + ZipExtraField[] result = new ZipExtraField[extraFields.size()]; + extraFields.copyInto(result); + return result; + } + + /** + * Adds an extra fields - replacing an already present extra field of the same + * type. + * + * @param ze + * an extra field + * @since 1.1 + */ + public void addExtraField(ZipExtraField ze) { + if (extraFields == null) { + extraFields = new Vector(); } - - /** - * Retrieves the extra data for the central directory. - * @return the central directory extra data - * @since 1.1 - */ - public byte[] getCentralDirectoryExtra() { - return ExtraFieldUtils.mergeCentralDirectoryData(getExtraFields()); + ZipShort type = ze.getHeaderId(); + boolean done = false; + for (int i = 0, fieldsSize = extraFields.size(); !done && i < fieldsSize; i++) { + if (((ZipExtraField) extraFields.elementAt(i)).getHeaderId().equals(type)) { + extraFields.setElementAt(ze, i); + done = true; + } } - - /** - * Make this class work in JDK 1.1 like a 1.2 class. - * - *

This either stores the size for later usage or invokes - * setCompressedSize via reflection.

- * @param size the size to use - * @deprecated since 1.7. - * Use setCompressedSize directly. - * @since 1.2 - */ - public void setComprSize(long size) { - setCompressedSize(size); + if (!done) { + extraFields.addElement(ze); } - - /** - * Get the name of the entry. - * @return the entry name - * @since 1.9 - */ - public String getName() { - return name == null ? super.getName() : name; + setExtra(); + } + + /** + * Remove an extra fields. + * + * @param type + * the type of extra field to remove + * @since 1.1 + */ + public void removeExtraField(ZipShort type) { + if (extraFields == null) { + extraFields = new Vector(); } - - /** - * Is this entry a directory? - * @return true if the entry is a directory - * @since 1.10 - */ - public boolean isDirectory() { - return getName().endsWith("/"); + boolean done = false; + for (int i = 0, fieldsSize = extraFields.size(); !done && i < fieldsSize; i++) { + if (((ZipExtraField) extraFields.elementAt(i)).getHeaderId().equals(type)) { + extraFields.removeElementAt(i); + done = true; + } } - - /** - * Set the name of the entry. - * @param name the name to use - */ - protected void setName(String name) { - this.name = name; + if (!done) { + throw new java.util.NoSuchElementException(); } - - /** - * Get the hashCode of the entry. - * This uses the name as the hashcode. - * @return a hashcode. - * @since Ant 1.7 - */ - public int hashCode() { - // this method has severe consequences on performance. We cannot rely - // on the super.hashCode() method since super.getName() always return - // the empty string in the current implemention (there's no setter) - // so it is basically draining the performance of a hashmap lookup - return getName().hashCode(); - } - - /** - * The equality method. In this case, the implementation returns 'this == o' - * which is basically the equals method of the Object class. - * @param o the object to compare to - * @return true if this object is the same as o - * @since Ant 1.7 - */ - public boolean equals(Object o) { - return (this == o); + setExtra(); + } + + /** + * Throws an Exception if extra data cannot be parsed into extra fields. + * + * @param extra + * an array of bytes to be parsed into extra fields + * @throws RuntimeException + * if the bytes cannot be parsed + * @since 1.1 + * @throws RuntimeException + * on error + */ + public void setExtra(byte[] extra) throws RuntimeException { + try { + setExtraFields(ExtraFieldUtils.parse(extra)); + } catch (Exception e) { + throw new RuntimeException(e.getMessage()); } + } + + /** + * Unfortunately {@link java.util.zip.ZipOutputStream + * java.util.zip.ZipOutputStream} seems to access the extra data directly, so + * overriding getExtra doesn't help - we need to modify super's data directly. + * + * @since 1.1 + */ + protected void setExtra() { + super.setExtra(ExtraFieldUtils.mergeLocalFileDataData(getExtraFields())); + } + + /** + * Retrieves the extra data for the local file data. + * + * @return the extra data for local file + * @since 1.1 + */ + public byte[] getLocalFileDataExtra() { + byte[] extra = getExtra(); + return extra != null ? extra : new byte[0]; + } + + /** + * Retrieves the extra data for the central directory. + * + * @return the central directory extra data + * @since 1.1 + */ + public byte[] getCentralDirectoryExtra() { + return ExtraFieldUtils.mergeCentralDirectoryData(getExtraFields()); + } + + /** + * Make this class work in JDK 1.1 like a 1.2 class. + * + *

+ * This either stores the size for later usage or invokes setCompressedSize + * via reflection. + *

+ * + * @param size + * the size to use + * @deprecated since 1.7. Use setCompressedSize directly. + * @since 1.2 + */ + public void setComprSize(long size) { + setCompressedSize(size); + } + + /** + * Get the name of the entry. + * + * @return the entry name + * @since 1.9 + */ + public String getName() { + return name == null ? super.getName() : name; + } + + /** + * Is this entry a directory? + * + * @return true if the entry is a directory + * @since 1.10 + */ + public boolean isDirectory() { + return getName().endsWith("/"); + } + + /** + * Set the name of the entry. + * + * @param name + * the name to use + */ + protected void setName(String name) { + this.name = name; + } + + /** + * Get the hashCode of the entry. This uses the name as the hashcode. + * + * @return a hashcode. + * @since Ant 1.7 + */ + public int hashCode() { + // this method has severe consequences on performance. We cannot rely + // on the super.hashCode() method since super.getName() always return + // the empty string in the current implemention (there's no setter) + // so it is basically draining the performance of a hashmap lookup + return getName().hashCode(); + } + + /** + * The equality method. In this case, the implementation returns 'this == o' + * which is basically the equals method of the Object class. + * + * @param o + * the object to compare to + * @return true if this object is the same as o + * @since Ant 1.7 + */ + public boolean equals(Object o) { + return (this == o); + } } diff --git a/src/org/apache/tools/zip/ZipExtraField.java b/src/org/apache/tools/zip/ZipExtraField.java index 622ff17..a755cd7 100644 --- a/src/org/apache/tools/zip/ZipExtraField.java +++ b/src/org/apache/tools/zip/ZipExtraField.java @@ -22,64 +22,75 @@ import java.util.zip.ZipException; /** * General format of extra field data. - * - *

Extra fields usually appear twice per file, once in the local - * file data and once in the central directory. Usually they are the - * same, but they don't have to be. {@link - * java.util.zip.ZipOutputStream java.util.zip.ZipOutputStream} will - * only use the local file data in both places.

- * + * + *

+ * Extra fields usually appear twice per file, once in the local file data and + * once in the central directory. Usually they are the same, but they don't have + * to be. {@link java.util.zip.ZipOutputStream java.util.zip.ZipOutputStream} + * will only use the local file data in both places. + *

+ * */ public interface ZipExtraField { - /** - * The Header-ID. - * @return the header id - * @since 1.1 - */ - ZipShort getHeaderId(); + /** + * The Header-ID. + * + * @return the header id + * @since 1.1 + */ + ZipShort getHeaderId(); - /** - * Length of the extra field in the local file data - without - * Header-ID or length specifier. - * @return the length of the field in the local file data - * @since 1.1 - */ - ZipShort getLocalFileDataLength(); + /** + * Length of the extra field in the local file data - without Header-ID or + * length specifier. + * + * @return the length of the field in the local file data + * @since 1.1 + */ + ZipShort getLocalFileDataLength(); - /** - * Length of the extra field in the central directory - without - * Header-ID or length specifier. - * @return the length of the field in the central directory - * @since 1.1 - */ - ZipShort getCentralDirectoryLength(); + /** + * Length of the extra field in the central directory - without Header-ID or + * length specifier. + * + * @return the length of the field in the central directory + * @since 1.1 + */ + ZipShort getCentralDirectoryLength(); - /** - * The actual data to put into local file data - without Header-ID - * or length specifier. - * @return the data - * @since 1.1 - */ - byte[] getLocalFileDataData(); + /** + * The actual data to put into local file data - without Header-ID or length + * specifier. + * + * @return the data + * @since 1.1 + */ + byte[] getLocalFileDataData(); - /** - * The actual data to put central directory - without Header-ID or - * length specifier. - * @return the data - * @since 1.1 - */ - byte[] getCentralDirectoryData(); + /** + * The actual data to put central directory - without Header-ID or length + * specifier. + * + * @return the data + * @since 1.1 + */ + byte[] getCentralDirectoryData(); - /** - * Populate data from this array as if it was in local file data. - * @param data an array of bytes - * @param offset the start offset - * @param length the number of bytes in the array from offset - * - * @since 1.1 - * @throws ZipException on error - */ - void parseFromLocalFileData(byte[] data, int offset, int length) - throws ZipException; + /** + * Populate data from this array as if it was in local file data. + * + * @param data + * an array of bytes + * @param offset + * the start offset + * @param length + * the number of bytes in the array from offset + * + * @since 1.1 + * @throws ZipException + * on error + */ + void parseFromLocalFileData(byte[] data, int offset, int length) + throws ZipException; } diff --git a/src/org/apache/tools/zip/ZipFile.java b/src/org/apache/tools/zip/ZipFile.java index 2de51aa..fe757db 100644 --- a/src/org/apache/tools/zip/ZipFile.java +++ b/src/org/apache/tools/zip/ZipFile.java @@ -33,561 +33,597 @@ import java.util.zip.ZipException; /** * Replacement for java.util.ZipFile. - * - *

This class adds support for file name encodings other than UTF-8 - * (which is required to work on ZIP files created by native zip tools - * and is able to skip a preamble like the one found in self - * extracting archives. Furthermore it returns instances of - * org.apache.tools.zip.ZipEntry instead of - * java.util.zip.ZipEntry.

- * - *

It doesn't extend java.util.zip.ZipFile as it would - * have to reimplement all methods anyway. Like - * java.util.ZipFile, it uses RandomAccessFile under the - * covers and supports compressed and uncompressed entries.

- *

For the VAMSAS library, a new constructor was added to pass in - * existing RandomAccessFile directly. This allows the ZIPped data input - * from a file locked under the java.nio.FileChannel.Lock - * mechanism.

- *

The method signatures mimic the ones of - * java.util.zip.ZipFile, with a couple of exceptions: - * + * + *

+ * This class adds support for file name encodings other than UTF-8 (which is + * required to work on ZIP files created by native zip tools and is able to skip + * a preamble like the one found in self extracting archives. Furthermore it + * returns instances of org.apache.tools.zip.ZipEntry instead of + * java.util.zip.ZipEntry. + *

+ * + *

+ * It doesn't extend java.util.zip.ZipFile as it would have to + * reimplement all methods anyway. Like java.util.ZipFile, it uses + * RandomAccessFile under the covers and supports compressed and uncompressed + * entries. + *

+ *

+ * Contribution from Jim Procter (VAMSAS Library)
+ * For the VAMSAS library, a new constructor was added to pass in existing + * RandomAccessFile directly. This allows the ZIPped data input from a file + * locked under the java.nio.FileChannel.Lock mechanism. + *

+ *

+ * The method signatures mimic the ones of java.util.zip.ZipFile, + * with a couple of exceptions: + * *

    - *
  • There is no getName method.
  • - *
  • entries has been renamed to getEntries.
  • - *
  • getEntries and getEntry return - * org.apache.tools.zip.ZipEntry instances.
  • - *
  • close is allowed to throw IOException.
  • + *
  • There is no getName method.
  • + *
  • entries has been renamed to getEntries.
  • + *
  • getEntries and getEntry return org.apache.tools.zip.ZipEntry + * instances.
  • + *
  • close is allowed to throw IOException.
  • *
- * + * */ public class ZipFile { - /** - * Maps ZipEntrys to Longs, recording the offsets of the local - * file headers. - */ - private Hashtable entries = new Hashtable(509); - - /** - * Maps String to ZipEntrys, name -> actual entry. - */ - private Hashtable nameMap = new Hashtable(509); - - private static final class OffsetEntry { - private long headerOffset = -1; - private long dataOffset = -1; - } - - /** - * The encoding to use for filenames and the file comment. - * - *

For a list of possible values see http://java.sun.com/j2se/1.5.0/docs/guide/intl/encoding.doc.html. - * Defaults to the platform's default character encoding.

- */ - private String encoding = null; - - /** - * The actual data source. - */ - private RandomAccessFile archive; - - /** - * Opens the given file for reading, assuming the platform's - * native encoding for file names. - * - * @param f the archive. - * - * @throws IOException if an error occurs while reading the file. - */ - public ZipFile(File f) throws IOException { - this(f, null); - } - - /** - * Opens the given file for reading, assuming the platform's - * native encoding for file names. - * - * @param name name of the archive. - * - * @throws IOException if an error occurs while reading the file. - */ - public ZipFile(String name) throws IOException { - this(new File(name), null); - } - - /** - * Opens the given file for reading, assuming the specified - * encoding for file names. - * - * @param name name of the archive. - * @param encoding the encoding to use for file names - * - * @throws IOException if an error occurs while reading the file. - */ - public ZipFile(String name, String encoding) throws IOException { - this(new File(name), encoding); - } - - /** - * Opens the given file for reading, assuming the specified - * encoding for file names. - * - * @param f the archive. - * @param encoding the encoding to use for file names - * - * @throws IOException if an error occurs while reading the file. - */ - public ZipFile(File f, String encoding) throws IOException { - this(new RandomAccessFile(f, "r"), encoding); + /** + * Maps ZipEntrys to Longs, recording the offsets of the local file headers. + */ + private Hashtable entries = new Hashtable(509); + + /** + * Maps String to ZipEntrys, name -> actual entry. + */ + private Hashtable nameMap = new Hashtable(509); + + private static final class OffsetEntry { + private long headerOffset = -1; + + private long dataOffset = -1; + } + + /** + * The encoding to use for filenames and the file comment. + * + *

+ * For a list of possible values see http://java.sun.com/j2se/1.5.0/docs/guide/intl/encoding.doc.html. + * Defaults to the platform's default character encoding. + *

+ */ + private String encoding = null; + + /** + * The actual data source. + */ + private RandomAccessFile archive; + + /** + * Opens the given file for reading, assuming the platform's native encoding + * for file names. + * + * @param f + * the archive. + * + * @throws IOException + * if an error occurs while reading the file. + */ + public ZipFile(File f) throws IOException { + this(f, null); + } + + /** + * Opens the given file for reading, assuming the platform's native encoding + * for file names. + * + * @param name + * name of the archive. + * + * @throws IOException + * if an error occurs while reading the file. + */ + public ZipFile(String name) throws IOException { + this(new File(name), null); + } + + /** + * Opens the given file for reading, assuming the specified encoding for file + * names. + * + * @param name + * name of the archive. + * @param encoding + * the encoding to use for file names + * + * @throws IOException + * if an error occurs while reading the file. + */ + public ZipFile(String name, String encoding) throws IOException { + this(new File(name), encoding); + } + + /** + * Opens the given file for reading, assuming the specified encoding for file + * names. + * + * @param f + * the archive. + * @param encoding + * the encoding to use for file names + * + * @throws IOException + * if an error occurs while reading the file. + */ + public ZipFile(File f, String encoding) throws IOException { + this(new RandomAccessFile(f, "r"), encoding); + } + + /** + * Read an archive from the given random access file + * + * @param rafile + * the archive as a readable random access file + * @throws IOException + */ + public ZipFile(RandomAccessFile rafile) throws IOException { + this(rafile, null); + } + + /** + * Read an archive from the given random access file, assuming the specified + * encoding for file names. + * + * @param readablearchive + * the archive opened as a readable random access file + * @param encoding + * the encoding to use for file names + * + * @throws IOException + * if an error occurs while reading the file. + */ + public ZipFile(RandomAccessFile readablearchive, String encoding) + throws IOException { + this.encoding = encoding; + archive = readablearchive; + try { + populateFromCentralDirectory(); + resolveLocalFileHeaderData(); + } catch (IOException e) { + try { + archive.close(); + } catch (IOException e2) { + // swallow, throw the original exception instead + } + throw e; } - /** - * Read an archive from the given random access file - * - * @param rafile the archive as a readable random access file - * @throws IOException - */ - public ZipFile(RandomAccessFile rafile) throws IOException - { - this (rafile, null); + } + + /** + * The encoding to use for filenames and the file comment. + * + * @return null if using the platform's default character encoding. + */ + public String getEncoding() { + return encoding; + } + + /** + * Closes the archive. + * + * @throws IOException + * if an error occurs closing the archive. + */ + public void close() throws IOException { + archive.close(); + } + + /** + * close a zipfile quietly; throw no io fault, do nothing on a null parameter + * + * @param zipfile + * file to close, can be null + */ + public static void closeQuietly(ZipFile zipfile) { + if (zipfile != null) { + try { + zipfile.close(); + } catch (IOException e) { + // ignore + } } - /** - * Read an archive from the given random access file, assuming the specified - * encoding for file names. - * - * @param readablearchive the archive opened as a readable random access file - * @param encoding the encoding to use for file names - * - * @throws IOException if an error occurs while reading the file. - */ - public ZipFile(RandomAccessFile readablearchive, String encoding) throws IOException - { - this.encoding = encoding; - archive = readablearchive; - try { - populateFromCentralDirectory(); - resolveLocalFileHeaderData(); - } catch (IOException e) { - try { - archive.close(); - } catch (IOException e2) { - // swallow, throw the original exception instead - } - throw e; - } + } + + /** + * Returns all entries. + * + * @return all entries as {@link ZipEntry} instances + */ + public Enumeration getEntries() { + return entries.keys(); + } + + /** + * Returns a named entry - or null if no entry by that name + * exists. + * + * @param name + * name of the entry. + * @return the ZipEntry corresponding to the given name - or null + * if not present. + */ + public ZipEntry getEntry(String name) { + return (ZipEntry) nameMap.get(name); + } + + /** + * Returns an InputStream for reading the contents of the given entry. + * + * @param ze + * the entry to get the stream for. + * @return a stream to read the entry from. + * @throws IOException + * if unable to create an input stream from the zipenty + * @throws ZipException + * if the zipentry has an unsupported compression method + */ + public InputStream getInputStream(ZipEntry ze) throws IOException, + ZipException { + OffsetEntry offsetEntry = (OffsetEntry) entries.get(ze); + if (offsetEntry == null) { + return null; } - /** - * The encoding to use for filenames and the file comment. - * - * @return null if using the platform's default character encoding. - */ - public String getEncoding() { - return encoding; + long start = offsetEntry.dataOffset; + BoundedInputStream bis = new BoundedInputStream(start, ze + .getCompressedSize()); + switch (ze.getMethod()) { + case ZipEntry.STORED: + return bis; + case ZipEntry.DEFLATED: + bis.addDummy(); + return new InflaterInputStream(bis, new Inflater(true)); + default: + throw new ZipException("Found unsupported compression method " + + ze.getMethod()); } - - /** - * Closes the archive. - * @throws IOException if an error occurs closing the archive. - */ - public void close() throws IOException { - archive.close(); + } + + private static final int CFH_LEN = + /* version made by */2 + /* version needed to extract */+ 2 + /* general purpose bit flag */+ 2 + /* compression method */+ 2 + /* last mod file time */+ 2 + /* last mod file date */+ 2 + /* crc-32 */+ 4 + /* compressed size */+ 4 + /* uncompressed size */+ 4 + /* filename length */+ 2 + /* extra field length */+ 2 + /* file comment length */+ 2 + /* disk number start */+ 2 + /* internal file attributes */+ 2 + /* external file attributes */+ 4 + /* relative offset of local header */+ 4; + + /** + * Reads the central directory of the given archive and populates the internal + * tables with ZipEntry instances. + * + *

+ * The ZipEntrys will know all data that can be obtained from the central + * directory alone, but not the data that requires the local file header or + * additional data to be read. + *

+ */ + private void populateFromCentralDirectory() throws IOException { + positionAtCentralDirectory(); + + byte[] cfh = new byte[CFH_LEN]; + + byte[] signatureBytes = new byte[4]; + archive.readFully(signatureBytes); + long sig = ZipLong.getValue(signatureBytes); + final long cfhSig = ZipLong.getValue(ZipOutputStream.CFH_SIG); + while (sig == cfhSig) { + archive.readFully(cfh); + int off = 0; + ZipEntry ze = new ZipEntry(); + + int versionMadeBy = ZipShort.getValue(cfh, off); + off += 2; + ze.setPlatform((versionMadeBy >> 8) & 0x0F); + + off += 4; // skip version info and general purpose byte + + ze.setMethod(ZipShort.getValue(cfh, off)); + off += 2; + + // FIXME this is actually not very cpu cycles friendly as we are + // converting from + // dos to java while the underlying Sun implementation will convert + // from java to dos time for internal storage... + long time = dosToJavaTime(ZipLong.getValue(cfh, off)); + ze.setTime(time); + off += 4; + + ze.setCrc(ZipLong.getValue(cfh, off)); + off += 4; + + ze.setCompressedSize(ZipLong.getValue(cfh, off)); + off += 4; + + ze.setSize(ZipLong.getValue(cfh, off)); + off += 4; + + int fileNameLen = ZipShort.getValue(cfh, off); + off += 2; + + int extraLen = ZipShort.getValue(cfh, off); + off += 2; + + int commentLen = ZipShort.getValue(cfh, off); + off += 2; + + off += 2; // disk number + + ze.setInternalAttributes(ZipShort.getValue(cfh, off)); + off += 2; + + ze.setExternalAttributes(ZipLong.getValue(cfh, off)); + off += 4; + + byte[] fileName = new byte[fileNameLen]; + archive.readFully(fileName); + ze.setName(getString(fileName)); + + // LFH offset, + OffsetEntry offset = new OffsetEntry(); + offset.headerOffset = ZipLong.getValue(cfh, off); + // data offset will be filled later + entries.put(ze, offset); + + nameMap.put(ze.getName(), ze); + + archive.skipBytes(extraLen); + + byte[] comment = new byte[commentLen]; + archive.readFully(comment); + ze.setComment(getString(comment)); + + archive.readFully(signatureBytes); + sig = ZipLong.getValue(signatureBytes); } - - /** - * close a zipfile quietly; throw no io fault, do nothing - * on a null parameter - * @param zipfile file to close, can be null - */ - public static void closeQuietly(ZipFile zipfile) { - if (zipfile != null) { - try { - zipfile.close(); - } catch (IOException e) { - //ignore + } + + private static final int MIN_EOCD_SIZE = + /* end of central dir signature */4 + /* number of this disk */+ 2 + /* number of the disk with the */ + /* start of the central directory */+ 2 + /* total number of entries in */ + /* the central dir on this disk */+ 2 + /* total number of entries in */ + /* the central dir */+ 2 + /* size of the central directory */+ 4 + /* offset of start of central */ + /* directory with respect to */ + /* the starting disk number */+ 4 + /* zipfile comment length */+ 2; + + private static final int CFD_LOCATOR_OFFSET = + /* end of central dir signature */4 + /* number of this disk */+ 2 + /* number of the disk with the */ + /* start of the central directory */+ 2 + /* total number of entries in */ + /* the central dir on this disk */+ 2 + /* total number of entries in */ + /* the central dir */+ 2 + /* size of the central directory */+ 4; + + /** + * Searches for the "End of central dir record", parses it and + * positions the stream at the first central directory record. + */ + private void positionAtCentralDirectory() throws IOException { + boolean found = false; + long off = archive.length() - MIN_EOCD_SIZE; + if (off >= 0) { + archive.seek(off); + byte[] sig = ZipOutputStream.EOCD_SIG; + int curr = archive.read(); + while (curr != -1) { + if (curr == sig[0]) { + curr = archive.read(); + if (curr == sig[1]) { + curr = archive.read(); + if (curr == sig[2]) { + curr = archive.read(); + if (curr == sig[3]) { + found = true; + break; + } } + } } + archive.seek(--off); + curr = archive.read(); + } } - - /** - * Returns all entries. - * @return all entries as {@link ZipEntry} instances - */ - public Enumeration getEntries() { - return entries.keys(); + if (!found) { + throw new ZipException("archive is not a ZIP archive"); } - - /** - * Returns a named entry - or null if no entry by - * that name exists. - * @param name name of the entry. - * @return the ZipEntry corresponding to the given name - or - * null if not present. - */ - public ZipEntry getEntry(String name) { - return (ZipEntry) nameMap.get(name); + archive.seek(off + CFD_LOCATOR_OFFSET); + byte[] cfdOffset = new byte[4]; + archive.readFully(cfdOffset); + archive.seek(ZipLong.getValue(cfdOffset)); + } + + /** + * Number of bytes in local file header up to the "length of + * filename" entry. + */ + private static final long LFH_OFFSET_FOR_FILENAME_LENGTH = + /* local file header signature */4 + /* version needed to extract */+ 2 + /* general purpose bit flag */+ 2 + /* compression method */+ 2 + /* last mod file time */+ 2 + /* last mod file date */+ 2 + /* crc-32 */+ 4 + /* compressed size */+ 4 + /* uncompressed size */+ 4; + + /** + * Walks through all recorded entries and adds the data available from the + * local file header. + * + *

+ * Also records the offsets for the data to read from the entries. + *

+ */ + private void resolveLocalFileHeaderData() throws IOException { + Enumeration e = getEntries(); + while (e.hasMoreElements()) { + ZipEntry ze = (ZipEntry) e.nextElement(); + OffsetEntry offsetEntry = (OffsetEntry) entries.get(ze); + long offset = offsetEntry.headerOffset; + archive.seek(offset + LFH_OFFSET_FOR_FILENAME_LENGTH); + byte[] b = new byte[2]; + archive.readFully(b); + int fileNameLen = ZipShort.getValue(b); + archive.readFully(b); + int extraFieldLen = ZipShort.getValue(b); + archive.skipBytes(fileNameLen); + byte[] localExtraData = new byte[extraFieldLen]; + archive.readFully(localExtraData); + ze.setExtra(localExtraData); + /* + * dataOffsets.put(ze, new Long(offset + LFH_OFFSET_FOR_FILENAME_LENGTH + + * 2 + 2 + fileNameLen + extraFieldLen)); + */ + offsetEntry.dataOffset = offset + LFH_OFFSET_FOR_FILENAME_LENGTH + 2 + 2 + + fileNameLen + extraFieldLen; } - - /** - * Returns an InputStream for reading the contents of the given entry. - * @param ze the entry to get the stream for. - * @return a stream to read the entry from. - * @throws IOException if unable to create an input stream from the zipenty - * @throws ZipException if the zipentry has an unsupported compression method - */ - public InputStream getInputStream(ZipEntry ze) - throws IOException, ZipException { - OffsetEntry offsetEntry = (OffsetEntry) entries.get(ze); - if (offsetEntry == null) { - return null; - } - long start = offsetEntry.dataOffset; - BoundedInputStream bis = - new BoundedInputStream(start, ze.getCompressedSize()); - switch (ze.getMethod()) { - case ZipEntry.STORED: - return bis; - case ZipEntry.DEFLATED: - bis.addDummy(); - return new InflaterInputStream(bis, new Inflater(true)); - default: - throw new ZipException("Found unsupported compression method " - + ze.getMethod()); - } + } + + /** + * Convert a DOS date/time field to a Date object. + * + * @param zipDosTime + * contains the stored DOS time. + * @return a Date instance corresponding to the given time. + */ + protected static Date fromDosTime(ZipLong zipDosTime) { + long dosTime = zipDosTime.getValue(); + return new Date(dosToJavaTime(dosTime)); + } + + /* + * Converts DOS time to Java time (number of milliseconds since epoch). + */ + private static long dosToJavaTime(long dosTime) { + Calendar cal = Calendar.getInstance(); + cal.set(Calendar.YEAR, (int) ((dosTime >> 25) & 0x7f) + 1980); + cal.set(Calendar.MONTH, (int) ((dosTime >> 21) & 0x0f) - 1); + cal.set(Calendar.DATE, (int) (dosTime >> 16) & 0x1f); + cal.set(Calendar.HOUR_OF_DAY, (int) (dosTime >> 11) & 0x1f); + cal.set(Calendar.MINUTE, (int) (dosTime >> 5) & 0x3f); + cal.set(Calendar.SECOND, (int) (dosTime << 1) & 0x3e); + return cal.getTime().getTime(); + } + + /** + * Retrieve a String from the given bytes using the encoding set for this + * ZipFile. + * + * @param bytes + * the byte array to transform + * @return String obtained by using the given encoding + * @throws ZipException + * if the encoding cannot be recognized. + */ + protected String getString(byte[] bytes) throws ZipException { + if (encoding == null) { + return new String(bytes); + } else { + try { + return new String(bytes, encoding); + } catch (UnsupportedEncodingException uee) { + throw new ZipException(uee.getMessage()); + } } + } - private static final int CFH_LEN = - /* version made by */ 2 - /* version needed to extract */ + 2 - /* general purpose bit flag */ + 2 - /* compression method */ + 2 - /* last mod file time */ + 2 - /* last mod file date */ + 2 - /* crc-32 */ + 4 - /* compressed size */ + 4 - /* uncompressed size */ + 4 - /* filename length */ + 2 - /* extra field length */ + 2 - /* file comment length */ + 2 - /* disk number start */ + 2 - /* internal file attributes */ + 2 - /* external file attributes */ + 4 - /* relative offset of local header */ + 4; - - /** - * Reads the central directory of the given archive and populates - * the internal tables with ZipEntry instances. - * - *

The ZipEntrys will know all data that can be obtained from - * the central directory alone, but not the data that requires the - * local file header or additional data to be read.

- */ - private void populateFromCentralDirectory() - throws IOException { - positionAtCentralDirectory(); - - byte[] cfh = new byte[CFH_LEN]; - - byte[] signatureBytes = new byte[4]; - archive.readFully(signatureBytes); - long sig = ZipLong.getValue(signatureBytes); - final long cfhSig = ZipLong.getValue(ZipOutputStream.CFH_SIG); - while (sig == cfhSig) { - archive.readFully(cfh); - int off = 0; - ZipEntry ze = new ZipEntry(); - - int versionMadeBy = ZipShort.getValue(cfh, off); - off += 2; - ze.setPlatform((versionMadeBy >> 8) & 0x0F); - - off += 4; // skip version info and general purpose byte - - ze.setMethod(ZipShort.getValue(cfh, off)); - off += 2; - - // FIXME this is actually not very cpu cycles friendly as we are converting from - // dos to java while the underlying Sun implementation will convert - // from java to dos time for internal storage... - long time = dosToJavaTime(ZipLong.getValue(cfh, off)); - ze.setTime(time); - off += 4; - - ze.setCrc(ZipLong.getValue(cfh, off)); - off += 4; - - ze.setCompressedSize(ZipLong.getValue(cfh, off)); - off += 4; - - ze.setSize(ZipLong.getValue(cfh, off)); - off += 4; - - int fileNameLen = ZipShort.getValue(cfh, off); - off += 2; - - int extraLen = ZipShort.getValue(cfh, off); - off += 2; - - int commentLen = ZipShort.getValue(cfh, off); - off += 2; - - off += 2; // disk number - - ze.setInternalAttributes(ZipShort.getValue(cfh, off)); - off += 2; - - ze.setExternalAttributes(ZipLong.getValue(cfh, off)); - off += 4; + /** + * InputStream that delegates requests to the underlying RandomAccessFile, + * making sure that only bytes from a certain range can be read. + */ + private class BoundedInputStream extends InputStream { + private long remaining; - byte[] fileName = new byte[fileNameLen]; - archive.readFully(fileName); - ze.setName(getString(fileName)); + private long loc; + private boolean addDummyByte = false; - // LFH offset, - OffsetEntry offset = new OffsetEntry(); - offset.headerOffset = ZipLong.getValue(cfh, off); - // data offset will be filled later - entries.put(ze, offset); - - nameMap.put(ze.getName(), ze); - - archive.skipBytes(extraLen); - - byte[] comment = new byte[commentLen]; - archive.readFully(comment); - ze.setComment(getString(comment)); - - archive.readFully(signatureBytes); - sig = ZipLong.getValue(signatureBytes); - } + BoundedInputStream(long start, long remaining) { + this.remaining = remaining; + loc = start; } - private static final int MIN_EOCD_SIZE = - /* end of central dir signature */ 4 - /* number of this disk */ + 2 - /* number of the disk with the */ - /* start of the central directory */ + 2 - /* total number of entries in */ - /* the central dir on this disk */ + 2 - /* total number of entries in */ - /* the central dir */ + 2 - /* size of the central directory */ + 4 - /* offset of start of central */ - /* directory with respect to */ - /* the starting disk number */ + 4 - /* zipfile comment length */ + 2; - - private static final int CFD_LOCATOR_OFFSET = - /* end of central dir signature */ 4 - /* number of this disk */ + 2 - /* number of the disk with the */ - /* start of the central directory */ + 2 - /* total number of entries in */ - /* the central dir on this disk */ + 2 - /* total number of entries in */ - /* the central dir */ + 2 - /* size of the central directory */ + 4; - - /** - * Searches for the "End of central dir record", parses - * it and positions the stream at the first central directory - * record. - */ - private void positionAtCentralDirectory() - throws IOException { - boolean found = false; - long off = archive.length() - MIN_EOCD_SIZE; - if (off >= 0) { - archive.seek(off); - byte[] sig = ZipOutputStream.EOCD_SIG; - int curr = archive.read(); - while (curr != -1) { - if (curr == sig[0]) { - curr = archive.read(); - if (curr == sig[1]) { - curr = archive.read(); - if (curr == sig[2]) { - curr = archive.read(); - if (curr == sig[3]) { - found = true; - break; - } - } - } - } - archive.seek(--off); - curr = archive.read(); - } - } - if (!found) { - throw new ZipException("archive is not a ZIP archive"); + public int read() throws IOException { + if (remaining-- <= 0) { + if (addDummyByte) { + addDummyByte = false; + return 0; } - archive.seek(off + CFD_LOCATOR_OFFSET); - byte[] cfdOffset = new byte[4]; - archive.readFully(cfdOffset); - archive.seek(ZipLong.getValue(cfdOffset)); + return -1; + } + synchronized (archive) { + archive.seek(loc++); + return archive.read(); + } } - /** - * Number of bytes in local file header up to the "length of - * filename" entry. - */ - private static final long LFH_OFFSET_FOR_FILENAME_LENGTH = - /* local file header signature */ 4 - /* version needed to extract */ + 2 - /* general purpose bit flag */ + 2 - /* compression method */ + 2 - /* last mod file time */ + 2 - /* last mod file date */ + 2 - /* crc-32 */ + 4 - /* compressed size */ + 4 - /* uncompressed size */ + 4; - - /** - * Walks through all recorded entries and adds the data available - * from the local file header. - * - *

Also records the offsets for the data to read from the - * entries.

- */ - private void resolveLocalFileHeaderData() - throws IOException { - Enumeration e = getEntries(); - while (e.hasMoreElements()) { - ZipEntry ze = (ZipEntry) e.nextElement(); - OffsetEntry offsetEntry = (OffsetEntry) entries.get(ze); - long offset = offsetEntry.headerOffset; - archive.seek(offset + LFH_OFFSET_FOR_FILENAME_LENGTH); - byte[] b = new byte[2]; - archive.readFully(b); - int fileNameLen = ZipShort.getValue(b); - archive.readFully(b); - int extraFieldLen = ZipShort.getValue(b); - archive.skipBytes(fileNameLen); - byte[] localExtraData = new byte[extraFieldLen]; - archive.readFully(localExtraData); - ze.setExtra(localExtraData); - /*dataOffsets.put(ze, - new Long(offset + LFH_OFFSET_FOR_FILENAME_LENGTH - + 2 + 2 + fileNameLen + extraFieldLen)); - */ - offsetEntry.dataOffset = offset + LFH_OFFSET_FOR_FILENAME_LENGTH - + 2 + 2 + fileNameLen + extraFieldLen; + public int read(byte[] b, int off, int len) throws IOException { + if (remaining <= 0) { + if (addDummyByte) { + addDummyByte = false; + b[off] = 0; + return 1; } + return -1; + } + + if (len <= 0) { + return 0; + } + + if (len > remaining) { + len = (int) remaining; + } + int ret = -1; + synchronized (archive) { + archive.seek(loc); + ret = archive.read(b, off, len); + } + if (ret > 0) { + loc += ret; + remaining -= ret; + } + return ret; } /** - * Convert a DOS date/time field to a Date object. - * - * @param zipDosTime contains the stored DOS time. - * @return a Date instance corresponding to the given time. + * Inflater needs an extra dummy byte for nowrap - see Inflater's javadocs. */ - protected static Date fromDosTime(ZipLong zipDosTime) { - long dosTime = zipDosTime.getValue(); - return new Date(dosToJavaTime(dosTime)); - } - - /* - * Converts DOS time to Java time (number of milliseconds since epoch). - */ - private static long dosToJavaTime(long dosTime) { - Calendar cal = Calendar.getInstance(); - cal.set(Calendar.YEAR, (int) ((dosTime >> 25) & 0x7f) + 1980); - cal.set(Calendar.MONTH, (int) ((dosTime >> 21) & 0x0f) - 1); - cal.set(Calendar.DATE, (int) (dosTime >> 16) & 0x1f); - cal.set(Calendar.HOUR_OF_DAY, (int) (dosTime >> 11) & 0x1f); - cal.set(Calendar.MINUTE, (int) (dosTime >> 5) & 0x3f); - cal.set(Calendar.SECOND, (int) (dosTime << 1) & 0x3e); - return cal.getTime().getTime(); - } - - - /** - * Retrieve a String from the given bytes using the encoding set - * for this ZipFile. - * - * @param bytes the byte array to transform - * @return String obtained by using the given encoding - * @throws ZipException if the encoding cannot be recognized. - */ - protected String getString(byte[] bytes) throws ZipException { - if (encoding == null) { - return new String(bytes); - } else { - try { - return new String(bytes, encoding); - } catch (UnsupportedEncodingException uee) { - throw new ZipException(uee.getMessage()); - } - } - } - - /** - * InputStream that delegates requests to the underlying - * RandomAccessFile, making sure that only bytes from a certain - * range can be read. - */ - private class BoundedInputStream extends InputStream { - private long remaining; - private long loc; - private boolean addDummyByte = false; - - BoundedInputStream(long start, long remaining) { - this.remaining = remaining; - loc = start; - } - - public int read() throws IOException { - if (remaining-- <= 0) { - if (addDummyByte) { - addDummyByte = false; - return 0; - } - return -1; - } - synchronized (archive) { - archive.seek(loc++); - return archive.read(); - } - } - - public int read(byte[] b, int off, int len) throws IOException { - if (remaining <= 0) { - if (addDummyByte) { - addDummyByte = false; - b[off] = 0; - return 1; - } - return -1; - } - - if (len <= 0) { - return 0; - } - - if (len > remaining) { - len = (int) remaining; - } - int ret = -1; - synchronized (archive) { - archive.seek(loc); - ret = archive.read(b, off, len); - } - if (ret > 0) { - loc += ret; - remaining -= ret; - } - return ret; - } - - /** - * Inflater needs an extra dummy byte for nowrap - see - * Inflater's javadocs. - */ - void addDummy() { - addDummyByte = true; - } + void addDummy() { + addDummyByte = true; } + } } diff --git a/src/org/apache/tools/zip/ZipLong.java b/src/org/apache/tools/zip/ZipLong.java index 5804798..4f30585 100644 --- a/src/org/apache/tools/zip/ZipLong.java +++ b/src/org/apache/tools/zip/ZipLong.java @@ -19,116 +19,136 @@ package org.apache.tools.zip; /** - * Utility class that represents a four byte integer with conversion - * rules for the big endian byte order of ZIP files. - * + * Utility class that represents a four byte integer with conversion rules for + * the big endian byte order of ZIP files. + * */ public final class ZipLong implements Cloneable { - private long value; + private long value; - /** - * Create instance from a number. - * @param value the long to store as a ZipLong - * @since 1.1 - */ - public ZipLong(long value) { - this.value = value; - } + /** + * Create instance from a number. + * + * @param value + * the long to store as a ZipLong + * @since 1.1 + */ + public ZipLong(long value) { + this.value = value; + } - /** - * Create instance from bytes. - * @param bytes the bytes to store as a ZipLong - * @since 1.1 - */ - public ZipLong (byte[] bytes) { - this(bytes, 0); - } + /** + * Create instance from bytes. + * + * @param bytes + * the bytes to store as a ZipLong + * @since 1.1 + */ + public ZipLong(byte[] bytes) { + this(bytes, 0); + } - /** - * Create instance from the four bytes starting at offset. - * @param bytes the bytes to store as a ZipLong - * @param offset the offset to start - * @since 1.1 - */ - public ZipLong (byte[] bytes, int offset) { - value = ZipLong.getValue(bytes, offset); - } + /** + * Create instance from the four bytes starting at offset. + * + * @param bytes + * the bytes to store as a ZipLong + * @param offset + * the offset to start + * @since 1.1 + */ + public ZipLong(byte[] bytes, int offset) { + value = ZipLong.getValue(bytes, offset); + } - /** - * Get value as four bytes in big endian byte order. - * @since 1.1 - * @return value as four bytes in big endian order - */ - public byte[] getBytes() { - return ZipLong.getBytes(value); - } + /** + * Get value as four bytes in big endian byte order. + * + * @since 1.1 + * @return value as four bytes in big endian order + */ + public byte[] getBytes() { + return ZipLong.getBytes(value); + } - /** - * Get value as Java long. - * @since 1.1 - * @return value as a long - */ - public long getValue() { - return value; - } + /** + * Get value as Java long. + * + * @since 1.1 + * @return value as a long + */ + public long getValue() { + return value; + } - /** - * Get value as four bytes in big endian byte order. - * @param value the value to convert - * @return value as four bytes in big endian byte order - */ - public static byte[] getBytes(long value) { - byte[] result = new byte[4]; - result[0] = (byte) ((value & 0xFF)); - result[1] = (byte) ((value & 0xFF00) >> 8); - result[2] = (byte) ((value & 0xFF0000) >> 16); - result[3] = (byte) ((value & 0xFF000000L) >> 24); - return result; - } + /** + * Get value as four bytes in big endian byte order. + * + * @param value + * the value to convert + * @return value as four bytes in big endian byte order + */ + public static byte[] getBytes(long value) { + byte[] result = new byte[4]; + result[0] = (byte) ((value & 0xFF)); + result[1] = (byte) ((value & 0xFF00) >> 8); + result[2] = (byte) ((value & 0xFF0000) >> 16); + result[3] = (byte) ((value & 0xFF000000L) >> 24); + return result; + } - /** - * Helper method to get the value as a Java long from four bytes starting at given array offset - * @param bytes the array of bytes - * @param offset the offset to start - * @return the correspondanding Java long value - */ - public static long getValue(byte[] bytes, int offset) { - long value = (bytes[offset + 3] << 24) & 0xFF000000L; - value += (bytes[offset + 2] << 16) & 0xFF0000; - value += (bytes[offset + 1] << 8) & 0xFF00; - value += (bytes[offset] & 0xFF); - return value; - } + /** + * Helper method to get the value as a Java long from four bytes starting at + * given array offset + * + * @param bytes + * the array of bytes + * @param offset + * the offset to start + * @return the correspondanding Java long value + */ + public static long getValue(byte[] bytes, int offset) { + long value = (bytes[offset + 3] << 24) & 0xFF000000L; + value += (bytes[offset + 2] << 16) & 0xFF0000; + value += (bytes[offset + 1] << 8) & 0xFF00; + value += (bytes[offset] & 0xFF); + return value; + } - /** - * Helper method to get the value as a Java long from a four-byte array - * @param bytes the array of bytes - * @return the correspondanding Java long value - */ - public static long getValue(byte[] bytes) { - return getValue(bytes, 0); - } + /** + * Helper method to get the value as a Java long from a four-byte array + * + * @param bytes + * the array of bytes + * @return the correspondanding Java long value + */ + public static long getValue(byte[] bytes) { + return getValue(bytes, 0); + } - /** - * Override to make two instances with same value equal. - * @param o an object to compare - * @return true if the objects are equal - * @since 1.1 - */ - public boolean equals(Object o) { - if (o == null || !(o instanceof ZipLong)) { - return false; - } - return value == ((ZipLong) o).getValue(); + /** + * Override to make two instances with same value equal. + * + * @param o + * an object to compare + * @return true if the objects are equal + * @since 1.1 + */ + public boolean equals(Object o) { + if (o == null || !(o instanceof ZipLong)) { + return false; } + return value == ((ZipLong) o).getValue(); + } - /** - * Override to make two instances with same value equal. - * @return the value stored in the ZipLong - * @since 1.1 - */ - public int hashCode() { - return (int) value; - } + /** + * Override to make two instances with same value equal. + * + * @return the value stored in the ZipLong + * @since 1.1 + */ + public int hashCode() { + return (int) value; + } } diff --git a/src/org/apache/tools/zip/ZipOutputStream.java b/src/org/apache/tools/zip/ZipOutputStream.java index 2c4c4a9..7a5388a 100644 --- a/src/org/apache/tools/zip/ZipOutputStream.java +++ b/src/org/apache/tools/zip/ZipOutputStream.java @@ -34,867 +34,938 @@ import java.util.zip.ZipException; /** * Reimplementation of {@link java.util.zip.ZipOutputStream - * java.util.zip.ZipOutputStream} that does handle the extended - * functionality of this package, especially internal/external file - * attributes and extra fields with different layouts for local file - * data and central directory entries. - * - *

This class will try to use {@link java.io.RandomAccessFile - * RandomAccessFile} when you know that the output is going to go to a - * file.

- * - *

If RandomAccessFile cannot be used, this implementation will use - * a Data Descriptor to store size and CRC information for {@link - * #DEFLATED DEFLATED} entries, this means, you don't need to - * calculate them yourself. Unfortunately this is not possible for - * the {@link #STORED STORED} method, here setting the CRC and - * uncompressed size information is required before {@link - * #putNextEntry putNextEntry} can be called.

- * + * java.util.zip.ZipOutputStream} that does handle the extended functionality of + * this package, especially internal/external file attributes and extra fields + * with different layouts for local file data and central directory entries. + * + *

+ * This class will try to use {@link java.io.RandomAccessFile RandomAccessFile} + * when you know that the output is going to go to a file. + *

+ * + *

+ * If RandomAccessFile cannot be used, this implementation will use a Data + * Descriptor to store size and CRC information for {@link #DEFLATED DEFLATED} + * entries, this means, you don't need to calculate them yourself. Unfortunately + * this is not possible for the {@link #STORED STORED} method, here setting the + * CRC and uncompressed size information is required before + * {@link #putNextEntry putNextEntry} can be called. + *

+ * */ public class ZipOutputStream extends FilterOutputStream { - /** - * Compression method for deflated entries. - * - * @since 1.1 - */ - public static final int DEFLATED = java.util.zip.ZipEntry.DEFLATED; - - /** - * Default compression level for deflated entries. - * - * @since Ant 1.7 - */ - public static final int DEFAULT_COMPRESSION = Deflater.DEFAULT_COMPRESSION; - - /** - * Compression method for stored entries. - * - * @since 1.1 - */ - public static final int STORED = java.util.zip.ZipEntry.STORED; - - /** - * Current entry. - * - * @since 1.1 - */ - private ZipEntry entry; - - /** - * The file comment. - * - * @since 1.1 - */ - private String comment = ""; - - /** - * Compression level for next entry. - * - * @since 1.1 - */ - private int level = DEFAULT_COMPRESSION; - - /** - * Has the compression level changed when compared to the last - * entry? - * - * @since 1.5 - */ - private boolean hasCompressionLevelChanged = false; - - /** - * Default compression method for next entry. - * - * @since 1.1 - */ - private int method = java.util.zip.ZipEntry.DEFLATED; - - /** - * List of ZipEntries written so far. - * - * @since 1.1 - */ - private Vector entries = new Vector(); - - /** - * CRC instance to avoid parsing DEFLATED data twice. - * - * @since 1.1 - */ - private CRC32 crc = new CRC32(); - - /** - * Count the bytes written to out. - * - * @since 1.1 - */ - private long written = 0; - - /** - * Data for local header data - * - * @since 1.1 - */ - private long dataStart = 0; - - /** - * Offset for CRC entry in the local file header data for the - * current entry starts here. - * - * @since 1.15 - */ - private long localDataStart = 0; - - /** - * Start of central directory. - * - * @since 1.1 - */ - private long cdOffset = 0; - - /** - * Length of central directory. - * - * @since 1.1 - */ - private long cdLength = 0; - - /** - * Helper, a 0 as ZipShort. - * - * @since 1.1 - */ - private static final byte[] ZERO = {0, 0}; - - /** - * Helper, a 0 as ZipLong. - * - * @since 1.1 - */ - private static final byte[] LZERO = {0, 0, 0, 0}; - - /** - * Holds the offsets of the LFH starts for each entry. - * - * @since 1.1 - */ - private Hashtable offsets = new Hashtable(); - - /** - * The encoding to use for filenames and the file comment. - * - *

For a list of possible values see http://java.sun.com/j2se/1.5.0/docs/guide/intl/encoding.doc.html. - * Defaults to the platform's default character encoding.

- * - * @since 1.3 - */ - private String encoding = null; - - // CheckStyle:VisibilityModifier OFF - bc - - /** - * This Deflater object is used for output. - * - *

This attribute is only protected to provide a level of API - * backwards compatibility. This class used to extend {@link - * java.util.zip.DeflaterOutputStream DeflaterOutputStream} up to - * Revision 1.13.

- * - * @since 1.14 - */ - protected Deflater def = new Deflater(level, true); - - /** - * This buffer servers as a Deflater. - * - *

This attribute is only protected to provide a level of API - * backwards compatibility. This class used to extend {@link - * java.util.zip.DeflaterOutputStream DeflaterOutputStream} up to - * Revision 1.13.

- * - * @since 1.14 - */ - protected byte[] buf = new byte[512]; - - // CheckStyle:VisibilityModifier ON - - /** - * Optional random access output. - * - * @since 1.14 - */ - private RandomAccessFile raf = null; - - /** - * Creates a new ZIP OutputStream filtering the underlying stream. - * @param out the outputstream to zip - * @since 1.1 - */ - public ZipOutputStream(OutputStream out) { - super(out); - } - - /** - * Creates a new ZIP OutputStream writing to a File. Will use - * random access if possible. - * @param file the file to zip to - * @since 1.14 - * @throws IOException on error - */ - public ZipOutputStream(File file) throws IOException { - super(null); - + /** + * Compression method for deflated entries. + * + * @since 1.1 + */ + public static final int DEFLATED = java.util.zip.ZipEntry.DEFLATED; + + /** + * Default compression level for deflated entries. + * + * @since Ant 1.7 + */ + public static final int DEFAULT_COMPRESSION = Deflater.DEFAULT_COMPRESSION; + + /** + * Compression method for stored entries. + * + * @since 1.1 + */ + public static final int STORED = java.util.zip.ZipEntry.STORED; + + /** + * Current entry. + * + * @since 1.1 + */ + private ZipEntry entry; + + /** + * The file comment. + * + * @since 1.1 + */ + private String comment = ""; + + /** + * Compression level for next entry. + * + * @since 1.1 + */ + private int level = DEFAULT_COMPRESSION; + + /** + * Has the compression level changed when compared to the last entry? + * + * @since 1.5 + */ + private boolean hasCompressionLevelChanged = false; + + /** + * Default compression method for next entry. + * + * @since 1.1 + */ + private int method = java.util.zip.ZipEntry.DEFLATED; + + /** + * List of ZipEntries written so far. + * + * @since 1.1 + */ + private Vector entries = new Vector(); + + /** + * CRC instance to avoid parsing DEFLATED data twice. + * + * @since 1.1 + */ + private CRC32 crc = new CRC32(); + + /** + * Count the bytes written to out. + * + * @since 1.1 + */ + private long written = 0; + + /** + * Data for local header data + * + * @since 1.1 + */ + private long dataStart = 0; + + /** + * Offset for CRC entry in the local file header data for the current entry + * starts here. + * + * @since 1.15 + */ + private long localDataStart = 0; + + /** + * Start of central directory. + * + * @since 1.1 + */ + private long cdOffset = 0; + + /** + * Length of central directory. + * + * @since 1.1 + */ + private long cdLength = 0; + + /** + * Helper, a 0 as ZipShort. + * + * @since 1.1 + */ + private static final byte[] ZERO = { 0, 0 }; + + /** + * Helper, a 0 as ZipLong. + * + * @since 1.1 + */ + private static final byte[] LZERO = { 0, 0, 0, 0 }; + + /** + * Holds the offsets of the LFH starts for each entry. + * + * @since 1.1 + */ + private Hashtable offsets = new Hashtable(); + + /** + * The encoding to use for filenames and the file comment. + * + *

+ * For a list of possible values see http://java.sun.com/j2se/1.5.0/docs/guide/intl/encoding.doc.html. + * Defaults to the platform's default character encoding. + *

+ * + * @since 1.3 + */ + private String encoding = null; + + // CheckStyle:VisibilityModifier OFF - bc + + /** + * This Deflater object is used for output. + * + *

+ * This attribute is only protected to provide a level of API backwards + * compatibility. This class used to extend + * {@link java.util.zip.DeflaterOutputStream DeflaterOutputStream} up to + * Revision 1.13. + *

+ * + * @since 1.14 + */ + protected Deflater def = new Deflater(level, true); + + /** + * This buffer servers as a Deflater. + * + *

+ * This attribute is only protected to provide a level of API backwards + * compatibility. This class used to extend + * {@link java.util.zip.DeflaterOutputStream DeflaterOutputStream} up to + * Revision 1.13. + *

+ * + * @since 1.14 + */ + protected byte[] buf = new byte[512]; + + // CheckStyle:VisibilityModifier ON + + /** + * Optional random access output. + * + * @since 1.14 + */ + private RandomAccessFile raf = null; + + /** + * Creates a new ZIP OutputStream filtering the underlying stream. + * + * @param out + * the outputstream to zip + * @since 1.1 + */ + public ZipOutputStream(OutputStream out) { + super(out); + } + + /** + * Creates a new ZIP OutputStream writing to a File. Will use random access if + * possible. + * + * @param file + * the file to zip to + * @since 1.14 + * @throws IOException + * on error + */ + public ZipOutputStream(File file) throws IOException { + super(null); + + try { + raf = new RandomAccessFile(file, "rw"); + raf.setLength(0); + } catch (IOException e) { + if (raf != null) { try { - raf = new RandomAccessFile(file, "rw"); - raf.setLength(0); - } catch (IOException e) { - if (raf != null) { - try { - raf.close(); - } catch (IOException inner) { - // ignore - } - raf = null; - } - out = new FileOutputStream(file); + raf.close(); + } catch (IOException inner) { + // ignore } + raf = null; + } + out = new FileOutputStream(file); } - - /** - * This method indicates whether this archive is writing to a seekable stream (i.e., to a random - * access file). - * - *

For seekable streams, you don't need to calculate the CRC or - * uncompressed size for {@link #STORED} entries before - * invoking {@link #putNextEntry}. - * @return true if seekable - * @since 1.17 - */ - public boolean isSeekable() { - return raf != null; - } - - /** - * The encoding to use for filenames and the file comment. - * - *

For a list of possible values see http://java.sun.com/j2se/1.5.0/docs/guide/intl/encoding.doc.html. - * Defaults to the platform's default character encoding.

- * @param encoding the encoding value - * @since 1.3 - */ - public void setEncoding(String encoding) { - this.encoding = encoding; + } + + /** + * This method indicates whether this archive is writing to a seekable stream + * (i.e., to a random access file). + * + *

+ * For seekable streams, you don't need to calculate the CRC or uncompressed + * size for {@link #STORED} entries before invoking {@link #putNextEntry}. + * + * @return true if seekable + * @since 1.17 + */ + public boolean isSeekable() { + return raf != null; + } + + /** + * The encoding to use for filenames and the file comment. + * + *

+ * For a list of possible values see http://java.sun.com/j2se/1.5.0/docs/guide/intl/encoding.doc.html. + * Defaults to the platform's default character encoding. + *

+ * + * @param encoding + * the encoding value + * @since 1.3 + */ + public void setEncoding(String encoding) { + this.encoding = encoding; + } + + /** + * The encoding to use for filenames and the file comment. + * + * @return null if using the platform's default character encoding. + * + * @since 1.3 + */ + public String getEncoding() { + return encoding; + } + + /** + * Finishs writing the contents and closes this as well as the underlying + * stream. + * + * @since 1.1 + * @throws IOException + * on error + */ + public void finish() throws IOException { + closeEntry(); + cdOffset = written; + for (int i = 0, entriesSize = entries.size(); i < entriesSize; i++) { + writeCentralFileHeader((ZipEntry) entries.elementAt(i)); } - - /** - * The encoding to use for filenames and the file comment. - * - * @return null if using the platform's default character encoding. - * - * @since 1.3 - */ - public String getEncoding() { - return encoding; + cdLength = written - cdOffset; + writeCentralDirectoryEnd(); + offsets.clear(); + entries.removeAllElements(); + } + + /** + * Writes all necessary data for this entry. + * + * @since 1.1 + * @throws IOException + * on error + */ + public void closeEntry() throws IOException { + if (entry == null) { + return; } - /** - * Finishs writing the contents and closes this as well as the - * underlying stream. - * - * @since 1.1 - * @throws IOException on error - */ - public void finish() throws IOException { - closeEntry(); - cdOffset = written; - for (int i = 0, entriesSize = entries.size(); i < entriesSize; i++) { - writeCentralFileHeader((ZipEntry) entries.elementAt(i)); - } - cdLength = written - cdOffset; - writeCentralDirectoryEnd(); - offsets.clear(); - entries.removeAllElements(); + long realCrc = crc.getValue(); + crc.reset(); + + if (entry.getMethod() == DEFLATED) { + def.finish(); + while (!def.finished()) { + deflate(); + } + + entry.setSize(adjustToLong(def.getTotalIn())); + entry.setCompressedSize(adjustToLong(def.getTotalOut())); + entry.setCrc(realCrc); + + def.reset(); + + written += entry.getCompressedSize(); + } else if (raf == null) { + if (entry.getCrc() != realCrc) { + throw new ZipException("bad CRC checksum for entry " + entry.getName() + + ": " + Long.toHexString(entry.getCrc()) + " instead of " + + Long.toHexString(realCrc)); + } + + if (entry.getSize() != written - dataStart) { + throw new ZipException("bad size for entry " + entry.getName() + ": " + + entry.getSize() + " instead of " + (written - dataStart)); + } + } else { /* method is STORED and we used RandomAccessFile */ + long size = written - dataStart; + + entry.setSize(size); + entry.setCompressedSize(size); + entry.setCrc(realCrc); } - /** - * Writes all necessary data for this entry. - * - * @since 1.1 - * @throws IOException on error - */ - public void closeEntry() throws IOException { - if (entry == null) { - return; - } - - long realCrc = crc.getValue(); - crc.reset(); - - if (entry.getMethod() == DEFLATED) { - def.finish(); - while (!def.finished()) { - deflate(); - } - - entry.setSize(adjustToLong(def.getTotalIn())); - entry.setCompressedSize(adjustToLong(def.getTotalOut())); - entry.setCrc(realCrc); - - def.reset(); - - written += entry.getCompressedSize(); - } else if (raf == null) { - if (entry.getCrc() != realCrc) { - throw new ZipException("bad CRC checksum for entry " - + entry.getName() + ": " - + Long.toHexString(entry.getCrc()) - + " instead of " - + Long.toHexString(realCrc)); - } - - if (entry.getSize() != written - dataStart) { - throw new ZipException("bad size for entry " - + entry.getName() + ": " - + entry.getSize() - + " instead of " - + (written - dataStart)); - } - } else { /* method is STORED and we used RandomAccessFile */ - long size = written - dataStart; - - entry.setSize(size); - entry.setCompressedSize(size); - entry.setCrc(realCrc); - } + // If random access output, write the local file header containing + // the correct CRC and compressed/uncompressed sizes + if (raf != null) { + long save = raf.getFilePointer(); - // If random access output, write the local file header containing - // the correct CRC and compressed/uncompressed sizes - if (raf != null) { - long save = raf.getFilePointer(); - - raf.seek(localDataStart); - writeOut(ZipLong.getBytes(entry.getCrc())); - writeOut(ZipLong.getBytes(entry.getCompressedSize())); - writeOut(ZipLong.getBytes(entry.getSize())); - raf.seek(save); - } - - writeDataDescriptor(entry); - entry = null; + raf.seek(localDataStart); + writeOut(ZipLong.getBytes(entry.getCrc())); + writeOut(ZipLong.getBytes(entry.getCompressedSize())); + writeOut(ZipLong.getBytes(entry.getSize())); + raf.seek(save); } - /** - * Begin writing next entry. - * @param ze the entry to write - * @since 1.1 - * @throws IOException on error - */ - public void putNextEntry(ZipEntry ze) throws IOException { - closeEntry(); - - entry = ze; - entries.addElement(entry); - - if (entry.getMethod() == -1) { // not specified - entry.setMethod(method); - } - - if (entry.getTime() == -1) { // not specified - entry.setTime(System.currentTimeMillis()); - } - - // Size/CRC not required if RandomAccessFile is used - if (entry.getMethod() == STORED && raf == null) { - if (entry.getSize() == -1) { - throw new ZipException("uncompressed size is required for" - + " STORED method when not writing to a" - + " file"); - } - if (entry.getCrc() == -1) { - throw new ZipException("crc checksum is required for STORED" - + " method when not writing to a file"); - } - entry.setCompressedSize(entry.getSize()); - } - - if (entry.getMethod() == DEFLATED && hasCompressionLevelChanged) { - def.setLevel(level); - hasCompressionLevelChanged = false; - } - writeLocalFileHeader(entry); + writeDataDescriptor(entry); + entry = null; + } + + /** + * Begin writing next entry. + * + * @param ze + * the entry to write + * @since 1.1 + * @throws IOException + * on error + */ + public void putNextEntry(ZipEntry ze) throws IOException { + closeEntry(); + + entry = ze; + entries.addElement(entry); + + if (entry.getMethod() == -1) { // not specified + entry.setMethod(method); } - /** - * Set the file comment. - * @param comment the comment - * @since 1.1 - */ - public void setComment(String comment) { - this.comment = comment; + if (entry.getTime() == -1) { // not specified + entry.setTime(System.currentTimeMillis()); } - /** - * Sets the compression level for subsequent entries. - * - *

Default is Deflater.DEFAULT_COMPRESSION.

- * @param level the compression level. - * @throws IllegalArgumentException if an invalid compression level is specified. - * @since 1.1 - */ - public void setLevel(int level) { - if (level < Deflater.DEFAULT_COMPRESSION - || level > Deflater.BEST_COMPRESSION) { - throw new IllegalArgumentException( - "Invalid compression level: " + level); - } - hasCompressionLevelChanged = (this.level != level); - this.level = level; + // Size/CRC not required if RandomAccessFile is used + if (entry.getMethod() == STORED && raf == null) { + if (entry.getSize() == -1) { + throw new ZipException("uncompressed size is required for" + + " STORED method when not writing to a" + " file"); + } + if (entry.getCrc() == -1) { + throw new ZipException("crc checksum is required for STORED" + + " method when not writing to a file"); + } + entry.setCompressedSize(entry.getSize()); } - /** - * Sets the default compression method for subsequent entries. - * - *

Default is DEFLATED.

- * @param method an int from java.util.zip.ZipEntry - * @since 1.1 - */ - public void setMethod(int method) { - this.method = method; + if (entry.getMethod() == DEFLATED && hasCompressionLevelChanged) { + def.setLevel(level); + hasCompressionLevelChanged = false; } - - /** - * Writes bytes to ZIP entry. - * @param b the byte array to write - * @param offset the start position to write from - * @param length the number of bytes to write - * @throws IOException on error - */ - public void write(byte[] b, int offset, int length) throws IOException { - if (entry.getMethod() == DEFLATED) { - if (length > 0) { - if (!def.finished()) { - def.setInput(b, offset, length); - while (!def.needsInput()) { - deflate(); - } - } - } - } else { - writeOut(b, offset, length); - written += length; - } - crc.update(b, offset, length); - } - - /** - * Writes a single byte to ZIP entry. - * - *

Delegates to the three arg method.

- * @param b the byte to write - * @since 1.14 - * @throws IOException on error - */ - public void write(int b) throws IOException { - byte[] buff = new byte[1]; - buff[0] = (byte) (b & 0xff); - write(buff, 0, 1); + writeLocalFileHeader(entry); + } + + /** + * Set the file comment. + * + * @param comment + * the comment + * @since 1.1 + */ + public void setComment(String comment) { + this.comment = comment; + } + + /** + * Sets the compression level for subsequent entries. + * + *

+ * Default is Deflater.DEFAULT_COMPRESSION. + *

+ * + * @param level + * the compression level. + * @throws IllegalArgumentException + * if an invalid compression level is specified. + * @since 1.1 + */ + public void setLevel(int level) { + if (level < Deflater.DEFAULT_COMPRESSION + || level > Deflater.BEST_COMPRESSION) { + throw new IllegalArgumentException("Invalid compression level: " + level); } - - /** - * Closes this output stream and releases any system resources - * associated with the stream. - * - * @exception IOException if an I/O error occurs. - * @since 1.14 - */ - public void close() throws IOException { - finish(); - - if (raf != null) { - raf.close(); - } - if (out != null) { - out.close(); + hasCompressionLevelChanged = (this.level != level); + this.level = level; + } + + /** + * Sets the default compression method for subsequent entries. + * + *

+ * Default is DEFLATED. + *

+ * + * @param method + * an int from java.util.zip.ZipEntry + * @since 1.1 + */ + public void setMethod(int method) { + this.method = method; + } + + /** + * Writes bytes to ZIP entry. + * + * @param b + * the byte array to write + * @param offset + * the start position to write from + * @param length + * the number of bytes to write + * @throws IOException + * on error + */ + public void write(byte[] b, int offset, int length) throws IOException { + if (entry.getMethod() == DEFLATED) { + if (length > 0) { + if (!def.finished()) { + def.setInput(b, offset, length); + while (!def.needsInput()) { + deflate(); + } } + } + } else { + writeOut(b, offset, length); + written += length; } - - /** - * Flushes this output stream and forces any buffered output bytes - * to be written out to the stream. - * - * @exception IOException if an I/O error occurs. - * @since 1.14 - */ - public void flush() throws IOException { - if (out != null) { - out.flush(); - } + crc.update(b, offset, length); + } + + /** + * Writes a single byte to ZIP entry. + * + *

+ * Delegates to the three arg method. + *

+ * + * @param b + * the byte to write + * @since 1.14 + * @throws IOException + * on error + */ + public void write(int b) throws IOException { + byte[] buff = new byte[1]; + buff[0] = (byte) (b & 0xff); + write(buff, 0, 1); + } + + /** + * Closes this output stream and releases any system resources associated with + * the stream. + * + * @exception IOException + * if an I/O error occurs. + * @since 1.14 + */ + public void close() throws IOException { + finish(); + + if (raf != null) { + raf.close(); } - - /* - * Various ZIP constants - */ - /** - * local file header signature - * - * @since 1.1 - */ - protected static final byte[] LFH_SIG = ZipLong.getBytes(0X04034B50L); - /** - * data descriptor signature - * - * @since 1.1 - */ - protected static final byte[] DD_SIG = ZipLong.getBytes(0X08074B50L); - /** - * central file header signature - * - * @since 1.1 - */ - protected static final byte[] CFH_SIG = ZipLong.getBytes(0X02014B50L); - /** - * end of central dir signature - * - * @since 1.1 - */ - protected static final byte[] EOCD_SIG = ZipLong.getBytes(0X06054B50L); - - /** - * Writes next block of compressed data to the output stream. - * @throws IOException on error - * - * @since 1.14 - */ - protected final void deflate() throws IOException { - int len = def.deflate(buf, 0, buf.length); - if (len > 0) { - writeOut(buf, 0, len); - } + if (out != null) { + out.close(); } - - /** - * Writes the local file header entry - * @param ze the entry to write - * @throws IOException on error - * - * @since 1.1 - */ - protected void writeLocalFileHeader(ZipEntry ze) throws IOException { - offsets.put(ze, ZipLong.getBytes(written)); - - writeOut(LFH_SIG); - written += 4; - - //store method in local variable to prevent multiple method calls - final int zipMethod = ze.getMethod(); - - // version needed to extract - // general purpose bit flag - if (zipMethod == DEFLATED && raf == null) { - // requires version 2 as we are going to store length info - // in the data descriptor - writeOut(ZipShort.getBytes(20)); - - // bit3 set to signal, we use a data descriptor - writeOut(ZipShort.getBytes(8)); - } else { - writeOut(ZipShort.getBytes(10)); - writeOut(ZERO); - } - written += 4; - - // compression method - writeOut(ZipShort.getBytes(zipMethod)); - written += 2; - - // last mod. time and date - writeOut(toDosTime(ze.getTime())); - written += 4; - - // CRC - // compressed length - // uncompressed length - localDataStart = written; - if (zipMethod == DEFLATED || raf != null) { - writeOut(LZERO); - writeOut(LZERO); - writeOut(LZERO); - } else { - writeOut(ZipLong.getBytes(ze.getCrc())); - writeOut(ZipLong.getBytes(ze.getSize())); - writeOut(ZipLong.getBytes(ze.getSize())); - } - written += 12; - - // file name length - byte[] name = getBytes(ze.getName()); - writeOut(ZipShort.getBytes(name.length)); - written += 2; - - // extra field length - byte[] extra = ze.getLocalFileDataExtra(); - writeOut(ZipShort.getBytes(extra.length)); - written += 2; - - // file name - writeOut(name); - written += name.length; - - // extra field - writeOut(extra); - written += extra.length; - - dataStart = written; + } + + /** + * Flushes this output stream and forces any buffered output bytes to be + * written out to the stream. + * + * @exception IOException + * if an I/O error occurs. + * @since 1.14 + */ + public void flush() throws IOException { + if (out != null) { + out.flush(); } - - /** - * Writes the data descriptor entry. - * @param ze the entry to write - * @throws IOException on error - * - * @since 1.1 - */ - protected void writeDataDescriptor(ZipEntry ze) throws IOException { - if (ze.getMethod() != DEFLATED || raf != null) { - return; - } - writeOut(DD_SIG); - writeOut(ZipLong.getBytes(entry.getCrc())); - writeOut(ZipLong.getBytes(entry.getCompressedSize())); - writeOut(ZipLong.getBytes(entry.getSize())); - written += 16; + } + + /* + * Various ZIP constants + */ + /** + * local file header signature + * + * @since 1.1 + */ + protected static final byte[] LFH_SIG = ZipLong.getBytes(0X04034B50L); + + /** + * data descriptor signature + * + * @since 1.1 + */ + protected static final byte[] DD_SIG = ZipLong.getBytes(0X08074B50L); + + /** + * central file header signature + * + * @since 1.1 + */ + protected static final byte[] CFH_SIG = ZipLong.getBytes(0X02014B50L); + + /** + * end of central dir signature + * + * @since 1.1 + */ + protected static final byte[] EOCD_SIG = ZipLong.getBytes(0X06054B50L); + + /** + * Writes next block of compressed data to the output stream. + * + * @throws IOException + * on error + * + * @since 1.14 + */ + protected final void deflate() throws IOException { + int len = def.deflate(buf, 0, buf.length); + if (len > 0) { + writeOut(buf, 0, len); } - - /** - * Writes the central file header entry. - * @param ze the entry to write - * @throws IOException on error - * - * @since 1.1 - */ - protected void writeCentralFileHeader(ZipEntry ze) throws IOException { - writeOut(CFH_SIG); - written += 4; - - // version made by - writeOut(ZipShort.getBytes((ze.getPlatform() << 8) | 20)); - written += 2; - - // version needed to extract - // general purpose bit flag - if (ze.getMethod() == DEFLATED && raf == null) { - // requires version 2 as we are going to store length info - // in the data descriptor - writeOut(ZipShort.getBytes(20)); - - // bit3 set to signal, we use a data descriptor - writeOut(ZipShort.getBytes(8)); - } else { - writeOut(ZipShort.getBytes(10)); - writeOut(ZERO); - } - written += 4; - - // compression method - writeOut(ZipShort.getBytes(ze.getMethod())); - written += 2; - - // last mod. time and date - writeOut(toDosTime(ze.getTime())); - written += 4; - - // CRC - // compressed length - // uncompressed length - writeOut(ZipLong.getBytes(ze.getCrc())); - writeOut(ZipLong.getBytes(ze.getCompressedSize())); - writeOut(ZipLong.getBytes(ze.getSize())); - written += 12; - - // file name length - byte[] name = getBytes(ze.getName()); - writeOut(ZipShort.getBytes(name.length)); - written += 2; - - // extra field length - byte[] extra = ze.getCentralDirectoryExtra(); - writeOut(ZipShort.getBytes(extra.length)); - written += 2; - - // file comment length - String comm = ze.getComment(); - if (comm == null) { - comm = ""; - } - byte[] commentB = getBytes(comm); - writeOut(ZipShort.getBytes(commentB.length)); - written += 2; - - // disk number start - writeOut(ZERO); - written += 2; - - // internal file attributes - writeOut(ZipShort.getBytes(ze.getInternalAttributes())); - written += 2; - - // external file attributes - writeOut(ZipLong.getBytes(ze.getExternalAttributes())); - written += 4; - - // relative offset of LFH - writeOut((byte[]) offsets.get(ze)); - written += 4; - - // file name - writeOut(name); - written += name.length; - - // extra field - writeOut(extra); - written += extra.length; - - // file comment - writeOut(commentB); - written += commentB.length; + } + + /** + * Writes the local file header entry + * + * @param ze + * the entry to write + * @throws IOException + * on error + * + * @since 1.1 + */ + protected void writeLocalFileHeader(ZipEntry ze) throws IOException { + offsets.put(ze, ZipLong.getBytes(written)); + + writeOut(LFH_SIG); + written += 4; + + // store method in local variable to prevent multiple method calls + final int zipMethod = ze.getMethod(); + + // version needed to extract + // general purpose bit flag + if (zipMethod == DEFLATED && raf == null) { + // requires version 2 as we are going to store length info + // in the data descriptor + writeOut(ZipShort.getBytes(20)); + + // bit3 set to signal, we use a data descriptor + writeOut(ZipShort.getBytes(8)); + } else { + writeOut(ZipShort.getBytes(10)); + writeOut(ZERO); } - - /** - * Writes the "End of central dir record". - * @throws IOException on error - * - * @since 1.1 - */ - protected void writeCentralDirectoryEnd() throws IOException { - writeOut(EOCD_SIG); - - // disk numbers - writeOut(ZERO); - writeOut(ZERO); - - // number of entries - byte[] num = ZipShort.getBytes(entries.size()); - writeOut(num); - writeOut(num); - - // length and location of CD - writeOut(ZipLong.getBytes(cdLength)); - writeOut(ZipLong.getBytes(cdOffset)); - - // ZIP file comment - byte[] data = getBytes(comment); - writeOut(ZipShort.getBytes(data.length)); - writeOut(data); + written += 4; + + // compression method + writeOut(ZipShort.getBytes(zipMethod)); + written += 2; + + // last mod. time and date + writeOut(toDosTime(ze.getTime())); + written += 4; + + // CRC + // compressed length + // uncompressed length + localDataStart = written; + if (zipMethod == DEFLATED || raf != null) { + writeOut(LZERO); + writeOut(LZERO); + writeOut(LZERO); + } else { + writeOut(ZipLong.getBytes(ze.getCrc())); + writeOut(ZipLong.getBytes(ze.getSize())); + writeOut(ZipLong.getBytes(ze.getSize())); } - - /** - * Smallest date/time ZIP can handle. - * - * @since 1.1 - */ - private static final byte[] DOS_TIME_MIN = ZipLong.getBytes(0x00002100L); - - /** - * Convert a Date object to a DOS date/time field. - * @param time the Date to convert - * @return the date as a ZipLong - * @since 1.1 - */ - protected static ZipLong toDosTime(Date time) { - return new ZipLong(toDosTime(time.getTime())); + written += 12; + + // file name length + byte[] name = getBytes(ze.getName()); + writeOut(ZipShort.getBytes(name.length)); + written += 2; + + // extra field length + byte[] extra = ze.getLocalFileDataExtra(); + writeOut(ZipShort.getBytes(extra.length)); + written += 2; + + // file name + writeOut(name); + written += name.length; + + // extra field + writeOut(extra); + written += extra.length; + + dataStart = written; + } + + /** + * Writes the data descriptor entry. + * + * @param ze + * the entry to write + * @throws IOException + * on error + * + * @since 1.1 + */ + protected void writeDataDescriptor(ZipEntry ze) throws IOException { + if (ze.getMethod() != DEFLATED || raf != null) { + return; } - - /** - * Convert a Date object to a DOS date/time field. - * - *

Stolen from InfoZip's fileio.c

- * @param t number of milliseconds since the epoch - * @return the date as a byte array - * @since 1.26 - */ - protected static byte[] toDosTime(long t) { - Date time = new Date(t); - int year = time.getYear() + 1900; - if (year < 1980) { - return DOS_TIME_MIN; - } - int month = time.getMonth() + 1; - long value = ((year - 1980) << 25) - | (month << 21) - | (time.getDate() << 16) - | (time.getHours() << 11) - | (time.getMinutes() << 5) - | (time.getSeconds() >> 1); - return ZipLong.getBytes(value); + writeOut(DD_SIG); + writeOut(ZipLong.getBytes(entry.getCrc())); + writeOut(ZipLong.getBytes(entry.getCompressedSize())); + writeOut(ZipLong.getBytes(entry.getSize())); + written += 16; + } + + /** + * Writes the central file header entry. + * + * @param ze + * the entry to write + * @throws IOException + * on error + * + * @since 1.1 + */ + protected void writeCentralFileHeader(ZipEntry ze) throws IOException { + writeOut(CFH_SIG); + written += 4; + + // version made by + writeOut(ZipShort.getBytes((ze.getPlatform() << 8) | 20)); + written += 2; + + // version needed to extract + // general purpose bit flag + if (ze.getMethod() == DEFLATED && raf == null) { + // requires version 2 as we are going to store length info + // in the data descriptor + writeOut(ZipShort.getBytes(20)); + + // bit3 set to signal, we use a data descriptor + writeOut(ZipShort.getBytes(8)); + } else { + writeOut(ZipShort.getBytes(10)); + writeOut(ZERO); } - - /** - * Retrieve the bytes for the given String in the encoding set for - * this Stream. - * @param name the string to get bytes from - * @return the bytes as a byte array - * @throws ZipException on error - * - * @since 1.3 - */ - protected byte[] getBytes(String name) throws ZipException { - if (encoding == null) { - return name.getBytes(); - } else { - try { - return name.getBytes(encoding); - } catch (UnsupportedEncodingException uee) { - throw new ZipException(uee.getMessage()); - } - } + written += 4; + + // compression method + writeOut(ZipShort.getBytes(ze.getMethod())); + written += 2; + + // last mod. time and date + writeOut(toDosTime(ze.getTime())); + written += 4; + + // CRC + // compressed length + // uncompressed length + writeOut(ZipLong.getBytes(ze.getCrc())); + writeOut(ZipLong.getBytes(ze.getCompressedSize())); + writeOut(ZipLong.getBytes(ze.getSize())); + written += 12; + + // file name length + byte[] name = getBytes(ze.getName()); + writeOut(ZipShort.getBytes(name.length)); + written += 2; + + // extra field length + byte[] extra = ze.getCentralDirectoryExtra(); + writeOut(ZipShort.getBytes(extra.length)); + written += 2; + + // file comment length + String comm = ze.getComment(); + if (comm == null) { + comm = ""; } - - /** - * Write bytes to output or random access file. - * @param data the byte array to write - * @throws IOException on error - * - * @since 1.14 - */ - protected final void writeOut(byte[] data) throws IOException { - writeOut(data, 0, data.length); + byte[] commentB = getBytes(comm); + writeOut(ZipShort.getBytes(commentB.length)); + written += 2; + + // disk number start + writeOut(ZERO); + written += 2; + + // internal file attributes + writeOut(ZipShort.getBytes(ze.getInternalAttributes())); + written += 2; + + // external file attributes + writeOut(ZipLong.getBytes(ze.getExternalAttributes())); + written += 4; + + // relative offset of LFH + writeOut((byte[]) offsets.get(ze)); + written += 4; + + // file name + writeOut(name); + written += name.length; + + // extra field + writeOut(extra); + written += extra.length; + + // file comment + writeOut(commentB); + written += commentB.length; + } + + /** + * Writes the "End of central dir record". + * + * @throws IOException + * on error + * + * @since 1.1 + */ + protected void writeCentralDirectoryEnd() throws IOException { + writeOut(EOCD_SIG); + + // disk numbers + writeOut(ZERO); + writeOut(ZERO); + + // number of entries + byte[] num = ZipShort.getBytes(entries.size()); + writeOut(num); + writeOut(num); + + // length and location of CD + writeOut(ZipLong.getBytes(cdLength)); + writeOut(ZipLong.getBytes(cdOffset)); + + // ZIP file comment + byte[] data = getBytes(comment); + writeOut(ZipShort.getBytes(data.length)); + writeOut(data); + } + + /** + * Smallest date/time ZIP can handle. + * + * @since 1.1 + */ + private static final byte[] DOS_TIME_MIN = ZipLong.getBytes(0x00002100L); + + /** + * Convert a Date object to a DOS date/time field. + * + * @param time + * the Date to convert + * @return the date as a ZipLong + * @since 1.1 + */ + protected static ZipLong toDosTime(Date time) { + return new ZipLong(toDosTime(time.getTime())); + } + + /** + * Convert a Date object to a DOS date/time field. + * + *

+ * Stolen from InfoZip's fileio.c + *

+ * + * @param t + * number of milliseconds since the epoch + * @return the date as a byte array + * @since 1.26 + */ + protected static byte[] toDosTime(long t) { + Date time = new Date(t); + int year = time.getYear() + 1900; + if (year < 1980) { + return DOS_TIME_MIN; } - - /** - * Write bytes to output or random access file. - * @param data the byte array to write - * @param offset the start position to write from - * @param length the number of bytes to write - * @throws IOException on error - * - * @since 1.14 - */ - protected final void writeOut(byte[] data, int offset, int length) - throws IOException { - if (raf != null) { - raf.write(data, offset, length); - } else { - out.write(data, offset, length); - } + int month = time.getMonth() + 1; + long value = ((year - 1980) << 25) | (month << 21) | (time.getDate() << 16) + | (time.getHours() << 11) | (time.getMinutes() << 5) + | (time.getSeconds() >> 1); + return ZipLong.getBytes(value); + } + + /** + * Retrieve the bytes for the given String in the encoding set for this + * Stream. + * + * @param name + * the string to get bytes from + * @return the bytes as a byte array + * @throws ZipException + * on error + * + * @since 1.3 + */ + protected byte[] getBytes(String name) throws ZipException { + if (encoding == null) { + return name.getBytes(); + } else { + try { + return name.getBytes(encoding); + } catch (UnsupportedEncodingException uee) { + throw new ZipException(uee.getMessage()); + } } - - /** - * Assumes a negative integer really is a positive integer that - * has wrapped around and re-creates the original value. - * @param i the value to treat as unsigned int. - * @return the unsigned int as a long. - * @since 1.34 - */ - protected static long adjustToLong(int i) { - if (i < 0) { - return 2 * ((long) Integer.MAX_VALUE) + 2 + i; - } else { - return i; - } + } + + /** + * Write bytes to output or random access file. + * + * @param data + * the byte array to write + * @throws IOException + * on error + * + * @since 1.14 + */ + protected final void writeOut(byte[] data) throws IOException { + writeOut(data, 0, data.length); + } + + /** + * Write bytes to output or random access file. + * + * @param data + * the byte array to write + * @param offset + * the start position to write from + * @param length + * the number of bytes to write + * @throws IOException + * on error + * + * @since 1.14 + */ + protected final void writeOut(byte[] data, int offset, int length) + throws IOException { + if (raf != null) { + raf.write(data, offset, length); + } else { + out.write(data, offset, length); + } + } + + /** + * Assumes a negative integer really is a positive integer that has wrapped + * around and re-creates the original value. + * + * @param i + * the value to treat as unsigned int. + * @return the unsigned int as a long. + * @since 1.34 + */ + protected static long adjustToLong(int i) { + if (i < 0) { + return 2 * ((long) Integer.MAX_VALUE) + 2 + i; + } else { + return i; } + } } diff --git a/src/org/apache/tools/zip/ZipShort.java b/src/org/apache/tools/zip/ZipShort.java index 97bb03f..6f4ba38 100644 --- a/src/org/apache/tools/zip/ZipShort.java +++ b/src/org/apache/tools/zip/ZipShort.java @@ -19,115 +19,135 @@ package org.apache.tools.zip; /** - * Utility class that represents a two byte integer with conversion - * rules for the big endian byte order of ZIP files. - * + * Utility class that represents a two byte integer with conversion rules for + * the big endian byte order of ZIP files. + * */ public final class ZipShort implements Cloneable { - private int value; + private int value; - /** - * Create instance from a number. - * @param value the int to store as a ZipShort - * @since 1.1 - */ - public ZipShort (int value) { - this.value = value; - } + /** + * Create instance from a number. + * + * @param value + * the int to store as a ZipShort + * @since 1.1 + */ + public ZipShort(int value) { + this.value = value; + } - /** - * Create instance from bytes. - * @param bytes the bytes to store as a ZipShort - * @since 1.1 - */ - public ZipShort (byte[] bytes) { - this(bytes, 0); - } + /** + * Create instance from bytes. + * + * @param bytes + * the bytes to store as a ZipShort + * @since 1.1 + */ + public ZipShort(byte[] bytes) { + this(bytes, 0); + } - /** - * Create instance from the two bytes starting at offset. - * @param bytes the bytes to store as a ZipShort - * @param offset the offset to start - * @since 1.1 - */ - public ZipShort (byte[] bytes, int offset) { - value = ZipShort.getValue(bytes, offset); - } + /** + * Create instance from the two bytes starting at offset. + * + * @param bytes + * the bytes to store as a ZipShort + * @param offset + * the offset to start + * @since 1.1 + */ + public ZipShort(byte[] bytes, int offset) { + value = ZipShort.getValue(bytes, offset); + } - /** - * Get value as two bytes in big endian byte order. - * @return the value as a a two byte array in big endian byte order - * @since 1.1 - */ - public byte[] getBytes() { - byte[] result = new byte[2]; - result[0] = (byte) (value & 0xFF); - result[1] = (byte) ((value & 0xFF00) >> 8); - return result; - } + /** + * Get value as two bytes in big endian byte order. + * + * @return the value as a a two byte array in big endian byte order + * @since 1.1 + */ + public byte[] getBytes() { + byte[] result = new byte[2]; + result[0] = (byte) (value & 0xFF); + result[1] = (byte) ((value & 0xFF00) >> 8); + return result; + } - /** - * Get value as Java int. - * @return value as a Java int - * @since 1.1 - */ - public int getValue() { - return value; - } + /** + * Get value as Java int. + * + * @return value as a Java int + * @since 1.1 + */ + public int getValue() { + return value; + } - /** - * Get value as two bytes in big endian byte order. - * @param value the Java int to convert to bytes - * @return the converted int as a byte array in big endian byte order - */ - public static byte[] getBytes(int value) { - byte[] result = new byte[2]; - result[0] = (byte) (value & 0xFF); - result[1] = (byte) ((value & 0xFF00) >> 8); - return result; - } + /** + * Get value as two bytes in big endian byte order. + * + * @param value + * the Java int to convert to bytes + * @return the converted int as a byte array in big endian byte order + */ + public static byte[] getBytes(int value) { + byte[] result = new byte[2]; + result[0] = (byte) (value & 0xFF); + result[1] = (byte) ((value & 0xFF00) >> 8); + return result; + } - /** - * Helper method to get the value as a java int from two bytes starting at given array offset - * @param bytes the array of bytes - * @param offset the offset to start - * @return the correspondanding java int value - */ - public static int getValue(byte[] bytes, int offset) { - int value = (bytes[offset + 1] << 8) & 0xFF00; - value += (bytes[offset] & 0xFF); - return value; - } + /** + * Helper method to get the value as a java int from two bytes starting at + * given array offset + * + * @param bytes + * the array of bytes + * @param offset + * the offset to start + * @return the correspondanding java int value + */ + public static int getValue(byte[] bytes, int offset) { + int value = (bytes[offset + 1] << 8) & 0xFF00; + value += (bytes[offset] & 0xFF); + return value; + } - /** - * Helper method to get the value as a java int from a two-byte array - * @param bytes the array of bytes - * @return the correspondanding java int value - */ - public static int getValue(byte[] bytes) { - return getValue(bytes, 0); - } + /** + * Helper method to get the value as a java int from a two-byte array + * + * @param bytes + * the array of bytes + * @return the correspondanding java int value + */ + public static int getValue(byte[] bytes) { + return getValue(bytes, 0); + } - /** - * Override to make two instances with same value equal. - * @param o an object to compare - * @return true if the objects are equal - * @since 1.1 - */ - public boolean equals(Object o) { - if (o == null || !(o instanceof ZipShort)) { - return false; - } - return value == ((ZipShort) o).getValue(); + /** + * Override to make two instances with same value equal. + * + * @param o + * an object to compare + * @return true if the objects are equal + * @since 1.1 + */ + public boolean equals(Object o) { + if (o == null || !(o instanceof ZipShort)) { + return false; } + return value == ((ZipShort) o).getValue(); + } - /** - * Override to make two instances with same value equal. - * @return the value stored in the ZipShort - * @since 1.1 - */ - public int hashCode() { - return value; - } + /** + * Override to make two instances with same value equal. + * + * @return the value stored in the ZipShort + * @since 1.1 + */ + public int hashCode() { + return value; + } } diff --git a/src/uk/ac/vamsas/client/AppDataInputStream.java b/src/uk/ac/vamsas/client/AppDataInputStream.java index 0b021aa..0e03bc8 100644 --- a/src/uk/ac/vamsas/client/AppDataInputStream.java +++ b/src/uk/ac/vamsas/client/AppDataInputStream.java @@ -1,53 +1,77 @@ -/** - * - */ -package uk.ac.vamsas.client; - -import java.io.DataInput; -import java.io.DataInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.jar.JarInputStream; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * @author jimp - * LATER: this may not be a necessary or useful class to return from IClientAppdata get*InputStream() methods - */ -public class AppDataInputStream extends DataInputStream implements DataInput { - private Log log = LogFactory.getLog(AppDataInputStream.class); - private boolean isOpen = false; - /** - * Wrapper for writing to/from AppData Entries in a Vamsas Document. - */ - public AppDataInputStream(InputStream inputstream) { - super(inputstream); - isOpen=true; - } - - /* (non-Javadoc) - * @see java.io.FilterInputStream#close() - */ - public void close() throws IOException { - if (!isOpen) { - log.debug("close() called on closed AppDataInputStream."); - // throw new IOException("Attempt to close an already closed AppDataInputStream"); - } else { - isOpen=false; - } - } - - /** - * Will return zero if stream has been closed. - * @see java.io.FilterInputStream#available() - */ - public int available() throws IOException { - if (isOpen) - return super.available(); - else - return 0; - } - -} +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ +package uk.ac.vamsas.client; + +import java.io.DataInput; +import java.io.DataInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.jar.JarInputStream; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * @author jimp LATER: this may not be a necessary or useful class to return + * from IClientAppdata get*InputStream() methods + */ +public class AppDataInputStream extends DataInputStream implements DataInput { + private Log log = LogFactory.getLog(AppDataInputStream.class); + + private boolean isOpen = false; + + /** + * Wrapper for writing to/from AppData Entries in a Vamsas Document. + */ + public AppDataInputStream(InputStream inputstream) { + super(inputstream); + isOpen = true; + } + + /* + * (non-Javadoc) + * + * @see java.io.FilterInputStream#close() + */ + public void close() throws IOException { + if (!isOpen) { + log.debug("close() called on closed AppDataInputStream."); + // throw new + // IOException("Attempt to close an already closed AppDataInputStream"); + } else { + isOpen = false; + } + } + + /** + * Will return zero if stream has been closed. + * + * @see java.io.FilterInputStream#available() + */ + public int available() throws IOException { + if (isOpen) + return super.available(); + else + return 0; + } + +} diff --git a/src/uk/ac/vamsas/client/AppDataOutputStream.java b/src/uk/ac/vamsas/client/AppDataOutputStream.java index 5eb1ff3..eaaa7ef 100644 --- a/src/uk/ac/vamsas/client/AppDataOutputStream.java +++ b/src/uk/ac/vamsas/client/AppDataOutputStream.java @@ -1,86 +1,121 @@ -/** - * - */ -package uk.ac.vamsas.client; - -import java.io.DataOutputStream; -import java.io.IOException; -import java.io.OutputStream; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * @author jimp - * - */ -public class AppDataOutputStream extends DataOutputStream { - private Log log = LogFactory.getLog(AppDataOutputStream.class); - private boolean isOpen=true; - /** - * @param out - */ - public AppDataOutputStream(OutputStream out) { - super(out); - isOpen=true; - } - /* (non-Javadoc) - * @see java.io.DataOutputStream#flush() - */ - public void flush() throws IOException { - if (isOpen) - super.flush(); - else - log.warn("flush() called on closed AppDataOutputStream"); - } - /* (non-Javadoc) - * @see java.io.DataOutputStream#write(byte[], int, int) - */ - public synchronized void write(byte[] b, int off, int len) throws IOException { - if (isOpen) { - super.write(b, off, len); - } else { - log.debug("write(b,off,len) called on closed AppDataOutputStream"); - throw new IOException("Attempt to write to closed AppDataOutputStream"); - } - } - /* (non-Javadoc) - * @see java.io.DataOutputStream#write(int) - */ - public synchronized void write(int b) throws IOException { - if (isOpen) { - super.write(b); - } else { - log.debug("write(b) called on closed AppDataOutputStream"); - throw new IOException("Attempt to write to closed AppDataOutputStream"); - } - } - /** - * Sets an internal flag preventing further write operations - * to the AppData output stream and flushes any pending writes. - * @see java.io.FilterOutputStream#close() - */ - public void close() throws IOException { - isOpen=false; - super.flush(); - log.debug("AppDataOutputStream was closed."); - } - /* (non-Javadoc) - * @see java.io.FilterOutputStream#write(byte[]) - */ - public void write(byte[] b) throws IOException { - if (isOpen) { - super.write(b); - } else { - log.debug("write(b[]) called on closed AppDataOutputStream"); - throw new IOException("Attempt to write to closed AppDataOutputStream"); - } - } - /** - * @return true if stream is still Open. - */ - public boolean isOpen() { - return isOpen; - } - -} +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ +package uk.ac.vamsas.client; + +import java.io.DataOutputStream; +import java.io.IOException; +import java.io.OutputStream; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * @author jimp + * + */ +public class AppDataOutputStream extends DataOutputStream { + private Log log = LogFactory.getLog(AppDataOutputStream.class); + + private boolean isOpen = true; + + /** + * @param out + */ + public AppDataOutputStream(OutputStream out) { + super(out); + isOpen = true; + } + + /* + * (non-Javadoc) + * + * @see java.io.DataOutputStream#flush() + */ + public void flush() throws IOException { + if (isOpen) + super.flush(); + else + log.warn("flush() called on closed AppDataOutputStream"); + } + + /* + * (non-Javadoc) + * + * @see java.io.DataOutputStream#write(byte[], int, int) + */ + public synchronized void write(byte[] b, int off, int len) throws IOException { + if (isOpen) { + super.write(b, off, len); + } else { + log.debug("write(b,off,len) called on closed AppDataOutputStream"); + throw new IOException("Attempt to write to closed AppDataOutputStream"); + } + } + + /* + * (non-Javadoc) + * + * @see java.io.DataOutputStream#write(int) + */ + public synchronized void write(int b) throws IOException { + if (isOpen) { + super.write(b); + } else { + log.debug("write(b) called on closed AppDataOutputStream"); + throw new IOException("Attempt to write to closed AppDataOutputStream"); + } + } + + /** + * Sets an internal flag preventing further write operations to the AppData + * output stream and flushes any pending writes. + * + * @see java.io.FilterOutputStream#close() + */ + public void close() throws IOException { + isOpen = false; + super.flush(); + log.debug("AppDataOutputStream was closed."); + } + + /* + * (non-Javadoc) + * + * @see java.io.FilterOutputStream#write(byte[]) + */ + public void write(byte[] b) throws IOException { + if (isOpen) { + super.write(b); + } else { + log.debug("write(b[]) called on closed AppDataOutputStream"); + throw new IOException("Attempt to write to closed AppDataOutputStream"); + } + } + + /** + * @return true if stream is still Open. + */ + public boolean isOpen() { + return isOpen; + } + +} diff --git a/src/uk/ac/vamsas/client/ClientDocument.java b/src/uk/ac/vamsas/client/ClientDocument.java index 49f949c..992555f 100644 --- a/src/uk/ac/vamsas/client/ClientDocument.java +++ b/src/uk/ac/vamsas/client/ClientDocument.java @@ -1,5 +1,23 @@ /* - * + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ package uk.ac.vamsas.client; @@ -11,43 +29,46 @@ import org.apache.commons.logging.LogFactory; import uk.ac.vamsas.objects.core.VAMSAS; /** - * skeleton abstract class to allow client implementations - * access to vamsas.client.Vobject registry mechanism. + * skeleton abstract class to allow client implementations access to + * vamsas.client.Vobject registry mechanism. */ public abstract class ClientDocument implements IClientDocument { static Log log = LogFactory.getLog(ClientDocument.class); - + /** * collection of uk.ac.vamsas.client.Vobject references */ protected Hashtable vamsasObjects; + protected IVorbaIdFactory vorbafactory; - + protected ClientDocument(Hashtable objects, IVorbaIdFactory factory) { vamsasObjects = objects; vorbafactory = factory; } - + /** * @see IClientHandle.registerObject(Vobject unregistered) */ protected VorbaId _registerObject(Vobject unregistered) { - // be ultra safe here because the user may be trying to mix different factories - if (unregistered.__vorba==null) - unregistered.__vorba = vorbafactory; - else - if (unregistered.__vorba!=vorbafactory) { - // LATER: decide if this is allowed - it isn't for the moment. - log.error("Attempt to overwrite info in a registered vorba Vobject (under a different IVorbaIdFactory) ! - Implementation fix needed."); - return null; - } else { - // probably didn't need to call registerObject. - log.debug("Redundant call to registerObject"); - } + // be ultra safe here because the user may be trying to mix different + // factories + if (unregistered.__vorba == null) + unregistered.__vorba = vorbafactory; + else if (unregistered.__vorba != vorbafactory) { + // LATER: decide if this is allowed - it isn't for the moment. + log + .error("Attempt to overwrite info in a registered vorba Vobject (under a different IVorbaIdFactory) ! - Implementation fix needed."); + return null; + } else { + // probably didn't need to call registerObject. + log.debug("Redundant call to registerObject"); + } // TODO: add default provenance. // TODO: decide if we need to do call __ensure_instance_ids here - // TODO: check if __ensure_instance_ids works correctly with new 'visit flag' mechanism - unregistered.__ensure_instance_ids(); // call cascade method here : + // TODO: check if __ensure_instance_ids works correctly with new 'visit + // flag' mechanism + unregistered.__ensure_instance_ids(); // call cascade method here : return unregistered.getVorbaId(); } } diff --git a/src/uk/ac/vamsas/client/ClientHandle.java b/src/uk/ac/vamsas/client/ClientHandle.java index b566c8d..4d0f936 100644 --- a/src/uk/ac/vamsas/client/ClientHandle.java +++ b/src/uk/ac/vamsas/client/ClientHandle.java @@ -1,4 +1,23 @@ /* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ package uk.ac.vamsas.client; @@ -6,11 +25,12 @@ import java.io.Serializable; /** * Uniquely describes a vamsas client application. - * @author jimp + * + * @author jimp */ public class ClientHandle implements Serializable { static final long serialVersionUID = 0; - + /** * @param clientName * @param version @@ -19,19 +39,21 @@ public class ClientHandle implements Serializable { super(); this.clientName = _clientName; this.version = _version; - //this.setClientUrn("vamsas://"+clientName+":"+version+"/"); // TODO: decide on application handle ornthing (used to prefix new ids made by a particular application) + // this.setClientUrn("vamsas://"+clientName+":"+version+"/"); // TODO: + // decide on application handle ornthing (used to prefix new ids made by a + // particular application) this.setClientUrn(this.generateClientUrn(this.clientName, this.version)); } + /** * (non-unique) human readable vamsas client name */ String clientName; /** - * the unambiguous client identifier - * This may be rewritten by the Vorba object if - * other clients with the same name, version - * and user are involved in a session. + * the unambiguous client identifier This may be rewritten by the Vorba object + * if other clients with the same name, version and user are involved in a + * session. * */ String clientUrn; @@ -43,16 +65,17 @@ public class ClientHandle implements Serializable { /** * Generates the client Urn from the clientName and version - * - * @param clientName (non-unique) human readable vamsas client name - * @param version version modifier + * + * @param clientName + * (non-unique) human readable vamsas client name + * @param version + * version modifier * @return a String corresponding to the clientUrn */ - private String generateClientUrn(String _clientName, String _version) - { - return ("vamsas://"+_clientName+":"+_version+"/").intern(); - } - + private String generateClientUrn(String _clientName, String _version) { + return ("vamsas://" + _clientName + ":" + _version + "/").intern(); + } + /** * @return Returns the clientUrn. */ @@ -62,6 +85,7 @@ public class ClientHandle implements Serializable { /** * May become protected - should only be set by a Vorba object. + * * @param clientUrn * The clientUrn to set. */ @@ -85,7 +109,6 @@ public class ClientHandle implements Serializable { this.setClientUrn(this.generateClientUrn(this.clientName, this.version)); } - /** * @return Returns the clientName. */ @@ -104,17 +127,18 @@ public class ClientHandle implements Serializable { public boolean equals(Object that) { if (that instanceof ClientHandle) - return this.equals((ClientHandle) that); + return this.equals((ClientHandle) that); return false; } + public boolean equals(ClientHandle that) { - return ( (this.clientName == null || this.clientName.equals(that.clientName)) - && (this.version == null || this.version.equals(that.version)) - && (this.clientUrn == null || this.clientUrn.equals(that.clientUrn))); + return ((this.clientName == null || this.clientName.equals(that.clientName)) + && (this.version == null || this.version.equals(that.version)) && (this.clientUrn == null || this.clientUrn + .equals(that.clientUrn))); } public String getClientNCname() { - + String ncname = clientName.replace(':', '_'); ncname = ncname.replace('@', '.'); return ncname; diff --git a/src/uk/ac/vamsas/client/Events.java b/src/uk/ac/vamsas/client/Events.java index c75ac7b..2a2d22e 100644 --- a/src/uk/ac/vamsas/client/Events.java +++ b/src/uk/ac/vamsas/client/Events.java @@ -1,29 +1,48 @@ +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ package uk.ac.vamsas.client; /** * Enumerates the event types generated during the lifecycle of a Vamsas - * session. - * See the excel spreadsheet in VamsasClient/docs/VamsasSessionEventAnalysis.xls for - * some more information about when these are generated and how they should be - * handled. + * session. See the excel spreadsheet in + * VamsasClient/docs/VamsasSessionEventAnalysis.xls for some more information + * about when these are generated and how they should be handled. * */ public class Events { /** - * Generated when a client has finished updating the document. - * Client which has completed an update should - * not receive the event. - * NewValue: uk.ac.vamsas.client.IClient for session. + * Generated when a client has finished updating the document. Client which + * has completed an update should not receive the event. NewValue: + * uk.ac.vamsas.client.IClient for session. */ public static final String DOCUMENT_UPDATE = "uk.ac.vamsas.client.events.documentUpdateEvent"; /** * Generated when a new vamsas document is created (perhaps from some existing * Vamsas data) so an application may do its own data space initialization. - * Raised for a new application connecting to a vamsas document - * NewValue: uk.ac.vamsas.client.IClient for session. - * LATER: DOCUMENT_CREATE event may be redundant + * Raised for a new application connecting to a vamsas document NewValue: + * uk.ac.vamsas.client.IClient for session. LATER: DOCUMENT_CREATE event may + * be redundant */ public static final String DOCUMENT_CREATE = "uk.ac.vamsas.client.events.documentCreateEvent"; @@ -41,38 +60,34 @@ public class Events { /** * Generated prior to session Shutdown, after the last participating vamsas - * client has finalized. - * Probably only useful to IClientFactory implementations. - * NewValue: + * client has finalized. Probably only useful to IClientFactory + * implementations. NewValue: */ public static final String SESSION_SHUTDOWN = "uk.ac.vamsas.client.events.SessionShutdownEvent"; /** * Generated for all clients when any client calls IClient.storeDocument() to * allow them to store any updates before an offline copy of the session is - * created. - * Any client that handles this should call the + * created. Any client that handles this should call the * IClient.getDocument(), update and then IClient.updateDocument in the same * handler thread (the lock on the document is held until the handler exits). - * EventName: - * NewValue: uk.ac.vamsas.client.IClient for session. + * EventName: NewValue: uk.ac.vamsas.client.IClient for + * session. */ public static final String DOCUMENT_FINALIZEAPPDATA = "uk.ac.vamsas.client.events.DocumentFinalizeAppData"; /** - * Generated by Vorba stub for the sole remaining client instance in a session, - * when it makes a call to finalizeClient(). - * It is only raised if the session has been modified since the - * last call to storeDocument() by any application. - * LATER: copies of a document should be on a per-user basis for multi-user sessions. - * Sequence is as follows : 1. All other vamsas clients have - * called finalizeClient() 2. Final living client monitors closures, and + * Generated by Vorba stub for the sole remaining client instance in a + * session, when it makes a call to finalizeClient(). It is only raised if the + * session has been modified since the last call to storeDocument() by any + * application. LATER: copies of a document should be on a per-user basis for + * multi-user sessions. Sequence is as follows : 1. All other vamsas clients + * have called finalizeClient() 2. Final living client monitors closures, and * realises that it is last. 3. Final client generates event to prompt * associated application to inquire if the user wishes to save the document - * for future reference. - * * Any call to finalizeClient in a thread other than the registered - * EventListener will block until the RequestToClose handler has exited. - * NewValue: uk.ac.vamsas.client.IClient for session. + * for future reference. * Any call to finalizeClient in a thread other than + * the registered EventListener will block until the RequestToClose handler + * has exited. NewValue: uk.ac.vamsas.client.IClient for session. */ public static final String DOCUMENT_REQUESTTOCLOSE = "uk.ac.vamas.client.DocumentRequestToCloseEvent"; diff --git a/src/uk/ac/vamsas/client/IClient.java b/src/uk/ac/vamsas/client/IClient.java index cf61bb2..c59a26c 100644 --- a/src/uk/ac/vamsas/client/IClient.java +++ b/src/uk/ac/vamsas/client/IClient.java @@ -1,6 +1,23 @@ -/** - * uk.ac.vamsas.client.IClient +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ package uk.ac.vamsas.client; @@ -8,142 +25,162 @@ import java.beans.PropertyChangeListener; import java.io.IOException; /** - * Defines the methods availabable to a vamsas - * application for interacting with its Vorba agent - * created by an IClientFactory instance for a particular session, - * user, and application handle. - * (it's VORBA, not CORBA!) - * LATER: add exceptions for timeouts raised when there are problems accessing session data (because another application is hogging it). - * LATER: think about situations when two applications both want a ClientDocument at the same time - can one have read-only access (and be told that another is about to update) + * Defines the methods availabable to a vamsas application for interacting with + * its Vorba agent created by an IClientFactory instance for a particular + * session, user, and application handle. (it's VORBA, not CORBA!) LATER: add + * exceptions for timeouts raised when there are problems accessing session data + * (because another application is hogging it). LATER: think about situations + * when two applications both want a ClientDocument at the same time - can one + * have read-only access (and be told that another is about to update) */ public interface IClient { - + /** - * Self-documenting/describing info for the application to present - * to the user. - * LATER: formalise this for describing VAMSAS system, a particular + * Self-documenting/describing info for the application to present to the + * user. LATER: formalise this for describing VAMSAS system, a particular * Vorba client agent, and a particular session. + * * @return string like VamsasClient v.1.1.1 (GPL) and whatever */ public String getAbout(); - + /** - * convenience method to get the SessionUrn as a string (for passing directly to a text box...). + * convenience method to get the SessionUrn as a string (for passing directly + * to a text box...). + * * @return current SessionUrn */ - public String getSessionUrn(); - /** - * Returns a valid URN for other applications to connect to - * the vamsas session. - * @return session handle for this session. - */ - public SessionHandle getSessionHandle(); - /** - * Included for applications with several ClientHandle - * identities. - * @return ClientHandle used to interact with - * other Vamsas applications. - */ - public ClientHandle getClientHandle(); - /** - * - * @return UserHandle used when interacting - * with other Vamsas applications. - */ - public UserHandle getUserHandle(); - /** - * Method called by client application on exit. - * Vorba will inform other clients if they exist. - * If this is the last application in the session - * then the session will be closed. - * Note: The application should be ready to handle - * 'RequestToCloseDocument' events from the Vorba - * agent in the latter case and so prompt the user - * to save the session locally. - * LATER: pick a better name ? - */ - public void finalizeClient(); - /** - * register handler for updates for the current session - */ - public void addDocumentUpdateHandler(PropertyChangeListener evt); - /** - * get vamsas document with - * user and app specific data - * IClientDocuments are not thread-safe. - * TODO: New exception for failed document lock. - * @throws IOException if lock is not obtainable for the document in the session - */ - public IClientDocument getClientDocument() throws IOException; - /** - * Queue new Vorba objects for storage and propagation - * to other clients (via Event.DOCUMENT_UPDATE based - * notification of document change) - * New objects without provenance information will be - * given a default entry using the IClient's application, - * user (and session) handles - * Validity of IClientDocument object instances after this call is implementation dependent - * TODO: consider refactoring to remove the redundant IClientDocument parameter for this method - */ - public void updateDocument(IClientDocument newdoc); - /** - * Any application may call storeDocument to - * save a local copy of the current vamsas document - * including all application specific entries. - * - * @param location to write zip file - */ - public void storeDocument(java.io.File location); - /** - * Any application may call importDocument to merge a stored - * vamsasDocument into the current session. - * Note: use a IClientFactory's implementation to make sessions out of vamsas documents - * TODO: this is not currently implemented by SimpleClient - and may be dropped from the first version of the interface. - * LATER: VAMSAS: The IClient implementation will handle all ID 'relocations' - * @param location - */ - public void importDocument(java.io.File location); - /** - * Add a listener to a particular event chain. - * See uk.ac.vamsas.client.Events for allowed - * values for EventChain. - * The EventChain value is passed as the - * propertyName in the java.bean.PropertyChangeEvent - * LATER: extend class to form own vamsas Event/Listener model. - * @param EventChain Name of event. Blank/null registers handler for all events. - * @param evt - event handler function. - */ - public void addVorbaEventHandler(String EventChain, PropertyChangeListener evt); - /** - * Sets the update handler that will be called when any updates occur to objects of type rootObject. - * @param rootObject - * @param handler - */ - public void setUpdateHandler(IObjectUpdate handler); - public IObjectUpdate getUpdateHandler(Class rootObject); - public void removeUpdateHandler(Class rootObject); - public IObjectUpdate[] getUpdateHandlers(); - /** - * client application calls this to force the - * Vorba client to check for updates immediately. - * - */ - public void pollUpdate(); - - /** - * Client application calls this after any pre-session initialization - * (registering of Handlers, etc) - * Exceptions are raised for any failures. Any stateful calls to the session prior to - * this will result in an implicit call to joinSession - if that results in an exception - * then the VamsasClient should raise an Error. - * LATER: create VAMSAS exception hierarchy (in a language agnostic manner) - */ - public void joinSession() throws Exception; - /** - * get the Vamsas Pick Manager for registering pick handlers and sending messages for the current session. - * @return an object implementing IPickManager (which maybe the same as the IClient implementer) - */ - public uk.ac.vamsas.client.picking.IPickManager getPickManager(); - + public String getSessionUrn(); + + /** + * Returns a valid URN for other applications to connect to the vamsas + * session. + * + * @return session handle for this session. + */ + public SessionHandle getSessionHandle(); + + /** + * Included for applications with several ClientHandle identities. + * + * @return ClientHandle used to interact with other Vamsas applications. + */ + public ClientHandle getClientHandle(); + + /** + * + * @return UserHandle used when interacting with other Vamsas applications. + */ + public UserHandle getUserHandle(); + + /** + * Method called by client application on exit. Vorba will inform other + * clients if they exist. If this is the last application in the session then + * the session will be closed. Note: The application should be ready to handle + * 'RequestToCloseDocument' events from the Vorba agent in the latter case and + * so prompt the user to save the session locally. LATER: pick a better name ? + */ + public void finalizeClient(); + + /** + * register handler for updates for the current session + */ + public void addDocumentUpdateHandler(PropertyChangeListener evt); + + /** + * get vamsas document with user and app specific data IClientDocuments are + * not thread-safe. TODO: New exception for failed document lock. + * + * @throws IOException + * if lock is not obtainable for the document in the session + */ + public IClientDocument getClientDocument() throws IOException; + + /** + * Queue new Vorba objects for storage and propagation to other clients (via + * Event.DOCUMENT_UPDATE based notification of document change) New objects + * without provenance information will be given a default entry using the + * IClient's application, user (and session) handles Validity of + * IClientDocument object instances after this call is implementation + * dependent TODO: consider refactoring to remove the redundant + * IClientDocument parameter for this method + */ + public void updateDocument(IClientDocument newdoc); + + /** + * Any application may call storeDocument to save a local copy of the current + * vamsas document including all application specific entries. + * + * @param location + * to write zip file + */ + public void storeDocument(java.io.File location); + + /** + * Any application may call importDocument to merge a stored vamsasDocument + * into the current session. Note: use a IClientFactory's implementation to + * make sessions out of vamsas documents TODO: this is not currently + * implemented by SimpleClient - and may be dropped from the first version of + * the interface. LATER: VAMSAS: The IClient implementation will handle all ID + * 'relocations' + * + * @param location + */ + public void importDocument(java.io.File location); + + /** + * Add a listener to a particular event chain. See uk.ac.vamsas.client.Events + * for allowed values for EventChain. The EventChain value is passed as the + * propertyName in the java.bean.PropertyChangeEvent LATER: extend class to + * form own vamsas Event/Listener model. + * + * @param EventChain + * Name of event. Blank/null registers handler for all events. + * @param evt + * - event handler function. + */ + public void addVorbaEventHandler(String EventChain, PropertyChangeListener evt); + + /** + * Sets the update handler that will be called when any updates occur to + * objects of type rootObject. + * + * @param rootObject + * @param handler + */ + public void setUpdateHandler(IObjectUpdate handler); + + public IObjectUpdate getUpdateHandler(Class rootObject); + + public void removeUpdateHandler(Class rootObject); + + public IObjectUpdate[] getUpdateHandlers(); + + /** + * client application calls this to force the Vorba client to check for + * updates immediately. + * + */ + public void pollUpdate(); + + /** + * Client application calls this after any pre-session initialization + * (registering of Handlers, etc) Exceptions are raised for any failures. Any + * stateful calls to the session prior to this will result in an implicit call + * to joinSession - if that results in an exception then the VamsasClient + * should raise an Error. LATER: create VAMSAS exception hierarchy (in a + * language agnostic manner) + */ + public void joinSession() throws Exception; + + /** + * get the Vamsas Pick Manager for registering pick handlers and sending + * messages for the current session. + * + * @return an object implementing IPickManager (which maybe the same as the + * IClient implementer) + */ + public uk.ac.vamsas.client.picking.IPickManager getPickManager(); + } diff --git a/src/uk/ac/vamsas/client/IClientAppdata.java b/src/uk/ac/vamsas/client/IClientAppdata.java index 4df6abb..2099995 100644 --- a/src/uk/ac/vamsas/client/IClientAppdata.java +++ b/src/uk/ac/vamsas/client/IClientAppdata.java @@ -1,60 +1,91 @@ -/** - * - */ -package uk.ac.vamsas.client; - - - -/** - * Object for accessing Client and User specific data - * in an IClientDocument instance. - * - */ -public interface IClientAppdata { - /** - * @return true if Client's non-user specific application data is non-zero length. - */ - boolean hasClientAppdata(); - /** - * @return true if User's Client Application data is non-zero length - */ - boolean hasUserAppdata(); - /** - * - * @return byte array containing the Client's non-user specific application data - */ - byte[] getClientAppdata(); - /** - * - * @return byte array containing the Client's user specific application data - */ - byte[] getUserAppdata(); - /** - * set the non-User-specific application data - * @param data - the new non-user-specific data - */ - void setClientAppdata(byte[] data); - /** - * set the User-specific application data - * @param data - the new user-specific data - */ - void setUserAppdata(byte[] data); - /** - * @return non-user specific data output stream - */ - AppDataOutputStream getClientOutputStream(); - /** - * @return non-user specific data input stream - */ - AppDataInputStream getClientInputStream(); - /** - * - * @return user specific data output stream - */ - AppDataOutputStream getUserOutputStream(); - /** - * - * @return user specific data input stream - */ - AppDataInputStream getUserInputStream(); -} +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ +package uk.ac.vamsas.client; + +/** + * Object for accessing Client and User specific data in an IClientDocument + * instance. + * + */ +public interface IClientAppdata { + /** + * @return true if Client's non-user specific application data is non-zero + * length. + */ + boolean hasClientAppdata(); + + /** + * @return true if User's Client Application data is non-zero length + */ + boolean hasUserAppdata(); + + /** + * + * @return byte array containing the Client's non-user specific application + * data + */ + byte[] getClientAppdata(); + + /** + * + * @return byte array containing the Client's user specific application data + */ + byte[] getUserAppdata(); + + /** + * set the non-User-specific application data + * + * @param data + * - the new non-user-specific data + */ + void setClientAppdata(byte[] data); + + /** + * set the User-specific application data + * + * @param data + * - the new user-specific data + */ + void setUserAppdata(byte[] data); + + /** + * @return non-user specific data output stream + */ + AppDataOutputStream getClientOutputStream(); + + /** + * @return non-user specific data input stream + */ + AppDataInputStream getClientInputStream(); + + /** + * + * @return user specific data output stream + */ + AppDataOutputStream getUserOutputStream(); + + /** + * + * @return user specific data input stream + */ + AppDataInputStream getUserInputStream(); +} diff --git a/src/uk/ac/vamsas/client/IClientDocument.java b/src/uk/ac/vamsas/client/IClientDocument.java index 5244849..b2d6763 100644 --- a/src/uk/ac/vamsas/client/IClientDocument.java +++ b/src/uk/ac/vamsas/client/IClientDocument.java @@ -1,99 +1,125 @@ /* - * Created on 13-Sep-2005 - * - * TODO To change the template for this generated file go to - * Window - Preferences - Java - Code Style - Code Templates + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ package uk.ac.vamsas.client; import uk.ac.vamsas.objects.core.VAMSAS; - /** - * Defines the API for the Vamsas XML Document - * as accessed by a Vamsas SimpleClient Application. - * An instance of this interface is valid for a - * particular set of user, session and application - * handles. + * Defines the API for the Vamsas XML Document as accessed by a Vamsas + * SimpleClient Application. An instance of this interface is valid for a + * particular set of user, session and application handles. + * + * It initially represents a snapshot of the XML document at a particular time - + * queriable by reference or by retrieval of root objects. It provides methods + * to make new Vobject references, These are guaranteed to be unique amongst + * existing objects in the document, all other references created by this + * Vobject's instance and all other references constructed by any other vamsas + * agents in the session. TODO: LATER: finegrained access control for + * public/private user access Finegrained access control: Since a clientDocument + * is created for a particular UserHandle, there is scope for fine grain data + * access control based on user identity. A user may also want to make private + * notes, not available to other people using the same application in the same + * session. TODO: LATER: implement a more sophisticated query interface for + * quickly identifying new data in a vamsas document and manipulating existing + * objects * - * It initially represents a snapshot of the - * XML document at a particular time - queriable by - * reference or by retrieval of root objects. - * It provides methods to make new Vobject references, - * These are guaranteed to be unique amongst existing - * objects in the document, all other references created - * by this Vobject's instance and all other references - * constructed by any other vamsas agents in the session. - * TODO: LATER: finegrained access control for public/private user access - * Finegrained access control: Since a clientDocument is created for a particular - * UserHandle, there is scope for fine grain data access - * control based on user identity. - * A user may also want to make private notes, not - * available to other people using the same application - * in the same session. - * TODO: LATER: implement a more sophisticated query interface for quickly identifying new data in a vamsas document and manipulating existing objects * @author jimp */ public interface IClientDocument { - + /** * Get a single Vobject. + * * @param id * @return Vobject referred to by id or null if it doesn't exist. */ Vobject getObject(VorbaId id); + /** * Get a list of objects. + * * @param ids * @return array of objects using a vector of VorbaId ids. */ Vobject[] getObjects(VorbaId[] ids); + /** - * Returns all root objects in document. All objects inherit - * from uk.ac.vamsas.client.Vobject and have valid VorbaIds and provenance entries. + * Returns all root objects in document. All objects inherit from + * uk.ac.vamsas.client.Vobject and have valid VorbaIds and provenance entries. + * * @return array of root Vamsas element objects. */ VAMSAS[] getVamsasRoots(); + /** - * set the VAMSAS roots in the document - * TODO: decide if objects are verified for provenance and VorbaIds by this call or when document is stored - * TODO: decide if this call should throw InvalidVamsasObject exceptions. - * TODO: decide how this call deals with applications that 'forget' to include all VAMSAS roots (this is where reference counting/garbage collection happens) + * set the VAMSAS roots in the document TODO: decide if objects are verified + * for provenance and VorbaIds by this call or when document is stored TODO: + * decide if this call should throw InvalidVamsasObject exceptions. TODO: + * decide how this call deals with applications that 'forget' to include all + * VAMSAS roots (this is where reference counting/garbage collection happens) + * * @param roots */ void setVamsasRoots(VAMSAS[] roots); + /** - * Adds a new VAMSAS root entry - * TODO: decide on same InvalidVamsasObject exceptions. - * TODO: decide if a 'removeVamsasRoot' method is really needed. + * Adds a new VAMSAS root entry TODO: decide on same InvalidVamsasObject + * exceptions. TODO: decide if a 'removeVamsasRoot' method is really needed. + * * @param newroot */ void addVamsasRoot(VAMSAS newroot); + /** - * Returns an Vobject with a valid VorbaId, and provenance element. - * The VorbaId is so the application may refer to it in - * its own dataspace. + * Returns an Vobject with a valid VorbaId, and provenance element. The + * VorbaId is so the application may refer to it in its own dataspace. * - * Note: An Vobject with valid VorbaId will not be reregistered. - * Advice: Calling this method for a high-level Vobject - * (such as uk.ac.vamsas.objects.core.VAMSAS) will - * register all its component objects too. + * Note: An Vobject with valid VorbaId will not be reregistered. Advice: + * Calling this method for a high-level Vobject (such as + * uk.ac.vamsas.objects.core.VAMSAS) will register all its component objects + * too. * - * @param unregistered unregistered vamsas Vobject + * @param unregistered + * unregistered vamsas Vobject * @return VorbaId registered for vamsas Vobject */ VorbaId registerObject(Vobject unregistered); + /** - * Returns an array of objects, each with a valid VorbaId - * (and completed provenance entry). - * Note: An Vobject with valid VorbaId will not be reregistered. - * @param unregistered array of unregistered objects. + * Returns an array of objects, each with a valid VorbaId (and completed + * provenance entry). Note: An Vobject with valid VorbaId will not be + * reregistered. + * + * @param unregistered + * array of unregistered objects. * @return array of VorbaIds for the registered objects */ VorbaId[] registerObjects(Vobject[] unregistered); + /** - * Get instance of Client and User specific vamsas document data access interface. + * Get instance of Client and User specific vamsas document data access + * interface. + * * @return Interface to Client and user specific application data */ IClientAppdata getClientAppdata(); -} \ No newline at end of file +} diff --git a/src/uk/ac/vamsas/client/IClientFactory.java b/src/uk/ac/vamsas/client/IClientFactory.java index ac9ff88..5f16a6e 100644 --- a/src/uk/ac/vamsas/client/IClientFactory.java +++ b/src/uk/ac/vamsas/client/IClientFactory.java @@ -1,8 +1,23 @@ /* - * Created on 13-Sep-2005 - * - * TODO To change the template for this generated file go to - * Window - Preferences - Java - Code Style - Code Templates + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ package uk.ac.vamsas.client; @@ -10,76 +25,108 @@ import java.io.File; /** * Defines methods for instantiating Vorba client application agents + * * @author jimp - * - * (it's VORBA, not CORBA!) + * + * (it's VORBA, not CORBA!) */ public interface IClientFactory { - /** - * Create a new Vorba Session - * @param applicationHandle is the application's VAMSAS handle string - * @throws NoDefaultSessionException if more than one session exists that the client may connect to - */ - IClient getIClient(ClientHandle applicationHandle) throws NoDefaultSessionException; - /** - * returns new Vorba for a given session. - * @param applicationHandle - * @param sessionUrn session to connect to (or null to create a new session) - * @return - */ - IClient getIClient(ClientHandle applicationHandle, String sessionUrn); - /** - * returns new vorba for a given session acting as a particular identity - * @param applicationHandle - * @param userId - * @param sessionUrn session to connect to (or null to create a new session) - * @return - */ - IClient getIClient(ClientHandle applicationHandle, UserHandle userId, String sessionUrn); - /** - * New session for application and specific user - * @param applicationHandle - * @param userId - * @return - * @throws NoDefaultSessionException if more than one session exists that the client may connect to - */ - IClient getIClient(ClientHandle applicationHandle, UserHandle userId) throws NoDefaultSessionException; - /** - * Create a new sesssion for the application with the current user - * @param applicationHandle - * @return - */ - IClient getNewSessionIClient(ClientHandle applicationHandle); - /** - * Create a new session for the application using a particular user identity - * @param applicationHandle - * @param userId - * @return - */ - IClient getNewSessionIClient(ClientHandle applicationHandle, UserHandle userId); - /** - * Create a new session and import an existing vamsas document into it. - * @param applicationHandle - * @param vamsasDocument - * @return - */ - IClient openAsNewSessionIClient(ClientHandle applicationHandle, File vamsasDocument) throws InvalidSessionDocumentException; - /** - * Create a new session as a particular user and import an existing vamsas document into it. - * @param applicationHandle - * @param userId - * @param vamsasDocument - * @return - */ - IClient openAsNewSessionIClient(ClientHandle applicationHandle, UserHandle userId, File vamsasDocument) throws InvalidSessionDocumentException; - /** - * enumerate the active sessions this IClientFactory instance knows about. - * Can be used by caller to pick a session on catching a NoDefaultSessionException. - * LATER: Define interface for discovering more information about a session (so it can be presented to a user in a meaningful way) - * @return possibly empty array of sessionUrn strings - */ - public String[] getCurrentSessions(); + /** + * Create a new Vorba Session + * + * @param applicationHandle + * is the application's VAMSAS handle string + * @throws NoDefaultSessionException + * if more than one session exists that the client may connect to + */ + IClient getIClient(ClientHandle applicationHandle) + throws NoDefaultSessionException; + + /** + * returns new Vorba for a given session. + * + * @param applicationHandle + * @param sessionUrn + * session to connect to (or null to create a new session) + * @return + */ + IClient getIClient(ClientHandle applicationHandle, String sessionUrn); + + /** + * returns new vorba for a given session acting as a particular identity + * + * @param applicationHandle + * @param userId + * @param sessionUrn + * session to connect to (or null to create a new session) + * @return + */ + IClient getIClient(ClientHandle applicationHandle, UserHandle userId, + String sessionUrn); + + /** + * New session for application and specific user + * + * @param applicationHandle + * @param userId + * @return + * @throws NoDefaultSessionException + * if more than one session exists that the client may connect to + */ + IClient getIClient(ClientHandle applicationHandle, UserHandle userId) + throws NoDefaultSessionException; + + /** + * Create a new sesssion for the application with the current user + * + * @param applicationHandle + * @return + */ + IClient getNewSessionIClient(ClientHandle applicationHandle); + + /** + * Create a new session for the application using a particular user identity + * + * @param applicationHandle + * @param userId + * @return + */ + IClient getNewSessionIClient(ClientHandle applicationHandle, UserHandle userId); + + /** + * Create a new session and import an existing vamsas document into it. + * + * @param applicationHandle + * @param vamsasDocument + * @return + */ + IClient openAsNewSessionIClient(ClientHandle applicationHandle, + File vamsasDocument) throws InvalidSessionDocumentException; + + /** + * Create a new session as a particular user and import an existing vamsas + * document into it. + * + * @param applicationHandle + * @param userId + * @param vamsasDocument + * @return + */ + IClient openAsNewSessionIClient(ClientHandle applicationHandle, + UserHandle userId, File vamsasDocument) + throws InvalidSessionDocumentException; + + /** + * enumerate the active sessions this IClientFactory instance knows about. Can + * be used by caller to pick a session on catching a + * NoDefaultSessionException. LATER: Define interface for discovering more + * information about a session (so it can be presented to a user in a + * meaningful way) + * + * @return possibly empty array of sessionUrn strings + */ + public String[] getCurrentSessions(); } diff --git a/src/uk/ac/vamsas/client/IObjectUpdate.java b/src/uk/ac/vamsas/client/IObjectUpdate.java index 941321b..3fc32a6 100644 --- a/src/uk/ac/vamsas/client/IObjectUpdate.java +++ b/src/uk/ac/vamsas/client/IObjectUpdate.java @@ -1,26 +1,57 @@ +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ package uk.ac.vamsas.client; /** * Methods implemented by a Vamsas Application's Object Update handler - * @author vamsas - * Introduced November 2006 Vamsas Meeting - * TODO: verify this is sufficient for the per-object update event mechanism + * + * @author vamsas Introduced November 2006 Vamsas Meeting TODO: verify this is + * sufficient for the per-object update event mechanism */ public interface IObjectUpdate { /** - * Called by the library to find out which vamsas document object this update handler is interested in + * Called by the library to find out which vamsas document object this update + * handler is interested in + * * @return class that extends org.vamsas.Vobject */ Class getRootVobject(); + /** - * Called to test if this handler is to be called for updates to any Vobjects below the Root Vobject in the vamsas document. - * @return false means IObjectUpdate.update(updated, cdoc) will only be called with instances of type getRootVobject(). + * Called to test if this handler is to be called for updates to any Vobjects + * below the Root Vobject in the vamsas document. + * + * @return false means IObjectUpdate.update(updated, cdoc) will only be called + * with instances of type getRootVobject(). */ boolean handlesSubtreeUpdates(); + /** - * Method called by Vamsas Client Library for all updated objects that the handler is registered for. + * Method called by Vamsas Client Library for all updated objects that the + * handler is registered for. + * * @param updated * @param cdoc */ - void update(uk.ac.vamsas.client.Vobject updated, uk.ac.vamsas.client.IClientDocument cdoc); + void update(uk.ac.vamsas.client.Vobject updated, + uk.ac.vamsas.client.IClientDocument cdoc); } diff --git a/src/uk/ac/vamsas/client/IVorbaIdFactory.java b/src/uk/ac/vamsas/client/IVorbaIdFactory.java index 5a478c9..2d31366 100644 --- a/src/uk/ac/vamsas/client/IVorbaIdFactory.java +++ b/src/uk/ac/vamsas/client/IVorbaIdFactory.java @@ -1,22 +1,38 @@ /* - * Created on 14-Sep-2005 - * - * TODO To change the template for this generated file go to - * Window - Preferences - Java - Code Style - Code Templates + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ package uk.ac.vamsas.client; /** - * @author jimp - * middleware interface for generating new VorbaId objects - * for a particular vamsas client based on the current - * session, user and client handle. Generally implemented - * by instances of the vamsas library api only. + * @author jimp middleware interface for generating new VorbaId objects for a + * particular vamsas client based on the current session, user and + * client handle. Generally implemented by instances of the vamsas + * library api only. */ public interface IVorbaIdFactory { /** * construct a new id appropriate for this client in the vamsas session. - * @param vobject TODO + * + * @param vobject + * TODO * * @return valid VorbaId for session, or null if VorbaIdFactory not configured * correctly. @@ -28,10 +44,12 @@ public interface IVorbaIdFactory { public abstract ClientHandle getClientHandle(); public abstract UserHandle getUserHandle(); + /** - * called when an object is touched by the vamsas library prior to writing - * to record last hash for the object's VorbaId + * called when an object is touched by the vamsas library prior to writing to + * record last hash for the object's VorbaId + * * @param vobject */ public abstract void updateHashValue(Vobject vobject); -} \ No newline at end of file +} diff --git a/src/uk/ac/vamsas/client/Iapp.java b/src/uk/ac/vamsas/client/Iapp.java index 43ea8ec..57f0504 100644 --- a/src/uk/ac/vamsas/client/Iapp.java +++ b/src/uk/ac/vamsas/client/Iapp.java @@ -1,12 +1,31 @@ -/** - * uk.ac.vamsas.client.Iapp +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ package uk.ac.vamsas.client; + public interface Iapp { - /** - * Define core callback functionality that a fully - * fledged vamsas application Vobject must implement - * TODO: define some Application Callbacks and create use cases for them - */ + /** + * Define core callback functionality that a fully fledged vamsas application + * Vobject must implement TODO: define some Application Callbacks and create + * use cases for them + */ }; diff --git a/src/uk/ac/vamsas/client/InvalidSessionDocumentException.java b/src/uk/ac/vamsas/client/InvalidSessionDocumentException.java index e988d58..de0c56c 100644 --- a/src/uk/ac/vamsas/client/InvalidSessionDocumentException.java +++ b/src/uk/ac/vamsas/client/InvalidSessionDocumentException.java @@ -1,45 +1,63 @@ -/** +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ package uk.ac.vamsas.client; /** * @author JimP - * + * */ -public class InvalidSessionDocumentException extends Exception -{ +public class InvalidSessionDocumentException extends Exception { /** * basic error for this exception */ public static final String INVALID_DOC = "Invalid Shared Document."; + /** * */ - public InvalidSessionDocumentException() { - super(INVALID_DOC); + public InvalidSessionDocumentException() { + super(INVALID_DOC); } - /** - * @param message - */ - public InvalidSessionDocumentException(String message) { - super(INVALID_DOC+":"+message); - } + /** + * @param message + */ + public InvalidSessionDocumentException(String message) { + super(INVALID_DOC + ":" + message); + } - /** - * @param cause - */ - public InvalidSessionDocumentException(Throwable cause) { - super(INVALID_DOC, cause); - } + /** + * @param cause + */ + public InvalidSessionDocumentException(Throwable cause) { + super(INVALID_DOC, cause); + } - /** - * @param message - * @param cause - */ - public InvalidSessionDocumentException(String message, Throwable cause) { - super(INVALID_DOC+":"+message, cause); - } + /** + * @param message + * @param cause + */ + public InvalidSessionDocumentException(String message, Throwable cause) { + super(INVALID_DOC + ":" + message, cause); + } } diff --git a/src/uk/ac/vamsas/client/InvalidSessionUrnException.java b/src/uk/ac/vamsas/client/InvalidSessionUrnException.java index baabebf..bed68a3 100644 --- a/src/uk/ac/vamsas/client/InvalidSessionUrnException.java +++ b/src/uk/ac/vamsas/client/InvalidSessionUrnException.java @@ -1,38 +1,59 @@ -package uk.ac.vamsas.client; - -public class InvalidSessionUrnException extends Exception { - - /** - * - */ - public InvalidSessionUrnException() { - super("Invalid Vamsas Session URN."); - // TODO Auto-generated constructor stub - } - - /** - * @param message - * @param cause - */ - public InvalidSessionUrnException(String message, Throwable cause) { - super(message, cause); - // TODO Auto-generated constructor stub - } - - /** - * @param message - */ - public InvalidSessionUrnException(String message) { - super("Invalid Vamsas Session URN: "+message); - // TODO Auto-generated constructor stub - } - - /** - * @param cause - */ - public InvalidSessionUrnException(Throwable cause) { - super(cause); - // TODO Auto-generated constructor stub - } - -} +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ +package uk.ac.vamsas.client; + +public class InvalidSessionUrnException extends Exception { + + /** + * + */ + public InvalidSessionUrnException() { + super("Invalid Vamsas Session URN."); + // TODO Auto-generated constructor stub + } + + /** + * @param message + * @param cause + */ + public InvalidSessionUrnException(String message, Throwable cause) { + super(message, cause); + // TODO Auto-generated constructor stub + } + + /** + * @param message + */ + public InvalidSessionUrnException(String message) { + super("Invalid Vamsas Session URN: " + message); + // TODO Auto-generated constructor stub + } + + /** + * @param cause + */ + public InvalidSessionUrnException(Throwable cause) { + super(cause); + // TODO Auto-generated constructor stub + } + +} diff --git a/src/uk/ac/vamsas/client/NoDefaultSessionException.java b/src/uk/ac/vamsas/client/NoDefaultSessionException.java index f9aab17..61fdd59 100644 --- a/src/uk/ac/vamsas/client/NoDefaultSessionException.java +++ b/src/uk/ac/vamsas/client/NoDefaultSessionException.java @@ -1,46 +1,63 @@ -/** - * - */ -package uk.ac.vamsas.client; - -/** - * @author jimp - * Raised if an IClient instance is requested without - * specifying a particular vamsas session handle - * when more than one candidate session exists. - */ -public class NoDefaultSessionException extends Exception { - - /** - * - */ - public NoDefaultSessionException() { - super("No Default Session Defined"); - } - - /** - * @param message - */ - public NoDefaultSessionException(String message) { - super(message); - // TODO Auto-generated constructor stub - } - - /** - * @param cause - */ - public NoDefaultSessionException(Throwable cause) { - super(cause); - // TODO Auto-generated constructor stub - } - - /** - * @param message - * @param cause - */ - public NoDefaultSessionException(String message, Throwable cause) { - super(message, cause); - // TODO Auto-generated constructor stub - } - -} +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ +package uk.ac.vamsas.client; + +/** + * @author jimp Raised if an IClient instance is requested without specifying a + * particular vamsas session handle when more than one candidate session + * exists. + */ +public class NoDefaultSessionException extends Exception { + + /** + * + */ + public NoDefaultSessionException() { + super("No Default Session Defined"); + } + + /** + * @param message + */ + public NoDefaultSessionException(String message) { + super(message); + // TODO Auto-generated constructor stub + } + + /** + * @param cause + */ + public NoDefaultSessionException(Throwable cause) { + super(cause); + // TODO Auto-generated constructor stub + } + + /** + * @param message + * @param cause + */ + public NoDefaultSessionException(String message, Throwable cause) { + super(message, cause); + // TODO Auto-generated constructor stub + } + +} diff --git a/src/uk/ac/vamsas/client/SessionHandle.java b/src/uk/ac/vamsas/client/SessionHandle.java index 3bd78c6..72c6d98 100644 --- a/src/uk/ac/vamsas/client/SessionHandle.java +++ b/src/uk/ac/vamsas/client/SessionHandle.java @@ -1,6 +1,23 @@ /* - * Created on 12-Sep-2005 - * + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ package uk.ac.vamsas.client; @@ -8,11 +25,12 @@ import java.io.Serializable; /** * Uniquely locates a particular VAMSAS session. + * * @author jimp - * + * */ public class SessionHandle implements Serializable { - + /** * @param sessionUrn */ @@ -20,37 +38,39 @@ public class SessionHandle implements Serializable { super(); this.sessionUrn = _sessionUrn; } + /** * @return Returns the sessionUrn. */ public String getSessionUrn() { return this.sessionUrn; } + /** - * @param sessionUrn The sessionUrn to set. + * @param sessionUrn + * The sessionUrn to set. */ public void setSessionUrn(String _sessionUrn) { - this.sessionUrn = _sessionUrn; + this.sessionUrn = _sessionUrn; } + /** * The path to the vamsas session file. */ String sessionUrn = null; - + /** * @see java.lang.Object#equals(java.lang.Object) */ public boolean equals(Object obj) { if (obj instanceof SessionHandle) - return this.equals((SessionHandle) obj); + return this.equals((SessionHandle) obj); return false; } - public boolean equals(SessionHandle that) { return (this.sessionUrn.equals(that.getSessionUrn())); } - - + } diff --git a/src/uk/ac/vamsas/client/SessionUrn.java b/src/uk/ac/vamsas/client/SessionUrn.java index 66b73c3..7789d2d 100644 --- a/src/uk/ac/vamsas/client/SessionUrn.java +++ b/src/uk/ac/vamsas/client/SessionUrn.java @@ -1,78 +1,99 @@ -/** - * - */ -package uk.ac.vamsas.client; - -import java.net.URI; -import java.util.Hashtable; - -/** - * @author jimp - * base class for vamsas session/document types - * uses java.net.URI internally for construction of URN - */ -public abstract class SessionUrn { - protected URI urn; - /** - * The types of URI protocols we understand - */ - protected static final Hashtable TYPES=new Hashtable(); - - - protected SessionUrn() - { - // - } - /** - * construct urn for a locally stored session file - * @param type - * @param url - */ - protected SessionUrn(String type, java.net.URL url) { - if (!TYPES.containsKey(type.toLowerCase())) - throw new Error("Unknown "+this.getClass().getName()+" type '"+type+"' for URL '"+url+"'"); - try { - - this.setURN(type+"://"+url.getPath()); - // urn = URI.create(type+"://"+url.getPath()); - } catch (Exception e) { - // TODO: something better than throwing an error should be done here. - e.printStackTrace(System.err); - throw new Error(e); - } - } - - protected SessionUrn(String type, URI uri) { - if (!TYPES.containsKey(type.toLowerCase())) - throw new Error("Unknown "+this.getClass().getName()+" type '"+type+"' for URI '"+uri+"'"); - try { - // this.setURN(type+"://"+uri.getPath()); - //bad hack but should do the trick - this.setURN(type+"://"+uri.getRawPath()); - } catch (Exception e) { - // TODO: something better than throwing an error should be done here. - e.printStackTrace(System.err); - throw new Error(e); - } - } - - public String getSessionUrn() { - return this.urn.toString(); - } - - /** - * Set the urn attribute - * create a URI from the provided String - * - * @param urnString urn to convert to a URN - */ - protected void setURN(String urnString) throws InvalidSessionUrnException// NullPointerException, IllegalArgumentException - { - try { - this.urn = URI.create(urnString); - } catch (Exception e) { - throw new InvalidSessionUrnException(e); - } - } - -} +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ +package uk.ac.vamsas.client; + +import java.net.URI; +import java.util.Hashtable; + +/** + * @author jimp base class for vamsas session/document types uses java.net.URI + * internally for construction of URN + */ +public abstract class SessionUrn { + protected URI urn; + + /** + * The types of URI protocols we understand + */ + protected static final Hashtable TYPES = new Hashtable(); + + protected SessionUrn() { + // + } + + /** + * construct urn for a locally stored session file + * + * @param type + * @param url + */ + protected SessionUrn(String type, java.net.URL url) { + if (!TYPES.containsKey(type.toLowerCase())) + throw new Error("Unknown " + this.getClass().getName() + " type '" + type + + "' for URL '" + url + "'"); + try { + + this.setURN(type + "://" + url.getPath()); + // urn = URI.create(type+"://"+url.getPath()); + } catch (Exception e) { + // TODO: something better than throwing an error should be done here. + e.printStackTrace(System.err); + throw new Error(e); + } + } + + protected SessionUrn(String type, URI uri) { + if (!TYPES.containsKey(type.toLowerCase())) + throw new Error("Unknown " + this.getClass().getName() + " type '" + type + + "' for URI '" + uri + "'"); + try { + // this.setURN(type+"://"+uri.getPath()); + // bad hack but should do the trick + this.setURN(type + "://" + uri.getRawPath()); + } catch (Exception e) { + // TODO: something better than throwing an error should be done here. + e.printStackTrace(System.err); + throw new Error(e); + } + } + + public String getSessionUrn() { + return this.urn.toString(); + } + + /** + * Set the urn attribute create a URI from the provided String + * + * @param urnString + * urn to convert to a URN + */ + protected void setURN(String urnString) throws InvalidSessionUrnException// NullPointerException, + // IllegalArgumentException + { + try { + this.urn = URI.create(urnString); + } catch (Exception e) { + throw new InvalidSessionUrnException(e); + } + } + +} diff --git a/src/uk/ac/vamsas/client/UserHandle.java b/src/uk/ac/vamsas/client/UserHandle.java index 688d5ac..5fe4280 100644 --- a/src/uk/ac/vamsas/client/UserHandle.java +++ b/src/uk/ac/vamsas/client/UserHandle.java @@ -1,15 +1,30 @@ /* - * Created on 12-Sep-2005 - * - * TODO To change the template for this generated file go to - * Window - Preferences - Java - Code Style - Code Templates + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ package uk.ac.vamsas.client; /** - * Unique user identifier for a vamsas session. - * Used to write user provenance information, and - * track view/access control in multiuser sessions. + * Unique user identifier for a vamsas session. Used to write user provenance + * information, and track view/access control in multiuser sessions. + * * @author jimp */ public class UserHandle { @@ -21,28 +36,36 @@ public class UserHandle { this.fullName = fullName; Organization = organization; } + String fullName; + String Organization; + /** * @return Returns the fullName. */ public String getFullName() { return fullName; } + /** - * @param fullName The fullName to set. + * @param fullName + * The fullName to set. */ public void setFullName(String fullname) { fullName = fullname; } + /** * @return Returns the organization. */ public String getOrganization() { return Organization; } + /** - * @param organization The organization to set. + * @param organization + * The organization to set. */ public void setOrganization(String organization) { Organization = organization; diff --git a/src/uk/ac/vamsas/client/Vobject.java b/src/uk/ac/vamsas/client/Vobject.java index 6603f1a..23cb8e0 100644 --- a/src/uk/ac/vamsas/client/Vobject.java +++ b/src/uk/ac/vamsas/client/Vobject.java @@ -1,5 +1,23 @@ -/** +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ package uk.ac.vamsas.client; @@ -25,33 +43,44 @@ import uk.ac.vamsas.test.simpleclient.VamsasArchive; */ public abstract class Vobject { static Log log = LogFactory.getLog(Vobject.class); - + /** - * true if Vobject was stored in a vamsas Document or has been retrieved from it + * true if Vobject was stored in a vamsas Document or has been retrieved from + * it */ protected boolean __stored_in_document = false; + /** - * true if Vobject was updated since the vamsas library last read a Vobj with the same VorbaId from a document. + * true if Vobject was updated since the vamsas library last read a Vobj with + * the same VorbaId from a document. */ protected boolean __updated_since_last_read = false; + /** - * true if Vobject appeared in the document after the last access by this vamsas library instance + * true if Vobject appeared in the document after the last access by this + * vamsas library instance */ protected boolean __added_since_last_read = false; + /** - * memory of the last doHash() value computed for the Vobject + * memory of the last doHash() value computed for the Vobject + * * @see doHash() */ - protected int __last_hash = 0; + protected int __last_hash = 0; + /** * set by testInstanceForIdField() if Vobject should have a VorbaId */ - protected boolean registerable = false; + protected boolean registerable = false; + protected boolean __visited = false; + /** * reference to containing object for this Vobject. */ - protected Vobject V_parent=null; + protected Vobject V_parent = null; + /** * unique id for all vamsas objects allows unambiguous referencing to any * Vobject in the vamsas document @@ -62,14 +91,16 @@ public abstract class Vobject { * the source of unique VorbaIds. */ protected IVorbaIdFactory __vorba = null; - - /* (non-Javadoc) + + /* + * (non-Javadoc) + * * @see java.lang.Object#finalize() */ protected void finalize() throws Throwable { - V_parent=null; - __vorba=null; - vorbaId=null; + V_parent = null; + __vorba = null; + vorbaId = null; super.finalize(); } @@ -80,67 +111,86 @@ public abstract class Vobject { super(); testInstanceForIdField(); } + /** - * Override Object.hashCode with base value for castor generated object hashcodes. + * Override Object.hashCode with base value for castor generated object + * hashcodes. */ public int hashCode() { return 17; } - java.lang.reflect.Field ___id_field=null; // set to ease pain of reflection + + java.lang.reflect.Field ___id_field = null; // set to ease pain of reflection + /** - * set the isRegisterable flag based on the presence of a 'private String _id' field in - * the reflected class instance. + * set the isRegisterable flag based on the presence of a 'private String _id' + * field in the reflected class instance. */ private void testInstanceForIdField() { - // TODO: decide if 'id' is an appropriate reserved attribute name for the VorbaId + // TODO: decide if 'id' is an appropriate reserved attribute name for the + // VorbaId // look for the id field in all castor classes (should be an NCName string) - - Class thisclass=this.getClass(); + + Class thisclass = this.getClass(); setRegisterable(false); while (!thisclass.equals(Vobject.class)) { try { java.lang.reflect.Field fd = thisclass.getDeclaredField("_id"); if (String.class.isAssignableFrom(fd.getType())) { - ___id_field=fd; + ___id_field = fd; this.setRegisterable(true); break; } } catch (SecurityException e) { - log.error("Unexpected Security Exception whilst finding id fields to set!",e); + log + .error( + "Unexpected Security Exception whilst finding id fields to set!", + e); } catch (NoSuchFieldException e) { - thisclass=thisclass.getSuperclass(); + thisclass = thisclass.getSuperclass(); } } } + // boolean __testedInstance=false; /** * update the Vobject instance's _id field, based on the contents of the * VorbaId. Only call this if you mean to do it! */ protected void setInstanceIdField() { - /*if (!registerable && !__testedInstance) { - testInstanceForIdField(); - __testedInstance=true; - }*/ + /* + * if (!registerable && !__testedInstance) { testInstanceForIdField(); + * __testedInstance=true; } + */ if (registerable) { if (__vorba != null) try { - Method fd = this.getClass().getMethod("setId", new Class[] { String.class }); - fd.invoke((Object) this, new Object[] {new String(this.getVorbaId().id)}); - log.debug(this.getClass().getName()+" called setInstanceIdField!"); - } catch (InvocationTargetException e) { - log.error("SourceGeneration of " - + this.getClass().toString() - + "\n has resulted in an inaccessible 'setId' method!\nCannot set ID from the vorbaId Vobject.", e); - } - catch (IllegalAccessException e) { - log.error("SourceGeneration of " - + this.getClass().toString() - + "\n has resulted in an inaccessible 'setId' method!\nCannot set ID from the vorbaId Vobject.", e); + Method fd = this.getClass().getMethod("setId", + new Class[] { String.class }); + fd.invoke((Object) this, new Object[] { new String( + this.getVorbaId().id) }); + log.debug(this.getClass().getName() + " called setInstanceIdField!"); + } catch (InvocationTargetException e) { + log + .error( + "SourceGeneration of " + + this.getClass().toString() + + "\n has resulted in an inaccessible 'setId' method!\nCannot set ID from the vorbaId Vobject.", + e); + } catch (IllegalAccessException e) { + log + .error( + "SourceGeneration of " + + this.getClass().toString() + + "\n has resulted in an inaccessible 'setId' method!\nCannot set ID from the vorbaId Vobject.", + e); } catch (SecurityException e) { - log.error("Security access violation for "+this.getClass().toString(),e); + log.error("Security access violation for " + + this.getClass().toString(), e); } catch (NoSuchMethodException e) { - log.warn(this.getClass().toString()+" was erroneously marked as a Vorba Vobject class (Implementation error?)"); + log + .warn(this.getClass().toString() + + " was erroneously marked as a Vorba Vobject class (Implementation error?)"); this.setRegisterable(false); } } else { @@ -148,35 +198,43 @@ public abstract class Vobject { + this.getClass().toString() + " (which cannot be given a vorbaId)"); } } - + protected String __getInstanceIdField() { - /*if (!registerable && !__testedInstance) { - testInstanceForIdField(); - __testedInstance=true; - }*/ + /* + * if (!registerable && !__testedInstance) { testInstanceForIdField(); + * __testedInstance=true; } + */ if (registerable) { if (__vorba != null) try { Method fd = this.getClass().getMethod("getId", (Class[]) null); Object idstring = fd.invoke((Object) this, (Object[]) null); - log.debug(this.getClass().getName()+" called getInstanceIdField!"); - if (idstring!=null && idstring instanceof String) { - if (((String) idstring).length()>0) + log.debug(this.getClass().getName() + " called getInstanceIdField!"); + if (idstring != null && idstring instanceof String) { + if (((String) idstring).length() > 0) return (String) idstring; } - } catch (InvocationTargetException e) { - log.error("SourceGeneration of " - + this.getClass().toString() - + "\n has resulted in an inaccessible 'getId' method!\nCannot set ID from the vorbaId Vobject.", e); - } - catch (IllegalAccessException e) { - log.error("SourceGeneration of " - + this.getClass().toString() - + "\n has resulted in an inaccessible 'getId' method!\nCannot set ID from the vorbaId Vobject.", e); + } catch (InvocationTargetException e) { + log + .error( + "SourceGeneration of " + + this.getClass().toString() + + "\n has resulted in an inaccessible 'getId' method!\nCannot set ID from the vorbaId Vobject.", + e); + } catch (IllegalAccessException e) { + log + .error( + "SourceGeneration of " + + this.getClass().toString() + + "\n has resulted in an inaccessible 'getId' method!\nCannot set ID from the vorbaId Vobject.", + e); } catch (SecurityException e) { - log.error("Security access violation for "+this.getClass().toString(),e); + log.error("Security access violation for " + + this.getClass().toString(), e); } catch (NoSuchMethodException e) { - log.warn(this.getClass().toString()+" was erroneously marked as a Vorba Vobject class (Implementation error?)"); + log + .warn(this.getClass().toString() + + " was erroneously marked as a Vorba Vobject class (Implementation error?)"); this.setRegisterable(false); } } else { @@ -185,8 +243,10 @@ public abstract class Vobject { } return null; } + /** * calls the castor-generated hashCode() method + * * @return */ protected int __callHash() { @@ -194,69 +254,83 @@ public abstract class Vobject { Method fd = this.getClass().getMethod("hashCode", (Class[]) null); Object hashvalue = fd.invoke((Object) this, (Object[]) null); if (log.isDebugEnabled()) - log.debug(this.getClass().getName()+" called hashCode()!"); - if (hashvalue!=null && hashvalue instanceof Integer) { + log.debug(this.getClass().getName() + " called hashCode()!"); + if (hashvalue != null && hashvalue instanceof Integer) { return ((Integer) hashvalue).intValue(); } - } catch (InvocationTargetException e) { - log.error("SourceGeneration of " - + this.getClass().toString() - + "\n has resulted in an inaccessible 'hashCode' method!\nHave you set org.exolab.castor.builder.equalsmethod=true in castorbuilder.properties ?.", e); - } - catch (IllegalAccessException e) { - log.error("SourceGeneration of " - + this.getClass().toString() - + "\n has resulted in an inaccessible 'hashCode' method!\nHave you set org.exolab.castor.builder.equalsmethod=true in castorbuilder.properties ?.", e); + } catch (InvocationTargetException e) { + log + .error( + "SourceGeneration of " + + this.getClass().toString() + + "\n has resulted in an inaccessible 'hashCode' method!\nHave you set org.exolab.castor.builder.equalsmethod=true in castorbuilder.properties ?.", + e); + } catch (IllegalAccessException e) { + log + .error( + "SourceGeneration of " + + this.getClass().toString() + + "\n has resulted in an inaccessible 'hashCode' method!\nHave you set org.exolab.castor.builder.equalsmethod=true in castorbuilder.properties ?.", + e); } catch (SecurityException e) { - log.error("Security access violation for "+this.getClass().toString(),e); + log.error("Security access violation for " + this.getClass().toString(), + e); } catch (NoSuchMethodException e) { - log.warn(this.getClass().toString()+" was erroneously extending from a Vorba Vobject class (Implementation error? no hashCode() method)" + - "\nHave you set org.exolab.castor.builder.equalsmethod=true in castorbuilder.properties ?.", e); + log + .warn( + this.getClass().toString() + + " was erroneously extending from a Vorba Vobject class (Implementation error? no hashCode() method)" + + "\nHave you set org.exolab.castor.builder.equalsmethod=true in castorbuilder.properties ?.", + e); } return 0; } + /** * calculate a hash for the Vobject with all housekeeping fields at standard - * values. (isRegisterable is an immutable attribute property) - * TODO: LATER: make this hash function compute a hash that truly reflects changes in Vobject attributes for benefit of update mechanism - * @return true if new hash different to last hash (or first time its been computed) + * values. (isRegisterable is an immutable attribute property) TODO: LATER: + * make this hash function compute a hash that truly reflects changes in + * Vobject attributes for benefit of update mechanism + * + * @return true if new hash different to last hash (or first time its been + * computed) */ synchronized protected boolean doHash() { boolean stored = __stored_in_document; - __stored_in_document=false; + __stored_in_document = false; boolean updated = __updated_since_last_read; - __updated_since_last_read=false; - boolean added_since=__added_since_last_read; - __added_since_last_read=false; + __updated_since_last_read = false; + boolean added_since = __added_since_last_read; + __added_since_last_read = false; long __old_hash = __last_hash; __last_hash = 0; // leave registerable - doesn't change boolean visited = __visited; - __visited=false; - Vobject _V_parent=V_parent; - V_parent=null; + __visited = false; + Vobject _V_parent = V_parent; + V_parent = null; VorbaId thisid = vorbaId; vorbaId = null; IVorbaIdFactory factory = __vorba; __vorba = null; java.lang.reflect.Field idfield = ___id_field; - ___id_field=null; + ___id_field = null; long l_hash = __l_hash; __l_hash = 0; // compute hash __last_hash = __callHash(); // reset houseskeeping variables - ___id_field=idfield; + ___id_field = idfield; vorbaId = thisid; __vorba = factory; __stored_in_document = stored; - __updated_since_last_read=updated; - V_parent=_V_parent; - __visited=visited; - __added_since_last_read=added_since; + __updated_since_last_read = updated; + V_parent = _V_parent; + __visited = visited; + __added_since_last_read = added_since; __l_hash = l_hash; // return true if first time hash was computed or if hash has changed - return (__old_hash==0) || (__old_hash != __last_hash); + return (__old_hash == 0) || (__old_hash != __last_hash); } /** @@ -269,7 +343,7 @@ public abstract class Vobject { * @return */ protected boolean merge(Vobject laterCopy) { - log.warn(this.getClass().getName()+".merge() not implemented."); + log.warn(this.getClass().getName() + ".merge() not implemented."); return true; } @@ -290,8 +364,9 @@ public abstract class Vobject { public VorbaId getVorbaId() { if (registerable && vorbaId == null) { if (this.__stored_in_document) { - if (__vorba!=null) - vorbaId=uk.ac.vamsas.client.VorbaId.newId(this.__getInstanceIdField()); + if (__vorba != null) + vorbaId = uk.ac.vamsas.client.VorbaId.newId(this + .__getInstanceIdField()); } // Try to use the associated factory. if (__vorba != null) @@ -321,50 +396,60 @@ public abstract class Vobject { } /** - * @return true if this object has been updated in the currently stored document since the last time a Vobject with the same ID was read from a Vamsas Document + * @return true if this object has been updated in the currently stored + * document since the last time a Vobject with the same ID was read + * from a Vamsas Document */ public boolean isUpdated() { return __updated_since_last_read; } + /** * - * @return true if this object was added to the document after the last time the vamsas library acessed the session document + * @return true if this object was added to the document after the last time + * the vamsas library acessed the session document */ public boolean isNewInDocument() { return __added_since_last_read; } + /** - * Set internal flag to indicate this object was updated since the last document read - * @param __updated_since_last_read the __updated_since_last_read to set + * Set internal flag to indicate this object was updated since the last + * document read + * + * @param __updated_since_last_read + * the __updated_since_last_read to set */ protected void set__updated_since_last_read(boolean __updated_since_last_read) { this.__updated_since_last_read = __updated_since_last_read; - if(__updated_since_last_read && log.isDebugEnabled()) - log.debug("Registered update for "+this.getVorbaId()); + if (__updated_since_last_read && log.isDebugEnabled()) + log.debug("Registered update for " + this.getVorbaId()); } /** * for use by Vorba agent to reflect state of vamsas Vobject to client - * application. - * Setting stored_in_document on a registerable Vobject without a - * vorbaId will mean is will *never* get a vorbaId and - * horrible things will happen. - * @param __stored_in_document true if Vobject has been marshalled into current document. + * application. Setting stored_in_document on a registerable Vobject without a + * vorbaId will mean is will *never* get a vorbaId and horrible things will + * happen. + * + * @param __stored_in_document + * true if Vobject has been marshalled into current document. */ protected void set__stored_in_document(boolean __stored_in_document) { this.__stored_in_document = __stored_in_document; - if(__stored_in_document && log.isDebugEnabled()) - log.debug("Retrieved document object: "+this.getVorbaId()); + if (__stored_in_document && log.isDebugEnabled()) + log.debug("Retrieved document object: " + this.getVorbaId()); } /** - * @param __added_since_last_read the __added_since_last_read to set + * @param __added_since_last_read + * the __added_since_last_read to set */ protected void set__added_since_last_read(boolean __added_since_last_read) { this.__added_since_last_read = __added_since_last_read; - if(__added_since_last_read && log.isDebugEnabled()) - log.debug("New object in document: "+this.getVorbaId()); + if (__added_since_last_read && log.isDebugEnabled()) + log.debug("New object in document: " + this.getVorbaId()); } /** @@ -386,41 +471,45 @@ public abstract class Vobject { } /** - * Called by __testInstanceForidField and the post-unmarshalling handler - * to indicate if Vobject will have a vorbaId. - * @param registerable + * Called by __testInstanceForidField and the post-unmarshalling handler to + * indicate if Vobject will have a vorbaId. + * + * @param registerable */ protected void setRegisterable(boolean registerable) { this.registerable = registerable; } + /** - * ensure's internal id field corresponds to vorbaId and - * cascade through all fields referring to an instance of Vobject - * calling the same method on them. - * TODO: LATER: properly apply castors own field mechanisms to get at accessors - * TODO: FIX CYCLIC __ensure+instance_ids - * Implementation note for the todo: - * this works like a depth-first search over all vamsas objects in an vamsasDocument. - * __visited is the visited flag, any Vobj who's flag is of a different parity - * to the visited argument will be recursed on. - * note - the doHash() function used to be used as the 'visited' flag - - * this *is not* a valid heuristic, although it will work "most of the time". - * TODO: LATER? Add another method for setDefaultProvenanceField (in the spirit of setInstanceIdField) using the info from the __vorba.getClient/User/Session methods + * ensure's internal id field corresponds to vorbaId and cascade through all + * fields referring to an instance of Vobject calling the same method on them. + * TODO: LATER: properly apply castors own field mechanisms to get at + * accessors TODO: FIX CYCLIC __ensure+instance_ids Implementation note for + * the todo: this works like a depth-first search over all vamsas objects in + * an vamsasDocument. __visited is the visited flag, any Vobj who's flag is of + * a different parity to the visited argument will be recursed on. note - the + * doHash() function used to be used as the 'visited' flag - this *is not* a + * valid heuristic, although it will work "most of the time". TODO: LATER? Add + * another method for setDefaultProvenanceField (in the spirit of + * setInstanceIdField) using the info from the __vorba.getClient/User/Session + * methods */ protected void __ensure_instance_ids() { __ensure_instance_ids(!__visited); } + protected void __ensure_instance_ids(boolean visited) { - if (__vorba==null) - throw new Error("Improperly intialised uk.ac.vamsas.client.Vobject - no VorbaFactory given."); - log.debug("doing "+this.getClass()+".__ensure_instance_ids()"); + if (__vorba == null) + throw new Error( + "Improperly intialised uk.ac.vamsas.client.Vobject - no VorbaFactory given."); + log.debug("doing " + this.getClass() + ".__ensure_instance_ids()"); if (!__stored_in_document && registerable) setInstanceIdField(); - if (__visited==visited) + if (__visited == visited) return; - __visited=visited; - //__vorba.updateHashValue(this); - + __visited = visited; + // __vorba.updateHashValue(this); + Class descriptor = null; XMLClassDescriptorImpl descimpl = null; try { @@ -428,96 +517,101 @@ public abstract class Vobject { StringBuffer desname = new StringBuffer(this.getClass().getName()); desname.insert(desname.lastIndexOf("."), ".descriptors"); desname.append("Descriptor"); - descriptor = this.getClass().getClassLoader().loadClass(desname.toString()); - descimpl = (XMLClassDescriptorImpl) descriptor.getConstructor((Class[])null).newInstance((Object[])null); + descriptor = this.getClass().getClassLoader().loadClass( + desname.toString()); + descimpl = (XMLClassDescriptorImpl) descriptor.getConstructor( + (Class[]) null).newInstance((Object[]) null); } catch (Exception e) { log.fatal("Source Generation Error!: Couldn't resolve descriptor for " - +this.getClass().getName() - +" was 'generate descriptors' set for castorbuilder.properties?"); + + this.getClass().getName() + + " was 'generate descriptors' set for castorbuilder.properties?"); return; } FieldDescriptor fields[] = descimpl.getFields(); - for (int i=0,j=fields.length; i. + */ package uk.ac.vamsas.client; /** - * Holds information about Vobj instances that is held over between different writes to the document. - * Currently records the LhashValue obtained from Vobject + * Holds information about Vobj instances that is held over between different + * writes to the document. Currently records the LhashValue obtained from + * Vobject + * * @author JimP - * + * */ public class Vobjhash { - private static org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(Vobjhash.class); - long hashvalue; + private static org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory + .getLog(Vobjhash.class); + + long hashvalue; + /** * creates a record of the hash value for a vamsas document object + * * @param tobemarshalled */ public Vobjhash(Vobject tobemarshalled) { tobemarshalled.doHash(); hashvalue = tobemarshalled.get__last_hash(); if (log.isDebugEnabled()) - log.debug(tobemarshalled.getVorbaId()+":"+hashvalue); + log.debug(tobemarshalled.getVorbaId() + ":" + hashvalue); } + /** - * compares the old hash value with the unmarshalled object's most recently computed hash value and updates internal record. + * compares the old hash value with the unmarshalled object's most recently + * computed hash value and updates internal record. + * * @param unmarshalled * @return true if the hash values differ */ public boolean isUpdated(Vobject unmarshalled) { long oldhash = hashvalue; unmarshalled.doHash(); - hashvalue=unmarshalled.get__last_hash(); - if (log.isDebugEnabled() && oldhash!=hashvalue) - log.debug(" has changed."+unmarshalled.getVorbaId()); - return oldhash!=hashvalue; + hashvalue = unmarshalled.get__last_hash(); + if (log.isDebugEnabled() && oldhash != hashvalue) + log.debug(" has changed." + unmarshalled.getVorbaId()); + return oldhash != hashvalue; } } diff --git a/src/uk/ac/vamsas/client/VorbaId.java b/src/uk/ac/vamsas/client/VorbaId.java index fd6d6de..6e756d9 100644 --- a/src/uk/ac/vamsas/client/VorbaId.java +++ b/src/uk/ac/vamsas/client/VorbaId.java @@ -1,19 +1,34 @@ /* - * Created on 12-Sep-2005 - * - * TODO To change the template for this generated file go to - * Window - Preferences - Java - Code Style - Code Templates + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ package uk.ac.vamsas.client; import java.io.Serializable; /** - * The unique reference id for a Vamsas document Vobject, - * used by applications to refer to the vamsas Vobject - * within their own data space in the vamsas document. - * This is serializable (thanks to Dominik Lindner) so an - * application can store it easily. + * The unique reference id for a Vamsas document Vobject, used by applications + * to refer to the vamsas Vobject within their own data space in the vamsas + * document. This is serializable (thanks to Dominik Lindner) so an application + * can store it easily. + * * @author jimp */ public class VorbaId implements Serializable { @@ -21,62 +36,81 @@ public class VorbaId implements Serializable { * 1 is first vamsas release ID version. */ private static final long serialVersionUID = 1L; + protected String id; + protected VorbaId() { super(); } + private VorbaId(String Id) { super(); id = Id; } + /** * - * @param vorbaObject the source of vorba Ids - * @param vobject the Vobject to be registered with a new vorba id + * @param vorbaObject + * the source of vorba Ids + * @param vobject + * the Vobject to be registered with a new vorba id * @return */ protected static VorbaId newId(IVorbaIdFactory vorbaObject, Vobject vobject) { // Make unique id from appSpace info in vorbaObject synchronized (vorbaObject) { - vobject.vorbaId=vorbaObject.makeVorbaId(vobject); + vobject.vorbaId = vorbaObject.makeVorbaId(vobject); return vobject.vorbaId; } } + /** - * protected VorbaId constructor used when turning XML ID strings into vorba IDs + * protected VorbaId constructor used when turning XML ID strings into vorba + * IDs + * * @param id * @return VorbaId object or null if string was null. */ protected static VorbaId newId(String id) { - return (id==null) ? null : new VorbaId(id); + return (id == null) ? null : new VorbaId(id); } + /** * @return Returns the id. */ public String getId() { return id; } - /* (non-Javadoc) + + /* + * (non-Javadoc) + * * @see java.lang.Object#equals(java.lang.Object) */ public boolean equals(Object obj) { if (obj instanceof String) return id.equals(obj); else if (obj instanceof VorbaId) - return id.equals(((VorbaId)obj).id); + return id.equals(((VorbaId) obj).id); return false; } - /* (non-Javadoc) + + /* + * (non-Javadoc) + * * @see java.lang.Object#hashCode() */ public int hashCode() { return id.hashCode(); } - /* (non-Javadoc) + + /* + * (non-Javadoc) + * * @see java.lang.Object#toString() */ public String toString() { return id; } - + } diff --git a/src/uk/ac/vamsas/client/VorbaIdFactory.java b/src/uk/ac/vamsas/client/VorbaIdFactory.java index c5a5079..8b0e98a 100644 --- a/src/uk/ac/vamsas/client/VorbaIdFactory.java +++ b/src/uk/ac/vamsas/client/VorbaIdFactory.java @@ -1,8 +1,23 @@ /* - * Created on 12-Sep-2005 - * - * TODO To change the template for this generated file go to - * Window - Preferences - Java - Code Style - Code Templates + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ package uk.ac.vamsas.client; @@ -10,9 +25,8 @@ import java.util.Hashtable; import java.util.Vector; /** - * A VorbaIdFactory is constructed by an IClient instance. - * It guarantees that any new VorbaId objects are unique - * within the VAMSAS session. + * A VorbaIdFactory is constructed by an IClient instance. It guarantees that + * any new VorbaId objects are unique within the VAMSAS session. * * @author jimp */ @@ -20,16 +34,18 @@ public abstract class VorbaIdFactory implements IVorbaIdFactory { /** * hash of VorbaIds to Vobject. */ - protected Hashtable extantids=null; + protected Hashtable extantids = null; + /** * hash of VorbaIds to persisted hash values */ - protected Hashtable extanthashv=null; + protected Hashtable extanthashv = null; + /** * list of Vobjects added since last Document read. */ - protected Vector newobj=null; - + protected Vector newobj = null; + /** * construct a new id appropriate for this client in the vamsas session. * @@ -37,28 +53,35 @@ public abstract class VorbaIdFactory implements IVorbaIdFactory { * correctly. */ public abstract VorbaId makeVorbaId(Vobject vobject); - + /** - * internal method to access the protected VorbaId object constructor - * This shennanigan is to prevent casual generation of VorbaIds - * (which may destroy the integrity of a Vamsas Document!) + * internal method to access the protected VorbaId object constructor This + * shennanigan is to prevent casual generation of VorbaIds (which may destroy + * the integrity of a Vamsas Document!) + * * @param id * @return new VorbaId object */ protected VorbaId newId(String id) { return VorbaId.newId(id); } + /** - * Called by VorbaXmlBinder so the record of newly unmarshalled Vobject Ids - * is accessible to the Document's VorbaIdFactory instance. + * Called by VorbaXmlBinder so the record of newly unmarshalled Vobject Ids is + * accessible to the Document's VorbaIdFactory instance. + * * @param idtable */ protected void setNewIdHash(Hashtable idtable) { extantids = idtable; } - - /* (non-Javadoc) - * @see uk.ac.vamsas.client.IVorbaIdFactory#updateHashValue(uk.ac.vamsas.client.Vobject) + + /* + * (non-Javadoc) + * + * @see + * uk.ac.vamsas.client.IVorbaIdFactory#updateHashValue(uk.ac.vamsas.client + * .Vobject) */ public void updateHashValue(Vobject vobject) { if (vobject.isRegisterable()) diff --git a/src/uk/ac/vamsas/client/VorbaXmlBinder.java b/src/uk/ac/vamsas/client/VorbaXmlBinder.java index 9462494..b237dcf 100644 --- a/src/uk/ac/vamsas/client/VorbaXmlBinder.java +++ b/src/uk/ac/vamsas/client/VorbaXmlBinder.java @@ -1,258 +1,310 @@ -/** - * - */ -package uk.ac.vamsas.client; - -import java.io.IOException; -import java.io.PrintWriter; -import java.io.Reader; -import java.io.Writer; -import java.lang.reflect.Field; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.Vector; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.exolab.castor.mapping.FieldHandler; -import org.exolab.castor.mapping.GeneralizedFieldHandler; -import org.exolab.castor.mapping.ValidityException; -import org.exolab.castor.xml.IDResolver; -import org.exolab.castor.xml.MarshalException; -import org.exolab.castor.xml.MarshalListener; -import org.exolab.castor.xml.Marshaller; -import org.exolab.castor.xml.UnmarshalListener; -import org.exolab.castor.xml.Unmarshaller; -import org.exolab.castor.xml.ValidationException; - -import uk.ac.vamsas.objects.core.VamsasDocument; -/** - * Implements the Vamsas Vobject ID machinery for translating - * between non-volatile XML IDs and Vobject references. Use the - * marshalling and unmarshalling methods in this class in order - * to add automatically computed values for required fields in objects, - * so as to avoid validation exceptions when marshalling new objects - * into the vamsas document. - */ -public class VorbaXmlBinder implements UnmarshalListener { - private static Log log = LogFactory.getLog(VorbaXmlBinder.class); - private final IVorbaIdFactory vorbafactory; - - private final Vector obj; - private final Hashtable oldobjhashes; - private final Hashtable objrefs; - private final Vector updatedobjs; // not yet used elswhere ? - public VorbaXmlBinder(IVorbaIdFactory vorbafactory2, Vector unrefedObj, Hashtable objrefs2, Hashtable oldobjhashes, Vector updatedObj) { - this.vorbafactory = vorbafactory2; - this.obj = unrefedObj; - this.objrefs = objrefs2; - this.oldobjhashes = oldobjhashes; - this.updatedobjs = updatedObj; - } - - /* - * (non-Javadoc) - * - * @see org.exolab.castor.xml.UnmarshalListener#attributesProcessed(java.lang.Object) - */ - public void attributesProcessed(Object object) { - - } - - /* - * (non-Javadoc) - * - * @see org.exolab.castor.xml.UnmarshalListener#fieldAdded(java.lang.String, - * java.lang.Object, java.lang.Object) - */ - public void fieldAdded(String fieldName, Object parent, Object child) { - if (parent instanceof Vobject && child instanceof Vobject) { - if (((Vobject) child).V_parent==null) { - // System.err.println("Setting parent of "+fieldName); - ((Vobject) child).setV_parent((Vobject) parent); - } - } - } - - /* - * (non-Javadoc) - * - * @see org.exolab.castor.xml.UnmarshalListener#initialized(java.lang.Object) - */ - public void initialized(Object object) { - if (object instanceof Vobject) { - Vobject nobj = (Vobject) object; - } - } - - /* - * Check if the object has an 'id' field - if it does, copy the value into - * the VorbaId field of Vobject, and add the Vobject to the VorbaId hash. - * - * @see org.exolab.castor.xml.UnmarshalListener#unmarshalled(java.lang.Object) - */ - public void unmarshalled(Object newobj) { - if (newobj instanceof Vobject) { - Vobject nobj = (Vobject) newobj; - nobj.set__stored_in_document(true); - try { - if (nobj.isRegisterable() && nobj.___id_field!=null) { - VorbaId nobj_id=null; - // look for the id field (should be an NCName string) - nobj.__vorba = vorbafactory; - // use the Vobject accessor method to avoid unpleasant security exceptions. - String idstring = nobj.__getInstanceIdField(); - if (idstring!=null) { - if (idstring.length() > 0) { - nobj.setVorbaId(VorbaId.newId(idstring)); - nobj_id=nobj.getVorbaId(); - if (objrefs.containsKey(nobj_id) && !objrefs.get(nobj_id).equals(nobj)) { - System.err.println("Serious problem : duplicate id '"+idstring+"' found! expect badness."); - // TODO: HANDLE duplicate XML ids correctly - } - objrefs.put(nobj_id, nobj); - } else { - // add to list of objects without a valid vorbaId - obj.add(nobj); - } - } else { - // TODO: add to list of objects without a valid vorbaId - obj.add(nobj); - } - nobj.doHash(); // updates detected by comparing with last hash when marshalling - // check to see if new object was present in old object hash - if (nobj_id!=null) { - if (oldobjhashes.containsKey(nobj_id)) { - Vobjhash oldhash = (Vobjhash) oldobjhashes.get(nobj_id); - if (oldhash.isUpdated(nobj)) { - // mark the object as updated in this document read. - nobj.set__updated_since_last_read(true); - updatedobjs.addElement(nobj); - } - } else { - // object has no entry in the oldhashvalue list but - // there is a valid vorbaId so - nobj.set__added_since_last_read(true); - } - // and record the just-unmarshalled hash value - oldobjhashes.put(nobj_id, new Vobjhash(nobj)); - } else { - // for objects yet to get a valid vorba_id - nobj.set__added_since_last_read(true); - } - } - - } catch (Exception e) { - return; - }; - - } - } - - /** - * writes the VamsasDocument to the given stream. - * TODO: ensure that (at least) default provenance entries are written for objects. - * @param outstream - * @param vorba valid VorbaIdFactory to construct any missing IDs - * @param doc - * @throws IOException - * @throws MarshalException - * @throws ValidationException - */ - public static void putVamsasDocument(PrintWriter outstream, VorbaIdFactory vorba, VamsasDocument doc) - throws IOException, MarshalException, ValidationException { - // Ensure references - if (vorba==null) - throw new Error("Null VorbaIdFactory Parameter"); - if (doc.__vorba==null) - doc.__vorba = vorba; - doc.__ensure_instance_ids(); // this may take a while. Do we allow for cyclic references ? - Marshaller mshl = new Marshaller(outstream); - mshl.marshal(doc); - - } - /** - * creates new VorbaId references where necessary for newly unmarshalled objects - * @param unrefed - * @param objrefs - * @return false if any new object references were made - */ - private static boolean ensure_references(Vector unrefed, Hashtable objrefs) { - boolean sync=true; - if (unrefed.size()>0) { - sync=false; // document is out of sync - ids have been created. - java.util.Iterator newobj = unrefed.listIterator(); - while (newobj.hasNext()) { - Vobject o = (Vobject) newobj.next(); - // forces registration and id field update. - VorbaId id = o.getVorbaId(); - if (!objrefs.containsKey(id)) { - objrefs.put(id, o); - } else { - if (!objrefs.get(id).equals(o)) - throw new Error("Serious! Duplicate reference made by vorbaIdFactory!"); - } - } - } - return sync; - } - /** - * Unmarshals a vamsasDocument Vobject from a stream, registers - * unregistered objects, records existing VorbaIds, and completes - * the uk.ac.vamsas.client.Vobject housekeeping fields. - * For a valid unmarshalling, the array of returned objects also includes - * a sync parameter which is true if new VorbaIds - * were created. If sync is false, then the caller should ensure that the - * vamsasDocument is written back to disk to propagate the new VorbaIds. - * TODO: ensure that provenance is correct for newly registered objects - * as getVamsasObjects but will detect updated objects based on differing hash values - * obtained from the VorbaIdFactory's VorbaId, Vobject.get__last_Hash() pairs (if any) - * @param instream - the XML input stream - * @param factory - the SimpleClient's properly configured VorbaId factory to make new references. - * @param root the root element's uk.ac.vamsas.objects.core Vobject. - * @return null or {(Object) VamsasDocument Vobject, (Object) Hashtable of Vobject references, (Object) Boolean(sync), (Object) Vector of updated objects in document } - */ - public static Object[] getVamsasObjects(Reader instream, - VorbaIdFactory factory, Vobject root) { - Unmarshaller unmarshaller = new Unmarshaller(root); - unmarshaller.setIDResolver(new IDResolver() { - public Object resolve(String id) { - // TODO: allow for external ID resolution - VorbaXmlBinder.log.warn("Warning - id " + id - + " is not found in the Vamsas XML! (TODO: Ignore if this is a forward reference!)"); - return null; - } - }); - final Hashtable objrefs = new Hashtable(); - if (factory.extanthashv==null) - factory.extanthashv=new Hashtable(); - final Hashtable oobjhashes=factory.extanthashv; - final VorbaIdFactory vorbafactory = factory; - final Vector unrefedObj = new Vector(); - final Vector updatedObj = new Vector(); - unmarshaller.setUnmarshalListener(new VorbaXmlBinder(vorbafactory, unrefedObj, objrefs, oobjhashes,updatedObj)); - // Call the unmarshaller. - try { - while (instream.ready()) { - // TODO: mark objects in oobjhash prior to unmarshalling, to detect when objects have been lost through an update. - //tohere - Object obj = unmarshaller.unmarshal(instream); - boolean sync=ensure_references(unrefedObj, objrefs); - if (!(obj instanceof Vobject)) - return null; - vorbafactory.setNewIdHash(objrefs); // update the Document IO Handler's set of vorbaId<>Object bindings. - return new Object[] { obj, objrefs, new Boolean(sync),updatedObj}; - } - } catch (MarshalException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (ValidationException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - return null; - } -} \ No newline at end of file +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ +package uk.ac.vamsas.client; + +import java.io.IOException; +import java.io.PrintWriter; +import java.io.Reader; +import java.io.Writer; +import java.lang.reflect.Field; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.Vector; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.exolab.castor.mapping.FieldHandler; +import org.exolab.castor.mapping.GeneralizedFieldHandler; +import org.exolab.castor.mapping.ValidityException; +import org.exolab.castor.xml.IDResolver; +import org.exolab.castor.xml.MarshalException; +import org.exolab.castor.xml.MarshalListener; +import org.exolab.castor.xml.Marshaller; +import org.exolab.castor.xml.UnmarshalListener; +import org.exolab.castor.xml.Unmarshaller; +import org.exolab.castor.xml.ValidationException; + +import uk.ac.vamsas.objects.core.VamsasDocument; + +/** + * Implements the Vamsas Vobject ID machinery for translating between + * non-volatile XML IDs and Vobject references. Use the marshalling and + * unmarshalling methods in this class in order to add automatically computed + * values for required fields in objects, so as to avoid validation exceptions + * when marshalling new objects into the vamsas document. + */ +public class VorbaXmlBinder implements UnmarshalListener { + private static Log log = LogFactory.getLog(VorbaXmlBinder.class); + + private final IVorbaIdFactory vorbafactory; + + private final Vector obj; + + private final Hashtable oldobjhashes; + + private final Hashtable objrefs; + + private final Vector updatedobjs; // not yet used elswhere ? + + public VorbaXmlBinder(IVorbaIdFactory vorbafactory2, Vector unrefedObj, + Hashtable objrefs2, Hashtable oldobjhashes, Vector updatedObj) { + this.vorbafactory = vorbafactory2; + this.obj = unrefedObj; + this.objrefs = objrefs2; + this.oldobjhashes = oldobjhashes; + this.updatedobjs = updatedObj; + } + + /* + * (non-Javadoc) + * + * @see + * org.exolab.castor.xml.UnmarshalListener#attributesProcessed(java.lang.Object + * ) + */ + public void attributesProcessed(Object object) { + + } + + /* + * (non-Javadoc) + * + * @see org.exolab.castor.xml.UnmarshalListener#fieldAdded(java.lang.String, + * java.lang.Object, java.lang.Object) + */ + public void fieldAdded(String fieldName, Object parent, Object child) { + if (parent instanceof Vobject && child instanceof Vobject) { + if (((Vobject) child).V_parent == null) { + // System.err.println("Setting parent of "+fieldName); + ((Vobject) child).setV_parent((Vobject) parent); + } + } + } + + /* + * (non-Javadoc) + * + * @see org.exolab.castor.xml.UnmarshalListener#initialized(java.lang.Object) + */ + public void initialized(Object object) { + if (object instanceof Vobject) { + Vobject nobj = (Vobject) object; + } + } + + /* + * Check if the object has an 'id' field - if it does, copy the value into the + * VorbaId field of Vobject, and add the Vobject to the VorbaId hash. + * + * @see org.exolab.castor.xml.UnmarshalListener#unmarshalled(java.lang.Object) + */ + public void unmarshalled(Object newobj) { + if (newobj instanceof Vobject) { + Vobject nobj = (Vobject) newobj; + nobj.set__stored_in_document(true); + try { + if (nobj.isRegisterable() && nobj.___id_field != null) { + VorbaId nobj_id = null; + // look for the id field (should be an NCName string) + nobj.__vorba = vorbafactory; + // use the Vobject accessor method to avoid unpleasant security + // exceptions. + String idstring = nobj.__getInstanceIdField(); + if (idstring != null) { + if (idstring.length() > 0) { + nobj.setVorbaId(VorbaId.newId(idstring)); + nobj_id = nobj.getVorbaId(); + if (objrefs.containsKey(nobj_id) + && !objrefs.get(nobj_id).equals(nobj)) { + System.err.println("Serious problem : duplicate id '" + + idstring + "' found! expect badness."); + // TODO: HANDLE duplicate XML ids correctly + } + objrefs.put(nobj_id, nobj); + } else { + // add to list of objects without a valid vorbaId + obj.add(nobj); + } + } else { + // TODO: add to list of objects without a valid vorbaId + obj.add(nobj); + } + nobj.doHash(); // updates detected by comparing with last hash when + // marshalling + // check to see if new object was present in old object hash + if (nobj_id != null) { + if (oldobjhashes.containsKey(nobj_id)) { + Vobjhash oldhash = (Vobjhash) oldobjhashes.get(nobj_id); + if (oldhash.isUpdated(nobj)) { + // mark the object as updated in this document read. + nobj.set__updated_since_last_read(true); + updatedobjs.addElement(nobj); + } + } else { + // object has no entry in the oldhashvalue list but + // there is a valid vorbaId so + nobj.set__added_since_last_read(true); + } + // and record the just-unmarshalled hash value + oldobjhashes.put(nobj_id, new Vobjhash(nobj)); + } else { + // for objects yet to get a valid vorba_id + nobj.set__added_since_last_read(true); + } + } + + } catch (Exception e) { + return; + } + ; + + } + } + + /** + * writes the VamsasDocument to the given stream. TODO: ensure that (at least) + * default provenance entries are written for objects. + * + * @param outstream + * @param vorba + * valid VorbaIdFactory to construct any missing IDs + * @param doc + * @throws IOException + * @throws MarshalException + * @throws ValidationException + */ + public static void putVamsasDocument(PrintWriter outstream, + VorbaIdFactory vorba, VamsasDocument doc) throws IOException, + MarshalException, ValidationException { + // Ensure references + if (vorba == null) + throw new Error("Null VorbaIdFactory Parameter"); + if (doc.__vorba == null) + doc.__vorba = vorba; + doc.__ensure_instance_ids(); // this may take a while. Do we allow for + // cyclic references ? + Marshaller mshl = new Marshaller(outstream); + mshl.marshal(doc); + + } + + /** + * creates new VorbaId references where necessary for newly unmarshalled + * objects + * + * @param unrefed + * @param objrefs + * @return false if any new object references were made + */ + private static boolean ensure_references(Vector unrefed, Hashtable objrefs) { + boolean sync = true; + if (unrefed.size() > 0) { + sync = false; // document is out of sync - ids have been created. + java.util.Iterator newobj = unrefed.listIterator(); + while (newobj.hasNext()) { + Vobject o = (Vobject) newobj.next(); + // forces registration and id field update. + VorbaId id = o.getVorbaId(); + if (!objrefs.containsKey(id)) { + objrefs.put(id, o); + } else { + if (!objrefs.get(id).equals(o)) + throw new Error( + "Serious! Duplicate reference made by vorbaIdFactory!"); + } + } + } + return sync; + } + + /** + * Unmarshals a vamsasDocument Vobject from a stream, registers unregistered + * objects, records existing VorbaIds, and completes the + * uk.ac.vamsas.client.Vobject housekeeping fields. For a valid unmarshalling, + * the array of returned objects also includes a sync + * parameter which is true if new VorbaIds were created. If sync is false, + * then the caller should ensure that the vamsasDocument is written back to + * disk to propagate the new VorbaIds. TODO: ensure that provenance is correct + * for newly registered objects as getVamsasObjects but will detect updated + * objects based on differing hash values obtained from the VorbaIdFactory's + * VorbaId, Vobject.get__last_Hash() pairs (if any) + * + * @param instream + * - the XML input stream + * @param factory + * - the SimpleClient's properly configured VorbaId factory to make + * new references. + * @param root + * the root element's uk.ac.vamsas.objects.core Vobject. + * @return null or {(Object) VamsasDocument Vobject, (Object) Hashtable of + * Vobject references, (Object) Boolean(sync), (Object) Vector of + * updated objects in document } + */ + public static Object[] getVamsasObjects(Reader instream, + VorbaIdFactory factory, Vobject root) { + Unmarshaller unmarshaller = new Unmarshaller(root); + unmarshaller.setIDResolver(new IDResolver() { + public Object resolve(String id) { + // TODO: allow for external ID resolution + VorbaXmlBinder.log + .warn("Warning - id " + + id + + " is not found in the Vamsas XML! (TODO: Ignore if this is a forward reference!)"); + return null; + } + }); + final Hashtable objrefs = new Hashtable(); + if (factory.extanthashv == null) + factory.extanthashv = new Hashtable(); + final Hashtable oobjhashes = factory.extanthashv; + final VorbaIdFactory vorbafactory = factory; + final Vector unrefedObj = new Vector(); + final Vector updatedObj = new Vector(); + unmarshaller.setUnmarshalListener(new VorbaXmlBinder(vorbafactory, + unrefedObj, objrefs, oobjhashes, updatedObj)); + // Call the unmarshaller. + try { + while (instream.ready()) { + // TODO: mark objects in oobjhash prior to unmarshalling, to detect when + // objects have been lost through an update. + // tohere + Object obj = unmarshaller.unmarshal(instream); + boolean sync = ensure_references(unrefedObj, objrefs); + if (!(obj instanceof Vobject)) + return null; + vorbafactory.setNewIdHash(objrefs); // update the Document IO Handler's + // set of vorbaId<>Object bindings. + return new Object[] { obj, objrefs, new Boolean(sync), updatedObj }; + } + } catch (MarshalException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (ValidationException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } +} diff --git a/src/uk/ac/vamsas/client/picking/CustomMessage.java b/src/uk/ac/vamsas/client/picking/CustomMessage.java index b418651..f422277 100644 --- a/src/uk/ac/vamsas/client/picking/CustomMessage.java +++ b/src/uk/ac/vamsas/client/picking/CustomMessage.java @@ -1,17 +1,38 @@ +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ package uk.ac.vamsas.client.picking; /** * Defines a custom message that applications can use to send message types that * haven't been predefined in the API. */ -public class CustomMessage extends Message -{ - /** - * Constructs a new custom message. - * @param message the message to be sent - */ - public CustomMessage(String message) - { - this.message = "CUSTOM\t" + message; - } -} \ No newline at end of file +public class CustomMessage extends Message { + /** + * Constructs a new custom message. + * + * @param message + * the message to be sent + */ + public CustomMessage(String message) { + this.message = "CUSTOM\t" + message; + } +} diff --git a/src/uk/ac/vamsas/client/picking/IMessageHandler.java b/src/uk/ac/vamsas/client/picking/IMessageHandler.java index c6eba16..0fadcc2 100644 --- a/src/uk/ac/vamsas/client/picking/IMessageHandler.java +++ b/src/uk/ac/vamsas/client/picking/IMessageHandler.java @@ -1,3 +1,24 @@ +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ package uk.ac.vamsas.client.picking; /** @@ -5,13 +26,14 @@ package uk.ac.vamsas.client.picking; * interface must be implemented by the client application (TOPALi, Jalview or * AstexViewer). */ -public interface IMessageHandler -{ - /** - * Responds to a message received event. It is advisable to implement this - * method so that it threads off any actions into the GUI event-dispatching - * thread. - * @param message the message that was received - */ - public void handleMessage(Message message); -} \ No newline at end of file +public interface IMessageHandler { + /** + * Responds to a message received event. It is advisable to implement this + * method so that it threads off any actions into the GUI event-dispatching + * thread. + * + * @param message + * the message that was received + */ + public void handleMessage(Message message); +} diff --git a/src/uk/ac/vamsas/client/picking/IPickManager.java b/src/uk/ac/vamsas/client/picking/IPickManager.java index a91802d..0496ab8 100644 --- a/src/uk/ac/vamsas/client/picking/IPickManager.java +++ b/src/uk/ac/vamsas/client/picking/IPickManager.java @@ -1,26 +1,50 @@ +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ package uk.ac.vamsas.client.picking; /** * Interface that defines the methods required for a pick manager. */ -public interface IPickManager -{ - /** - * Sends a message. - * @param message the message to send - */ - public void sendMessage(Message message); - - /** - * Registers a message handler with the manager that allows the manager to - * perform a method callback on that object whenever a message is received. - * @param handler the message handler to register - */ - public void registerMessageHandler(IMessageHandler handler); - - /** - * Shutsdown the pick manager processes, terminating any connections to - * other clients. - */ - public void shutdown(); -} \ No newline at end of file +public interface IPickManager { + /** + * Sends a message. + * + * @param message + * the message to send + */ + public void sendMessage(Message message); + + /** + * Registers a message handler with the manager that allows the manager to + * perform a method callback on that object whenever a message is received. + * + * @param handler + * the message handler to register + */ + public void registerMessageHandler(IMessageHandler handler); + + /** + * Shutsdown the pick manager processes, terminating any connections to other + * clients. + */ + public void shutdown(); +} diff --git a/src/uk/ac/vamsas/client/picking/Message.java b/src/uk/ac/vamsas/client/picking/Message.java index c696934..308fdfe 100644 --- a/src/uk/ac/vamsas/client/picking/Message.java +++ b/src/uk/ac/vamsas/client/picking/Message.java @@ -1,57 +1,83 @@ +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ package uk.ac.vamsas.client.picking; /** * Abstract base class for all message types supported by the picking API. */ -public abstract class Message -{ - protected String message; - - /** - * Constructs a new message. - */ - protected Message() - { +public abstract class Message { + protected String message; + + /** + * Constructs a new message. + */ + protected Message() { + + } + + /** + * Returns the raw message content as a string. + * + * @return the raw message content as a string + */ + public String getRawMessage() { + return message; + } + + /** + * compare the on-wire message content of the given message to this. + * + * @param msg + * @return true if message content is equal + */ + public boolean equals(Message msg) { + return message.equals(msg.getRawMessage()); + } - } - - /** - * Returns the raw message content as a string. - * @return the raw message content as a string - */ - public String getRawMessage() - { return message; } - /** - * compare the on-wire message content of the given message to this. - * @param msg - * @return true if message content is equal - */ - public boolean equals(Message msg) - { - return message.equals(msg.getRawMessage()); - } - /** - * Test consistence of a Message class implementation. This method throws an error if - * the message object cannot be parsed into another instance of the same object by - * invoking the MessageImpl(String this.getRawMessage()) constructor or that - * newinstance.getRawMessage != this.getRawMessage - */ + /** + * Test consistence of a Message class implementation. This method throws an + * error if the message object cannot be parsed into another instance of the + * same object by invoking the MessageImpl(String this.getRawMessage()) + * constructor or that newinstance.getRawMessage != this.getRawMessage + */ public void validate() { try { - java.lang.reflect.Constructor msgcons = this.getClass().getConstructor(new Class[] { String.class }); - if (msgcons==null) - { - throw new Exception("No "+this.getClass().getName()+"(String rawmessage) constructor."); + java.lang.reflect.Constructor msgcons = this.getClass().getConstructor( + new Class[] { String.class }); + if (msgcons == null) { + throw new Exception("No " + this.getClass().getName() + + "(String rawmessage) constructor."); } - Message instance = (Message) msgcons.newInstance(new Object[] { this.getRawMessage() }); - if (!instance.getRawMessage().equals(getRawMessage())) - { - throw new Error("Raw Message Content does not match :\nInitial Message:"+getRawMessage()+"\nParsed and regnerated as :\n"+instance.getRawMessage()+"\n"); + Message instance = (Message) msgcons.newInstance(new Object[] { this + .getRawMessage() }); + if (!instance.getRawMessage().equals(getRawMessage())) { + throw new Error( + "Raw Message Content does not match :\nInitial Message:" + + getRawMessage() + "\nParsed and regnerated as :\n" + + instance.getRawMessage() + "\n"); } - } catch (Exception e) - { - throw new Error("Message implementation broken for "+this.getClass(),e); + } catch (Exception e) { + throw new Error("Message implementation broken for " + this.getClass(), e); } } -} \ No newline at end of file +} diff --git a/src/uk/ac/vamsas/client/picking/MouseOverMessage.java b/src/uk/ac/vamsas/client/picking/MouseOverMessage.java index 2cb8531..7c04eb9 100644 --- a/src/uk/ac/vamsas/client/picking/MouseOverMessage.java +++ b/src/uk/ac/vamsas/client/picking/MouseOverMessage.java @@ -1,61 +1,88 @@ +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ package uk.ac.vamsas.client.picking; /** * Message class that can be used to send mouse over events. */ -public class MouseOverMessage extends Message -{ - private String vorbaID; - private int position; - - /** - * Constructs a new mouse over message. - * @param vorbaID the VAMSAS object ID of the event's source (usually an - * alignment or alignment sequence) - * @param position a position on the source in its coordinate system (ie a - * column or nucleotide/residue position) - */ - public MouseOverMessage(String vorbaID, int position) - { - this.vorbaID = vorbaID; - this.position = position; - - message = "MOUSEOVER\t" - + "vorbaID=" + vorbaID + "\t" + "position=" + position; - } - - /** - * Constructs a new mouse over message from its underlying string format. - * @param str the string representation of an instance of this object - * @throws java.lang.Exception if the message cannot be reconstructed - */ - MouseOverMessage(String str) - throws Exception - { - message = str; - - String[] elements = str.split("\t"); - - for (int i = 0; i < elements.length; i++) - { - if (elements[i].startsWith("vorbaID=")) - vorbaID = elements[i].substring(8); - else if (elements[i].startsWith("position=")) - position = Integer.parseInt(elements[i].substring(9)); - } - } - - /** - * Returns the VAMSAS object ID associated with this message. - * @return the VAMSAS object ID associated with this message - */ - public String getVorbaID() - { return vorbaID; } - - /** - * Returns the position value associated with this message. - * @return the position value associated with this message - */ - public int getPosition() - { return position; } -} \ No newline at end of file +public class MouseOverMessage extends Message { + private String vorbaID; + + private int position; + + /** + * Constructs a new mouse over message. + * + * @param vorbaID + * the VAMSAS object ID of the event's source (usually an alignment + * or alignment sequence) + * @param position + * a position on the source in its coordinate system (ie a column or + * nucleotide/residue position) + */ + public MouseOverMessage(String vorbaID, int position) { + this.vorbaID = vorbaID; + this.position = position; + + message = "MOUSEOVER\t" + "vorbaID=" + vorbaID + "\t" + "position=" + + position; + } + + /** + * Constructs a new mouse over message from its underlying string format. + * + * @param str + * the string representation of an instance of this object + * @throws java.lang.Exception + * if the message cannot be reconstructed + */ + MouseOverMessage(String str) throws Exception { + message = str; + + String[] elements = str.split("\t"); + + for (int i = 0; i < elements.length; i++) { + if (elements[i].startsWith("vorbaID=")) + vorbaID = elements[i].substring(8); + else if (elements[i].startsWith("position=")) + position = Integer.parseInt(elements[i].substring(9)); + } + } + + /** + * Returns the VAMSAS object ID associated with this message. + * + * @return the VAMSAS object ID associated with this message + */ + public String getVorbaID() { + return vorbaID; + } + + /** + * Returns the position value associated with this message. + * + * @return the position value associated with this message + */ + public int getPosition() { + return position; + } +} diff --git a/src/uk/ac/vamsas/client/picking/PickEndPoint.java b/src/uk/ac/vamsas/client/picking/PickEndPoint.java index beb0e46..c9c7e71 100644 --- a/src/uk/ac/vamsas/client/picking/PickEndPoint.java +++ b/src/uk/ac/vamsas/client/picking/PickEndPoint.java @@ -1,3 +1,24 @@ +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ package uk.ac.vamsas.client.picking; import java.io.*; @@ -6,144 +27,135 @@ import java.util.logging.*; import org.apache.commons.logging.Log; -class PickEndPoint extends Thread -{ - private Log logger = org.apache.commons.logging.LogFactory.getLog(uk.ac.vamsas.client.picking.PickEndPoint.class); - - private Socket socket; - private int rPort; - private BufferedWriter os; - private BufferedReader in; - /** +class PickEndPoint extends Thread { + private Log logger = org.apache.commons.logging.LogFactory + .getLog(uk.ac.vamsas.client.picking.PickEndPoint.class); + + private Socket socket; + + private int rPort; + + private BufferedWriter os; + + private BufferedReader in; + + /** * reference to server or null if no comms session active */ - private SocketManager manager; - - PickEndPoint(SocketManager manager, Socket s) - { - this.manager = manager; - socket = s; - } - - boolean openConnection() - { - try - { - // Create the socket if it doesn't already exist - if (socket == null) - socket = new Socket(InetAddress.getLocalHost(), PickServer.PORT); - - rPort = socket.getPort(); - socket.setKeepAlive(true); - - // Open the streams for reading/writing - os = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())); - in = new BufferedReader(new InputStreamReader(socket.getInputStream())); - - // Start the thread to listen for incoming messages - logger.debug("CLIENT: connection successful to port " - + socket.getPort() + " via port " + socket.getLocalPort()); - start(); - - return true; - } - catch (Exception e) - { - logger.info("CLIENT: connection failed: " + e); - return false; - } - } - - void send(Message message) - { - try - { - String str = message.getRawMessage(); - - // System.err.println("CLIENT: send " + str + " to " + rPort); - os.write(str); - - // We use a newline to terminate the message - os.newLine(); - os.flush(); - } - catch (Exception e) - { - //logger.info("CLIENT: failed to send"); - - // TODO: terminate the connection on a failed send or retry? (Has this been done? JBP) - terminate(); - } - } - - // void receive() (threaded) - public void run() - { - try - { - while (manager!=null) - { - String str = in.readLine(); - //logger.info("CLIENT: recv " + str + " from " + rPort); - - // TODO: Spawn this off into the GUI Event-Dispatch thread... - - // Convert the string back into something API friendly - Message message = strToMessage(str); - - // Ignore corrupted or unknown message types - if (message != null) - manager.processMessage(this, message); - } - } - catch (Exception e) - { - // Means the other end of the connection has (probably died) so we need - // terminate this endpoint (if this is server side) - //logger.info("CLIENT: read failed: " + e); - - terminate(); // this may not be necessary - probably caused infinite loop on terminate() without null checks - } - } - - void terminate() - { - SocketManager mgr=manager; - manager=null; // stops receive thread - if (socket!=null) { - try { socket.close(); } - catch (IOException e) {} - socket=null; + private SocketManager manager; + + PickEndPoint(SocketManager manager, Socket s) { + this.manager = manager; + socket = s; + } + + boolean openConnection() { + try { + // Create the socket if it doesn't already exist + if (socket == null) + socket = new Socket(InetAddress.getLocalHost(), PickServer.PORT); + + rPort = socket.getPort(); + socket.setKeepAlive(true); + + // Open the streams for reading/writing + os = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())); + in = new BufferedReader(new InputStreamReader(socket.getInputStream())); + + // Start the thread to listen for incoming messages + logger.debug("CLIENT: connection successful to port " + socket.getPort() + + " via port " + socket.getLocalPort()); + start(); + + return true; + } catch (Exception e) { + logger.info("CLIENT: connection failed: " + e); + return false; + } + } + + void send(Message message) { + try { + String str = message.getRawMessage(); + + // System.err.println("CLIENT: send " + str + " to " + rPort); + os.write(str); + + // We use a newline to terminate the message + os.newLine(); + os.flush(); + } catch (Exception e) { + // logger.info("CLIENT: failed to send"); + + // TODO: terminate the connection on a failed send or retry? (Has this + // been done? JBP) + terminate(); + } + } + + // void receive() (threaded) + public void run() { + try { + while (manager != null) { + String str = in.readLine(); + // logger.info("CLIENT: recv " + str + " from " + rPort); + + // TODO: Spawn this off into the GUI Event-Dispatch thread... + + // Convert the string back into something API friendly + Message message = strToMessage(str); + + // Ignore corrupted or unknown message types + if (message != null) + manager.processMessage(this, message); + } + } catch (Exception e) { + // Means the other end of the connection has (probably died) so we need + // terminate this endpoint (if this is server side) + // logger.info("CLIENT: read failed: " + e); + + terminate(); // this may not be necessary - probably caused infinite loop + // on terminate() without null checks + } + } + + void terminate() { + SocketManager mgr = manager; + manager = null; // stops receive thread + if (socket != null) { + try { + socket.close(); + } catch (IOException e) { + } + socket = null; } - //logger.info("CLIENT: closing connection to port " + socket.getPort()); - // terminate() can be called by the socket manager to shutdown the connection, + // logger.info("CLIENT: closing connection to port " + socket.getPort()); + // terminate() can be called by the socket manager to shutdown the + // connection, // or the receive thread after an exception has been received // (which includes the above case when the socket is closed. - // so we only want to removeEndPoint once - for the initial call to terminate() - if (mgr!=null) + // so we only want to removeEndPoint once - for the initial call to + // terminate() + if (mgr != null) mgr.removeEndPoint(this); - } - - private Message strToMessage(String str) - { - try - { - // System.err.println("Received Message\n*\n"+str+"*"); - if (str==null || str.length()==1) + } + + private Message strToMessage(String str) { + try { + // System.err.println("Received Message\n*\n"+str+"*"); + if (str == null || str.length() == 1) return null; - if (str.startsWith("CUSTOM")) - return new CustomMessage(str.substring(6)); - if (str.startsWith("MOUSEOVER")) - return new MouseOverMessage(str); - if (str.startsWith("SELECTION")) + if (str.startsWith("CUSTOM")) + return new CustomMessage(str.substring(6)); + if (str.startsWith("MOUSEOVER")) + return new MouseOverMessage(str); + if (str.startsWith("SELECTION")) return new SelectionMessage(str); - - } - catch (Exception e) - { - //logger.info("Unable to reconstruct message: " + e); - } - - return null; - } -} \ No newline at end of file + + } catch (Exception e) { + // logger.info("Unable to reconstruct message: " + e); + } + + return null; + } +} diff --git a/src/uk/ac/vamsas/client/picking/PickServer.java b/src/uk/ac/vamsas/client/picking/PickServer.java index 3198427..7a38be7 100644 --- a/src/uk/ac/vamsas/client/picking/PickServer.java +++ b/src/uk/ac/vamsas/client/picking/PickServer.java @@ -1,3 +1,24 @@ +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ package uk.ac.vamsas.client.picking; import java.io.*; @@ -9,90 +30,88 @@ import org.apache.commons.logging.Log; /** * Server class that listens for incoming connections on a predefined port. */ -class PickServer extends Thread -{ - private Log logger = org.apache.commons.logging.LogFactory.getLog(uk.ac.vamsas.client.picking.PickServer.class); - - // The port number we'll listen on - static final int PORT = 53782; - - private ServerSocket serverSocket; - // Set to true once the server is established - private boolean isServer = false; +class PickServer extends Thread { + private Log logger = org.apache.commons.logging.LogFactory + .getLog(uk.ac.vamsas.client.picking.PickServer.class); + + // The port number we'll listen on + static final int PORT = 53782; + + private ServerSocket serverSocket; + + // Set to true once the server is established + private boolean isServer = false; + // Set to false when server is shutting down - private boolean isAlive= true; - private SocketManager manager; - - /** - * Constructs a new instance of the server (but doesn't start it). - * @param manager a reference to the pick manager that owns this server - */ - PickServer(SocketManager manager) - { - this.manager = manager; - } - - /** - * Returns true if this server instance is running. - * Return true if this server instance is running - */ - boolean isServer() - { return isServer; } - - /** - * Attempts to create the server by opening a server socket on the port. - * @return true if the server was created; false otherwise - */ - boolean createServer() - { - try - { - serverSocket = new ServerSocket(PORT); - start(); - - return isServer = true; - } - catch (IOException e) - { - logger.debug("SERVER: " + e); - return false; - } - } - - /** - * Thread listening method - loops indefinitely listening for connections. - * When one is received, the socket object is passed to the manager so it - * can make a full client connection for further comms. - */ - public void run() - { - logger.debug("SERVER: listening on " + PORT + " - SERVER"); - - // Loop forever, accepting connectons from other clients - // TODO: add in the ability to terminate the server if a VAMSAS session - // is ended - while (isAlive) - { - try - { - Socket socket = serverSocket.accept(); - logger.info("SERVER: connection detected"); - if (isAlive) - manager.addEndPoint(socket); - } - catch (IOException e) {} - } - } - - void terminate() - { - logger.debug("Server shutting down..."); - isAlive=false; - try { serverSocket.close(); } - catch (Exception e) - { - logger.error(e); - } + private boolean isAlive = true; + + private SocketManager manager; + + /** + * Constructs a new instance of the server (but doesn't start it). + * + * @param manager + * a reference to the pick manager that owns this server + */ + PickServer(SocketManager manager) { + this.manager = manager; + } + + /** + * Returns true if this server instance is running. Return true if this server + * instance is running + */ + boolean isServer() { + return isServer; + } + + /** + * Attempts to create the server by opening a server socket on the port. + * + * @return true if the server was created; false otherwise + */ + boolean createServer() { + try { + serverSocket = new ServerSocket(PORT); + start(); + + return isServer = true; + } catch (IOException e) { + logger.debug("SERVER: " + e); + return false; + } + } + + /** + * Thread listening method - loops indefinitely listening for connections. + * When one is received, the socket object is passed to the manager so it can + * make a full client connection for further comms. + */ + public void run() { + logger.debug("SERVER: listening on " + PORT + " - SERVER"); + + // Loop forever, accepting connectons from other clients + // TODO: add in the ability to terminate the server if a VAMSAS session + // is ended + while (isAlive) { + try { + Socket socket = serverSocket.accept(); + logger.info("SERVER: connection detected"); + if (isAlive) + manager.addEndPoint(socket); + } catch (IOException e) { + } + } + } + + void terminate() { + logger.debug("Server shutting down..."); + isAlive = false; + try { + serverSocket.close(); + } catch (Exception e) { + logger.error(e); + } logger.debug("Server shut down complete."); - } -} \ No newline at end of file + } +} diff --git a/src/uk/ac/vamsas/client/picking/SelectionMessage.java b/src/uk/ac/vamsas/client/picking/SelectionMessage.java index d611437..32289aa 100644 --- a/src/uk/ac/vamsas/client/picking/SelectionMessage.java +++ b/src/uk/ac/vamsas/client/picking/SelectionMessage.java @@ -1,5 +1,23 @@ -/** +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ package uk.ac.vamsas.client.picking; @@ -22,7 +40,8 @@ public class SelectionMessage extends Message { RangeType ranges; - private boolean none=false; + private boolean none = false; + /** * parse a message payload as a selection message * @@ -44,13 +63,11 @@ public class SelectionMessage extends Message { if (elements[i].startsWith("ranges=")) { segs = elements[i].substring(7).split(","); } - if (elements[i].equals("none")) - { - none=true; + if (elements[i].equals("none")) { + none = true; } } - if (none) - { + if (none) { ranges = null; vorbaIDs = null; } @@ -85,20 +102,22 @@ public class SelectionMessage extends Message { /** * create a new selection message * - * @param selectionID - - * (may be null) optional handle (or ID) to refer to selection by - * @param vorbaIDs - - * one or more objects to be selected, or null for the empty selection + * @param selectionID + * - (may be null) optional handle (or ID) to refer to selection by + * @param vorbaIDs + * - one or more objects to be selected, or null for the empty + * selection * @param ranges * optional rangetype specifying positions or intervals over * object(s) coordinate system. */ public SelectionMessage(String selectionID, String[] vorbaIDs, RangeType ranges) { - this(selectionID,vorbaIDs,ranges,false); + this(selectionID, vorbaIDs, ranges, false); } - public SelectionMessage(String selectionID, String[] vorbaIDs, RangeType ranges, boolean none) - { + + public SelectionMessage(String selectionID, String[] vorbaIDs, + RangeType ranges, boolean none) { super(); this.selectionID = selectionID; if (selectionID != null && selectionID.indexOf("\t") > -1) { @@ -107,7 +126,7 @@ public class SelectionMessage extends Message { } this.vorbaIDs = vorbaIDs; this.ranges = ranges; - this.none=none; + this.none = none; StringBuffer message = new StringBuffer(); message.append("SELECTION\t"); if (selectionID != null) { @@ -132,21 +151,22 @@ public class SelectionMessage extends Message { } if (none) { // must have only IDs for the selection or the selection scope - no range - if (ranges!=null) - { + if (ranges != null) { throw new Error("Empty selection cannot specify a range."); } - if ((selectionID==null || selectionID.length()==0) && (vorbaIDs==null || vorbaIDs.length==0)) - { - throw new Error("Empty selection must have at least a selection ID or at least one vorbaID indicating selection scope."); + if ((selectionID == null || selectionID.length() == 0) + && (vorbaIDs == null || vorbaIDs.length == 0)) { + throw new Error( + "Empty selection must have at least a selection ID or at least one vorbaID indicating selection scope."); } message.append("none"); return; - } - // Verify that the range has at least one valid vorbaID for it to be defined on. - if (vorbaIDs==null || vorbaIDs.length==0) - { - throw new Error("You must specify at least one vorbaID for the selection."); + } + // Verify that the range has at least one valid vorbaID for it to be defined + // on. + if (vorbaIDs == null || vorbaIDs.length == 0) { + throw new Error( + "You must specify at least one vorbaID for the selection."); } if (ranges != null) { if (ranges.getPosCount() > 0) { diff --git a/src/uk/ac/vamsas/client/picking/SocketManager.java b/src/uk/ac/vamsas/client/picking/SocketManager.java index bc9dd59..a4ce769 100644 --- a/src/uk/ac/vamsas/client/picking/SocketManager.java +++ b/src/uk/ac/vamsas/client/picking/SocketManager.java @@ -1,3 +1,24 @@ +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ package uk.ac.vamsas.client.picking; import java.net.*; @@ -12,181 +33,182 @@ import org.apache.commons.logging.Log; * server for other clients; failing that, it attempts to connect to an existing * server instead. */ -public class SocketManager implements IPickManager -{ - private Log logger = org.apache.commons.logging.LogFactory.getLog(uk.ac.vamsas.client.picking.SocketManager.class); - - // Maintains a list of client communication objects - each object represents - // a way of talking to either: - // the server - if this is client side (and in which case, the list will only contain one element - // the other clients - if this is server side - private LinkedList clients; - - private PickServer server; - - private IMessageHandler msgHandler; - - private boolean isRunning = true; - - /** - * Constructs a new PickManager. This method will return immediately, while - * a looping thread runs that attempts to run the server or connect to an - * existing server. - */ - public SocketManager() - { - //logger.setLevel(Level.OFF); - - server = new PickServer(this); - clients = new LinkedList(); - - new InitializeThread().start(); - } - - /** - * Registers a message handler with the manager that allows the manager to - * perform a method callback on that object whenever a message is received. - * @param handler the message handler to register - */ - public void registerMessageHandler(IMessageHandler handler) - { - msgHandler = handler; - } - - /** - * Attempts to establish a connection between two client endpoints. This - * method is called in two ways: 1) by the server when it receives a remote - * request (in which case the socket will already be established) and 2) by - * a client that is attempting to connect *to* the server. - * @param socket a socket endpoint for the connection - * @return true if the connection is successfully, false otherwise - */ - synchronized boolean addEndPoint(Socket socket) - { - PickEndPoint client = new PickEndPoint(this, socket); - - if (client.openConnection()) - { - clients.add(client); - //logger.info("List now contains " + clients.size() + " client(s)"); - return true; - } - - return false; - } - - /** - * Sends a message to other clients. - * @param message the message to send - */ - public void sendMessage(Message message) - { - forwardMessage(null, message); - } - - /** - * Forwards (or sends) a message. When the server (client A) receives a - * message from client B, it must also forward it to clients C and D (etc), - * but mustn't forward it *back* to client B. - * @param origin the client endpoint that received the message (will be null - * if the message originates from this instance - * @param message the message to send - */ - private void forwardMessage(PickEndPoint origin, Message message) - { - for (int i = clients.size()-1; i >= 0; i--) - { - try - { - PickEndPoint client = (PickEndPoint) clients.get(i); - if (client != origin) - client.send(message); - } - catch (Exception e) - { - System.out.println("FORWARD: " + e); - } - } - } - - /** - * Handles a received message. If the manager is running in server mode, - * then it must ensure the message is also forwarded to the other clients. - * @param origin the client endpoint that received the message - * @message the message that was received - */ - void processMessage(PickEndPoint origin, Message message) - { - if (server.isServer()) - forwardMessage(origin, message); - - if (msgHandler != null) - msgHandler.handleMessage(message); -// else -// logger.info("No handler available to deal with incoming message"); - } - - /** - * Removes a client connection from the list when its connection is no - * longer valid. - * @param client the client endpoint to remove - */ - synchronized void removeEndPoint(PickEndPoint client) - { - clients.remove(client); - //logger.info("List now contains " + clients.size() + " client(s)"); - - // If there's no endpoints left, then we've lost all connections and - // need to reinitialize - but only if we've not been told to stop - if (clients.size() == 0 && isRunning) - new InitializeThread().start(); - } - - /** - * Thread extension class to handle the actual initialization - */ - private class InitializeThread extends Thread - { - public void run() - { - logger.debug("Initializing connection..."); - boolean connected = false; - - // Loop until we can get a connection (one way or the other) - while (!connected && isRunning) - { - // Sleep for a rnd time so we don't end up with all the VAMSAS - // apps trying to initialize servers at the same time - try { Thread.sleep((int)(10*Math.random())); } - catch (InterruptedException e) {} - - // Attempt to open the server port... - if (server.isServer() || server.createServer()) - connected = true; - - // If it fails, then attempt to make a client connection... - else if (addEndPoint(null)) - connected = true; - } +public class SocketManager implements IPickManager { + private Log logger = org.apache.commons.logging.LogFactory + .getLog(uk.ac.vamsas.client.picking.SocketManager.class); + + // Maintains a list of client communication objects - each object represents + // a way of talking to either: + // the server - if this is client side (and in which case, the list will only + // contain one element + // the other clients - if this is server side + private LinkedList clients; + + private PickServer server; + + private IMessageHandler msgHandler; + + private boolean isRunning = true; + + /** + * Constructs a new PickManager. This method will return immediately, while a + * looping thread runs that attempts to run the server or connect to an + * existing server. + */ + public SocketManager() { + // logger.setLevel(Level.OFF); + + server = new PickServer(this); + clients = new LinkedList(); + + new InitializeThread().start(); + } + + /** + * Registers a message handler with the manager that allows the manager to + * perform a method callback on that object whenever a message is received. + * + * @param handler + * the message handler to register + */ + public void registerMessageHandler(IMessageHandler handler) { + msgHandler = handler; + } + + /** + * Attempts to establish a connection between two client endpoints. This + * method is called in two ways: 1) by the server when it receives a remote + * request (in which case the socket will already be established) and 2) by a + * client that is attempting to connect *to* the server. + * + * @param socket + * a socket endpoint for the connection + * @return true if the connection is successfully, false otherwise + */ + synchronized boolean addEndPoint(Socket socket) { + PickEndPoint client = new PickEndPoint(this, socket); + + if (client.openConnection()) { + clients.add(client); + // logger.info("List now contains " + clients.size() + " client(s)"); + return true; + } + + return false; + } + + /** + * Sends a message to other clients. + * + * @param message + * the message to send + */ + public void sendMessage(Message message) { + forwardMessage(null, message); + } + + /** + * Forwards (or sends) a message. When the server (client A) receives a + * message from client B, it must also forward it to clients C and D (etc), + * but mustn't forward it *back* to client B. + * + * @param origin + * the client endpoint that received the message (will be null if the + * message originates from this instance + * @param message + * the message to send + */ + private void forwardMessage(PickEndPoint origin, Message message) { + for (int i = clients.size() - 1; i >= 0; i--) { + try { + PickEndPoint client = (PickEndPoint) clients.get(i); + if (client != origin) + client.send(message); + } catch (Exception e) { + System.out.println("FORWARD: " + e); + } + } + } + + /** + * Handles a received message. If the manager is running in server mode, then + * it must ensure the message is also forwarded to the other clients. + * + * @param origin + * the client endpoint that received the message + * @message the message that was received + */ + void processMessage(PickEndPoint origin, Message message) { + if (server.isServer()) + forwardMessage(origin, message); + + if (msgHandler != null) + msgHandler.handleMessage(message); + // else + // logger.info("No handler available to deal with incoming message"); + } + + /** + * Removes a client connection from the list when its connection is no longer + * valid. + * + * @param client + * the client endpoint to remove + */ + synchronized void removeEndPoint(PickEndPoint client) { + clients.remove(client); + // logger.info("List now contains " + clients.size() + " client(s)"); + + // If there's no endpoints left, then we've lost all connections and + // need to reinitialize - but only if we've not been told to stop + if (clients.size() == 0 && isRunning) + new InitializeThread().start(); + } + + /** + * Thread extension class to handle the actual initialization + */ + private class InitializeThread extends Thread { + public void run() { + logger.debug("Initializing connection..."); + boolean connected = false; + + // Loop until we can get a connection (one way or the other) + while (!connected && isRunning) { + // Sleep for a rnd time so we don't end up with all the VAMSAS + // apps trying to initialize servers at the same time + try { + Thread.sleep((int) (10 * Math.random())); + } catch (InterruptedException e) { + } + + // Attempt to open the server port... + if (server.isServer() || server.createServer()) + connected = true; + + // If it fails, then attempt to make a client connection... + else if (addEndPoint(null)) + connected = true; + } logger.debug("Completed initializing connection."); - } - } - - public void shutdown() - { - logger.debug("Shutting down socket manager."); + } + } + + public void shutdown() { + logger.debug("Shutting down socket manager."); if (server == null) - throw new Error("Client Implementation Error: shutdown() called on uninitialized SocketManager."); - - isRunning = false; - - if (server.isServer()) - server.terminate(); - - while (clients.size() > 0) { - logger.debug("Closing endpoint."); - ((PickEndPoint)clients.getFirst()).terminate(); - } + throw new Error( + "Client Implementation Error: shutdown() called on uninitialized SocketManager."); + + isRunning = false; + + if (server.isServer()) + server.terminate(); + + while (clients.size() > 0) { + logger.debug("Closing endpoint."); + ((PickEndPoint) clients.getFirst()).terminate(); + } logger.debug("Shutdown of socketmanager completed."); } -} \ No newline at end of file +} diff --git a/src/uk/ac/vamsas/client/picking/TestApp.java b/src/uk/ac/vamsas/client/picking/TestApp.java index bb27811..72a49a5 100644 --- a/src/uk/ac/vamsas/client/picking/TestApp.java +++ b/src/uk/ac/vamsas/client/picking/TestApp.java @@ -1,3 +1,24 @@ +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ package uk.ac.vamsas.client.picking; import java.util.logging.*; @@ -65,8 +86,9 @@ public class TestApp implements IMessageHandler { for (int id = 0; id < ids.length; id++) { ids[id] = "object" + id; } - - SelectionMessage sel = new SelectionMessage("mysel", ids, (ids.length>0) ? range : null,(ids.length==0) ? true : false); + + SelectionMessage sel = new SelectionMessage("mysel", ids, + (ids.length > 0) ? range : null, (ids.length == 0) ? true : false); sel.validate(); manager.sendMessage(sel); } catch (Exception e) { @@ -96,4 +118,4 @@ public class TestApp implements IMessageHandler { + sm.getRanges().getSegCount() + "intervals."))); } } -} \ No newline at end of file +} diff --git a/src/uk/ac/vamsas/client/simpleclient/ArchiveUrn.java b/src/uk/ac/vamsas/client/simpleclient/ArchiveUrn.java index e6184eb..84f8238 100644 --- a/src/uk/ac/vamsas/client/simpleclient/ArchiveUrn.java +++ b/src/uk/ac/vamsas/client/simpleclient/ArchiveUrn.java @@ -1,34 +1,57 @@ -package uk.ac.vamsas.client.simpleclient; - -import java.io.File; -import java.net.MalformedURLException; - -/** - * Vamsas Document URN for files understood by ArchiveReader and - * written by VamsasArchive. - * vdoc://{Absolute path to file} - * @author jimp - * - */ -public class ArchiveUrn extends uk.ac.vamsas.client.SessionUrn { - /** - * a simple vamsas document urn prefix - */ - public static String VAMSASDOCUMENT="vdoc"; - static { - TYPES.put(ArchiveUrn.VAMSASDOCUMENT, ArchiveUrn.class); - } - - public ArchiveUrn(File docLocation) throws MalformedURLException { - super(VAMSASDOCUMENT, docLocation.getAbsoluteFile().toURL()); - } - - /** - * TODO: LATER: think about this again. - * @return File(urn.getPath()) - */ - public File asFile() { - return new File(urn.getPath()); - } - // TODO: add abstract 'handler' methods for resolving the URN to a particular class -} +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ +package uk.ac.vamsas.client.simpleclient; + +import java.io.File; +import java.net.MalformedURLException; + +/** + * Vamsas Document URN for files understood by ArchiveReader and written by + * VamsasArchive. vdoc://{Absolute path to file} + * + * @author jimp + * + */ +public class ArchiveUrn extends uk.ac.vamsas.client.SessionUrn { + /** + * a simple vamsas document urn prefix + */ + public static String VAMSASDOCUMENT = "vdoc"; + static { + TYPES.put(ArchiveUrn.VAMSASDOCUMENT, ArchiveUrn.class); + } + + public ArchiveUrn(File docLocation) throws MalformedURLException { + super(VAMSASDOCUMENT, docLocation.getAbsoluteFile().toURL()); + } + + /** + * TODO: LATER: think about this again. + * + * @return File(urn.getPath()) + */ + public File asFile() { + return new File(urn.getPath()); + } + // TODO: add abstract 'handler' methods for resolving the URN to a particular + // class +} diff --git a/src/uk/ac/vamsas/client/simpleclient/ClientDocument.java b/src/uk/ac/vamsas/client/simpleclient/ClientDocument.java index b9e918e..a4b4971 100644 --- a/src/uk/ac/vamsas/client/simpleclient/ClientDocument.java +++ b/src/uk/ac/vamsas/client/simpleclient/ClientDocument.java @@ -1,5 +1,23 @@ /* - * + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ package uk.ac.vamsas.client.simpleclient; @@ -23,281 +41,302 @@ import uk.ac.vamsas.objects.utils.AppDataReference; import uk.ac.vamsas.test.objects.Core; /** - * Maintains a collection of vamsas objects, appdatas and states, - * and provides api for a SimpleClient's client. - * TODO: test and migrate ArchiveClient.getAppData methods to here and retest in ExampleApplication - * @author jimp + * Maintains a collection of vamsas objects, appdatas and states, and provides + * api for a SimpleClient's client. TODO: test and migrate + * ArchiveClient.getAppData methods to here and retest in ExampleApplication + * + * @author jimp */ -public class ClientDocument extends uk.ac.vamsas.client.ClientDocument implements IClientDocument { +public class ClientDocument extends uk.ac.vamsas.client.ClientDocument + implements IClientDocument { private static Log log = LogFactory.getLog(ClientDocument.class); + private VamsasDocument doc; + protected SimpleClient sclient; + protected VamsasArchive iohandler = null; + /** * indicate if new data has been incorporated */ private boolean isModified = false; + /** * Public method for internal use by SimpleClient. + * * @return true if document has been modified. */ public boolean isModified() { return isModified; } + /** - * - * prepare Application-side dataset from the vamsas Document iohandler - * @param doc - the dataset - * @param docHandler - the sessionFile IO handler - * @param Factory - the source of current and new vorbaIds - * @param sclient - the simpleclient instance + * + * prepare Application-side dataset from the vamsas Document iohandler + * + * @param doc + * - the dataset + * @param docHandler + * - the sessionFile IO handler + * @param Factory + * - the source of current and new vorbaIds + * @param sclient + * - the simpleclient instance */ - protected ClientDocument(VamsasDocument doc, VamsasArchive docHandler, IdFactory Factory, SimpleClient sclient) { + protected ClientDocument(VamsasDocument doc, VamsasArchive docHandler, + IdFactory Factory, SimpleClient sclient) { super(Factory.getVorbaIdHash(), Factory); - - + /** * prepare Application-side dataset from the vamsas Document iohandler */ this.sclient = sclient; iohandler = docHandler; this.doc = doc; - _VamsasRoots=doc.getVAMSAS(); + _VamsasRoots = doc.getVAMSAS(); } - + /* * (non-Javadoc) * - * @see uk.ac.vamsas.client.IClientDocument#getObject(uk.ac.vamsas.client.VorbaId) + * @see + * uk.ac.vamsas.client.IClientDocument#getObject(uk.ac.vamsas.client.VorbaId) */ public Vobject getObject(VorbaId id) { - if (vamsasObjects==null) { + if (vamsasObjects == null) { log.debug("getObject called on null objrefs list."); return null; } if (vamsasObjects.containsKey(id)) return (Vobject) vamsasObjects.get(id); - log.debug("Returning null Vobject reference for id "+id.getId()); + log.debug("Returning null Vobject reference for id " + id.getId()); return null; } - + /* * (non-Javadoc) * - * @see uk.ac.vamsas.client.IClientDocument#getObjects(uk.ac.vamsas.client.VorbaId[]) + * @see + * uk.ac.vamsas.client.IClientDocument#getObjects(uk.ac.vamsas.client.VorbaId + * []) */ public Vobject[] getObjects(VorbaId[] ids) { - if (vamsasObjects==null) { + if (vamsasObjects == null) { log.debug("getObject[] called on null vamsasObjects list."); return null; } Vobject[] vo = new Vobject[ids.length]; - for (int i=0,j=ids.length; i-1) { + if (k > -1) { if (isValidUpdate(newr[k], original[i], modflag)) { - // set by isValidUpdate if the hashcodes were really different from last store + // set by isValidUpdate if the hashcodes were really different from + // last store rts.add(newr[k]); - newr[k]=null; + newr[k] = null; } else { // LATER: try harder to merge ducument roots. - log.warn("Couldn't merge new VAMSAS root "+newr[k].getId()); + log.warn("Couldn't merge new VAMSAS root " + newr[k].getId()); newr[k] = null; // LATER: this means we ignore mangled roots. NOT GOOD } } else { @@ -306,136 +345,155 @@ public class ClientDocument extends uk.ac.vamsas.client.ClientDocument implement } } // add remaining (new) roots - for (int i=0,j=newr.length; i timeoutBeforeLastCycle) - { - if(this.handler != null ) - synchronized (this.handler) - { - this.callHandler(doclock); - } - } - //log.debug("no modification"); - return false; - } - if (this.isTimeOutEnable) this.cycleCountSinceModif =0; //change detected - if(this.handler != null ) - synchronized (this.handler) - { - this.callHandler(doclock); - } - - return true; - } - - - /** - * count of cycles since last modification on the file - */ - protected int cycleCountSinceModif =0; - - /** - * resets count of watch cycles (default value : 0) - * - */ - protected void resetCycleCount () - { - this.cycleCountSinceModif = 0; - } - - /** - * Increases the count of cycles - * - */ - protected void increaseCycleCount () - { - this.cycleCountSinceModif ++; - } - - /** - * Enable the time out if the timeout is greater than zero - * @param timeoutBeforeLastCycle the timeoutBeforeLastCycle to set - */ - public void setTimeoutBeforeLastCycle(int timeoutBeforeLastCycle) { - - this.timeoutBeforeLastCycle = timeoutBeforeLastCycle; - if (this.timeoutBeforeLastCycle>0) - isTimeOutEnable = true; - } - - /** - * Disables the checking on the count of cycles - * - */ - public void disableCycleTimeOut () - { - this.isTimeOutEnable = false; - } -} +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ +package uk.ac.vamsas.client.simpleclient; + +public class ClientSessionFileWatcherElement extends SessionFileWatcherElement { + + private static org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory + .getLog(VamsasFileWatcherElement.class); + + /** + * count of watch cycle before considering there is no other active client. + */ + private int timeoutBeforeLastCycle = -1; + + private boolean isTimeOutEnable = false; + + /** + * @param watcher + * @param handler + */ + public ClientSessionFileWatcherElement(SessionFile watcher, + WatcherCallBack handler) { + super(watcher, handler); + } + + /** + * @param watcher + * @param handler + * @param enableWatching + */ + public ClientSessionFileWatcherElement(SessionFile watcher, + WatcherCallBack handler, boolean enableWatching) { + super(watcher, handler, enableWatching); + } + + /** + * @see uk.ac.vamsas.client.simpleclient.WatcherElement#doWatch() * @return + * true if the handler was called for a changeEvent + */ + public boolean doWatch() { + if (!watchForChange || handler == null) { // log.debug("!watchForChange || handler==null"); + return false; + } + if (watcher == null) + initWatch(); // somehow not done the first time + handlerCalled = false; + Lock doclock = null; + try { + doclock = watcher.getChangedState(); + } catch (Exception e) { + log.error("Whilst watching " + watcher.getSubject(), e); + } + // log.debug("got lock watcher"); + if (doclock == null) {// no change detected + this.cycleCountSinceModif++; + if (this.isTimeOutEnable && cycleCountSinceModif > timeoutBeforeLastCycle) { + if (this.handler != null) + synchronized (this.handler) { + this.callHandler(doclock); + } + } + // log.debug("no modification"); + return false; + } + if (this.isTimeOutEnable) + this.cycleCountSinceModif = 0; // change detected + if (this.handler != null) + synchronized (this.handler) { + this.callHandler(doclock); + } + + return true; + } + + /** + * count of cycles since last modification on the file + */ + protected int cycleCountSinceModif = 0; + + /** + * resets count of watch cycles (default value : 0) + * + */ + protected void resetCycleCount() { + this.cycleCountSinceModif = 0; + } + + /** + * Increases the count of cycles + * + */ + protected void increaseCycleCount() { + this.cycleCountSinceModif++; + } + + /** + * Enable the time out if the timeout is greater than zero + * + * @param timeoutBeforeLastCycle + * the timeoutBeforeLastCycle to set + */ + public void setTimeoutBeforeLastCycle(int timeoutBeforeLastCycle) { + + this.timeoutBeforeLastCycle = timeoutBeforeLastCycle; + if (this.timeoutBeforeLastCycle > 0) + isTimeOutEnable = true; + } + + /** + * Disables the checking on the count of cycles + * + */ + public void disableCycleTimeOut() { + this.isTimeOutEnable = false; + } +} diff --git a/src/uk/ac/vamsas/client/simpleclient/ClientsFile.java b/src/uk/ac/vamsas/client/simpleclient/ClientsFile.java index e700ee4..f83324a 100644 --- a/src/uk/ac/vamsas/client/simpleclient/ClientsFile.java +++ b/src/uk/ac/vamsas/client/simpleclient/ClientsFile.java @@ -1,298 +1,355 @@ -package uk.ac.vamsas.client.simpleclient; - -import uk.ac.vamsas.client.*; - -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.ObjectInputStream; -import java.io.ObjectOutput; -import java.io.ObjectOutputStream; -import java.io.OutputStream; -import java.util.Vector; - -/** - * Handler for the clientsFile within a vamsas session thread. - * @author jim - */ -public class ClientsFile extends ListFile { - private static org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(ClientsFile.class); - /** - * number of my client in list - passed back when a client - * is added to list, and used (if valid) for quickly - * looking up presence of client handle in the list. - */ - private int syncnum = 1; - - public ClientsFile(File filelist) throws IOException { - super(filelist); - } - - /** - * internal method for getting clientList - ensures a lock has been made but - * does not release it. - * - * @return list of clients - */ - private ClientHandle[] retrieveClientHandles() { - if (lockFile()) { - try { - ClientHandle[] clients=null; - if (fileLock.length()>0) { - - ObjectInputStream is = new ObjectInputStream(fileLock.getBufferedInputStream(true)); - Object o; - o=is.readObject(); - if (o!=null) { - try { - clients = (ClientHandle[]) o; - } - catch (Exception e) { - System.err.println("Garbage in the clientHandle list "+this.sessionFile); - } - } - } - return clients; - } catch (FileNotFoundException e) { - // TODO Auto-generated catch block - e.printStackTrace(System.err); - } catch (Exception e) { - e.printStackTrace(System.err); - } - } - return null; - } - /** - * get the clientList from the file. May return null if lock failed! - * @return clientList - */ - public ClientHandle[] retrieveClientList() { - if (lockFile()) { - ClientHandle[] clients = retrieveClientHandles(); - unlockFile(); - return clients; - } - return null; - } - /** - * get list from the locked ClientList. - * @param extantlock - * @return clientList or null if lock failed (or file was empty) - */ - public ClientHandle[] retrieveClientList(Lock extantlock) { - if (lockFile(extantlock)) { - ClientHandle[] clients = retrieveClientHandles(); - unlockFile(); - return clients; - } - return null; - } - /** - * adds clientHandle me to the clientList under an existing lock extantLock. - * @param me - * @param extantLock - * @return client index in list or 0 if lock was invalid or addClient operation failed. - */ - public int addClient(ClientHandle me, Lock extantLock) { - return addClient(me, true, extantLock); - } - - /** - * adds clientHandle me to the clientList under an existing lock. - * @param me - clientHandle - * @param disambig - if true then add will fail if an identical clientHandle already exists - * @param extantLock - existing lock - * @return client index in list or 0 if addClient (or the lock) failed. - */ - - public int addClient(ClientHandle me, boolean disambig, Lock extantLock) { - if (lockFile(extantLock)) { - syncnum = addClient(me, disambig); - unlockFile(); - return syncnum; - } - return 0; - } - - /** - * adds the ClientHandle to the list - if it is not unique, then the - * ClientHandle object is modified to make it unique in the list. returns the - * clientNumber for the client in the session. - * - * @param me - * @return - */ - - public int addClient(ClientHandle me) { - syncnum = addClient(me, true); - unlockFile(); - return syncnum; - } - - /** - * removes 'me' from the session ClientList without complaint if 'me' isn't in the clientList already. - * @param me client handle to be removed - * @param clientlock existing lock passed from watcher. - */ - public void removeClient(ClientHandle me, Lock clientlock) { - int mynum=-1; - if (lockFile(clientlock)) { - ClientHandle[] clients = retrieveClientHandles(); - if (clients != null) { - if ((syncnum<=0 || syncnum>clients.length) || clients[syncnum-1]!=me) { - for (int i = 0, j = clients.length; i < j; i++) - if (clients[i].equals(me)) { - mynum=i; - break; - } - } else { - mynum=syncnum-1; - } - if (mynum>-1) { - ClientHandle[] newlist = new ClientHandle[clients.length - 1]; - for (int k=0,i = 0, j = clients.length; i < j; i++) - if (i!=mynum) - newlist[k++] = clients[i]; - if (!putClientList(newlist)) - throw new Error("Failed to write new clientList!"); // failed to put the clientList to disk. - } - } - unlockFile(); - } else { - throw new Error("Couldn't get lock for "+((sessionFile==null) ? "Unitialised sessionFile in ClientsFile" : sessionFile.getAbsolutePath())); - } - } - /** - * Adds a ClientHandle to the ClientList file - optionally disambiguating - * the ClientHandle (modifes the URN). - * Note: Caller is left to release the lock on the ClientList. - * @param me - * @param disambiguate - - * flag indicating if the URN for me should be disambiguated to - * differentiate between sessions. - * @return index of clientHandle in new list, or -1-position of existing - * clientHandle (if disambiguate is true) - */ - protected int addClient(ClientHandle me, boolean disambiguate) { - int newclient = 0; - int tries=5; - while (tries-->0 && !lockFile()) - try { Thread.sleep(1); } catch (Exception e){}; - if (lockFile()) { - ClientHandle[] clients = retrieveClientHandles(); - if (me.getClientUrn()==null) { - // TODO: move this into ClientUrn as a standard form method. - me.setClientUrn("vamsas://"+me.getClientName()+":"+me.getVersion()+"/"); - } - if (clients == null) { - clients = new ClientHandle[1]; - clients[0] = me; - newclient = 1; - } else { - int k = 0; - for (int i = 0, j = clients.length; i < j; i++) { - if (clients[i].equals(me)) { - if (disambiguate) { - while (clients[i].equals(me)) { - me.setClientUrn(me.getClientUrn() + k++); // TODO: make a better - // disambiguation of - // urn. - } - } else { - // will not write the ambiguous clientHandle to disk, just return - // its index. - return -1 - i; - } - } - } - int i, j; - ClientHandle[] newlist = new ClientHandle[clients.length + 1]; - for (i = 0, j = clients.length; i < j; i++) - newlist[i] = clients[i]; - newlist[j] = me; - clients = newlist; - newclient = j+1; - } - if (!putClientList(clients)) - return 0; // failed to put the clientList to disk. - } - return newclient; - } - /** - * when set true - get FileNotFoundExceptions on WinXP when writing to locked stream after the backup has been made (via the backupFile method) - */ - boolean backup=false; - /** - * safely writes clients array to the file referred to by sessionFile. - * - * @param clients - * @return true if successful write. Throws Errors otherwise. - */ - protected boolean putClientList(ClientHandle[] clients) { - if (lockFile()) { - File templist=null; - if (backup) { - templist = backupSessionFile(); - } - if (!backup || (templist != null)) { - int retries=3; - while (retries-->0) { - try { - ObjectOutputStream os = - new ObjectOutputStream(fileLock.getBufferedOutputStream(true)); - log.debug("About to write "+clients.length+" clientHandles to output stream."); - os.writeObject(clients); - os.close(); - // All done - remove the backup. - if (backup) - templist.delete(); - templist = null; - retries=-1; - } catch (Exception e) { - System.err - .println("Serious - problems writing to sessionFile."); - if (retries>0 && templist != null) { - System.err.println("Recovering from Backup in " - + templist.getAbsolutePath()); - templist.renameTo(fileLock.target); - } - e.printStackTrace(System.err); - } - } - if (retries>-2) { - System.err - .println("Serious - problems writing to sessionFile. Giving Up."); - return false; - } - } else { - throw new Error( - "Couldn't create backup of the clientList before writing to it!"); - } - } else { - throw new Error("Could not lock the clientList: " - + ((sessionFile == null) ? "Unitialized ClientsFile" - : " failed to get lock on " + sessionFile.getAbsolutePath())); - } - // successful! - return true; - } - - public void clearList() { - if (lockFile()) { - try { - FileOutputStream fout = fileLock.getFileOutputStream(true); - fout.flush(); - fout.close(); - } catch (Exception e) { - throw new Error("Problems trying to clear clientlist!",e); - - } - } - - } -} +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ +package uk.ac.vamsas.client.simpleclient; + +import uk.ac.vamsas.client.*; + +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.ObjectInputStream; +import java.io.ObjectOutput; +import java.io.ObjectOutputStream; +import java.io.OutputStream; +import java.util.Vector; + +/** + * Handler for the clientsFile within a vamsas session thread. + * + * @author jim + */ +public class ClientsFile extends ListFile { + private static org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory + .getLog(ClientsFile.class); + + /** + * number of my client in list - passed back when a client is added to list, + * and used (if valid) for quickly looking up presence of client handle in the + * list. + */ + private int syncnum = 1; + + public ClientsFile(File filelist) throws IOException { + super(filelist); + } + + /** + * internal method for getting clientList - ensures a lock has been made but + * does not release it. + * + * @return list of clients + */ + private ClientHandle[] retrieveClientHandles() { + if (lockFile()) { + try { + ClientHandle[] clients = null; + if (fileLock.length() > 0) { + + ObjectInputStream is = new ObjectInputStream(fileLock + .getBufferedInputStream(true)); + Object o; + o = is.readObject(); + if (o != null) { + try { + clients = (ClientHandle[]) o; + } catch (Exception e) { + System.err.println("Garbage in the clientHandle list " + + this.sessionFile); + } + } + } + return clients; + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(System.err); + } catch (Exception e) { + e.printStackTrace(System.err); + } + } + return null; + } + + /** + * get the clientList from the file. May return null if lock failed! + * + * @return clientList + */ + public ClientHandle[] retrieveClientList() { + if (lockFile()) { + ClientHandle[] clients = retrieveClientHandles(); + unlockFile(); + return clients; + } + return null; + } + + /** + * get list from the locked ClientList. + * + * @param extantlock + * @return clientList or null if lock failed (or file was empty) + */ + public ClientHandle[] retrieveClientList(Lock extantlock) { + if (lockFile(extantlock)) { + ClientHandle[] clients = retrieveClientHandles(); + unlockFile(); + return clients; + } + return null; + } + + /** + * adds clientHandle me to the clientList under an existing lock extantLock. + * + * @param me + * @param extantLock + * @return client index in list or 0 if lock was invalid or addClient + * operation failed. + */ + public int addClient(ClientHandle me, Lock extantLock) { + return addClient(me, true, extantLock); + } + + /** + * adds clientHandle me to the clientList under an existing lock. + * + * @param me + * - clientHandle + * @param disambig + * - if true then add will fail if an identical clientHandle already + * exists + * @param extantLock + * - existing lock + * @return client index in list or 0 if addClient (or the lock) failed. + */ + + public int addClient(ClientHandle me, boolean disambig, Lock extantLock) { + if (lockFile(extantLock)) { + syncnum = addClient(me, disambig); + unlockFile(); + return syncnum; + } + return 0; + } + + /** + * adds the ClientHandle to the list - if it is not unique, then the + * ClientHandle object is modified to make it unique in the list. returns the + * clientNumber for the client in the session. + * + * @param me + * @return + */ + + public int addClient(ClientHandle me) { + syncnum = addClient(me, true); + unlockFile(); + return syncnum; + } + + /** + * removes 'me' from the session ClientList without complaint if 'me' isn't in + * the clientList already. + * + * @param me + * client handle to be removed + * @param clientlock + * existing lock passed from watcher. + */ + public void removeClient(ClientHandle me, Lock clientlock) { + int mynum = -1; + if (lockFile(clientlock)) { + ClientHandle[] clients = retrieveClientHandles(); + if (clients != null) { + if ((syncnum <= 0 || syncnum > clients.length) + || clients[syncnum - 1] != me) { + for (int i = 0, j = clients.length; i < j; i++) + if (clients[i].equals(me)) { + mynum = i; + break; + } + } else { + mynum = syncnum - 1; + } + if (mynum > -1) { + ClientHandle[] newlist = new ClientHandle[clients.length - 1]; + for (int k = 0, i = 0, j = clients.length; i < j; i++) + if (i != mynum) + newlist[k++] = clients[i]; + if (!putClientList(newlist)) + throw new Error("Failed to write new clientList!"); // failed to put + // the + // clientList to + // disk. + } + } + unlockFile(); + } else { + throw new Error("Couldn't get lock for " + + ((sessionFile == null) ? "Unitialised sessionFile in ClientsFile" + : sessionFile.getAbsolutePath())); + } + } + + /** + * Adds a ClientHandle to the ClientList file - optionally disambiguating the + * ClientHandle (modifes the URN). Note: Caller is left to release the lock on + * the ClientList. + * + * @param me + * @param disambiguate + * - flag indicating if the URN for me should be disambiguated to + * differentiate between sessions. + * @return index of clientHandle in new list, or -1-position of existing + * clientHandle (if disambiguate is true) + */ + protected int addClient(ClientHandle me, boolean disambiguate) { + int newclient = 0; + int tries = 5; + while (tries-- > 0 && !lockFile()) + try { + Thread.sleep(1); + } catch (Exception e) { + } + ; + if (lockFile()) { + ClientHandle[] clients = retrieveClientHandles(); + if (me.getClientUrn() == null) { + // TODO: move this into ClientUrn as a standard form method. + me.setClientUrn("vamsas://" + me.getClientName() + ":" + + me.getVersion() + "/"); + } + if (clients == null) { + clients = new ClientHandle[1]; + clients[0] = me; + newclient = 1; + } else { + int k = 0; + for (int i = 0, j = clients.length; i < j; i++) { + if (clients[i].equals(me)) { + if (disambiguate) { + while (clients[i].equals(me)) { + me.setClientUrn(me.getClientUrn() + k++); // TODO: make a better + // disambiguation of + // urn. + } + } else { + // will not write the ambiguous clientHandle to disk, just return + // its index. + return -1 - i; + } + } + } + int i, j; + ClientHandle[] newlist = new ClientHandle[clients.length + 1]; + for (i = 0, j = clients.length; i < j; i++) + newlist[i] = clients[i]; + newlist[j] = me; + clients = newlist; + newclient = j + 1; + } + if (!putClientList(clients)) + return 0; // failed to put the clientList to disk. + } + return newclient; + } + + /** + * when set true - get FileNotFoundExceptions on WinXP when writing to locked + * stream after the backup has been made (via the backupFile method) + */ + boolean backup = false; + + /** + * safely writes clients array to the file referred to by sessionFile. + * + * @param clients + * @return true if successful write. Throws Errors otherwise. + */ + protected boolean putClientList(ClientHandle[] clients) { + if (lockFile()) { + File templist = null; + if (backup) { + templist = backupSessionFile(); + } + if (!backup || (templist != null)) { + int retries = 3; + while (retries-- > 0) { + try { + ObjectOutputStream os = new ObjectOutputStream(fileLock + .getBufferedOutputStream(true)); + log.debug("About to write " + clients.length + + " clientHandles to output stream."); + os.writeObject(clients); + os.close(); + // All done - remove the backup. + if (backup) + templist.delete(); + templist = null; + retries = -1; + } catch (Exception e) { + System.err.println("Serious - problems writing to sessionFile."); + if (retries > 0 && templist != null) { + System.err.println("Recovering from Backup in " + + templist.getAbsolutePath()); + templist.renameTo(fileLock.target); + } + e.printStackTrace(System.err); + } + } + if (retries > -2) { + System.err + .println("Serious - problems writing to sessionFile. Giving Up."); + return false; + } + } else { + throw new Error( + "Couldn't create backup of the clientList before writing to it!"); + } + } else { + throw new Error("Could not lock the clientList: " + + ((sessionFile == null) ? "Unitialized ClientsFile" + : " failed to get lock on " + sessionFile.getAbsolutePath())); + } + // successful! + return true; + } + + public void clearList() { + if (lockFile()) { + try { + FileOutputStream fout = fileLock.getFileOutputStream(true); + fout.flush(); + fout.close(); + } catch (Exception e) { + throw new Error("Problems trying to clear clientlist!", e); + + } + } + + } +} diff --git a/src/uk/ac/vamsas/client/simpleclient/EventGeneratorThread.java b/src/uk/ac/vamsas/client/simpleclient/EventGeneratorThread.java index d00e119..47c84ac 100644 --- a/src/uk/ac/vamsas/client/simpleclient/EventGeneratorThread.java +++ b/src/uk/ac/vamsas/client/simpleclient/EventGeneratorThread.java @@ -1,356 +1,430 @@ -package uk.ac.vamsas.client.simpleclient; - -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeSupport; -import java.util.Hashtable; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import uk.ac.vamsas.client.Events; - -/** - * monitors watcher objects and generates events. - */ -public class EventGeneratorThread { - private static Log log = LogFactory.getLog(EventGeneratorThread.class); - private SimpleClient client; - private Hashtable handlers; // manager object - private VamsasSession session; - /** - * thread watching all the session's file objects - */ - protected VamsasFileWatcherThread watchThread=null; - /** - * Watcher element for list of all the clientHandles for the session - */ - protected SessionFileWatcherElement clientfile=null; - /** - * the session's vamsasDocument - */ - protected VamsasFileWatcherElement vamsasfile=null; - /** - * written to by client when its app calls storeDocument. - */ - protected SessionFileWatcherElement storeFile=null; - - EventGeneratorThread(VamsasSession s, SimpleClient _client, Hashtable eventhandlers) { - if (eventhandlers==null || s==null || _client==null) - throw new Error("Null arguments to EventGeneratorThread constructor."); - handlers = eventhandlers; - session = s; - client = _client; - log.debug("Creating VamsasFileWatcherThread."); - watchThread = new VamsasFileWatcherThread(this); - initWatchers(); - } - - private void initWatchers() { - if (clientfile==null) { - log.debug("Initializing clientfile Watcher"); - clientfile = session.getClientWatcherElement(); - // handler is set in the Vamsas session -/* clientfile.setHandler(new WatcherCallBack() { - - public boolean handleWatchEvent(WatcherElement watcher, Lock lock) { - return clientListChanged(watcher, lock); - } - });*/ - watchThread.addElement(clientfile); - } - final EventGeneratorThread evgen=this; - - if (vamsasfile ==null) { - log.debug("Initializing VamsasFileWatcher"); - vamsasfile = new VamsasFileWatcherElement(session.vamArchive, - new WatcherCallBack() { - public boolean handleWatchEvent(WatcherElement watcher, Lock lock) { - return evgen.documentChanged(lock); - } - }); - watchThread.addElement(vamsasfile); - } - if (storeFile == null) { - storeFile = new SessionFileWatcherElement(session.getStoreDocFile(), - new WatcherCallBack() { - public boolean handleWatchEvent(WatcherElement watcher, Lock lock) { - return evgen.storeDocRequest(lock); - } - }); - log.debug("Initializing storeDocFile flag watcher"); - } - /* - */ - log.debug("Watchers inited."); - } - /** - * Call registered handlers for a vamsas session event - * @param handlerEvent a named event - * @param property property name to pass to handler - * @param oldval old value of property to pass - * @param newval new value of property to pass - * @return true if event generation did not raise any exceptions. - */ - boolean _raise(String handlerEvent, String property, Object oldval, Object newval) { - PropertyChangeSupport h = (PropertyChangeSupport) handlers.get(handlerEvent); - if (h!=null) { - log.debug("Triggering:"+handlerEvent); - try { - h.firePropertyChange(property, oldval, newval); - } catch (Exception e) { - log.warn("Client Exception during handling of "+handlerEvent, e); - return false; - } - catch (Error e) - { - log.error("Serious! Client Error during handling of "+handlerEvent, e); - return false; - } - log.debug("Finished :"+handlerEvent); - } else - log.debug("No handlers for raised "+handlerEvent); - return true; - } - protected boolean storeDocRequest(Lock lock) { - if (log.isDebugEnabled()) - log.debug("StoreDocRequest on "+(lock==null ? (lock.isLocked() ? "" : "Invalid ") : "Non-")+"Existing lock"); - // TODO: define the storeFile semaphore mechanism : file exists - all clients inform their apps, and then the client that wrote the file should delete the file (it should hold the lock to it). - if (storeFile.getWatcher().exists) { - _raise(Events.DOCUMENT_FINALIZEAPPDATA, client.getSessionUrn(), null, client); - // expect client to write to document so update watcher state on return - vamsasfile.getWatcher().setState(); - lock.release(); - } - return true; - } - - protected boolean documentChanged(Lock doclock) { - boolean continueWatching=true; - if (!block_document_updates) { - session.vamArchive.fileLock=doclock; - if (client.pickmanager!=null) - client.pickmanager.setPassThru(false); - if (log.isDebugEnabled()) { - log.debug("Initiating a documentChanged event. Document is "+(client.cdocument==null ? "closed" : "open")); - } - // TODO: decide if individual object update handlers are called as well as overall event handler - if (!_raise(Events.DOCUMENT_UPDATE, client.getSessionUrn(), null, client)) - { - log.info("Recovering from errors or exceptions generated by client application"); - if (client.cdocument!=null) - { - try { - client.tidyAwaySessionDocumentState(); - } - catch (Exception e) - { - log.warn("Exception generated by vamsas library - when tidying away session document:",e); - } - catch (Error e) - { - log.error("LIBRARY Implementation error - when tidying away session document:",e); - } - } - - } - if (client.pickmanager!=null) - client.pickmanager.setPassThru(true); - if (log.isDebugEnabled()) { - log.debug("Finished handling a documentChanged event. Document is "+(client.cdocument==null ? "closed" : "open")); - } - if (client.cdocument!=null) - { - log.warn("Implementation Error ? ClientDocument instance has not been closed or updated by handler!"); - } - /*try { - client._session.getVamsasDocument().closeArchive(); - } catch (Exception e) {log.warn("Unexpected exception when closing document after update.",e);}; - */ - } else { - // TODO: check documentChanged */ - log.debug("Ignoring documentChanged event for "+client.getSessionUrn()); - } - return continueWatching; - } - boolean ownsf = false; - /** - * Moved to SimpleClientSessionManager - * scans all watchers and fires changeEvents if necessary - * @return number of events generated. - */ - private boolean clientListChanged(WatcherElement clientfile, Lock watchlock) { - log.debug("ClientListChanged handler called for "+clientfile.getWatcher().getSubject()); - // could make this general - but for now keep simple - if (watchlock!=null) { - // TODO: compare new client list to old list version. is it changed ? - // see what happened to the clientfile - compare our internal version with the one in the file, or just send the updated list out...? - // - /** - * Generated when a new vamsas client is attached to a session (Handle is - * passed) Note: the newly created client does not receive the event. - * - public static final String CLIENT_CREATION = "uk.ac.vamsas.client.events.clientCreateEvent"; - */ // as the test - /** - * Generated when a vamsas client leaves a session (Handle is passed to all - * others). - public static final String CLIENT_FINALIZATION = "uk.ac.vamsas.client.events.clientFinalizationEvent"; - */ // again - as the test. - watchlock.release(); - } - return true; - } - /** - * Events raised by IClient and propagated to others in session - */ - - /** - * number of milliseconds between any file state check. - */ - long POLL_UNIT = 20; - protected void wait(int u) { - if (u<=0) - u=1; - long l = System.currentTimeMillis()+POLL_UNIT*u; - while (System.currentTimeMillis(). + */ +package uk.ac.vamsas.client.simpleclient; + +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; +import java.util.Hashtable; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import uk.ac.vamsas.client.Events; + +/** + * monitors watcher objects and generates events. + */ +public class EventGeneratorThread { + private static Log log = LogFactory.getLog(EventGeneratorThread.class); + + private SimpleClient client; + + private Hashtable handlers; // manager object + + private VamsasSession session; + + /** + * thread watching all the session's file objects + */ + protected VamsasFileWatcherThread watchThread = null; + + /** + * Watcher element for list of all the clientHandles for the session + */ + protected SessionFileWatcherElement clientfile = null; + + /** + * the session's vamsasDocument + */ + protected VamsasFileWatcherElement vamsasfile = null; + + /** + * written to by client when its app calls storeDocument. + */ + protected SessionFileWatcherElement storeFile = null; + + EventGeneratorThread(VamsasSession s, SimpleClient _client, + Hashtable eventhandlers) { + if (eventhandlers == null || s == null || _client == null) + throw new Error("Null arguments to EventGeneratorThread constructor."); + handlers = eventhandlers; + session = s; + client = _client; + log.debug("Creating VamsasFileWatcherThread."); + watchThread = new VamsasFileWatcherThread(this); + initWatchers(); + } + + private void initWatchers() { + if (clientfile == null) { + log.debug("Initializing clientfile Watcher"); + clientfile = session.getClientWatcherElement(); + // handler is set in the Vamsas session + /* + * clientfile.setHandler(new WatcherCallBack() { + * + * public boolean handleWatchEvent(WatcherElement watcher, Lock lock) { + * return clientListChanged(watcher, lock); } }); + */ + watchThread.addElement(clientfile); + } + final EventGeneratorThread evgen = this; + + if (vamsasfile == null) { + log.debug("Initializing VamsasFileWatcher"); + vamsasfile = new VamsasFileWatcherElement(session.vamArchive, + new WatcherCallBack() { + public boolean handleWatchEvent(WatcherElement watcher, Lock lock) { + return evgen.documentChanged(lock); + } + }); + watchThread.addElement(vamsasfile); + } + if (storeFile == null) { + storeFile = new SessionFileWatcherElement(session.getStoreDocFile(), + new WatcherCallBack() { + public boolean handleWatchEvent(WatcherElement watcher, Lock lock) { + return evgen.storeDocRequest(lock); + } + }); + log.debug("Initializing storeDocFile flag watcher"); + } + /* + */ + log.debug("Watchers inited."); + } + + /** + * Call registered handlers for a vamsas session event + * + * @param handlerEvent + * a named event + * @param property + * property name to pass to handler + * @param oldval + * old value of property to pass + * @param newval + * new value of property to pass + * @return true if event generation did not raise any exceptions. + */ + boolean _raise(String handlerEvent, String property, Object oldval, + Object newval) { + PropertyChangeSupport h = (PropertyChangeSupport) handlers + .get(handlerEvent); + if (h != null) { + log.debug("Triggering:" + handlerEvent); + try { + h.firePropertyChange(property, oldval, newval); + } catch (Exception e) { + log.warn("Client Exception during handling of " + handlerEvent, e); + return false; + } catch (Error e) { + log + .error("Serious! Client Error during handling of " + handlerEvent, + e); + return false; + } + log.debug("Finished :" + handlerEvent); + } else + log.debug("No handlers for raised " + handlerEvent); + return true; + } + + protected boolean storeDocRequest(Lock lock) { + if (log.isDebugEnabled()) + log.debug("StoreDocRequest on " + + (lock == null ? (lock.isLocked() ? "" : "Invalid ") : "Non-") + + "Existing lock"); + // TODO: define the storeFile semaphore mechanism : file exists - all + // clients inform their apps, and then the client that wrote the file should + // delete the file (it should hold the lock to it). + if (storeFile.getWatcher().exists) { + _raise(Events.DOCUMENT_FINALIZEAPPDATA, client.getSessionUrn(), null, + client); + // expect client to write to document so update watcher state on return + vamsasfile.getWatcher().setState(); + lock.release(); + } + return true; + } + + protected boolean documentChanged(Lock doclock) { + boolean continueWatching = true; + if (!block_document_updates) { + session.vamArchive.fileLock = doclock; + if (client.pickmanager != null) + client.pickmanager.setPassThru(false); + if (log.isDebugEnabled()) { + log.debug("Initiating a documentChanged event. Document is " + + (client.cdocument == null ? "closed" : "open")); + } + // TODO: decide if individual object update handlers are called as well as + // overall event handler + if (!_raise(Events.DOCUMENT_UPDATE, client.getSessionUrn(), null, client)) { + log + .info("Recovering from errors or exceptions generated by client application"); + if (client.cdocument != null) { + try { + client.tidyAwaySessionDocumentState(); + } catch (Exception e) { + log + .warn( + "Exception generated by vamsas library - when tidying away session document:", + e); + } catch (Error e) { + log + .error( + "LIBRARY Implementation error - when tidying away session document:", + e); + } + } + + } + if (client.pickmanager != null) + client.pickmanager.setPassThru(true); + if (log.isDebugEnabled()) { + log.debug("Finished handling a documentChanged event. Document is " + + (client.cdocument == null ? "closed" : "open")); + } + if (client.cdocument != null) { + log + .warn("Implementation Error ? ClientDocument instance has not been closed or updated by handler!"); + } + /* + * try { client._session.getVamsasDocument().closeArchive(); } catch + * (Exception e) + * {log.warn("Unexpected exception when closing document after update." + * ,e);}; + */ + } else { + // TODO: check documentChanged */ + log.debug("Ignoring documentChanged event for " + client.getSessionUrn()); + } + return continueWatching; + } + + boolean ownsf = false; + + /** + * Moved to SimpleClientSessionManager scans all watchers and fires + * changeEvents if necessary + * + * @return number of events generated. + */ + private boolean clientListChanged(WatcherElement clientfile, Lock watchlock) { + log.debug("ClientListChanged handler called for " + + clientfile.getWatcher().getSubject()); + // could make this general - but for now keep simple + if (watchlock != null) { + // TODO: compare new client list to old list version. is it changed ? + // see what happened to the clientfile - compare our internal version with + // the one in the file, or just send the updated list out...? + // + /** + * Generated when a new vamsas client is attached to a session (Handle is + * passed) Note: the newly created client does not receive the event. + * + * public static final String CLIENT_CREATION = + * "uk.ac.vamsas.client.events.clientCreateEvent"; + */ + // as the test + /** + * Generated when a vamsas client leaves a session (Handle is passed to + * all others). public static final String CLIENT_FINALIZATION = + * "uk.ac.vamsas.client.events.clientFinalizationEvent"; + */ + // again - as the test. + watchlock.release(); + } + return true; + } + + /** + * Events raised by IClient and propagated to others in session + */ + + /** + * number of milliseconds between any file state check. + */ + long POLL_UNIT = 20; + + protected void wait(int u) { + if (u <= 0) + u = 1; + long l = System.currentTimeMillis() + POLL_UNIT * u; + while (System.currentTimeMillis() < l) + ; + } + + private boolean block_document_updates = false; + + int STORE_WAIT = 5; // how many units before we decide all clients have + // finalized their appdatas + + private boolean in_want_to_store_phase = false; + + /** + * client App requests offline storage of vamsas data. Call blocks whilst + * other apps do any appData finalizing and then returns (after locking the + * vamsasDocument in the session) Note - the calling app may also receive + * events through the EventGeneratorThread for document updates. + * + * @return Lock for session.vamArchive + * @param STORE_WAIT + * indicates how lock the call will block for when nothing appears to + * be happening to the session. + */ + protected Lock want_to_store() { + if (in_want_to_store_phase) { + log + .error("client error: want_to_store called again before first call has completed."); + return null; + } + in_want_to_store_phase = true; + // TODO: test the storeDocumentRequest mechanism + /* + * / watchThread.haltWatchers(); + */ + log.debug("Stopping document_update watcher"); + vamsasfile.haltWatch(); + // block_document_updates=true; + log.debug("Cleared flag for ignoring document_update requests"); + + log.debug("Sending Store Document Request"); + try { + session.addStoreDocumentRequest(client.getClientHandle(), client + .getUserHandle()); + } catch (Exception e) { + log.warn("Whilst writing StoreDocumentRequest for " + + client.getClientHandle().getClientUrn() + " " + + client.getUserHandle(), e); + log.info("trying to continue after storeDocumentRequest exception."); + } + log.debug("Waiting for other apps to do FinalizeApp handling."); + // LATER: refine this semaphore process + // to make a robust signalling mechanism: + // app1 requests, app1..n do something (or don't - they may be dead), + // app1 realises all apps have done their thing, it then continues with + // synchronized data. + // this probably needs two files - a request file, + // and a response file which is acknowledged by the app1 requestor for each + // app. + // eventually, no more responses are received for the request, and the app + // can then only continue with its store. + FileWatcher sfwatcher = session.getStoreWatcher(); + FileWatcher vfwatcher = session.getDocWatcher(); + int units = 0; // zero if updates occured over a sleep period + while (units < STORE_WAIT) { + try { + Thread.sleep(watchThread.WATCH_SLEEP); + } catch (InterruptedException e) { + log.debug("interrupted."); + } + if (sfwatcher.hasChanged() || vfwatcher.hasChanged()) { + units = 0; + } else { + units++; + } + } + + block_document_updates = false; + vamsasfile.enableWatch(); + log.debug("Cleared flag for ignoring document_update requests"); + // wait around again (until our own watcher has woken up and synchronized). + while (units < STORE_WAIT) { + try { + Thread.sleep(watchThread.WATCH_SLEEP); + } catch (InterruptedException e) { + log.debug("interrupted."); + } + if (sfwatcher.hasChanged() || vfwatcher.hasChanged()) + units = 0; + else + units++; + } + + log.debug("finished waiting."); + in_want_to_store_phase = false; + return session.vamArchive.getLock(); + } + + /** + * count handlers for a particular vamsas event + * + * @param event + * string enumeration from uk.ac.vamsas.client.Events + * @return -1 for an invalid event, otherwise the number of handlers + */ + protected int countHandlersFor(String event) { + if (handlers.containsKey(event)) { + PropertyChangeSupport handler = (PropertyChangeSupport) handlers + .get(event); + PropertyChangeListener[] listeners; + if (handler != null) + return ((listeners = handler.getPropertyChangeListeners()) == null) ? -1 + : listeners.length; + } + return -1; + } + + public void disableDocumentWatch() { + vamsasfile.haltWatch(); + } + + public boolean isDocumentWatchEnabled() { + return (vamsasfile != null) && vamsasfile.isWatchEnabled(); + } + + public void enableDocumentWatch() { + vamsasfile.enableWatch(); + } + + public boolean isWatcherAlive() { + return watchThread != null && watchThread.running && watchThread.isAlive(); + } + + public void interruptWatching() { + if (watchThread != null && watchThread.isAlive()) { + // TODO: find a way of interrupting watcher in a way that prevents file IO + // being interrupted + watchThread.interrupt(); + } + + } + + /** + * called to start the session watching thread which generates events + */ + public void startWatching() { + enableDocumentWatch(); + watchThread.start(); + while (!watchThread.running && watchThread.isAlive()) + log.debug("Waiting until watcher is really started."); + } + + public void stopWatching() { + interruptWatching(); + watchThread.haltWatchers(); + + } + +} diff --git a/src/uk/ac/vamsas/client/simpleclient/FileLock.java b/src/uk/ac/vamsas/client/simpleclient/FileLock.java index 8a340c3..b5ddbf3 100644 --- a/src/uk/ac/vamsas/client/simpleclient/FileLock.java +++ b/src/uk/ac/vamsas/client/simpleclient/FileLock.java @@ -1,229 +1,272 @@ -package uk.ac.vamsas.client.simpleclient; - -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.RandomAccessFile; -import java.nio.channels.FileChannel; -import java.nio.channels.ReadableByteChannel; -/** - * File based Locking mechanism to get around some bizarre limitations of JarEntry seeking. - * Abstract locks have a target file, to which access is controlled when a lock is held. Native locks on WindowsXP seem to conflict with Jar seek operations, so a file lock creates an advisory lock. - * Method: - * A lock file is created, if it doesn't already exist - the naming convention is TargetFile+suffixSeparator+_LockSuffix. - * A lock is obtained by locking the lock file with a native lock. The NativeLock is used for this. - * @author JimP - * - */ -public class FileLock extends Lock { - private File _lock = null; - protected static String _LockSuffix="lck"; - private NativeLock advisory=null; - /** - * ensure that the _lock file exists - * and create a lock - */ - private boolean ensureLockFile(boolean block) { - if (_lock==null) - return false; - if (advisory!=null && advisory.isLocked()) - return true; - try { - advisory=new NativeLock(_lock, block); - } catch (Exception e) { - if (!_lock.exists()) { - // advisory cannot be created. this is serious. - log.fatal("Failed to create advisory lock file "+_lock,e); - throw new Error("Failed to create advisory lock file "+_lock); - } - } - return (advisory!=null) && advisory.isLocked(); - } - /** - * call to clear up a filelock file after its been made - * - */ - private void tidy() { - if (_lock!=null) { - if ( advisory!=null) { - // TODO: fix occasional exceptions raised here (usually on JVM shutdown) - if (advisory.target!=null) { - advisory.target.deleteOnExit(); // release will null the target - } - advisory.release(true); - } - advisory=null; - _lock=null; - } - } - /** - * @param lockfile - * @param block true means thread blocks until FileLock is obtained. - */ - public FileLock(File lockfile, boolean block) { - super(lockfile); - // try and get a lock. - try { - _lock = make_lockForTarget(lockfile); - if (!ensureLockFile(block)) { - log.debug("Couldn't get lock on "+_lock); - tidy(); - return; - } - // create target file ready to be written to if necessary. - if (!lockfile.exists()) - if (!lockfile.createNewFile()) { - log.warn("Failed to create locked file "+lockfile); - return; - } - //openRaFile(); - } catch (FileNotFoundException e) { - // - log.debug("FileLock failed with target="+lockfile+" and lockfile suffix of "+_LockSuffix); - //log.error("Error! Couldn't create a lockfile at " - // + lockfile.getAbsolutePath(), e); - } catch (IOException e) { - log.error("Error! Problems with IO when creating a lock on " - + lockfile.getAbsolutePath(),e); - } - } - /** - * - * @param lockfile target of lock - * @return file object that will be locked for lockfile - */ - private File make_lockForTarget(File lockfile) { - return new File(lockfile.getParentFile(), lockfile.getName()+"."+_LockSuffix); - } - private boolean openRaFile() throws IOException { - if (target==null) - return false; - if (advisory==null || !advisory.isLocked()) - return false; - if (rafile==null || rafile.getFD()==null || !rafile.getFD().valid()) { - rafile=new RandomAccessFile(target,"rw"); - } else { - if (log.isDebugEnabled()) - log.debug("Reusing existing RandomAccessFile on "+target); - } - return (rafile.getChannel()!=null) && rafile.getChannel().isOpen(); - } - - public boolean isLocked() { - if (advisory != null) { - if (advisory.isLocked()) - return true; - advisory=null; - if (log.isDebugEnabled()) - log.debug("Lockfile "+_lock+" unexpectedly deleted ?"); - } - return false; - } - - public void release() { - release(true); - } - - public void release(boolean closeChannel) { - if (!isLocked()) - return; - if (rafile!=null) { - if (closeChannel) { - try { - rafile.close(); - } catch (Exception e) { - log.debug("Unexpected exception whilst closing RandomAccessFile on "+target, e); - } - rafile=null; // do not hold reference to rafile anymore either - } - if (log.isDebugEnabled()) - log.debug("Releasing advisory lock on "+target); - // TODO: LATER: verify this change in closeChannel semantics really is correct - ArchiveClient works correctly - } - tidy(); - } - - public FileInputStream getFileInputStream(boolean atStart) throws IOException { - if (!isLocked()) { - log.debug("Don't hold lock on "+target+" to get locked FileInputStream."); - return null; - } - openRaFile(); - if (atStart) - rafile.seek(0); - return new FileInputStream(rafile.getFD()); - } - - - public FileOutputStream getFileOutputStream(boolean clear) throws IOException { - if (!isLocked()) { - log.debug("Don't hold lock on "+target+" to get locked FileOutputStream."); - return null; - } - openRaFile(); - if (clear) { - rafile.seek(0); - rafile.setLength(0); - } else - rafile.seek(rafile.length()); - return new LockedFileOutputStream(rafile.getFD()); - } - - - public BufferedOutputStream getBufferedOutputStream(boolean clear) throws IOException { - log.debug("Getting BufferedOutputStream (clear="+clear+")"); - FileOutputStream fos = getFileOutputStream(clear); - if (fos!=null) - return new BufferedOutputStream(fos); - return null; - } - - /* (non-Javadoc) - * @see uk.ac.vamsas.client.simpleclient.Lock#getLength() - */ - public long length() { - if (isLocked()) { - if (!target.exists()) { - try { - target.createNewFile(); - } catch (Exception e) { - log.error("Invalid lock:Failed to create target file "+target); - tidy(); - return -1; - } - return 0; - } - return target.length(); - } - return -1; - } - protected void finalize() throws Throwable { - release(true); // we explicitly lose the lock here. - super.finalize(); - } - public RandomAccessFile getRaFile() throws IOException { - if (isLocked() && openRaFile()) { - return rafile; - } - log.debug("Failed to getRaFile on target "+target); - return null; - } - public FileChannel getRaChannel() throws IOException { - if (isLocked() && openRaFile()) { - return rafile.getChannel(); - } - log.debug("Failed to getRaChannel on target "+target); - return null; - } - public boolean isTargetLockFile(File afile) { - if (isLocked()) - { - if (target.equals(afile) || make_lockForTarget(target).equals(afile)) - return true; - } - return false; - } -} +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ +package uk.ac.vamsas.client.simpleclient; + +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.RandomAccessFile; +import java.nio.channels.FileChannel; +import java.nio.channels.ReadableByteChannel; + +/** + * File based Locking mechanism to get around some bizarre limitations of + * JarEntry seeking. Abstract locks have a target file, to which access is + * controlled when a lock is held. Native locks on WindowsXP seem to conflict + * with Jar seek operations, so a file lock creates an advisory lock. Method: A + * lock file is created, if it doesn't already exist - the naming convention is + * TargetFile+suffixSeparator+_LockSuffix. A lock is obtained by locking the + * lock file with a native lock. The NativeLock is used for this. + * + * @author JimP + * + */ +public class FileLock extends Lock { + private File _lock = null; + + protected static String _LockSuffix = "lck"; + + private NativeLock advisory = null; + + /** + * ensure that the _lock file exists and create a lock + */ + private boolean ensureLockFile(boolean block) { + if (_lock == null) + return false; + if (advisory != null && advisory.isLocked()) + return true; + try { + advisory = new NativeLock(_lock, block); + } catch (Exception e) { + if (!_lock.exists()) { + // advisory cannot be created. this is serious. + log.fatal("Failed to create advisory lock file " + _lock, e); + throw new Error("Failed to create advisory lock file " + _lock); + } + } + return (advisory != null) && advisory.isLocked(); + } + + /** + * call to clear up a filelock file after its been made + * + */ + private void tidy() { + if (_lock != null) { + if (advisory != null) { + // TODO: fix occasional exceptions raised here (usually on JVM shutdown) + if (advisory.target != null) { + advisory.target.deleteOnExit(); // release will null the target + } + advisory.release(true); + } + advisory = null; + _lock = null; + } + } + + /** + * @param lockfile + * @param block + * true means thread blocks until FileLock is obtained. + */ + public FileLock(File lockfile, boolean block) { + super(lockfile); + // try and get a lock. + try { + _lock = make_lockForTarget(lockfile); + if (!ensureLockFile(block)) { + log.debug("Couldn't get lock on " + _lock); + tidy(); + return; + } + // create target file ready to be written to if necessary. + if (!lockfile.exists()) + if (!lockfile.createNewFile()) { + log.warn("Failed to create locked file " + lockfile); + return; + } + // openRaFile(); + } catch (FileNotFoundException e) { + // + log.debug("FileLock failed with target=" + lockfile + + " and lockfile suffix of " + _LockSuffix); + // log.error("Error! Couldn't create a lockfile at " + // + lockfile.getAbsolutePath(), e); + } catch (IOException e) { + log.error("Error! Problems with IO when creating a lock on " + + lockfile.getAbsolutePath(), e); + } + } + + /** + * + * @param lockfile + * target of lock + * @return file object that will be locked for lockfile + */ + private File make_lockForTarget(File lockfile) { + return new File(lockfile.getParentFile(), lockfile.getName() + "." + + _LockSuffix); + } + + private boolean openRaFile() throws IOException { + if (target == null) + return false; + if (advisory == null || !advisory.isLocked()) + return false; + if (rafile == null || rafile.getFD() == null || !rafile.getFD().valid()) { + rafile = new RandomAccessFile(target, "rw"); + } else { + if (log.isDebugEnabled()) + log.debug("Reusing existing RandomAccessFile on " + target); + } + return (rafile.getChannel() != null) && rafile.getChannel().isOpen(); + } + + public boolean isLocked() { + if (advisory != null) { + if (advisory.isLocked()) + return true; + advisory = null; + if (log.isDebugEnabled()) + log.debug("Lockfile " + _lock + " unexpectedly deleted ?"); + } + return false; + } + + public void release() { + release(true); + } + + public void release(boolean closeChannel) { + if (!isLocked()) + return; + if (rafile != null) { + if (closeChannel) { + try { + rafile.close(); + } catch (Exception e) { + log.debug("Unexpected exception whilst closing RandomAccessFile on " + + target, e); + } + rafile = null; // do not hold reference to rafile anymore either + } + if (log.isDebugEnabled()) + log.debug("Releasing advisory lock on " + target); + // TODO: LATER: verify this change in closeChannel semantics really is + // correct - ArchiveClient works correctly + } + tidy(); + } + + public FileInputStream getFileInputStream(boolean atStart) throws IOException { + if (!isLocked()) { + log.debug("Don't hold lock on " + target + + " to get locked FileInputStream."); + return null; + } + openRaFile(); + if (atStart) + rafile.seek(0); + return new FileInputStream(rafile.getFD()); + } + + public FileOutputStream getFileOutputStream(boolean clear) throws IOException { + if (!isLocked()) { + log.debug("Don't hold lock on " + target + + " to get locked FileOutputStream."); + return null; + } + openRaFile(); + if (clear) { + rafile.seek(0); + rafile.setLength(0); + } else + rafile.seek(rafile.length()); + return new LockedFileOutputStream(rafile.getFD()); + } + + public BufferedOutputStream getBufferedOutputStream(boolean clear) + throws IOException { + log.debug("Getting BufferedOutputStream (clear=" + clear + ")"); + FileOutputStream fos = getFileOutputStream(clear); + if (fos != null) + return new BufferedOutputStream(fos); + return null; + } + + /* + * (non-Javadoc) + * + * @see uk.ac.vamsas.client.simpleclient.Lock#getLength() + */ + public long length() { + if (isLocked()) { + if (!target.exists()) { + try { + target.createNewFile(); + } catch (Exception e) { + log.error("Invalid lock:Failed to create target file " + target); + tidy(); + return -1; + } + return 0; + } + return target.length(); + } + return -1; + } + + protected void finalize() throws Throwable { + release(true); // we explicitly lose the lock here. + super.finalize(); + } + + public RandomAccessFile getRaFile() throws IOException { + if (isLocked() && openRaFile()) { + return rafile; + } + log.debug("Failed to getRaFile on target " + target); + return null; + } + + public FileChannel getRaChannel() throws IOException { + if (isLocked() && openRaFile()) { + return rafile.getChannel(); + } + log.debug("Failed to getRaChannel on target " + target); + return null; + } + + public boolean isTargetLockFile(File afile) { + if (isLocked()) { + if (target.equals(afile) || make_lockForTarget(target).equals(afile)) + return true; + } + return false; + } +} diff --git a/src/uk/ac/vamsas/client/simpleclient/FileWatcher.java b/src/uk/ac/vamsas/client/simpleclient/FileWatcher.java index 93df102..1fc1476 100644 --- a/src/uk/ac/vamsas/client/simpleclient/FileWatcher.java +++ b/src/uk/ac/vamsas/client/simpleclient/FileWatcher.java @@ -1,174 +1,209 @@ -/** - * - */ -package uk.ac.vamsas.client.simpleclient; - -import java.io.File; - - -/** - * Watches a particular file for its creation, deletion, or - * modification. The watcher is thread safe and different - * instances watching the state of a particular file carry - * their own state record for the file. - */ -public class FileWatcher { - - private File subject = null; - - private long lastStat[]; - boolean waslocked=false; - boolean exists = false; - /** - * transient lock on subject - can be passed back to calling class - * to preserve new state of file for immediate reading. - */ - private Lock subjectLock = null; - /** - * clear local locks on subject. - * - */ - private void clearLock() { - if (subjectLock!=null) - subjectLock.release(); - subjectLock=null; - } - /** - * - * @return true if subject exists and is locked by another process. - */ - private boolean checkLock() { - if (subject!=null && subject.exists()) { - if (subjectLock!=null) { - subjectLock.release(); - } - subjectLock = LockFactory.tryLock(subject); - if (subjectLock.isLocked()) { - return false; - } - clearLock(); - return true; - } - return false; - } - - private long[] getStat(File subject) { - return new long[] { subject.lastModified(), subject.length() }; - } - private boolean compStat(long[] stat, long[] newstat) { - if (stat[0]!=newstat[0] || stat[1]!=newstat[1]) - return false; - return true; - } - /** - * Detect changes in file state and release of any - * lock in place during change. - * @return true if file state has changed. Leaves lock in subjectLock (ready to be passed to caller) - */ - private boolean check() { - if (subject != null) { - if (!subject.exists()) { - if (exists) { - if (!waslocked) { - // !checkLock()) { - - exists = false; - // waslocked=false; - return true; - } - } - // locked - state change registered after lock is released - return false; - } else { - long[] newStat = getStat(subject); // subject.lastModified(); - if (!checkLock()) { - // file is free to access, return state change - if (!exists || !compStat(lastStat, newStat)) { - waslocked=false; - exists=true; - lastStat=newStat; - return true; - } - // no change - return false; - } else { - waslocked=true; - return false; - } - } - } - return false; - } - /** - * updates internal record of file state when caller has intentionally - * modified subject. (ignores locked-state of subject) - */ - public void setState() { - if (subject!=null) { - if (exists = subject.exists()) { - lastStat = getStat(subject); - waslocked = false; - } - } - } - - /** - * Make a watcher for a particular file. If the file doesn't exist, the - * watcher will watch for its creation (and indicate a change of state) - * For locked files, the removal of a lock constitutes a change of - * state if the file was modified. - * - * @param subject - */ - - public FileWatcher(File subject) { - this.subject = subject; - setState(); - } - /** - * Test for change in file state. Only indicates a change - * after any lock on a file has been released. - * @return true if file has been modified. - */ - public boolean hasChanged() { - boolean res = check(); - clearLock(); - return res; - } - /** - * passes lock back to caller if hasChanged returned true. - * @return - */ - public Lock getChangedState() { - boolean res = check(); - if (res) - return subjectLock; - else { - clearLock(); - return null; - } - } - /** - * safely? getting current state of the watched file - * @return - */ - public long[] getCurrentState() { - return getStat(subject); - } - /** - * safely compare an externally recorded state with the current state - * for significant modifications. - * @param a - * @param b - * @return - */ - public boolean diffState(long[] a, long[] b) { - return compStat(a,b); - } - /** - * @return the subject - */ - public File getSubject() { - return subject; - } -} +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ +package uk.ac.vamsas.client.simpleclient; + +import java.io.File; + +/** + * Watches a particular file for its creation, deletion, or modification. The + * watcher is thread safe and different instances watching the state of a + * particular file carry their own state record for the file. + */ +public class FileWatcher { + + private File subject = null; + + private long lastStat[]; + + boolean waslocked = false; + + boolean exists = false; + + /** + * transient lock on subject - can be passed back to calling class to preserve + * new state of file for immediate reading. + */ + private Lock subjectLock = null; + + /** + * clear local locks on subject. + * + */ + private void clearLock() { + if (subjectLock != null) + subjectLock.release(); + subjectLock = null; + } + + /** + * + * @return true if subject exists and is locked by another process. + */ + private boolean checkLock() { + if (subject != null && subject.exists()) { + if (subjectLock != null) { + subjectLock.release(); + } + subjectLock = LockFactory.tryLock(subject); + if (subjectLock.isLocked()) { + return false; + } + clearLock(); + return true; + } + return false; + } + + private long[] getStat(File subject) { + return new long[] { subject.lastModified(), subject.length() }; + } + + private boolean compStat(long[] stat, long[] newstat) { + if (stat[0] != newstat[0] || stat[1] != newstat[1]) + return false; + return true; + } + + /** + * Detect changes in file state and release of any lock in place during + * change. + * + * @return true if file state has changed. Leaves lock in subjectLock (ready + * to be passed to caller) + */ + private boolean check() { + if (subject != null) { + if (!subject.exists()) { + if (exists) { + if (!waslocked) { + // !checkLock()) { + + exists = false; + // waslocked=false; + return true; + } + } + // locked - state change registered after lock is released + return false; + } else { + long[] newStat = getStat(subject); // subject.lastModified(); + if (!checkLock()) { + // file is free to access, return state change + if (!exists || !compStat(lastStat, newStat)) { + waslocked = false; + exists = true; + lastStat = newStat; + return true; + } + // no change + return false; + } else { + waslocked = true; + return false; + } + } + } + return false; + } + + /** + * updates internal record of file state when caller has intentionally + * modified subject. (ignores locked-state of subject) + */ + public void setState() { + if (subject != null) { + if (exists = subject.exists()) { + lastStat = getStat(subject); + waslocked = false; + } + } + } + + /** + * Make a watcher for a particular file. If the file doesn't exist, the + * watcher will watch for its creation (and indicate a change of state) For + * locked files, the removal of a lock constitutes a change of state if the + * file was modified. + * + * @param subject + */ + + public FileWatcher(File subject) { + this.subject = subject; + setState(); + } + + /** + * Test for change in file state. Only indicates a change after any lock on a + * file has been released. + * + * @return true if file has been modified. + */ + public boolean hasChanged() { + boolean res = check(); + clearLock(); + return res; + } + + /** + * passes lock back to caller if hasChanged returned true. + * + * @return + */ + public Lock getChangedState() { + boolean res = check(); + if (res) + return subjectLock; + else { + clearLock(); + return null; + } + } + + /** + * safely? getting current state of the watched file + * + * @return + */ + public long[] getCurrentState() { + return getStat(subject); + } + + /** + * safely compare an externally recorded state with the current state for + * significant modifications. + * + * @param a + * @param b + * @return + */ + public boolean diffState(long[] a, long[] b) { + return compStat(a, b); + } + + /** + * @return the subject + */ + public File getSubject() { + return subject; + } +} diff --git a/src/uk/ac/vamsas/client/simpleclient/IdFactory.java b/src/uk/ac/vamsas/client/simpleclient/IdFactory.java index 09a28e4..582ff39 100644 --- a/src/uk/ac/vamsas/client/simpleclient/IdFactory.java +++ b/src/uk/ac/vamsas/client/simpleclient/IdFactory.java @@ -1,171 +1,233 @@ -/** - * - */ -package uk.ac.vamsas.client.simpleclient; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import uk.ac.vamsas.client.ClientHandle; -import uk.ac.vamsas.client.SessionHandle; -import uk.ac.vamsas.client.UserHandle; -import uk.ac.vamsas.client.Vobject; -import uk.ac.vamsas.client.VorbaId; -import uk.ac.vamsas.client.VorbaIdFactory; -import uk.ac.vamsas.objects.utils.document.VersionEntries; - -import java.util.Hashtable; -import java.util.zip.CRC32; -/** - * Simplest VorbaId constructor - * @author jimp - * - */ -public class IdFactory extends VorbaIdFactory { - static Log log = LogFactory.getLog(IdFactory.class); - private SessionHandle session=null; - private ClientHandle client; - private UserHandle user; - private CRC32 unique=new CRC32(); // used to attempt a unique but predictable stream for IDs - private String idstring; - int sequence=1; // incrementing value for next new ID - /** - * - */ - public IdFactory() { - super(); - // TODO Auto-generated constructor stub - } - - /** - * @param session - * @param client - * @param user - */ - protected IdFactory(SessionHandle session, ClientHandle client, UserHandle user) { - super(); - this.session = session; - this.client = client; - this.user = user; - unique.reset(); - unique.update(new Object[] { session, client, user}.toString().getBytes()); - // TODO: Ensure format of URNs and use standard composition methods. - idstring = client.getClientNCname()+"_"+unique.getValue()+"."; - extantids=new Hashtable(); - this.extanthashv=new Hashtable(); - } - /** - * Create IdFactory with existing object hashes and id set - * @param session - * @param client - * @param user - * @param extanthashv hash of existing VorbaIds from a previous read of same document - */ - protected IdFactory(SessionHandle session, ClientHandle client, UserHandle user, Hashtable extanthashv) { - this(session, client, user); - this.extanthashv = extanthashv; - } - /** - * values for keys in this hash can be used to reference the uk.ac.vamsas.client.Vobject instance for the VorbaId string. - * @return the hash of all VorbaIds - */ - protected Hashtable getVorbaIdHash() { - return extantids; - } - /** - * values for keys in this hash are Vobjhash objects created for each Vobj with a VorbaId - * after this factory has been used to write a vamsas archive. - * @return the hash of all VorbaIds and their hash values. - */ - protected Hashtable getVobjhashVals() { - return extanthashv; - } - /* (non-Javadoc) - * @see uk.ac.vamsas.client.VorbaIdFactory#makeVorbaId() - */ - public VorbaId makeVorbaId(Vobject vobject) { - if (session==null) - throw new Error("makeVorbaId called on improperly initialised IdFactory Vobject!"); - if (!vobject.isRegisterable()) - throw new Error("makeVorbaId called on unregisterable object."); - if (vobject.isRegistered()) - throw new Error("makeVorbaId called on already registered object."); - String newidstring; - do { - if (sequence>0) { - sequence++; - } else { - idstring+="1/"; - sequence=1; - } - newidstring=idstring+Integer.toString(sequence); - } while (extantids.containsKey(newidstring)); - VorbaId id = newId(newidstring); // VorbaId.hash()==newidstring.hash() so we can still recover vobject - extantids.put(id, vobject); // hash the Vobject by its new Id - return id; - } - - /* (non-Javadoc) - * @see uk.ac.vamsas.client.VorbaIdFactory#setSession(uk.ac.vamsas.client.SessionHandle) - */ - protected void setSession(SessionHandle sessionhandle) { - if (sessionhandle!=null) - session=sessionhandle; - else - log.warn("setSession(null) called."); - } - - /* (non-Javadoc) - * @see uk.ac.vamsas.client.VorbaIdFactory#getSessionHandle() - */ - public SessionHandle getSessionHandle() { - return session; - } - - /* (non-Javadoc) - * @see uk.ac.vamsas.client.VorbaIdFactory#setClient(uk.ac.vamsas.client.ClientHandle) - */ - protected void setClient(ClientHandle appHandle) { - if (appHandle!=null) - client = appHandle; - else - log.warn("setClient(null) called."); - } - - /* (non-Javadoc) - * @see uk.ac.vamsas.client.VorbaIdFactory#getClientHandle() - */ - public ClientHandle getClientHandle() { - return client; - } - - /* (non-Javadoc) - * @see uk.ac.vamsas.client.VorbaIdFactory#setUser(uk.ac.vamsas.client.UserHandle) - */ - protected void setUser(UserHandle userHandle) { - if (userHandle!=null) - user = userHandle; - else - log.warn("setUser(null) called."); - } - - /* (non-Javadoc) - * @see uk.ac.vamsas.client.VorbaIdFactory#getUserHandle() - */ - public UserHandle getUserHandle() { - return user; - } - /** - * Convenience method used for default behaviour in testing - * and any anonymous internal vamsasDocument unmarshalling - * @param clientname - * @return - */ - protected static IdFactory getDummyFactory(String clientname) { - if (clientname==null) - clientname="uk.ac.vamsas.client.simpleclient.IdFactory"; - return new IdFactory(new SessionHandle("dummy.session"), - new ClientHandle(clientname,VersionEntries.latestVersion()), - new UserHandle(clientname, "Arnold User's Inc.")); - } -} +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ +package uk.ac.vamsas.client.simpleclient; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import uk.ac.vamsas.client.ClientHandle; +import uk.ac.vamsas.client.SessionHandle; +import uk.ac.vamsas.client.UserHandle; +import uk.ac.vamsas.client.Vobject; +import uk.ac.vamsas.client.VorbaId; +import uk.ac.vamsas.client.VorbaIdFactory; +import uk.ac.vamsas.objects.utils.document.VersionEntries; + +import java.util.Hashtable; +import java.util.zip.CRC32; + +/** + * Simplest VorbaId constructor + * + * @author jimp + * + */ +public class IdFactory extends VorbaIdFactory { + static Log log = LogFactory.getLog(IdFactory.class); + + private SessionHandle session = null; + + private ClientHandle client; + + private UserHandle user; + + private CRC32 unique = new CRC32(); // used to attempt a unique but + // predictable stream for IDs + + private String idstring; + + int sequence = 1; // incrementing value for next new ID + + /** + * + */ + public IdFactory() { + super(); + // TODO Auto-generated constructor stub + } + + /** + * @param session + * @param client + * @param user + */ + protected IdFactory(SessionHandle session, ClientHandle client, + UserHandle user) { + super(); + this.session = session; + this.client = client; + this.user = user; + unique.reset(); + unique.update(new Object[] { session, client, user }.toString().getBytes()); + // TODO: Ensure format of URNs and use standard composition methods. + idstring = client.getClientNCname() + "_" + unique.getValue() + "."; + extantids = new Hashtable(); + this.extanthashv = new Hashtable(); + } + + /** + * Create IdFactory with existing object hashes and id set + * + * @param session + * @param client + * @param user + * @param extanthashv + * hash of existing VorbaIds from a previous read of same document + */ + protected IdFactory(SessionHandle session, ClientHandle client, + UserHandle user, Hashtable extanthashv) { + this(session, client, user); + this.extanthashv = extanthashv; + } + + /** + * values for keys in this hash can be used to reference the + * uk.ac.vamsas.client.Vobject instance for the VorbaId string. + * + * @return the hash of all VorbaIds + */ + protected Hashtable getVorbaIdHash() { + return extantids; + } + + /** + * values for keys in this hash are Vobjhash objects created for each Vobj + * with a VorbaId after this factory has been used to write a vamsas archive. + * + * @return the hash of all VorbaIds and their hash values. + */ + protected Hashtable getVobjhashVals() { + return extanthashv; + } + + /* + * (non-Javadoc) + * + * @see uk.ac.vamsas.client.VorbaIdFactory#makeVorbaId() + */ + public VorbaId makeVorbaId(Vobject vobject) { + if (session == null) + throw new Error( + "makeVorbaId called on improperly initialised IdFactory Vobject!"); + if (!vobject.isRegisterable()) + throw new Error("makeVorbaId called on unregisterable object."); + if (vobject.isRegistered()) + throw new Error("makeVorbaId called on already registered object."); + String newidstring; + do { + if (sequence > 0) { + sequence++; + } else { + idstring += "1/"; + sequence = 1; + } + newidstring = idstring + Integer.toString(sequence); + } while (extantids.containsKey(newidstring)); + VorbaId id = newId(newidstring); // VorbaId.hash()==newidstring.hash() so we + // can still recover vobject + extantids.put(id, vobject); // hash the Vobject by its new Id + return id; + } + + /* + * (non-Javadoc) + * + * @see + * uk.ac.vamsas.client.VorbaIdFactory#setSession(uk.ac.vamsas.client.SessionHandle + * ) + */ + protected void setSession(SessionHandle sessionhandle) { + if (sessionhandle != null) + session = sessionhandle; + else + log.warn("setSession(null) called."); + } + + /* + * (non-Javadoc) + * + * @see uk.ac.vamsas.client.VorbaIdFactory#getSessionHandle() + */ + public SessionHandle getSessionHandle() { + return session; + } + + /* + * (non-Javadoc) + * + * @see + * uk.ac.vamsas.client.VorbaIdFactory#setClient(uk.ac.vamsas.client.ClientHandle + * ) + */ + protected void setClient(ClientHandle appHandle) { + if (appHandle != null) + client = appHandle; + else + log.warn("setClient(null) called."); + } + + /* + * (non-Javadoc) + * + * @see uk.ac.vamsas.client.VorbaIdFactory#getClientHandle() + */ + public ClientHandle getClientHandle() { + return client; + } + + /* + * (non-Javadoc) + * + * @see + * uk.ac.vamsas.client.VorbaIdFactory#setUser(uk.ac.vamsas.client.UserHandle) + */ + protected void setUser(UserHandle userHandle) { + if (userHandle != null) + user = userHandle; + else + log.warn("setUser(null) called."); + } + + /* + * (non-Javadoc) + * + * @see uk.ac.vamsas.client.VorbaIdFactory#getUserHandle() + */ + public UserHandle getUserHandle() { + return user; + } + + /** + * Convenience method used for default behaviour in testing and any anonymous + * internal vamsasDocument unmarshalling + * + * @param clientname + * @return + */ + protected static IdFactory getDummyFactory(String clientname) { + if (clientname == null) + clientname = "uk.ac.vamsas.client.simpleclient.IdFactory"; + return new IdFactory(new SessionHandle("dummy.session"), new ClientHandle( + clientname, VersionEntries.latestVersion()), new UserHandle(clientname, + "Arnold User's Inc.")); + } +} diff --git a/src/uk/ac/vamsas/client/simpleclient/ListFile.java b/src/uk/ac/vamsas/client/simpleclient/ListFile.java index 29bb29e..e3ec58c 100644 --- a/src/uk/ac/vamsas/client/simpleclient/ListFile.java +++ b/src/uk/ac/vamsas/client/simpleclient/ListFile.java @@ -1,25 +1,42 @@ -/** - * - */ -package uk.ac.vamsas.client.simpleclient; - -import java.io.File; - - -/** - * base class for generic list storage and retrieval operations from a locked IO file - * TODO: LATER: generalize for all list storage and retrieval operations - * (pull-up from ClientsFile object) - */ -public class ListFile extends SessionFile { - - /** - * @param file - */ - public ListFile(File file) throws java.io.IOException { - super(file); - if (!this.sessionFile.exists()) - this.sessionFile.createNewFile(); - } - -} +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ +package uk.ac.vamsas.client.simpleclient; + +import java.io.File; + +/** + * base class for generic list storage and retrieval operations from a locked IO + * file TODO: LATER: generalize for all list storage and retrieval operations + * (pull-up from ClientsFile object) + */ +public class ListFile extends SessionFile { + + /** + * @param file + */ + public ListFile(File file) throws java.io.IOException { + super(file); + if (!this.sessionFile.exists()) + this.sessionFile.createNewFile(); + } + +} diff --git a/src/uk/ac/vamsas/client/simpleclient/Lock.java b/src/uk/ac/vamsas/client/simpleclient/Lock.java index bd968fb..bf182c1 100644 --- a/src/uk/ac/vamsas/client/simpleclient/Lock.java +++ b/src/uk/ac/vamsas/client/simpleclient/Lock.java @@ -1,3 +1,24 @@ +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ package uk.ac.vamsas.client.simpleclient; import java.io.BufferedInputStream; @@ -15,89 +36,119 @@ import java.nio.channels.ReadableByteChannel; import org.apache.commons.logging.LogFactory; /** - * transient object representing a file lock - * This lock should hold for all processes interacting in a session. + * transient object representing a file lock This lock should hold for all + * processes interacting in a session. + * * @author jimp */ public abstract class Lock { protected org.apache.commons.logging.Log log = LogFactory.getLog(Lock.class); + File target = null; // The file that is being locked - protected RandomAccessFile rafile=null; - + + protected RandomAccessFile rafile = null; + /** - * creates a valid Lock (test with isLocked) - * if a lock could be obtained for lockfile + * creates a valid Lock (test with isLocked) if a lock could + * be obtained for lockfile + * * @param lockfile */ protected Lock(java.io.File lockfile) { target = lockfile; } + /** - * test whether the given file is a target or related to the lock - * on the target file. - * @param afile a file + * test whether the given file is a target or related to the lock on the + * target file. + * + * @param afile + * a file * @return true if target is locked and afile is related to target */ public abstract boolean isTargetLockFile(File afile); + /** * * @return true if lock is held on the target */ public abstract boolean isLocked(); + /** * release lock and close all managed channels to file - * + * */ public abstract void release(); + /** - * optionally close the open random access channel on the file when releasing lock + * optionally close the open random access channel on the file when releasing + * lock + * * @param closeChannel */ public abstract void release(boolean closeChannel); /** * gets Locked Stream for reading from - * @param atStart true to start reading at beginning of file. + * + * @param atStart + * true to start reading at beginning of file. * @return null if file not locked * @throws IOException */ - public abstract FileInputStream getFileInputStream(boolean atStart) throws IOException; + public abstract FileInputStream getFileInputStream(boolean atStart) + throws IOException; /** - * gets Locked stream to write to - * FileInput always starts at the *end* of the file (after any truncation) - * @param clear true means file will be cleared to zero length + * gets Locked stream to write to FileInput always starts at the *end* of the + * file (after any truncation) + * + * @param clear + * true means file will be cleared to zero length * @return null if file is not locked * @throws IOException */ - public abstract FileOutputStream getFileOutputStream(boolean clear) throws IOException; + public abstract FileOutputStream getFileOutputStream(boolean clear) + throws IOException; + /** * return buffered output stream to locked file. - * @param clear - true means file is truncated to 0 length before writing + * + * @param clear + * - true means file is truncated to 0 length before writing * @return */ - public abstract BufferedOutputStream getBufferedOutputStream(boolean clear) throws IOException; - + public abstract BufferedOutputStream getBufferedOutputStream(boolean clear) + throws IOException; + protected void finalize() throws Throwable { - target=null; + target = null; } + /** * return buffered input stream for locked file. - * @param atStart - true means read from begining of file + * + * @param atStart + * - true means read from begining of file * @return null if file is not locked. */ - public BufferedInputStream getBufferedInputStream(boolean atStart) throws IOException { + public BufferedInputStream getBufferedInputStream(boolean atStart) + throws IOException { FileInputStream fis = getFileInputStream(atStart); - if (fis!=null) + if (fis != null) return new BufferedInputStream(fis); return null; } + /** * safe lock target length() function. - * @return -1 for non-lockable target, otherwise target's file length + * + * @return -1 for non-lockable target, otherwise target's file length */ public abstract long length(); + public abstract RandomAccessFile getRaFile() throws IOException; + public abstract FileChannel getRaChannel() throws IOException; } diff --git a/src/uk/ac/vamsas/client/simpleclient/LockFactory.java b/src/uk/ac/vamsas/client/simpleclient/LockFactory.java index d8098d7..a392db2 100644 --- a/src/uk/ac/vamsas/client/simpleclient/LockFactory.java +++ b/src/uk/ac/vamsas/client/simpleclient/LockFactory.java @@ -1,52 +1,81 @@ -package uk.ac.vamsas.client.simpleclient; - -import java.io.File; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -public class LockFactory { - protected static Log log = LogFactory.getLog(LockFactory.class); - public static int locktype=0; // use file lock by default - public static String[] locktypes = {"file","native"}; - { - String lockt = System.getProperty("vamsas.locktype"); - if (lockt!=null) { - int i,j; - for (i=0, j=locktypes.length; i=j) { - String lt = "'"+locktypes[0]+"'"; - for (i=1; i. + */ +package uk.ac.vamsas.client.simpleclient; + +import java.io.File; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +public class LockFactory { + protected static Log log = LogFactory.getLog(LockFactory.class); + + public static int locktype = 0; // use file lock by default + + public static String[] locktypes = { "file", "native" }; + { + String lockt = System.getProperty("vamsas.locktype"); + if (lockt != null) { + int i, j; + for (i = 0, j = locktypes.length; i < j + && locktypes[i].equalsIgnoreCase(lockt); i++) + ; + if (i >= j) { + String lt = "'" + locktypes[0] + "'"; + for (i = 1; i < j; i++) + lt += ",'" + locktypes[i] + "'"; + log.warn("System property vamsas.locktype takes one of " + lt); + log.warn("Defaulting to Locktype of " + locktypes[locktype]); + } + } else + log.debug("Defaulting to Locktype of " + locktypes[locktype]); + } + + /** + * lock target (blocks until lock is obtained) + * + * @param target + * @return lock + */ + public static Lock getLock(java.io.File target) { + return getLock(target, true); + } + + public static Lock getLock(java.io.File target, boolean block) { + if (locktype == 0) + return new FileLock(target, block); + if (locktype == 1) + return new NativeLock(target, block); + log.fatal("Implementation Error! No valid Locktype value"); + return null; + } + + /** + * try to lock target + * + * @param target + * @return null if lock was not possible + */ + public static Lock tryLock(File target) { + return getLock(target, false); + } +} diff --git a/src/uk/ac/vamsas/client/simpleclient/LockTimeoutException.java b/src/uk/ac/vamsas/client/simpleclient/LockTimeoutException.java index ef5c644..fa5d14f 100644 --- a/src/uk/ac/vamsas/client/simpleclient/LockTimeoutException.java +++ b/src/uk/ac/vamsas/client/simpleclient/LockTimeoutException.java @@ -1,29 +1,52 @@ -/** +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ package uk.ac.vamsas.client.simpleclient; /** * @author jimp - * + * */ public class LockTimeoutException extends Exception { - static final long serialVersionUID=1; + static final long serialVersionUID = 1; + static final String defaultMessage = "Timeout whilst waiting for lock on VamsasDocument"; + public LockTimeoutException() { super(defaultMessage); } + public LockTimeoutException(String arg0, Throwable arg1) { - super(arg0+" (timeout whilst waiting for lock)", arg1); + super(arg0 + " (timeout whilst waiting for lock)", arg1); // TODO Auto-generated constructor stub } + public LockTimeoutException(String arg0) { - super(arg0+" (timeout whilst waiting for lock)"); + super(arg0 + " (timeout whilst waiting for lock)"); // TODO Auto-generated constructor stub } + public LockTimeoutException(Throwable arg0) { super(defaultMessage, arg0); // TODO Auto-generated constructor stub } - + } diff --git a/src/uk/ac/vamsas/client/simpleclient/LockedFileOutputStream.java b/src/uk/ac/vamsas/client/simpleclient/LockedFileOutputStream.java index 178c74d..cf2d7aa 100644 --- a/src/uk/ac/vamsas/client/simpleclient/LockedFileOutputStream.java +++ b/src/uk/ac/vamsas/client/simpleclient/LockedFileOutputStream.java @@ -1,5 +1,23 @@ -/** +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ package uk.ac.vamsas.client.simpleclient; @@ -15,22 +33,27 @@ import org.apache.commons.logging.LogFactory; /** * @author Jim - * + * */ public class LockedFileOutputStream extends FileOutputStream { - private static org.apache.commons.logging.Log log = LogFactory.getLog(LockedFileOutputStream.class); - //FileOutputStream ostream=null; - boolean closed=true; + private static org.apache.commons.logging.Log log = LogFactory + .getLog(LockedFileOutputStream.class); + + // FileOutputStream ostream=null; + boolean closed = true; + private void init() { FileChannel ch = super.getChannel(); - if (ch!=null) { - try { closed = !ch.isOpen(); + if (ch != null) { + try { + closed = !ch.isOpen(); } catch (Exception e) { - closed=true; - log.debug("Invalid LockedOutputStream marked closed.",e); + closed = true; + log.debug("Invalid LockedOutputStream marked closed.", e); } } } + /** * @param file * @throws FileNotFoundException @@ -58,7 +81,7 @@ public class LockedFileOutputStream extends FileOutputStream { super(fdObj); init(); if (fdObj.valid()) - closed=false; + closed = false; } /** @@ -80,6 +103,7 @@ public class LockedFileOutputStream extends FileOutputStream { super(name, append); init(); } + /** * closes - actually just flushes the stream instead. */ @@ -90,10 +114,9 @@ public class LockedFileOutputStream extends FileOutputStream { log.debug("Marking Lockedoutputstream closed."); } else throw new IOException("Close on already closed FileOutputStream."); - closed=true; + closed = true; } - /** * @throws IOException * @see java.io.OutputStream#flush() @@ -116,8 +139,6 @@ public class LockedFileOutputStream extends FileOutputStream { return null; } - - /** * @param b * @param off @@ -155,5 +176,5 @@ public class LockedFileOutputStream extends FileOutputStream { else throw new IOException("write on Closed FileOutputStream"); } - + } diff --git a/src/uk/ac/vamsas/client/simpleclient/NativeLock.java b/src/uk/ac/vamsas/client/simpleclient/NativeLock.java index ccaa407..4255858 100644 --- a/src/uk/ac/vamsas/client/simpleclient/NativeLock.java +++ b/src/uk/ac/vamsas/client/simpleclient/NativeLock.java @@ -1,181 +1,213 @@ -package uk.ac.vamsas.client.simpleclient; - -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.io.RandomAccessFile; -import java.nio.channels.FileChannel; -import java.nio.channels.FileLock; -import java.nio.channels.ReadableByteChannel; - -/** - * @author JimP - * - */ -public class NativeLock extends Lock { - - protected FileLock lock = null; - - /** - * @param lockfile - * @param block true means thread will block until a lock is obtained. - */ - public NativeLock(File lockfile, boolean block) { - super(lockfile); - // try and get a lock. - lock = null; - - try { - /*if (!lockfile.createNewFile()) { - log.warn("Failed to create locked file "+lockfile); - return; - } - */ - rafile=new RandomAccessFile(lockfile,"rw"); - if (block) - lock = rafile.getChannel().lock(); - else - lock = rafile.getChannel().tryLock(); - if (lock==null || !lock.isValid()) { - // failed to get lock. Close the file channel - log.debug("failed to get lock for "+lockfile); - rafile.getChannel().close(); - lock=null; - } - } catch (FileNotFoundException e) { - // - log.debug("Lock failed - normal behaviour for windows locking."); - //log.error("Error! Couldn't create a lockfile at " - // + lockfile.getAbsolutePath(), e); - } catch (IOException e) { - log.error("Error! Problems with IO when creating a lock on " - + lockfile.getAbsolutePath(),e); - } // catch (Exception ) - } - - public boolean isLocked() { - if (lock != null && lock.isValid()) { - return true; - } - return false; - } - - public void release() { - release(true); - } - - public void release(boolean closeChannel) { - if (lock==null) - return; - try { - // channel.close should be called before release() for rigourous locking. - if (lock.isValid() && rafile!=null && rafile.getFD().valid() && rafile.getChannel()!=null) { - if (closeChannel && rafile.getChannel().isOpen()) { - rafile.close(); - rafile=null; - } else { - // just release the lock without doing anything to the channe;l - if (lock!=null && lock.isValid()) - lock.release(); - } - } - } catch (IOException e) { - log.warn("Whilst releasing lock",e); - } - lock=null; - } - - /** - * gets Locked Stream for reading from - * @param atStart true to start reading at beginning of file. - * @return null if file not locked - * @throws IOException - */ - public FileInputStream getFileInputStream(boolean atStart) throws IOException { - if (!isLocked()) - return null; - if (atStart) - rafile.seek(0); - return new FileInputStream(rafile.getFD()); - } - - /** - * gets Locked stream to write to - * FileInput always starts at the *end* of the file (after any truncation) - * @param clear true means file will be cleared to zero length - * @return null if file is not locked - * @throws IOException - */ - public FileOutputStream getFileOutputStream(boolean clear) throws IOException { - if (!isLocked()) - return null; - if (clear) { - rafile.seek(0); - rafile.setLength(0); - } else - rafile.seek(rafile.length()); - return new LockedFileOutputStream(rafile.getFD()); - } - - /** - * return buffered output stream to locked file. - * @param clear - true means file is truncated to 0 length before writing - * @return - */ - public BufferedOutputStream getBufferedOutputStream(boolean clear) throws IOException { - OutputStream fos = getFileOutputStream(clear); - if (fos!=null) - return new BufferedOutputStream(fos); - return null; - } - /** - * @see uk.ac.vamsas.client.simpleclient.Lock#finalize() - */ - protected void finalize() throws Throwable { - release(true); // we explicitly lose the lock here. - // log.debug("lock closing through garbage collection ?"); - super.finalize(); - } - - /* (non-Javadoc) - * @see uk.ac.vamsas.client.simpleclient.Lock#getLength() - */ - public long length() { - if (isLocked()){ - try { - return rafile.length(); - } catch (Exception e) { - log.debug("getLength exception:",e); - } - } - return -1; - } - - public RandomAccessFile getRaFile() throws IOException { - if (isLocked()) - return rafile; - else - log.debug("Failed to getRaFile on "+target); - return null; - } - - public FileChannel getRaChannel() throws IOException { - if (isLocked()) - return rafile.getChannel(); - else - log.debug("Failed to getRaChannel on "+target); - return null; - } - - public boolean isTargetLockFile(File afile) { - if (isLocked() && target.equals(afile)) - return true; - return false; - } - -} +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ +package uk.ac.vamsas.client.simpleclient; + +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.io.RandomAccessFile; +import java.nio.channels.FileChannel; +import java.nio.channels.FileLock; +import java.nio.channels.ReadableByteChannel; + +/** + * @author JimP + * + */ +public class NativeLock extends Lock { + + protected FileLock lock = null; + + /** + * @param lockfile + * @param block + * true means thread will block until a lock is obtained. + */ + public NativeLock(File lockfile, boolean block) { + super(lockfile); + // try and get a lock. + lock = null; + + try { + /* + * if (!lockfile.createNewFile()) { + * log.warn("Failed to create locked file "+lockfile); return; } + */ + rafile = new RandomAccessFile(lockfile, "rw"); + if (block) + lock = rafile.getChannel().lock(); + else + lock = rafile.getChannel().tryLock(); + if (lock == null || !lock.isValid()) { + // failed to get lock. Close the file channel + log.debug("failed to get lock for " + lockfile); + rafile.getChannel().close(); + lock = null; + } + } catch (FileNotFoundException e) { + // + log.debug("Lock failed - normal behaviour for windows locking."); + // log.error("Error! Couldn't create a lockfile at " + // + lockfile.getAbsolutePath(), e); + } catch (IOException e) { + log.error("Error! Problems with IO when creating a lock on " + + lockfile.getAbsolutePath(), e); + } // catch (Exception ) + } + + public boolean isLocked() { + if (lock != null && lock.isValid()) { + return true; + } + return false; + } + + public void release() { + release(true); + } + + public void release(boolean closeChannel) { + if (lock == null) + return; + try { + // channel.close should be called before release() for rigourous locking. + if (lock.isValid() && rafile != null && rafile.getFD().valid() + && rafile.getChannel() != null) { + if (closeChannel && rafile.getChannel().isOpen()) { + rafile.close(); + rafile = null; + } else { + // just release the lock without doing anything to the channe;l + if (lock != null && lock.isValid()) + lock.release(); + } + } + } catch (IOException e) { + log.warn("Whilst releasing lock", e); + } + lock = null; + } + + /** + * gets Locked Stream for reading from + * + * @param atStart + * true to start reading at beginning of file. + * @return null if file not locked + * @throws IOException + */ + public FileInputStream getFileInputStream(boolean atStart) throws IOException { + if (!isLocked()) + return null; + if (atStart) + rafile.seek(0); + return new FileInputStream(rafile.getFD()); + } + + /** + * gets Locked stream to write to FileInput always starts at the *end* of the + * file (after any truncation) + * + * @param clear + * true means file will be cleared to zero length + * @return null if file is not locked + * @throws IOException + */ + public FileOutputStream getFileOutputStream(boolean clear) throws IOException { + if (!isLocked()) + return null; + if (clear) { + rafile.seek(0); + rafile.setLength(0); + } else + rafile.seek(rafile.length()); + return new LockedFileOutputStream(rafile.getFD()); + } + + /** + * return buffered output stream to locked file. + * + * @param clear + * - true means file is truncated to 0 length before writing + * @return + */ + public BufferedOutputStream getBufferedOutputStream(boolean clear) + throws IOException { + OutputStream fos = getFileOutputStream(clear); + if (fos != null) + return new BufferedOutputStream(fos); + return null; + } + + /** + * @see uk.ac.vamsas.client.simpleclient.Lock#finalize() + */ + protected void finalize() throws Throwable { + release(true); // we explicitly lose the lock here. + // log.debug("lock closing through garbage collection ?"); + super.finalize(); + } + + /* + * (non-Javadoc) + * + * @see uk.ac.vamsas.client.simpleclient.Lock#getLength() + */ + public long length() { + if (isLocked()) { + try { + return rafile.length(); + } catch (Exception e) { + log.debug("getLength exception:", e); + } + } + return -1; + } + + public RandomAccessFile getRaFile() throws IOException { + if (isLocked()) + return rafile; + else + log.debug("Failed to getRaFile on " + target); + return null; + } + + public FileChannel getRaChannel() throws IOException { + if (isLocked()) + return rafile.getChannel(); + else + log.debug("Failed to getRaChannel on " + target); + return null; + } + + public boolean isTargetLockFile(File afile) { + if (isLocked() && target.equals(afile)) + return true; + return false; + } + +} diff --git a/src/uk/ac/vamsas/client/simpleclient/SessionFile.java b/src/uk/ac/vamsas/client/simpleclient/SessionFile.java index aa5e779..0c35fe2 100644 --- a/src/uk/ac/vamsas/client/simpleclient/SessionFile.java +++ b/src/uk/ac/vamsas/client/simpleclient/SessionFile.java @@ -1,231 +1,281 @@ -package uk.ac.vamsas.client.simpleclient; - -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.RandomAccessFile; -import java.nio.channels.ReadableByteChannel; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Basic methods for classes handling locked IO on files - * monitored by all (simpleclient) clients in a vamsas session. - * @author jimp - *TODO: support non nio file locking capable systems - */ -public class SessionFile { - private static Log log = LogFactory.getLog(SessionFile.class); - protected File sessionFile; - protected Lock fileLock = null; - - protected SessionFile(File file) { - super(); - sessionFile = file; - } - - protected boolean lockFile(Lock extantlock) { - if (fileLock!=null && !fileLock.isLocked()) { - fileLock.release();// tidy up invalid lock - fileLock=null; - } - if (extantlock!=null && extantlock.isLocked()) - fileLock=extantlock; // THIS IS BROKEN - lockFile then nulls the lock. - return lockFile(); - } - private boolean ensureSessionFile() { - if (sessionFile != null) { - if (!sessionFile.exists()) { - // create new file - try { - if (!sessionFile.createNewFile()) { - log.error("Failed to create file prior to locking: "+sessionFile); - return false; - } - } catch (IOException e) { - log.error("Exception when trying to create file "+sessionFile, e); - return false; - } - } - return true; - } - log.error("ensureSessionFile called for non-initialised SessionFile!"); - return false; - } - /** - * Get a lock for the SessionFile - * - * @return true if lock was made - */ - protected boolean lockFile() { - if (fileLock != null) { - if (fileLock.isLocked()) { - if (!ensureSessionFile()) - return false; - return true; - } else { - // lock failed for some reason. - fileLock.release(); - log.info("Unexpected session file lock failure. Trying to get it again."); - fileLock=null; - } - } - if (!ensureSessionFile()) - return false; - // TODO: see if we need to loop-wait for locks or they just block until - // lock is made... - long tries=5000; - do { - tries--; - if (fileLock==null || !fileLock.isLocked()) { - //try { Thread.sleep(1); } catch (Exception e) {}; - fileLock = LockFactory.getLock(sessionFile,true); // TODO: wait around if we can't get the lock. - } - } while (tries>0 && !fileLock.isLocked()); - if (!fileLock.isLocked()) - log.error("Failed to get lock for "+sessionFile); - // fileLock = new Lock(sessionFile); - return fileLock.isLocked(); - } - - /** - * Explicitly release the SessionFile's lock. - * - * @return true if lock was released. - */ - protected void unlockFile() { - if (fileLock != null) { - fileLock.release(); - fileLock = null; - } - } - - /** - * Makes a backup of the sessionFile. - * @return Backed up SessionFile or null if failed to make backup. - */ - protected File backupSessionFile() { - return backupSessionFile(fileLock, sessionFile.getName(),".old", sessionFile.getParentFile()); - } - - protected File backupSessionFile(Lock extantLock, String backupPrefix, String backupSuffix, File backupDir) { - File tempfile=null; - if (lockFile(extantLock)) { - try { - tempfile = File.createTempFile(backupPrefix, backupSuffix, backupDir); - long sourceln = fileLock.length(); - if (sourceln>0) { - FileOutputStream tos = new FileOutputStream(tempfile); - ReadableByteChannel channel; - channel = fileLock.getRaChannel().position(0); - long ntrans = 0; - while (ntrans0) { - log.debug("Lost lock on "+sessionFile+"! Re-trying for a transfer."); - lockFile(); - trafile = fileLock.getRaFile(); - }*/ - // TODO JBPNote: attempt to ensure save really saves the VamDoc.jar file - trafile.seek(0); - trafile.getChannel().transferFrom(nrafile.getChannel(), 0, - nrafile.length()); - // JBPNote: attempt to close the streams to flush the data out - // trafile.close(); - //nrafile.close(); - } - /** - * remove all trace of the sessionFile file - * - */ - protected void eraseExistence() { - unlockFile(); - if (sessionFile!=null) { - sessionFile.delete(); - sessionFile = null; - } - } - /* (non-Javadoc) - * @see uk.ac.vamsas.client.simpleclient.Lock#getBufferedInputStream(boolean) - */ - public BufferedInputStream getBufferedInputStream(boolean atStart) throws IOException { - lockFile(); - return fileLock.getBufferedInputStream(atStart); - } - - /* (non-Javadoc) - * @see uk.ac.vamsas.client.simpleclient.Lock#getBufferedOutputStream(boolean) - */ - public BufferedOutputStream getBufferedOutputStream(boolean clear) throws IOException { - lockFile(); - return fileLock.getBufferedOutputStream(clear); - } - - /* (non-Javadoc) - * @see uk.ac.vamsas.client.simpleclient.Lock#getFileInputStream(boolean) - */ - public FileInputStream getFileInputStream(boolean atStart) throws IOException { - lockFile(); - return fileLock.getFileInputStream(atStart); - } - - /* (non-Javadoc) - * @see uk.ac.vamsas.client.simpleclient.Lock#getFileOutputStream(boolean) - */ - public FileOutputStream getFileOutputStream(boolean clear) throws IOException { - lockFile(); - return fileLock.getFileOutputStream(clear); - } - -} +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ +package uk.ac.vamsas.client.simpleclient; + +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.RandomAccessFile; +import java.nio.channels.ReadableByteChannel; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * Basic methods for classes handling locked IO on files monitored by all + * (simpleclient) clients in a vamsas session. + * + * @author jimp TODO: support non nio file locking capable systems + */ +public class SessionFile { + private static Log log = LogFactory.getLog(SessionFile.class); + + protected File sessionFile; + + protected Lock fileLock = null; + + protected SessionFile(File file) { + super(); + sessionFile = file; + } + + protected boolean lockFile(Lock extantlock) { + if (fileLock != null && !fileLock.isLocked()) { + fileLock.release();// tidy up invalid lock + fileLock = null; + } + if (extantlock != null && extantlock.isLocked()) + fileLock = extantlock; // THIS IS BROKEN - lockFile then nulls the lock. + return lockFile(); + } + + private boolean ensureSessionFile() { + if (sessionFile != null) { + if (!sessionFile.exists()) { + // create new file + try { + if (!sessionFile.createNewFile()) { + log.error("Failed to create file prior to locking: " + sessionFile); + return false; + } + } catch (IOException e) { + log.error("Exception when trying to create file " + sessionFile, e); + return false; + } + } + return true; + } + log.error("ensureSessionFile called for non-initialised SessionFile!"); + return false; + } + + /** + * Get a lock for the SessionFile + * + * @return true if lock was made + */ + protected boolean lockFile() { + if (fileLock != null) { + if (fileLock.isLocked()) { + if (!ensureSessionFile()) + return false; + return true; + } else { + // lock failed for some reason. + fileLock.release(); + log + .info("Unexpected session file lock failure. Trying to get it again."); + fileLock = null; + } + } + if (!ensureSessionFile()) + return false; + // TODO: see if we need to loop-wait for locks or they just block until + // lock is made... + long tries = 5000; + do { + tries--; + if (fileLock == null || !fileLock.isLocked()) { + // try { Thread.sleep(1); } catch (Exception e) {}; + fileLock = LockFactory.getLock(sessionFile, true); // TODO: wait around + // if we can't get + // the lock. + } + } while (tries > 0 && !fileLock.isLocked()); + if (!fileLock.isLocked()) + log.error("Failed to get lock for " + sessionFile); + // fileLock = new Lock(sessionFile); + return fileLock.isLocked(); + } + + /** + * Explicitly release the SessionFile's lock. + * + * @return true if lock was released. + */ + protected void unlockFile() { + if (fileLock != null) { + fileLock.release(); + fileLock = null; + } + } + + /** + * Makes a backup of the sessionFile. + * + * @return Backed up SessionFile or null if failed to make backup. + */ + protected File backupSessionFile() { + return backupSessionFile(fileLock, sessionFile.getName(), ".old", + sessionFile.getParentFile()); + } + + protected File backupSessionFile(Lock extantLock, String backupPrefix, + String backupSuffix, File backupDir) { + File tempfile = null; + if (lockFile(extantLock)) { + try { + tempfile = File.createTempFile(backupPrefix, backupSuffix, backupDir); + long sourceln = fileLock.length(); + if (sourceln > 0) { + FileOutputStream tos = new FileOutputStream(tempfile); + ReadableByteChannel channel; + channel = fileLock.getRaChannel().position(0); + long ntrans = 0; + while (ntrans < sourceln) { + long tlen; + ntrans += tlen = tos.getChannel().transferFrom(channel, ntrans, + sourceln); + if (log.isDebugEnabled()) { + log.debug("Transferred " + tlen + " out of " + sourceln + + " bytes"); + } + } + tos.close(); + if (!channel.isOpen()) + throw new Error("LIBRARY PORTABILITY ISSUE: " + + tos.getChannel().getClass() + + ".transferFrom closes source channel!"); + if (!lockFile(extantLock)) + throw new Error("LIBRARY PORTABILITY ISSUE: Lost lock for " + + sessionFile.getName() + " after backup."); + + } + } catch (FileNotFoundException e1) { + log.warn("Can't create temp file for " + sessionFile.getName(), e1); + tempfile = null; + } catch (IOException e1) { + log.warn("Error when copying content to temp file for " + + sessionFile.getName(), e1); + tempfile = null; + } + } + return tempfile; + } + + /** + * Replaces data in sessionFile with data from file handled by another + * sessionFile passes up any exceptions. + * + * @param newData + * source for new data + */ + protected void updateFrom(Lock extantLock, SessionFile newData) + throws IOException { + log.debug("Updating " + sessionFile.getAbsolutePath() + " from " + + newData.sessionFile.getAbsolutePath()); + if (newData == null) + throw new IOException("Null newData object."); + if (newData.sessionFile == null) + throw new IOException("Null SessionFile in newData."); + + if (!lockFile(extantLock)) + throw new IOException("Failed to get write lock for " + sessionFile); + if (!newData.lockFile()) + throw new IOException("Failed to get lock for updateFrom " + + newData.sessionFile); + RandomAccessFile nrafile = newData.fileLock.getRaFile(); + nrafile.seek(0); + RandomAccessFile trafile = fileLock.getRaFile(); + /* + * long tries=5000; while (trafile==null && --tries>0) { + * log.debug("Lost lock on "+sessionFile+"! Re-trying for a transfer."); + * lockFile(); trafile = fileLock.getRaFile(); } + */ + // TODO JBPNote: attempt to ensure save really saves the VamDoc.jar file + trafile.seek(0); + trafile.getChannel() + .transferFrom(nrafile.getChannel(), 0, nrafile.length()); + // JBPNote: attempt to close the streams to flush the data out + // trafile.close(); + // nrafile.close(); + } + + /** + * remove all trace of the sessionFile file + * + */ + protected void eraseExistence() { + unlockFile(); + if (sessionFile != null) { + sessionFile.delete(); + sessionFile = null; + } + } + + /* + * (non-Javadoc) + * + * @see uk.ac.vamsas.client.simpleclient.Lock#getBufferedInputStream(boolean) + */ + public BufferedInputStream getBufferedInputStream(boolean atStart) + throws IOException { + lockFile(); + return fileLock.getBufferedInputStream(atStart); + } + + /* + * (non-Javadoc) + * + * @see uk.ac.vamsas.client.simpleclient.Lock#getBufferedOutputStream(boolean) + */ + public BufferedOutputStream getBufferedOutputStream(boolean clear) + throws IOException { + lockFile(); + return fileLock.getBufferedOutputStream(clear); + } + + /* + * (non-Javadoc) + * + * @see uk.ac.vamsas.client.simpleclient.Lock#getFileInputStream(boolean) + */ + public FileInputStream getFileInputStream(boolean atStart) throws IOException { + lockFile(); + return fileLock.getFileInputStream(atStart); + } + + /* + * (non-Javadoc) + * + * @see uk.ac.vamsas.client.simpleclient.Lock#getFileOutputStream(boolean) + */ + public FileOutputStream getFileOutputStream(boolean clear) throws IOException { + lockFile(); + return fileLock.getFileOutputStream(clear); + } + +} diff --git a/src/uk/ac/vamsas/client/simpleclient/SessionFileWatcherElement.java b/src/uk/ac/vamsas/client/simpleclient/SessionFileWatcherElement.java index 034aae6..1ef053f 100644 --- a/src/uk/ac/vamsas/client/simpleclient/SessionFileWatcherElement.java +++ b/src/uk/ac/vamsas/client/simpleclient/SessionFileWatcherElement.java @@ -1,42 +1,71 @@ +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ package uk.ac.vamsas.client.simpleclient; - /** - * Element of the VamsasFileWatcherThread event generator chain. - * Keep a reference to this element before adding it to the chain - * in order to control the generation of events with halt and enable. + * Element of the VamsasFileWatcherThread event generator chain. Keep a + * reference to this element before adding it to the chain in order to control + * the generation of events with halt and enable. * * doWatch will do nothing if the element is not enabled. * */ public class SessionFileWatcherElement extends WatcherElement { - SessionFile watched=null; + SessionFile watched = null; + /** * create a new, enabled watch element - * @param watcher file being watched - * @param handler handler to call on state change + * + * @param watcher + * file being watched + * @param handler + * handler to call on state change */ public SessionFileWatcherElement(SessionFile watcher, WatcherCallBack handler) { this(watcher, handler, true); } + protected void initWatch() { - if (watched==null) + if (watched == null) return; - if (watcher==null || !watcher.getSubject().equals(watched.sessionFile)) - watcher=new FileWatcher(watched.sessionFile); + if (watcher == null || !watcher.getSubject().equals(watched.sessionFile)) + watcher = new FileWatcher(watched.sessionFile); else watcher.setState(); } + protected void endWatch() { // leaves watcher in state its in. } + /** * new watcher with flag to initially skip watching this sessionfile + * * @param watcher * @param handler * @param enableWatching */ - public SessionFileWatcherElement(SessionFile watcher, WatcherCallBack handler, boolean enableWatching) { + public SessionFileWatcherElement(SessionFile watcher, + WatcherCallBack handler, boolean enableWatching) { super(handler); this.watched = watcher; if (enableWatching) @@ -44,12 +73,14 @@ public class SessionFileWatcherElement extends WatcherElement { else haltWatch(); } + /** * @return the watched */ public SessionFile getWatched() { return watched; } + protected String getSubject() { return watched.sessionFile.toString(); } diff --git a/src/uk/ac/vamsas/client/simpleclient/SessionFlagFile.java b/src/uk/ac/vamsas/client/simpleclient/SessionFlagFile.java index 27f83c7..fab3ea9 100644 --- a/src/uk/ac/vamsas/client/simpleclient/SessionFlagFile.java +++ b/src/uk/ac/vamsas/client/simpleclient/SessionFlagFile.java @@ -1,85 +1,111 @@ -package uk.ac.vamsas.client.simpleclient; - -import java.io.File; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * methods for setting and checking - * binary flags in a vamsas session directory. - * all methods apart from the constructor will - * throw a fatal error if the flagFile is not - * a valid java.io.File object. - * LATER: extract SessionFlag interface for generalizing the vamsas session code - * @author jimp - * - */ -public class SessionFlagFile { - private static Log log = LogFactory.getLog(SessionFlagFile.class); - protected File flagFile=null; - private void checkFlagFile() { - if (flagFile==null) { - log.fatal("Implementation error - uninitialized SessionFlagFile", - new Error("Implementation error - uninitialized SessionFlagFile")); - } - } - /** - * will log a warning if exceptions occur during flag creation. - * @return true if flag was set successfully - */ - public boolean setFlag() { - checkFlagFile(); - try { - if (flagFile.createNewFile()) { - log.debug("Set session flag "+flagFile); - } else { - log.debug("Session flag already set "+flagFile); - } - return true; - } - catch (Exception e) { - log.warn("Couldn't set session flag "+flagFile, e); - } - return false; - } - /** - * - * @return true if flag was cleared successfully - */ - public boolean clearFlag() { - checkFlagFile(); - if (flagFile.exists()) { - log.debug("clearing session flag "+flagFile); - if (!flagFile.delete()) { - log.warn("failed to clear session flag "+flagFile); - return false; - } - } else { - log.debug("clearFlag called for already cleared flag "+flagFile); - } - return true; - } - /** - * - * @return state of session flag - */ - public boolean checkFlag() { - checkFlagFile(); - if (flagFile.exists()) { - if (log.isDebugEnabled()) - log.debug("Flag '"+flagFile+"' is set."); - return true; - } - if (log.isDebugEnabled()) - log.debug("Flag '"+flagFile+"' is not set."); - return false; - } - /** - * @param flagFile - */ - public SessionFlagFile(File flagFile) { - super(); - this.flagFile = flagFile; - }; -} +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ +package uk.ac.vamsas.client.simpleclient; + +import java.io.File; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * methods for setting and checking binary flags in a vamsas session directory. + * all methods apart from the constructor will throw a fatal error if the + * flagFile is not a valid java.io.File object. LATER: extract SessionFlag + * interface for generalizing the vamsas session code + * + * @author jimp + * + */ +public class SessionFlagFile { + private static Log log = LogFactory.getLog(SessionFlagFile.class); + + protected File flagFile = null; + + private void checkFlagFile() { + if (flagFile == null) { + log.fatal("Implementation error - uninitialized SessionFlagFile", + new Error("Implementation error - uninitialized SessionFlagFile")); + } + } + + /** + * will log a warning if exceptions occur during flag creation. + * + * @return true if flag was set successfully + */ + public boolean setFlag() { + checkFlagFile(); + try { + if (flagFile.createNewFile()) { + log.debug("Set session flag " + flagFile); + } else { + log.debug("Session flag already set " + flagFile); + } + return true; + } catch (Exception e) { + log.warn("Couldn't set session flag " + flagFile, e); + } + return false; + } + + /** + * + * @return true if flag was cleared successfully + */ + public boolean clearFlag() { + checkFlagFile(); + if (flagFile.exists()) { + log.debug("clearing session flag " + flagFile); + if (!flagFile.delete()) { + log.warn("failed to clear session flag " + flagFile); + return false; + } + } else { + log.debug("clearFlag called for already cleared flag " + flagFile); + } + return true; + } + + /** + * + * @return state of session flag + */ + public boolean checkFlag() { + checkFlagFile(); + if (flagFile.exists()) { + if (log.isDebugEnabled()) + log.debug("Flag '" + flagFile + "' is set."); + return true; + } + if (log.isDebugEnabled()) + log.debug("Flag '" + flagFile + "' is not set."); + return false; + } + + /** + * @param flagFile + */ + public SessionFlagFile(File flagFile) { + super(); + this.flagFile = flagFile; + }; +} diff --git a/src/uk/ac/vamsas/client/simpleclient/SessionFlagWatcherElement.java b/src/uk/ac/vamsas/client/simpleclient/SessionFlagWatcherElement.java index 8d70d9f..0c87398 100644 --- a/src/uk/ac/vamsas/client/simpleclient/SessionFlagWatcherElement.java +++ b/src/uk/ac/vamsas/client/simpleclient/SessionFlagWatcherElement.java @@ -1,39 +1,69 @@ +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ package uk.ac.vamsas.client.simpleclient; - /** - * Element of the VamsasFileWatcherThread event generator chain. - * Keep a reference to this element before adding it to the chain - * in order to control the generation of events with halt and enable. + * Element of the VamsasFileWatcherThread event generator chain. Keep a + * reference to this element before adding it to the chain in order to control + * the generation of events with halt and enable. * - * doWatch will do nothing if the element is not enabled. - * TODO: TEST THIS CLASS - not yet used in SimpleClient + * doWatch will do nothing if the element is not enabled. TODO: TEST THIS CLASS + * - not yet used in SimpleClient */ public class SessionFlagWatcherElement extends WatcherElement { - SessionFlagFile watched=null; + SessionFlagFile watched = null; + /** * create a new, enabled watch element - * @param watcher file being watched - * @param handler handler to call on state change + * + * @param watcher + * file being watched + * @param handler + * handler to call on state change */ - public SessionFlagWatcherElement(SessionFlagFile watcher, WatcherCallBack handler) { + public SessionFlagWatcherElement(SessionFlagFile watcher, + WatcherCallBack handler) { this(watcher, handler, true); } + protected void initWatch() { - if (watched==null) + if (watched == null) return; watcher = new FileWatcher(watched.flagFile); } + protected void endWatch() { // leaves watcher in state its in. } + /** * new watcher with flag to initially skip watching this sessionfile + * * @param watcher * @param handler * @param enableWatching */ - public SessionFlagWatcherElement(SessionFlagFile watcher, WatcherCallBack handler, boolean enableWatching) { + public SessionFlagWatcherElement(SessionFlagFile watcher, + WatcherCallBack handler, boolean enableWatching) { super(handler); this.watched = watcher; if (enableWatching) @@ -41,14 +71,16 @@ public class SessionFlagWatcherElement extends WatcherElement { else haltWatch(); } + /** * @return the watched */ public SessionFlagFile getWatched() { return watched; } + protected String getSubject() { - + return watched.flagFile.toString(); } } diff --git a/src/uk/ac/vamsas/client/simpleclient/SessionUrn.java b/src/uk/ac/vamsas/client/simpleclient/SessionUrn.java index ac64f0e..2172602 100644 --- a/src/uk/ac/vamsas/client/simpleclient/SessionUrn.java +++ b/src/uk/ac/vamsas/client/simpleclient/SessionUrn.java @@ -1,88 +1,109 @@ -package uk.ac.vamsas.client.simpleclient; - -import java.io.File; -import java.net.URI; - -import uk.ac.vamsas.client.InvalidSessionUrnException; - -/** - * SessionUrn for simpleclient sessions: - * simpleclient://{Absolute path to session directory} - * - * For simpleclient urn, it consideres as on the same machine, using the path to the session - * directory to generate the session URN - * - * @author jimp - * - */ -public class SessionUrn extends uk.ac.vamsas.client.SessionUrn { - /** - * a simple client session urn prefix - */ - public static final String SIMPLECLIENT="simpleclient"; - public static String VAMSASDOCUMENT="vdoc"; - static { - TYPES.put(SIMPLECLIENT, SessionUrn.class); - TYPES.put(SessionUrn.VAMSASDOCUMENT, SessionUrn.class); - } - - /** - * Creates a SessionUrn object from a String. - * The string must be a string representation of a URI - * @param urnString - * @throws InvalidSessionUrnException - */ - public SessionUrn(String urnString) throws InvalidSessionUrnException - { - super(); - this.setURN(urnString); - } - - - /** - * Generates a sessionURN bases on a session directory location - * - * @param sessionLocation the file object to the session directory - */ - public SessionUrn(File sessionLocation) - {//throws MalformedURLException { - // TODO: LATER: implement switch to have vamsas document or simpleclient sessions for same constructor - //use URI instead of URL - super(SIMPLECLIENT, sessionLocation.getAbsoluteFile().toURI()); - } - - /** - * Generates a sessionURN bases on a vamsas session - * @param session a VamsasSession - * - * Should return the same URN string than the creation with the session directory - */ - public SessionUrn(VamsasSession session) - { - //throws MalformedURLException { - // use URI instead of URL - super(SIMPLECLIENT, session.sessionDir.getAbsoluteFile().toURI()); - } - - - - - - /** - * TODO: LATER: think about this again. - * - * Retrieves the file associated to the current sessionURN. - * The sessionURN (URI) is based on the session directory absolute path. - * Use the raw path of the URN and change the scheme to file to generate a new file - * URI. Then, from the URI create the File object (a File object can be created from an uri) - * - * @return File object representing the session URN // - * File(urn.getPath()) - */ - public File asFile() { - String path = this.urn.getRawPath(); - - return new File ( URI.create("file://"+path)); - } - // TODO: add abstract 'handler' methods for resolving the URN to a particular class -} +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ +package uk.ac.vamsas.client.simpleclient; + +import java.io.File; +import java.net.URI; + +import uk.ac.vamsas.client.InvalidSessionUrnException; + +/** + * SessionUrn for simpleclient sessions: simpleclient://{Absolute path to + * session directory} + * + * For simpleclient urn, it consideres as on the same machine, using the path to + * the session directory to generate the session URN + * + * @author jimp + * + */ +public class SessionUrn extends uk.ac.vamsas.client.SessionUrn { + /** + * a simple client session urn prefix + */ + public static final String SIMPLECLIENT = "simpleclient"; + + public static String VAMSASDOCUMENT = "vdoc"; + static { + TYPES.put(SIMPLECLIENT, SessionUrn.class); + TYPES.put(SessionUrn.VAMSASDOCUMENT, SessionUrn.class); + } + + /** + * Creates a SessionUrn object from a String. The string must be a string + * representation of a URI + * + * @param urnString + * @throws InvalidSessionUrnException + */ + public SessionUrn(String urnString) throws InvalidSessionUrnException { + super(); + this.setURN(urnString); + } + + /** + * Generates a sessionURN bases on a session directory location + * + * @param sessionLocation + * the file object to the session directory + */ + public SessionUrn(File sessionLocation) {// throws MalformedURLException { + // TODO: LATER: implement switch to have vamsas document or simpleclient + // sessions for same constructor + // use URI instead of URL + super(SIMPLECLIENT, sessionLocation.getAbsoluteFile().toURI()); + } + + /** + * Generates a sessionURN bases on a vamsas session + * + * @param session + * a VamsasSession + * + * Should return the same URN string than the creation with the + * session directory + */ + public SessionUrn(VamsasSession session) { + // throws MalformedURLException { + // use URI instead of URL + super(SIMPLECLIENT, session.sessionDir.getAbsoluteFile().toURI()); + } + + /** + * TODO: LATER: think about this again. + * + * Retrieves the file associated to the current sessionURN. The sessionURN + * (URI) is based on the session directory absolute path. Use the raw path of + * the URN and change the scheme to file to generate a new file URI. Then, + * from the URI create the File object (a File object can be created from an + * uri) + * + * @return File object representing the session URN // File(urn.getPath()) + */ + public File asFile() { + String path = this.urn.getRawPath(); + + return new File(URI.create("file://" + path)); + } + // TODO: add abstract 'handler' methods for resolving the URN to a particular + // class +} diff --git a/src/uk/ac/vamsas/client/simpleclient/SessionsFile.java b/src/uk/ac/vamsas/client/simpleclient/SessionsFile.java index 230c633..5730317 100644 --- a/src/uk/ac/vamsas/client/simpleclient/SessionsFile.java +++ b/src/uk/ac/vamsas/client/simpleclient/SessionsFile.java @@ -1,302 +1,346 @@ -/* - * -* VAMSAS Project -* -* Dec 13, 2006 - VamsasClient -* -*/ - -package uk.ac.vamsas.client.simpleclient; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; - - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import uk.ac.vamsas.client.SessionHandle; - -/** - * @author Pierre MARGUERITE - * - * - */ -public class SessionsFile extends ListFile { - - private static Log log = LogFactory.getLog(SessionsFile.class); - /** - * when set true - get FileNotFoundExceptions on WinXP when writing to locked stream after the backup has been made (via the backupFile method) - */ - boolean backup=false; - /** - * number of my session in list - passed back when a session - * is added to list, and used (if valid) for quickly - * looking up presence of session handle in the list. - */ - private int syncnum = 1; - /** - * @param file - */ - public SessionsFile(File file) throws java.io.IOException { - super(file); - } - - - /** - * internal method for getting sessionsList - ensures a lock has been made but - * does not release it. - * - * @return list of clients - */ - private SessionHandle[] retrieveSessionHandles() { - if (lockFile()) { - try { - SessionHandle[] sessions =null; - if (this.fileLock.length()>0) { - - ObjectInputStream is = new ObjectInputStream(this.fileLock.getBufferedInputStream(true)); - Object o; - o=is.readObject(); - if (o!=null) { - try { - sessions = (SessionHandle[]) o; - } - catch (Exception e) { - log.error("Garbage in the clientHandle list "+this.sessionFile,e); - } - } - // is.close(); - } - return sessions; - } catch (FileNotFoundException e) { - // e.printStackTrace(System.err); - log.error(e); - } catch (Exception e) { - log.error(e); - //e.printStackTrace(System.err); - } - } - return null; - } - - /** - * get the SessionsList from the file. May return null if lock failed! - * @return sessionsList - */ - public SessionHandle[] retrieveSessionsList() { - if (lockFile()) { - SessionHandle[] clients = retrieveSessionHandles(); - unlockFile(); - return clients; - } - return null; - } - - /** - * get list from the locked SessionsList. - * @param extantlock - * @return sessionList or null if lock failed (or file was empty) - */ - public SessionHandle[] retrieveSessionsList(Lock extantlock) { - if (lockFile(extantlock)) { - SessionHandle[] sessions = retrieveSessionHandles(); - unlockFile(); - return sessions; - } - return null; - } - - - /** - * adds SessionHandle me to the sessionList under an existing lock extantLock. - * @param newSession - * @param extantLock - * @return session index in list or 0 if lock was invalid or addSession operation failed. - */ - public int addSession(SessionHandle newSession, Lock extantLock) { - return addSession(newSession, true, extantLock); - } - - /** - * adds SessionsHandle me to the sessionsList under an existing lock. - * @param newSession - sessionsHandle - * @param disambig - if true then add will fail if an identical sessionHandle already exists - * @param extantLock - existing lock - * @return client index in list or 0 if addSession (or the lock) failed. - */ - - public int addSession(SessionHandle newSession, boolean disambig, Lock extantLock) { - if (lockFile(extantLock)) { - this.syncnum = addSession(newSession, disambig); - unlockFile(); - return this.syncnum; - } - return 0; - } - - /** - * removes the current session from the SessionsList without complaint if the session isn't in the sessionsList already. - * @param session session handle to be removed - * @param sessionlock existing lock passed from watcher. - */ - public void removeSession(SessionHandle session, Lock sessionlock) { - int mynum =-1; - if (lockFile(sessionlock)) { - - SessionHandle[] sessions = retrieveSessionHandles(); - if (sessions != null) { - if ((this.syncnum<=0 || this.syncnum>sessions.length) || !sessions[this.syncnum-1].equals(session)) { - for (int i = 0, j = sessions.length; i < j; i++) - { if (sessions[i].equals(session)) { - mynum=i; - break; - } - } - } else { - mynum=this.syncnum-1; - } - - if (mynum>-1) { - SessionHandle[] newlist = new SessionHandle[sessions.length - 1]; - for (int k=0,i = 0, j = sessions.length; i < j; i++) - if (i!=mynum) - newlist[k++] = sessions[i]; - if (!putSessionsList(newlist)) - throw new Error("Failed to write new sessionsList!"); // failed to put the sessionList to disk. - } - } - unlockFile(); - } else { - throw new Error("Couldn't get lock for "+((this.sessionFile==null) ? "Unitialised sessionFile in SessionsFile" : this.sessionFile.getAbsolutePath())); - } - } - /** - * Adds a SessionHandle to the SessionList file - optionally disambiguating - * the SessionHandle (modifes the URN). - * Note: Caller is left to release the lock on the SessionList. - * @param session - * @param disambiguate - - * flag indicating if the URN for me should be disambiguated to - * differentiate between sessions. - * @return index of sessionHandle in new list, or -1-position of existing - * sessionHandle (if disambiguate is true) - */ - protected int addSession(SessionHandle session, boolean disambiguate) { - int newsession = 0; - int tries=5; - while (tries-->0 && !lockFile()) - try { Thread.sleep(1); } catch (Exception e){}; - if (lockFile()) { - SessionHandle[] sessions = retrieveSessionHandles(); - - if (sessions == null) { - sessions = new SessionHandle[1]; - sessions[0] = session; - newsession = 1; - } else { - int k = 0; - for (int i = 0, j = sessions.length; i < j; i++) { - if ( sessions[i].equals(session)) { - if (disambiguate) { - while (sessions[i].equals(session)) { - // me.setClientUrn(me.getClientUrn() + k++); // TODO: make a better - // disambiguation of - // urn. - } - } else { - // will not write the ambiguous clientHandle to disk, just return - // its index. - return -1 - i; - } - } - } - int i, j; - SessionHandle[] newlist = new SessionHandle[sessions.length + 1]; - for (i = 0, j = sessions.length; i < j; i++) - newlist[i] = sessions[i]; - newlist[j] = session; - sessions = newlist; - newsession = j+1; - } - if (!putSessionsList(sessions)) - return 0; // failed to put the clientList to disk. - } - return newsession; - } - - - /** - * safely writes sessions array to the file referred to by sessionFile. - * - * @param clients - * @return true if successful write. Throws Errors otherwise. - */ - protected boolean putSessionsList(SessionHandle[] clients) { - if (lockFile()) { - File templist=null; - if (!this.backup || (templist = backupSessionFile()) != null) { - int retries=3; - while (retries-->0) { - try { - ObjectOutputStream os = - new ObjectOutputStream(this.fileLock.getBufferedOutputStream(true)); - log.debug("About to write "+clients.length+" sessionHandles to output stream."); - os.writeObject(clients); - // os.flush(); - os.close(); - // All done - remove the backup. - if (this.backup) - templist.delete(); - templist = null; - retries=-1; - } catch (Exception e) { - // System.err - //.println("Serious - problems writing to sessionFile."); - log.error("Serious - problems writing to sessionFile.",e); - if (retries>0 && templist != null) { - // System.err.println("Recovering from Backup in " - // + templist.getAbsolutePath()); - log.error("Recovering from Backup in "+ templist.getAbsolutePath()); - templist.renameTo(this.fileLock.target); - } - //e.printStackTrace(System.err); - log.error(e); - } - } - if (retries>-2) { - // System.err - // .println("Serious - problems writing to sessionFile. Giving Up."); - log.error("Serious - problems writing to sessionFile. Giving Up."); - return false; - } - } else { - throw new Error( - "Couldn't create backup of the clientList before writing to it!"); - } - } else { - throw new Error("Could not lock the clientList: " - + ((this.sessionFile == null) ? "Unitialized ClientsFile" - : " failed to get lock on " + this.sessionFile.getAbsolutePath())); - } - // successful! - return true; - } - - public void clearList() { - if (lockFile()) { - try { - FileOutputStream fout = this.fileLock.getFileOutputStream(true); - fout.flush(); - fout.close(); - } catch (Exception e) { - throw new Error("Problems trying to clear clientlist!",e); - - } - } - - } -} +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ +package uk.ac.vamsas.client.simpleclient; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import uk.ac.vamsas.client.SessionHandle; + +/** + * @author Pierre MARGUERITE + * + * + */ +public class SessionsFile extends ListFile { + + private static Log log = LogFactory.getLog(SessionsFile.class); + + /** + * when set true - get FileNotFoundExceptions on WinXP when writing to locked + * stream after the backup has been made (via the backupFile method) + */ + boolean backup = false; + + /** + * number of my session in list - passed back when a session is added to list, + * and used (if valid) for quickly looking up presence of session handle in + * the list. + */ + private int syncnum = 1; + + /** + * @param file + */ + public SessionsFile(File file) throws java.io.IOException { + super(file); + } + + /** + * internal method for getting sessionsList - ensures a lock has been made but + * does not release it. + * + * @return list of clients + */ + private SessionHandle[] retrieveSessionHandles() { + if (lockFile()) { + try { + SessionHandle[] sessions = null; + if (this.fileLock.length() > 0) { + + ObjectInputStream is = new ObjectInputStream(this.fileLock + .getBufferedInputStream(true)); + Object o; + o = is.readObject(); + if (o != null) { + try { + sessions = (SessionHandle[]) o; + } catch (Exception e) { + log.error("Garbage in the clientHandle list " + this.sessionFile, + e); + } + } + // is.close(); + } + return sessions; + } catch (FileNotFoundException e) { + // e.printStackTrace(System.err); + log.error(e); + } catch (Exception e) { + log.error(e); + // e.printStackTrace(System.err); + } + } + return null; + } + + /** + * get the SessionsList from the file. May return null if lock failed! + * + * @return sessionsList + */ + public SessionHandle[] retrieveSessionsList() { + if (lockFile()) { + SessionHandle[] clients = retrieveSessionHandles(); + unlockFile(); + return clients; + } + return null; + } + + /** + * get list from the locked SessionsList. + * + * @param extantlock + * @return sessionList or null if lock failed (or file was empty) + */ + public SessionHandle[] retrieveSessionsList(Lock extantlock) { + if (lockFile(extantlock)) { + SessionHandle[] sessions = retrieveSessionHandles(); + unlockFile(); + return sessions; + } + return null; + } + + /** + * adds SessionHandle me to the sessionList under an existing lock extantLock. + * + * @param newSession + * @param extantLock + * @return session index in list or 0 if lock was invalid or addSession + * operation failed. + */ + public int addSession(SessionHandle newSession, Lock extantLock) { + return addSession(newSession, true, extantLock); + } + + /** + * adds SessionsHandle me to the sessionsList under an existing lock. + * + * @param newSession + * - sessionsHandle + * @param disambig + * - if true then add will fail if an identical sessionHandle already + * exists + * @param extantLock + * - existing lock + * @return client index in list or 0 if addSession (or the lock) failed. + */ + + public int addSession(SessionHandle newSession, boolean disambig, + Lock extantLock) { + if (lockFile(extantLock)) { + this.syncnum = addSession(newSession, disambig); + unlockFile(); + return this.syncnum; + } + return 0; + } + + /** + * removes the current session from the SessionsList without complaint if the + * session isn't in the sessionsList already. + * + * @param session + * session handle to be removed + * @param sessionlock + * existing lock passed from watcher. + */ + public void removeSession(SessionHandle session, Lock sessionlock) { + int mynum = -1; + if (lockFile(sessionlock)) { + + SessionHandle[] sessions = retrieveSessionHandles(); + if (sessions != null) { + if ((this.syncnum <= 0 || this.syncnum > sessions.length) + || !sessions[this.syncnum - 1].equals(session)) { + for (int i = 0, j = sessions.length; i < j; i++) { + if (sessions[i].equals(session)) { + mynum = i; + break; + } + } + } else { + mynum = this.syncnum - 1; + } + + if (mynum > -1) { + SessionHandle[] newlist = new SessionHandle[sessions.length - 1]; + for (int k = 0, i = 0, j = sessions.length; i < j; i++) + if (i != mynum) + newlist[k++] = sessions[i]; + if (!putSessionsList(newlist)) + throw new Error("Failed to write new sessionsList!"); // failed to + // put the + // sessionList + // to disk. + } + } + unlockFile(); + } else { + throw new Error( + "Couldn't get lock for " + + ((this.sessionFile == null) ? "Unitialised sessionFile in SessionsFile" + : this.sessionFile.getAbsolutePath())); + } + } + + /** + * Adds a SessionHandle to the SessionList file - optionally disambiguating + * the SessionHandle (modifes the URN). Note: Caller is left to release the + * lock on the SessionList. + * + * @param session + * @param disambiguate + * - flag indicating if the URN for me should be disambiguated to + * differentiate between sessions. + * @return index of sessionHandle in new list, or -1-position of existing + * sessionHandle (if disambiguate is true) + */ + protected int addSession(SessionHandle session, boolean disambiguate) { + int newsession = 0; + int tries = 5; + while (tries-- > 0 && !lockFile()) + try { + Thread.sleep(1); + } catch (Exception e) { + } + ; + if (lockFile()) { + SessionHandle[] sessions = retrieveSessionHandles(); + + if (sessions == null) { + sessions = new SessionHandle[1]; + sessions[0] = session; + newsession = 1; + } else { + int k = 0; + for (int i = 0, j = sessions.length; i < j; i++) { + if (sessions[i].equals(session)) { + if (disambiguate) { + while (sessions[i].equals(session)) { + // me.setClientUrn(me.getClientUrn() + k++); // TODO: make a + // better + // disambiguation of + // urn. + } + } else { + // will not write the ambiguous clientHandle to disk, just return + // its index. + return -1 - i; + } + } + } + int i, j; + SessionHandle[] newlist = new SessionHandle[sessions.length + 1]; + for (i = 0, j = sessions.length; i < j; i++) + newlist[i] = sessions[i]; + newlist[j] = session; + sessions = newlist; + newsession = j + 1; + } + if (!putSessionsList(sessions)) + return 0; // failed to put the clientList to disk. + } + return newsession; + } + + /** + * safely writes sessions array to the file referred to by sessionFile. + * + * @param clients + * @return true if successful write. Throws Errors otherwise. + */ + protected boolean putSessionsList(SessionHandle[] clients) { + if (lockFile()) { + File templist = null; + if (!this.backup || (templist = backupSessionFile()) != null) { + int retries = 3; + while (retries-- > 0) { + try { + ObjectOutputStream os = new ObjectOutputStream(this.fileLock + .getBufferedOutputStream(true)); + log.debug("About to write " + clients.length + + " sessionHandles to output stream."); + os.writeObject(clients); + // os.flush(); + os.close(); + // All done - remove the backup. + if (this.backup) + templist.delete(); + templist = null; + retries = -1; + } catch (Exception e) { + // System.err + // .println("Serious - problems writing to sessionFile."); + log.error("Serious - problems writing to sessionFile.", e); + if (retries > 0 && templist != null) { + // System.err.println("Recovering from Backup in " + // + templist.getAbsolutePath()); + log.error("Recovering from Backup in " + + templist.getAbsolutePath()); + templist.renameTo(this.fileLock.target); + } + // e.printStackTrace(System.err); + log.error(e); + } + } + if (retries > -2) { + // System.err + // .println("Serious - problems writing to sessionFile. Giving Up."); + log.error("Serious - problems writing to sessionFile. Giving Up."); + return false; + } + } else { + throw new Error( + "Couldn't create backup of the clientList before writing to it!"); + } + } else { + throw new Error("Could not lock the clientList: " + + ((this.sessionFile == null) ? "Unitialized ClientsFile" + : " failed to get lock on " + this.sessionFile.getAbsolutePath())); + } + // successful! + return true; + } + + public void clearList() { + if (lockFile()) { + try { + FileOutputStream fout = this.fileLock.getFileOutputStream(true); + fout.flush(); + fout.close(); + } catch (Exception e) { + throw new Error("Problems trying to clear clientlist!", e); + + } + } + + } +} diff --git a/src/uk/ac/vamsas/client/simpleclient/SimpleClient.java b/src/uk/ac/vamsas/client/simpleclient/SimpleClient.java index 2368164..6e40df0 100644 --- a/src/uk/ac/vamsas/client/simpleclient/SimpleClient.java +++ b/src/uk/ac/vamsas/client/simpleclient/SimpleClient.java @@ -1,8 +1,23 @@ /* - * Created on 15-Sep-2005 - * - * TODO To change the template for this generated file go to - * Window - Preferences - Java - Code Style - Code Templates + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ package uk.ac.vamsas.client.simpleclient; @@ -38,89 +53,104 @@ import uk.ac.vamsas.objects.utils.ProvenanceStuff; * @author jimp */ public class SimpleClient implements IClient { - + private static Log log = LogFactory.getLog(SimpleClient.class); - + protected UserHandle user = null; - + protected SessionUrn session = null; + protected VamsasSession _session; + protected ClientHandle client = null; + protected EventGeneratorThread evgen = null; + protected ClientDocument cdocument = null; - - - - + private Lock activeClientFilelock = null; - private File clientlockFile = null; - + + private File clientlockFile = null; + /** - * object hash table that persists in each client holding vorbaIds and hash values after a document write + * object hash table that persists in each client holding vorbaIds and hash + * values after a document write */ - protected Hashtable extantobjects=null; + protected Hashtable extantobjects = null; + /** - * construct a transient IdFactory instance - this should last only as long as the - * SimpleClient object holds the lock on the vamsas document being created/manipulated. + * construct a transient IdFactory instance - this should last only as long as + * the SimpleClient object holds the lock on the vamsas document being + * created/manipulated. + * * @return */ private IdFactory makeVorbaIdFactory() { - if (extantobjects==null) - extantobjects=new Hashtable(); + if (extantobjects == null) + extantobjects = new Hashtable(); return new IdFactory(getSessionHandle(), client, user, extantobjects); } - + /** - * construct SimpleClient for user, client and VamsasSession directory - * use the SimpleClientFactory rather than this constructor directly. + * construct SimpleClient for user, client and VamsasSession directory use the + * SimpleClientFactory rather than this constructor directly. + * * @param user * @param client * @param sess */ - protected SimpleClient(UserHandle user, ClientHandle client, VamsasSession sess) throws InvalidSessionUrnException { + protected SimpleClient(UserHandle user, ClientHandle client, + VamsasSession sess) throws InvalidSessionUrnException { // TODO: validate user/client/session _session = sess; this.user = user; this.client = client; - //try { - log.debug("Creating new session for "+_session); - session = new SessionUrn(_session); - log.debug("Creating new Event Generator"); - evgen = new EventGeneratorThread(_session, this, handlers); - /*} catch (MalformedURLException e) { - log.error("Couldn't form a valid SessionUrn object!",e); - throw new InvalidSessionUrnException(_session.toString()); - }*/ - log.debug("SimpleClient constructed for session "+session.getSessionUrn()); - + // try { + log.debug("Creating new session for " + _session); + session = new SessionUrn(_session); + log.debug("Creating new Event Generator"); + evgen = new EventGeneratorThread(_session, this, handlers); + /* + * } catch (MalformedURLException e) { + * log.error("Couldn't form a valid SessionUrn object!",e); throw new + * InvalidSessionUrnException(_session.toString()); } + */ + log + .debug("SimpleClient constructed for session " + + session.getSessionUrn()); + } + /** - * construct new SimpleClientsession by importing objects from an existing vamsas document + * construct new SimpleClientsession by importing objects from an existing + * vamsas document + * * @param user * @param client * @param sess * @param importingArchive - * @throws Exception IOExceptions for Session IO problems, and general Exception if importing document is invalid. - protected SimpleClient(UserHandle user, ClientHandle client, VamsasSession sess, File importingArchive) throws Exception { - this(user, client, sess); - if (log.isDebugEnabled()) - { - log.debug("Attempting to overwrite session document with file: "+importingArchive); - } - // TODO: write provenance entry for new session indicating the import. - - } + * @throws Exception + * IOExceptions for Session IO problems, and general Exception if + * importing document is invalid. protected SimpleClient(UserHandle + * user, ClientHandle client, VamsasSession sess, File + * importingArchive) throws Exception { this(user, client, sess); if + * (log.isDebugEnabled()) { + * log.debug("Attempting to overwrite session document with file: " + * +importingArchive); } // TODO: write provenance entry for new + * session indicating the import. + * + * } */ - + /* - * (non-Javadoc) - * LATER: check that build substitution variables are correct + * (non-Javadoc) LATER: check that build substitution variables are correct + * * @see uk.ac.vamsas.client.IClient#getAbout() */ public String getAbout() { return new String("VORBA SimpleClient version $version$ build $build$"); } - + /* * (non-Javadoc) * @@ -129,7 +159,7 @@ public class SimpleClient implements IClient { public String getSessionUrn() { return session.getSessionUrn(); } - + /* * (non-Javadoc) * @@ -140,7 +170,7 @@ public class SimpleClient implements IClient { SessionHandle sh = new SessionHandle(session.getSessionUrn()); return sh; } - + /* * (non-Javadoc) * @@ -149,7 +179,7 @@ public class SimpleClient implements IClient { public ClientHandle getClientHandle() { return client; } - + /* * (non-Javadoc) * @@ -158,6 +188,7 @@ public class SimpleClient implements IClient { public UserHandle getUserHandle() { return user; } + /** * * @return user field for a provenance entry @@ -165,22 +196,28 @@ public class SimpleClient implements IClient { protected String getProvenanceUser() { return new String(user.getFullName()); } + /** - * construct a provenance entry for this client with the specified action string. + * construct a provenance entry for this client with the specified action + * string. + * * @param action * @return properly completed provenance entry */ protected Entry getProvenanceEntry(String action) { - Entry prov = ProvenanceStuff.newProvenanceEntry(client.getClientUrn(), getProvenanceUser(), action); + Entry prov = ProvenanceStuff.newProvenanceEntry(client.getClientUrn(), + getProvenanceUser(), action); return prov; } + private Hashtable handlers = initHandlers(); - + private Vector listeners = new Vector(); - + /** - * make all the PropertyChangeSupport objects for the - * events described in uk.ac.vamsas.client.Event + * make all the PropertyChangeSupport objects for the events described in + * uk.ac.vamsas.client.Event + * * @return */ private static Hashtable initHandlers() { @@ -192,19 +229,23 @@ public class SimpleClient implements IClient { } return events; } - + /* * (non-Javadoc) * - * @see uk.ac.vamsas.client.IClient#addDocumentUpdateHandler(java.util.EventListener) + * @see + * uk.ac.vamsas.client.IClient#addDocumentUpdateHandler(java.util.EventListener + * ) */ public void addDocumentUpdateHandler(PropertyChangeListener evt) { this.addVorbaEventHandler(Events.DOCUMENT_UPDATE, evt); } - boolean finalized=false; + + boolean finalized = false; + private void haltPickmanager() { - if (pickmanager!=null) { - final SimpleClient dying=this; + if (pickmanager != null) { + final SimpleClient dying = this; new Thread() { public void run() { SimpleClient.log.debug("Stopping pickManager.."); @@ -214,6 +255,7 @@ public class SimpleClient implements IClient { }.start(); } } + /* * (non-Javadoc) * @@ -221,30 +263,32 @@ public class SimpleClient implements IClient { */ public void finalizeClient() { if (finalized) - throw new Error("VAMSAS Client Implementation Error: Finalized called twice for same client instance."); + throw new Error( + "VAMSAS Client Implementation Error: Finalized called twice for same client instance."); // mark this instance as finalized - finalized=true; - + finalized = true; + // TODO: determine if this is last client in session - - // TODO: raise events like : ((lst_client && document.request.to.close), (client_finalization), ( - evgen._raise(Events.CLIENT_FINALIZATION, null, this,null); + + // TODO: raise events like : ((lst_client && document.request.to.close), + // (client_finalization), ( + evgen._raise(Events.CLIENT_FINALIZATION, null, this, null); // if (handlers.containsKey(Events.)) // if (handlers.containsKey(Events.CLIENT_FINALIZATION)) // deregister listeners. log.debug("Stopping pickManager"); haltPickmanager(); - + log.debug("Deregistering Client"); _session.removeClient(this); - //log.debug("Stopping EventGenerator.."); - //evgen.stopWatching(); + // log.debug("Stopping EventGenerator.."); + // evgen.stopWatching(); this.cdocument = null; SimpleClient.log.debug("EventGenerator halted."); log.debug("finalization Complete."); } - + /* * (non-Javadoc) * @@ -252,8 +296,9 @@ public class SimpleClient implements IClient { */ public IClientDocument getClientDocument() throws IOException { log.debug("getClientDocument"); - if (cdocument!=null) { - // cdocument is non-nill if the ClientDocument.finalise() method hasn't been called. + if (cdocument != null) { + // cdocument is non-nill if the ClientDocument.finalise() method hasn't + // been called. return cdocument; } evgen.disableDocumentWatch(); @@ -261,70 +306,83 @@ public class SimpleClient implements IClient { try { // LATER: bail out if it takes too long to get the lock ? va = _session.getVamsasDocument(); - } - catch (IOException e) { + } catch (IOException e) { throw new IOException("Failed to get lock on session document"); } - VamsasDocument doc=null; + VamsasDocument doc = null; IdFactory vorba = null; - // TODO: LATER: reduce size of vorba ids generated from these parameters to IdFactory (mainly sessionHandle rationalization ?) + // TODO: LATER: reduce size of vorba ids generated from these parameters to + // IdFactory (mainly sessionHandle rationalization ?) try { - va.setVorba(vorba=makeVorbaIdFactory()); + va.setVorba(vorba = makeVorbaIdFactory()); // if session currently holds data - read it in - or get a dummy log.debug("Accessing document"); - doc = - va.getVamsasDocument(getProvenanceUser(), - "created new session document.", null); - if (doc!=null) + doc = va.getVamsasDocument(getProvenanceUser(), + "created new session document.", null); + if (doc != null) log.debug("Successfully retrieved document."); else log.error("Unexpectedly retrieved null document!"); - } - catch (Exception e) { - log.error("Failed to get session document for session directory '"+_session.sessionDir+"'", e); - throw new IOException("Failed to get session document for session directory '"+_session.sessionDir+"'"); + } catch (Exception e) { + log.error("Failed to get session document for session directory '" + + _session.sessionDir + "'", e); + throw new IOException( + "Failed to get session document for session directory '" + + _session.sessionDir + "'"); } // Construct the IClientDocument instance - + cdocument = new ClientDocument(doc, va, vorba, this); return cdocument; } - + /* * (non-Javadoc) + * * @throws Errors for invalid newdoc parameter - * @see uk.ac.vamsas.client.IClient#updateDocument(uk.ac.vamsas.client.IClientDocument) + * + * @see + * uk.ac.vamsas.client.IClient#updateDocument(uk.ac.vamsas.client.IClientDocument + * ) */ public void updateDocument(IClientDocument newdoc) { log.debug("updateDocument:"); - // Check validity of simpleclient instance and that it holds a lock on the session's document + // Check validity of simpleclient instance and that it holds a lock on the + // session's document if (!(newdoc instanceof ClientDocument)) { throw new Error("Invalid IClientDocument passsed to SimpleClient."); } - if (cdocument==null) - throw new Error("Client Error - updateDocument() called before getClientDocument() on this SimpleClient instance."); - if (newdoc!=cdocument) - throw new Error("Client Error - SimpleClient.updateDocument() can only take the IClientDocument instance returned from SimpleClient.getClientDocument()"); - + if (cdocument == null) + throw new Error( + "Client Error - updateDocument() called before getClientDocument() on this SimpleClient instance."); + if (newdoc != cdocument) + throw new Error( + "Client Error - SimpleClient.updateDocument() can only take the IClientDocument instance returned from SimpleClient.getClientDocument()"); + if (evgen.isDocumentWatchEnabled()) - throw new Error("Probable Client Error (did you remember to call SimpleClient.updateDocument(clientdoc) at the end of the document update handler?) - or Library Bug : Document watcher still enabled whilst ClientDocument instance exists."); - if (cdocument.isInvalidModification()) - { - log.info("Client has corrupted the vamsas document. It will not be written back to the session - sorry."); - // TODO: modify updateDocument signature: We should really raise an exception here to tell the client that it broke the datamodel. + throw new Error( + "Probable Client Error (did you remember to call SimpleClient.updateDocument(clientdoc) at the end of the document update handler?) - or Library Bug : Document watcher still enabled whilst ClientDocument instance exists."); + if (cdocument.isInvalidModification()) { + log + .info("Client has corrupted the vamsas document. It will not be written back to the session - sorry."); + // TODO: modify updateDocument signature: We should really raise an + // exception here to tell the client that it broke the datamodel. } else { // actually try to write - if necessary. if (!cdocument.isModified()) { - // client document is silently got rid of, with no session update events. + // client document is silently got rid of, with no session update + // events. if (log.isDebugEnabled()) - log.debug("updateDocument for "+session.getSessionUrn()+" with unmodified IClientDocument (skipping the write)"); + log.debug("updateDocument for " + session.getSessionUrn() + + " with unmodified IClientDocument (skipping the write)"); } else { writeSessionDocument(); } } // release locks, reset and start to receive events again - tidyAwaySessionDocumentState(); + tidyAwaySessionDocumentState(); } + /** * garbage collect the ClientDocument instance and re-enable watchers. */ @@ -333,7 +391,8 @@ public class SimpleClient implements IClient { log.debug("Finalizing ClientDocument instance."); cdocument.finalize(); } catch (Throwable e) { - log.error("Exception when trying to garbage collect ClientDocument for "+session.getSessionUrn(), e); + log.error("Exception when trying to garbage collect ClientDocument for " + + session.getSessionUrn(), e); } cdocument = null; // this is probably done by finalize @@ -341,8 +400,9 @@ public class SimpleClient implements IClient { _session.unlockVamsasDocument(); evgen.enableDocumentWatch(); } catch (IOException e) { - log.warn("IO Problems when releasing lock on session document!",e); - _session.slog.error("IO problems when attempting to release lock on session document."); + log.warn("IO Problems when releasing lock on session document!", e); + _session.slog + .error("IO problems when attempting to release lock on session document."); } } @@ -351,22 +411,24 @@ public class SimpleClient implements IClient { */ private void writeSessionDocument() { try { - boolean updated=cdocument.updateSessionDocument(); - boolean hasContent=cdocument.isModified(); + boolean updated = cdocument.updateSessionDocument(); + boolean hasContent = cdocument.isModified(); if (!updated) { - log.warn("Session document did not update properly for session directory "+_session.sessionDir); - // cdocument.archive.cancelArchive(); // LATER: could be done - would need to prevent updateSessionDocument closing the iohandler. - _session.slog.warn("Session Document updated but may not be valid (false return from org.vamsas.simpleclient.ClientDocument.updateSessionDocument()"); + log + .warn("Session document did not update properly for session directory " + + _session.sessionDir); + // cdocument.archive.cancelArchive(); // LATER: could be done - would + // need to prevent updateSessionDocument closing the iohandler. + _session.slog + .warn("Session Document updated but may not be valid (false return from org.vamsas.simpleclient.ClientDocument.updateSessionDocument()"); } else { log.debug("Document update successful."); } - if (hasContent) - { + if (hasContent) { _session.setUnsavedFlag(); } - } - catch (IOException e) { - log.warn("IO Problems when updating document!",e); + } catch (IOException e) { + log.warn("IO Problems when updating document!", e); _session.slog.error("IO problems when attempting to update document."); } } @@ -377,105 +439,115 @@ public class SimpleClient implements IClient { * @see uk.ac.vamsas.client.IClient#storeDocument(java.io.File) */ public void storeDocument(File location) { - if (location==null) - throw new Error("Vamsas Client API Usage Error: storeDocument called with null location."); - log.debug("StoreDocument to "+location); + if (location == null) + throw new Error( + "Vamsas Client API Usage Error: storeDocument called with null location."); + log.debug("StoreDocument to " + location); // write storeDocument file to inform other clients that they should raise Lock vamlock = evgen.want_to_store(); // Events.DOCUMENT_FINALIZEAPPDATA try { _session.writeVamsasDocument(location, vamlock); - _session.clearUnsavedFlag(); + _session.clearUnsavedFlag(); } catch (Exception e) { - log.warn("Exception whilst trying to store document in "+location,e); + log.warn("Exception whilst trying to store document in " + location, e); } vamlock.release(); } - + /* * (non-Javadoc) * * @see uk.ac.vamsas.client.IClient#addVorbaEventHandler(java.lang.String, - * java.beans.PropertyChangeListener) + * java.beans.PropertyChangeListener) */ public void addVorbaEventHandler(String EventChain, PropertyChangeListener evt) { if (handlers.containsKey(EventChain)) { - log.debug("Adding new handler for "+EventChain); + log.debug("Adding new handler for " + EventChain); Object handler; ((PropertyChangeSupport) (handler = handlers.get(EventChain))) - .addPropertyChangeListener(evt); + .addPropertyChangeListener(evt); listeners.add(handler); listeners.add((Object) evt); } } - - /* (non-Javadoc) + + /* + * (non-Javadoc) + * * @see uk.ac.vamsas.client.IClient#pollUpdate() */ public void pollUpdate() { log.debug("pollUpdate"); - if (evgen==null) { + if (evgen == null) { log.warn("pollUpdate called on incomplete SimpleClient object."); return; } - + if (!evgen.isWatcherAlive()) { log.warn("pollUpdate called before joinSession() - trying to do this."); try { joinSession(); } catch (Exception e) { - log.error("Unexpected exception on default call to joinSession",e); + log.error("Unexpected exception on default call to joinSession", e); } } - - //TODO ensure event generator robustly handles these interrupts. + + // TODO ensure event generator robustly handles these interrupts. log.debug("interrrupting event generator."); evgen.interruptWatching(); log.debug("interrrupted event generator."); } - - /* (non-Javadoc) + + /* + * (non-Javadoc) + * * @see uk.ac.vamsas.client.IClient#joinSession() */ public void joinSession() throws Exception { log.debug("Joining Session."); // start the EventGenerator thread. - if (evgen==null) { + if (evgen == null) { log.warn("joinSession called on incomplete SimpleClient object."); return; } if (evgen.isWatcherAlive()) - throw new Error("Join session called twice for the same SimpleClient (IClient instance)."); + throw new Error( + "Join session called twice for the same SimpleClient (IClient instance)."); evgen.startWatching(); if (evgen.isWatcherAlive()) log.debug("Started EventGenerator thread."); else { log.warn("Failed to start EventGenerator thread."); - throw new Exception("Failed to start event generator thread - client cannot be instantiated."); + throw new Exception( + "Failed to start event generator thread - client cannot be instantiated."); } - if (evgen.countHandlersFor(Events.DOCUMENT_CREATE)>0) { - //TODO: LATER: is this application connecting to a newly created session document ? - //evgen.raise(Events.DOCUMENT_CREATE); + if (evgen.countHandlersFor(Events.DOCUMENT_CREATE) > 0) { + // TODO: LATER: is this application connecting to a newly created session + // document ? + // evgen.raise(Events.DOCUMENT_CREATE); } - + } - - - - /* (non-Javadoc) + + /* + * (non-Javadoc) + * * @see uk.ac.vamsas.client.IClient#importDocument(java.io.File) */ public void importDocument(File location) { // TODO LATER: implement SimpleClient.importDocument() - // if (numberOfClients<1 or document file is empty/new, then can import directly.) - // more complex if data is already present in document. Could have a 'clearSession' method, too, or dump and overwrite instead. - log.error("importDocument is not yet implemented for a SimpleClient Session."); - - /*try { - this._session.setVamsasDocument(location); - } catch (IOException e) { - log.error("importDocument failed."); - }*/ + // if (numberOfClients<1 or document file is empty/new, then can import + // directly.) + // more complex if data is already present in document. Could have a + // 'clearSession' method, too, or dump and overwrite instead. + log + .error("importDocument is not yet implemented for a SimpleClient Session."); + + /* + * try { this._session.setVamsasDocument(location); } catch (IOException e) + * { log.error("importDocument failed."); } + */ } public IObjectUpdate getUpdateHandler(Class rootObject) { @@ -490,23 +562,28 @@ public class SimpleClient implements IClient { public void removeUpdateHandler(Class rootObject) { // TODO Auto-generated method stub - + } public void setUpdateHandler(IObjectUpdate handler) { // TODO Auto-generated method stub - + } /** * retrieves the current VamsasSession to which belong the client + * * @return the _session */ protected VamsasSession get_session() { return this._session; } - SimplePickManager pickmanager=null; - /* (non-Javadoc) + + SimplePickManager pickmanager = null; + + /* + * (non-Javadoc) + * * @see uk.ac.vamsas.client.IClient#getPickManager() */ public IPickManager getPickManager() { @@ -515,76 +592,81 @@ public class SimpleClient implements IClient { } private void createPickManager() { - if (pickmanager==null){ + if (pickmanager == null) { // TODO: Construct PickManager for session using details from sessionURN! log.debug("Creating PickManager (not from sessionURN yet)"); - pickmanager = new SimplePickManager(new uk.ac.vamsas.client.picking.SocketManager()); + pickmanager = new SimplePickManager( + new uk.ac.vamsas.client.picking.SocketManager()); } } - - - protected void releaseActiveClientFile() throws IOException - { - + + protected void releaseActiveClientFile() throws IOException { + log.debug("Releasing active client locks"); - if( activeClientFilelock != null) - {// Release the lock + if (activeClientFilelock != null) {// Release the lock log.debug("Releasing lock on active client lock file"); activeClientFilelock.release(); - log.debug("ReleaseActiveClientFile called when client has no lock on its clientLockFile"); + log + .debug("ReleaseActiveClientFile called when client has no lock on its clientLockFile"); activeClientFilelock = null; } else { - log.debug("ReleaseActiveClientFile called when client has no lock on its clientLockFile"); + log + .debug("ReleaseActiveClientFile called when client has no lock on its clientLockFile"); } - if (this.clientlockFile != null) - { + if (this.clientlockFile != null) { log.debug("trying to delete active client lock file"); - if (this.clientlockFile.exists()) - { + if (this.clientlockFile.exists()) { this.clientlockFile.delete(); log.debug("deleted active client lock file"); } } else { - log.debug("ReleaseActiveClientFile called when client has no clientLockFile"); + log + .debug("ReleaseActiveClientFile called when client has no clientLockFile"); } } - - protected void createActiveClientFile() throws IOException - { - if(this.clientlockFile != null )return; - log.debug("createActiveClientFile"); - //create, if need, subdirectory to contain client files - File clientlockFileDir = new File ( this.get_session().sessionDir, this.get_session().clientFileDirectory); - if( !clientlockFileDir.exists()) - {//the directory does not exist, create it - if (! clientlockFileDir.mkdirs()) - { - throw new IOException("Failed to create sub directory to session directory for client lock files'"+clientlockFileDir.getAbsolutePath()+"'"); - } + + protected void createActiveClientFile() throws IOException { + if (this.clientlockFile != null) + return; + log.debug("createActiveClientFile"); + // create, if need, subdirectory to contain client files + File clientlockFileDir = new File(this.get_session().sessionDir, this + .get_session().clientFileDirectory); + if (!clientlockFileDir.exists()) {// the directory does not exist, create it + if (!clientlockFileDir.mkdirs()) { + throw new IOException( + "Failed to create sub directory to session directory for client lock files'" + + clientlockFileDir.getAbsolutePath() + "'"); + } + } else { + if (!(clientlockFileDir.isDirectory() && clientlockFileDir.canWrite())) { + throw new IOException( + "Directory for client lock files is not a directory or is not accessibl: '" + + clientlockFileDir.getAbsolutePath() + "'"); } - else - { - if (!(clientlockFileDir.isDirectory() && clientlockFileDir.canWrite())) - { - throw new IOException("Directory for client lock files is not a directory or is not accessibl: '"+clientlockFileDir.getAbsolutePath()+"'"); - } } - this.clientlockFile = new File (clientlockFileDir, this.getClientHandle().getClientUrn().replaceAll("[:;/\\\\]+","")); - - log.debug("Creating active client lock file "+ this.clientlockFile.getAbsolutePath()); - Lock clientLock = uk.ac.vamsas.client.simpleclient.LockFactory.getLock(clientlockFile, false); - if (clientLock==null || !clientLock.isLocked()) - { - log.fatal("IMPLEMENTATION ERROR: Couldn't get a lock for the client lock file "+clientlockFile); + this.clientlockFile = new File(clientlockFileDir, this.getClientHandle() + .getClientUrn().replaceAll("[:;/\\\\]+", "")); + + log.debug("Creating active client lock file " + + this.clientlockFile.getAbsolutePath()); + Lock clientLock = uk.ac.vamsas.client.simpleclient.LockFactory.getLock( + clientlockFile, false); + if (clientLock == null || !clientLock.isLocked()) { + log + .fatal("IMPLEMENTATION ERROR: Couldn't get a lock for the client lock file " + + clientlockFile); } activeClientFilelock = clientLock; } + /** * @return the clientlockFile */ protected File getClientlockFile() { return clientlockFile; } + /** * * @return the lock for the client in the session @@ -592,10 +674,11 @@ public class SimpleClient implements IClient { protected Lock getClientLock() { return activeClientFilelock; } + SimpleClientConfig _config = null; + public SimpleClientConfig getSimpleClientConfig() { - if (_config==null) - { + if (_config == null) { _config = new SimpleClientConfig(); } return _config; diff --git a/src/uk/ac/vamsas/client/simpleclient/SimpleClientAppdata.java b/src/uk/ac/vamsas/client/simpleclient/SimpleClientAppdata.java index 7ea7dda..183d114 100644 --- a/src/uk/ac/vamsas/client/simpleclient/SimpleClientAppdata.java +++ b/src/uk/ac/vamsas/client/simpleclient/SimpleClientAppdata.java @@ -1,560 +1,694 @@ -/** - * - */ -package uk.ac.vamsas.client.simpleclient; - -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.DataInput; -import java.io.DataInputStream; -import java.io.DataOutput; -import java.io.DataOutputStream; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.Vector; -import java.util.jar.JarEntry; -import java.util.jar.JarInputStream; -import java.util.jar.JarOutputStream; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import uk.ac.vamsas.client.AppDataInputStream; -import uk.ac.vamsas.client.AppDataOutputStream; -import uk.ac.vamsas.client.IClientAppdata; -import uk.ac.vamsas.objects.core.AppData; -import uk.ac.vamsas.objects.core.ApplicationData; -import uk.ac.vamsas.objects.core.User; -import uk.ac.vamsas.objects.utils.AppDataReference; - -/** - * @author jimp - * Access interface to data chunks read from a VamsasArchiveReader stream - * (or byte buffer input stream) or written to a VamsasArchive stream. - * // TODO: get VamsasArchiveReader from sclient - */ -public class SimpleClientAppdata implements IClientAppdata { - private static Log log = LogFactory.getLog(SimpleClientAppdata.class); - /** - * has the session's document been accessed to get the AppData entrys? - */ - protected boolean accessedDocument = false; - /** - * has the user datablock been modified ? - * temporary file containing new user specific application data chunk - */ - SessionFile newUserData=null; - JarOutputStream newUserDataStream = null; - /** - * has the apps global datablock been modified ? - * temporary file containing new global application data chunk - */ - SessionFile newAppData=null; - JarOutputStream newAppDataStream=null; - /** - * set by extractAppData - */ - protected ApplicationData appsGlobal = null; - /** - * set by extractAppData - */ - protected User usersData = null; - - ClientDocument clientdoc; - /** - * state flags - * - accessed ClientAppdata - * - accessed UserAppdata - * => inputStream from embedded xml or jar entry of backup has been created - * - set ClientAppdata - * - set UserAppdata - * => an output stream has been created and written to - or a data chunk has been written. - * - need flag for switching between embedded and jar entry mode ? - always write a jar entry for a stream. - * - need code for rewind and overwriting if the set*Appdata methods are called more than once. - * - need flags for streams to except a call to set*Appdata when an output stream exists and is open. - * - need - * @param clientdoc The ClientDocument instance that this IClientAppData is accessing - */ - protected SimpleClientAppdata(ClientDocument clientdoc) { - if (clientdoc==null) { - log.fatal("Implementation error - Null ClientDocument for SimpleClientAppdata construction."); - throw new Error("Implementation error - Null ClientDocument for SimpleClientAppdata construction."); - } - this.clientdoc = clientdoc; - } - /** - * ensures that the appData information for this client - * instance has been extracted from the vamsas document provided by clientdoc. - */ - private void extractAppData() - { - if (!accessedDocument) - _extractAppData(clientdoc.getVamsasDocument()); - } - /** - * gets appropriate app data for the application, if it exists in this dataset - * Called by every accessor to ensure data has been retrieved from document. - */ - private void _extractAppData(uk.ac.vamsas.objects.core.VamsasDocument doc) { - if (doc==null) { - log.debug("extractAppData called for null document object"); - return; - } - if (accessedDocument) { - return; - } - Vector apldataset = AppDataReference.getUserandApplicationsData( - doc, clientdoc.sclient.getUserHandle(), clientdoc.sclient.getClientHandle()); - accessedDocument = true; - if (apldataset!=null) { - if (apldataset.size()>0) { - AppData clientdat = (AppData) apldataset.get(0); - if (clientdat instanceof ApplicationData) { - appsGlobal = (ApplicationData) clientdat; - if (apldataset.size()>1) { - clientdat = (AppData) apldataset.get(1); - if (clientdat instanceof User) { - usersData = (User) clientdat; - } - if (apldataset.size()>2) - log.info("Ignoring additional ("+(apldataset.size()-2)+") AppDatas returned by document appdata query."); - } - } else { - log.warn("Unexpected entry in AppDataReference query: id="+clientdat.getVorbaId()+" type="+clientdat.getClass().getName()); - } - apldataset.removeAllElements(); // destroy references. - } - } - } - /** - * LATER: generalize this for different low-level session implementations (it may not always be a Jar) - * @param appdata - * @param docreader - * @return - */ - private InputStream getAppDataStream(AppData appdata, VamsasArchiveReader docreader) { - String entryRef = appdata.getDataReference(); - if (entryRef!=null) { - log.debug("Resolving appData reference +"+entryRef); - InputStream entry = docreader.getAppdataStream(entryRef); - if (entry!=null) { - return entry; - // log.warn("Implementation problem - docreader didn't return a JarInputStream entry."); - } - } else { - log.debug("GetAppDataStream called for an AppData without a data reference."); - } - return null; - } - /** - * yuk - size of buffer used for slurping appData JarEntry into a byte array. - */ - private final int _TRANSFER_BUFFER=4096*4; - - /** - * Resolve AppData object to a byte array. - * @param appdata - * @param archiveReader - * @return null or the application data as a byte array - */ - private byte[] getAppDataAsByteArray(AppData appdata, VamsasArchiveReader docreader) { - if (appdata.getData()==null) { - if (docreader==null) { - log.warn("Silently failing getAppDataAsByteArray with null docreader.",new Exception()); - return null; - } - // resolve and load data - InputStream entry = getAppDataStream(appdata, docreader); - ByteArrayOutputStream bytes = new ByteArrayOutputStream(); - try { - byte buff[] = new byte[_TRANSFER_BUFFER]; - int olen=0; - while (entry!=null && entry.available()>0) { - int len = entry.read(buff, 0, _TRANSFER_BUFFER); - if (len>-1) - { bytes.write(buff, 0, len); - olen+=len; - } - } - buff=null; - } catch (Exception e) { - log.warn("Unexpected exception - probable truncation when accessing VamsasDocument entry "+appdata.getDataReference(), e); - } - if (bytes.size()>0) { - // LATER: deal with probable OutOfMemoryErrors here - log.debug("Got "+bytes.size()+" bytes from AppDataReference "+appdata.getDataReference()); - byte data[] = bytes.toByteArray(); - bytes = null; - return data; - } - return null; - } else { - log.debug("Returning inline AppData block for "+appdata.getVorbaId()); - return appdata.getData(); - } - } - /** - * internal method for getting a DataInputStream from an AppData object. - * @param appdata - * @param docreader - * @return data in object or null if no data is accessible - */ - private AppDataInputStream getAppDataAsDataInputStream(AppData appdata, VamsasArchiveReader docreader) { - if (appdata!=null && docreader!=null) { - String entryRef = appdata.getDataReference(); - if (entryRef!=null) { - log.debug("Resolving AppData reference for "+entryRef); - InputStream jstrm = docreader.getAppdataStream(entryRef); - if (jstrm!=null) - return new AppDataInputStream(jstrm); - else { - log.debug("Returning null input stream for unresolved reference ("+entryRef+") id="+appdata.getVorbaId()); - return null; - } - } else { - // return a byteArray input stream - byte[] data=appdata.getData(); - if (data.length>0) { - ByteArrayInputStream stream = new ByteArrayInputStream(data); - return new AppDataInputStream(stream); - } else { - log.debug("Returning null input stream for empty Appdata data block in id="+appdata.getVorbaId()); - return null; - } - } - } else { - log.debug("Returning null DataInputStream for appdata entry:"+appdata.getVorbaId()); - } - return null; - } - - /** - * internal method for getting ByteArray from AppData object - * @param clientOrUser - true for returning userData, otherwise return Client AppData. - * @return null or byte array - */ - private byte[] _getappdataByteArray(boolean clientOrUser) { - if (clientdoc==null) - throw new Error("Implementation error, Improperly initialized SimpleClientAppdata."); - byte[] data=null; - String appdName; - if (!clientOrUser) { - appdName = "Client's Appdata"; - } else { - appdName = "User's Appdata"; - } - log.debug("getting "+appdName+" as a byte array"); - extractAppData(); - AppData object; - if (!clientOrUser) { - object = appsGlobal; - } else { - object = usersData; - } - if (object!=null) { - log.debug("Trying to resolve "+appdName+" object to byte array."); - data = getAppDataAsByteArray(object, clientdoc.getVamsasArchiveReader()); - } - if (data == null) - log.debug("Returning null for "+appdName+"ClientAppdata byte[] array"); - return data; - - } - - /** - * common method for Client and User AppData->InputStream accessor - * @param clientOrUser - the appData to resolve - false for client, true for user appdata. - * @return null or the DataInputStream desired. - */ - private AppDataInputStream _getappdataInputStream(boolean clientOrUser) { - if (clientdoc==null) - throw new Error("Implementation error, Improperly initialized SimpleClientAppdata."); - String appdName; - if (!clientOrUser) { - appdName = "Client's Appdata"; - } else { - appdName = "User's Appdata"; - } - if (log.isDebugEnabled()) - log.debug("getting "+appdName+" as an input stream."); - extractAppData(); - AppData object; - if (!clientOrUser) { - object = appsGlobal; - } else { - object = usersData; - } - if (object!=null) { - log.debug("Trying to resolve ClientAppdata object to an input stream."); - return getAppDataAsDataInputStream(object, clientdoc.getVamsasArchiveReader()); - } - log.debug("getClientInputStream returning null."); - return null; - } - /* (non-Javadoc) - * @see uk.ac.vamsas.client.IClientAppdata#getClientAppdata() - */ - public byte[] getClientAppdata() { - return _getappdataByteArray(false); - } - /* (non-Javadoc) - * @see uk.ac.vamsas.client.IClientAppdata#getClientInputStream() - */ - public AppDataInputStream getClientInputStream() { - return _getappdataInputStream(false); - } - - /* (non-Javadoc) - * @see uk.ac.vamsas.client.IClientAppdata#getUserAppdata() - */ - public byte[] getUserAppdata() { - return _getappdataByteArray(true); - } - - /* (non-Javadoc) - * @see uk.ac.vamsas.client.IClientAppdata#getUserInputStream() - */ - public AppDataInputStream getUserInputStream() { - return _getappdataInputStream(true); - } - /** - * methods for writing new AppData entries. - */ - private AppDataOutputStream _getAppdataOutputStream(boolean clientOrUser) { - // Must access document to get any existing references - extractAppData(); - String apdname; - SessionFile apdfile=null; - if (!clientOrUser) { - apdname = "clientAppData"; - apdfile = newAppData; - } else { - apdname = "userAppData"; - apdfile = newUserData; - } - try { - if (apdfile==null) { - apdfile=clientdoc.sclient._session.getTempSessionFile(apdname,".jar"); - log.debug("Successfully made temp appData file for "+apdname); - } else { - // truncate to remove existing data. - apdfile.fileLock.getRaFile().setLength(0); - log.debug("Successfully truncated existing temp appData for "+apdname); - } - } catch (Exception e) { - log.error("Whilst opening temp file in directory "+clientdoc.sclient._session.sessionDir, e); - } - // we do not make another file for the new entry if one exists already - if (!clientOrUser) { - newAppData = apdfile; - } else { - newUserData = apdfile; - } - try { - apdfile.lockFile(); - // LATER: Refactor these local AppDatastream IO stuff to their own class. - JarOutputStream dstrm = - new JarOutputStream(apdfile.fileLock.getBufferedOutputStream(true)); - if (!clientOrUser) { - newAppDataStream = dstrm; - } else { - newUserDataStream = dstrm; - } - dstrm.putNextEntry(new JarEntry("appData_entry.dat")); - // LATER: there may be trouble ahead if an AppDataOutputStream is written to by one thread when another truncates the file. This situation should be prevented if possible - return new AppDataOutputStream(dstrm); - } - catch (Exception e) { - log.error("Whilst opening jar output stream for file "+apdfile.sessionFile); - } - // tidy up and return null - apdfile.unlockFile(); - return null; - } - /** - * copy data from the appData jar file to an appropriately - * referenced jar or Data entry for the given ApplicationData - * Assumes the JarFile is properly closed. - * @param vdoc session Document handler - * @param appd the AppData whose block is being updated - * @param apdjar the new data in a Jar written by this class - */ - protected void updateAnAppdataEntry(VamsasArchive vdoc, AppData appd, SessionFile apdjar) throws IOException { - if (apdjar==null || apdjar.sessionFile==null || !apdjar.sessionFile.exists()) { - throw new IOException("No temporary Appdata to recover and transfer."); - } - if (vdoc==null) { - log.fatal("FATAL! NO DOCUMENT TO WRITE TO!"); - throw new IOException("FATAL! NO DOCUMENT TO WRITE TO!"); - } - log.debug("Recovering AppData entry from "+apdjar.sessionFile); - JarInputStream istrm = new JarInputStream(apdjar.getBufferedInputStream(true)); - JarEntry je=null; - while (istrm.available()>0 && (je=istrm.getNextJarEntry())!=null && !je.getName().equals("appData_entry.dat")) { - if (je!=null) - log.debug("Ignoring extraneous entry "+je.getName()); - } - if (istrm.available()>0 && je!=null) { - log.debug("Found appData_entry.dat in Jar"); - String ref = appd.getDataReference(); - if (ref==null) { - throw new IOException("Null AppData.DataReference passed."); - } - log.debug("Writing appData_entry.dat as "+ref); - if (vdoc.writeAppdataFromStream(ref, istrm)) { - log.debug("Entry updated successfully."); - } else { - throw new IOException("writeAppdataFromStream did not return true - expect future badness."); // LATER - verify why this might occur. - } - } else { - throw new IOException("Couldn't find appData_entry.dat in temporary jar file "+apdjar.sessionFile.getAbsolutePath()); - } - istrm.close(); - } - /* (non-Javadoc) - * @see uk.ac.vamsas.client.IClientAppdata#getClientOutputStream() - */ - public AppDataOutputStream getClientOutputStream() { - if (clientdoc==null) - throw new Error("Implementation error, Improperly initialized SimpleClientAppdata."); - if (log.isDebugEnabled()) - log.debug("trying to getClientOutputStream for "+clientdoc.sclient.client.getClientUrn()); - return _getAppdataOutputStream(false); - } - - /* (non-Javadoc) - * @see uk.ac.vamsas.client.IClientAppdata#getUserOutputStream() - */ - public AppDataOutputStream getUserOutputStream() { - if (clientdoc==null) - throw new Error("Implementation error, Improperly initialized SimpleClientAppdata."); - if (log.isDebugEnabled()) - log.debug("trying to getUserOutputStream for (" - +clientdoc.sclient.getUserHandle().getFullName()+")"+clientdoc.sclient.client.getClientUrn()); - return _getAppdataOutputStream(true); - } - - /* (non-Javadoc) - * @see uk.ac.vamsas.client.IClientAppdata#hasClientAppdata() - */ - public boolean hasClientAppdata() { - if (clientdoc==null) - throw new Error("Implementation error, Improperly initialized SimpleClientAppdata."); - extractAppData(); - // LATER - check validity of a DataReference before we return true - // TODO: return true if usersData is null but we have already written a new data stream - if ((appsGlobal!=null) && (appsGlobal.getDataReference()!=null || appsGlobal.getData()!=null)) - return true; - return false; - } - - /* (non-Javadoc) - * @see uk.ac.vamsas.client.IClientAppdata#hasUserAppdata() - */ - public boolean hasUserAppdata() { - if (clientdoc==null) - throw new Error("Implementation error, Improperly initialized SimpleClientAppdata."); - extractAppData(); - // LATER - check validity of a DataReference before we return true - // TODO: return true if usersData is null but we have already written a new data stream - if ((usersData!=null) && (usersData.getDataReference()!=null || usersData.getData()!=null)) - return true; - return false; - } - private boolean _writeAppDataStream(JarOutputStream ostrm, byte[] data) { - try { - if (data!=null && data.length>0) - ostrm.write(data); - ostrm.closeEntry(); - return true; - } - catch (Exception e) { - log.error("Serious! - IO error when writing AppDataStream to file "+newAppData.sessionFile, e); - } - return false; - } - /* (non-Javadoc) - * @see uk.ac.vamsas.client.IClientAppdata#setClientAppdata(byte[]) - */ - public void setClientAppdata(byte[] data) { - if (clientdoc==null) - throw new Error("Implementation error, Improperly initialized SimpleClientAppdata."); - _getAppdataOutputStream(false); - if (newAppDataStream==null) { - // LATER: define an exception for this ? - operation may fail even if file i/o not involved - log.error("Serious! - couldn't open new AppDataStream in session directory "+clientdoc.sclient._session.sessionDir); - } else { - _writeAppDataStream(newAppDataStream, data); - // LATER: deal with error case - do we make session read only, or what ? - } - } - - /* (non-Javadoc) - * @see uk.ac.vamsas.client.IClientAppdata#setUserAppdata(byte[]) - */ - public void setUserAppdata(byte[] data) { - if (clientdoc==null) - throw new Error("Implementation error, Improperly initialized SimpleClientAppdata."); - _getAppdataOutputStream(true); - if (newUserDataStream==null) { - // LATER: define an exception for this ? - operation may fail even if file i/o not involved - log.error("Serious! - couldn't open new UserDataStream in session directory "+clientdoc.sclient._session.sessionDir); - } else { - _writeAppDataStream(newUserDataStream, data); - // LATER: deal with error case - do we make session read only, or what ? - } - } - /** - * flush and close outstanding output streams. - * - do this before checking data length. - * @throws IOException - */ - protected void closeForWriting() throws IOException { - if (newAppDataStream!=null) { - newAppDataStream.flush(); - newAppDataStream.closeEntry(); - newAppDataStream.close(); - } - if (newUserDataStream!=null) { - newUserDataStream.flush(); - newUserDataStream.closeEntry(); - newUserDataStream.close(); - } - } - - - /** - * - * @return true if any AppData blocks have to be updated in session Jar - */ - protected boolean isModified() { - // LATER differentiate between core xml modification and Jar Entry modification. - if ((newAppData!=null && newAppData.sessionFile.exists()) || (newUserData!=null && newUserData.sessionFile.exists())) - return true; - return false; - } - /* (non-Javadoc) - * @see java.lang.Object#finalize() - */ - protected void finalize() throws Throwable { - if (newAppDataStream!=null) { - newAppDataStream = null; - } - if (newAppDataStream!=null) { - newUserDataStream = null; - } - if (newAppData!=null) { - newAppData.eraseExistence(); - newAppData = null; - } - if (newUserData!=null) { - newUserData.eraseExistence(); - newUserData = null; - } - super.finalize(); - } - -} +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ +package uk.ac.vamsas.client.simpleclient; + +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.DataInput; +import java.io.DataInputStream; +import java.io.DataOutput; +import java.io.DataOutputStream; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.Vector; +import java.util.jar.JarEntry; +import java.util.jar.JarInputStream; +import java.util.jar.JarOutputStream; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import uk.ac.vamsas.client.AppDataInputStream; +import uk.ac.vamsas.client.AppDataOutputStream; +import uk.ac.vamsas.client.IClientAppdata; +import uk.ac.vamsas.objects.core.AppData; +import uk.ac.vamsas.objects.core.ApplicationData; +import uk.ac.vamsas.objects.core.User; +import uk.ac.vamsas.objects.utils.AppDataReference; + +/** + * @author jimp Access interface to data chunks read from a VamsasArchiveReader + * stream (or byte buffer input stream) or written to a VamsasArchive + * stream. // TODO: get VamsasArchiveReader from sclient + */ +public class SimpleClientAppdata implements IClientAppdata { + private static Log log = LogFactory.getLog(SimpleClientAppdata.class); + + /** + * has the session's document been accessed to get the AppData entrys? + */ + protected boolean accessedDocument = false; + + /** + * has the user datablock been modified ? temporary file containing new user + * specific application data chunk + */ + SessionFile newUserData = null; + + JarOutputStream newUserDataStream = null; + + /** + * has the apps global datablock been modified ? temporary file containing new + * global application data chunk + */ + SessionFile newAppData = null; + + JarOutputStream newAppDataStream = null; + + /** + * set by extractAppData + */ + protected ApplicationData appsGlobal = null; + + /** + * set by extractAppData + */ + protected User usersData = null; + + ClientDocument clientdoc; + + /** + * state flags - accessed ClientAppdata - accessed UserAppdata => inputStream + * from embedded xml or jar entry of backup has been created - set + * ClientAppdata - set UserAppdata => an output stream has been created and + * written to - or a data chunk has been written. - need flag for switching + * between embedded and jar entry mode ? - always write a jar entry for a + * stream. - need code for rewind and overwriting if the set*Appdata methods + * are called more than once. - need flags for streams to except a call to + * set*Appdata when an output stream exists and is open. - need + * + * @param clientdoc + * The ClientDocument instance that this IClientAppData is accessing + */ + protected SimpleClientAppdata(ClientDocument clientdoc) { + if (clientdoc == null) { + log + .fatal("Implementation error - Null ClientDocument for SimpleClientAppdata construction."); + throw new Error( + "Implementation error - Null ClientDocument for SimpleClientAppdata construction."); + } + this.clientdoc = clientdoc; + } + + /** + * ensures that the appData information for this client instance has been + * extracted from the vamsas document provided by clientdoc. + */ + private void extractAppData() { + if (!accessedDocument) + _extractAppData(clientdoc.getVamsasDocument()); + } + + /** + * gets appropriate app data for the application, if it exists in this dataset + * Called by every accessor to ensure data has been retrieved from document. + */ + private void _extractAppData(uk.ac.vamsas.objects.core.VamsasDocument doc) { + if (doc == null) { + log.debug("extractAppData called for null document object"); + return; + } + if (accessedDocument) { + return; + } + Vector apldataset = AppDataReference.getUserandApplicationsData(doc, + clientdoc.sclient.getUserHandle(), clientdoc.sclient.getClientHandle()); + accessedDocument = true; + if (apldataset != null) { + if (apldataset.size() > 0) { + AppData clientdat = (AppData) apldataset.get(0); + if (clientdat instanceof ApplicationData) { + appsGlobal = (ApplicationData) clientdat; + if (apldataset.size() > 1) { + clientdat = (AppData) apldataset.get(1); + if (clientdat instanceof User) { + usersData = (User) clientdat; + } + if (apldataset.size() > 2) + log.info("Ignoring additional (" + (apldataset.size() - 2) + + ") AppDatas returned by document appdata query."); + } + } else { + log.warn("Unexpected entry in AppDataReference query: id=" + + clientdat.getVorbaId() + " type=" + + clientdat.getClass().getName()); + } + apldataset.removeAllElements(); // destroy references. + } + } + } + + /** + * LATER: generalize this for different low-level session implementations (it + * may not always be a Jar) + * + * @param appdata + * @param docreader + * @return + */ + private InputStream getAppDataStream(AppData appdata, + VamsasArchiveReader docreader) { + String entryRef = appdata.getDataReference(); + if (entryRef != null) { + log.debug("Resolving appData reference +" + entryRef); + InputStream entry = docreader.getAppdataStream(entryRef); + if (entry != null) { + return entry; + // log.warn("Implementation problem - docreader didn't return a JarInputStream entry."); + } + } else { + log + .debug("GetAppDataStream called for an AppData without a data reference."); + } + return null; + } + + /** + * yuk - size of buffer used for slurping appData JarEntry into a byte array. + */ + private final int _TRANSFER_BUFFER = 4096 * 4; + + /** + * Resolve AppData object to a byte array. + * + * @param appdata + * @param archiveReader + * @return null or the application data as a byte array + */ + private byte[] getAppDataAsByteArray(AppData appdata, + VamsasArchiveReader docreader) { + if (appdata.getData() == null) { + if (docreader == null) { + log.warn("Silently failing getAppDataAsByteArray with null docreader.", + new Exception()); + return null; + } + // resolve and load data + InputStream entry = getAppDataStream(appdata, docreader); + ByteArrayOutputStream bytes = new ByteArrayOutputStream(); + try { + byte buff[] = new byte[_TRANSFER_BUFFER]; + int olen = 0; + while (entry != null && entry.available() > 0) { + int len = entry.read(buff, 0, _TRANSFER_BUFFER); + if (len > -1) { + bytes.write(buff, 0, len); + olen += len; + } + } + buff = null; + } catch (Exception e) { + log + .warn( + "Unexpected exception - probable truncation when accessing VamsasDocument entry " + + appdata.getDataReference(), e); + } + if (bytes.size() > 0) { + // LATER: deal with probable OutOfMemoryErrors here + log.debug("Got " + bytes.size() + " bytes from AppDataReference " + + appdata.getDataReference()); + byte data[] = bytes.toByteArray(); + bytes = null; + return data; + } + return null; + } else { + log.debug("Returning inline AppData block for " + appdata.getVorbaId()); + return appdata.getData(); + } + } + + /** + * internal method for getting a DataInputStream from an AppData object. + * + * @param appdata + * @param docreader + * @return data in object or null if no data is accessible + */ + private AppDataInputStream getAppDataAsDataInputStream(AppData appdata, + VamsasArchiveReader docreader) { + if (appdata != null && docreader != null) { + String entryRef = appdata.getDataReference(); + if (entryRef != null) { + log.debug("Resolving AppData reference for " + entryRef); + InputStream jstrm = docreader.getAppdataStream(entryRef); + if (jstrm != null) + return new AppDataInputStream(jstrm); + else { + log.debug("Returning null input stream for unresolved reference (" + + entryRef + ") id=" + appdata.getVorbaId()); + return null; + } + } else { + // return a byteArray input stream + byte[] data = appdata.getData(); + if (data.length > 0) { + ByteArrayInputStream stream = new ByteArrayInputStream(data); + return new AppDataInputStream(stream); + } else { + log + .debug("Returning null input stream for empty Appdata data block in id=" + + appdata.getVorbaId()); + return null; + } + } + } else { + log.debug("Returning null DataInputStream for appdata entry:" + + appdata.getVorbaId()); + } + return null; + } + + /** + * internal method for getting ByteArray from AppData object + * + * @param clientOrUser + * - true for returning userData, otherwise return Client AppData. + * @return null or byte array + */ + private byte[] _getappdataByteArray(boolean clientOrUser) { + if (clientdoc == null) + throw new Error( + "Implementation error, Improperly initialized SimpleClientAppdata."); + byte[] data = null; + String appdName; + if (!clientOrUser) { + appdName = "Client's Appdata"; + } else { + appdName = "User's Appdata"; + } + log.debug("getting " + appdName + " as a byte array"); + extractAppData(); + AppData object; + if (!clientOrUser) { + object = appsGlobal; + } else { + object = usersData; + } + if (object != null) { + log.debug("Trying to resolve " + appdName + " object to byte array."); + data = getAppDataAsByteArray(object, clientdoc.getVamsasArchiveReader()); + } + if (data == null) + log + .debug("Returning null for " + appdName + + "ClientAppdata byte[] array"); + return data; + + } + + /** + * common method for Client and User AppData->InputStream accessor + * + * @param clientOrUser + * - the appData to resolve - false for client, true for user + * appdata. + * @return null or the DataInputStream desired. + */ + private AppDataInputStream _getappdataInputStream(boolean clientOrUser) { + if (clientdoc == null) + throw new Error( + "Implementation error, Improperly initialized SimpleClientAppdata."); + String appdName; + if (!clientOrUser) { + appdName = "Client's Appdata"; + } else { + appdName = "User's Appdata"; + } + if (log.isDebugEnabled()) + log.debug("getting " + appdName + " as an input stream."); + extractAppData(); + AppData object; + if (!clientOrUser) { + object = appsGlobal; + } else { + object = usersData; + } + if (object != null) { + log.debug("Trying to resolve ClientAppdata object to an input stream."); + return getAppDataAsDataInputStream(object, clientdoc + .getVamsasArchiveReader()); + } + log.debug("getClientInputStream returning null."); + return null; + } + + /* + * (non-Javadoc) + * + * @see uk.ac.vamsas.client.IClientAppdata#getClientAppdata() + */ + public byte[] getClientAppdata() { + return _getappdataByteArray(false); + } + + /* + * (non-Javadoc) + * + * @see uk.ac.vamsas.client.IClientAppdata#getClientInputStream() + */ + public AppDataInputStream getClientInputStream() { + return _getappdataInputStream(false); + } + + /* + * (non-Javadoc) + * + * @see uk.ac.vamsas.client.IClientAppdata#getUserAppdata() + */ + public byte[] getUserAppdata() { + return _getappdataByteArray(true); + } + + /* + * (non-Javadoc) + * + * @see uk.ac.vamsas.client.IClientAppdata#getUserInputStream() + */ + public AppDataInputStream getUserInputStream() { + return _getappdataInputStream(true); + } + + /** + * methods for writing new AppData entries. + */ + private AppDataOutputStream _getAppdataOutputStream(boolean clientOrUser) { + // Must access document to get any existing references + extractAppData(); + String apdname; + SessionFile apdfile = null; + if (!clientOrUser) { + apdname = "clientAppData"; + apdfile = newAppData; + } else { + apdname = "userAppData"; + apdfile = newUserData; + } + try { + if (apdfile == null) { + apdfile = clientdoc.sclient._session + .getTempSessionFile(apdname, ".jar"); + log.debug("Successfully made temp appData file for " + apdname); + } else { + // truncate to remove existing data. + apdfile.fileLock.getRaFile().setLength(0); + log + .debug("Successfully truncated existing temp appData for " + + apdname); + } + } catch (Exception e) { + log.error("Whilst opening temp file in directory " + + clientdoc.sclient._session.sessionDir, e); + } + // we do not make another file for the new entry if one exists already + if (!clientOrUser) { + newAppData = apdfile; + } else { + newUserData = apdfile; + } + try { + apdfile.lockFile(); + // LATER: Refactor these local AppDatastream IO stuff to their own class. + JarOutputStream dstrm = new JarOutputStream(apdfile.fileLock + .getBufferedOutputStream(true)); + if (!clientOrUser) { + newAppDataStream = dstrm; + } else { + newUserDataStream = dstrm; + } + dstrm.putNextEntry(new JarEntry("appData_entry.dat")); + // LATER: there may be trouble ahead if an AppDataOutputStream is written + // to by one thread when another truncates the file. This situation should + // be prevented if possible + return new AppDataOutputStream(dstrm); + } catch (Exception e) { + log.error("Whilst opening jar output stream for file " + + apdfile.sessionFile); + } + // tidy up and return null + apdfile.unlockFile(); + return null; + } + + /** + * copy data from the appData jar file to an appropriately referenced jar or + * Data entry for the given ApplicationData Assumes the JarFile is properly + * closed. + * + * @param vdoc + * session Document handler + * @param appd + * the AppData whose block is being updated + * @param apdjar + * the new data in a Jar written by this class + */ + protected void updateAnAppdataEntry(VamsasArchive vdoc, AppData appd, + SessionFile apdjar) throws IOException { + if (apdjar == null || apdjar.sessionFile == null + || !apdjar.sessionFile.exists()) { + throw new IOException("No temporary Appdata to recover and transfer."); + } + if (vdoc == null) { + log.fatal("FATAL! NO DOCUMENT TO WRITE TO!"); + throw new IOException("FATAL! NO DOCUMENT TO WRITE TO!"); + } + log.debug("Recovering AppData entry from " + apdjar.sessionFile); + JarInputStream istrm = new JarInputStream(apdjar + .getBufferedInputStream(true)); + JarEntry je = null; + while (istrm.available() > 0 && (je = istrm.getNextJarEntry()) != null + && !je.getName().equals("appData_entry.dat")) { + if (je != null) + log.debug("Ignoring extraneous entry " + je.getName()); + } + if (istrm.available() > 0 && je != null) { + log.debug("Found appData_entry.dat in Jar"); + String ref = appd.getDataReference(); + if (ref == null) { + throw new IOException("Null AppData.DataReference passed."); + } + log.debug("Writing appData_entry.dat as " + ref); + if (vdoc.writeAppdataFromStream(ref, istrm)) { + log.debug("Entry updated successfully."); + } else { + throw new IOException( + "writeAppdataFromStream did not return true - expect future badness."); // LATER + // - + // verify + // why + // this + // might + // occur. + } + } else { + throw new IOException( + "Couldn't find appData_entry.dat in temporary jar file " + + apdjar.sessionFile.getAbsolutePath()); + } + istrm.close(); + } + + /* + * (non-Javadoc) + * + * @see uk.ac.vamsas.client.IClientAppdata#getClientOutputStream() + */ + public AppDataOutputStream getClientOutputStream() { + if (clientdoc == null) + throw new Error( + "Implementation error, Improperly initialized SimpleClientAppdata."); + if (log.isDebugEnabled()) + log.debug("trying to getClientOutputStream for " + + clientdoc.sclient.client.getClientUrn()); + return _getAppdataOutputStream(false); + } + + /* + * (non-Javadoc) + * + * @see uk.ac.vamsas.client.IClientAppdata#getUserOutputStream() + */ + public AppDataOutputStream getUserOutputStream() { + if (clientdoc == null) + throw new Error( + "Implementation error, Improperly initialized SimpleClientAppdata."); + if (log.isDebugEnabled()) + log.debug("trying to getUserOutputStream for (" + + clientdoc.sclient.getUserHandle().getFullName() + ")" + + clientdoc.sclient.client.getClientUrn()); + return _getAppdataOutputStream(true); + } + + /* + * (non-Javadoc) + * + * @see uk.ac.vamsas.client.IClientAppdata#hasClientAppdata() + */ + public boolean hasClientAppdata() { + if (clientdoc == null) + throw new Error( + "Implementation error, Improperly initialized SimpleClientAppdata."); + extractAppData(); + // LATER - check validity of a DataReference before we return true + // TODO: return true if usersData is null but we have already written a new + // data stream + if ((appsGlobal != null) + && (appsGlobal.getDataReference() != null || appsGlobal.getData() != null)) + return true; + return false; + } + + /* + * (non-Javadoc) + * + * @see uk.ac.vamsas.client.IClientAppdata#hasUserAppdata() + */ + public boolean hasUserAppdata() { + if (clientdoc == null) + throw new Error( + "Implementation error, Improperly initialized SimpleClientAppdata."); + extractAppData(); + // LATER - check validity of a DataReference before we return true + // TODO: return true if usersData is null but we have already written a new + // data stream + if ((usersData != null) + && (usersData.getDataReference() != null || usersData.getData() != null)) + return true; + return false; + } + + private boolean _writeAppDataStream(JarOutputStream ostrm, byte[] data) { + try { + if (data != null && data.length > 0) + ostrm.write(data); + ostrm.closeEntry(); + return true; + } catch (Exception e) { + log.error("Serious! - IO error when writing AppDataStream to file " + + newAppData.sessionFile, e); + } + return false; + } + + /* + * (non-Javadoc) + * + * @see uk.ac.vamsas.client.IClientAppdata#setClientAppdata(byte[]) + */ + public void setClientAppdata(byte[] data) { + if (clientdoc == null) + throw new Error( + "Implementation error, Improperly initialized SimpleClientAppdata."); + _getAppdataOutputStream(false); + if (newAppDataStream == null) { + // LATER: define an exception for this ? - operation may fail even if file + // i/o not involved + log + .error("Serious! - couldn't open new AppDataStream in session directory " + + clientdoc.sclient._session.sessionDir); + } else { + _writeAppDataStream(newAppDataStream, data); + // LATER: deal with error case - do we make session read only, or what ? + } + } + + /* + * (non-Javadoc) + * + * @see uk.ac.vamsas.client.IClientAppdata#setUserAppdata(byte[]) + */ + public void setUserAppdata(byte[] data) { + if (clientdoc == null) + throw new Error( + "Implementation error, Improperly initialized SimpleClientAppdata."); + _getAppdataOutputStream(true); + if (newUserDataStream == null) { + // LATER: define an exception for this ? - operation may fail even if file + // i/o not involved + log + .error("Serious! - couldn't open new UserDataStream in session directory " + + clientdoc.sclient._session.sessionDir); + } else { + _writeAppDataStream(newUserDataStream, data); + // LATER: deal with error case - do we make session read only, or what ? + } + } + + /** + * flush and close outstanding output streams. - do this before checking data + * length. + * + * @throws IOException + */ + protected void closeForWriting() throws IOException { + if (newAppDataStream != null) { + newAppDataStream.flush(); + newAppDataStream.closeEntry(); + newAppDataStream.close(); + } + if (newUserDataStream != null) { + newUserDataStream.flush(); + newUserDataStream.closeEntry(); + newUserDataStream.close(); + } + } + + /** + * + * @return true if any AppData blocks have to be updated in session Jar + */ + protected boolean isModified() { + // LATER differentiate between core xml modification and Jar Entry + // modification. + if ((newAppData != null && newAppData.sessionFile.exists()) + || (newUserData != null && newUserData.sessionFile.exists())) + return true; + return false; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#finalize() + */ + protected void finalize() throws Throwable { + if (newAppDataStream != null) { + newAppDataStream = null; + } + if (newAppDataStream != null) { + newUserDataStream = null; + } + if (newAppData != null) { + newAppData.eraseExistence(); + newAppData = null; + } + if (newUserData != null) { + newUserData.eraseExistence(); + newUserData = null; + } + super.finalize(); + } + +} diff --git a/src/uk/ac/vamsas/client/simpleclient/SimpleClientConfig.java b/src/uk/ac/vamsas/client/simpleclient/SimpleClientConfig.java index 379d3a0..1728f18 100644 --- a/src/uk/ac/vamsas/client/simpleclient/SimpleClientConfig.java +++ b/src/uk/ac/vamsas/client/simpleclient/SimpleClientConfig.java @@ -1,15 +1,41 @@ +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ package uk.ac.vamsas.client.simpleclient; + /** * Config for SimpleClient - a basic Vamsas Client Interface implementation. + * * @author JimP - * + * */ public class SimpleClientConfig { - public boolean _validatemergedroots=false; - public boolean _validateupdatedroots=false; + public boolean _validatemergedroots = false; + + public boolean _validateupdatedroots = false; + /** - * New VAMSAS roots added (merged) into the document - * will be validated before actually being added. + * New VAMSAS roots added (merged) into the document will be validated before + * actually being added. + * * @return */ public boolean validateMergedRoots() { @@ -17,13 +43,13 @@ public class SimpleClientConfig { } /** - * existing VAMSAS roots that may have been modified - * will be validated before the updated document can - * be written. + * existing VAMSAS roots that may have been modified will be validated before + * the updated document can be written. + * * @return */ public boolean validateUpdatedRoots() { return _validateupdatedroots; } - + } diff --git a/src/uk/ac/vamsas/client/simpleclient/SimpleClientFactory.java b/src/uk/ac/vamsas/client/simpleclient/SimpleClientFactory.java index 27aaf77..43cc4b6 100644 --- a/src/uk/ac/vamsas/client/simpleclient/SimpleClientFactory.java +++ b/src/uk/ac/vamsas/client/simpleclient/SimpleClientFactory.java @@ -1,12 +1,24 @@ -/** +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. * - * VAMSAS Project - * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. * - * Dec 13, 2006 - * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.client.simpleclient; import java.io.File; @@ -107,8 +119,8 @@ public class SimpleClientFactory implements IClientFactory { /** * @see uk.ac.vamsas.client.IClientFactory#getIClient(uk.ac.vamsas.client.ClientHandle) * - * Creates a IClient object, using default UserHandle with system - * variables:"user.name" or "USERNAME")), "host.name" or "HOSTNAME" + * Creates a IClient object, using default UserHandle with system + * variables:"user.name" or "USERNAME")), "host.name" or "HOSTNAME" */ public IClient getIClient(ClientHandle applicationHandle) throws NoDefaultSessionException { @@ -172,25 +184,28 @@ public class SimpleClientFactory implements IClientFactory { .debug("found session directory " + sessionDirectory.getAbsolutePath()); VamsasSession vamsasSession = new VamsasSession(sessionDirectory); - + /* * if (userId == null) { //create a default userHandle //with current OS - * user and hostname userId = new UserHandle(System.getProperty("user.name", + * user and hostname userId = new + * UserHandle(System.getProperty("user.name", * System.getProperty("USERNAME","Joe Doe")), - * System.getProperty("host.name",System.getProperty("HOSTNAME", "Unknown") - * ));// clientName, clientVersion, sessionPath); } + * System.getProperty("host.name",System.getProperty("HOSTNAME", + * "Unknown") ));// clientName, clientVersion, sessionPath); } * * * //create simple client client = new SimpleClient(userId, * applicationHandle, vamsasSession); */ - client = this.initClient(sessionDirectory, userId, applicationHandle, null); + client = this.initClient(sessionDirectory, userId, applicationHandle, + null); } catch (MalformedURLException e) { log.error("error while creating new IClient: incorrect session urn", e); client = null; - } catch (InvalidSessionDocumentException e) - { - log.error("error while creating new IClient: invalid session document", e); + } catch (InvalidSessionDocumentException e) { + log + .error("error while creating new IClient: invalid session document", + e); client = null; } catch (InvalidSessionUrnException e) { log.error("error while creating new IClient: incorrect session urn", e); @@ -201,23 +216,32 @@ public class SimpleClientFactory implements IClientFactory { } return client; } + /** - * initialise the vamsas session state and create a SimpleClient object to connect to it - * @param sessdir newly created or existing session directory - * @param userId + * initialise the vamsas session state and create a SimpleClient object to + * connect to it + * + * @param sessdir + * newly created or existing session directory + * @param userId * @param clientHandle - * @param vamsasDocument null or a document to pass to SimpleCLient to write into the sessdir + * @param vamsasDocument + * null or a document to pass to SimpleCLient to write into the + * sessdir * @return the client - * @throws IOException if there are problems in session or client creation or if the session already has a vamsasDocument - * @throws InvalidSessionUrnException for a malformed sessdir + * @throws IOException + * if there are problems in session or client creation or if the + * session already has a vamsasDocument + * @throws InvalidSessionUrnException + * for a malformed sessdir */ private IClient initClient(File sessdir, UserHandle userId, - ClientHandle clientHandle, File vamsasDocument) throws IOException, InvalidSessionUrnException, InvalidSessionDocumentException { + ClientHandle clientHandle, File vamsasDocument) throws IOException, + InvalidSessionUrnException, InvalidSessionDocumentException { IClient client = null; // create session VamsasSession vamsasSession = null; - if (vamsasDocument==null) - { + if (vamsasDocument == null) { vamsasSession = new VamsasSession(sessdir); } else { vamsasSession = new VamsasSession(sessdir, vamsasDocument); @@ -295,7 +319,8 @@ public class SimpleClientFactory implements IClientFactory { // check if any available session(s) String[] availableSessions = this.getCurrentSessions(); if (availableSessions != null) {// there are available sessions - if (availableSessions.length > 1) {// more than one session if available... can not choose + if (availableSessions.length > 1) {// more than one session if + // available... can not choose // represents list of session as String StringBuffer sessionURNs = new StringBuffer(""); @@ -317,43 +342,47 @@ public class SimpleClientFactory implements IClientFactory { // no session available - create a new one try { client = clientInNewSession(userId, clientHandle, null); - } catch (Exception e) - { - throw new Error("IMPLEMENTATION ERROR: unexpected exception when creating a new session to connect to.",e); + } catch (Exception e) { + throw new Error( + "IMPLEMENTATION ERROR: unexpected exception when creating a new session to connect to.", + e); } return client; } /** - * create a new session directory and possibly import an existing document into it + * create a new session directory and possibly import an existing document + * into it + * * @param userId * @param clientHandle - * @param vamsasDocument null or a document file to copy into the new session + * @param vamsasDocument + * null or a document file to copy into the new session * @return null or a valid IClient instance */ private IClient clientInNewSession(UserHandle userId, - ClientHandle clientHandle, File vamsasDocument) throws InvalidSessionDocumentException, InvalidSessionUrnException{ + ClientHandle clientHandle, File vamsasDocument) + throws InvalidSessionDocumentException, InvalidSessionUrnException { IClient client = null; try { // try and make a friendly session name String sesspref = ""; - if (vamsasDocument!=null) - { - sesspref = vamsasDocument.getName().replaceAll("([^-A-Za-z0-9]|\\.vdj)", ""); + if (vamsasDocument != null) { + sesspref = vamsasDocument.getName().replaceAll( + "([^-A-Za-z0-9]|\\.vdj)", ""); } - sesspref += (new java.util.Date()).toString().replaceAll("[^-A-Za-z0-9]","_"); + sesspref += (new java.util.Date()).toString().replaceAll("[^-A-Za-z0-9]", + "_"); // create sessionDirectory - File sessdir = new File(sessionArena, sesspref+".simpleclient"); - if (sessdir.exists()) - { + File sessdir = new File(sessionArena, sesspref + ".simpleclient"); + if (sessdir.exists()) { // make a unique session name - sessdir = File.createTempFile(sesspref, ".simpleclient", - sessionArena); + sessdir = File.createTempFile(sesspref, ".simpleclient", sessionArena); } else { - if (!sessdir.createNewFile()) - { - throw new Error("VAMSAS Implementation error : sesspref friendly session name is invalid on this platform - please tell the authors!"); + if (!sessdir.createNewFile()) { + throw new Error( + "VAMSAS Implementation error : sesspref friendly session name is invalid on this platform - please tell the authors!"); } } log.debug("Creating new session directory"); @@ -363,8 +392,8 @@ public class SimpleClientFactory implements IClientFactory { } catch (IOException e) { log.error("error while creating new IClient", e); } catch (InvalidSessionUrnException e) { - log.error("Unable to create new IClient. The new session urn is malformed.", - e); + log.error( + "Unable to create new IClient. The new session urn is malformed.", e); } return client; @@ -398,9 +427,8 @@ public class SimpleClientFactory implements IClientFactory { public IClient getNewSessionIClient(ClientHandle applicationHandle) { try { return clientInNewSession(null, applicationHandle, null); - } - catch (Exception e) { - log.error("Failed to create new session for app with default user.",e); + } catch (Exception e) { + log.error("Failed to create new session for app with default user.", e); } return null; } @@ -410,40 +438,41 @@ public class SimpleClientFactory implements IClientFactory { try { return clientInNewSession(userId, applicationHandle, null); } catch (Exception e) { - log.error("Failed to create new session for app and user.",e); + log.error("Failed to create new session for app and user.", e); } return null; } - private void checkImportedDocument(File vamsasDocument) throws InvalidSessionDocumentException - { - if (!vamsasDocument.exists()) - { - throw new InvalidSessionDocumentException("File "+vamsasDocument+" does not exist"); + + private void checkImportedDocument(File vamsasDocument) + throws InvalidSessionDocumentException { + if (!vamsasDocument.exists()) { + throw new InvalidSessionDocumentException("File " + vamsasDocument + + " does not exist"); } - if (!vamsasDocument.canRead()) - { - throw new InvalidSessionDocumentException("File "+vamsasDocument+" does not exist"); + if (!vamsasDocument.canRead()) { + throw new InvalidSessionDocumentException("File " + vamsasDocument + + " does not exist"); } } + public IClient openAsNewSessionIClient(ClientHandle applicationHandle, File vamsasDocument) throws InvalidSessionDocumentException { - checkImportedDocument(vamsasDocument); + checkImportedDocument(vamsasDocument); try { return clientInNewSession(null, applicationHandle, vamsasDocument); - } catch (InvalidSessionUrnException e) - { + } catch (InvalidSessionUrnException e) { throw new InvalidSessionDocumentException("Unexpected exception", e); } } public IClient openAsNewSessionIClient(ClientHandle applicationHandle, - UserHandle userId, File vamsasDocument) throws InvalidSessionDocumentException { - checkImportedDocument(vamsasDocument); + UserHandle userId, File vamsasDocument) + throws InvalidSessionDocumentException { + checkImportedDocument(vamsasDocument); try { - return clientInNewSession(userId, applicationHandle, vamsasDocument); - } catch (InvalidSessionUrnException e) - { - throw new InvalidSessionDocumentException("Unexpected exception", e); + return clientInNewSession(userId, applicationHandle, vamsasDocument); + } catch (InvalidSessionUrnException e) { + throw new InvalidSessionDocumentException("Unexpected exception", e); } } diff --git a/src/uk/ac/vamsas/client/simpleclient/SimpleDocBinding.java b/src/uk/ac/vamsas/client/simpleclient/SimpleDocBinding.java index 6815706..895bb0f 100644 --- a/src/uk/ac/vamsas/client/simpleclient/SimpleDocBinding.java +++ b/src/uk/ac/vamsas/client/simpleclient/SimpleDocBinding.java @@ -1,139 +1,180 @@ -package uk.ac.vamsas.client.simpleclient; - -import java.io.BufferedInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.util.Vector; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import uk.ac.vamsas.client.Vobject; -import uk.ac.vamsas.client.VorbaIdFactory; -import uk.ac.vamsas.client.VorbaXmlBinder; -import uk.ac.vamsas.objects.core.VAMSAS; -import uk.ac.vamsas.objects.core.VamsasDocument; -import uk.ac.vamsas.objects.utils.AppDataReference; -import uk.ac.vamsas.objects.utils.DocumentStuff; -import uk.ac.vamsas.objects.utils.ProvenanceStuff; -import uk.ac.vamsas.objects.utils.document.VersionEntries; - -/** - * Base class for SimpleClient Vamsas Document Object Manipulation - * holds static vamsasDocument from XML routines and - * state objects for a particular unmarshalled Document instance. - * @author jimp - */ - - -public class SimpleDocBinding { - - protected VorbaIdFactory vorba; - protected static Log log = LogFactory.getLog(SimpleDocBinding.class); - - /** - * @return Returns the vorba. - */ - public VorbaIdFactory getVorba() { - return vorba; - } - - /** - * @param vorba The vorba to set. - */ - public void setVorba(VorbaIdFactory vorba) { - this.vorba = vorba; - } - - /** - * Uses VorbaXmlBinder to retrieve the VamsasDocument from the given stream - */ - public VamsasDocument getVamsasDocument(VamsasArchiveReader oReader) throws IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - if (oReader!=null) { - // check the factory - if (vorba==null) { - log.error("Invalid SimpleDocument construction - no VorbaIdFactory defined!"); - return null; - } - - if (oReader.isValid()) { - // Read vamsasDocument.xsd instance - InputStreamReader vdoc = new InputStreamReader(oReader.getVamsasDocumentStream()); - Object unmarsh[] = VorbaXmlBinder.getVamsasObjects(vdoc, vorba, new VamsasDocument()); - if (unmarsh==null) - log.fatal("Couldn't unmarshall document!"); - - Vobject vobjs = (Vobject) unmarsh[0]; - if (vobjs!=null) { - VamsasDocument doc=(VamsasDocument) vobjs; - if (doc!=null) - return doc; - } - log.debug("Found no VamsasDocument object in properly formatted Vamsas Archive."); - } else { - // deprecated data handler (vamsas.xsd instance) - InputStream vxmlis = oReader.getVamsasXmlStream(); - if (vxmlis!=null) { // Might be an old vamsas file. - BufferedInputStream ixml = new BufferedInputStream(oReader.getVamsasXmlStream()); - InputStreamReader vxml = new InputStreamReader(ixml); - Object unmarsh[] = VorbaXmlBinder.getVamsasObjects(vxml, vorba, new VAMSAS()); - - if (unmarsh==null) - log.fatal("Couldn't unmarshall document!"); - - VAMSAS root[]= new VAMSAS[] { null}; - root[0] = (VAMSAS) unmarsh[0]; - - if (root[0]==null) { - log.debug("Found no VAMSAS object in VamsasXML stream."); - } else { - log.debug("Making new VamsasDocument from VamsasXML stream."); - VamsasDocument doc = DocumentStuff.newVamsasDocument(root, - ProvenanceStuff.newProvenance( - vorba.getUserHandle().getFullName(), - "Vamsas Document constructed from vamsas.xml"), VersionEntries.ALPHA_VERSION); - // VAMSAS: decide on 'system' operations provenance form - // LATER: implement classes for translating Vorba properties into provenance user fields. - // VAMSAS: decide on machine readable info embedding in provenance should be done - root[0]=null; - root=null; - return doc; - } - } - } - } - // otherwise - there was no valid original document to read. - return null; - } - - /** - * Extract all jarEntries in an archive referenced by the vamsas document - * LATER: a family of methods for finding extraneous jarEntries , and invalid appDataReferences - * @param doc - * @param oReader - * @return array of the subset of JarEntry names that are referenced in doc - */ - public Vector getReferencedEntries(VamsasDocument doc, VamsasArchiveReader oReader) { - if (oReader==null) - return null; - if (doc==null) { - try { doc = getVamsasDocument(oReader); } - catch (Exception e) { log.warn("Failed to get document from "+oReader.jfileName); }; - } - Vector docrefs = AppDataReference.getAppDataReferences(doc); - if (docrefs==null) - return null; - Vector entries = oReader.getExtraEntries(); - if (entries!=null && entries.size()>0 && docrefs.size()>0) { - int i=0, j=entries.size(); - do { - if (!docrefs.contains(entries.get(i))) { - entries.remove(i); - j--; - } else - i++; - } while (i. + */ +package uk.ac.vamsas.client.simpleclient; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.Vector; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import uk.ac.vamsas.client.Vobject; +import uk.ac.vamsas.client.VorbaIdFactory; +import uk.ac.vamsas.client.VorbaXmlBinder; +import uk.ac.vamsas.objects.core.VAMSAS; +import uk.ac.vamsas.objects.core.VamsasDocument; +import uk.ac.vamsas.objects.utils.AppDataReference; +import uk.ac.vamsas.objects.utils.DocumentStuff; +import uk.ac.vamsas.objects.utils.ProvenanceStuff; +import uk.ac.vamsas.objects.utils.document.VersionEntries; + +/** + * Base class for SimpleClient Vamsas Document Object Manipulation holds static + * vamsasDocument from XML routines and state objects for a particular + * unmarshalled Document instance. + * + * @author jimp + */ + +public class SimpleDocBinding { + + protected VorbaIdFactory vorba; + + protected static Log log = LogFactory.getLog(SimpleDocBinding.class); + + /** + * @return Returns the vorba. + */ + public VorbaIdFactory getVorba() { + return vorba; + } + + /** + * @param vorba + * The vorba to set. + */ + public void setVorba(VorbaIdFactory vorba) { + this.vorba = vorba; + } + + /** + * Uses VorbaXmlBinder to retrieve the VamsasDocument from the given stream + */ + public VamsasDocument getVamsasDocument(VamsasArchiveReader oReader) + throws IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + if (oReader != null) { + // check the factory + if (vorba == null) { + log + .error("Invalid SimpleDocument construction - no VorbaIdFactory defined!"); + return null; + } + + if (oReader.isValid()) { + // Read vamsasDocument.xsd instance + InputStreamReader vdoc = new InputStreamReader(oReader + .getVamsasDocumentStream()); + Object unmarsh[] = VorbaXmlBinder.getVamsasObjects(vdoc, vorba, + new VamsasDocument()); + if (unmarsh == null) + log.fatal("Couldn't unmarshall document!"); + + Vobject vobjs = (Vobject) unmarsh[0]; + if (vobjs != null) { + VamsasDocument doc = (VamsasDocument) vobjs; + if (doc != null) + return doc; + } + log + .debug("Found no VamsasDocument object in properly formatted Vamsas Archive."); + } else { + // deprecated data handler (vamsas.xsd instance) + InputStream vxmlis = oReader.getVamsasXmlStream(); + if (vxmlis != null) { // Might be an old vamsas file. + BufferedInputStream ixml = new BufferedInputStream(oReader + .getVamsasXmlStream()); + InputStreamReader vxml = new InputStreamReader(ixml); + Object unmarsh[] = VorbaXmlBinder.getVamsasObjects(vxml, vorba, + new VAMSAS()); + + if (unmarsh == null) + log.fatal("Couldn't unmarshall document!"); + + VAMSAS root[] = new VAMSAS[] { null }; + root[0] = (VAMSAS) unmarsh[0]; + + if (root[0] == null) { + log.debug("Found no VAMSAS object in VamsasXML stream."); + } else { + log.debug("Making new VamsasDocument from VamsasXML stream."); + VamsasDocument doc = DocumentStuff.newVamsasDocument(root, + ProvenanceStuff.newProvenance(vorba.getUserHandle() + .getFullName(), + "Vamsas Document constructed from vamsas.xml"), + VersionEntries.ALPHA_VERSION); + // VAMSAS: decide on 'system' operations provenance form + // LATER: implement classes for translating Vorba properties into + // provenance user fields. + // VAMSAS: decide on machine readable info embedding in provenance + // should be done + root[0] = null; + root = null; + return doc; + } + } + } + } + // otherwise - there was no valid original document to read. + return null; + } + + /** + * Extract all jarEntries in an archive referenced by the vamsas document + * LATER: a family of methods for finding extraneous jarEntries , and invalid + * appDataReferences + * + * @param doc + * @param oReader + * @return array of the subset of JarEntry names that are referenced in doc + */ + public Vector getReferencedEntries(VamsasDocument doc, + VamsasArchiveReader oReader) { + if (oReader == null) + return null; + if (doc == null) { + try { + doc = getVamsasDocument(oReader); + } catch (Exception e) { + log.warn("Failed to get document from " + oReader.jfileName); + } + ; + } + Vector docrefs = AppDataReference.getAppDataReferences(doc); + if (docrefs == null) + return null; + Vector entries = oReader.getExtraEntries(); + if (entries != null && entries.size() > 0 && docrefs.size() > 0) { + int i = 0, j = entries.size(); + do { + if (!docrefs.contains(entries.get(i))) { + entries.remove(i); + j--; + } else + i++; + } while (i < j); + } + return entries; + } +} diff --git a/src/uk/ac/vamsas/client/simpleclient/SimpleDocument.java b/src/uk/ac/vamsas/client/simpleclient/SimpleDocument.java index b569afb..f4b7a15 100644 --- a/src/uk/ac/vamsas/client/simpleclient/SimpleDocument.java +++ b/src/uk/ac/vamsas/client/simpleclient/SimpleDocument.java @@ -1,29 +1,52 @@ -package uk.ac.vamsas.client.simpleclient; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import uk.ac.vamsas.client.VorbaIdFactory; - -/** - * @see SimpleDocBinding - * Additional constructors for 'headless' Vamsas Document access - * @author jimp - */ -public class SimpleDocument extends SimpleDocBinding { - private static Log log = LogFactory.getLog(SimpleDocument.class); - - private VorbaIdFactory makeDefaultFactory(String name) { - return IdFactory.getDummyFactory(name); - } - - public SimpleDocument(String name) { - vorba = makeDefaultFactory(name); - } - public SimpleDocument(VorbaIdFactory Vorba) { - if (Vorba!=null) - vorba = Vorba; - else - log.error("Invalid SimpleDocument construction - no VorbaIdFactory defined!"); - } -} +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ +package uk.ac.vamsas.client.simpleclient; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import uk.ac.vamsas.client.VorbaIdFactory; + +/** + * @see SimpleDocBinding Additional constructors for 'headless' Vamsas Document + * access + * @author jimp + */ +public class SimpleDocument extends SimpleDocBinding { + private static Log log = LogFactory.getLog(SimpleDocument.class); + + private VorbaIdFactory makeDefaultFactory(String name) { + return IdFactory.getDummyFactory(name); + } + + public SimpleDocument(String name) { + vorba = makeDefaultFactory(name); + } + + public SimpleDocument(VorbaIdFactory Vorba) { + if (Vorba != null) + vorba = Vorba; + else + log + .error("Invalid SimpleDocument construction - no VorbaIdFactory defined!"); + } +} diff --git a/src/uk/ac/vamsas/client/simpleclient/SimplePickManager.java b/src/uk/ac/vamsas/client/simpleclient/SimplePickManager.java index 5f92d37..1eabeac 100644 --- a/src/uk/ac/vamsas/client/simpleclient/SimplePickManager.java +++ b/src/uk/ac/vamsas/client/simpleclient/SimplePickManager.java @@ -1,3 +1,24 @@ +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ package uk.ac.vamsas.client.simpleclient; import org.apache.commons.logging.*; @@ -6,18 +27,21 @@ import uk.ac.vamsas.client.picking.IMessageHandler; import uk.ac.vamsas.client.picking.IPickManager; import uk.ac.vamsas.client.picking.Message; import uk.ac.vamsas.client.picking.SocketManager; + /** * Blocking message handler + * * @author - * + * */ public class SimplePickManager implements IPickManager { private Log log = LogFactory.getLog(SimplePickManager.class); - - SocketManager manager=null; + + SocketManager manager = null; + SimplePickManager(SocketManager manager) { - this.manager=manager; - final SimplePickManager me=this; + this.manager = manager; + final SimplePickManager me = this; /** * add a handler that calls the SimplePickManager message handler */ @@ -26,45 +50,54 @@ public class SimplePickManager implements IPickManager { me.handleMessage(message); } }); - + } + /** * when false, messages are queued in a FIFO until thread can restart. */ - private boolean passThru=true; + private boolean passThru = true; + /** - * internal flag - set to true to sleep until passThru is true before passing on a message + * internal flag - set to true to sleep until passThru is true before passing + * on a message */ - private boolean qUEUE=false; + private boolean qUEUE = false; + /** * the client apps message handler */ - IMessageHandler pickHandler=null; + IMessageHandler pickHandler = null; + public void registerMessageHandler(IMessageHandler handler) { - pickHandler=handler; - + pickHandler = handler; + } public synchronized void sendMessage(Message message) { // throw away messages whilst we block - if (passThru && manager!=null) + if (passThru && manager != null) manager.sendMessage(message); } + /** - * pass message onto the Apps handler, or wait until - * passThru is true before passing message on. + * pass message onto the Apps handler, or wait until passThru is true before + * passing message on. + * * @param message */ protected synchronized void handleMessage(Message message) { if (qUEUE) { - while (!passThru && manager!=null) { - log.debug("Not passing through."); - try { - Thread.sleep(5); - } catch (InterruptedException e) {}; - } + while (!passThru && manager != null) { + log.debug("Not passing through."); + try { + Thread.sleep(5); + } catch (InterruptedException e) { + } + ; + } } - if (passThru && manager!=null) + if (passThru && manager != null) pickHandler.handleMessage(message); } @@ -76,19 +109,21 @@ public class SimplePickManager implements IPickManager { } /** - * @param true to pass messages on to handlers, false to hold messages in queue + * @param true to pass messages on to handlers, false to hold messages in + * queue */ public void setPassThru(boolean passThru) { this.passThru = passThru; } + /** * shutdown the pickmanager and remove all references to it */ public void shutdown() { - passThru=false; + passThru = false; manager.registerMessageHandler(null); SocketManager dying = manager; - manager=null; - dying.shutdown(); + manager = null; + dying.shutdown(); } } diff --git a/src/uk/ac/vamsas/client/simpleclient/SimpleSessionManager.java b/src/uk/ac/vamsas/client/simpleclient/SimpleSessionManager.java index 332f7e5..ea5fb60 100644 --- a/src/uk/ac/vamsas/client/simpleclient/SimpleSessionManager.java +++ b/src/uk/ac/vamsas/client/simpleclient/SimpleSessionManager.java @@ -1,106 +1,114 @@ -/* -* VAMSAS Project -* -* Dec 15, 2006 -* -*/ - -package uk.ac.vamsas.client.simpleclient; - -import java.io.File; -import java.io.IOException; - -import uk.ac.vamsas.client.SessionHandle; - -/** - * Class to deal with sessions - * - * retrieves list of available sessions - * - * adds an active session - * - * removes a close session (the last client has been closed) - * - * - */ -public class SimpleSessionManager -{ - private SessionsFile sessionFile = null; - - - protected SimpleSessionManager(File sessionsFile) throws IOException - { - this.initManagerObjects(sessionsFile); - } - -/** - * construct SessionFile objects and watchers for each - */ -private void initManagerObjects(File sessionsFile) throws IOException - { - if (this.sessionFile!=null ) - throw new IOException("initFactoryObjects called for initialised ClientFactory object."); - this.sessionFile = new SessionsFile(sessionsFile); - } - - -/** - * make a new watcher object for the sessionsFile - * @return new SessionsFile watcher instance - */ -public FileWatcher getSessionsWatcher() { - return new FileWatcher(this.getSessionFile().sessionFile); -} - -/** - * @see uk.ac.vamsas.client.IClientFactory#getCurrentSessions() - */ -public String[] getCurrentSessions() -{ - String[] sessions = null; - if (this.sessionFile!=null ) - { - SessionHandle[] sessionHandles = this.sessionFile.retrieveSessionsList(); - if (sessionHandles != null) - { - sessions = new String[sessionHandles.length]; - for (int i = sessionHandles.length -1; i > -1; i--) - { - SessionHandle sessionHandle = sessionHandles[i]; - sessions [i] = sessionHandle.getSessionUrn(); - } - } - } - return sessions; -} - -/** - * adds SessionHandle me to the sessionList - * @param newSession session to add to the session list - * @return session index in list or 0 if lock was invalid or addSession operation failed. - */ -public int addSession(SessionHandle newSession) - { - return this.sessionFile.addSession(newSession, false,this.getSessionsWatcher().getChangedState()); - } - -/** - * @return the sessionFile - */ -private SessionsFile getSessionFile() - { - return this.sessionFile; - } - -/** - * Removes a session from the list of currently active session - * - * @param session SessionHandle of the session to remove - */ -protected void removeSession(SessionHandle session) - { - this.getSessionFile().removeSession(session,this.getSessionsWatcher().getChangedState()); - } -} - - +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ +package uk.ac.vamsas.client.simpleclient; + +import java.io.File; +import java.io.IOException; + +import uk.ac.vamsas.client.SessionHandle; + +/** + * Class to deal with sessions + * + * retrieves list of available sessions + * + * adds an active session + * + * removes a close session (the last client has been closed) + * + * + */ +public class SimpleSessionManager { + private SessionsFile sessionFile = null; + + protected SimpleSessionManager(File sessionsFile) throws IOException { + this.initManagerObjects(sessionsFile); + } + + /** + * construct SessionFile objects and watchers for each + */ + private void initManagerObjects(File sessionsFile) throws IOException { + if (this.sessionFile != null) + throw new IOException( + "initFactoryObjects called for initialised ClientFactory object."); + this.sessionFile = new SessionsFile(sessionsFile); + } + + /** + * make a new watcher object for the sessionsFile + * + * @return new SessionsFile watcher instance + */ + public FileWatcher getSessionsWatcher() { + return new FileWatcher(this.getSessionFile().sessionFile); + } + + /** + * @see uk.ac.vamsas.client.IClientFactory#getCurrentSessions() + */ + public String[] getCurrentSessions() { + String[] sessions = null; + if (this.sessionFile != null) { + SessionHandle[] sessionHandles = this.sessionFile.retrieveSessionsList(); + if (sessionHandles != null) { + sessions = new String[sessionHandles.length]; + for (int i = sessionHandles.length - 1; i > -1; i--) { + SessionHandle sessionHandle = sessionHandles[i]; + sessions[i] = sessionHandle.getSessionUrn(); + } + } + } + return sessions; + } + + /** + * adds SessionHandle me to the sessionList + * + * @param newSession + * session to add to the session list + * @return session index in list or 0 if lock was invalid or addSession + * operation failed. + */ + public int addSession(SessionHandle newSession) { + return this.sessionFile.addSession(newSession, false, this + .getSessionsWatcher().getChangedState()); + } + + /** + * @return the sessionFile + */ + private SessionsFile getSessionFile() { + return this.sessionFile; + } + + /** + * Removes a session from the list of currently active session + * + * @param session + * SessionHandle of the session to remove + */ + protected void removeSession(SessionHandle session) { + this.getSessionFile().removeSession(session, + this.getSessionsWatcher().getChangedState()); + } +} diff --git a/src/uk/ac/vamsas/client/simpleclient/VamsasArchive.java b/src/uk/ac/vamsas/client/simpleclient/VamsasArchive.java index c01ac26..9306ca7 100644 --- a/src/uk/ac/vamsas/client/simpleclient/VamsasArchive.java +++ b/src/uk/ac/vamsas/client/simpleclient/VamsasArchive.java @@ -1,816 +1,991 @@ -package uk.ac.vamsas.client.simpleclient; - -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; -import java.io.DataOutputStream; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.io.PrintWriter; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.Vector; -import java.util.jar.JarEntry; -import java.util.jar.JarOutputStream; -import java.util.jar.Manifest; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import uk.ac.vamsas.client.AppDataOutputStream; -import uk.ac.vamsas.client.ClientHandle; -import uk.ac.vamsas.client.IVorbaIdFactory; -import uk.ac.vamsas.client.SessionHandle; -import uk.ac.vamsas.client.UserHandle; -import uk.ac.vamsas.client.Vobject; -import uk.ac.vamsas.client.VorbaIdFactory; -import uk.ac.vamsas.client.VorbaXmlBinder; -import uk.ac.vamsas.objects.core.ApplicationData; -import uk.ac.vamsas.objects.core.VAMSAS; -import uk.ac.vamsas.objects.core.VamsasDocument; -import uk.ac.vamsas.objects.utils.AppDataReference; -import uk.ac.vamsas.objects.utils.DocumentStuff; -import uk.ac.vamsas.objects.utils.ProvenanceStuff; -import uk.ac.vamsas.objects.utils.document.VersionEntries; - -/** - * Class for high-level io and Jar manipulation involved in creating - * or updating a vamsas archive (with backups). - * Writes to a temporary file and then swaps new file for backup. - * uses the sessionFile locking mechanism for safe I/O - * @author jimp - * - */ -public class VamsasArchive { - private static Log log = LogFactory.getLog(VamsasArchive.class); - /** - * Access original document if it exists, and get VAMSAS root objects. - * @return vector of vamsas roots from original document - * @throws IOException - */ - public static Vobject[] getOriginalRoots(VamsasArchive ths) throws IOException, - org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - VamsasArchiveReader oReader = ths.getOriginalArchiveReader(); - if (oReader!=null) { - - if (oReader.isValid()) { - InputStreamReader vdoc = new InputStreamReader(oReader.getVamsasDocumentStream()); - VamsasDocument doc = VamsasDocument.unmarshal(vdoc); - if (doc!=null) - return doc.getVAMSAS(); - // TODO ensure embedded appDatas are garbage collected to save memory - } else { - InputStream vxmlis = oReader.getVamsasXmlStream(); - if (vxmlis!=null) { // Might be an old vamsas file. - BufferedInputStream ixml = new BufferedInputStream(oReader.getVamsasXmlStream()); - InputStreamReader vxml = new InputStreamReader(ixml); - VAMSAS root[] = new VAMSAS[1]; - root[0] = VAMSAS.unmarshal(vxml); - if (root[0]!=null) - return root; - } - } - } - return null; - } - /** - * Access the original vamsas document for a VamsasArchive class, and return it. - * Users of the VamsasArchive class should use the getVamsasDocument method to retrieve - * the current document - only use this one if you want the 'backup' version. - * TODO: catch OutOfMemoryError - they are likely to occur here. - * NOTE: vamsas.xml datastreams are constructed as 'ALPHA_VERSION' vamsas documents. - * @param ths - * @return null if no document exists. - * @throws IOException - * @throws org.exolab.castor.xml.MarshalException - * @throws org.exolab.castor.xml.ValidationException - */ - public static VamsasDocument getOriginalVamsasDocument(VamsasArchive ths) throws IOException, - org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return VamsasArchive.getOriginalVamsasDocument(ths, null); - } - /** - * Uses VorbaXmlBinder to retrieve the VamsasDocument from the original archive referred to by ths - * @param ths - * @param vorba - * @return - * @throws IOException - * @throws org.exolab.castor.xml.MarshalException - * @throws org.exolab.castor.xml.ValidationException - */ - public static VamsasDocument getOriginalVamsasDocument(VamsasArchive ths, VorbaIdFactory vorba) throws IOException, - org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - VamsasArchiveReader oReader = ths.getOriginalArchiveReader(); - if (oReader!=null) { - ths.setVorba(vorba); - return ths.vorba.getVamsasDocument(oReader); - } - // otherwise - there was no valid original document to read. - return null; - } - /** - * destination of new archive data (tempfile if virginarchive=true, original archive location otherwise) - */ - java.io.File archive=null; - /** - * locked IO handler for new archive file - */ - SessionFile rchive=null; - /** - * original archive file to be updated (or null if virgin) where new data will finally reside - */ - java.io.File original=null; - /** - * original archive IO handler - */ - SessionFile odoclock = null; - Lock destinationLock = null; - /** - * Original archive reader class - */ - VamsasArchiveReader odoc = null; - /** - * true if a real vamsas document is being written. - */ - boolean vamsasdocument=true; - /** - * Output stream for archived data - */ - org.apache.tools.zip.ZipOutputStream newarchive=null; - /** - * JarEntries written to archive - */ - Hashtable entries = null; - - /** - * true if we aren't just updating an archive - */ - private boolean virginArchive=false; - - /** - * name of backup of existing archive that has been updated/overwritten. - * only one backup will be made - and this is it. - */ - File originalBackup = null; - - boolean donotdeletebackup=false; - private final int _TRANSFER_BUFFER=4096*4; - protected SimpleDocument vorba = null; - /** - * LATER: ? CUT'n'Paste error ? - * Access and return current vamsas Document, if it exists, or create a new one - * (without affecting VamsasArchive object state - so is NOT THREAD SAFE) - * _TODO: possibly modify internal state to lock low-level files - * (like the IClientDocument interface instance constructer would do) - * @see org.vamsas.simpleclient.VamsasArchive.getOriginalVamsasDocument for additional caveats - * - * @return - * @throws IOException - * @throws org.exolab.castor.xml.MarshalException - * @throws org.exolab.castor.xml.ValidationException - * ????? where does this live JBPNote ? - */ - private VamsasDocument _doc=null; - - /** - * Create a new vamsas archive - * File locks are made immediately to avoid contention - * - * @param archive - file spec for new vamsas archive - * @param vamsasdocument true if archive is to be a fully fledged vamsas document archive - * @throws IOException if call to accessOriginal failed for updates, or openArchive failed. - */ - public VamsasArchive(File archive, boolean vamsasdocument) throws IOException { - this(archive, false, vamsasdocument, null); - } - public VamsasArchive(File archive, boolean vamsasdocument, boolean overwrite) throws IOException { - this(archive, overwrite, vamsasdocument, null); - } - /** - * Constructor for accessing Files under file-lock management (ie a session file) - * @param archive - * @param vamsasdocument - * @param overwrite - * @throws IOException - */ - public VamsasArchive(VamsasFile archive, boolean vamsasdocument, boolean overwrite) throws IOException { - this(archive.sessionFile, overwrite, vamsasdocument, archive); - // log.debug("using non-functional lock-IO stream jar access constructor"); - } - /** - * read and write to archive - will not overwrite original contents, and will always write an up to date vamsas document structure. - * @param archive - * @throws IOException - */ - public VamsasArchive(VamsasFile archive) throws IOException { - this(archive, true, false); - } - /** - * - * @param archive file to write - * @param overwrite true if original contents should be deleted - * @param vamsasdocument true if a proper VamsasDocument archive is to be written. - * @param extantLock SessionFile object holding a lock for the archive - * @throws IOException - */ - public VamsasArchive(File archive, boolean overwrite, boolean vamsasdocument, SessionFile extantLock) throws IOException { - super(); - if (archive==null || (archive!=null && !(archive.getAbsoluteFile().getParentFile().canWrite() && (!archive.exists() || archive.canWrite())))) { - log.fatal("Expect Badness! -- Invalid parameters for VamsasArchive constructor:"+((archive!=null) - ? "File cannot be overwritten." : "Null Object not valid constructor parameter")); - return; - } - - this.vamsasdocument = vamsasdocument; - if (archive.exists() && !overwrite) { - this.original = archive; - if (extantLock!=null) { - this.odoclock = extantLock; - if (odoclock.fileLock==null || !odoclock.fileLock.isLocked()) - odoclock.lockFile(); - } else { - this.odoclock = new SessionFile(archive); - } - odoclock.lockFile(); // lock the file *immediatly* - this.archive = null; // archive will be a temp file when the open method is called - virginArchive=false; - try { - this.accessOriginal(); - } catch (IOException e) { - throw new IOException("Lock failed for existing archive"+archive); - } - } else { - this.original = null; - this.archive = archive; // archive is written in place. - if (extantLock!=null) - rchive=extantLock; - else - rchive = new SessionFile(archive); - rchive.lockFile(); - if (rchive.fileLock==null || !rchive.fileLock.isLocked()) - throw new IOException("Lock failed for new archive"+archive); - rchive.fileLock.getRaFile().setLength(0); // empty the archive. - virginArchive = true; - } - this.openArchive(); // open archive - } - /** - * open original archive file for exclusive (locked) reading. - * @throws IOException - */ - private void accessOriginal() throws IOException { - if (original!=null && original.exists()) { - if (odoclock==null) - odoclock = new SessionFile(original); - odoclock.lockFile(); - if (odoc == null) - odoc = new VamsasArchiveReader(original); - // this constructor is not implemented yet odoc = new VamsasArchiveReader(odoclock.fileLock); - } - } - - /** - * Add unique entry strings to internal JarEntries list. - * @param entry - * @return true if entry was unique and was added. - */ - private boolean addEntry(String entry) { - if (entries==null) - entries=new Hashtable(); - if (log.isDebugEnabled()) - { - log.debug("validating '"+entry+"' in hash for "+this); - } - if (entries.containsKey(entry)) - return false; - entries.put(entry, new Integer(entries.size())); - return true; - } - /** - * adds named entry to newarchive or returns false. - * @param entry - * @return true if entry was unique and could be added - * @throws IOException if entry name was invalid or a new entry could not be made on newarchive - */ - private boolean addValidEntry(String entry) throws IOException { - org.apache.tools.zip.ZipEntry je = new org.apache.tools.zip.ZipEntry(entry); - // je.setExsetExtra(null); - if (!addEntry(entry)) - return false; - newarchive.flush(); - newarchive.putNextEntry(je); - return true; - } - /** - * called by app to get name of backup if it was made. - * If this is called, the caller app *must* delete the backup themselves. - * @return null or a valid file object - */ - public File backupFile() { - - if (!virginArchive) { - makeBackup(); - donotdeletebackup=true; // external reference has been made. - return ((original!=null) ? originalBackup : null); - } - return null; - } - - /** - * Stops any current write to archive, and reverts to the backup if it exists. - * All existing locks on the original will be released. All backup files are removed. - */ - public boolean cancelArchive() { - if (newarchive!=null) { - try { - newarchive.closeEntry(); - newarchive.putNextEntry(new org.apache.tools.zip.ZipEntry("deleted")); - newarchive.closeEntry(); - newarchive.close(); - - } catch (Exception e) { - log.debug("Whilst closing newarchive",e); - }; - if (!virginArchive) { - // then there is something to recover. - try { - recoverBackup(); - } - catch (Exception e) { - log.warn("Problems when trying to cancel Archive "+archive.getAbsolutePath(), e); - return false; - } - } - - } else { - log.warn("Client Error: cancelArchive called before archive("+original.getAbsolutePath()+") has been opened!"); - } - closeAndReset(); // tidy up and release locks. - return true; - } - - /** - * only do this if you want to destroy the current file output stream - * - */ - private void closeAndReset() { - if (rchive!=null) { - rchive.unlockFile(); - rchive=null; - } - if (original!=null) { - if (odoc!=null) { - odoc.close(); - odoc=null; - } - if (archive!=null) - archive.delete(); - if (odoclock!=null) { - odoclock.unlockFile(); - odoclock = null; - } - } - removeBackup(); - newarchive=null; - original=null; - entries=null; - } - /** - * Tidies up and closes archive, removing any backups that were created. - * NOTE: It is up to the caller to delete the original archive backup obtained from backupFile() - * TODO: ensure all extant AppDataReference jar entries are transferred to new Jar - * TODO: provide convenient mechanism for generating new unique AppDataReferences and adding them to the document - */ - public void closeArchive() throws IOException { - if (newarchive!=null) { - newarchive.flush(); - newarchive.closeEntry(); - if (!isDocumentWritten()) - log.warn("Premature closure of archive '"+archive.getAbsolutePath()+"': No document has been written."); - newarchive.finish();// close(); // use newarchive.finish(); for a stream IO - newarchive.flush(); - // - updateOriginal(); - closeAndReset(); - } else { - log.warn("Attempt to close archive that has not been opened for writing."); - } - } - /** - * Opens and returns the applicationData output stream for the appdataReference string. - * @param appdataReference - * @return Output stream to write to - * @throws IOException - */ - public AppDataOutputStream getAppDataStream(String appdataReference) throws IOException { - if (newarchive==null) - throw new IOException("Attempt to write to closed VamsasArchive object."); - if (addValidEntry(appdataReference)) { - return new AppDataOutputStream(newarchive); - } - return null; - } - - /** - * - * @return JarEntry name for the vamsas XML stream in this archive - */ - protected String getDocumentJarEntry() { - if (vamsasdocument) - return VamsasArchiveReader.VAMSASDOC; - return VamsasArchiveReader.VAMSASXML; - } - /** - * Safely initializes the VAMSAS XML document Jar Entry. - * @return Writer to pass to the marshalling function. - * @throws IOException if a document entry has already been written. - */ - public PrintWriter getDocumentOutputStream() throws IOException { - if (newarchive==null) - openArchive(); - if (!isDocumentWritten()) { - try { - if (addValidEntry(getDocumentJarEntry())) - return new PrintWriter(new java.io.OutputStreamWriter(newarchive, "UTF-8")); - } catch (Exception e) { - log.warn("Problems opening XML document JarEntry stream",e); - } - } else { - throw new IOException("Vamsas Document output stream is already written."); - } - return null; - } - - /** - * Access original archive if it exists, pass the reader to the client - * Note: this is NOT thread safe and a call to closeArchive() will by necessity - * close and invalidate the VamsasArchiveReader object. - * @return null if no original archive exists. - */ - public VamsasArchiveReader getOriginalArchiveReader() throws IOException { - if (!virginArchive) { - accessOriginal(); - return odoc; - } - return null; - } - /** - * returns original document's root vamsas elements. - * @return - * @throws IOException - * @throws org.exolab.castor.xml.MarshalException - * @throws org.exolab.castor.xml.ValidationException - */ - public Vobject[] getOriginalRoots() throws IOException, - org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return VamsasArchive.getOriginalRoots(this); - } - /** - * @return original document or a new empty document (with default provenance) - * @throws IOException - * @throws org.exolab.castor.xml.MarshalException - * @throws org.exolab.castor.xml.ValidationException - */ - public VamsasDocument getVamsasDocument() throws IOException, - org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return getVamsasDocument("org.vamsas.simpleclient.VamsasArchive", "Created new empty document", null); - } - /** - * Return the original document or a new empty document with initial provenance entry. - * @param provenance_user (null sets user to be the class name) - * @param provenance_action (null sets action to be 'created new document') - * @param version (null means use latest version) - * @return (original document or a new vamsas document with supplied provenance and version info) - * @throws IOException - * @throws org.exolab.castor.xml.MarshalException - * @throws org.exolab.castor.xml.ValidationException - */ - public VamsasDocument getVamsasDocument(String provenance_user, String provenance_action, String version) throws IOException, - org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - if (_doc!=null) - return _doc; - _doc = getOriginalVamsasDocument(this, getVorba()); - if (_doc!=null) - return _doc; - // validate parameters - if (provenance_user==null) - provenance_user = "org.vamsas.simpleclient.VamsasArchive"; - if (provenance_action == null) - provenance_action="Created new empty document"; - if (version==null) - version = VersionEntries.latestVersion(); - // Create a new document and return it - _doc = DocumentStuff.newVamsasDocument(new VAMSAS[] { new VAMSAS()}, - ProvenanceStuff.newProvenance(provenance_user, provenance_action), version); - return _doc; - } - /** - * @return Returns the current VorbaIdFactory for the archive. - */ - public VorbaIdFactory getVorba() { - if (vorba==null) - vorba = new SimpleDocument("simpleclient.VamsasArchive"); - return vorba.getVorba(); - } - /** - * @return true if Vamsas Document has been written to archive - */ - protected boolean isDocumentWritten() { - if (newarchive==null) - log.warn("isDocumentWritten() called for unopened archive."); - if (entries!=null) { - if (entries.containsKey(getDocumentJarEntry())) - return true; - } - return false; - } - private void makeBackup() { - if (!virginArchive) { - if (originalBackup==null && original!=null && original.exists()) { - try { - accessOriginal(); - originalBackup = odoclock.backupSessionFile(null, original.getName(), ".bak", original.getParentFile()); - } - catch (IOException e) { - log.warn("Problem whilst making a backup of original archive.",e); - } - } - } - } - /** - * opens the new archive ready for writing. If the new archive is replacing an existing one, - * then the existing archive will be locked, and the new archive written to a temporary file. - * The new archive will be put in place once close() is called. - * @param doclock LATER - pass existing lock on document, if it exists.... no need yet? - * @throws IOException - */ - private void openArchive() throws IOException { - - if (newarchive!=null) { - log.warn("openArchive() called multiple times."); - throw new IOException("Vamsas Archive '"+archive.getAbsolutePath()+"' is already open."); - } - if (archive==null && (virginArchive || original==null)) { - log.warn("openArchive called on uninitialised VamsasArchive object."); - throw new IOException("Badly initialised VamsasArchive object - no archive file specified."); - } - if (!virginArchive) { - // lock the original - accessOriginal(); - // make a temporary file to write to - archive = File.createTempFile(original.getName(), ".new",original.getParentFile()); - } else { - if (archive.exists()) - log.warn("New archive file name already in use! Possible lock failure imminent?"); - } - - if (rchive==null) - rchive = new SessionFile(archive); - if (!rchive.lockFile()) - throw new IOException("Failed to get lock on file "+archive); - // LATER: locked IO stream based access. - // Manifest newmanifest = new Manifest(); - newarchive = new org.apache.tools.zip.ZipOutputStream(rchive.fileLock.getBufferedOutputStream(true));// , newmanifest); - //newarchive = new JarOutputStream(new BufferedOutputStream(new java.io.FileOutputStream(archive))); - entries = new Hashtable(); - } - public void putVamsasDocument(VamsasDocument doc) throws IOException, - org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - putVamsasDocument(doc, getVorba()); - } - /** - * - * @param doc - * @param vorba - * @return (vorbaId string, Vobjhash) pairs for last hash of each object in document - * @throws IOException - * @throws org.exolab.castor.xml.MarshalException - * @throws org.exolab.castor.xml.ValidationException - */ - public void putVamsasDocument(VamsasDocument doc, VorbaIdFactory vorba) throws IOException, - org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - if (vamsasdocument) - doc.setVersion(VersionEntries.latestVersion()); // LATER: ensure this does the correct thing. - VorbaXmlBinder.putVamsasDocument(getDocumentOutputStream(), vorba, doc); - } - - /** - * recovers the original file's contents from the (temporary) backup. - * @throws Exception if any SessionFile or file removal operations fail. - */ - private void recoverBackup() throws Exception { - if (originalBackup!=null) { - // backup has been made. - // revert from backup and delete it (changing backup filename) - if (rchive==null) { - rchive = new SessionFile(original); - } - SessionFile bckup = new SessionFile(originalBackup); - - rchive.updateFrom(null, bckup); // recover from backup file. - bckup.unlockFile(); - bckup=null; - removeBackup(); - } - } - - /** - * forget about any backup that was made - removing it first if it was only temporary. - */ - private void removeBackup() { - if (originalBackup!=null) { - log.debug("Removing backup in "+originalBackup.getAbsolutePath()); - if (!donotdeletebackup) - if (!originalBackup.delete()) - log.info("VamsasArchive couldn't remove temporary backup "+originalBackup.getAbsolutePath()); - originalBackup=null; - } - } - /** - * @param vorba the VorbaIdFactory to use for accessing vamsas objects. - */ - public void setVorba(VorbaIdFactory Vorba) { - if (Vorba!=null) { - if (vorba==null) - vorba = new SimpleDocument(Vorba); - else - vorba.setVorba(Vorba); - } else - getVorba(); - } - /** - * Convenience method to copy over the referred entry from the backup to the new version. - * Warning messages are raised if no backup exists or the - * entry doesn't exist in the backed-up original. - * Duplicate writes return true - but a warning message will also be raised. - * @param AppDataReference - * @return true if AppDataReference now exists in the new document - * @throws IOException - */ - public boolean transferAppDataEntry(String AppDataReference) throws IOException { - return transferAppDataEntry(AppDataReference, AppDataReference); - } - /** - * Validates the AppDataReference: not null and not already written to archive. - * @param AppDataReference - * @return true if valid. false if not - * @throws IOException for really broken references! - */ - protected boolean _validNewAppDataReference(String newAppDataReference) throws IOException { - // LATER: Specify valid AppDataReference form in all VamsasArchive handlers - if (newAppDataReference==null) - throw new IOException("null newAppDataReference!"); - if (entries.containsKey(newAppDataReference)) { - log.warn("Attempt to write '"+newAppDataReference+"' twice! - IGNORED"); - // LATER: fix me? warning message should raise an exception here. - return false; - } - return true; - } - /** - * Transfers an AppDataReference from old to new vamsas archive, with a name change. - * @see transferAppDataEntry(String AppDataReference) - * @param AppDataReference - * @param NewAppDataReference - AppDataReference in new Archive - * @return - * @throws IOException - */ - public boolean transferAppDataEntry(String AppDataReference, String NewAppDataReference) throws IOException { - if (original==null || !original.exists()) { - log.warn("No backup archive exists."); - return false; - } - if (AppDataReference==null) - throw new IOException("null AppDataReference!"); - - if (!_validNewAppDataReference(NewAppDataReference)) - return false; - - accessOriginal(); - - java.io.InputStream adstream = odoc.getAppdataStream(AppDataReference); - - if (adstream==null) { - log.warn("AppDataReference '"+AppDataReference+"' doesn't exist in backup archive."); - return false; - } - - java.io.OutputStream adout = getAppDataStream(NewAppDataReference); - // copy over the bytes - int written=-1; - long count=0; - byte[] buffer = new byte[_TRANSFER_BUFFER]; // conservative estimate of a sensible buffer - do { - if ((written = adstream.read(buffer))>-1) { - adout.write(buffer, 0, written); - log.debug("Transferring "+written+"."); - count+=written; - } - } while (written>-1); - log.debug("Sucessfully transferred AppData for '" - +AppDataReference+"' as '"+NewAppDataReference+"' ("+count+" bytes)"); - return true; - } - /** - * write data from a stream into an appData reference. - * @param AppDataReference - New AppDataReference not already written to archive - * @param adstream Source of data for appData reference - read until .read(buffer) returns -1 - * @return true on success. - * @throws IOException for file IO or invalid AppDataReference string - */ - public boolean writeAppdataFromStream(String AppDataReference, java.io.InputStream adstream) throws IOException { - if (!_validNewAppDataReference(AppDataReference)) { - log.warn("Invalid AppDataReference passed to writeAppdataFromStream"); - throw new IOException("Invalid AppDataReference! (null, or maybe non-unique)!"); - } - - if (AppDataReference==null) { - log.warn("null appdata passed."); - throw new IOException("Null AppDataReference"); - } - - java.io.OutputStream adout = getAppDataStream(AppDataReference); - // copy over the bytes - int written=-1; - long count=0; - byte[] buffer = new byte[_TRANSFER_BUFFER]; // conservative estimate of a sensible buffer - do { - if ((written = adstream.read(buffer))>-1) { - adout.write(buffer, 0, written); - log.debug("Transferring "+written+"."); - count+=written; - } - } while (written>-1); - return true; - } - /** - * transfers any AppDataReferences existing in the old document - * that haven't already been transferred to the new one - * LATER: do the same for transfers requiring a namechange - more document dependent. - * @return true if data was transferred. - */ - public boolean transferRemainingAppDatas() throws IOException { - boolean transfered=false; - if (original==null || !original.exists()) { - log.warn("No backup archive exists."); - return false; - } - accessOriginal(); - - if (getVorba()!=null) { - Vector originalRefs=null; - try { - originalRefs = vorba.getReferencedEntries(getVamsasDocument(), getOriginalArchiveReader()); - } catch (Exception e) { - log.warn("Problems accessing original document entries!",e); - } - if (originalRefs!=null) { - Iterator ref = originalRefs.iterator(); - while (ref.hasNext()) { - String oldentry = (String) ref.next(); - if (oldentry!=null && !entries.containsKey(oldentry)) { - log.debug("Transferring remaining entry '"+oldentry+"'"); - transfered |= transferAppDataEntry(oldentry); - } - } - } - } - return transfered; - } - /** - * called after archive is written to put file in its final place - */ - private void updateOriginal() { - if (!virginArchive) { - // make sure original document really is backed up and then overwrite it. - if (odoc!=null) { - // try to shut the odoc reader. - odoc.close(); - odoc = null; - } - // Make a backup if it isn't done already - makeBackup(); - try { - // copy new Archive data that was writen to a temporary file - odoclock.updateFrom(null, rchive); - } - catch (IOException e) { - // LATER: decide if leaving nastily named backup files around is necessary. - File backupFile=backupFile(); - if (backupFile!=null) - log.error("Problem updating archive from temporary file! - backup left in '" - +backupFile().getAbsolutePath()+"'",e); - else - log.error("Problems updating, and failed to even make a backup file. Ooops!", e); - } - // Tidy up if necessary. - removeBackup(); - } else { - - - } - } -} +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ +package uk.ac.vamsas.client.simpleclient; + +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.DataOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.io.PrintWriter; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.Vector; +import java.util.jar.JarEntry; +import java.util.jar.JarOutputStream; +import java.util.jar.Manifest; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import uk.ac.vamsas.client.AppDataOutputStream; +import uk.ac.vamsas.client.ClientHandle; +import uk.ac.vamsas.client.IVorbaIdFactory; +import uk.ac.vamsas.client.SessionHandle; +import uk.ac.vamsas.client.UserHandle; +import uk.ac.vamsas.client.Vobject; +import uk.ac.vamsas.client.VorbaIdFactory; +import uk.ac.vamsas.client.VorbaXmlBinder; +import uk.ac.vamsas.objects.core.ApplicationData; +import uk.ac.vamsas.objects.core.VAMSAS; +import uk.ac.vamsas.objects.core.VamsasDocument; +import uk.ac.vamsas.objects.utils.AppDataReference; +import uk.ac.vamsas.objects.utils.DocumentStuff; +import uk.ac.vamsas.objects.utils.ProvenanceStuff; +import uk.ac.vamsas.objects.utils.document.VersionEntries; + +/** + * Class for high-level io and Jar manipulation involved in creating or updating + * a vamsas archive (with backups). Writes to a temporary file and then swaps + * new file for backup. uses the sessionFile locking mechanism for safe I/O + * + * @author jimp + * + */ +public class VamsasArchive { + private static Log log = LogFactory.getLog(VamsasArchive.class); + + /** + * Access original document if it exists, and get VAMSAS root objects. + * + * @return vector of vamsas roots from original document + * @throws IOException + */ + public static Vobject[] getOriginalRoots(VamsasArchive ths) + throws IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + VamsasArchiveReader oReader = ths.getOriginalArchiveReader(); + if (oReader != null) { + + if (oReader.isValid()) { + InputStreamReader vdoc = new InputStreamReader(oReader + .getVamsasDocumentStream()); + VamsasDocument doc = VamsasDocument.unmarshal(vdoc); + if (doc != null) + return doc.getVAMSAS(); + // TODO ensure embedded appDatas are garbage collected to save memory + } else { + InputStream vxmlis = oReader.getVamsasXmlStream(); + if (vxmlis != null) { // Might be an old vamsas file. + BufferedInputStream ixml = new BufferedInputStream(oReader + .getVamsasXmlStream()); + InputStreamReader vxml = new InputStreamReader(ixml); + VAMSAS root[] = new VAMSAS[1]; + root[0] = VAMSAS.unmarshal(vxml); + if (root[0] != null) + return root; + } + } + } + return null; + } + + /** + * Access the original vamsas document for a VamsasArchive class, and return + * it. Users of the VamsasArchive class should use the getVamsasDocument + * method to retrieve the current document - only use this one if you want the + * 'backup' version. TODO: catch OutOfMemoryError - they are likely to occur + * here. NOTE: vamsas.xml datastreams are constructed as 'ALPHA_VERSION' + * vamsas documents. + * + * @param ths + * @return null if no document exists. + * @throws IOException + * @throws org.exolab.castor.xml.MarshalException + * @throws org.exolab.castor.xml.ValidationException + */ + public static VamsasDocument getOriginalVamsasDocument(VamsasArchive ths) + throws IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + return VamsasArchive.getOriginalVamsasDocument(ths, null); + } + + /** + * Uses VorbaXmlBinder to retrieve the VamsasDocument from the original + * archive referred to by ths + * + * @param ths + * @param vorba + * @return + * @throws IOException + * @throws org.exolab.castor.xml.MarshalException + * @throws org.exolab.castor.xml.ValidationException + */ + public static VamsasDocument getOriginalVamsasDocument(VamsasArchive ths, + VorbaIdFactory vorba) throws IOException, + org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + VamsasArchiveReader oReader = ths.getOriginalArchiveReader(); + if (oReader != null) { + ths.setVorba(vorba); + return ths.vorba.getVamsasDocument(oReader); + } + // otherwise - there was no valid original document to read. + return null; + } + + /** + * destination of new archive data (tempfile if virginarchive=true, original + * archive location otherwise) + */ + java.io.File archive = null; + + /** + * locked IO handler for new archive file + */ + SessionFile rchive = null; + + /** + * original archive file to be updated (or null if virgin) where new data will + * finally reside + */ + java.io.File original = null; + + /** + * original archive IO handler + */ + SessionFile odoclock = null; + + Lock destinationLock = null; + + /** + * Original archive reader class + */ + VamsasArchiveReader odoc = null; + + /** + * true if a real vamsas document is being written. + */ + boolean vamsasdocument = true; + + /** + * Output stream for archived data + */ + org.apache.tools.zip.ZipOutputStream newarchive = null; + + /** + * JarEntries written to archive + */ + Hashtable entries = null; + + /** + * true if we aren't just updating an archive + */ + private boolean virginArchive = false; + + /** + * name of backup of existing archive that has been updated/overwritten. only + * one backup will be made - and this is it. + */ + File originalBackup = null; + + boolean donotdeletebackup = false; + + private final int _TRANSFER_BUFFER = 4096 * 4; + + protected SimpleDocument vorba = null; + + /** + * LATER: ? CUT'n'Paste error ? Access and return current vamsas Document, if + * it exists, or create a new one (without affecting VamsasArchive object + * state - so is NOT THREAD SAFE) _TODO: possibly modify internal state to + * lock low-level files (like the IClientDocument interface instance + * constructer would do) + * + * @see org.vamsas.simpleclient.VamsasArchive.getOriginalVamsasDocument for + * additional caveats + * + * @return + * @throws IOException + * @throws org.exolab.castor.xml.MarshalException + * @throws org.exolab.castor.xml.ValidationException + * ????? where does this live JBPNote ? + */ + private VamsasDocument _doc = null; + + /** + * Create a new vamsas archive File locks are made immediately to avoid + * contention + * + * @param archive + * - file spec for new vamsas archive + * @param vamsasdocument + * true if archive is to be a fully fledged vamsas document archive + * @throws IOException + * if call to accessOriginal failed for updates, or openArchive + * failed. + */ + public VamsasArchive(File archive, boolean vamsasdocument) throws IOException { + this(archive, false, vamsasdocument, null); + } + + public VamsasArchive(File archive, boolean vamsasdocument, boolean overwrite) + throws IOException { + this(archive, overwrite, vamsasdocument, null); + } + + /** + * Constructor for accessing Files under file-lock management (ie a session + * file) + * + * @param archive + * @param vamsasdocument + * @param overwrite + * @throws IOException + */ + public VamsasArchive(VamsasFile archive, boolean vamsasdocument, + boolean overwrite) throws IOException { + this(archive.sessionFile, overwrite, vamsasdocument, archive); + // log.debug("using non-functional lock-IO stream jar access constructor"); + } + + /** + * read and write to archive - will not overwrite original contents, and will + * always write an up to date vamsas document structure. + * + * @param archive + * @throws IOException + */ + public VamsasArchive(VamsasFile archive) throws IOException { + this(archive, true, false); + } + + /** + * + * @param archive + * file to write + * @param overwrite + * true if original contents should be deleted + * @param vamsasdocument + * true if a proper VamsasDocument archive is to be written. + * @param extantLock + * SessionFile object holding a lock for the archive + * @throws IOException + */ + public VamsasArchive(File archive, boolean overwrite, boolean vamsasdocument, + SessionFile extantLock) throws IOException { + super(); + if (archive == null + || (archive != null && !(archive.getAbsoluteFile().getParentFile() + .canWrite() && (!archive.exists() || archive.canWrite())))) { + log + .fatal("Expect Badness! -- Invalid parameters for VamsasArchive constructor:" + + ((archive != null) ? "File cannot be overwritten." + : "Null Object not valid constructor parameter")); + return; + } + + this.vamsasdocument = vamsasdocument; + if (archive.exists() && !overwrite) { + this.original = archive; + if (extantLock != null) { + this.odoclock = extantLock; + if (odoclock.fileLock == null || !odoclock.fileLock.isLocked()) + odoclock.lockFile(); + } else { + this.odoclock = new SessionFile(archive); + } + odoclock.lockFile(); // lock the file *immediatly* + this.archive = null; // archive will be a temp file when the open method + // is called + virginArchive = false; + try { + this.accessOriginal(); + } catch (IOException e) { + throw new IOException("Lock failed for existing archive" + archive); + } + } else { + this.original = null; + this.archive = archive; // archive is written in place. + if (extantLock != null) + rchive = extantLock; + else + rchive = new SessionFile(archive); + rchive.lockFile(); + if (rchive.fileLock == null || !rchive.fileLock.isLocked()) + throw new IOException("Lock failed for new archive" + archive); + rchive.fileLock.getRaFile().setLength(0); // empty the archive. + virginArchive = true; + } + this.openArchive(); // open archive + } + + /** + * open original archive file for exclusive (locked) reading. + * + * @throws IOException + */ + private void accessOriginal() throws IOException { + if (original != null && original.exists()) { + if (odoclock == null) + odoclock = new SessionFile(original); + odoclock.lockFile(); + if (odoc == null) + odoc = new VamsasArchiveReader(original); + // this constructor is not implemented yet odoc = new + // VamsasArchiveReader(odoclock.fileLock); + } + } + + /** + * Add unique entry strings to internal JarEntries list. + * + * @param entry + * @return true if entry was unique and was added. + */ + private boolean addEntry(String entry) { + if (entries == null) + entries = new Hashtable(); + if (log.isDebugEnabled()) { + log.debug("validating '" + entry + "' in hash for " + this); + } + if (entries.containsKey(entry)) + return false; + entries.put(entry, new Integer(entries.size())); + return true; + } + + /** + * adds named entry to newarchive or returns false. + * + * @param entry + * @return true if entry was unique and could be added + * @throws IOException + * if entry name was invalid or a new entry could not be made on + * newarchive + */ + private boolean addValidEntry(String entry) throws IOException { + org.apache.tools.zip.ZipEntry je = new org.apache.tools.zip.ZipEntry(entry); + // je.setExsetExtra(null); + if (!addEntry(entry)) + return false; + newarchive.flush(); + newarchive.putNextEntry(je); + return true; + } + + /** + * called by app to get name of backup if it was made. If this is called, the + * caller app *must* delete the backup themselves. + * + * @return null or a valid file object + */ + public File backupFile() { + + if (!virginArchive) { + makeBackup(); + donotdeletebackup = true; // external reference has been made. + return ((original != null) ? originalBackup : null); + } + return null; + } + + /** + * Stops any current write to archive, and reverts to the backup if it exists. + * All existing locks on the original will be released. All backup files are + * removed. + */ + public boolean cancelArchive() { + if (newarchive != null) { + try { + newarchive.closeEntry(); + newarchive.putNextEntry(new org.apache.tools.zip.ZipEntry("deleted")); + newarchive.closeEntry(); + newarchive.close(); + + } catch (Exception e) { + log.debug("Whilst closing newarchive", e); + } + ; + if (!virginArchive) { + // then there is something to recover. + try { + recoverBackup(); + } catch (Exception e) { + log.warn("Problems when trying to cancel Archive " + + archive.getAbsolutePath(), e); + return false; + } + } + + } else { + log.warn("Client Error: cancelArchive called before archive(" + + original.getAbsolutePath() + ") has been opened!"); + } + closeAndReset(); // tidy up and release locks. + return true; + } + + /** + * only do this if you want to destroy the current file output stream + * + */ + private void closeAndReset() { + if (rchive != null) { + rchive.unlockFile(); + rchive = null; + } + if (original != null) { + if (odoc != null) { + odoc.close(); + odoc = null; + } + if (archive != null) + archive.delete(); + if (odoclock != null) { + odoclock.unlockFile(); + odoclock = null; + } + } + removeBackup(); + newarchive = null; + original = null; + entries = null; + } + + /** + * Tidies up and closes archive, removing any backups that were created. NOTE: + * It is up to the caller to delete the original archive backup obtained from + * backupFile() TODO: ensure all extant AppDataReference jar entries are + * transferred to new Jar TODO: provide convenient mechanism for generating + * new unique AppDataReferences and adding them to the document + */ + public void closeArchive() throws IOException { + if (newarchive != null) { + newarchive.flush(); + newarchive.closeEntry(); + if (!isDocumentWritten()) + log.warn("Premature closure of archive '" + archive.getAbsolutePath() + + "': No document has been written."); + newarchive.finish();// close(); // use newarchive.finish(); for a stream + // IO + newarchive.flush(); + // + updateOriginal(); + closeAndReset(); + } else { + log + .warn("Attempt to close archive that has not been opened for writing."); + } + } + + /** + * Opens and returns the applicationData output stream for the + * appdataReference string. + * + * @param appdataReference + * @return Output stream to write to + * @throws IOException + */ + public AppDataOutputStream getAppDataStream(String appdataReference) + throws IOException { + if (newarchive == null) + throw new IOException("Attempt to write to closed VamsasArchive object."); + if (addValidEntry(appdataReference)) { + return new AppDataOutputStream(newarchive); + } + return null; + } + + /** + * + * @return JarEntry name for the vamsas XML stream in this archive + */ + protected String getDocumentJarEntry() { + if (vamsasdocument) + return VamsasArchiveReader.VAMSASDOC; + return VamsasArchiveReader.VAMSASXML; + } + + /** + * Safely initializes the VAMSAS XML document Jar Entry. + * + * @return Writer to pass to the marshalling function. + * @throws IOException + * if a document entry has already been written. + */ + public PrintWriter getDocumentOutputStream() throws IOException { + if (newarchive == null) + openArchive(); + if (!isDocumentWritten()) { + try { + if (addValidEntry(getDocumentJarEntry())) + return new PrintWriter(new java.io.OutputStreamWriter(newarchive, + "UTF-8")); + } catch (Exception e) { + log.warn("Problems opening XML document JarEntry stream", e); + } + } else { + throw new IOException("Vamsas Document output stream is already written."); + } + return null; + } + + /** + * Access original archive if it exists, pass the reader to the client Note: + * this is NOT thread safe and a call to closeArchive() will by necessity + * close and invalidate the VamsasArchiveReader object. + * + * @return null if no original archive exists. + */ + public VamsasArchiveReader getOriginalArchiveReader() throws IOException { + if (!virginArchive) { + accessOriginal(); + return odoc; + } + return null; + } + + /** + * returns original document's root vamsas elements. + * + * @return + * @throws IOException + * @throws org.exolab.castor.xml.MarshalException + * @throws org.exolab.castor.xml.ValidationException + */ + public Vobject[] getOriginalRoots() throws IOException, + org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + return VamsasArchive.getOriginalRoots(this); + } + + /** + * @return original document or a new empty document (with default provenance) + * @throws IOException + * @throws org.exolab.castor.xml.MarshalException + * @throws org.exolab.castor.xml.ValidationException + */ + public VamsasDocument getVamsasDocument() throws IOException, + org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + return getVamsasDocument("org.vamsas.simpleclient.VamsasArchive", + "Created new empty document", null); + } + + /** + * Return the original document or a new empty document with initial + * provenance entry. + * + * @param provenance_user + * (null sets user to be the class name) + * @param provenance_action + * (null sets action to be 'created new document') + * @param version + * (null means use latest version) + * @return (original document or a new vamsas document with supplied + * provenance and version info) + * @throws IOException + * @throws org.exolab.castor.xml.MarshalException + * @throws org.exolab.castor.xml.ValidationException + */ + public VamsasDocument getVamsasDocument(String provenance_user, + String provenance_action, String version) throws IOException, + org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + if (_doc != null) + return _doc; + _doc = getOriginalVamsasDocument(this, getVorba()); + if (_doc != null) + return _doc; + // validate parameters + if (provenance_user == null) + provenance_user = "org.vamsas.simpleclient.VamsasArchive"; + if (provenance_action == null) + provenance_action = "Created new empty document"; + if (version == null) + version = VersionEntries.latestVersion(); + // Create a new document and return it + _doc = DocumentStuff.newVamsasDocument(new VAMSAS[] { new VAMSAS() }, + ProvenanceStuff.newProvenance(provenance_user, provenance_action), + version); + return _doc; + } + + /** + * @return Returns the current VorbaIdFactory for the archive. + */ + public VorbaIdFactory getVorba() { + if (vorba == null) + vorba = new SimpleDocument("simpleclient.VamsasArchive"); + return vorba.getVorba(); + } + + /** + * @return true if Vamsas Document has been written to archive + */ + protected boolean isDocumentWritten() { + if (newarchive == null) + log.warn("isDocumentWritten() called for unopened archive."); + if (entries != null) { + if (entries.containsKey(getDocumentJarEntry())) + return true; + } + return false; + } + + private void makeBackup() { + if (!virginArchive) { + if (originalBackup == null && original != null && original.exists()) { + try { + accessOriginal(); + originalBackup = odoclock.backupSessionFile(null, original.getName(), + ".bak", original.getParentFile()); + } catch (IOException e) { + log.warn("Problem whilst making a backup of original archive.", e); + } + } + } + } + + /** + * opens the new archive ready for writing. If the new archive is replacing an + * existing one, then the existing archive will be locked, and the new archive + * written to a temporary file. The new archive will be put in place once + * close() is called. + * + * @param doclock + * LATER - pass existing lock on document, if it exists.... no need + * yet? + * @throws IOException + */ + private void openArchive() throws IOException { + + if (newarchive != null) { + log.warn("openArchive() called multiple times."); + throw new IOException("Vamsas Archive '" + archive.getAbsolutePath() + + "' is already open."); + } + if (archive == null && (virginArchive || original == null)) { + log.warn("openArchive called on uninitialised VamsasArchive object."); + throw new IOException( + "Badly initialised VamsasArchive object - no archive file specified."); + } + if (!virginArchive) { + // lock the original + accessOriginal(); + // make a temporary file to write to + archive = File.createTempFile(original.getName(), ".new", original + .getParentFile()); + } else { + if (archive.exists()) + log + .warn("New archive file name already in use! Possible lock failure imminent?"); + } + + if (rchive == null) + rchive = new SessionFile(archive); + if (!rchive.lockFile()) + throw new IOException("Failed to get lock on file " + archive); + // LATER: locked IO stream based access. + // Manifest newmanifest = new Manifest(); + newarchive = new org.apache.tools.zip.ZipOutputStream(rchive.fileLock + .getBufferedOutputStream(true));// , newmanifest); + // newarchive = new JarOutputStream(new BufferedOutputStream(new + // java.io.FileOutputStream(archive))); + entries = new Hashtable(); + } + + public void putVamsasDocument(VamsasDocument doc) throws IOException, + org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + putVamsasDocument(doc, getVorba()); + } + + /** + * + * @param doc + * @param vorba + * @return (vorbaId string, Vobjhash) pairs for last hash of each object in + * document + * @throws IOException + * @throws org.exolab.castor.xml.MarshalException + * @throws org.exolab.castor.xml.ValidationException + */ + public void putVamsasDocument(VamsasDocument doc, VorbaIdFactory vorba) + throws IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + if (vamsasdocument) + doc.setVersion(VersionEntries.latestVersion()); // LATER: ensure this does + // the correct thing. + VorbaXmlBinder.putVamsasDocument(getDocumentOutputStream(), vorba, doc); + } + + /** + * recovers the original file's contents from the (temporary) backup. + * + * @throws Exception + * if any SessionFile or file removal operations fail. + */ + private void recoverBackup() throws Exception { + if (originalBackup != null) { + // backup has been made. + // revert from backup and delete it (changing backup filename) + if (rchive == null) { + rchive = new SessionFile(original); + } + SessionFile bckup = new SessionFile(originalBackup); + + rchive.updateFrom(null, bckup); // recover from backup file. + bckup.unlockFile(); + bckup = null; + removeBackup(); + } + } + + /** + * forget about any backup that was made - removing it first if it was only + * temporary. + */ + private void removeBackup() { + if (originalBackup != null) { + log.debug("Removing backup in " + originalBackup.getAbsolutePath()); + if (!donotdeletebackup) + if (!originalBackup.delete()) + log.info("VamsasArchive couldn't remove temporary backup " + + originalBackup.getAbsolutePath()); + originalBackup = null; + } + } + + /** + * @param vorba + * the VorbaIdFactory to use for accessing vamsas objects. + */ + public void setVorba(VorbaIdFactory Vorba) { + if (Vorba != null) { + if (vorba == null) + vorba = new SimpleDocument(Vorba); + else + vorba.setVorba(Vorba); + } else + getVorba(); + } + + /** + * Convenience method to copy over the referred entry from the backup to the + * new version. Warning messages are raised if no backup exists or the entry + * doesn't exist in the backed-up original. Duplicate writes return true - but + * a warning message will also be raised. + * + * @param AppDataReference + * @return true if AppDataReference now exists in the new document + * @throws IOException + */ + public boolean transferAppDataEntry(String AppDataReference) + throws IOException { + return transferAppDataEntry(AppDataReference, AppDataReference); + } + + /** + * Validates the AppDataReference: not null and not already written to + * archive. + * + * @param AppDataReference + * @return true if valid. false if not + * @throws IOException + * for really broken references! + */ + protected boolean _validNewAppDataReference(String newAppDataReference) + throws IOException { + // LATER: Specify valid AppDataReference form in all VamsasArchive handlers + if (newAppDataReference == null) + throw new IOException("null newAppDataReference!"); + if (entries.containsKey(newAppDataReference)) { + log.warn("Attempt to write '" + newAppDataReference + + "' twice! - IGNORED"); + // LATER: fix me? warning message should raise an exception here. + return false; + } + return true; + } + + /** + * Transfers an AppDataReference from old to new vamsas archive, with a name + * change. + * + * @see transferAppDataEntry(String AppDataReference) + * @param AppDataReference + * @param NewAppDataReference + * - AppDataReference in new Archive + * @return + * @throws IOException + */ + public boolean transferAppDataEntry(String AppDataReference, + String NewAppDataReference) throws IOException { + if (original == null || !original.exists()) { + log.warn("No backup archive exists."); + return false; + } + if (AppDataReference == null) + throw new IOException("null AppDataReference!"); + + if (!_validNewAppDataReference(NewAppDataReference)) + return false; + + accessOriginal(); + + java.io.InputStream adstream = odoc.getAppdataStream(AppDataReference); + + if (adstream == null) { + log.warn("AppDataReference '" + AppDataReference + + "' doesn't exist in backup archive."); + return false; + } + + java.io.OutputStream adout = getAppDataStream(NewAppDataReference); + // copy over the bytes + int written = -1; + long count = 0; + byte[] buffer = new byte[_TRANSFER_BUFFER]; // conservative estimate of a + // sensible buffer + do { + if ((written = adstream.read(buffer)) > -1) { + adout.write(buffer, 0, written); + log.debug("Transferring " + written + "."); + count += written; + } + } while (written > -1); + log.debug("Sucessfully transferred AppData for '" + AppDataReference + + "' as '" + NewAppDataReference + "' (" + count + " bytes)"); + return true; + } + + /** + * write data from a stream into an appData reference. + * + * @param AppDataReference + * - New AppDataReference not already written to archive + * @param adstream + * Source of data for appData reference - read until .read(buffer) + * returns -1 + * @return true on success. + * @throws IOException + * for file IO or invalid AppDataReference string + */ + public boolean writeAppdataFromStream(String AppDataReference, + java.io.InputStream adstream) throws IOException { + if (!_validNewAppDataReference(AppDataReference)) { + log.warn("Invalid AppDataReference passed to writeAppdataFromStream"); + throw new IOException( + "Invalid AppDataReference! (null, or maybe non-unique)!"); + } + + if (AppDataReference == null) { + log.warn("null appdata passed."); + throw new IOException("Null AppDataReference"); + } + + java.io.OutputStream adout = getAppDataStream(AppDataReference); + // copy over the bytes + int written = -1; + long count = 0; + byte[] buffer = new byte[_TRANSFER_BUFFER]; // conservative estimate of a + // sensible buffer + do { + if ((written = adstream.read(buffer)) > -1) { + adout.write(buffer, 0, written); + log.debug("Transferring " + written + "."); + count += written; + } + } while (written > -1); + return true; + } + + /** + * transfers any AppDataReferences existing in the old document that haven't + * already been transferred to the new one LATER: do the same for transfers + * requiring a namechange - more document dependent. + * + * @return true if data was transferred. + */ + public boolean transferRemainingAppDatas() throws IOException { + boolean transfered = false; + if (original == null || !original.exists()) { + log.warn("No backup archive exists."); + return false; + } + accessOriginal(); + + if (getVorba() != null) { + Vector originalRefs = null; + try { + originalRefs = vorba.getReferencedEntries(getVamsasDocument(), + getOriginalArchiveReader()); + } catch (Exception e) { + log.warn("Problems accessing original document entries!", e); + } + if (originalRefs != null) { + Iterator ref = originalRefs.iterator(); + while (ref.hasNext()) { + String oldentry = (String) ref.next(); + if (oldentry != null && !entries.containsKey(oldentry)) { + log.debug("Transferring remaining entry '" + oldentry + "'"); + transfered |= transferAppDataEntry(oldentry); + } + } + } + } + return transfered; + } + + /** + * called after archive is written to put file in its final place + */ + private void updateOriginal() { + if (!virginArchive) { + // make sure original document really is backed up and then overwrite it. + if (odoc != null) { + // try to shut the odoc reader. + odoc.close(); + odoc = null; + } + // Make a backup if it isn't done already + makeBackup(); + try { + // copy new Archive data that was writen to a temporary file + odoclock.updateFrom(null, rchive); + } catch (IOException e) { + // LATER: decide if leaving nastily named backup files around is + // necessary. + File backupFile = backupFile(); + if (backupFile != null) + log.error( + "Problem updating archive from temporary file! - backup left in '" + + backupFile().getAbsolutePath() + "'", e); + else + log + .error( + "Problems updating, and failed to even make a backup file. Ooops!", + e); + } + // Tidy up if necessary. + removeBackup(); + } else { + + } + } +} diff --git a/src/uk/ac/vamsas/client/simpleclient/VamsasArchiveReader.java b/src/uk/ac/vamsas/client/simpleclient/VamsasArchiveReader.java index 97efc73..f863eb7 100644 --- a/src/uk/ac/vamsas/client/simpleclient/VamsasArchiveReader.java +++ b/src/uk/ac/vamsas/client/simpleclient/VamsasArchiveReader.java @@ -1,316 +1,336 @@ -package uk.ac.vamsas.client.simpleclient; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.BufferedInputStream; -import java.io.FileInputStream; -import java.io.RandomAccessFile; -import java.util.Enumeration; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.Vector; -import org.apache.tools.zip.*; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import uk.ac.vamsas.client.AppDataInputStream; -import uk.ac.vamsas.objects.utils.document.VersionEntries; -/** - * Basic methods for accessing an existing Vamsas Archive, - * and Jar entry names for creating new vamsas archives. - * - * @author jimp - * - */ -public class VamsasArchiveReader { - private static final int JARFILE_OPEN_RETRIES = 50; - private static final int JARFILE_OPEN_RETRYWAIT = 1; - private static Log log = LogFactory.getLog(VamsasArchiveReader.class); - ZipFile jfile=null; - String jfileName="randomAccessFile"; - boolean stream=false; // true if we are seeking on the stream. - RandomAccessFile rfile; - // ZipInputStream jstream=null; - Hashtable strmentries = null; - private void streamInit() { - //throw new Error("VamsasArchiveReader(Stream) Not implemented!"); - if (!stream) { - log.debug("Skipping init for Jar Stream input."); - return; - } else { - throw new Error("Implementation error - we don't do streams - only files or RA files"); - } - /*strmentries = new Hashtable(); - log.debug("Jar Stream input Initialisation"); - try { - rfile.seek(0); - // no buffering - we need to be able to move around the random access stream. - jstream = new ZipInputStream(new FileInputStream(rfile.getFD())); // no manifest (probably) - if (jstream.available()==0) - log.warn("Can't read from JarInputStream (Locked stream!)"); - ZipEntry entry=null; - long pos=0; - do { - if ((entry=jstream.getNextEntry())!=null) { - if (strmentries.containsKey(entry.getName())) { - log.info("Only recording last of duplicate entries '"+entry.getName()+"'"); - } - strmentries.put(entry.getName(), new Long(pos++)); - jstream.closeEntry(); - } - } while (entry!=null); - } - catch (Exception e) { - log.warn("Exceptions during init!",e); - jstream=null; - } */ - } - - public VamsasArchiveReader(File vamsasfile) { - jfile=null; - int retries=JARFILE_OPEN_RETRIES; - Exception ex=null; - if (vamsasfile.exists()) { - while (jfile==null && --retries>0) - { - try { - jfile=new ZipFile(vamsasfile); - jfileName = vamsasfile.toString(); - } - catch (Exception e) { - ex = e; - jfile=null; - try { - Thread.sleep(JARFILE_OPEN_RETRYWAIT); - } catch (Exception w) {}; - } - } - if (jfile==null && ex!=null) - { - log.debug("non-serious? Exceptions when opening JarFile at "+vamsasfile,ex); - } - } - } - /** - * in an ideal world - this constructor will create a reader object - * for the locked file's random access stream. - * - * @param vamsaslock - */ - public VamsasArchiveReader(Lock vamsaslock) { - jfile = null; - if (vamsaslock==null || !vamsaslock.isLocked()) - throw new Error("IMPLEMENTATION ERROR: Cannot create a VamsasArchiveReader without a valid lock."); - // throw new Error("VamsasArchiveReading from locked IO stream not yet implemented."); - try { - rfile = vamsaslock.getRaFile(); - jfile = new ZipFile(rfile); - if (vamsaslock.target!=null) - jfileName = vamsaslock.target.toString(); - } catch (Exception e) { - rfile = null; - jfile = null; - log.warn("Unexpected IO Exception when accessing locked vamsas archive stream "+vamsaslock.target,e); - } - /*stream = true; - streamInit(); - if (jstream==null) - throw new Error("Failed to open archive from Locked random access stream."); - */ - } - - /** - * the vamsas document version(s) handled by this Reader - */ - final public static String DOCUMENT_VERSION=VersionEntries.BETA_VERSION; - /** - * name of the jarEntry containing a well formatted vamsas XML Document - */ - - final public static String VAMSASDOC="vamsasDocument.xml"; - - /** - * name of the jarEntry containing a root VAMSAS element, and containing a - * random sequence of VAMSAS DataSet elements - */ - - final public static String VAMSASXML="vamsas.xml"; - /** - * seeks jstream to the given entry name and reads it. - * @param entryname - * @return - private JarEntry seekEntry(String entryname) { - if (jstream==null) - return null; - if (!strmentries.containsKey(entryname)) - return null; - Long entrypos = (Long) strmentries.get(entryname); - if (entrypos==null) { - log.error("Null entry position for "+entryname); - return null; - } - try { - jstream=null; - rfile.seek(0); - jstream = new ZipInputStream(new FileInputStream(rfile.getFD())); - ZipEntry entry = null; - long epos = entrypos.longValue(); - do { - entry = jstream.getNextEntry(); - } while (entry!=null && --epos>=0); - // rfile.seek(entrypos.longValue()); - // make a Jar entry from a zip entry. - return new JarEntry(entry); - } - catch (Exception e) { - log.warn("Whilst seeking for "+entryname, e); - } - return null; - } - */ - /** - * - * @return JarEntry for VamsasArchiveReader.VAMSASDOC - */ - protected ZipEntry getVamsasDocumentEntry() { - return getJarEntry(VAMSASDOC); - } - /** - * - * @return JarEntry for VamsasArchiveReader.VAMSASXML - */ - protected ZipEntry getVamsasXmlEntry() { - return getJarEntry(VAMSASXML); - } - /** - * Test for valid vamsas document archive - * @return true if getVamsasDocumentStream will return a stream likely to contain valid XML - */ - public boolean isValid() { - // TODO: check if VAMSASDOC is well formed (follows www.vamsas.ac.uk/schemas/vamsasDocument.xsd) and all appData references are resolvable - preferably as jar entries - if (jfile!=null) // || jstream!=null) - return (getVamsasDocumentEntry()!=null); - return false; - } - - - protected ZipEntry getAppdataEntry(String AppdataRef) { - ZipEntry entry; - if (jfile==null || !isValid() || (entry=getJarEntry(AppdataRef))==null) - return null; - - return entry; - } - - public InputStream getAppdataStream(String AppdataRef) { - ZipEntry entry=getAppdataEntry(AppdataRef); - try { - if (entry!=null) - return getInputStream(entry); - } catch (IOException e) { - log.error("Failed when opening AppdataStream for "+AppdataRef, e); - } - return null; - } - /** - * get the VamsasDocument input stream, if it exists. - * @return null or valid input stream - */ - public InputStream getVamsasDocumentStream() { - InputStream vdoc; - if (jfile==null || !isValid()) - return null; - try { - vdoc = getInputStream(getVamsasDocumentEntry()); - } catch (IOException e) { - log.error("Whilst geting document stream",e); - vdoc=null; - } - return vdoc; - } - - /** - * get the VamsasXML input stream, if it exists. - * Note: Deprecated beyond our prealpha testing. - * @return null or valid input stream. - */ - - public InputStream getVamsasXmlStream() { - // log.warn("Deprecated call"); - ZipEntry xmle=getVamsasXmlEntry(); - InputStream vdoc; - if (xmle==null) - return null; - try { - vdoc = getInputStream(xmle); - } catch (IOException e) { - log.error("Whilst getting VamsasXmlStream",e); - vdoc=null; - } - return vdoc; - } - - /** - * silently close the jar file. - * - */ - public void close() { - if (jfile!=null) { - try { - jfile.close(); - rfile=null; - } - catch (Exception e) { - log.error("Whilst closing JarFile "+jfileName, e); - } - } - } - - /** - * returns all entries not matching the filespec of a vamsas xml entry - * @return array of entries. - */ - public Vector getExtraEntries() { - if (jfile==null || !isValid()) - return null; - Vector e = new Vector(); - /*if (jstream!=null) { - Enumeration entries = strmentries.keys(); - if (entries!=null && entries.hasMoreElements()) { - do { - JarEntry el = (JarEntry) entries.nextElement(); - if (!el.getName().equals(VAMSASDOC) && !el.getName().equals(VAMSASXML)) - e.add(new String(el.getName())); // avoid references - } while (entries.hasMoreElements()); - } - } else */ - Enumeration entries = jfile.getEntries(); - if (entries!=null && entries.hasMoreElements()) { - do { - ZipEntry el = (ZipEntry) entries.nextElement(); - if (!el.getName().equals(VAMSASDOC) && !el.getName().equals(VAMSASXML)) - e.add(new String(el.getName())); // avoid references - } while (entries.hasMoreElements()); - } - return e; - } - - /* (non-Javadoc) - * @see java.util.jar.JarFile#getInputStream(java.util.zip.ZipEntry) - */ - private InputStream getInputStream(ZipEntry ze) throws IOException { - if (jfile!=null) - return jfile.getInputStream(ze); - return null; - } - - /* (non-Javadoc) - * @see java.util.jar.JarFile#getJarEntry(java.lang.String) - */ - private ZipEntry getJarEntry(String name) { - if (jfile!=null) - return jfile.getEntry(name); - return null; - } - } +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ +package uk.ac.vamsas.client.simpleclient; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.BufferedInputStream; +import java.io.FileInputStream; +import java.io.RandomAccessFile; +import java.util.Enumeration; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.Vector; +import org.apache.tools.zip.*; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import uk.ac.vamsas.client.AppDataInputStream; +import uk.ac.vamsas.objects.utils.document.VersionEntries; + +/** + * Basic methods for accessing an existing Vamsas Archive, and Jar entry names + * for creating new vamsas archives. + * + * @author jimp + * + */ +public class VamsasArchiveReader { + private static final int JARFILE_OPEN_RETRIES = 50; + + private static final int JARFILE_OPEN_RETRYWAIT = 1; + + private static Log log = LogFactory.getLog(VamsasArchiveReader.class); + + ZipFile jfile = null; + + String jfileName = "randomAccessFile"; + + boolean stream = false; // true if we are seeking on the stream. + + RandomAccessFile rfile; + + // ZipInputStream jstream=null; + Hashtable strmentries = null; + + private void streamInit() { + // throw new Error("VamsasArchiveReader(Stream) Not implemented!"); + if (!stream) { + log.debug("Skipping init for Jar Stream input."); + return; + } else { + throw new Error( + "Implementation error - we don't do streams - only files or RA files"); + } + /* + * strmentries = new Hashtable(); + * log.debug("Jar Stream input Initialisation"); try { rfile.seek(0); // no + * buffering - we need to be able to move around the random access stream. + * jstream = new ZipInputStream(new FileInputStream(rfile.getFD())); // no + * manifest (probably) if (jstream.available()==0) + * log.warn("Can't read from JarInputStream (Locked stream!)"); ZipEntry + * entry=null; long pos=0; do { if ((entry=jstream.getNextEntry())!=null) { + * if (strmentries.containsKey(entry.getName())) { + * log.info("Only recording last of duplicate entries '" + * +entry.getName()+"'"); } strmentries.put(entry.getName(), new + * Long(pos++)); jstream.closeEntry(); } } while (entry!=null); } catch + * (Exception e) { log.warn("Exceptions during init!",e); jstream=null; } + */ + } + + public VamsasArchiveReader(File vamsasfile) { + jfile = null; + int retries = JARFILE_OPEN_RETRIES; + Exception ex = null; + if (vamsasfile.exists()) { + while (jfile == null && --retries > 0) { + try { + jfile = new ZipFile(vamsasfile); + jfileName = vamsasfile.toString(); + } catch (Exception e) { + ex = e; + jfile = null; + try { + Thread.sleep(JARFILE_OPEN_RETRYWAIT); + } catch (Exception w) { + } + ; + } + } + if (jfile == null && ex != null) { + log.debug("non-serious? Exceptions when opening JarFile at " + + vamsasfile, ex); + } + } + } + + /** + * in an ideal world - this constructor will create a reader object for the + * locked file's random access stream. + * + * @param vamsaslock + */ + public VamsasArchiveReader(Lock vamsaslock) { + jfile = null; + if (vamsaslock == null || !vamsaslock.isLocked()) + throw new Error( + "IMPLEMENTATION ERROR: Cannot create a VamsasArchiveReader without a valid lock."); + // throw new + // Error("VamsasArchiveReading from locked IO stream not yet implemented."); + try { + rfile = vamsaslock.getRaFile(); + jfile = new ZipFile(rfile); + if (vamsaslock.target != null) + jfileName = vamsaslock.target.toString(); + } catch (Exception e) { + rfile = null; + jfile = null; + log.warn( + "Unexpected IO Exception when accessing locked vamsas archive stream " + + vamsaslock.target, e); + } + /* + * stream = true; streamInit(); if (jstream==null) throw new + * Error("Failed to open archive from Locked random access stream."); + */ + } + + /** + * the vamsas document version(s) handled by this Reader + */ + final public static String DOCUMENT_VERSION = VersionEntries.BETA_VERSION; + + /** + * name of the jarEntry containing a well formatted vamsas XML Document + */ + + final public static String VAMSASDOC = "vamsasDocument.xml"; + + /** + * name of the jarEntry containing a root VAMSAS element, and containing a + * random sequence of VAMSAS DataSet elements + */ + + final public static String VAMSASXML = "vamsas.xml"; + + /** + * seeks jstream to the given entry name and reads it. + * + * @param entryname + * @return private JarEntry seekEntry(String entryname) { if (jstream==null) + * return null; if (!strmentries.containsKey(entryname)) return null; + * Long entrypos = (Long) strmentries.get(entryname); if + * (entrypos==null) { log.error("Null entry position for "+entryname); + * return null; } try { jstream=null; rfile.seek(0); jstream = new + * ZipInputStream(new FileInputStream(rfile.getFD())); ZipEntry entry + * = null; long epos = entrypos.longValue(); do { entry = + * jstream.getNextEntry(); } while (entry!=null && --epos>=0); // + * rfile.seek(entrypos.longValue()); // make a Jar entry from a zip + * entry. return new JarEntry(entry); } catch (Exception e) { + * log.warn("Whilst seeking for "+entryname, e); } return null; } + */ + /** + * + * @return JarEntry for VamsasArchiveReader.VAMSASDOC + */ + protected ZipEntry getVamsasDocumentEntry() { + return getJarEntry(VAMSASDOC); + } + + /** + * + * @return JarEntry for VamsasArchiveReader.VAMSASXML + */ + protected ZipEntry getVamsasXmlEntry() { + return getJarEntry(VAMSASXML); + } + + /** + * Test for valid vamsas document archive + * + * @return true if getVamsasDocumentStream will return a stream likely to + * contain valid XML + */ + public boolean isValid() { + // TODO: check if VAMSASDOC is well formed (follows + // www.vamsas.ac.uk/schemas/vamsasDocument.xsd) and all appData references + // are resolvable - preferably as jar entries + if (jfile != null) // || jstream!=null) + return (getVamsasDocumentEntry() != null); + return false; + } + + protected ZipEntry getAppdataEntry(String AppdataRef) { + ZipEntry entry; + if (jfile == null || !isValid() + || (entry = getJarEntry(AppdataRef)) == null) + return null; + + return entry; + } + + public InputStream getAppdataStream(String AppdataRef) { + ZipEntry entry = getAppdataEntry(AppdataRef); + try { + if (entry != null) + return getInputStream(entry); + } catch (IOException e) { + log.error("Failed when opening AppdataStream for " + AppdataRef, e); + } + return null; + } + + /** + * get the VamsasDocument input stream, if it exists. + * + * @return null or valid input stream + */ + public InputStream getVamsasDocumentStream() { + InputStream vdoc; + if (jfile == null || !isValid()) + return null; + try { + vdoc = getInputStream(getVamsasDocumentEntry()); + } catch (IOException e) { + log.error("Whilst geting document stream", e); + vdoc = null; + } + return vdoc; + } + + /** + * get the VamsasXML input stream, if it exists. Note: Deprecated beyond our + * prealpha testing. + * + * @return null or valid input stream. + */ + + public InputStream getVamsasXmlStream() { + // log.warn("Deprecated call"); + ZipEntry xmle = getVamsasXmlEntry(); + InputStream vdoc; + if (xmle == null) + return null; + try { + vdoc = getInputStream(xmle); + } catch (IOException e) { + log.error("Whilst getting VamsasXmlStream", e); + vdoc = null; + } + return vdoc; + } + + /** + * silently close the jar file. + * + */ + public void close() { + if (jfile != null) { + try { + jfile.close(); + rfile = null; + } catch (Exception e) { + log.error("Whilst closing JarFile " + jfileName, e); + } + } + } + + /** + * returns all entries not matching the filespec of a vamsas xml entry + * + * @return array of entries. + */ + public Vector getExtraEntries() { + if (jfile == null || !isValid()) + return null; + Vector e = new Vector(); + /* + * if (jstream!=null) { Enumeration entries = strmentries.keys(); if + * (entries!=null && entries.hasMoreElements()) { do { JarEntry el = + * (JarEntry) entries.nextElement(); if (!el.getName().equals(VAMSASDOC) && + * !el.getName().equals(VAMSASXML)) e.add(new String(el.getName())); // + * avoid references } while (entries.hasMoreElements()); } } else + */ + Enumeration entries = jfile.getEntries(); + if (entries != null && entries.hasMoreElements()) { + do { + ZipEntry el = (ZipEntry) entries.nextElement(); + if (!el.getName().equals(VAMSASDOC) && !el.getName().equals(VAMSASXML)) + e.add(new String(el.getName())); // avoid references + } while (entries.hasMoreElements()); + } + return e; + } + + /* + * (non-Javadoc) + * + * @see java.util.jar.JarFile#getInputStream(java.util.zip.ZipEntry) + */ + private InputStream getInputStream(ZipEntry ze) throws IOException { + if (jfile != null) + return jfile.getInputStream(ze); + return null; + } + + /* + * (non-Javadoc) + * + * @see java.util.jar.JarFile#getJarEntry(java.lang.String) + */ + private ZipEntry getJarEntry(String name) { + if (jfile != null) + return jfile.getEntry(name); + return null; + } +} diff --git a/src/uk/ac/vamsas/client/simpleclient/VamsasFile.java b/src/uk/ac/vamsas/client/simpleclient/VamsasFile.java index 1d3732b..e0c6f90 100644 --- a/src/uk/ac/vamsas/client/simpleclient/VamsasFile.java +++ b/src/uk/ac/vamsas/client/simpleclient/VamsasFile.java @@ -1,4 +1,24 @@ - +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ package uk.ac.vamsas.client.simpleclient; import java.io.File; @@ -15,18 +35,18 @@ import java.util.jar.JarInputStream; import java.util.jar.JarOutputStream; /** - * low level vamsas document management routines - * analogous to ClientsFile - * Grew out of io tests on VamsasArchive class in uk.ac.vamsas.test.simpleclient.VamsasArchive - * This class is not thread safe. + * low level vamsas document management routines analogous to ClientsFile Grew + * out of io tests on VamsasArchive class in + * uk.ac.vamsas.test.simpleclient.VamsasArchive This class is not thread safe. + * * @author jimp - * + * */ public class VamsasFile extends SessionFile { /** * - * Connect to an existing Vamsas document in a given sessionDir - * or create a new one. + * Connect to an existing Vamsas document in a given sessionDir or create a + * new one. * * @param sessionDir * @throws java.io.IOException @@ -34,6 +54,7 @@ public class VamsasFile extends SessionFile { public VamsasFile(File sessionFile) throws java.io.IOException { super(sessionFile); } + /** * * @return the VamsasFile @@ -41,34 +62,32 @@ public class VamsasFile extends SessionFile { public File getVamsasFile() { return sessionFile; } + /** * Expand a previously stored session into the sessionDir + * * @param sessionDir * @param storedSession - - public VamsasFile(File sessionDir, JarFile storedSession) throws IOException { - // check if sessionDir is live or not - if (!sessionDir.exists()) { - sessionDir.mkdir(); - } - - { - // check its actually a writable directory - } - - File sfile = new File(sessionDir, "vamsas.jar"); - VamsasFile(sfile); - // if live - try to merge storedSession with sessionDir - // - will probably fail through duplicate Vobject references needing to be dereferenced. - // TODO: think of a way of specifying vorba_id scope for an application's references to allow merging of one vamsasDocument with another. - - } - */ + * public VamsasFile(File sessionDir, JarFile storedSession) throws + * IOException { // check if sessionDir is live or not if + * (!sessionDir.exists()) { sessionDir.mkdir(); } + * + * { // check its actually a writable directory } + * + * File sfile = new File(sessionDir, "vamsas.jar"); + * VamsasFile(sfile); // if live - try to merge storedSession with + * sessionDir // - will probably fail through duplicate Vobject + * references needing to be dereferenced. // TODO: think of a way of + * specifying vorba_id scope for an application's references to allow + * merging of one vamsasDocument with another. + * + * } + */ /** - * public interface for getting a lock. - * The lock object is internally referenced - * so the lock will persist even after the - * return value of the method goes out of scope. + * public interface for getting a lock. The lock object is internally + * referenced so the lock will persist even after the return value of the + * method goes out of scope. + * * @return null if lock couldn't be got or a valid Lock object. */ public Lock getLock() { @@ -76,6 +95,7 @@ public class VamsasFile extends SessionFile { return fileLock; return null; } + /** * * @param extantLock @@ -86,13 +106,13 @@ public class VamsasFile extends SessionFile { return fileLock; return null; } + /** - * explicitly unlocks vamsas file. - * if you have called getLock() you *must* + * explicitly unlocks vamsas file. if you have called getLock() you *must* * call this to release the lock. */ public void unLock() { this.unlockFile(); } - + } diff --git a/src/uk/ac/vamsas/client/simpleclient/VamsasFileWatcherElement.java b/src/uk/ac/vamsas/client/simpleclient/VamsasFileWatcherElement.java index ceb1e65..06fda30 100644 --- a/src/uk/ac/vamsas/client/simpleclient/VamsasFileWatcherElement.java +++ b/src/uk/ac/vamsas/client/simpleclient/VamsasFileWatcherElement.java @@ -1,40 +1,69 @@ +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ package uk.ac.vamsas.client.simpleclient; - /** - * Element of the VamsasFileWatcherThread event generator chain. - * Keep a reference to this element before adding it to the chain - * in order to control the generation of events with halt and enable. + * Element of the VamsasFileWatcherThread event generator chain. Keep a + * reference to this element before adding it to the chain in order to control + * the generation of events with halt and enable. * * doWatch will do nothing if the element is not enabled. * */ public class VamsasFileWatcherElement extends WatcherElement { - VamsasFile watched=null; + VamsasFile watched = null; + /** * create a new, enabled watch element - * @param watcher file being watched - * @param handler handler to call on state change + * + * @param watcher + * file being watched + * @param handler + * handler to call on state change */ public VamsasFileWatcherElement(VamsasFile watcher, WatcherCallBack handler) { this(watcher, handler, true); } + protected void initWatch() { - if (watched==null) + if (watched == null) return; watched.unLock(); // very very essential! watcher = new FileWatcher(watched.getVamsasFile()); } + protected void endWatch() { // leaves watcher in state its in. } + /** * new watcher with flag to initially skip watching this sessionfile + * * @param watcher * @param handler * @param enableWatching */ - public VamsasFileWatcherElement(VamsasFile watcher, WatcherCallBack handler, boolean enableWatching) { + public VamsasFileWatcherElement(VamsasFile watcher, WatcherCallBack handler, + boolean enableWatching) { super(handler); this.watched = watcher; if (enableWatching) @@ -42,12 +71,14 @@ public class VamsasFileWatcherElement extends WatcherElement { else haltWatch(); } + /** * @return the watched */ public VamsasFile getWatched() { return watched; } + protected String getSubject() { return watched.getVamsasFile().toString(); } diff --git a/src/uk/ac/vamsas/client/simpleclient/VamsasFileWatcherThread.java b/src/uk/ac/vamsas/client/simpleclient/VamsasFileWatcherThread.java index 56a0440..7b0e858 100644 --- a/src/uk/ac/vamsas/client/simpleclient/VamsasFileWatcherThread.java +++ b/src/uk/ac/vamsas/client/simpleclient/VamsasFileWatcherThread.java @@ -1,3 +1,24 @@ +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ package uk.ac.vamsas.client.simpleclient; import java.util.Iterator; @@ -7,94 +28,116 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** - * Watches a bunch of VamsasFile states, calling - * the associated event handler when anything changes. + * Watches a bunch of VamsasFile states, calling the associated event handler + * when anything changes. + * * @author JimP - * + * */ public class VamsasFileWatcherThread extends Thread { - private Log log = LogFactory.getLog(VamsasFileWatcherThread.class); - /* (non-Javadoc) + private Log log = LogFactory.getLog(VamsasFileWatcherThread.class); + + /* + * (non-Javadoc) + * * @see java.lang.Thread#run() */ - EventGeneratorThread client=null; - private Vector elements=null; + EventGeneratorThread client = null; + + private Vector elements = null; + public VamsasFileWatcherThread(EventGeneratorThread client) { this.client = client; - elements=new Vector(); + elements = new Vector(); } + public void addElement(WatcherElement welement) { elements.addElement(welement); } + public void removeElemenet(WatcherElement welement) { elements.removeElement(welement); } + public void clearElements() { elements.clear(); } + /** * true if the thread is running */ - boolean running=false; + boolean running = false; + /** * true if the watcher loop is in progress */ - boolean watching=false; + boolean watching = false; + public void haltWatchers() { if (!watching) return; - watching=false; + watching = false; // wait arount for WATCH_SLEEP milliseconds before returning // in the hope that the watcher loop has stopped try { interrupt(); - long time = System.currentTimeMillis()+WATCH_SLEEP; - while (running && time>System.currentTimeMillis()) { + long time = System.currentTimeMillis() + WATCH_SLEEP; + while (running && time > System.currentTimeMillis()) { Thread.sleep(1); } - } catch (Exception e) {}; + } catch (Exception e) { + } + ; if (running) log.warn("haltWatchers returning whilst thread is still running."); } - + /** * time between checks for changes of state on the file */ - public int WATCH_SLEEP=30; + public int WATCH_SLEEP = 30; + /** - * check each watcher in sequence, monitoring any events generated. - * Then wait WATCH_SLEEP milliseconds before checking all again (if there were no events) + * check each watcher in sequence, monitoring any events generated. Then wait + * WATCH_SLEEP milliseconds before checking all again (if there were no + * events) */ public void run() { - running=true; - watching=true; + running = true; + watching = true; log.debug("Starting WatcherThread poll loop"); while (watching) { - boolean wait=true; - Iterator watchers=elements.iterator(); + boolean wait = true; + Iterator watchers = elements.iterator(); while (watching && watchers.hasNext()) { WatcherElement watch = (WatcherElement) watchers.next(); if (watch.doWatch()) { - wait=false; - log.debug("Event generated for watcher on "+watch.getWatcher().getSubject()); + wait = false; + log.debug("Event generated for watcher on " + + watch.getWatcher().getSubject()); } } if (watching && wait) { try { Thread.sleep(WATCH_SLEEP); + } catch (InterruptedException e) { } - catch (InterruptedException e) {}; + ; } } log.debug("Finishing WatcherThread poll loop"); - running=false; + running = false; } - /* (non-Javadoc) + + /* + * (non-Javadoc) + * * @see java.lang.Thread#interrupt() */ public void interrupt() { - // TODO: make thread gracefully interrupt watchers so that any handlers finish doing what they were doing + // TODO: make thread gracefully interrupt watchers so that any handlers + // finish doing what they were doing // super.interrupt(); } - + } diff --git a/src/uk/ac/vamsas/client/simpleclient/VamsasSession.java b/src/uk/ac/vamsas/client/simpleclient/VamsasSession.java index 87e904a..af5ab37 100644 --- a/src/uk/ac/vamsas/client/simpleclient/VamsasSession.java +++ b/src/uk/ac/vamsas/client/simpleclient/VamsasSession.java @@ -1,884 +1,902 @@ -package uk.ac.vamsas.client.simpleclient; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.RandomAccessFile; -import java.nio.channels.FileChannel; -import java.nio.channels.OverlappingFileLockException; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.log4j.FileAppender; -import org.apache.log4j.Logger; -import org.apache.log4j.PatternLayout; - -import uk.ac.vamsas.client.ClientHandle; -import uk.ac.vamsas.client.Events; -import uk.ac.vamsas.client.IClient; -import uk.ac.vamsas.client.SessionHandle; -import uk.ac.vamsas.client.UserHandle; - -/** - * Does all the IO operations for a SimpleClient instance accessing a - * SimpleClient vamsas session. - * - * Basically, it defines the various standard names for the files in the session - * directory (that maps to the sessionUrn), provides constructors for the file - * handlers and watchers of those file entities, and some higher level methods - * to check and change the state flags for the session. - * - * TODO: move the stuff below to the SimpleClientFactory documentation. much may - * not be valid now : Vamsas client is intialised with a path to create live - * session directories. This path may contain a vamsas.properties file that sets - * additional parameters (otherwise client just uses the one on the classpath). - * - * A vamsas session consists of : SessionDir - translates to urn of a live - * session. Contains: Vamsas Document (as a jar), Session client list file, both - * of which may be locked, and additional temporary versions of these files when - * write operations are taking place. - * - * Zip file entries - vamsasdocument.xml : core info one or more: - - * .version.sessionnumber.raw (string given in - * vamsasdocument.xml applicationData entry) - * - * Lockfile - filename given in the vamsasdocument.xml. Should be checked for - * validity by any client and rewritten if necessary. The lockfile can point to - * the jar itself. Mode of operation. Initially - documentHandler either: - - * creates a zip for a new session for the client - connect to an existing - * session zip 1. reads session urn file 2. waits for lock 3. examines session - - * decide whether to create new application data slice or connect to one stored - * in session. 4. writes info into session file 5. releases lock and generates - * local client events. 6. Creates Watcher thread to generate events. - * - * During the session - Update watcher checks for file change - - * - * Procedures for file based session message exchange - session document - * modification flag - * - */ - -public class VamsasSession { - /** - * indicator file for informing other processes that they should finalise - * their vamsas datasets for storing into a vamsas archive. - */ - public static final String CLOSEANDSAVE_FILE = "stored.log"; - - /** - * session file storing the last_stored_stat data - */ - public static final String MODIFIEDDOC_FILE = "modified"; - - private SimpleSessionManager sessionManager = null; - - /** - * Count of cycles before considering the current client as the last one of - * the session (if no other client registered as active ) - */ - private final int watchCycleCountBeforeLastClient = 1220; - - /** - * time between checking - */ - public int WATCH_SLEEP = 30; - - protected String clientFileDirectory = "clients"; - - /** - * called to clear update flag after a successful offline storage event - */ - protected void clearUnsavedFlag() { - SessionFlagFile laststored = new SessionFlagFile(new File(sessionDir, - MODIFIEDDOC_FILE)); - if (!laststored.clearFlag()) - log.warn("Unsaved flag was not cleared for " + sessionDir); - } - - /** - * called to indicate session document has been modified. - * - */ - protected void setUnsavedFlag() { - SessionFlagFile laststored = new SessionFlagFile(new File(sessionDir, - MODIFIEDDOC_FILE)); - if (!laststored.setFlag()) - log.warn("Couldn't set the Unsaved flag for " + sessionDir); - } - - /** - * - * @return true if session document has been modified since last offline - * storage event - */ - protected boolean getUnsavedFlag() { - SessionFlagFile laststored = new SessionFlagFile(new File(sessionDir, - MODIFIEDDOC_FILE)); - return laststored.checkFlag(); - } - - /** - * log file location - */ - public static final String SESSION_LOG = "Log.txt"; - - private static Log log = LogFactory.getLog(VamsasSession.class); - - protected Logger slog = Logger.getLogger("uk.ac.vamsas.client.SessionLog"); - - /** - * the appender that writes to the log file inside the session's directory. - */ - private FileAppender slogAppender = null; - - /** - * setup the sessionLog using Log4j. - * - * @throws IOException - */ - private void initLog() throws IOException { - // TODO: fix session event logging - // LATER: make dedicated appender format for session log. - /* - * Appender app = slog.getAppender("log4j.appender.SESSIONLOG"); // - * slog.addAppender(new FileAppender(app.getLayout(), new File(sessionDir, - * SESSION_LOG).getAbsolutePath())); // slog.addAppender(new - * FileAppender(app.getLayout(), new File(sessionDir, - * SESSION_LOG).getAbsolutePath())); for (Enumeration e = - * slog.getAllAppenders() ; e.hasMoreElements() ;) { - * System.out.println(e.nextElement()); - * } - */ - - if (slog != null) { - File sessionLogFile = new File(this.sessionDir, SESSION_LOG); - slog.addAppender(slogAppender = new FileAppender(new PatternLayout( - "%-4r [%t] %-5p %c %x - %m%n"), sessionLogFile.getAbsolutePath(), - true)); - } else { - log.info("No appender for SessionLog"); - } - } - - private void closeSessionLog() { - if (slog != null) { - if (slogAppender != null) { - slog.removeAppender(slogAppender); - slogAppender.close(); - slogAppender = null; - } - } - } - - /** - * the sessionDir is given as the session location for new clients. - */ - protected File sessionDir; - - /** - * holds the list of attached clients - */ - ClientsFile clist; - - public static final String CLIENT_LIST = "Clients.obj"; - - /** - * holds the data - */ - VamsasFile vamArchive; - - public static final String VAMSAS_OBJ = "VamDoc.jar"; - - /** - * sets up the vamsas session files and watchers in sessionDir1 - * - * @param sessionDir1 - */ - protected VamsasSession(File sessionDir1) throws IOException { - this(sessionDir1, null); - } - - /** - * sets up the vamsas session files and watchers in sessionDir1 - * - * @param sessionDir1 - * @param extVamDoc - * null or an existing archive to initialise the session with - * @throws any - * IOExceptions from creating session directory and files. - * @throws error - * if both extVamDoc and sessionDir1 already exist (cannot import - * new data into session in this way) - */ - protected VamsasSession(File sessionDir1, File extVamDoc) throws IOException { - if (sessionDir1 == null) - throw new Error("Null directory for VamsasSession."); - if (!sessionDir1.exists() && !sessionDir1.mkdir()) { - throw new IOException("Failed to make VamsasSession directory in " - + sessionDir1); - } - if (!sessionDir1.isDirectory() || !sessionDir1.canWrite() - || !sessionDir1.canRead()) { - throw new IOException("Cannot access '" + sessionDir1 - + "' as a read/writable Directory."); - } - boolean existingSession=checkSessionFiles(sessionDir1); - if (existingSession) - { - if (extVamDoc!=null) { - throw new Error( - "Client Initialisation Error: Cannot join an existing session directory with an existing vamsas document to import."); - } else { - log - .debug("Joining an existing session."); - } - } - this.sessionDir = sessionDir1; - initSessionObjects(); - if (existingSession) - { slog.debug("Initialising additional VamsasSession instance"); - } else - { - slog.debug("Founding client has joined VamsasSession instance"); - } - - log.debug("Attached to VamsasSession in " + sessionDir1); - if (extVamDoc!=null) - { - setVamsasDocument(extVamDoc); - } - slog.debug("Session directory created."); - log.debug("Initialised VamsasSession in " + sessionDir1); - } - - /** - * tests presence of existing sessionfiles files in dir - * - * @param dir - * @return - */ - private boolean checkSessionFiles(File dir) throws IOException { - File c_file = new File(dir, CLIENT_LIST); - File v_doc = new File(dir, VAMSAS_OBJ); - if (c_file.exists() && v_doc.exists()) - return true; - return false; - } - - /** - * create new empty files in dir - * - */ - private void createSessionFiles() throws IOException { - if (sessionDir == null) - throw new IOException( - "Invalid call to createSessionFiles() with null sessionDir"); - File c_file = new File(sessionDir, CLIENT_LIST); - File v_doc = new File(sessionDir, VAMSAS_OBJ); - if (!c_file.exists() && c_file.createNewFile()) - log.debug("Created new ClientFile " + c_file); // don't care if this - // works or not - if (!v_doc.exists()) { - if (v_doc.createNewFile()) { - log.debug("Created new Vamsas Session Document File " + v_doc); - } else { - log.warn("Didn't create Vamsas Session Document file in " + v_doc); - } - } - } - - /** - * construct SessionFile objects and watchers for each - */ - private void initSessionObjects() throws IOException { - createSessionFiles(); - if (clist != null || vamArchive != null) - throw new IOException( - "initSessionObjects called for initialised VamsasSession object."); - clist = new ClientsFile(new File(sessionDir, CLIENT_LIST)); - vamArchive = new VamsasFile(new File(sessionDir, VAMSAS_OBJ)); - storedocfile = new ClientsFile(new File(sessionDir, CLOSEANDSAVE_FILE)); - initLog(); - } - - /** - * make a new watcher object for the clientFile - * - * @return new ClientFile watcher instance - */ - public FileWatcher getClientWatcher() { - return new FileWatcher(clist.sessionFile); - } - - /** - * make a new watcher object for the vamsas Document - * - * @return new ClientFile watcher instance - */ - public FileWatcher getDocWatcher() { - return new FileWatcher(vamArchive.sessionFile); - } - - FileWatcher store_doc_file = null; - - public ClientsFile storedocfile = null; - - /** - * make a new watcher object for the messages file - * - * @return new watcher instance - */ - public FileWatcher getStoreWatcher() { - return new FileWatcher(new File(sessionDir, CLOSEANDSAVE_FILE)); - - } - - /** - * write to the StoreWatcher file to indicate that a storeDocumentRequest has - * been made. The local client's storeWatcher FileWatcher object is updated so - * the initial change is not registered. - * - * @param client - * @param user - * @return - */ - public void addStoreDocumentRequest(ClientHandle client, UserHandle user) - throws IOException { - // TODO: replace this with clientsFile mechanism - SessionFile sfw = new SessionFile(new File(sessionDir, CLOSEANDSAVE_FILE)); - while (!sfw.lockFile()) - log.debug("Trying to get lock for " + CLOSEANDSAVE_FILE); - RandomAccessFile sfwfile = sfw.fileLock.getRaFile(); - sfwfile.setLength(0); // wipe out any old info. - // TODO: rationalise what gets written to this file (ie do we want other - // clients to read the id of the requestor?) - sfwfile.writeUTF(client.getClientUrn() + ":" + user.getFullName() + "@" - + user.getOrganization()); - sfw.unlockFile(); - if (store_doc_file != null) - store_doc_file.setState(); - slog.info("FinalizeAppData request from " + user.getFullName() + " using " - + client.getClientUrn() + ""); - } - - /** - * create a new session with an existing vamsas Document - by copying it into - * the session. - * - * @param archive - */ - public void setVamsasDocument(File archive) throws IOException { - log.debug("Transferring vamsas data from " + archive + " to session:" - + vamArchive.sessionFile); - SessionFile xtantdoc = new SessionFile(archive); - while (!vamArchive.lockFile()) - log.info("Trying to get lock for " + vamArchive.sessionFile); - vamArchive.updateFrom(null, xtantdoc); - xtantdoc.unlockFile(); - unlockVamsasDocument(); - // TODO: session archive provenance should be updated to reflect import from external source - log.debug("Transfer complete."); - } - - /** - * write session as a new vamsas Document (this will overwrite any existing - * file without warning) TODO: test TODO: verify that lock should be released - * for vamsas document. - * - * @param destarchive - */ - protected void writeVamsasDocument(File destarchive, Lock extlock) - throws IOException { - log.debug("Transferring vamsas data from " + vamArchive.sessionFile - + " to session:" + destarchive); - SessionFile newdoc = new SessionFile(destarchive); - if (extlock == null && !vamArchive.lockFile()) - while (!vamArchive.lockFile()) - log.info("Trying to get lock for " + vamArchive.sessionFile); - // TODO: LATER: decide if a provenance entry should be written in the - // exported document recording the export from the session - newdoc.updateFrom(null, vamArchive); - // LATER: LATER: fix use of updateFrom for file systems where locks cannot - // be made (because they don't have a lockManager, ie NFS/Unix, etc). - vamArchive.unLock(); - newdoc.unlockFile(); - log.debug("Transfer complete."); - } - - /** - * extant archive IO handler - */ - VamsasArchive _va = null; - - /** - * Creates a VamsasArchive Vobject for accessing and updating document Note: - * this will lock the Vamsas Document for exclusive access to the client. - * - * @return session vamsas document - * @throws IOException - * if locks fail or vamsas document read fails. - */ - protected VamsasArchive getVamsasDocument() throws IOException { - // check we haven't already done this once - probably should be done by - // caller - if (_va != null) - return _va; - // patiently wait for a lock on the document. (from - // ArchiveClient.getUpdateable()) - long tries = 5000; - while (vamArchive.getLock() == null && --tries > 0) { - // Thread.sleep(1); - log.debug("Trying to get a document lock for the " + tries + "'th time."); - } - if (tries == 0) - throw new IOException("Failed to get lock for vamsas archive."); - - VamsasArchive va = new VamsasArchive(vamArchive.sessionFile, false, true, - vamArchive); - - return va; - } - - /** - * Unlocks the vamsas archive session document after it has been closed. - * - * @throws IOException - */ - protected void unlockVamsasDocument() throws IOException { - if (_va != null) - _va.closeArchive(); - _va = null; - if (vamArchive != null) - vamArchive.unLock(); - - } - - /** - * create a uniquely named - * uk.ac.vamsas.client.simpleclient.ClientsFile.addClient(ClientHandle)ile in - * the session Directory - * - * @see java.io.File.createTempFile - * @param pref - * Prefix for name - * @param suff - * Suffix for name - * @return SessionFile object configured for the new file (of length zero) - * @throws IOException - */ - protected SessionFile getTempSessionFile(String pref, String suff) - throws IOException { - File tfile = File.createTempFile(pref, suff, sessionDir); - SessionFile tempFile = new SessionFile(tfile); - return tempFile; - } - - /** - * add a IClient to the session - * - * add the client to the client list file - * - * @param client - * client to add to the session - */ - protected void addClient(SimpleClient client) { - if (client == null) - slog.error("Try to add a null client to the session "); - else { - log.debug("Adding client " + client.getClientHandle().getClientUrn()); - getClientWatcherElement().haltWatch(); - clist.addClient(client.getClientHandle()); - - log.debug("Added."); - log.debug("Register Client as Active."); - try { - client.createActiveClientFile(); - } catch (IOException e) { - log.debug("Error during active client file creation."); - } - // tracks modification to the client list and readds client to the list - getClientWatcherElement().setHandler(new AddClientWatchCallBack(client)); - getClientWatcherElement().enableWatch(); - - } - } - - /** - * Handler for the client watcher. - * - * If (the current client is not in the client list, it is added again;) - */ - private class AddClientWatchCallBack implements WatcherCallBack { - - private SimpleClient client; - - /** - * Inits the handler with the client to check in the list - * - * @param client - * client to monitor in the client list - */ - protected AddClientWatchCallBack(SimpleClient client) { - this.client = client; - } - - /** - * If the client list is modified, checks if the current is still in the - * list. otherwise, readds ti. - * - * @return true to enable watcher, or false to disable it in future - * WatcherThread cycles. - */ - public boolean handleWatchEvent(WatcherElement watcher, Lock lock) { - boolean isWatchEnable = watcher.isWatchEnabled(); - if (lock == null)// no update on the list - return isWatchEnable; - log.debug("change on the client list "); - if (client != null) { - - // checks if the client is not already in the lists - ClientHandle[] cl = clist.retrieveClientList(lock);// clist.retrieveClientList(); - boolean found = false; - if (cl != null) { - for (int chi = cl.length - 1; !found && chi > -1; chi--) { - found = cl[chi].equals(this.client.getClientHandle()); - } - - } - if (!found) { - log.debug("client not in the list "); - if (log.isDebugEnabled()) - log - .debug("the client has not been found in the list. Adding it again :" - + cl); - addClient(client); - } else - log.debug("client is in the list"); - - } - log.debug("isWatchEnable " + isWatchEnable); - return isWatchEnable; - } - } - - /** - * - * removes a client from the current session removes the client from the - * session client list if the client is the last one from the session - * (ClientList), the current session is removed from active session list. - * - * The active should add them self to the client list. To insure to close the - * session,when the current client is the lact active client, clears the list - * of clients and when two cycles to insure there is no more active client, - * that otherwise would have readd themself to the list - * - * @param client - * client to remove - */ - protected void removeClient(SimpleClient client)// IClient client) - { - if (client == null) { - log.error("Null client passed to removeClient"); - return; - } - // ClientSessionFileWatcherElement cwe=getClientWatcherElement(); - // if (cwe!=null && cwe.isWatchEnabled()) { - // cwe.haltWatch(); - // }; - // set handler to check is the the last active client of the session - // Wait for several watchers cycle to see if the current client was the last - // client active in the session. - // if yes, close the session - - // getClientWatcherElement().setHandler(new RemoveClientWatchCallBack - // (client)); - // getClientWatcherElement().setTimeoutBeforeLastCycle(this.watchCycleCountBeforeLastClient); - log.info("remove client from list"); - if (clistWatchElement != null) { - clistWatchElement.haltWatch(); - clistWatchElement.watched.unlockFile(); - } - // clist.clearList(); - // clist.unlockFile(); - log.info("list cleared"); - // if (cwe!=null) { - // cwe.enableWatch(); - - log.debug("Stopping EventGenerator.."); - client.evgen.stopWatching(); - // cwe.setHandler(null); - // ask to the client to copy application data into the document - client.evgen._raise(Events.DOCUMENT_FINALIZEAPPDATA, null, client, null); - boolean closeSession = isLastActiveClient(client); - if (closeSession) { - if (client.get_session().getUnsavedFlag()) - { - log.debug("Raising request-to-save event"); - client.evgen._raise(Events.DOCUMENT_REQUESTTOCLOSE, null, client, null); - } - log.debug("Raising session shutdown event"); - client.evgen._raise(Events.SESSION_SHUTDOWN, null, client - .getSessionHandle(), null); - log.debug("All events raised for finalising session "+client.getSessionHandle().toString()); - } - // cwe.haltWatch(); - client.evgen.stopWatching(); - try { - log.debug("Attempting to release active client locks"); - client.releaseActiveClientFile(); - } catch (IOException e) { - log.error("error during active file client release"); - } - tidyUp(); - if (closeSession) { - log.debug("Last active client: closing session"); - log.info("Closing session"); - getSessionManager().removeSession(client.getSessionHandle()); - } - } - - /** - * close every file and stop. - */ - private void tidyUp() { - if (clist != null) - clist.unlockFile(); - clist = null; - storedocfile.unlockFile(); - storedocfile = null; - closeSessionLog(); - } - - private boolean isLastActiveClient(SimpleClient client) { - log.debug("Testing if current client is the last one."); - log - .debug("current client lockfile is '" + client.getClientlockFile() - + "'"); - boolean noOtherActiveClient = true; - // create, if need, subdirectory to contain client files - File clientlockFileDir = new File(this.sessionDir, clientFileDirectory); - if (!clientlockFileDir.exists()) { - log - .error("Something wrong the active client file does not exits... should not happen"); - return false; - } - - try { - - // no check every file in the directory and try to get lock on it. - File[] clientFiles = clientlockFileDir.listFiles(); - if (clientFiles == null || clientFiles.length == 0) {// there is not file - // on the directory. - // the current - // client should be - // the last one. - return true; - } - - for (int i = clientFiles.length - 1; i > -1 && noOtherActiveClient; i--) { - File clientFile = clientFiles[i]; - log.debug("testing file for lock: " + clientFile.getAbsolutePath()); - if (client.getClientLock().isTargetLockFile(clientFile)) { - log.debug("current client file found"); - continue; - } - if (clientFile != null && clientFile.exists()) { - try { - log.debug("Try to acquire a lock on the file"); - // Get a file channel for the file - FileChannel channel = new RandomAccessFile(clientFile, "rw") - .getChannel(); - - // Use the file channel to create a lock on the file. - // This method blocks until it can retrieve the lock. - // java.nio.channels.FileLock activeClientFilelock = channel.lock(); - - // Try acquiring the lock without blocking. This method returns - // null or throws an exception if the file is already locked. - try { - java.nio.channels.FileLock activeClientFilelock = channel - .tryLock(); - - // the lock has been acquired. - // the file was not lock and so the corresponding application - // seems to have die - if (activeClientFilelock != null) { - log - .debug("lock obtained : file must be from a crashed application"); - - activeClientFilelock.release(); - log.debug("lock released"); - - channel.close(); - log.debug("channel closed"); - - // delete file - clientFile.delete(); - log.debug("crashed application file deleted"); - - } else { - noOtherActiveClient = false; - log.debug("lock not obtained : another application is active"); - } - } catch (OverlappingFileLockException e) { - // File is already locked in this thread or virtual machine - // that the expected behaviour - log.debug("lock not accessible ", e); - } - } catch (Exception e) { - log.debug("error during lock testing ", e); - } - } - } - - } catch (Exception e) { - log.error("error during counting active clients"); - } - return noOtherActiveClient; - } - - /** - * Handler for the client watcher. after a client have been removed - * - * Checks if the client is not the last active one. - * - * If (the current client is not in the client list readd it;) - */ - private class RemoveClientWatchCallBack implements WatcherCallBack { - - private SimpleClient client; - - private boolean manualCheckOfClientCount = false; - - /** - * Inits the handler with the client to check in the list - * - * @param client - * client to monitor in the client list - */ - protected RemoveClientWatchCallBack(SimpleClient client) { - this.client = client; - } - - /** - * If the client list is modified, checks if the current is still in the - * list. otherwise, readds ti. - * - * @return true to enable watcher, or false to disable it in future - * WatcherThread cycles. - */ - public boolean handleWatchEvent(WatcherElement watcher, Lock lock) { - // if lock is null, no client has been added since last, clear. - // the client is then the last client - if (client != null) { - - if (lock == null) { - - // checks if the client is not already in the lists - // ClientHandle[] cl = - // clist.retrieveClientList();//lock);//clist.retrieveClientList(); - - boolean islastClient = true; - if (manualCheckOfClientCount) { - log.debug("manual checking of count of client"); - // checks if the client is not already in the lists - ClientHandle[] cl = clist.retrieveClientList();// lock);//clist.retrieveClientList(); - if (cl == null || cl.length < 1) - // {//no client has registered as active - { - islastClient = true; - log.debug("list is empty"); - } else - islastClient = false; - log.debug("list is not empty"); - } - // if(cl == null || cl.length<1 ) - // {//no client has registered as active - if (islastClient) { - // the client is the last one, so close current session - log.info("FROMCLIENTLIST WATCHER: last client removed: closing session"); - closeSession(client); - } - } else { - log.debug("not the last client found "); - // ask to the client to cpoy application data into the document - // client.evgen._raise(Events.DOCUMENT_FINALIZEAPPDATA, null, - // client,null); - - // / } - - } - log.debug("Stopping EventGenerator.."); - // TODO: ensure ClientsFile lock is really released!! - // clist.unlockFile(); - client.evgen.stopWatching(); - } - watcher.setHandler(null);// Do not check if the client is the last - // client. watcher will shutdown anyway - // watcher.haltWatch(); - // watcher. - return false; - } - } - - /** - * closes the current session, and send an event to the last client to close - * the document - * - * @param client - * the last client of the client - */ - private void closeSession(SimpleClient client) { - // close document - client.evgen._raise(Events.DOCUMENT_REQUESTTOCLOSE, null, client, null); - log.debug("close document request done"); - closeSession(client.getSessionHandle()); - } - - /** - * CLoses the current session - * - * @param sessionHandle - * sessionHandle of the session to remove - */ - private void closeSession(SessionHandle sessionHandle) { - getSessionManager().removeSession(sessionHandle); - log.debug("Session removed"); - } - - /** - * @return the sessionManager - */ - protected SimpleSessionManager getSessionManager() { - return sessionManager; - } - - /** - * @param sessionManager - * the sessionManager to set - */ - protected void setSessionManager(SimpleSessionManager sessionManager) { - this.sessionManager = sessionManager; - } - - public ClientsFile getStoreDocFile() { - if (storedocfile == null) { - - } - return storedocfile; - } - - ClientSessionFileWatcherElement clistWatchElement = null; - - /** - * get or create a watcher on clist. - * - * @return the contents of clistWatchElement or initialise it - */ - public ClientSessionFileWatcherElement getClientWatcherElement() { - if (clistWatchElement == null) { - clistWatchElement = new ClientSessionFileWatcherElement(clist, null); - } - return clistWatchElement; - } -} +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ +package uk.ac.vamsas.client.simpleclient; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.RandomAccessFile; +import java.nio.channels.FileChannel; +import java.nio.channels.OverlappingFileLockException; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.log4j.FileAppender; +import org.apache.log4j.Logger; +import org.apache.log4j.PatternLayout; + +import uk.ac.vamsas.client.ClientHandle; +import uk.ac.vamsas.client.Events; +import uk.ac.vamsas.client.IClient; +import uk.ac.vamsas.client.SessionHandle; +import uk.ac.vamsas.client.UserHandle; + +/** + * Does all the IO operations for a SimpleClient instance accessing a + * SimpleClient vamsas session. + * + * Basically, it defines the various standard names for the files in the session + * directory (that maps to the sessionUrn), provides constructors for the file + * handlers and watchers of those file entities, and some higher level methods + * to check and change the state flags for the session. + * + * TODO: move the stuff below to the SimpleClientFactory documentation. much may + * not be valid now : Vamsas client is intialised with a path to create live + * session directories. This path may contain a vamsas.properties file that sets + * additional parameters (otherwise client just uses the one on the classpath). + * + * A vamsas session consists of : SessionDir - translates to urn of a live + * session. Contains: Vamsas Document (as a jar), Session client list file, both + * of which may be locked, and additional temporary versions of these files when + * write operations are taking place. + * + * Zip file entries - vamsasdocument.xml : core info one or more: - + * .version.sessionnumber.raw (string given in + * vamsasdocument.xml applicationData entry) + * + * Lockfile - filename given in the vamsasdocument.xml. Should be checked for + * validity by any client and rewritten if necessary. The lockfile can point to + * the jar itself. Mode of operation. Initially - documentHandler either: - + * creates a zip for a new session for the client - connect to an existing + * session zip 1. reads session urn file 2. waits for lock 3. examines session - + * decide whether to create new application data slice or connect to one stored + * in session. 4. writes info into session file 5. releases lock and generates + * local client events. 6. Creates Watcher thread to generate events. + * + * During the session - Update watcher checks for file change - + * + * Procedures for file based session message exchange - session document + * modification flag + * + */ + +public class VamsasSession { + /** + * indicator file for informing other processes that they should finalise + * their vamsas datasets for storing into a vamsas archive. + */ + public static final String CLOSEANDSAVE_FILE = "stored.log"; + + /** + * session file storing the last_stored_stat data + */ + public static final String MODIFIEDDOC_FILE = "modified"; + + private SimpleSessionManager sessionManager = null; + + /** + * Count of cycles before considering the current client as the last one of + * the session (if no other client registered as active ) + */ + private final int watchCycleCountBeforeLastClient = 1220; + + /** + * time between checking + */ + public int WATCH_SLEEP = 30; + + protected String clientFileDirectory = "clients"; + + /** + * called to clear update flag after a successful offline storage event + */ + protected void clearUnsavedFlag() { + SessionFlagFile laststored = new SessionFlagFile(new File(sessionDir, + MODIFIEDDOC_FILE)); + if (!laststored.clearFlag()) + log.warn("Unsaved flag was not cleared for " + sessionDir); + } + + /** + * called to indicate session document has been modified. + * + */ + protected void setUnsavedFlag() { + SessionFlagFile laststored = new SessionFlagFile(new File(sessionDir, + MODIFIEDDOC_FILE)); + if (!laststored.setFlag()) + log.warn("Couldn't set the Unsaved flag for " + sessionDir); + } + + /** + * + * @return true if session document has been modified since last offline + * storage event + */ + protected boolean getUnsavedFlag() { + SessionFlagFile laststored = new SessionFlagFile(new File(sessionDir, + MODIFIEDDOC_FILE)); + return laststored.checkFlag(); + } + + /** + * log file location + */ + public static final String SESSION_LOG = "Log.txt"; + + private static Log log = LogFactory.getLog(VamsasSession.class); + + protected Logger slog = Logger.getLogger("uk.ac.vamsas.client.SessionLog"); + + /** + * the appender that writes to the log file inside the session's directory. + */ + private FileAppender slogAppender = null; + + /** + * setup the sessionLog using Log4j. + * + * @throws IOException + */ + private void initLog() throws IOException { + // TODO: fix session event logging + // LATER: make dedicated appender format for session log. + /* + * Appender app = slog.getAppender("log4j.appender.SESSIONLOG"); // + * slog.addAppender(new FileAppender(app.getLayout(), new File(sessionDir, + * SESSION_LOG).getAbsolutePath())); // slog.addAppender(new + * FileAppender(app.getLayout(), new File(sessionDir, + * SESSION_LOG).getAbsolutePath())); for (Enumeration e = + * slog.getAllAppenders() ; e.hasMoreElements() ;) { + * System.out.println(e.nextElement()); } + */ + + if (slog != null) { + File sessionLogFile = new File(this.sessionDir, SESSION_LOG); + slog.addAppender(slogAppender = new FileAppender(new PatternLayout( + "%-4r [%t] %-5p %c %x - %m%n"), sessionLogFile.getAbsolutePath(), + true)); + } else { + log.info("No appender for SessionLog"); + } + } + + private void closeSessionLog() { + if (slog != null) { + if (slogAppender != null) { + slog.removeAppender(slogAppender); + slogAppender.close(); + slogAppender = null; + } + } + } + + /** + * the sessionDir is given as the session location for new clients. + */ + protected File sessionDir; + + /** + * holds the list of attached clients + */ + ClientsFile clist; + + public static final String CLIENT_LIST = "Clients.obj"; + + /** + * holds the data + */ + VamsasFile vamArchive; + + public static final String VAMSAS_OBJ = "VamDoc.jar"; + + /** + * sets up the vamsas session files and watchers in sessionDir1 + * + * @param sessionDir1 + */ + protected VamsasSession(File sessionDir1) throws IOException { + this(sessionDir1, null); + } + + /** + * sets up the vamsas session files and watchers in sessionDir1 + * + * @param sessionDir1 + * @param extVamDoc + * null or an existing archive to initialise the session with + * @throws any + * IOExceptions from creating session directory and files. + * @throws error + * if both extVamDoc and sessionDir1 already exist (cannot import + * new data into session in this way) + */ + protected VamsasSession(File sessionDir1, File extVamDoc) throws IOException { + if (sessionDir1 == null) + throw new Error("Null directory for VamsasSession."); + if (!sessionDir1.exists() && !sessionDir1.mkdir()) { + throw new IOException("Failed to make VamsasSession directory in " + + sessionDir1); + } + if (!sessionDir1.isDirectory() || !sessionDir1.canWrite() + || !sessionDir1.canRead()) { + throw new IOException("Cannot access '" + sessionDir1 + + "' as a read/writable Directory."); + } + boolean existingSession = checkSessionFiles(sessionDir1); + if (existingSession) { + if (extVamDoc != null) { + throw new Error( + "Client Initialisation Error: Cannot join an existing session directory with an existing vamsas document to import."); + } else { + log.debug("Joining an existing session."); + } + } + this.sessionDir = sessionDir1; + initSessionObjects(); + if (existingSession) { + slog.debug("Initialising additional VamsasSession instance"); + } else { + slog.debug("Founding client has joined VamsasSession instance"); + } + + log.debug("Attached to VamsasSession in " + sessionDir1); + if (extVamDoc != null) { + setVamsasDocument(extVamDoc); + } + slog.debug("Session directory created."); + log.debug("Initialised VamsasSession in " + sessionDir1); + } + + /** + * tests presence of existing sessionfiles files in dir + * + * @param dir + * @return + */ + private boolean checkSessionFiles(File dir) throws IOException { + File c_file = new File(dir, CLIENT_LIST); + File v_doc = new File(dir, VAMSAS_OBJ); + if (c_file.exists() && v_doc.exists()) + return true; + return false; + } + + /** + * create new empty files in dir + * + */ + private void createSessionFiles() throws IOException { + if (sessionDir == null) + throw new IOException( + "Invalid call to createSessionFiles() with null sessionDir"); + File c_file = new File(sessionDir, CLIENT_LIST); + File v_doc = new File(sessionDir, VAMSAS_OBJ); + if (!c_file.exists() && c_file.createNewFile()) + log.debug("Created new ClientFile " + c_file); // don't care if this + // works or not + if (!v_doc.exists()) { + if (v_doc.createNewFile()) { + log.debug("Created new Vamsas Session Document File " + v_doc); + } else { + log.warn("Didn't create Vamsas Session Document file in " + v_doc); + } + } + } + + /** + * construct SessionFile objects and watchers for each + */ + private void initSessionObjects() throws IOException { + createSessionFiles(); + if (clist != null || vamArchive != null) + throw new IOException( + "initSessionObjects called for initialised VamsasSession object."); + clist = new ClientsFile(new File(sessionDir, CLIENT_LIST)); + vamArchive = new VamsasFile(new File(sessionDir, VAMSAS_OBJ)); + storedocfile = new ClientsFile(new File(sessionDir, CLOSEANDSAVE_FILE)); + initLog(); + } + + /** + * make a new watcher object for the clientFile + * + * @return new ClientFile watcher instance + */ + public FileWatcher getClientWatcher() { + return new FileWatcher(clist.sessionFile); + } + + /** + * make a new watcher object for the vamsas Document + * + * @return new ClientFile watcher instance + */ + public FileWatcher getDocWatcher() { + return new FileWatcher(vamArchive.sessionFile); + } + + FileWatcher store_doc_file = null; + + public ClientsFile storedocfile = null; + + /** + * make a new watcher object for the messages file + * + * @return new watcher instance + */ + public FileWatcher getStoreWatcher() { + return new FileWatcher(new File(sessionDir, CLOSEANDSAVE_FILE)); + + } + + /** + * write to the StoreWatcher file to indicate that a storeDocumentRequest has + * been made. The local client's storeWatcher FileWatcher object is updated so + * the initial change is not registered. + * + * @param client + * @param user + * @return + */ + public void addStoreDocumentRequest(ClientHandle client, UserHandle user) + throws IOException { + // TODO: replace this with clientsFile mechanism + SessionFile sfw = new SessionFile(new File(sessionDir, CLOSEANDSAVE_FILE)); + while (!sfw.lockFile()) + log.debug("Trying to get lock for " + CLOSEANDSAVE_FILE); + RandomAccessFile sfwfile = sfw.fileLock.getRaFile(); + sfwfile.setLength(0); // wipe out any old info. + // TODO: rationalise what gets written to this file (ie do we want other + // clients to read the id of the requestor?) + sfwfile.writeUTF(client.getClientUrn() + ":" + user.getFullName() + "@" + + user.getOrganization()); + sfw.unlockFile(); + if (store_doc_file != null) + store_doc_file.setState(); + slog.info("FinalizeAppData request from " + user.getFullName() + " using " + + client.getClientUrn() + ""); + } + + /** + * create a new session with an existing vamsas Document - by copying it into + * the session. + * + * @param archive + */ + public void setVamsasDocument(File archive) throws IOException { + log.debug("Transferring vamsas data from " + archive + " to session:" + + vamArchive.sessionFile); + SessionFile xtantdoc = new SessionFile(archive); + while (!vamArchive.lockFile()) + log.info("Trying to get lock for " + vamArchive.sessionFile); + vamArchive.updateFrom(null, xtantdoc); + xtantdoc.unlockFile(); + unlockVamsasDocument(); + // TODO: session archive provenance should be updated to reflect import from + // external source + log.debug("Transfer complete."); + } + + /** + * write session as a new vamsas Document (this will overwrite any existing + * file without warning) TODO: test TODO: verify that lock should be released + * for vamsas document. + * + * @param destarchive + */ + protected void writeVamsasDocument(File destarchive, Lock extlock) + throws IOException { + log.debug("Transferring vamsas data from " + vamArchive.sessionFile + + " to session:" + destarchive); + SessionFile newdoc = new SessionFile(destarchive); + if (extlock == null && !vamArchive.lockFile()) + while (!vamArchive.lockFile()) + log.info("Trying to get lock for " + vamArchive.sessionFile); + // TODO: LATER: decide if a provenance entry should be written in the + // exported document recording the export from the session + newdoc.updateFrom(null, vamArchive); + // LATER: LATER: fix use of updateFrom for file systems where locks cannot + // be made (because they don't have a lockManager, ie NFS/Unix, etc). + vamArchive.unLock(); + newdoc.unlockFile(); + log.debug("Transfer complete."); + } + + /** + * extant archive IO handler + */ + VamsasArchive _va = null; + + /** + * Creates a VamsasArchive Vobject for accessing and updating document Note: + * this will lock the Vamsas Document for exclusive access to the client. + * + * @return session vamsas document + * @throws IOException + * if locks fail or vamsas document read fails. + */ + protected VamsasArchive getVamsasDocument() throws IOException { + // check we haven't already done this once - probably should be done by + // caller + if (_va != null) + return _va; + // patiently wait for a lock on the document. (from + // ArchiveClient.getUpdateable()) + long tries = 5000; + while (vamArchive.getLock() == null && --tries > 0) { + // Thread.sleep(1); + log.debug("Trying to get a document lock for the " + tries + "'th time."); + } + if (tries == 0) + throw new IOException("Failed to get lock for vamsas archive."); + + VamsasArchive va = new VamsasArchive(vamArchive.sessionFile, false, true, + vamArchive); + + return va; + } + + /** + * Unlocks the vamsas archive session document after it has been closed. + * + * @throws IOException + */ + protected void unlockVamsasDocument() throws IOException { + if (_va != null) + _va.closeArchive(); + _va = null; + if (vamArchive != null) + vamArchive.unLock(); + + } + + /** + * create a uniquely named + * uk.ac.vamsas.client.simpleclient.ClientsFile.addClient(ClientHandle)ile in + * the session Directory + * + * @see java.io.File.createTempFile + * @param pref + * Prefix for name + * @param suff + * Suffix for name + * @return SessionFile object configured for the new file (of length zero) + * @throws IOException + */ + protected SessionFile getTempSessionFile(String pref, String suff) + throws IOException { + File tfile = File.createTempFile(pref, suff, sessionDir); + SessionFile tempFile = new SessionFile(tfile); + return tempFile; + } + + /** + * add a IClient to the session + * + * add the client to the client list file + * + * @param client + * client to add to the session + */ + protected void addClient(SimpleClient client) { + if (client == null) + slog.error("Try to add a null client to the session "); + else { + log.debug("Adding client " + client.getClientHandle().getClientUrn()); + getClientWatcherElement().haltWatch(); + clist.addClient(client.getClientHandle()); + + log.debug("Added."); + log.debug("Register Client as Active."); + try { + client.createActiveClientFile(); + } catch (IOException e) { + log.debug("Error during active client file creation."); + } + // tracks modification to the client list and readds client to the list + getClientWatcherElement().setHandler(new AddClientWatchCallBack(client)); + getClientWatcherElement().enableWatch(); + + } + } + + /** + * Handler for the client watcher. + * + * If (the current client is not in the client list, it is added again;) + */ + private class AddClientWatchCallBack implements WatcherCallBack { + + private SimpleClient client; + + /** + * Inits the handler with the client to check in the list + * + * @param client + * client to monitor in the client list + */ + protected AddClientWatchCallBack(SimpleClient client) { + this.client = client; + } + + /** + * If the client list is modified, checks if the current is still in the + * list. otherwise, readds ti. + * + * @return true to enable watcher, or false to disable it in future + * WatcherThread cycles. + */ + public boolean handleWatchEvent(WatcherElement watcher, Lock lock) { + boolean isWatchEnable = watcher.isWatchEnabled(); + if (lock == null)// no update on the list + return isWatchEnable; + log.debug("change on the client list "); + if (client != null) { + + // checks if the client is not already in the lists + ClientHandle[] cl = clist.retrieveClientList(lock);// clist.retrieveClientList(); + boolean found = false; + if (cl != null) { + for (int chi = cl.length - 1; !found && chi > -1; chi--) { + found = cl[chi].equals(this.client.getClientHandle()); + } + + } + if (!found) { + log.debug("client not in the list "); + if (log.isDebugEnabled()) + log + .debug("the client has not been found in the list. Adding it again :" + + cl); + addClient(client); + } else + log.debug("client is in the list"); + + } + log.debug("isWatchEnable " + isWatchEnable); + return isWatchEnable; + } + } + + /** + * + * removes a client from the current session removes the client from the + * session client list if the client is the last one from the session + * (ClientList), the current session is removed from active session list. + * + * The active should add them self to the client list. To insure to close the + * session,when the current client is the lact active client, clears the list + * of clients and when two cycles to insure there is no more active client, + * that otherwise would have readd themself to the list + * + * @param client + * client to remove + */ + protected void removeClient(SimpleClient client)// IClient client) + { + if (client == null) { + log.error("Null client passed to removeClient"); + return; + } + // ClientSessionFileWatcherElement cwe=getClientWatcherElement(); + // if (cwe!=null && cwe.isWatchEnabled()) { + // cwe.haltWatch(); + // }; + // set handler to check is the the last active client of the session + // Wait for several watchers cycle to see if the current client was the last + // client active in the session. + // if yes, close the session + + // getClientWatcherElement().setHandler(new RemoveClientWatchCallBack + // (client)); + // getClientWatcherElement().setTimeoutBeforeLastCycle(this.watchCycleCountBeforeLastClient); + log.info("remove client from list"); + if (clistWatchElement != null) { + clistWatchElement.haltWatch(); + clistWatchElement.watched.unlockFile(); + } + // clist.clearList(); + // clist.unlockFile(); + log.info("list cleared"); + // if (cwe!=null) { + // cwe.enableWatch(); + + log.debug("Stopping EventGenerator.."); + client.evgen.stopWatching(); + // cwe.setHandler(null); + // ask to the client to copy application data into the document + client.evgen._raise(Events.DOCUMENT_FINALIZEAPPDATA, null, client, null); + boolean closeSession = isLastActiveClient(client); + if (closeSession) { + if (client.get_session().getUnsavedFlag()) { + log.debug("Raising request-to-save event"); + client.evgen._raise(Events.DOCUMENT_REQUESTTOCLOSE, null, client, null); + } + log.debug("Raising session shutdown event"); + client.evgen._raise(Events.SESSION_SHUTDOWN, null, client + .getSessionHandle(), null); + log.debug("All events raised for finalising session " + + client.getSessionHandle().toString()); + } + // cwe.haltWatch(); + client.evgen.stopWatching(); + try { + log.debug("Attempting to release active client locks"); + client.releaseActiveClientFile(); + } catch (IOException e) { + log.error("error during active file client release"); + } + tidyUp(); + if (closeSession) { + log.debug("Last active client: closing session"); + log.info("Closing session"); + getSessionManager().removeSession(client.getSessionHandle()); + } + } + + /** + * close every file and stop. + */ + private void tidyUp() { + if (clist != null) + clist.unlockFile(); + clist = null; + storedocfile.unlockFile(); + storedocfile = null; + closeSessionLog(); + } + + private boolean isLastActiveClient(SimpleClient client) { + log.debug("Testing if current client is the last one."); + log + .debug("current client lockfile is '" + client.getClientlockFile() + + "'"); + boolean noOtherActiveClient = true; + // create, if need, subdirectory to contain client files + File clientlockFileDir = new File(this.sessionDir, clientFileDirectory); + if (!clientlockFileDir.exists()) { + log + .error("Something wrong the active client file does not exits... should not happen"); + return false; + } + + try { + + // no check every file in the directory and try to get lock on it. + File[] clientFiles = clientlockFileDir.listFiles(); + if (clientFiles == null || clientFiles.length == 0) {// there is not file + // on the directory. + // the current + // client should be + // the last one. + return true; + } + + for (int i = clientFiles.length - 1; i > -1 && noOtherActiveClient; i--) { + File clientFile = clientFiles[i]; + log.debug("testing file for lock: " + clientFile.getAbsolutePath()); + if (client.getClientLock().isTargetLockFile(clientFile)) { + log.debug("current client file found"); + continue; + } + if (clientFile != null && clientFile.exists()) { + try { + log.debug("Try to acquire a lock on the file"); + // Get a file channel for the file + FileChannel channel = new RandomAccessFile(clientFile, "rw") + .getChannel(); + + // Use the file channel to create a lock on the file. + // This method blocks until it can retrieve the lock. + // java.nio.channels.FileLock activeClientFilelock = channel.lock(); + + // Try acquiring the lock without blocking. This method returns + // null or throws an exception if the file is already locked. + try { + java.nio.channels.FileLock activeClientFilelock = channel + .tryLock(); + + // the lock has been acquired. + // the file was not lock and so the corresponding application + // seems to have die + if (activeClientFilelock != null) { + log + .debug("lock obtained : file must be from a crashed application"); + + activeClientFilelock.release(); + log.debug("lock released"); + + channel.close(); + log.debug("channel closed"); + + // delete file + clientFile.delete(); + log.debug("crashed application file deleted"); + + } else { + noOtherActiveClient = false; + log.debug("lock not obtained : another application is active"); + } + } catch (OverlappingFileLockException e) { + // File is already locked in this thread or virtual machine + // that the expected behaviour + log.debug("lock not accessible ", e); + } + } catch (Exception e) { + log.debug("error during lock testing ", e); + } + } + } + + } catch (Exception e) { + log.error("error during counting active clients"); + } + return noOtherActiveClient; + } + + /** + * Handler for the client watcher. after a client have been removed + * + * Checks if the client is not the last active one. + * + * If (the current client is not in the client list readd it;) + */ + private class RemoveClientWatchCallBack implements WatcherCallBack { + + private SimpleClient client; + + private boolean manualCheckOfClientCount = false; + + /** + * Inits the handler with the client to check in the list + * + * @param client + * client to monitor in the client list + */ + protected RemoveClientWatchCallBack(SimpleClient client) { + this.client = client; + } + + /** + * If the client list is modified, checks if the current is still in the + * list. otherwise, readds ti. + * + * @return true to enable watcher, or false to disable it in future + * WatcherThread cycles. + */ + public boolean handleWatchEvent(WatcherElement watcher, Lock lock) { + // if lock is null, no client has been added since last, clear. + // the client is then the last client + if (client != null) { + + if (lock == null) { + + // checks if the client is not already in the lists + // ClientHandle[] cl = + // clist.retrieveClientList();//lock);//clist.retrieveClientList(); + + boolean islastClient = true; + if (manualCheckOfClientCount) { + log.debug("manual checking of count of client"); + // checks if the client is not already in the lists + ClientHandle[] cl = clist.retrieveClientList();// lock);//clist.retrieveClientList(); + if (cl == null || cl.length < 1) + // {//no client has registered as active + { + islastClient = true; + log.debug("list is empty"); + } else + islastClient = false; + log.debug("list is not empty"); + } + // if(cl == null || cl.length<1 ) + // {//no client has registered as active + if (islastClient) { + // the client is the last one, so close current session + log + .info("FROMCLIENTLIST WATCHER: last client removed: closing session"); + closeSession(client); + } + } else { + log.debug("not the last client found "); + // ask to the client to cpoy application data into the document + // client.evgen._raise(Events.DOCUMENT_FINALIZEAPPDATA, null, + // client,null); + + // / } + + } + log.debug("Stopping EventGenerator.."); + // TODO: ensure ClientsFile lock is really released!! + // clist.unlockFile(); + client.evgen.stopWatching(); + } + watcher.setHandler(null);// Do not check if the client is the last + // client. watcher will shutdown anyway + // watcher.haltWatch(); + // watcher. + return false; + } + } + + /** + * closes the current session, and send an event to the last client to close + * the document + * + * @param client + * the last client of the client + */ + private void closeSession(SimpleClient client) { + // close document + client.evgen._raise(Events.DOCUMENT_REQUESTTOCLOSE, null, client, null); + log.debug("close document request done"); + closeSession(client.getSessionHandle()); + } + + /** + * CLoses the current session + * + * @param sessionHandle + * sessionHandle of the session to remove + */ + private void closeSession(SessionHandle sessionHandle) { + getSessionManager().removeSession(sessionHandle); + log.debug("Session removed"); + } + + /** + * @return the sessionManager + */ + protected SimpleSessionManager getSessionManager() { + return sessionManager; + } + + /** + * @param sessionManager + * the sessionManager to set + */ + protected void setSessionManager(SimpleSessionManager sessionManager) { + this.sessionManager = sessionManager; + } + + public ClientsFile getStoreDocFile() { + if (storedocfile == null) { + + } + return storedocfile; + } + + ClientSessionFileWatcherElement clistWatchElement = null; + + /** + * get or create a watcher on clist. + * + * @return the contents of clistWatchElement or initialise it + */ + public ClientSessionFileWatcherElement getClientWatcherElement() { + if (clistWatchElement == null) { + clistWatchElement = new ClientSessionFileWatcherElement(clist, null); + } + return clistWatchElement; + } +} diff --git a/src/uk/ac/vamsas/client/simpleclient/WatcherCallBack.java b/src/uk/ac/vamsas/client/simpleclient/WatcherCallBack.java index 28ff915..7c7e5b1 100644 --- a/src/uk/ac/vamsas/client/simpleclient/WatcherCallBack.java +++ b/src/uk/ac/vamsas/client/simpleclient/WatcherCallBack.java @@ -1,12 +1,35 @@ +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ package uk.ac.vamsas.client.simpleclient; /** - * Interface for VamsasFileWatcherElement call back events generated by the VamsasFileWatcherThread. + * Interface for VamsasFileWatcherElement call back events generated by the + * VamsasFileWatcherThread. */ public interface WatcherCallBack { /** * - * @return true to enable watcher, or false to disable it in future WatcherThread cycles. + * @return true to enable watcher, or false to disable it in future + * WatcherThread cycles. */ public boolean handleWatchEvent(WatcherElement watcher, Lock lock); } diff --git a/src/uk/ac/vamsas/client/simpleclient/WatcherElement.java b/src/uk/ac/vamsas/client/simpleclient/WatcherElement.java index b3235d5..80f9606 100644 --- a/src/uk/ac/vamsas/client/simpleclient/WatcherElement.java +++ b/src/uk/ac/vamsas/client/simpleclient/WatcherElement.java @@ -1,16 +1,40 @@ +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ package uk.ac.vamsas.client.simpleclient; - - public abstract class WatcherElement { - private static org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(VamsasFileWatcherElement.class); + private static org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory + .getLog(VamsasFileWatcherElement.class); + protected FileWatcher watcher = null; + protected WatcherCallBack handler = null; + /** * set this to false to stop the thread */ protected boolean watchForChange = true; + /** * true when the handler is being called for this watcher */ @@ -19,77 +43,78 @@ public abstract class WatcherElement { public WatcherElement(WatcherCallBack handler) { this.handler = handler; } + /** - * will instruct watcher to stop and wait around for one WATCH_SLEEP - * before returning. If no thread is running then it returns immediately. + * will instruct watcher to stop and wait around for one WATCH_SLEEP before + * returning. If no thread is running then it returns immediately. */ public void haltWatch() { // set the flag to skip this watch element. - watchForChange=false; + watchForChange = false; if (log.isDebugEnabled()) - log.debug("haltWatch on "+watcher.getSubject()); + log.debug("haltWatch on " + watcher.getSubject()); endWatch(); if (log.isDebugEnabled()) - log.debug("haltWatch completed on "+watcher.getSubject()); + log.debug("haltWatch completed on " + watcher.getSubject()); } + /** - * called by haltWatch before - * clearing the FileWatcher reference. - * + * called by haltWatch before clearing the FileWatcher reference. + * */ protected abstract void endWatch(); + /** - * called to generate the watcher object - * by enableWatch and in doWatch - * + * called to generate the watcher object by enableWatch and in doWatch + * */ protected abstract void initWatch(); + /** * implemented for debug information purposes. + * * @return Informative string about what the watcher is watching */ protected abstract String getSubject(); + /** - * must be called by implementations of - * enablewatch + * must be called by implementations of enablewatch */ protected void enableWatch() { if (log.isDebugEnabled()) - log.debug("enableWatch on "+getSubject()); - watchForChange=true; + log.debug("enableWatch on " + getSubject()); + watchForChange = true; initWatch(); if (log.isDebugEnabled()) - log.debug("enableWatch returning on "+getSubject()); + log.debug("enableWatch returning on " + getSubject()); } /** * Originally from the uk.ac.vamsas.test.simpleclient.ArchiveClient method + * * @return true if the handler was called for a changeEvent */ public boolean doWatch() { - if (!watchForChange || handler==null) + if (!watchForChange || handler == null) return false; - if (watcher==null) + if (watcher == null) initWatch(); // somehow not done the first time - handlerCalled=false; - Lock doclock=null; + handlerCalled = false; + Lock doclock = null; try { - doclock=watcher.getChangedState(); + doclock = watcher.getChangedState(); } catch (Exception e) { - log.error("Whilst watching "+watcher.getSubject(), e); + log.error("Whilst watching " + watcher.getSubject(), e); } - if (doclock==null) + if (doclock == null) return false; - /* handlerCalled=true; - if (log.isDebugEnabled()) - log.debug("Triggering watchEvent for change on "+watcher.getSubject()); - boolean finish=!handler.handleWatchEvent(this, doclock); - doclock=null; // TODO: check that lock should really be released rather than dereferenced - if (finish) - haltWatch(); - else - enableWatch(); - handlerCalled=false;*/ + /* + * handlerCalled=true; if (log.isDebugEnabled()) + * log.debug("Triggering watchEvent for change on "+watcher.getSubject()); + * boolean finish=!handler.handleWatchEvent(this, doclock); doclock=null; // + * TODO: check that lock should really be released rather than dereferenced + * if (finish) haltWatch(); else enableWatch(); handlerCalled=false; + */ this.callHandler(doclock); return true; } @@ -97,33 +122,36 @@ public abstract class WatcherElement { /** * Calls the current eventhandler * - * @param doclock the lock on the watch file + * @param doclock + * the lock on the watch file */ - protected void callHandler(Lock doclock) - { - if (log.isDebugEnabled()) - log.debug("Triggering watchEvent for change on "+watcher.getSubject()); - boolean finish=!handler.handleWatchEvent(this, doclock); - doclock=null; // TODO: check that lock should really be released rather than dereferenced - if (finish) - haltWatch(); - else - enableWatch(); - handlerCalled=false; + protected void callHandler(Lock doclock) { + if (log.isDebugEnabled()) + log.debug("Triggering watchEvent for change on " + watcher.getSubject()); + boolean finish = !handler.handleWatchEvent(this, doclock); + doclock = null; // TODO: check that lock should really be released rather + // than dereferenced + if (finish) + haltWatch(); + else + enableWatch(); + handlerCalled = false; } - + /** * @return the handler */ public WatcherCallBack getHandler() { return handler; } + /** * @return the handlerCalled */ public boolean isHandlerCalled() { return handlerCalled; } + /** * * @return true if watcher is enabled @@ -131,12 +159,15 @@ public abstract class WatcherElement { public boolean isWatchEnabled() { return watchForChange; } + /** - * @param handler the handler to set + * @param handler + * the handler to set */ public void setHandler(WatcherCallBack handler) { this.handler = handler; } + /** * @return the watcher */ diff --git a/src/uk/ac/vamsas/objects/DocumentUpdaterEngine.java b/src/uk/ac/vamsas/objects/DocumentUpdaterEngine.java index cb2d2c3..715d7e4 100644 --- a/src/uk/ac/vamsas/objects/DocumentUpdaterEngine.java +++ b/src/uk/ac/vamsas/objects/DocumentUpdaterEngine.java @@ -1,38 +1,67 @@ +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ package uk.ac.vamsas.objects; import uk.ac.vamsas.client.IClientDocument; import uk.ac.vamsas.objects.core.*; + /** - * Implements a depth first traversal over the document tree calling update handlers based on the Vobject.isUpdated() and Vobject.isNewInDocument() state at each backtrack. + * Implements a depth first traversal over the document tree calling update + * handlers based on the Vobject.isUpdated() and Vobject.isNewInDocument() state + * at each backtrack. + * * @author JimP - * + * */ public class DocumentUpdaterEngine { - private static org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(DocumentUpdaterEngine.class); + private static org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory + .getLog(DocumentUpdaterEngine.class); + private IDocumentUpdater handler; + /** - * initialise the engine with an implementation - * of the interface. + * initialise the engine with an implementation of the interface. + * * @param hander */ public DocumentUpdaterEngine(IDocumentUpdater handler) { super(); this.handler = handler; } + /** - * call the necessary update handlers at - * each point on the VamsasDocument OM - * TODO: later: Make this more elegant (use reflection and factor to single update(Object) method) ? - * - we take the plodding, explicit approach rather than a funky generalised one here + * call the necessary update handlers at each point on the VamsasDocument OM + * TODO: later: Make this more elegant (use reflection and factor to single + * update(Object) method) ? - we take the plodding, explicit approach rather + * than a funky generalised one here */ public void callHandlers(IClientDocument cdoc) { - if (cdoc==null) { + if (cdoc == null) { log.debug("Null IClientDocument instance."); return; } VAMSAS[] roots = cdoc.getVamsasRoots(); - if (roots!=null) { - for (int r=0; r. + */ package uk.ac.vamsas.objects; import uk.ac.vamsas.objects.core.*; -public class EmptyDocumentUpdater implements IDocumentUpdater -{ - public void update(Alignment vobj) {} - - public void update(AlignmentAnnotation vobj) {} - - public void update(AlignmentSequence vobj) {} - - public void update(AlignmentSequenceAnnotation vobj) {} - - public void update(AnnotationElement vobj) {} - - public void update(AppData vobj) {} - - public void update(ApplicationData vobj) {} - - public void update(Common vobj) {} - - public void update(DataSet vobj) {} - - public void update(DataSetAnnotations vobj) {} - - public void update(DbRef vobj) {} - - public void update(Entry vobj) {} - - public void update(Glyph vobj) {} - - public void update(Input vobj) {} - - public void update(Instance vobj) {} - - public void update(Link vobj) {} - - public void update(LockFile vobj) {} - - public void update(Map vobj) {} - - // TODO: replace with mapRangeType handler public void update(MapList vobj) {} - - public void update(SequenceMapping vobj) {} - - public void update(Newick vobj) {} - - public void update(Param vobj) {} - - public void update(Pos vobj) {} - - public void update(Property vobj) {} - - public void update(Provenance vobj) {} - - public void update(RangeAnnotation vobj) {} - - public void update(RangeType vobj) {} - - public void update(Score vobj) {} - - public void update(Seg vobj) {} - - public void update(Sequence vobj) {} - - public void update(SequenceType vobj) {} - - public void update(Tree vobj) {} - - public void update(User vobj) {} - - public void update(VAMSAS vobj) {} - - public void update(VamsasDocument vobj) {} -} \ No newline at end of file +public class EmptyDocumentUpdater implements IDocumentUpdater { + public void update(Alignment vobj) { + } + + public void update(AlignmentAnnotation vobj) { + } + + public void update(AlignmentSequence vobj) { + } + + public void update(AlignmentSequenceAnnotation vobj) { + } + + public void update(AnnotationElement vobj) { + } + + public void update(AppData vobj) { + } + + public void update(ApplicationData vobj) { + } + + public void update(Common vobj) { + } + + public void update(DataSet vobj) { + } + + public void update(DataSetAnnotations vobj) { + } + + public void update(DbRef vobj) { + } + + public void update(Entry vobj) { + } + + public void update(Glyph vobj) { + } + + public void update(Input vobj) { + } + + public void update(Instance vobj) { + } + + public void update(Link vobj) { + } + + public void update(LockFile vobj) { + } + + public void update(Map vobj) { + } + + // TODO: replace with mapRangeType handler public void update(MapList vobj) {} + + public void update(SequenceMapping vobj) { + } + + public void update(Newick vobj) { + } + + public void update(Param vobj) { + } + + public void update(Pos vobj) { + } + + public void update(Property vobj) { + } + + public void update(Provenance vobj) { + } + + public void update(RangeAnnotation vobj) { + } + + public void update(RangeType vobj) { + } + + public void update(Score vobj) { + } + + public void update(Seg vobj) { + } + + public void update(Sequence vobj) { + } + + public void update(SequenceType vobj) { + } + + public void update(Tree vobj) { + } + + public void update(User vobj) { + } + + public void update(VAMSAS vobj) { + } + + public void update(VamsasDocument vobj) { + } +} diff --git a/src/uk/ac/vamsas/objects/IDocumentUpdater.java b/src/uk/ac/vamsas/objects/IDocumentUpdater.java index bb8e2ae..c8ffc09 100644 --- a/src/uk/ac/vamsas/objects/IDocumentUpdater.java +++ b/src/uk/ac/vamsas/objects/IDocumentUpdater.java @@ -1,76 +1,96 @@ +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ package uk.ac.vamsas.objects; import uk.ac.vamsas.objects.core.*; -public interface IDocumentUpdater -{ - public void update(Alignment vobj); - - public void update(AlignmentAnnotation vobj); - - public void update(AlignmentSequence vobj); - - public void update(AlignmentSequenceAnnotation vobj); - - public void update(AnnotationElement vobj); - - public void update(AppData vobj); - - public void update(ApplicationData vobj); - - public void update(Common vobj); - - public void update(DataSet vobj); - - public void update(DataSetAnnotations vobj); - - public void update(DbRef vobj); - - public void update(Entry vobj); - - public void update(Glyph vobj); - - public void update(Input vobj); - - public void update(Instance vobj); - - public void update(Link vobj); - - public void update(LockFile vobj); - - public void update(Map vobj); - +public interface IDocumentUpdater { + public void update(Alignment vobj); + + public void update(AlignmentAnnotation vobj); + + public void update(AlignmentSequence vobj); + + public void update(AlignmentSequenceAnnotation vobj); + + public void update(AnnotationElement vobj); + + public void update(AppData vobj); + + public void update(ApplicationData vobj); + + public void update(Common vobj); + + public void update(DataSet vobj); + + public void update(DataSetAnnotations vobj); + + public void update(DbRef vobj); + + public void update(Entry vobj); + + public void update(Glyph vobj); + + public void update(Input vobj); + + public void update(Instance vobj); + + public void update(Link vobj); + + public void update(LockFile vobj); + + public void update(Map vobj); + // TODO: replace with mapRangeType handler public void update(MapList vobj) {} - - public void update(SequenceMapping vobj); - - public void update(Newick vobj); - - public void update(Param vobj); - - public void update(Pos vobj); - - public void update(Property vobj); - - public void update(Provenance vobj); - - public void update(RangeAnnotation vobj); - - public void update(RangeType vobj); - - public void update(Score vobj); - - public void update(Seg vobj); - - public void update(Sequence vobj); - - public void update(SequenceType vobj); - - public void update(Tree vobj); - - public void update(User vobj); - - public void update(VAMSAS vobj); - - public void update(VamsasDocument vobj); -} \ No newline at end of file + + public void update(SequenceMapping vobj); + + public void update(Newick vobj); + + public void update(Param vobj); + + public void update(Pos vobj); + + public void update(Property vobj); + + public void update(Provenance vobj); + + public void update(RangeAnnotation vobj); + + public void update(RangeType vobj); + + public void update(Score vobj); + + public void update(Seg vobj); + + public void update(Sequence vobj); + + public void update(SequenceType vobj); + + public void update(Tree vobj); + + public void update(User vobj); + + public void update(VAMSAS vobj); + + public void update(VamsasDocument vobj); +} diff --git a/src/uk/ac/vamsas/objects/IVorbaBinding.java b/src/uk/ac/vamsas/objects/IVorbaBinding.java index f70a3dd..bc7198f 100644 --- a/src/uk/ac/vamsas/objects/IVorbaBinding.java +++ b/src/uk/ac/vamsas/objects/IVorbaBinding.java @@ -1,5 +1,23 @@ -/** +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ package uk.ac.vamsas.objects; @@ -7,39 +25,48 @@ import uk.ac.vamsas.client.Vobject; import uk.ac.vamsas.client.VorbaId; /** - * Provides methods to map between VorbaIds and arbitrary object references - * for use by a vamsas Application when moving between its own datamodel and the - * Vamsas session objects. - * The implementing class needs a valid client-document instance if it is expected - * to be able to register newly created vObjects. Normally this will be the case if - * the implementing class has been generated by an IClient implementation which will - * also have passed it a reference to the current valid IClientDocument instance for - * that application's document access thread. - * TODO: add remove/clear binding functions - currently you can just pass a null - * to either argument for bindAppsObjectToVamsasObject to remove the binding from memory. + * Provides methods to map between VorbaIds and arbitrary object references for + * use by a vamsas Application when moving between its own datamodel and the + * Vamsas session objects. The implementing class needs a valid client-document + * instance if it is expected to be able to register newly created vObjects. + * Normally this will be the case if the implementing class has been generated + * by an IClient implementation which will also have passed it a reference to + * the current valid IClientDocument instance for that application's document + * access thread. TODO: add remove/clear binding functions - currently you can + * just pass a null to either argument for bindAppsObjectToVamsasObject to + * remove the binding from memory. + * * @author JimP * */ public interface IVorbaBinding { -/** - * get the Vamsas session object bound to an internal object. - * @param appObject - * @return valid session object or Null. - */ + /** + * get the Vamsas session object bound to an internal object. + * + * @param appObject + * @return valid session object or Null. + */ Vobject getVamsasObjectFor(Object appObject); + /** * Get the Application's own object bound to an existing Vamsas session object - * @param vObject - object in vamsas document + * + * @param vObject + * - object in vamsas document * @return apps object bound to the vamsas document object */ Object getAppsObjectFor(uk.ac.vamsas.client.Vobject vObject); /** - * Record a mapping between a vamsas document object and an application's internal object. - * If either appObject or vObject parameters are null then any existing - * binding to the non-null object will be deleted + * Record a mapping between a vamsas document object and an application's + * internal object. If either appObject or vObject parameters are null then + * any existing binding to the non-null object will be deleted + * * @param appObject - * @param vObject - if newly created then it will be registered using the uk.ac.vamsas.client.IClientDocument.registerObject method. + * @param vObject + * - if newly created then it will be registered using the + * uk.ac.vamsas.client.IClientDocument.registerObject method. */ - void bindAppsObjectToVamsasObject(Object appObject, uk.ac.vamsas.client.Vobject vObject); + void bindAppsObjectToVamsasObject(Object appObject, + uk.ac.vamsas.client.Vobject vObject); } diff --git a/src/uk/ac/vamsas/objects/core/Alignment.java b/src/uk/ac/vamsas/objects/core/Alignment.java index ffafc47..bc95178 100644 --- a/src/uk/ac/vamsas/objects/core/Alignment.java +++ b/src/uk/ac/vamsas/objects/core/Alignment.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import org.exolab.castor.xml.Marshaller; @@ -17,1314 +31,1370 @@ import org.exolab.castor.xml.Unmarshaller; /** * Class Alignment. * - * @version $Revision$ $Date$ + * @version $Revision$ $Date: 2007-06-28 14:51:44 +0100 (Thu, 28 Jun 2007) + * $ */ -public class Alignment extends uk.ac.vamsas.client.Vobject -implements java.io.Serializable -{ - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _gapChar. - */ - private java.lang.String _gapChar; - - /** - * Field _aligned. - */ - private boolean _aligned; - - /** - * keeps track of state for field: _aligned - */ - private boolean _has_aligned; - - /** - * Primary Key for vamsas object referencing - * - */ - private java.lang.String _id; - - /** - * Field _modifiable. - */ - private java.lang.String _modifiable; - - /** - * This is annotation over the coordinate frame - * defined by all the columns in the alignment. - * - */ - private java.util.Vector _alignmentAnnotationList; - - /** - * Field _treeList. - */ - private java.util.Vector _treeList; - - /** - * Field _alignmentSequenceList. - */ - private java.util.Vector _alignmentSequenceList; - - /** - * typical properties may be additional - * alignment score objects - */ - private java.util.Vector _propertyList; - - /** - * Field _provenance. - */ - private uk.ac.vamsas.objects.core.Provenance _provenance; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public Alignment() { - super(); - this._alignmentAnnotationList = new java.util.Vector(); - this._treeList = new java.util.Vector(); - this._alignmentSequenceList = new java.util.Vector(); - this._propertyList = new java.util.Vector(); - } - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * - * - * @param vAlignmentAnnotation - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addAlignmentAnnotation( - final uk.ac.vamsas.objects.core.AlignmentAnnotation vAlignmentAnnotation) - throws java.lang.IndexOutOfBoundsException { - this._alignmentAnnotationList.addElement(vAlignmentAnnotation); - } - - /** - * - * - * @param index - * @param vAlignmentAnnotation - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addAlignmentAnnotation( - final int index, - final uk.ac.vamsas.objects.core.AlignmentAnnotation vAlignmentAnnotation) - throws java.lang.IndexOutOfBoundsException { - this._alignmentAnnotationList.add(index, vAlignmentAnnotation); - } - - /** - * - * - * @param vAlignmentSequence - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addAlignmentSequence( - final uk.ac.vamsas.objects.core.AlignmentSequence vAlignmentSequence) - throws java.lang.IndexOutOfBoundsException { - this._alignmentSequenceList.addElement(vAlignmentSequence); - } - - /** - * - * - * @param index - * @param vAlignmentSequence - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addAlignmentSequence( - final int index, - final uk.ac.vamsas.objects.core.AlignmentSequence vAlignmentSequence) - throws java.lang.IndexOutOfBoundsException { - this._alignmentSequenceList.add(index, vAlignmentSequence); - } - - /** - * - * - * @param vProperty - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addProperty( - final uk.ac.vamsas.objects.core.Property vProperty) - throws java.lang.IndexOutOfBoundsException { - this._propertyList.addElement(vProperty); - } - - /** - * - * - * @param index - * @param vProperty - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addProperty( - final int index, - final uk.ac.vamsas.objects.core.Property vProperty) - throws java.lang.IndexOutOfBoundsException { - this._propertyList.add(index, vProperty); - } - - /** - * - * - * @param vTree - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addTree( - final uk.ac.vamsas.objects.core.Tree vTree) - throws java.lang.IndexOutOfBoundsException { - this._treeList.addElement(vTree); - } - - /** - * - * - * @param index - * @param vTree - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addTree( - final int index, - final uk.ac.vamsas.objects.core.Tree vTree) - throws java.lang.IndexOutOfBoundsException { - this._treeList.add(index, vTree); - } - - /** - */ - public void deleteAligned( - ) { - this._has_aligned= false; - } - - /** - * Method enumerateAlignmentAnnotation. - * - * @return an Enumeration over all - * uk.ac.vamsas.objects.core.AlignmentAnnotation elements - */ - public java.util.Enumeration enumerateAlignmentAnnotation( - ) { - return this._alignmentAnnotationList.elements(); - } - - /** - * Method enumerateAlignmentSequence. - * - * @return an Enumeration over all - * uk.ac.vamsas.objects.core.AlignmentSequence elements - */ - public java.util.Enumeration enumerateAlignmentSequence( - ) { - return this._alignmentSequenceList.elements(); - } - - /** - * Method enumerateProperty. - * - * @return an Enumeration over all - * uk.ac.vamsas.objects.core.Property elements - */ - public java.util.Enumeration enumerateProperty( - ) { - return this._propertyList.elements(); - } - - /** - * Method enumerateTree. - * - * @return an Enumeration over all - * uk.ac.vamsas.objects.core.Tree elements - */ - public java.util.Enumeration enumerateTree( - ) { - return this._treeList.elements(); - } - - /** - * Overrides the java.lang.Object.equals method. - * - * @param obj - * @return true if the objects are equal. - */ - public boolean equals( - final java.lang.Object obj) { - if ( this == obj ) - return true; - - if (super.equals(obj)==false) +public class Alignment extends uk.ac.vamsas.client.Vobject implements + java.io.Serializable { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _gapChar. + */ + private java.lang.String _gapChar; + + /** + * Field _aligned. + */ + private boolean _aligned; + + /** + * keeps track of state for field: _aligned + */ + private boolean _has_aligned; + + /** + * Primary Key for vamsas object referencing + * + */ + private java.lang.String _id; + + /** + * Field _modifiable. + */ + private java.lang.String _modifiable; + + /** + * This is annotation over the coordinate frame defined by all the columns in + * the alignment. + * + */ + private java.util.Vector _alignmentAnnotationList; + + /** + * Field _treeList. + */ + private java.util.Vector _treeList; + + /** + * Field _alignmentSequenceList. + */ + private java.util.Vector _alignmentSequenceList; + + /** + * typical properties may be additional alignment score objects + */ + private java.util.Vector _propertyList; + + /** + * Field _provenance. + */ + private uk.ac.vamsas.objects.core.Provenance _provenance; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public Alignment() { + super(); + this._alignmentAnnotationList = new java.util.Vector(); + this._treeList = new java.util.Vector(); + this._alignmentSequenceList = new java.util.Vector(); + this._propertyList = new java.util.Vector(); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * + * + * @param vAlignmentAnnotation + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addAlignmentAnnotation( + final uk.ac.vamsas.objects.core.AlignmentAnnotation vAlignmentAnnotation) + throws java.lang.IndexOutOfBoundsException { + this._alignmentAnnotationList.addElement(vAlignmentAnnotation); + } + + /** + * + * + * @param index + * @param vAlignmentAnnotation + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addAlignmentAnnotation(final int index, + final uk.ac.vamsas.objects.core.AlignmentAnnotation vAlignmentAnnotation) + throws java.lang.IndexOutOfBoundsException { + this._alignmentAnnotationList.add(index, vAlignmentAnnotation); + } + + /** + * + * + * @param vAlignmentSequence + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addAlignmentSequence( + final uk.ac.vamsas.objects.core.AlignmentSequence vAlignmentSequence) + throws java.lang.IndexOutOfBoundsException { + this._alignmentSequenceList.addElement(vAlignmentSequence); + } + + /** + * + * + * @param index + * @param vAlignmentSequence + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addAlignmentSequence(final int index, + final uk.ac.vamsas.objects.core.AlignmentSequence vAlignmentSequence) + throws java.lang.IndexOutOfBoundsException { + this._alignmentSequenceList.add(index, vAlignmentSequence); + } + + /** + * + * + * @param vProperty + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addProperty(final uk.ac.vamsas.objects.core.Property vProperty) + throws java.lang.IndexOutOfBoundsException { + this._propertyList.addElement(vProperty); + } + + /** + * + * + * @param index + * @param vProperty + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addProperty(final int index, + final uk.ac.vamsas.objects.core.Property vProperty) + throws java.lang.IndexOutOfBoundsException { + this._propertyList.add(index, vProperty); + } + + /** + * + * + * @param vTree + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addTree(final uk.ac.vamsas.objects.core.Tree vTree) + throws java.lang.IndexOutOfBoundsException { + this._treeList.addElement(vTree); + } + + /** + * + * + * @param index + * @param vTree + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addTree(final int index, + final uk.ac.vamsas.objects.core.Tree vTree) + throws java.lang.IndexOutOfBoundsException { + this._treeList.add(index, vTree); + } + + /** + */ + public void deleteAligned() { + this._has_aligned = false; + } + + /** + * Method enumerateAlignmentAnnotation. + * + * @return an Enumeration over all + * uk.ac.vamsas.objects.core.AlignmentAnnotation elements + */ + public java.util.Enumeration enumerateAlignmentAnnotation() { + return this._alignmentAnnotationList.elements(); + } + + /** + * Method enumerateAlignmentSequence. + * + * @return an Enumeration over all uk.ac.vamsas.objects.core.AlignmentSequence + * elements + */ + public java.util.Enumeration enumerateAlignmentSequence() { + return this._alignmentSequenceList.elements(); + } + + /** + * Method enumerateProperty. + * + * @return an Enumeration over all uk.ac.vamsas.objects.core.Property elements + */ + public java.util.Enumeration enumerateProperty() { + return this._propertyList.elements(); + } + + /** + * Method enumerateTree. + * + * @return an Enumeration over all uk.ac.vamsas.objects.core.Tree elements + */ + public java.util.Enumeration enumerateTree() { + return this._treeList.elements(); + } + + /** + * Overrides the java.lang.Object.equals method. + * + * @param obj + * @return true if the objects are equal. + */ + public boolean equals(final java.lang.Object obj) { + if (this == obj) + return true; + + if (super.equals(obj) == false) + return false; + + if (obj instanceof Alignment) { + + Alignment temp = (Alignment) obj; + boolean thcycle; + boolean tmcycle; + if (this._gapChar != null) { + if (temp._gapChar == null) + return false; + if (this._gapChar != temp._gapChar) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._gapChar); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._gapChar); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._gapChar); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._gapChar); + } + ; return false; - - if (obj instanceof Alignment) { - - Alignment temp = (Alignment)obj; - boolean thcycle; - boolean tmcycle; - if (this._gapChar != null) { - if (temp._gapChar == null) return false; - if (this._gapChar != temp._gapChar) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._gapChar); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._gapChar); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._gapChar); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._gapChar); }; - return false; - } - if (!thcycle) { - if (!this._gapChar.equals(temp._gapChar)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._gapChar); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._gapChar); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._gapChar); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._gapChar); - } - } - } else if (temp._gapChar != null) - return false; - if (this._aligned != temp._aligned) - return false; - if (this._has_aligned != temp._has_aligned) - return false; - if (this._id != null) { - if (temp._id == null) return false; - if (this._id != temp._id) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._id); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._id); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._id); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); }; - return false; - } - if (!thcycle) { - if (!this._id.equals(temp._id)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._id); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._id); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); - } - } - } else if (temp._id != null) - return false; - if (this._modifiable != null) { - if (temp._modifiable == null) return false; - if (this._modifiable != temp._modifiable) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._modifiable); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._modifiable); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._modifiable); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._modifiable); }; - return false; - } - if (!thcycle) { - if (!this._modifiable.equals(temp._modifiable)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._modifiable); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._modifiable); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._modifiable); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._modifiable); - } - } - } else if (temp._modifiable != null) - return false; - if (this._alignmentAnnotationList != null) { - if (temp._alignmentAnnotationList == null) return false; - if (this._alignmentAnnotationList != temp._alignmentAnnotationList) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._alignmentAnnotationList); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._alignmentAnnotationList); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._alignmentAnnotationList); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._alignmentAnnotationList); }; - return false; - } - if (!thcycle) { - if (!this._alignmentAnnotationList.equals(temp._alignmentAnnotationList)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._alignmentAnnotationList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._alignmentAnnotationList); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._alignmentAnnotationList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._alignmentAnnotationList); - } - } - } else if (temp._alignmentAnnotationList != null) - return false; - if (this._treeList != null) { - if (temp._treeList == null) return false; - if (this._treeList != temp._treeList) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._treeList); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._treeList); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._treeList); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._treeList); }; - return false; - } - if (!thcycle) { - if (!this._treeList.equals(temp._treeList)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._treeList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._treeList); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._treeList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._treeList); - } - } - } else if (temp._treeList != null) - return false; - if (this._alignmentSequenceList != null) { - if (temp._alignmentSequenceList == null) return false; - if (this._alignmentSequenceList != temp._alignmentSequenceList) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._alignmentSequenceList); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._alignmentSequenceList); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._alignmentSequenceList); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._alignmentSequenceList); }; - return false; - } - if (!thcycle) { - if (!this._alignmentSequenceList.equals(temp._alignmentSequenceList)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._alignmentSequenceList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._alignmentSequenceList); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._alignmentSequenceList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._alignmentSequenceList); - } - } - } else if (temp._alignmentSequenceList != null) - return false; - if (this._propertyList != null) { - if (temp._propertyList == null) return false; - if (this._propertyList != temp._propertyList) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._propertyList); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._propertyList); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._propertyList); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._propertyList); }; - return false; - } - if (!thcycle) { - if (!this._propertyList.equals(temp._propertyList)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._propertyList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._propertyList); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._propertyList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._propertyList); - } - } - } else if (temp._propertyList != null) - return false; - if (this._provenance != null) { - if (temp._provenance == null) return false; - if (this._provenance != temp._provenance) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._provenance); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._provenance); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance); }; - return false; - } - if (!thcycle) { - if (!this._provenance.equals(temp._provenance)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance); - } - } - } else if (temp._provenance != null) - return false; - return true; + } + if (!thcycle) { + if (!this._gapChar.equals(temp._gapChar)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._gapChar); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._gapChar); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._gapChar); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._gapChar); + } } + } else if (temp._gapChar != null) return false; - } - - /** - * Returns the value of field 'aligned'. - * - * @return the value of field 'Aligned'. - */ - public boolean getAligned( - ) { - return this._aligned; - } - - /** - * Method getAlignmentAnnotation. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the - * uk.ac.vamsas.objects.core.AlignmentAnnotation at the given - * index - */ - public uk.ac.vamsas.objects.core.AlignmentAnnotation getAlignmentAnnotation( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._alignmentAnnotationList.size()) { - throw new IndexOutOfBoundsException("getAlignmentAnnotation: Index value '" + index + "' not in range [0.." + (this._alignmentAnnotationList.size() - 1) + "]"); - } - - return (uk.ac.vamsas.objects.core.AlignmentAnnotation) _alignmentAnnotationList.get(index); - } - - /** - * Method getAlignmentAnnotation.Returns the contents of the - * collection in an Array.

Note: Just in case the - * collection contents are changing in another thread, we pass - * a 0-length Array of the correct type into the API call. - * This way we know that the Array returned is of - * exactly the correct length. - * - * @return this collection as an Array - */ - public uk.ac.vamsas.objects.core.AlignmentAnnotation[] getAlignmentAnnotation( - ) { - uk.ac.vamsas.objects.core.AlignmentAnnotation[] array = new uk.ac.vamsas.objects.core.AlignmentAnnotation[0]; - return (uk.ac.vamsas.objects.core.AlignmentAnnotation[]) this._alignmentAnnotationList.toArray(array); - } - - /** - * Method getAlignmentAnnotationAsReference.Returns a reference - * to '_alignmentAnnotationList'. No type checking is performed - * on any modifications to the Vector. - * - * @return a reference to the Vector backing this class - */ - public java.util.Vector getAlignmentAnnotationAsReference( - ) { - return this._alignmentAnnotationList; - } - - /** - * Method getAlignmentAnnotationCount. - * - * @return the size of this collection - */ - public int getAlignmentAnnotationCount( - ) { - return this._alignmentAnnotationList.size(); - } - - /** - * Method getAlignmentSequence. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the - * uk.ac.vamsas.objects.core.AlignmentSequence at the given inde - */ - public uk.ac.vamsas.objects.core.AlignmentSequence getAlignmentSequence( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._alignmentSequenceList.size()) { - throw new IndexOutOfBoundsException("getAlignmentSequence: Index value '" + index + "' not in range [0.." + (this._alignmentSequenceList.size() - 1) + "]"); - } - - return (uk.ac.vamsas.objects.core.AlignmentSequence) _alignmentSequenceList.get(index); - } - - /** - * Method getAlignmentSequence.Returns the contents of the - * collection in an Array.

Note: Just in case the - * collection contents are changing in another thread, we pass - * a 0-length Array of the correct type into the API call. - * This way we know that the Array returned is of - * exactly the correct length. - * - * @return this collection as an Array - */ - public uk.ac.vamsas.objects.core.AlignmentSequence[] getAlignmentSequence( - ) { - uk.ac.vamsas.objects.core.AlignmentSequence[] array = new uk.ac.vamsas.objects.core.AlignmentSequence[0]; - return (uk.ac.vamsas.objects.core.AlignmentSequence[]) this._alignmentSequenceList.toArray(array); - } - - /** - * Method getAlignmentSequenceAsReference.Returns a reference - * to '_alignmentSequenceList'. No type checking is performed - * on any modifications to the Vector. - * - * @return a reference to the Vector backing this class - */ - public java.util.Vector getAlignmentSequenceAsReference( - ) { - return this._alignmentSequenceList; - } - - /** - * Method getAlignmentSequenceCount. - * - * @return the size of this collection - */ - public int getAlignmentSequenceCount( - ) { - return this._alignmentSequenceList.size(); - } - - /** - * Returns the value of field 'gapChar'. - * - * @return the value of field 'GapChar'. - */ - public java.lang.String getGapChar( - ) { - return this._gapChar; - } - - /** - * Returns the value of field 'id'. The field 'id' has the - * following description: Primary Key for vamsas object - * referencing - * - * - * @return the value of field 'Id'. - */ - public java.lang.String getId( - ) { - return this._id; - } - - /** - * Returns the value of field 'modifiable'. - * - * @return the value of field 'Modifiable'. - */ - public java.lang.String getModifiable( - ) { - return this._modifiable; - } - - /** - * Method getProperty. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the uk.ac.vamsas.objects.core.Property - * at the given index - */ - public uk.ac.vamsas.objects.core.Property getProperty( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._propertyList.size()) { - throw new IndexOutOfBoundsException("getProperty: Index value '" + index + "' not in range [0.." + (this._propertyList.size() - 1) + "]"); - } - - return (uk.ac.vamsas.objects.core.Property) _propertyList.get(index); - } - - /** - * Method getProperty.Returns the contents of the collection in - * an Array.

Note: Just in case the collection contents - * are changing in another thread, we pass a 0-length Array of - * the correct type into the API call. This way we know - * that the Array returned is of exactly the correct length. - * - * @return this collection as an Array - */ - public uk.ac.vamsas.objects.core.Property[] getProperty( - ) { - uk.ac.vamsas.objects.core.Property[] array = new uk.ac.vamsas.objects.core.Property[0]; - return (uk.ac.vamsas.objects.core.Property[]) this._propertyList.toArray(array); - } - - /** - * Method getPropertyAsReference.Returns a reference to - * '_propertyList'. No type checking is performed on any - * modifications to the Vector. - * - * @return a reference to the Vector backing this class - */ - public java.util.Vector getPropertyAsReference( - ) { - return this._propertyList; - } - - /** - * Method getPropertyCount. - * - * @return the size of this collection - */ - public int getPropertyCount( - ) { - return this._propertyList.size(); - } - - /** - * Returns the value of field 'provenance'. - * - * @return the value of field 'Provenance'. - */ - public uk.ac.vamsas.objects.core.Provenance getProvenance( - ) { - return this._provenance; - } - - /** - * Method getTree. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the uk.ac.vamsas.objects.core.Tree at - * the given index - */ - public uk.ac.vamsas.objects.core.Tree getTree( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._treeList.size()) { - throw new IndexOutOfBoundsException("getTree: Index value '" + index + "' not in range [0.." + (this._treeList.size() - 1) + "]"); - } - - return (uk.ac.vamsas.objects.core.Tree) _treeList.get(index); - } - - /** - * Method getTree.Returns the contents of the collection in an - * Array.

Note: Just in case the collection contents are - * changing in another thread, we pass a 0-length Array of the - * correct type into the API call. This way we know - * that the Array returned is of exactly the correct length. - * - * @return this collection as an Array - */ - public uk.ac.vamsas.objects.core.Tree[] getTree( - ) { - uk.ac.vamsas.objects.core.Tree[] array = new uk.ac.vamsas.objects.core.Tree[0]; - return (uk.ac.vamsas.objects.core.Tree[]) this._treeList.toArray(array); - } - - /** - * Method getTreeAsReference.Returns a reference to - * '_treeList'. No type checking is performed on any - * modifications to the Vector. - * - * @return a reference to the Vector backing this class - */ - public java.util.Vector getTreeAsReference( - ) { - return this._treeList; - } - - /** - * Method getTreeCount. - * - * @return the size of this collection - */ - public int getTreeCount( - ) { - return this._treeList.size(); - } - - /** - * Method hasAligned. - * - * @return true if at least one Aligned has been added - */ - public boolean hasAligned( - ) { - return this._has_aligned; - } - - /** - * Overrides the java.lang.Object.hashCode method. - *

- * The following steps came from Effective Java Programming - * Language Guide by Joshua Bloch, Chapter 3 - * - * @return a hash code value for the object. - */ - public int hashCode( - ) { - int result = super.hashCode(); - - long tmp; - if (_gapChar != null - && !org.castor.util.CycleBreaker.startingToCycle(_gapChar)) { - result = 37 * result + _gapChar.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_gapChar); - } - result = 37 * result + (_aligned?0:1); - if (_id != null - && !org.castor.util.CycleBreaker.startingToCycle(_id)) { - result = 37 * result + _id.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_id); - } - if (_modifiable != null - && !org.castor.util.CycleBreaker.startingToCycle(_modifiable)) { - result = 37 * result + _modifiable.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_modifiable); - } - if (_alignmentAnnotationList != null - && !org.castor.util.CycleBreaker.startingToCycle(_alignmentAnnotationList)) { - result = 37 * result + _alignmentAnnotationList.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_alignmentAnnotationList); - } - if (_treeList != null - && !org.castor.util.CycleBreaker.startingToCycle(_treeList)) { - result = 37 * result + _treeList.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_treeList); - } - if (_alignmentSequenceList != null - && !org.castor.util.CycleBreaker.startingToCycle(_alignmentSequenceList)) { - result = 37 * result + _alignmentSequenceList.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_alignmentSequenceList); - } - if (_propertyList != null - && !org.castor.util.CycleBreaker.startingToCycle(_propertyList)) { - result = 37 * result + _propertyList.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_propertyList); - } - if (_provenance != null - && !org.castor.util.CycleBreaker.startingToCycle(_provenance)) { - result = 37 * result + _provenance.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_provenance); - } - - return result; - } - - /** - * Returns the value of field 'aligned'. - * - * @return the value of field 'Aligned'. - */ - public boolean isAligned( - ) { - return this._aligned; - } - - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { + if (this._aligned != temp._aligned) + return false; + if (this._has_aligned != temp._has_aligned) + return false; + if (this._id != null) { + if (temp._id == null) + return false; + if (this._id != temp._id) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._id); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._id); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._id); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); + } + ; return false; + } + if (!thcycle) { + if (!this._id.equals(temp._id)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._id); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._id); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); + } } - return true; - } - - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } - - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } - - /** - * Method removeAlignmentAnnotation. - * - * @param vAlignmentAnnotation - * @return true if the object was removed from the collection. - */ - public boolean removeAlignmentAnnotation( - final uk.ac.vamsas.objects.core.AlignmentAnnotation vAlignmentAnnotation) { - boolean removed = _alignmentAnnotationList.remove(vAlignmentAnnotation); - return removed; - } - - /** - * Method removeAlignmentAnnotationAt. - * - * @param index - * @return the element removed from the collection - */ - public uk.ac.vamsas.objects.core.AlignmentAnnotation removeAlignmentAnnotationAt( - final int index) { - java.lang.Object obj = this._alignmentAnnotationList.remove(index); - return (uk.ac.vamsas.objects.core.AlignmentAnnotation) obj; - } - - /** - * Method removeAlignmentSequence. - * - * @param vAlignmentSequence - * @return true if the object was removed from the collection. - */ - public boolean removeAlignmentSequence( - final uk.ac.vamsas.objects.core.AlignmentSequence vAlignmentSequence) { - boolean removed = _alignmentSequenceList.remove(vAlignmentSequence); - return removed; - } - - /** - * Method removeAlignmentSequenceAt. - * - * @param index - * @return the element removed from the collection - */ - public uk.ac.vamsas.objects.core.AlignmentSequence removeAlignmentSequenceAt( - final int index) { - java.lang.Object obj = this._alignmentSequenceList.remove(index); - return (uk.ac.vamsas.objects.core.AlignmentSequence) obj; - } - - /** - */ - public void removeAllAlignmentAnnotation( - ) { - this._alignmentAnnotationList.clear(); - } - - /** - */ - public void removeAllAlignmentSequence( - ) { - this._alignmentSequenceList.clear(); - } - - /** - */ - public void removeAllProperty( - ) { - this._propertyList.clear(); - } - - /** - */ - public void removeAllTree( - ) { - this._treeList.clear(); - } - - /** - * Method removeProperty. - * - * @param vProperty - * @return true if the object was removed from the collection. - */ - public boolean removeProperty( - final uk.ac.vamsas.objects.core.Property vProperty) { - boolean removed = _propertyList.remove(vProperty); - return removed; - } - - /** - * Method removePropertyAt. - * - * @param index - * @return the element removed from the collection - */ - public uk.ac.vamsas.objects.core.Property removePropertyAt( - final int index) { - java.lang.Object obj = this._propertyList.remove(index); - return (uk.ac.vamsas.objects.core.Property) obj; - } - - /** - * Method removeTree. - * - * @param vTree - * @return true if the object was removed from the collection. - */ - public boolean removeTree( - final uk.ac.vamsas.objects.core.Tree vTree) { - boolean removed = _treeList.remove(vTree); - return removed; - } - - /** - * Method removeTreeAt. - * - * @param index - * @return the element removed from the collection - */ - public uk.ac.vamsas.objects.core.Tree removeTreeAt( - final int index) { - java.lang.Object obj = this._treeList.remove(index); - return (uk.ac.vamsas.objects.core.Tree) obj; - } - - /** - * Sets the value of field 'aligned'. - * - * @param aligned the value of field 'aligned'. - */ - public void setAligned( - final boolean aligned) { - this._aligned = aligned; - this._has_aligned = true; - } - - /** - * - * - * @param index - * @param vAlignmentAnnotation - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setAlignmentAnnotation( - final int index, - final uk.ac.vamsas.objects.core.AlignmentAnnotation vAlignmentAnnotation) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._alignmentAnnotationList.size()) { - throw new IndexOutOfBoundsException("setAlignmentAnnotation: Index value '" + index + "' not in range [0.." + (this._alignmentAnnotationList.size() - 1) + "]"); - } - - this._alignmentAnnotationList.set(index, vAlignmentAnnotation); - } - - /** - * - * - * @param vAlignmentAnnotationArray - */ - public void setAlignmentAnnotation( - final uk.ac.vamsas.objects.core.AlignmentAnnotation[] vAlignmentAnnotationArray) { - //-- copy array - _alignmentAnnotationList.clear(); - - for (int i = 0; i < vAlignmentAnnotationArray.length; i++) { - this._alignmentAnnotationList.add(vAlignmentAnnotationArray[i]); - } - } - - /** - * Sets the value of '_alignmentAnnotationList' by copying the - * given Vector. All elements will be checked for type safety. - * - * @param vAlignmentAnnotationList the Vector to copy. - */ - public void setAlignmentAnnotation( - final java.util.Vector vAlignmentAnnotationList) { - // copy vector - this._alignmentAnnotationList.clear(); - - this._alignmentAnnotationList.addAll(vAlignmentAnnotationList); - } - - /** - * Sets the value of '_alignmentAnnotationList' by setting it - * to the given Vector. No type checking is performed. - * @deprecated - * - * @param alignmentAnnotationVector the Vector to set. - */ - public void setAlignmentAnnotationAsReference( - final java.util.Vector alignmentAnnotationVector) { - this._alignmentAnnotationList = alignmentAnnotationVector; - } - - /** - * - * - * @param index - * @param vAlignmentSequence - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setAlignmentSequence( - final int index, - final uk.ac.vamsas.objects.core.AlignmentSequence vAlignmentSequence) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._alignmentSequenceList.size()) { - throw new IndexOutOfBoundsException("setAlignmentSequence: Index value '" + index + "' not in range [0.." + (this._alignmentSequenceList.size() - 1) + "]"); + } else if (temp._id != null) + return false; + if (this._modifiable != null) { + if (temp._modifiable == null) + return false; + if (this._modifiable != temp._modifiable) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._modifiable); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._modifiable); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._modifiable); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._modifiable); + } + ; + return false; + } + if (!thcycle) { + if (!this._modifiable.equals(temp._modifiable)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._modifiable); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._modifiable); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._modifiable); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._modifiable); + } } - - this._alignmentSequenceList.set(index, vAlignmentSequence); - } - - /** - * - * - * @param vAlignmentSequenceArray - */ - public void setAlignmentSequence( - final uk.ac.vamsas.objects.core.AlignmentSequence[] vAlignmentSequenceArray) { - //-- copy array - _alignmentSequenceList.clear(); - - for (int i = 0; i < vAlignmentSequenceArray.length; i++) { - this._alignmentSequenceList.add(vAlignmentSequenceArray[i]); + } else if (temp._modifiable != null) + return false; + if (this._alignmentAnnotationList != null) { + if (temp._alignmentAnnotationList == null) + return false; + if (this._alignmentAnnotationList != temp._alignmentAnnotationList) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._alignmentAnnotationList); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._alignmentAnnotationList); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker + .releaseCycleHandle(this._alignmentAnnotationList); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._alignmentAnnotationList); + } + ; + return false; + } + if (!thcycle) { + if (!this._alignmentAnnotationList + .equals(temp._alignmentAnnotationList)) { + org.castor.util.CycleBreaker + .releaseCycleHandle(this._alignmentAnnotationList); + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._alignmentAnnotationList); + return false; + } + org.castor.util.CycleBreaker + .releaseCycleHandle(this._alignmentAnnotationList); + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._alignmentAnnotationList); + } } - } - - /** - * Sets the value of '_alignmentSequenceList' by copying the - * given Vector. All elements will be checked for type safety. - * - * @param vAlignmentSequenceList the Vector to copy. - */ - public void setAlignmentSequence( - final java.util.Vector vAlignmentSequenceList) { - // copy vector - this._alignmentSequenceList.clear(); - - this._alignmentSequenceList.addAll(vAlignmentSequenceList); - } - - /** - * Sets the value of '_alignmentSequenceList' by setting it to - * the given Vector. No type checking is performed. - * @deprecated - * - * @param alignmentSequenceVector the Vector to set. - */ - public void setAlignmentSequenceAsReference( - final java.util.Vector alignmentSequenceVector) { - this._alignmentSequenceList = alignmentSequenceVector; - } - - /** - * Sets the value of field 'gapChar'. - * - * @param gapChar the value of field 'gapChar'. - */ - public void setGapChar( - final java.lang.String gapChar) { - this._gapChar = gapChar; - } - - /** - * 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( - final java.lang.String id) { - this._id = id; - } - - /** - * Sets the value of field 'modifiable'. - * - * @param modifiable the value of field 'modifiable'. - */ - public void setModifiable( - final java.lang.String modifiable) { - this._modifiable = modifiable; - } - - /** - * - * - * @param index - * @param vProperty - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setProperty( - final int index, - final uk.ac.vamsas.objects.core.Property vProperty) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._propertyList.size()) { - throw new IndexOutOfBoundsException("setProperty: Index value '" + index + "' not in range [0.." + (this._propertyList.size() - 1) + "]"); + } else if (temp._alignmentAnnotationList != null) + return false; + if (this._treeList != null) { + if (temp._treeList == null) + return false; + if (this._treeList != temp._treeList) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._treeList); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._treeList); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._treeList); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._treeList); + } + ; + return false; + } + if (!thcycle) { + if (!this._treeList.equals(temp._treeList)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._treeList); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._treeList); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._treeList); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._treeList); + } } - - this._propertyList.set(index, vProperty); - } - - /** - * - * - * @param vPropertyArray - */ - public void setProperty( - final uk.ac.vamsas.objects.core.Property[] vPropertyArray) { - //-- copy array - _propertyList.clear(); - - for (int i = 0; i < vPropertyArray.length; i++) { - this._propertyList.add(vPropertyArray[i]); + } else if (temp._treeList != null) + return false; + if (this._alignmentSequenceList != null) { + if (temp._alignmentSequenceList == null) + return false; + if (this._alignmentSequenceList != temp._alignmentSequenceList) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._alignmentSequenceList); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._alignmentSequenceList); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker + .releaseCycleHandle(this._alignmentSequenceList); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._alignmentSequenceList); + } + ; + return false; + } + if (!thcycle) { + if (!this._alignmentSequenceList + .equals(temp._alignmentSequenceList)) { + org.castor.util.CycleBreaker + .releaseCycleHandle(this._alignmentSequenceList); + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._alignmentSequenceList); + return false; + } + org.castor.util.CycleBreaker + .releaseCycleHandle(this._alignmentSequenceList); + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._alignmentSequenceList); + } } - } - - /** - * Sets the value of '_propertyList' by copying the given - * Vector. All elements will be checked for type safety. - * - * @param vPropertyList the Vector to copy. - */ - public void setProperty( - final java.util.Vector vPropertyList) { - // copy vector - this._propertyList.clear(); - - this._propertyList.addAll(vPropertyList); - } - - /** - * Sets the value of '_propertyList' by setting it to the given - * Vector. No type checking is performed. - * @deprecated - * - * @param propertyVector the Vector to set. - */ - public void setPropertyAsReference( - final java.util.Vector propertyVector) { - this._propertyList = propertyVector; - } - - /** - * Sets the value of field 'provenance'. - * - * @param provenance the value of field 'provenance'. - */ - public void setProvenance( - final uk.ac.vamsas.objects.core.Provenance provenance) { - this._provenance = provenance; - } - - /** - * - * - * @param index - * @param vTree - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setTree( - final int index, - final uk.ac.vamsas.objects.core.Tree vTree) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._treeList.size()) { - throw new IndexOutOfBoundsException("setTree: Index value '" + index + "' not in range [0.." + (this._treeList.size() - 1) + "]"); + } else if (temp._alignmentSequenceList != null) + return false; + if (this._propertyList != null) { + if (temp._propertyList == null) + return false; + if (this._propertyList != temp._propertyList) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._propertyList); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._propertyList); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker + .releaseCycleHandle(this._propertyList); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._propertyList); + } + ; + return false; + } + if (!thcycle) { + if (!this._propertyList.equals(temp._propertyList)) { + org.castor.util.CycleBreaker + .releaseCycleHandle(this._propertyList); + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._propertyList); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._propertyList); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._propertyList); + } } - - this._treeList.set(index, vTree); - } - - /** - * - * - * @param vTreeArray - */ - public void setTree( - final uk.ac.vamsas.objects.core.Tree[] vTreeArray) { - //-- copy array - _treeList.clear(); - - for (int i = 0; i < vTreeArray.length; i++) { - this._treeList.add(vTreeArray[i]); + } else if (temp._propertyList != null) + return false; + if (this._provenance != null) { + if (temp._provenance == null) + return false; + if (this._provenance != temp._provenance) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._provenance); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._provenance); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance); + } + ; + return false; + } + if (!thcycle) { + if (!this._provenance.equals(temp._provenance)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance); + } } - } - - /** - * Sets the value of '_treeList' by copying the given Vector. - * All elements will be checked for type safety. - * - * @param vTreeList the Vector to copy. - */ - public void setTree( - final java.util.Vector vTreeList) { - // copy vector - this._treeList.clear(); - - this._treeList.addAll(vTreeList); - } - - /** - * Sets the value of '_treeList' by setting it to the given - * Vector. No type checking is performed. - * @deprecated - * - * @param treeVector the Vector to set. - */ - public void setTreeAsReference( - final java.util.Vector treeVector) { - this._treeList = treeVector; - } - - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled uk.ac.vamsas.objects.core.Alignment - */ - public static uk.ac.vamsas.objects.core.Alignment unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (uk.ac.vamsas.objects.core.Alignment) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.Alignment.class, reader); - } - - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); - } + } else if (temp._provenance != null) + return false; + return true; + } + return false; + } + + /** + * Returns the value of field 'aligned'. + * + * @return the value of field 'Aligned'. + */ + public boolean getAligned() { + return this._aligned; + } + + /** + * Method getAlignmentAnnotation. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the uk.ac.vamsas.objects.core.AlignmentAnnotation at + * the given index + */ + public uk.ac.vamsas.objects.core.AlignmentAnnotation getAlignmentAnnotation( + final int index) throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._alignmentAnnotationList.size()) { + throw new IndexOutOfBoundsException( + "getAlignmentAnnotation: Index value '" + index + + "' not in range [0.." + + (this._alignmentAnnotationList.size() - 1) + "]"); + } + + return (uk.ac.vamsas.objects.core.AlignmentAnnotation) _alignmentAnnotationList + .get(index); + } + + /** + * Method getAlignmentAnnotation.Returns the contents of the collection in an + * Array. + *

+ * Note: Just in case the collection contents are changing in another thread, + * we pass a 0-length Array of the correct type into the API call. This way we + * know that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public uk.ac.vamsas.objects.core.AlignmentAnnotation[] getAlignmentAnnotation() { + uk.ac.vamsas.objects.core.AlignmentAnnotation[] array = new uk.ac.vamsas.objects.core.AlignmentAnnotation[0]; + return (uk.ac.vamsas.objects.core.AlignmentAnnotation[]) this._alignmentAnnotationList + .toArray(array); + } + + /** + * Method getAlignmentAnnotationAsReference.Returns a reference to + * '_alignmentAnnotationList'. No type checking is performed on any + * modifications to the Vector. + * + * @return a reference to the Vector backing this class + */ + public java.util.Vector getAlignmentAnnotationAsReference() { + return this._alignmentAnnotationList; + } + + /** + * Method getAlignmentAnnotationCount. + * + * @return the size of this collection + */ + public int getAlignmentAnnotationCount() { + return this._alignmentAnnotationList.size(); + } + + /** + * Method getAlignmentSequence. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the uk.ac.vamsas.objects.core.AlignmentSequence at the + * given inde + */ + public uk.ac.vamsas.objects.core.AlignmentSequence getAlignmentSequence( + final int index) throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._alignmentSequenceList.size()) { + throw new IndexOutOfBoundsException("getAlignmentSequence: Index value '" + + index + "' not in range [0.." + + (this._alignmentSequenceList.size() - 1) + "]"); + } + + return (uk.ac.vamsas.objects.core.AlignmentSequence) _alignmentSequenceList + .get(index); + } + + /** + * Method getAlignmentSequence.Returns the contents of the collection in an + * Array. + *

+ * Note: Just in case the collection contents are changing in another thread, + * we pass a 0-length Array of the correct type into the API call. This way we + * know that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public uk.ac.vamsas.objects.core.AlignmentSequence[] getAlignmentSequence() { + uk.ac.vamsas.objects.core.AlignmentSequence[] array = new uk.ac.vamsas.objects.core.AlignmentSequence[0]; + return (uk.ac.vamsas.objects.core.AlignmentSequence[]) this._alignmentSequenceList + .toArray(array); + } + + /** + * Method getAlignmentSequenceAsReference.Returns a reference to + * '_alignmentSequenceList'. No type checking is performed on any + * modifications to the Vector. + * + * @return a reference to the Vector backing this class + */ + public java.util.Vector getAlignmentSequenceAsReference() { + return this._alignmentSequenceList; + } + + /** + * Method getAlignmentSequenceCount. + * + * @return the size of this collection + */ + public int getAlignmentSequenceCount() { + return this._alignmentSequenceList.size(); + } + + /** + * Returns the value of field 'gapChar'. + * + * @return the value of field 'GapChar'. + */ + public java.lang.String getGapChar() { + return this._gapChar; + } + + /** + * Returns the value of field 'id'. The field 'id' has the following + * description: Primary Key for vamsas object referencing + * + * + * @return the value of field 'Id'. + */ + public java.lang.String getId() { + return this._id; + } + + /** + * Returns the value of field 'modifiable'. + * + * @return the value of field 'Modifiable'. + */ + public java.lang.String getModifiable() { + return this._modifiable; + } + + /** + * Method getProperty. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the uk.ac.vamsas.objects.core.Property at the given + * index + */ + public uk.ac.vamsas.objects.core.Property getProperty(final int index) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._propertyList.size()) { + throw new IndexOutOfBoundsException("getProperty: Index value '" + index + + "' not in range [0.." + (this._propertyList.size() - 1) + "]"); + } + + return (uk.ac.vamsas.objects.core.Property) _propertyList.get(index); + } + + /** + * Method getProperty.Returns the contents of the collection in an Array. + *

+ * Note: Just in case the collection contents are changing in another thread, + * we pass a 0-length Array of the correct type into the API call. This way we + * know that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public uk.ac.vamsas.objects.core.Property[] getProperty() { + uk.ac.vamsas.objects.core.Property[] array = new uk.ac.vamsas.objects.core.Property[0]; + return (uk.ac.vamsas.objects.core.Property[]) this._propertyList + .toArray(array); + } + + /** + * Method getPropertyAsReference.Returns a reference to '_propertyList'. No + * type checking is performed on any modifications to the Vector. + * + * @return a reference to the Vector backing this class + */ + public java.util.Vector getPropertyAsReference() { + return this._propertyList; + } + + /** + * Method getPropertyCount. + * + * @return the size of this collection + */ + public int getPropertyCount() { + return this._propertyList.size(); + } + + /** + * Returns the value of field 'provenance'. + * + * @return the value of field 'Provenance'. + */ + public uk.ac.vamsas.objects.core.Provenance getProvenance() { + return this._provenance; + } + + /** + * Method getTree. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the uk.ac.vamsas.objects.core.Tree at the given index + */ + public uk.ac.vamsas.objects.core.Tree getTree(final int index) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._treeList.size()) { + throw new IndexOutOfBoundsException("getTree: Index value '" + index + + "' not in range [0.." + (this._treeList.size() - 1) + "]"); + } + + return (uk.ac.vamsas.objects.core.Tree) _treeList.get(index); + } + + /** + * Method getTree.Returns the contents of the collection in an Array. + *

+ * Note: Just in case the collection contents are changing in another thread, + * we pass a 0-length Array of the correct type into the API call. This way we + * know that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public uk.ac.vamsas.objects.core.Tree[] getTree() { + uk.ac.vamsas.objects.core.Tree[] array = new uk.ac.vamsas.objects.core.Tree[0]; + return (uk.ac.vamsas.objects.core.Tree[]) this._treeList.toArray(array); + } + + /** + * Method getTreeAsReference.Returns a reference to '_treeList'. No type + * checking is performed on any modifications to the Vector. + * + * @return a reference to the Vector backing this class + */ + public java.util.Vector getTreeAsReference() { + return this._treeList; + } + + /** + * Method getTreeCount. + * + * @return the size of this collection + */ + public int getTreeCount() { + return this._treeList.size(); + } + + /** + * Method hasAligned. + * + * @return true if at least one Aligned has been added + */ + public boolean hasAligned() { + return this._has_aligned; + } + + /** + * Overrides the java.lang.Object.hashCode method. + *

+ * The following steps came from Effective Java Programming Language + * Guide by Joshua Bloch, Chapter 3 + * + * @return a hash code value for the object. + */ + public int hashCode() { + int result = super.hashCode(); + + long tmp; + if (_gapChar != null + && !org.castor.util.CycleBreaker.startingToCycle(_gapChar)) { + result = 37 * result + _gapChar.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_gapChar); + } + result = 37 * result + (_aligned ? 0 : 1); + if (_id != null && !org.castor.util.CycleBreaker.startingToCycle(_id)) { + result = 37 * result + _id.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_id); + } + if (_modifiable != null + && !org.castor.util.CycleBreaker.startingToCycle(_modifiable)) { + result = 37 * result + _modifiable.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_modifiable); + } + if (_alignmentAnnotationList != null + && !org.castor.util.CycleBreaker + .startingToCycle(_alignmentAnnotationList)) { + result = 37 * result + _alignmentAnnotationList.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_alignmentAnnotationList); + } + if (_treeList != null + && !org.castor.util.CycleBreaker.startingToCycle(_treeList)) { + result = 37 * result + _treeList.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_treeList); + } + if (_alignmentSequenceList != null + && !org.castor.util.CycleBreaker + .startingToCycle(_alignmentSequenceList)) { + result = 37 * result + _alignmentSequenceList.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_alignmentSequenceList); + } + if (_propertyList != null + && !org.castor.util.CycleBreaker.startingToCycle(_propertyList)) { + result = 37 * result + _propertyList.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_propertyList); + } + if (_provenance != null + && !org.castor.util.CycleBreaker.startingToCycle(_provenance)) { + result = 37 * result + _provenance.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_provenance); + } + + return result; + } + + /** + * Returns the value of field 'aligned'. + * + * @return the value of field 'Aligned'. + */ + public boolean isAligned() { + return this._aligned; + } + + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() { + try { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) { + return false; + } + return true; + } + + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, out); + } + + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, handler); + } + + /** + * Method removeAlignmentAnnotation. + * + * @param vAlignmentAnnotation + * @return true if the object was removed from the collection. + */ + public boolean removeAlignmentAnnotation( + final uk.ac.vamsas.objects.core.AlignmentAnnotation vAlignmentAnnotation) { + boolean removed = _alignmentAnnotationList.remove(vAlignmentAnnotation); + return removed; + } + + /** + * Method removeAlignmentAnnotationAt. + * + * @param index + * @return the element removed from the collection + */ + public uk.ac.vamsas.objects.core.AlignmentAnnotation removeAlignmentAnnotationAt( + final int index) { + java.lang.Object obj = this._alignmentAnnotationList.remove(index); + return (uk.ac.vamsas.objects.core.AlignmentAnnotation) obj; + } + + /** + * Method removeAlignmentSequence. + * + * @param vAlignmentSequence + * @return true if the object was removed from the collection. + */ + public boolean removeAlignmentSequence( + final uk.ac.vamsas.objects.core.AlignmentSequence vAlignmentSequence) { + boolean removed = _alignmentSequenceList.remove(vAlignmentSequence); + return removed; + } + + /** + * Method removeAlignmentSequenceAt. + * + * @param index + * @return the element removed from the collection + */ + public uk.ac.vamsas.objects.core.AlignmentSequence removeAlignmentSequenceAt( + final int index) { + java.lang.Object obj = this._alignmentSequenceList.remove(index); + return (uk.ac.vamsas.objects.core.AlignmentSequence) obj; + } + + /** + */ + public void removeAllAlignmentAnnotation() { + this._alignmentAnnotationList.clear(); + } + + /** + */ + public void removeAllAlignmentSequence() { + this._alignmentSequenceList.clear(); + } + + /** + */ + public void removeAllProperty() { + this._propertyList.clear(); + } + + /** + */ + public void removeAllTree() { + this._treeList.clear(); + } + + /** + * Method removeProperty. + * + * @param vProperty + * @return true if the object was removed from the collection. + */ + public boolean removeProperty( + final uk.ac.vamsas.objects.core.Property vProperty) { + boolean removed = _propertyList.remove(vProperty); + return removed; + } + + /** + * Method removePropertyAt. + * + * @param index + * @return the element removed from the collection + */ + public uk.ac.vamsas.objects.core.Property removePropertyAt(final int index) { + java.lang.Object obj = this._propertyList.remove(index); + return (uk.ac.vamsas.objects.core.Property) obj; + } + + /** + * Method removeTree. + * + * @param vTree + * @return true if the object was removed from the collection. + */ + public boolean removeTree(final uk.ac.vamsas.objects.core.Tree vTree) { + boolean removed = _treeList.remove(vTree); + return removed; + } + + /** + * Method removeTreeAt. + * + * @param index + * @return the element removed from the collection + */ + public uk.ac.vamsas.objects.core.Tree removeTreeAt(final int index) { + java.lang.Object obj = this._treeList.remove(index); + return (uk.ac.vamsas.objects.core.Tree) obj; + } + + /** + * Sets the value of field 'aligned'. + * + * @param aligned + * the value of field 'aligned'. + */ + public void setAligned(final boolean aligned) { + this._aligned = aligned; + this._has_aligned = true; + } + + /** + * + * + * @param index + * @param vAlignmentAnnotation + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setAlignmentAnnotation(final int index, + final uk.ac.vamsas.objects.core.AlignmentAnnotation vAlignmentAnnotation) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._alignmentAnnotationList.size()) { + throw new IndexOutOfBoundsException( + "setAlignmentAnnotation: Index value '" + index + + "' not in range [0.." + + (this._alignmentAnnotationList.size() - 1) + "]"); + } + + this._alignmentAnnotationList.set(index, vAlignmentAnnotation); + } + + /** + * + * + * @param vAlignmentAnnotationArray + */ + public void setAlignmentAnnotation( + final uk.ac.vamsas.objects.core.AlignmentAnnotation[] vAlignmentAnnotationArray) { + // -- copy array + _alignmentAnnotationList.clear(); + + for (int i = 0; i < vAlignmentAnnotationArray.length; i++) { + this._alignmentAnnotationList.add(vAlignmentAnnotationArray[i]); + } + } + + /** + * Sets the value of '_alignmentAnnotationList' by copying the given Vector. + * All elements will be checked for type safety. + * + * @param vAlignmentAnnotationList + * the Vector to copy. + */ + public void setAlignmentAnnotation( + final java.util.Vector vAlignmentAnnotationList) { + // copy vector + this._alignmentAnnotationList.clear(); + + this._alignmentAnnotationList.addAll(vAlignmentAnnotationList); + } + + /** + * Sets the value of '_alignmentAnnotationList' by setting it to the given + * Vector. No type checking is performed. + * + * @deprecated + * + * @param alignmentAnnotationVector + * the Vector to set. + */ + public void setAlignmentAnnotationAsReference( + final java.util.Vector alignmentAnnotationVector) { + this._alignmentAnnotationList = alignmentAnnotationVector; + } + + /** + * + * + * @param index + * @param vAlignmentSequence + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setAlignmentSequence(final int index, + final uk.ac.vamsas.objects.core.AlignmentSequence vAlignmentSequence) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._alignmentSequenceList.size()) { + throw new IndexOutOfBoundsException("setAlignmentSequence: Index value '" + + index + "' not in range [0.." + + (this._alignmentSequenceList.size() - 1) + "]"); + } + + this._alignmentSequenceList.set(index, vAlignmentSequence); + } + + /** + * + * + * @param vAlignmentSequenceArray + */ + public void setAlignmentSequence( + final uk.ac.vamsas.objects.core.AlignmentSequence[] vAlignmentSequenceArray) { + // -- copy array + _alignmentSequenceList.clear(); + + for (int i = 0; i < vAlignmentSequenceArray.length; i++) { + this._alignmentSequenceList.add(vAlignmentSequenceArray[i]); + } + } + + /** + * Sets the value of '_alignmentSequenceList' by copying the given Vector. All + * elements will be checked for type safety. + * + * @param vAlignmentSequenceList + * the Vector to copy. + */ + public void setAlignmentSequence(final java.util.Vector vAlignmentSequenceList) { + // copy vector + this._alignmentSequenceList.clear(); + + this._alignmentSequenceList.addAll(vAlignmentSequenceList); + } + + /** + * Sets the value of '_alignmentSequenceList' by setting it to the given + * Vector. No type checking is performed. + * + * @deprecated + * + * @param alignmentSequenceVector + * the Vector to set. + */ + public void setAlignmentSequenceAsReference( + final java.util.Vector alignmentSequenceVector) { + this._alignmentSequenceList = alignmentSequenceVector; + } + + /** + * Sets the value of field 'gapChar'. + * + * @param gapChar + * the value of field 'gapChar'. + */ + public void setGapChar(final java.lang.String gapChar) { + this._gapChar = gapChar; + } + + /** + * 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(final java.lang.String id) { + this._id = id; + } + + /** + * Sets the value of field 'modifiable'. + * + * @param modifiable + * the value of field 'modifiable'. + */ + public void setModifiable(final java.lang.String modifiable) { + this._modifiable = modifiable; + } + + /** + * + * + * @param index + * @param vProperty + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setProperty(final int index, + final uk.ac.vamsas.objects.core.Property vProperty) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._propertyList.size()) { + throw new IndexOutOfBoundsException("setProperty: Index value '" + index + + "' not in range [0.." + (this._propertyList.size() - 1) + "]"); + } + + this._propertyList.set(index, vProperty); + } + + /** + * + * + * @param vPropertyArray + */ + public void setProperty( + final uk.ac.vamsas.objects.core.Property[] vPropertyArray) { + // -- copy array + _propertyList.clear(); + + for (int i = 0; i < vPropertyArray.length; i++) { + this._propertyList.add(vPropertyArray[i]); + } + } + + /** + * Sets the value of '_propertyList' by copying the given Vector. All elements + * will be checked for type safety. + * + * @param vPropertyList + * the Vector to copy. + */ + public void setProperty(final java.util.Vector vPropertyList) { + // copy vector + this._propertyList.clear(); + + this._propertyList.addAll(vPropertyList); + } + + /** + * Sets the value of '_propertyList' by setting it to the given Vector. No + * type checking is performed. + * + * @deprecated + * + * @param propertyVector + * the Vector to set. + */ + public void setPropertyAsReference(final java.util.Vector propertyVector) { + this._propertyList = propertyVector; + } + + /** + * Sets the value of field 'provenance'. + * + * @param provenance + * the value of field 'provenance'. + */ + public void setProvenance( + final uk.ac.vamsas.objects.core.Provenance provenance) { + this._provenance = provenance; + } + + /** + * + * + * @param index + * @param vTree + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setTree(final int index, + final uk.ac.vamsas.objects.core.Tree vTree) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._treeList.size()) { + throw new IndexOutOfBoundsException("setTree: Index value '" + index + + "' not in range [0.." + (this._treeList.size() - 1) + "]"); + } + + this._treeList.set(index, vTree); + } + + /** + * + * + * @param vTreeArray + */ + public void setTree(final uk.ac.vamsas.objects.core.Tree[] vTreeArray) { + // -- copy array + _treeList.clear(); + + for (int i = 0; i < vTreeArray.length; i++) { + this._treeList.add(vTreeArray[i]); + } + } + + /** + * Sets the value of '_treeList' by copying the given Vector. All elements + * will be checked for type safety. + * + * @param vTreeList + * the Vector to copy. + */ + public void setTree(final java.util.Vector vTreeList) { + // copy vector + this._treeList.clear(); + + this._treeList.addAll(vTreeList); + } + + /** + * Sets the value of '_treeList' by setting it to the given Vector. No type + * checking is performed. + * + * @deprecated + * + * @param treeVector + * the Vector to set. + */ + public void setTreeAsReference(final java.util.Vector treeVector) { + this._treeList = treeVector; + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @return the unmarshaled uk.ac.vamsas.objects.core.Alignment + */ + public static uk.ac.vamsas.objects.core.Alignment unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + return (uk.ac.vamsas.objects.core.Alignment) Unmarshaller.unmarshal( + uk.ac.vamsas.objects.core.Alignment.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/uk/ac/vamsas/objects/core/AlignmentAnnotation.java b/src/uk/ac/vamsas/objects/core/AlignmentAnnotation.java index b6c544c..4e5c695 100644 --- a/src/uk/ac/vamsas/objects/core/AlignmentAnnotation.java +++ b/src/uk/ac/vamsas/objects/core/AlignmentAnnotation.java @@ -1,515 +1,516 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import org.exolab.castor.xml.Marshaller; import org.exolab.castor.xml.Unmarshaller; /** - * This is annotation over the coordinate frame - * defined by all the columns in the alignment. - * + * This is annotation over the coordinate frame defined by all the columns in + * the alignment. + * * * @version $Revision$ $Date$ */ -public class AlignmentAnnotation extends uk.ac.vamsas.objects.core.RangeAnnotation -implements java.io.Serializable -{ - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * TODO: decide if this flag is - * redundant - when true it would suggest that - * the annotationElement values together form a - * graph - */ - private boolean _graph; - - /** - * keeps track of state for field: _graph - */ - private boolean _has_graph; - - /** - * annotation is associated with - * a range on a particular group of alignment - * sequences - */ - private java.util.Vector _seqrefs; - - /** - * Field _provenance. - */ - private uk.ac.vamsas.objects.core.Provenance _provenance; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public AlignmentAnnotation() { - super(); - this._seqrefs = new java.util.Vector(); - } - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * - * - * @param vSeqrefs - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addSeqrefs( - final java.lang.Object vSeqrefs) - throws java.lang.IndexOutOfBoundsException { - this._seqrefs.addElement(vSeqrefs); - } - - /** - * - * - * @param index - * @param vSeqrefs - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addSeqrefs( - final int index, - final java.lang.Object vSeqrefs) - throws java.lang.IndexOutOfBoundsException { - this._seqrefs.add(index, vSeqrefs); - } - - /** - */ - public void deleteGraph( - ) { - this._has_graph= false; - } - - /** - * Method enumerateSeqrefs. - * - * @return an Enumeration over all java.lang.Object elements - */ - public java.util.Enumeration enumerateSeqrefs( - ) { - return this._seqrefs.elements(); - } - - /** - * Overrides the java.lang.Object.equals method. - * - * @param obj - * @return true if the objects are equal. - */ - public boolean equals( - final java.lang.Object obj) { - if ( this == obj ) - return true; - - if (super.equals(obj)==false) +public class AlignmentAnnotation extends + uk.ac.vamsas.objects.core.RangeAnnotation implements java.io.Serializable { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * TODO: decide if this flag is redundant - when true it would suggest that + * the annotationElement values together form a graph + */ + private boolean _graph; + + /** + * keeps track of state for field: _graph + */ + private boolean _has_graph; + + /** + * annotation is associated with a range on a particular group of alignment + * sequences + */ + private java.util.Vector _seqrefs; + + /** + * Field _provenance. + */ + private uk.ac.vamsas.objects.core.Provenance _provenance; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public AlignmentAnnotation() { + super(); + this._seqrefs = new java.util.Vector(); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * + * + * @param vSeqrefs + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addSeqrefs(final java.lang.Object vSeqrefs) + throws java.lang.IndexOutOfBoundsException { + this._seqrefs.addElement(vSeqrefs); + } + + /** + * + * + * @param index + * @param vSeqrefs + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addSeqrefs(final int index, final java.lang.Object vSeqrefs) + throws java.lang.IndexOutOfBoundsException { + this._seqrefs.add(index, vSeqrefs); + } + + /** + */ + public void deleteGraph() { + this._has_graph = false; + } + + /** + * Method enumerateSeqrefs. + * + * @return an Enumeration over all java.lang.Object elements + */ + public java.util.Enumeration enumerateSeqrefs() { + return this._seqrefs.elements(); + } + + /** + * Overrides the java.lang.Object.equals method. + * + * @param obj + * @return true if the objects are equal. + */ + public boolean equals(final java.lang.Object obj) { + if (this == obj) + return true; + + if (super.equals(obj) == false) + return false; + + if (obj instanceof AlignmentAnnotation) { + + AlignmentAnnotation temp = (AlignmentAnnotation) obj; + boolean thcycle; + boolean tmcycle; + if (this._graph != temp._graph) + return false; + if (this._has_graph != temp._has_graph) + return false; + if (this._seqrefs != null) { + if (temp._seqrefs == null) + return false; + if (this._seqrefs != temp._seqrefs) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._seqrefs); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._seqrefs); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._seqrefs); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._seqrefs); + } + ; return false; - - if (obj instanceof AlignmentAnnotation) { - - AlignmentAnnotation temp = (AlignmentAnnotation)obj; - boolean thcycle; - boolean tmcycle; - if (this._graph != temp._graph) - return false; - if (this._has_graph != temp._has_graph) - return false; - if (this._seqrefs != null) { - if (temp._seqrefs == null) return false; - if (this._seqrefs != temp._seqrefs) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._seqrefs); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._seqrefs); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._seqrefs); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._seqrefs); }; - return false; - } - if (!thcycle) { - if (!this._seqrefs.equals(temp._seqrefs)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._seqrefs); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._seqrefs); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._seqrefs); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._seqrefs); - } - } - } else if (temp._seqrefs != null) - return false; - if (this._provenance != null) { - if (temp._provenance == null) return false; - if (this._provenance != temp._provenance) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._provenance); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._provenance); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance); }; - return false; - } - if (!thcycle) { - if (!this._provenance.equals(temp._provenance)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance); - } - } - } else if (temp._provenance != null) - return false; - return true; + } + if (!thcycle) { + if (!this._seqrefs.equals(temp._seqrefs)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._seqrefs); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._seqrefs); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._seqrefs); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._seqrefs); + } } + } else if (temp._seqrefs != null) return false; - } - - /** - * Returns the value of field 'graph'. The field 'graph' has - * the following description: TODO: decide if this flag is - * redundant - when true it would suggest that - * the annotationElement values together form a - * graph - * - * @return the value of field 'Graph'. - */ - public boolean getGraph( - ) { - return this._graph; - } - - /** - * Returns the value of field 'provenance'. - * - * @return the value of field 'Provenance'. - */ - public uk.ac.vamsas.objects.core.Provenance getProvenance( - ) { - return this._provenance; - } - - /** - * Method getSeqrefs. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the java.lang.Object at the given index - */ - public java.lang.Object getSeqrefs( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._seqrefs.size()) { - throw new IndexOutOfBoundsException("getSeqrefs: Index value '" + index + "' not in range [0.." + (this._seqrefs.size() - 1) + "]"); - } - - return _seqrefs.get(index); - } - - /** - * Method getSeqrefs.Returns the contents of the collection in - * an Array.

Note: Just in case the collection contents - * are changing in another thread, we pass a 0-length Array of - * the correct type into the API call. This way we know - * that the Array returned is of exactly the correct length. - * - * @return this collection as an Array - */ - public java.lang.Object[] getSeqrefs( - ) { - java.lang.Object[] array = new java.lang.Object[0]; - return (java.lang.Object[]) this._seqrefs.toArray(array); - } - - /** - * Method getSeqrefsAsReference.Returns a reference to - * '_seqrefs'. No type checking is performed on any - * modifications to the Vector. - * - * @return a reference to the Vector backing this class - */ - public java.util.Vector getSeqrefsAsReference( - ) { - return this._seqrefs; - } - - /** - * Method getSeqrefsCount. - * - * @return the size of this collection - */ - public int getSeqrefsCount( - ) { - return this._seqrefs.size(); - } - - /** - * Method hasGraph. - * - * @return true if at least one Graph has been added - */ - public boolean hasGraph( - ) { - return this._has_graph; - } - - /** - * Overrides the java.lang.Object.hashCode method. - *

- * The following steps came from Effective Java Programming - * Language Guide by Joshua Bloch, Chapter 3 - * - * @return a hash code value for the object. - */ - public int hashCode( - ) { - int result = super.hashCode(); - - long tmp; - result = 37 * result + (_graph?0:1); - if (_seqrefs != null - && !org.castor.util.CycleBreaker.startingToCycle(_seqrefs)) { - result = 37 * result + _seqrefs.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_seqrefs); - } - if (_provenance != null - && !org.castor.util.CycleBreaker.startingToCycle(_provenance)) { - result = 37 * result + _provenance.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_provenance); - } - - return result; - } - - /** - * Returns the value of field 'graph'. The field 'graph' has - * the following description: TODO: decide if this flag is - * redundant - when true it would suggest that - * the annotationElement values together form a - * graph - * - * @return the value of field 'Graph'. - */ - public boolean isGraph( - ) { - return this._graph; - } - - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { + if (this._provenance != null) { + if (temp._provenance == null) + return false; + if (this._provenance != temp._provenance) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._provenance); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._provenance); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance); + } + ; return false; + } + if (!thcycle) { + if (!this._provenance.equals(temp._provenance)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance); + } } - return true; - } - - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } - - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } - - /** - */ - public void removeAllSeqrefs( - ) { - this._seqrefs.clear(); - } - - /** - * Method removeSeqrefs. - * - * @param vSeqrefs - * @return true if the object was removed from the collection. - */ - public boolean removeSeqrefs( - final java.lang.Object vSeqrefs) { - boolean removed = _seqrefs.remove(vSeqrefs); - return removed; - } - - /** - * Method removeSeqrefsAt. - * - * @param index - * @return the element removed from the collection - */ - public java.lang.Object removeSeqrefsAt( - final int index) { - java.lang.Object obj = this._seqrefs.remove(index); - return obj; + } else if (temp._provenance != null) + return false; + return true; } - - /** - * Sets the value of field 'graph'. The field 'graph' has the - * following description: TODO: decide if this flag is - * redundant - when true it would suggest that - * the annotationElement values together form a - * graph - * - * @param graph the value of field 'graph'. - */ - public void setGraph( - final boolean graph) { - this._graph = graph; - this._has_graph = true; + return false; + } + + /** + * Returns the value of field 'graph'. The field 'graph' has the following + * description: TODO: decide if this flag is redundant - when true it would + * suggest that the annotationElement values together form a graph + * + * @return the value of field 'Graph'. + */ + public boolean getGraph() { + return this._graph; + } + + /** + * Returns the value of field 'provenance'. + * + * @return the value of field 'Provenance'. + */ + public uk.ac.vamsas.objects.core.Provenance getProvenance() { + return this._provenance; + } + + /** + * Method getSeqrefs. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the java.lang.Object at the given index + */ + public java.lang.Object getSeqrefs(final int index) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._seqrefs.size()) { + throw new IndexOutOfBoundsException("getSeqrefs: Index value '" + index + + "' not in range [0.." + (this._seqrefs.size() - 1) + "]"); } - /** - * Sets the value of field 'provenance'. - * - * @param provenance the value of field 'provenance'. - */ - public void setProvenance( - final uk.ac.vamsas.objects.core.Provenance provenance) { - this._provenance = provenance; + return _seqrefs.get(index); + } + + /** + * Method getSeqrefs.Returns the contents of the collection in an Array. + *

+ * Note: Just in case the collection contents are changing in another thread, + * we pass a 0-length Array of the correct type into the API call. This way we + * know that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public java.lang.Object[] getSeqrefs() { + java.lang.Object[] array = new java.lang.Object[0]; + return (java.lang.Object[]) this._seqrefs.toArray(array); + } + + /** + * Method getSeqrefsAsReference.Returns a reference to '_seqrefs'. No type + * checking is performed on any modifications to the Vector. + * + * @return a reference to the Vector backing this class + */ + public java.util.Vector getSeqrefsAsReference() { + return this._seqrefs; + } + + /** + * Method getSeqrefsCount. + * + * @return the size of this collection + */ + public int getSeqrefsCount() { + return this._seqrefs.size(); + } + + /** + * Method hasGraph. + * + * @return true if at least one Graph has been added + */ + public boolean hasGraph() { + return this._has_graph; + } + + /** + * Overrides the java.lang.Object.hashCode method. + *

+ * The following steps came from Effective Java Programming Language + * Guide by Joshua Bloch, Chapter 3 + * + * @return a hash code value for the object. + */ + public int hashCode() { + int result = super.hashCode(); + + long tmp; + result = 37 * result + (_graph ? 0 : 1); + if (_seqrefs != null + && !org.castor.util.CycleBreaker.startingToCycle(_seqrefs)) { + result = 37 * result + _seqrefs.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_seqrefs); } - - /** - * - * - * @param index - * @param vSeqrefs - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setSeqrefs( - final int index, - final java.lang.Object vSeqrefs) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._seqrefs.size()) { - throw new IndexOutOfBoundsException("setSeqrefs: Index value '" + index + "' not in range [0.." + (this._seqrefs.size() - 1) + "]"); - } - - this._seqrefs.set(index, vSeqrefs); + if (_provenance != null + && !org.castor.util.CycleBreaker.startingToCycle(_provenance)) { + result = 37 * result + _provenance.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_provenance); } - /** - * - * - * @param vSeqrefsArray - */ - public void setSeqrefs( - final java.lang.Object[] vSeqrefsArray) { - //-- copy array - _seqrefs.clear(); - - for (int i = 0; i < vSeqrefsArray.length; i++) { - this._seqrefs.add(vSeqrefsArray[i]); - } + return result; + } + + /** + * Returns the value of field 'graph'. The field 'graph' has the following + * description: TODO: decide if this flag is redundant - when true it would + * suggest that the annotationElement values together form a graph + * + * @return the value of field 'Graph'. + */ + public boolean isGraph() { + return this._graph; + } + + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() { + try { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) { + return false; } - - /** - * Sets the value of '_seqrefs' by copying the given Vector. - * All elements will be checked for type safety. - * - * @param vSeqrefsList the Vector to copy. - */ - public void setSeqrefs( - final java.util.Vector vSeqrefsList) { - // copy vector - this._seqrefs.clear(); - - this._seqrefs.addAll(vSeqrefsList); + return true; + } + + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, out); + } + + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, handler); + } + + /** + */ + public void removeAllSeqrefs() { + this._seqrefs.clear(); + } + + /** + * Method removeSeqrefs. + * + * @param vSeqrefs + * @return true if the object was removed from the collection. + */ + public boolean removeSeqrefs(final java.lang.Object vSeqrefs) { + boolean removed = _seqrefs.remove(vSeqrefs); + return removed; + } + + /** + * Method removeSeqrefsAt. + * + * @param index + * @return the element removed from the collection + */ + public java.lang.Object removeSeqrefsAt(final int index) { + java.lang.Object obj = this._seqrefs.remove(index); + return obj; + } + + /** + * Sets the value of field 'graph'. The field 'graph' has the following + * description: TODO: decide if this flag is redundant - when true it would + * suggest that the annotationElement values together form a graph + * + * @param graph + * the value of field 'graph'. + */ + public void setGraph(final boolean graph) { + this._graph = graph; + this._has_graph = true; + } + + /** + * Sets the value of field 'provenance'. + * + * @param provenance + * the value of field 'provenance'. + */ + public void setProvenance( + final uk.ac.vamsas.objects.core.Provenance provenance) { + this._provenance = provenance; + } + + /** + * + * + * @param index + * @param vSeqrefs + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setSeqrefs(final int index, final java.lang.Object vSeqrefs) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._seqrefs.size()) { + throw new IndexOutOfBoundsException("setSeqrefs: Index value '" + index + + "' not in range [0.." + (this._seqrefs.size() - 1) + "]"); } - /** - * Sets the value of '_seqrefs' by setting it to the given - * Vector. No type checking is performed. - * @deprecated - * - * @param seqrefsVector the Vector to set. - */ - public void setSeqrefsAsReference( - final java.util.Vector seqrefsVector) { - this._seqrefs = seqrefsVector; - } + this._seqrefs.set(index, vSeqrefs); + } - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled uk.ac.vamsas.objects.core.RangeType - */ - public static uk.ac.vamsas.objects.core.RangeType unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (uk.ac.vamsas.objects.core.RangeType) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.AlignmentAnnotation.class, reader); - } + /** + * + * + * @param vSeqrefsArray + */ + public void setSeqrefs(final java.lang.Object[] vSeqrefsArray) { + // -- copy array + _seqrefs.clear(); - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); + for (int i = 0; i < vSeqrefsArray.length; i++) { + this._seqrefs.add(vSeqrefsArray[i]); } + } + + /** + * Sets the value of '_seqrefs' by copying the given Vector. All elements will + * be checked for type safety. + * + * @param vSeqrefsList + * the Vector to copy. + */ + public void setSeqrefs(final java.util.Vector vSeqrefsList) { + // copy vector + this._seqrefs.clear(); + + this._seqrefs.addAll(vSeqrefsList); + } + + /** + * Sets the value of '_seqrefs' by setting it to the given Vector. No type + * checking is performed. + * + * @deprecated + * + * @param seqrefsVector + * the Vector to set. + */ + public void setSeqrefsAsReference(final java.util.Vector seqrefsVector) { + this._seqrefs = seqrefsVector; + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @return the unmarshaled uk.ac.vamsas.objects.core.RangeType + */ + public static uk.ac.vamsas.objects.core.RangeType unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + return (uk.ac.vamsas.objects.core.RangeType) Unmarshaller.unmarshal( + uk.ac.vamsas.objects.core.AlignmentAnnotation.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/uk/ac/vamsas/objects/core/AlignmentSequence.java b/src/uk/ac/vamsas/objects/core/AlignmentSequence.java index 8192795..58c866f 100644 --- a/src/uk/ac/vamsas/objects/core/AlignmentSequence.java +++ b/src/uk/ac/vamsas/objects/core/AlignmentSequence.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import org.exolab.castor.xml.Marshaller; @@ -17,488 +31,518 @@ import org.exolab.castor.xml.Unmarshaller; /** * Class AlignmentSequence. * - * @version $Revision$ $Date$ + * @version $Revision$ $Date: 2007-06-28 14:51:44 +0100 (Thu, 28 Jun 2007) + * $ */ -public class AlignmentSequence extends uk.ac.vamsas.objects.core.SequenceType -implements java.io.Serializable -{ - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Primary Key for vamsas object - * referencing - */ - private java.lang.String _id; - - /** - * Dataset Sequence from which - * this alignment sequence is taken from - * - */ - private java.lang.Object _refid; - - /** - * Field _alignmentSequenceAnnotationList. - */ - private java.util.Vector _alignmentSequenceAnnotationList; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public AlignmentSequence() { - super(); - this._alignmentSequenceAnnotationList = new java.util.Vector(); - } - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * - * - * @param vAlignmentSequenceAnnotation - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addAlignmentSequenceAnnotation( - final uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation vAlignmentSequenceAnnotation) - throws java.lang.IndexOutOfBoundsException { - this._alignmentSequenceAnnotationList.addElement(vAlignmentSequenceAnnotation); - } - - /** - * - * - * @param index - * @param vAlignmentSequenceAnnotation - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addAlignmentSequenceAnnotation( - final int index, - final uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation vAlignmentSequenceAnnotation) - throws java.lang.IndexOutOfBoundsException { - this._alignmentSequenceAnnotationList.add(index, vAlignmentSequenceAnnotation); - } - - /** - * Method enumerateAlignmentSequenceAnnotation. - * - * @return an Enumeration over all - * uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation element - */ - public java.util.Enumeration enumerateAlignmentSequenceAnnotation( - ) { - return this._alignmentSequenceAnnotationList.elements(); - } - - /** - * Overrides the java.lang.Object.equals method. - * - * @param obj - * @return true if the objects are equal. - */ - public boolean equals( - final java.lang.Object obj) { - if ( this == obj ) - return true; - - if (super.equals(obj)==false) +public class AlignmentSequence extends uk.ac.vamsas.objects.core.SequenceType + implements java.io.Serializable { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Primary Key for vamsas object referencing + */ + private java.lang.String _id; + + /** + * Dataset Sequence from which this alignment sequence is taken from + * + */ + private java.lang.Object _refid; + + /** + * Field _alignmentSequenceAnnotationList. + */ + private java.util.Vector _alignmentSequenceAnnotationList; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public AlignmentSequence() { + super(); + this._alignmentSequenceAnnotationList = new java.util.Vector(); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * + * + * @param vAlignmentSequenceAnnotation + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addAlignmentSequenceAnnotation( + final uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation vAlignmentSequenceAnnotation) + throws java.lang.IndexOutOfBoundsException { + this._alignmentSequenceAnnotationList + .addElement(vAlignmentSequenceAnnotation); + } + + /** + * + * + * @param index + * @param vAlignmentSequenceAnnotation + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addAlignmentSequenceAnnotation( + final int index, + final uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation vAlignmentSequenceAnnotation) + throws java.lang.IndexOutOfBoundsException { + this._alignmentSequenceAnnotationList.add(index, + vAlignmentSequenceAnnotation); + } + + /** + * Method enumerateAlignmentSequenceAnnotation. + * + * @return an Enumeration over all + * uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation element + */ + public java.util.Enumeration enumerateAlignmentSequenceAnnotation() { + return this._alignmentSequenceAnnotationList.elements(); + } + + /** + * Overrides the java.lang.Object.equals method. + * + * @param obj + * @return true if the objects are equal. + */ + public boolean equals(final java.lang.Object obj) { + if (this == obj) + return true; + + if (super.equals(obj) == false) + return false; + + if (obj instanceof AlignmentSequence) { + + AlignmentSequence temp = (AlignmentSequence) obj; + boolean thcycle; + boolean tmcycle; + if (this._id != null) { + if (temp._id == null) + return false; + if (this._id != temp._id) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._id); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._id); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._id); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); + } + ; return false; - - if (obj instanceof AlignmentSequence) { - - AlignmentSequence temp = (AlignmentSequence)obj; - boolean thcycle; - boolean tmcycle; - if (this._id != null) { - if (temp._id == null) return false; - if (this._id != temp._id) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._id); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._id); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._id); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); }; - return false; - } - if (!thcycle) { - if (!this._id.equals(temp._id)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._id); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._id); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); - } - } - } else if (temp._id != null) - return false; - if (this._refid != null) { - if (temp._refid == null) return false; - if (this._refid != temp._refid) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._refid); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._refid); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._refid); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._refid); }; - return false; - } - if (!thcycle) { - if (!this._refid.equals(temp._refid)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._refid); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._refid); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._refid); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._refid); - } - } - } else if (temp._refid != null) - return false; - if (this._alignmentSequenceAnnotationList != null) { - if (temp._alignmentSequenceAnnotationList == null) return false; - if (this._alignmentSequenceAnnotationList != temp._alignmentSequenceAnnotationList) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._alignmentSequenceAnnotationList); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._alignmentSequenceAnnotationList); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._alignmentSequenceAnnotationList); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._alignmentSequenceAnnotationList); }; - return false; - } - if (!thcycle) { - if (!this._alignmentSequenceAnnotationList.equals(temp._alignmentSequenceAnnotationList)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._alignmentSequenceAnnotationList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._alignmentSequenceAnnotationList); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._alignmentSequenceAnnotationList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._alignmentSequenceAnnotationList); - } - } - } else if (temp._alignmentSequenceAnnotationList != null) - return false; - return true; + } + if (!thcycle) { + if (!this._id.equals(temp._id)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._id); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._id); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); + } } + } else if (temp._id != null) return false; - } - - /** - * Method getAlignmentSequenceAnnotation. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the - * uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation at the - * given index - */ - public uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation getAlignmentSequenceAnnotation( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._alignmentSequenceAnnotationList.size()) { - throw new IndexOutOfBoundsException("getAlignmentSequenceAnnotation: Index value '" + index + "' not in range [0.." + (this._alignmentSequenceAnnotationList.size() - 1) + "]"); - } - - return (uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation) _alignmentSequenceAnnotationList.get(index); - } - - /** - * Method getAlignmentSequenceAnnotation.Returns the contents - * of the collection in an Array.

Note: Just in case the - * collection contents are changing in another thread, we pass - * a 0-length Array of the correct type into the API call. - * This way we know that the Array returned is of - * exactly the correct length. - * - * @return this collection as an Array - */ - public uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation[] getAlignmentSequenceAnnotation( - ) { - uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation[] array = new uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation[0]; - return (uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation[]) this._alignmentSequenceAnnotationList.toArray(array); - } - - /** - * Method getAlignmentSequenceAnnotationAsReference.Returns a - * reference to '_alignmentSequenceAnnotationList'. No type - * checking is performed on any modifications to the Vector. - * - * @return a reference to the Vector backing this class - */ - public java.util.Vector getAlignmentSequenceAnnotationAsReference( - ) { - return this._alignmentSequenceAnnotationList; - } - - /** - * Method getAlignmentSequenceAnnotationCount. - * - * @return the size of this collection - */ - public int getAlignmentSequenceAnnotationCount( - ) { - return this._alignmentSequenceAnnotationList.size(); - } - - /** - * Returns the value of field 'id'. The field 'id' has the - * following description: Primary Key for vamsas object - * referencing - * - * @return the value of field 'Id'. - */ - public java.lang.String getId( - ) { - return this._id; - } - - /** - * Returns the value of field 'refid'. The field 'refid' has - * the following description: Dataset Sequence from which - * this alignment sequence is taken from - * - * - * @return the value of field 'Refid'. - */ - public java.lang.Object getRefid( - ) { - return this._refid; - } - - /** - * Overrides the java.lang.Object.hashCode method. - *

- * The following steps came from Effective Java Programming - * Language Guide by Joshua Bloch, Chapter 3 - * - * @return a hash code value for the object. - */ - public int hashCode( - ) { - int result = super.hashCode(); - - long tmp; - if (_id != null - && !org.castor.util.CycleBreaker.startingToCycle(_id)) { - result = 37 * result + _id.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_id); - } - if (_refid != null - && !org.castor.util.CycleBreaker.startingToCycle(_refid)) { - result = 37 * result + _refid.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_refid); - } - if (_alignmentSequenceAnnotationList != null - && !org.castor.util.CycleBreaker.startingToCycle(_alignmentSequenceAnnotationList)) { - result = 37 * result + _alignmentSequenceAnnotationList.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_alignmentSequenceAnnotationList); - } - - return result; - } - - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { + if (this._refid != null) { + if (temp._refid == null) + return false; + if (this._refid != temp._refid) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._refid); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._refid); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._refid); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._refid); + } + ; return false; + } + if (!thcycle) { + if (!this._refid.equals(temp._refid)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._refid); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._refid); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._refid); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._refid); + } } - return true; - } - - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } - - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } - - /** - * Method removeAlignmentSequenceAnnotation. - * - * @param vAlignmentSequenceAnnotation - * @return true if the object was removed from the collection. - */ - public boolean removeAlignmentSequenceAnnotation( - final uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation vAlignmentSequenceAnnotation) { - boolean removed = _alignmentSequenceAnnotationList.remove(vAlignmentSequenceAnnotation); - return removed; - } - - /** - * Method removeAlignmentSequenceAnnotationAt. - * - * @param index - * @return the element removed from the collection - */ - public uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation removeAlignmentSequenceAnnotationAt( - final int index) { - java.lang.Object obj = this._alignmentSequenceAnnotationList.remove(index); - return (uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation) obj; - } - - /** - */ - public void removeAllAlignmentSequenceAnnotation( - ) { - this._alignmentSequenceAnnotationList.clear(); - } - - /** - * - * - * @param index - * @param vAlignmentSequenceAnnotation - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setAlignmentSequenceAnnotation( - final int index, - final uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation vAlignmentSequenceAnnotation) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._alignmentSequenceAnnotationList.size()) { - throw new IndexOutOfBoundsException("setAlignmentSequenceAnnotation: Index value '" + index + "' not in range [0.." + (this._alignmentSequenceAnnotationList.size() - 1) + "]"); + } else if (temp._refid != null) + return false; + if (this._alignmentSequenceAnnotationList != null) { + if (temp._alignmentSequenceAnnotationList == null) + return false; + if (this._alignmentSequenceAnnotationList != temp._alignmentSequenceAnnotationList) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._alignmentSequenceAnnotationList); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._alignmentSequenceAnnotationList); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker + .releaseCycleHandle(this._alignmentSequenceAnnotationList); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._alignmentSequenceAnnotationList); + } + ; + return false; + } + if (!thcycle) { + if (!this._alignmentSequenceAnnotationList + .equals(temp._alignmentSequenceAnnotationList)) { + org.castor.util.CycleBreaker + .releaseCycleHandle(this._alignmentSequenceAnnotationList); + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._alignmentSequenceAnnotationList); + return false; + } + org.castor.util.CycleBreaker + .releaseCycleHandle(this._alignmentSequenceAnnotationList); + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._alignmentSequenceAnnotationList); + } } - - this._alignmentSequenceAnnotationList.set(index, vAlignmentSequenceAnnotation); + } else if (temp._alignmentSequenceAnnotationList != null) + return false; + return true; } - - /** - * - * - * @param vAlignmentSequenceAnnotationArray - */ - public void setAlignmentSequenceAnnotation( - final uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation[] vAlignmentSequenceAnnotationArray) { - //-- copy array - _alignmentSequenceAnnotationList.clear(); - - for (int i = 0; i < vAlignmentSequenceAnnotationArray.length; i++) { - this._alignmentSequenceAnnotationList.add(vAlignmentSequenceAnnotationArray[i]); - } + return false; + } + + /** + * Method getAlignmentSequenceAnnotation. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the + * uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation at the given + * index + */ + public uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation getAlignmentSequenceAnnotation( + final int index) throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._alignmentSequenceAnnotationList.size()) { + throw new IndexOutOfBoundsException( + "getAlignmentSequenceAnnotation: Index value '" + index + + "' not in range [0.." + + (this._alignmentSequenceAnnotationList.size() - 1) + "]"); } - /** - * Sets the value of '_alignmentSequenceAnnotationList' by - * copying the given Vector. All elements will be checked for - * type safety. - * - * @param vAlignmentSequenceAnnotationList the Vector to copy. - */ - public void setAlignmentSequenceAnnotation( - final java.util.Vector vAlignmentSequenceAnnotationList) { - // copy vector - this._alignmentSequenceAnnotationList.clear(); - - this._alignmentSequenceAnnotationList.addAll(vAlignmentSequenceAnnotationList); + return (uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation) _alignmentSequenceAnnotationList + .get(index); + } + + /** + * Method getAlignmentSequenceAnnotation.Returns the contents of the + * collection in an Array. + *

+ * Note: Just in case the collection contents are changing in another thread, + * we pass a 0-length Array of the correct type into the API call. This way we + * know that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation[] getAlignmentSequenceAnnotation() { + uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation[] array = new uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation[0]; + return (uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation[]) this._alignmentSequenceAnnotationList + .toArray(array); + } + + /** + * Method getAlignmentSequenceAnnotationAsReference.Returns a reference to + * '_alignmentSequenceAnnotationList'. No type checking is performed on any + * modifications to the Vector. + * + * @return a reference to the Vector backing this class + */ + public java.util.Vector getAlignmentSequenceAnnotationAsReference() { + return this._alignmentSequenceAnnotationList; + } + + /** + * Method getAlignmentSequenceAnnotationCount. + * + * @return the size of this collection + */ + public int getAlignmentSequenceAnnotationCount() { + return this._alignmentSequenceAnnotationList.size(); + } + + /** + * Returns the value of field 'id'. The field 'id' has the following + * description: Primary Key for vamsas object referencing + * + * @return the value of field 'Id'. + */ + public java.lang.String getId() { + return this._id; + } + + /** + * Returns the value of field 'refid'. The field 'refid' has the following + * description: Dataset Sequence from which this alignment sequence is taken + * from + * + * + * @return the value of field 'Refid'. + */ + public java.lang.Object getRefid() { + return this._refid; + } + + /** + * Overrides the java.lang.Object.hashCode method. + *

+ * The following steps came from Effective Java Programming Language + * Guide by Joshua Bloch, Chapter 3 + * + * @return a hash code value for the object. + */ + public int hashCode() { + int result = super.hashCode(); + + long tmp; + if (_id != null && !org.castor.util.CycleBreaker.startingToCycle(_id)) { + result = 37 * result + _id.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_id); } - - /** - * Sets the value of '_alignmentSequenceAnnotationList' by - * setting it to the given Vector. No type checking is - * performed. - * @deprecated - * - * @param alignmentSequenceAnnotationVector the Vector to set. - */ - public void setAlignmentSequenceAnnotationAsReference( - final java.util.Vector alignmentSequenceAnnotationVector) { - this._alignmentSequenceAnnotationList = alignmentSequenceAnnotationVector; + if (_refid != null && !org.castor.util.CycleBreaker.startingToCycle(_refid)) { + result = 37 * result + _refid.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_refid); } - - /** - * 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( - final java.lang.String id) { - this._id = id; + if (_alignmentSequenceAnnotationList != null + && !org.castor.util.CycleBreaker + .startingToCycle(_alignmentSequenceAnnotationList)) { + result = 37 * result + _alignmentSequenceAnnotationList.hashCode(); + org.castor.util.CycleBreaker + .releaseCycleHandle(_alignmentSequenceAnnotationList); } - /** - * Sets the value of field 'refid'. The field 'refid' has the - * following description: Dataset Sequence from which - * this alignment sequence is taken from - * - * - * @param refid the value of field 'refid'. - */ - public void setRefid( - final java.lang.Object refid) { - this._refid = refid; + return result; + } + + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() { + try { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) { + return false; } - - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled uk.ac.vamsas.objects.core.SequenceTyp + return true; + } + + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, out); + } + + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, handler); + } + + /** + * Method removeAlignmentSequenceAnnotation. + * + * @param vAlignmentSequenceAnnotation + * @return true if the object was removed from the collection. + */ + public boolean removeAlignmentSequenceAnnotation( + final uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation vAlignmentSequenceAnnotation) { + boolean removed = _alignmentSequenceAnnotationList + .remove(vAlignmentSequenceAnnotation); + return removed; + } + + /** + * Method removeAlignmentSequenceAnnotationAt. + * + * @param index + * @return the element removed from the collection + */ + public uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation removeAlignmentSequenceAnnotationAt( + final int index) { + java.lang.Object obj = this._alignmentSequenceAnnotationList.remove(index); + return (uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation) obj; + } + + /** */ - public static uk.ac.vamsas.objects.core.SequenceType unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (uk.ac.vamsas.objects.core.SequenceType) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.AlignmentSequence.class, reader); + public void removeAllAlignmentSequenceAnnotation() { + this._alignmentSequenceAnnotationList.clear(); + } + + /** + * + * + * @param index + * @param vAlignmentSequenceAnnotation + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setAlignmentSequenceAnnotation( + final int index, + final uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation vAlignmentSequenceAnnotation) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._alignmentSequenceAnnotationList.size()) { + throw new IndexOutOfBoundsException( + "setAlignmentSequenceAnnotation: Index value '" + index + + "' not in range [0.." + + (this._alignmentSequenceAnnotationList.size() - 1) + "]"); } - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); + this._alignmentSequenceAnnotationList.set(index, + vAlignmentSequenceAnnotation); + } + + /** + * + * + * @param vAlignmentSequenceAnnotationArray + */ + public void setAlignmentSequenceAnnotation( + final uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation[] vAlignmentSequenceAnnotationArray) { + // -- copy array + _alignmentSequenceAnnotationList.clear(); + + for (int i = 0; i < vAlignmentSequenceAnnotationArray.length; i++) { + this._alignmentSequenceAnnotationList + .add(vAlignmentSequenceAnnotationArray[i]); } + } + + /** + * Sets the value of '_alignmentSequenceAnnotationList' by copying the given + * Vector. All elements will be checked for type safety. + * + * @param vAlignmentSequenceAnnotationList + * the Vector to copy. + */ + public void setAlignmentSequenceAnnotation( + final java.util.Vector vAlignmentSequenceAnnotationList) { + // copy vector + this._alignmentSequenceAnnotationList.clear(); + + this._alignmentSequenceAnnotationList + .addAll(vAlignmentSequenceAnnotationList); + } + + /** + * Sets the value of '_alignmentSequenceAnnotationList' by setting it to the + * given Vector. No type checking is performed. + * + * @deprecated + * + * @param alignmentSequenceAnnotationVector + * the Vector to set. + */ + public void setAlignmentSequenceAnnotationAsReference( + final java.util.Vector alignmentSequenceAnnotationVector) { + this._alignmentSequenceAnnotationList = alignmentSequenceAnnotationVector; + } + + /** + * 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(final java.lang.String id) { + this._id = id; + } + + /** + * Sets the value of field 'refid'. The field 'refid' has the following + * description: Dataset Sequence from which this alignment sequence is taken + * from + * + * + * @param refid + * the value of field 'refid'. + */ + public void setRefid(final java.lang.Object refid) { + this._refid = refid; + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @return the unmarshaled uk.ac.vamsas.objects.core.SequenceTyp + */ + public static uk.ac.vamsas.objects.core.SequenceType unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + return (uk.ac.vamsas.objects.core.SequenceType) Unmarshaller.unmarshal( + uk.ac.vamsas.objects.core.AlignmentSequence.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/uk/ac/vamsas/objects/core/AlignmentSequenceAnnotation.java b/src/uk/ac/vamsas/objects/core/AlignmentSequenceAnnotation.java index 7494819..ae36079 100644 --- a/src/uk/ac/vamsas/objects/core/AlignmentSequenceAnnotation.java +++ b/src/uk/ac/vamsas/objects/core/AlignmentSequenceAnnotation.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import org.exolab.castor.xml.Marshaller; @@ -19,286 +33,271 @@ import org.exolab.castor.xml.Unmarshaller; * * @version $Revision$ $Date$ */ -public class AlignmentSequenceAnnotation extends uk.ac.vamsas.objects.core.RangeAnnotation -implements java.io.Serializable -{ +public class AlignmentSequenceAnnotation extends + uk.ac.vamsas.objects.core.RangeAnnotation implements java.io.Serializable { + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ + /** + * TODO: decide if this flag is redundant - when true it would suggest that + * the annotationElement values together form a graph + * + */ + private boolean _graph; - /** - * TODO: - * decide if this flag is - * redundant - when true it - * would suggest that the - * annotationElement values - * together form a graph - * - */ - private boolean _graph; + /** + * keeps track of state for field: _graph + */ + private boolean _has_graph; - /** - * keeps track of state for field: _graph - */ - private boolean _has_graph; + /** + * Field _provenance. + */ + private uk.ac.vamsas.objects.core.Provenance _provenance; - /** - * Field _provenance. - */ - private uk.ac.vamsas.objects.core.Provenance _provenance; + // ----------------/ + // - Constructors -/ + // ----------------/ + public AlignmentSequenceAnnotation() { + super(); + } - //----------------/ - //- Constructors -/ - //----------------/ + // -----------/ + // - Methods -/ + // -----------/ - public AlignmentSequenceAnnotation() { - super(); - } + /** + */ + public void deleteGraph() { + this._has_graph = false; + } + /** + * Overrides the java.lang.Object.equals method. + * + * @param obj + * @return true if the objects are equal. + */ + public boolean equals(final java.lang.Object obj) { + if (this == obj) + return true; - //-----------/ - //- Methods -/ - //-----------/ + if (super.equals(obj) == false) + return false; - /** - */ - public void deleteGraph( - ) { - this._has_graph= false; - } + if (obj instanceof AlignmentSequenceAnnotation) { - /** - * Overrides the java.lang.Object.equals method. - * - * @param obj - * @return true if the objects are equal. - */ - public boolean equals( - final java.lang.Object obj) { - if ( this == obj ) - return true; - - if (super.equals(obj)==false) + AlignmentSequenceAnnotation temp = (AlignmentSequenceAnnotation) obj; + boolean thcycle; + boolean tmcycle; + if (this._graph != temp._graph) + return false; + if (this._has_graph != temp._has_graph) + return false; + if (this._provenance != null) { + if (temp._provenance == null) + return false; + if (this._provenance != temp._provenance) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._provenance); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._provenance); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance); + } + ; return false; - - if (obj instanceof AlignmentSequenceAnnotation) { - - AlignmentSequenceAnnotation temp = (AlignmentSequenceAnnotation)obj; - boolean thcycle; - boolean tmcycle; - if (this._graph != temp._graph) - return false; - if (this._has_graph != temp._has_graph) - return false; - if (this._provenance != null) { - if (temp._provenance == null) return false; - if (this._provenance != temp._provenance) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._provenance); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._provenance); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance); }; - return false; - } - if (!thcycle) { - if (!this._provenance.equals(temp._provenance)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance); - } - } - } else if (temp._provenance != null) - return false; - return true; + } + if (!thcycle) { + if (!this._provenance.equals(temp._provenance)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance); + } } + } else if (temp._provenance != null) return false; + return true; } + return false; + } - /** - * Returns the value of field 'graph'. The field 'graph' has - * the following description: TODO: - * decide if this flag is - * redundant - when true it - * would suggest that the - * annotationElement values - * together form a graph - * - * - * @return the value of field 'Graph'. - */ - public boolean getGraph( - ) { - return this._graph; - } + /** + * Returns the value of field 'graph'. The field 'graph' has the following + * description: TODO: decide if this flag is redundant - when true it would + * suggest that the annotationElement values together form a graph + * + * + * @return the value of field 'Graph'. + */ + public boolean getGraph() { + return this._graph; + } - /** - * Returns the value of field 'provenance'. - * - * @return the value of field 'Provenance'. - */ - public uk.ac.vamsas.objects.core.Provenance getProvenance( - ) { - return this._provenance; - } + /** + * Returns the value of field 'provenance'. + * + * @return the value of field 'Provenance'. + */ + public uk.ac.vamsas.objects.core.Provenance getProvenance() { + return this._provenance; + } - /** - * Method hasGraph. - * - * @return true if at least one Graph has been added - */ - public boolean hasGraph( - ) { - return this._has_graph; - } + /** + * Method hasGraph. + * + * @return true if at least one Graph has been added + */ + public boolean hasGraph() { + return this._has_graph; + } - /** - * Overrides the java.lang.Object.hashCode method. - *

- * The following steps came from Effective Java Programming - * Language Guide by Joshua Bloch, Chapter 3 - * - * @return a hash code value for the object. - */ - public int hashCode( - ) { - int result = super.hashCode(); - - long tmp; - result = 37 * result + (_graph?0:1); - if (_provenance != null - && !org.castor.util.CycleBreaker.startingToCycle(_provenance)) { - result = 37 * result + _provenance.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_provenance); - } - - return result; - } + /** + * Overrides the java.lang.Object.hashCode method. + *

+ * The following steps came from Effective Java Programming Language + * Guide by Joshua Bloch, Chapter 3 + * + * @return a hash code value for the object. + */ + public int hashCode() { + int result = super.hashCode(); - /** - * Returns the value of field 'graph'. The field 'graph' has - * the following description: TODO: - * decide if this flag is - * redundant - when true it - * would suggest that the - * annotationElement values - * together form a graph - * - * - * @return the value of field 'Graph'. - */ - public boolean isGraph( - ) { - return this._graph; + long tmp; + result = 37 * result + (_graph ? 0 : 1); + if (_provenance != null + && !org.castor.util.CycleBreaker.startingToCycle(_provenance)) { + result = 37 * result + _provenance.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_provenance); } - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { - return false; - } - return true; - } + return result; + } - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } + /** + * Returns the value of field 'graph'. The field 'graph' has the following + * description: TODO: decide if this flag is redundant - when true it would + * suggest that the annotationElement values together form a graph + * + * + * @return the value of field 'Graph'. + */ + public boolean isGraph() { + return this._graph; + } - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() { + try { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) { + return false; } + return true; + } - /** - * Sets the value of field 'graph'. The field 'graph' has the - * following description: TODO: - * decide if this flag is - * redundant - when true it - * would suggest that the - * annotationElement values - * together form a graph - * - * - * @param graph the value of field 'graph'. - */ - public void setGraph( - final boolean graph) { - this._graph = graph; - this._has_graph = true; - } + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, out); + } - /** - * Sets the value of field 'provenance'. - * - * @param provenance the value of field 'provenance'. - */ - public void setProvenance( - final uk.ac.vamsas.objects.core.Provenance provenance) { - this._provenance = provenance; - } + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, handler); + } - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled uk.ac.vamsas.objects.core.RangeType - */ - public static uk.ac.vamsas.objects.core.RangeType unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (uk.ac.vamsas.objects.core.RangeType) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation.class, reader); - } + /** + * Sets the value of field 'graph'. The field 'graph' has the following + * description: TODO: decide if this flag is redundant - when true it would + * suggest that the annotationElement values together form a graph + * + * + * @param graph + * the value of field 'graph'. + */ + public void setGraph(final boolean graph) { + this._graph = graph; + this._has_graph = true; + } - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); - } + /** + * Sets the value of field 'provenance'. + * + * @param provenance + * the value of field 'provenance'. + */ + public void setProvenance( + final uk.ac.vamsas.objects.core.Provenance provenance) { + this._provenance = provenance; + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @return the unmarshaled uk.ac.vamsas.objects.core.RangeType + */ + public static uk.ac.vamsas.objects.core.RangeType unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + return (uk.ac.vamsas.objects.core.RangeType) Unmarshaller.unmarshal( + uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/uk/ac/vamsas/objects/core/AnnotationElement.java b/src/uk/ac/vamsas/objects/core/AnnotationElement.java index 05aec77..45cb5c7 100644 --- a/src/uk/ac/vamsas/objects/core/AnnotationElement.java +++ b/src/uk/ac/vamsas/objects/core/AnnotationElement.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import org.exolab.castor.xml.Marshaller; @@ -17,841 +31,829 @@ import org.exolab.castor.xml.Unmarshaller; /** * Class AnnotationElement. * - * @version $Revision$ $Date$ + * @version $Revision$ $Date: 2007-06-28 14:51:44 +0100 (Thu, 28 Jun 2007) + * $ */ -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 long _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(); - this._glyphList = new java.util.Vector(); - this._valueList = new java.util.Vector(); - } - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * - * - * @param vGlyph - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addGlyph( - final uk.ac.vamsas.objects.core.Glyph vGlyph) - throws java.lang.IndexOutOfBoundsException { - this._glyphList.addElement(vGlyph); - } - - /** - * - * - * @param index - * @param vGlyph - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addGlyph( - final int index, - final uk.ac.vamsas.objects.core.Glyph vGlyph) - throws java.lang.IndexOutOfBoundsException { - this._glyphList.add(index, vGlyph); - } - - /** - * - * - * @param vValue - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addValue( - final float vValue) - throws java.lang.IndexOutOfBoundsException { - this._valueList.addElement(new java.lang.Float(vValue)); - } - - /** - * - * - * @param index - * @param vValue - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addValue( - final int index, - final float vValue) - throws java.lang.IndexOutOfBoundsException { - this._valueList.add(index, new java.lang.Float(vValue)); - } - - /** - */ - public void deleteAfter( - ) { - this._has_after= false; - } - - /** - */ - public void deletePosition( - ) { - this._has_position= false; - } - - /** - * Method enumerateGlyph. - * - * @return an Enumeration over all - * uk.ac.vamsas.objects.core.Glyph elements - */ - public java.util.Enumeration enumerateGlyph( - ) { - return this._glyphList.elements(); - } - - /** - * Method enumerateValue. - * - * @return an Enumeration over all float elements - */ - public java.util.Enumeration enumerateValue( - ) { - return this._valueList.elements(); - } - - /** - * Overrides the java.lang.Object.equals method. - * - * @param obj - * @return true if the objects are equal. - */ - public boolean equals( - final java.lang.Object obj) { - if ( this == obj ) - return true; - - if (super.equals(obj)==false) +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 long _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(); + this._glyphList = new java.util.Vector(); + this._valueList = new java.util.Vector(); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * + * + * @param vGlyph + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addGlyph(final uk.ac.vamsas.objects.core.Glyph vGlyph) + throws java.lang.IndexOutOfBoundsException { + this._glyphList.addElement(vGlyph); + } + + /** + * + * + * @param index + * @param vGlyph + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addGlyph(final int index, + final uk.ac.vamsas.objects.core.Glyph vGlyph) + throws java.lang.IndexOutOfBoundsException { + this._glyphList.add(index, vGlyph); + } + + /** + * + * + * @param vValue + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addValue(final float vValue) + throws java.lang.IndexOutOfBoundsException { + this._valueList.addElement(new java.lang.Float(vValue)); + } + + /** + * + * + * @param index + * @param vValue + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addValue(final int index, final float vValue) + throws java.lang.IndexOutOfBoundsException { + this._valueList.add(index, new java.lang.Float(vValue)); + } + + /** + */ + public void deleteAfter() { + this._has_after = false; + } + + /** + */ + public void deletePosition() { + this._has_position = false; + } + + /** + * Method enumerateGlyph. + * + * @return an Enumeration over all uk.ac.vamsas.objects.core.Glyph elements + */ + public java.util.Enumeration enumerateGlyph() { + return this._glyphList.elements(); + } + + /** + * Method enumerateValue. + * + * @return an Enumeration over all float elements + */ + public java.util.Enumeration enumerateValue() { + return this._valueList.elements(); + } + + /** + * Overrides the java.lang.Object.equals method. + * + * @param obj + * @return true if the objects are equal. + */ + public boolean equals(final java.lang.Object obj) { + if (this == obj) + return true; + + if (super.equals(obj) == false) + return false; + + if (obj instanceof AnnotationElement) { + + AnnotationElement temp = (AnnotationElement) obj; + boolean thcycle; + boolean tmcycle; + 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; + if (this._id != temp._id) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._id); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._id); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._id); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); + } + ; return false; - - if (obj instanceof AnnotationElement) { - - AnnotationElement temp = (AnnotationElement)obj; - boolean thcycle; - boolean tmcycle; - 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; - if (this._id != temp._id) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._id); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._id); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._id); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); }; - return false; - } - if (!thcycle) { - if (!this._id.equals(temp._id)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._id); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._id); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); - } - } - } else if (temp._id != null) - return false; - if (this._description != null) { - if (temp._description == null) return false; - if (this._description != temp._description) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._description); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._description); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._description); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._description); }; - return false; - } - if (!thcycle) { - if (!this._description.equals(temp._description)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._description); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._description); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._description); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._description); - } - } - } else if (temp._description != null) - return false; - if (this._glyphList != null) { - if (temp._glyphList == null) return false; - if (this._glyphList != temp._glyphList) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._glyphList); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._glyphList); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._glyphList); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._glyphList); }; - return false; - } - if (!thcycle) { - if (!this._glyphList.equals(temp._glyphList)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._glyphList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._glyphList); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._glyphList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._glyphList); - } - } - } else if (temp._glyphList != null) - return false; - if (this._valueList != null) { - if (temp._valueList == null) return false; - if (this._valueList != temp._valueList) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._valueList); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._valueList); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._valueList); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._valueList); }; - return false; - } - if (!thcycle) { - if (!this._valueList.equals(temp._valueList)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._valueList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._valueList); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._valueList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._valueList); - } - } - } else if (temp._valueList != null) - return false; - return true; + } + if (!thcycle) { + if (!this._id.equals(temp._id)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._id); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._id); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); + } } + } else if (temp._id != null) return false; - } - - /** - * 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 the value of field 'After'. - */ - public boolean getAfter( - ) { - return this._after; - } - - /** - * Returns the value of field 'description'. The field - * 'description' has the following description: Free text at - * this position - * - * @return the value of field 'Description'. - */ - public java.lang.String getDescription( - ) { - return this._description; - } - - /** - * Method getGlyph. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the uk.ac.vamsas.objects.core.Glyph at - * the given index - */ - public uk.ac.vamsas.objects.core.Glyph getGlyph( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._glyphList.size()) { - throw new IndexOutOfBoundsException("getGlyph: Index value '" + index + "' not in range [0.." + (this._glyphList.size() - 1) + "]"); - } - - return (uk.ac.vamsas.objects.core.Glyph) _glyphList.get(index); - } - - /** - * Method getGlyph.Returns the contents of the collection in an - * Array.

Note: Just in case the collection contents are - * changing in another thread, we pass a 0-length Array of the - * correct type into the API call. This way we know - * that the Array returned is of exactly the correct length. - * - * @return this collection as an Array - */ - public uk.ac.vamsas.objects.core.Glyph[] getGlyph( - ) { - uk.ac.vamsas.objects.core.Glyph[] array = new uk.ac.vamsas.objects.core.Glyph[0]; - return (uk.ac.vamsas.objects.core.Glyph[]) this._glyphList.toArray(array); - } - - /** - * Method getGlyphAsReference.Returns a reference to - * '_glyphList'. No type checking is performed on any - * modifications to the Vector. - * - * @return a reference to the Vector backing this class - */ - public java.util.Vector getGlyphAsReference( - ) { - return this._glyphList; - } - - /** - * Method getGlyphCount. - * - * @return the size of this collection - */ - public int getGlyphCount( - ) { - return this._glyphList.size(); - } - - /** - * Returns the value of field 'id'. The field 'id' has the - * following description: Primary Key for vamsas object - * referencing - * - * @return the value of field 'Id'. - */ - public java.lang.String getId( - ) { - return this._id; - } - - /** - * 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 the value of field 'Position'. - */ - public long getPosition( - ) { - return this._position; - } - - /** - * Method getValue. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the float at the given index - */ - public float getValue( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._valueList.size()) { - throw new IndexOutOfBoundsException("getValue: Index value '" + index + "' not in range [0.." + (this._valueList.size() - 1) + "]"); - } - - return ((java.lang.Float) _valueList.get(index)).floatValue(); - } - - /** - * Method getValue.Returns the contents of the collection in an - * Array. - * - * @return this collection as an Array - */ - public float[] getValue( - ) { - int size = this._valueList.size(); - float[] array = new float[size]; - java.util.Iterator iter = _valueList.iterator(); - for (int index = 0; index < size; index++) { - array[index] = ((java.lang.Float) iter.next()).floatValue(); - } - return array; - } - - /** - * Method getValueAsReference.Returns a reference to - * '_valueList'. No type checking is performed on any - * modifications to the Vector. - * - * @return a reference to the Vector backing this class - */ - public java.util.Vector getValueAsReference( - ) { - return this._valueList; - } - - /** - * Method getValueCount. - * - * @return the size of this collection - */ - public int getValueCount( - ) { - return this._valueList.size(); - } - - /** - * Method hasAfter. - * - * @return true if at least one After has been added - */ - public boolean hasAfter( - ) { - return this._has_after; - } - - /** - * Method hasPosition. - * - * @return true if at least one Position has been added - */ - public boolean hasPosition( - ) { - return this._has_position; - } - - /** - * Overrides the java.lang.Object.hashCode method. - *

- * The following steps came from Effective Java Programming - * Language Guide by Joshua Bloch, Chapter 3 - * - * @return a hash code value for the object. - */ - public int hashCode( - ) { - int result = super.hashCode(); - - long tmp; - result = 37 * result + (int)(_position^(_position>>>32)); - result = 37 * result + (_after?0:1); - if (_id != null - && !org.castor.util.CycleBreaker.startingToCycle(_id)) { - result = 37 * result + _id.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_id); - } - if (_description != null - && !org.castor.util.CycleBreaker.startingToCycle(_description)) { - result = 37 * result + _description.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_description); - } - if (_glyphList != null - && !org.castor.util.CycleBreaker.startingToCycle(_glyphList)) { - result = 37 * result + _glyphList.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_glyphList); - } - if (_valueList != null - && !org.castor.util.CycleBreaker.startingToCycle(_valueList)) { - result = 37 * result + _valueList.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_valueList); - } - - return result; - } - - /** - * 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 the value of field 'After'. - */ - public boolean isAfter( - ) { - return this._after; - } - - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { + if (this._description != null) { + if (temp._description == null) + return false; + if (this._description != temp._description) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._description); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._description); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker + .releaseCycleHandle(this._description); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._description); + } + ; return false; + } + if (!thcycle) { + if (!this._description.equals(temp._description)) { + org.castor.util.CycleBreaker + .releaseCycleHandle(this._description); + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._description); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._description); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._description); + } } - return true; - } - - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } - - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } - - /** - */ - public void removeAllGlyph( - ) { - this._glyphList.clear(); - } - - /** - */ - public void removeAllValue( - ) { - this._valueList.clear(); - } - - /** - * Method removeGlyph. - * - * @param vGlyph - * @return true if the object was removed from the collection. - */ - public boolean removeGlyph( - final uk.ac.vamsas.objects.core.Glyph vGlyph) { - boolean removed = _glyphList.remove(vGlyph); - return removed; - } - - /** - * Method removeGlyphAt. - * - * @param index - * @return the element removed from the collection - */ - public uk.ac.vamsas.objects.core.Glyph removeGlyphAt( - final int index) { - java.lang.Object obj = this._glyphList.remove(index); - return (uk.ac.vamsas.objects.core.Glyph) obj; - } - - /** - * Method removeValue. - * - * @param vValue - * @return true if the object was removed from the collection. - */ - public boolean removeValue( - final float vValue) { - boolean removed = _valueList.remove(new java.lang.Float(vValue)); - return removed; - } - - /** - * Method removeValueAt. - * - * @param index - * @return the element removed from the collection - */ - public float removeValueAt( - final int index) { - java.lang.Object obj = this._valueList.remove(index); - return ((java.lang.Float) obj).floatValue(); - } - - /** - * 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( - final boolean after) { - this._after = after; - this._has_after = true; - } - - /** - * 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( - final java.lang.String description) { - this._description = description; - } - - /** - * - * - * @param index - * @param vGlyph - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setGlyph( - final int index, - final uk.ac.vamsas.objects.core.Glyph vGlyph) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._glyphList.size()) { - throw new IndexOutOfBoundsException("setGlyph: Index value '" + index + "' not in range [0.." + (this._glyphList.size() - 1) + "]"); - } - - this._glyphList.set(index, vGlyph); - } - - /** - * - * - * @param vGlyphArray - */ - public void setGlyph( - final uk.ac.vamsas.objects.core.Glyph[] vGlyphArray) { - //-- copy array - _glyphList.clear(); - - for (int i = 0; i < vGlyphArray.length; i++) { - this._glyphList.add(vGlyphArray[i]); - } - } - - /** - * Sets the value of '_glyphList' by copying the given Vector. - * All elements will be checked for type safety. - * - * @param vGlyphList the Vector to copy. - */ - public void setGlyph( - final java.util.Vector vGlyphList) { - // copy vector - this._glyphList.clear(); - - this._glyphList.addAll(vGlyphList); - } - - /** - * Sets the value of '_glyphList' by setting it to the given - * Vector. No type checking is performed. - * @deprecated - * - * @param glyphVector the Vector to set. - */ - public void setGlyphAsReference( - final java.util.Vector glyphVector) { - this._glyphList = glyphVector; - } - - /** - * 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( - final java.lang.String id) { - this._id = id; - } - - /** - * 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( - final long position) { - this._position = position; - this._has_position = true; - } - - /** - * - * - * @param index - * @param vValue - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setValue( - final int index, - final float vValue) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._valueList.size()) { - throw new IndexOutOfBoundsException("setValue: Index value '" + index + "' not in range [0.." + (this._valueList.size() - 1) + "]"); + } else if (temp._description != null) + return false; + if (this._glyphList != null) { + if (temp._glyphList == null) + return false; + if (this._glyphList != temp._glyphList) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._glyphList); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._glyphList); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._glyphList); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._glyphList); + } + ; + return false; + } + if (!thcycle) { + if (!this._glyphList.equals(temp._glyphList)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._glyphList); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._glyphList); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._glyphList); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._glyphList); + } } - - this._valueList.set(index, new java.lang.Float(vValue)); - } - - /** - * - * - * @param vValueArray - */ - public void setValue( - final float[] vValueArray) { - //-- copy array - _valueList.clear(); - - for (int i = 0; i < vValueArray.length; i++) { - this._valueList.add(new java.lang.Float(vValueArray[i])); + } else if (temp._glyphList != null) + return false; + if (this._valueList != null) { + if (temp._valueList == null) + return false; + if (this._valueList != temp._valueList) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._valueList); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._valueList); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._valueList); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._valueList); + } + ; + return false; + } + if (!thcycle) { + if (!this._valueList.equals(temp._valueList)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._valueList); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._valueList); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._valueList); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._valueList); + } } - } - - /** - * Sets the value of '_valueList' by copying the given Vector. - * All elements will be checked for type safety. - * - * @param vValueList the Vector to copy. - */ - public void setValue( - final java.util.Vector vValueList) { - // copy vector - this._valueList.clear(); - - this._valueList.addAll(vValueList); - } - - /** - * Sets the value of '_valueList' by setting it to the given - * Vector. No type checking is performed. - * @deprecated - * - * @param valueVector the Vector to set. - */ - public void setValueAsReference( - final java.util.Vector valueVector) { - this._valueList = valueVector; - } - - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled - * uk.ac.vamsas.objects.core.AnnotationElement - */ - public static uk.ac.vamsas.objects.core.AnnotationElement unmarshal( - final 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); - } - - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); - } + } else if (temp._valueList != null) + return false; + return true; + } + return false; + } + + /** + * 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 the value of field 'After'. + */ + public boolean getAfter() { + return this._after; + } + + /** + * Returns the value of field 'description'. The field 'description' has the + * following description: Free text at this position + * + * @return the value of field 'Description'. + */ + public java.lang.String getDescription() { + return this._description; + } + + /** + * Method getGlyph. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the uk.ac.vamsas.objects.core.Glyph at the given index + */ + public uk.ac.vamsas.objects.core.Glyph getGlyph(final int index) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._glyphList.size()) { + throw new IndexOutOfBoundsException("getGlyph: Index value '" + index + + "' not in range [0.." + (this._glyphList.size() - 1) + "]"); + } + + return (uk.ac.vamsas.objects.core.Glyph) _glyphList.get(index); + } + + /** + * Method getGlyph.Returns the contents of the collection in an Array. + *

+ * Note: Just in case the collection contents are changing in another thread, + * we pass a 0-length Array of the correct type into the API call. This way we + * know that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public uk.ac.vamsas.objects.core.Glyph[] getGlyph() { + uk.ac.vamsas.objects.core.Glyph[] array = new uk.ac.vamsas.objects.core.Glyph[0]; + return (uk.ac.vamsas.objects.core.Glyph[]) this._glyphList.toArray(array); + } + + /** + * Method getGlyphAsReference.Returns a reference to '_glyphList'. No type + * checking is performed on any modifications to the Vector. + * + * @return a reference to the Vector backing this class + */ + public java.util.Vector getGlyphAsReference() { + return this._glyphList; + } + + /** + * Method getGlyphCount. + * + * @return the size of this collection + */ + public int getGlyphCount() { + return this._glyphList.size(); + } + + /** + * Returns the value of field 'id'. The field 'id' has the following + * description: Primary Key for vamsas object referencing + * + * @return the value of field 'Id'. + */ + public java.lang.String getId() { + return this._id; + } + + /** + * 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 the value of field 'Position'. + */ + public long getPosition() { + return this._position; + } + + /** + * Method getValue. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the float at the given index + */ + public float getValue(final int index) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._valueList.size()) { + throw new IndexOutOfBoundsException("getValue: Index value '" + index + + "' not in range [0.." + (this._valueList.size() - 1) + "]"); + } + + return ((java.lang.Float) _valueList.get(index)).floatValue(); + } + + /** + * Method getValue.Returns the contents of the collection in an Array. + * + * @return this collection as an Array + */ + public float[] getValue() { + int size = this._valueList.size(); + float[] array = new float[size]; + java.util.Iterator iter = _valueList.iterator(); + for (int index = 0; index < size; index++) { + array[index] = ((java.lang.Float) iter.next()).floatValue(); + } + return array; + } + + /** + * Method getValueAsReference.Returns a reference to '_valueList'. No type + * checking is performed on any modifications to the Vector. + * + * @return a reference to the Vector backing this class + */ + public java.util.Vector getValueAsReference() { + return this._valueList; + } + + /** + * Method getValueCount. + * + * @return the size of this collection + */ + public int getValueCount() { + return this._valueList.size(); + } + + /** + * Method hasAfter. + * + * @return true if at least one After has been added + */ + public boolean hasAfter() { + return this._has_after; + } + + /** + * Method hasPosition. + * + * @return true if at least one Position has been added + */ + public boolean hasPosition() { + return this._has_position; + } + + /** + * Overrides the java.lang.Object.hashCode method. + *

+ * The following steps came from Effective Java Programming Language + * Guide by Joshua Bloch, Chapter 3 + * + * @return a hash code value for the object. + */ + public int hashCode() { + int result = super.hashCode(); + + long tmp; + result = 37 * result + (int) (_position ^ (_position >>> 32)); + result = 37 * result + (_after ? 0 : 1); + if (_id != null && !org.castor.util.CycleBreaker.startingToCycle(_id)) { + result = 37 * result + _id.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_id); + } + if (_description != null + && !org.castor.util.CycleBreaker.startingToCycle(_description)) { + result = 37 * result + _description.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_description); + } + if (_glyphList != null + && !org.castor.util.CycleBreaker.startingToCycle(_glyphList)) { + result = 37 * result + _glyphList.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_glyphList); + } + if (_valueList != null + && !org.castor.util.CycleBreaker.startingToCycle(_valueList)) { + result = 37 * result + _valueList.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_valueList); + } + + return result; + } + + /** + * 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 the value of field 'After'. + */ + public boolean isAfter() { + return this._after; + } + + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() { + try { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) { + return false; + } + return true; + } + + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, out); + } + + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, handler); + } + + /** + */ + public void removeAllGlyph() { + this._glyphList.clear(); + } + + /** + */ + public void removeAllValue() { + this._valueList.clear(); + } + + /** + * Method removeGlyph. + * + * @param vGlyph + * @return true if the object was removed from the collection. + */ + public boolean removeGlyph(final uk.ac.vamsas.objects.core.Glyph vGlyph) { + boolean removed = _glyphList.remove(vGlyph); + return removed; + } + + /** + * Method removeGlyphAt. + * + * @param index + * @return the element removed from the collection + */ + public uk.ac.vamsas.objects.core.Glyph removeGlyphAt(final int index) { + java.lang.Object obj = this._glyphList.remove(index); + return (uk.ac.vamsas.objects.core.Glyph) obj; + } + + /** + * Method removeValue. + * + * @param vValue + * @return true if the object was removed from the collection. + */ + public boolean removeValue(final float vValue) { + boolean removed = _valueList.remove(new java.lang.Float(vValue)); + return removed; + } + + /** + * Method removeValueAt. + * + * @param index + * @return the element removed from the collection + */ + public float removeValueAt(final int index) { + java.lang.Object obj = this._valueList.remove(index); + return ((java.lang.Float) obj).floatValue(); + } + + /** + * 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(final boolean after) { + this._after = after; + this._has_after = true; + } + + /** + * 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(final java.lang.String description) { + this._description = description; + } + + /** + * + * + * @param index + * @param vGlyph + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setGlyph(final int index, + final uk.ac.vamsas.objects.core.Glyph vGlyph) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._glyphList.size()) { + throw new IndexOutOfBoundsException("setGlyph: Index value '" + index + + "' not in range [0.." + (this._glyphList.size() - 1) + "]"); + } + + this._glyphList.set(index, vGlyph); + } + + /** + * + * + * @param vGlyphArray + */ + public void setGlyph(final uk.ac.vamsas.objects.core.Glyph[] vGlyphArray) { + // -- copy array + _glyphList.clear(); + + for (int i = 0; i < vGlyphArray.length; i++) { + this._glyphList.add(vGlyphArray[i]); + } + } + + /** + * Sets the value of '_glyphList' by copying the given Vector. All elements + * will be checked for type safety. + * + * @param vGlyphList + * the Vector to copy. + */ + public void setGlyph(final java.util.Vector vGlyphList) { + // copy vector + this._glyphList.clear(); + + this._glyphList.addAll(vGlyphList); + } + + /** + * Sets the value of '_glyphList' by setting it to the given Vector. No type + * checking is performed. + * + * @deprecated + * + * @param glyphVector + * the Vector to set. + */ + public void setGlyphAsReference(final java.util.Vector glyphVector) { + this._glyphList = glyphVector; + } + + /** + * 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(final java.lang.String id) { + this._id = id; + } + + /** + * 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(final long position) { + this._position = position; + this._has_position = true; + } + + /** + * + * + * @param index + * @param vValue + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setValue(final int index, final float vValue) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._valueList.size()) { + throw new IndexOutOfBoundsException("setValue: Index value '" + index + + "' not in range [0.." + (this._valueList.size() - 1) + "]"); + } + + this._valueList.set(index, new java.lang.Float(vValue)); + } + + /** + * + * + * @param vValueArray + */ + public void setValue(final float[] vValueArray) { + // -- copy array + _valueList.clear(); + + for (int i = 0; i < vValueArray.length; i++) { + this._valueList.add(new java.lang.Float(vValueArray[i])); + } + } + + /** + * Sets the value of '_valueList' by copying the given Vector. All elements + * will be checked for type safety. + * + * @param vValueList + * the Vector to copy. + */ + public void setValue(final java.util.Vector vValueList) { + // copy vector + this._valueList.clear(); + + this._valueList.addAll(vValueList); + } + + /** + * Sets the value of '_valueList' by setting it to the given Vector. No type + * checking is performed. + * + * @deprecated + * + * @param valueVector + * the Vector to set. + */ + public void setValueAsReference(final java.util.Vector valueVector) { + this._valueList = valueVector; + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @return the unmarshaled uk.ac.vamsas.objects.core.AnnotationElement + */ + public static uk.ac.vamsas.objects.core.AnnotationElement unmarshal( + final 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); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/uk/ac/vamsas/objects/core/AppData.java b/src/uk/ac/vamsas/objects/core/AppData.java index d54bca7..221aadd 100644 --- a/src/uk/ac/vamsas/objects/core/AppData.java +++ b/src/uk/ac/vamsas/objects/core/AppData.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import org.exolab.castor.xml.Marshaller; @@ -19,294 +33,320 @@ import org.exolab.castor.xml.Unmarshaller; * * @version $Revision$ $Date$ */ -public class AppData extends uk.ac.vamsas.client.Vobject -implements java.io.Serializable -{ +public class AppData extends uk.ac.vamsas.client.Vobject implements + java.io.Serializable { + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ + /** + * Internal choice value storage + */ + private java.lang.Object _choiceValue; - /** - * Internal choice value storage - */ - private java.lang.Object _choiceValue; + /** + * Field _data. + */ + private byte[] _data; - /** - * Field _data. - */ - private byte[] _data; + /** + * Field _dataReference. + */ + private java.lang.String _dataReference; - /** - * Field _dataReference. - */ - private java.lang.String _dataReference; + // ----------------/ + // - Constructors -/ + // ----------------/ + public AppData() { + super(); + } - //----------------/ - //- Constructors -/ - //----------------/ + // -----------/ + // - Methods -/ + // -----------/ - public AppData() { - super(); - } + /** + * Overrides the java.lang.Object.equals method. + * + * @param obj + * @return true if the objects are equal. + */ + public boolean equals(final java.lang.Object obj) { + if (this == obj) + return true; + if (super.equals(obj) == false) + return false; - //-----------/ - //- Methods -/ - //-----------/ + if (obj instanceof AppData) { - /** - * Overrides the java.lang.Object.equals method. - * - * @param obj - * @return true if the objects are equal. - */ - public boolean equals( - final java.lang.Object obj) { - if ( this == obj ) - return true; - - if (super.equals(obj)==false) + AppData temp = (AppData) obj; + boolean thcycle; + boolean tmcycle; + if (this._choiceValue != null) { + if (temp._choiceValue == null) + return false; + if (this._choiceValue != temp._choiceValue) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._choiceValue); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._choiceValue); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker + .releaseCycleHandle(this._choiceValue); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._choiceValue); + } + ; return false; - - if (obj instanceof AppData) { - - AppData temp = (AppData)obj; - boolean thcycle; - boolean tmcycle; - if (this._choiceValue != null) { - if (temp._choiceValue == null) return false; - if (this._choiceValue != temp._choiceValue) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._choiceValue); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._choiceValue); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._choiceValue); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._choiceValue); }; - return false; - } - if (!thcycle) { - if (!this._choiceValue.equals(temp._choiceValue)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._choiceValue); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._choiceValue); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._choiceValue); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._choiceValue); - } - } - } else if (temp._choiceValue != null) - return false; - if (this._data != null) { - if (temp._data == null) return false; - if (this._data != temp._data) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._data); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._data); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._data); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._data); }; - return false; - } - if (!thcycle) { - if (!java.util.Arrays.equals(this._data, temp._data)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._data); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._data); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._data); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._data); - } - } - } else if (temp._data != null) - return false; - if (this._dataReference != null) { - if (temp._dataReference == null) return false; - if (this._dataReference != temp._dataReference) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._dataReference); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._dataReference); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._dataReference); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._dataReference); }; - return false; - } - if (!thcycle) { - if (!this._dataReference.equals(temp._dataReference)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._dataReference); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._dataReference); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._dataReference); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._dataReference); - } - } - } else if (temp._dataReference != null) - return false; - return true; + } + if (!thcycle) { + if (!this._choiceValue.equals(temp._choiceValue)) { + org.castor.util.CycleBreaker + .releaseCycleHandle(this._choiceValue); + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._choiceValue); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._choiceValue); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._choiceValue); + } } + } else if (temp._choiceValue != null) return false; + if (this._data != null) { + if (temp._data == null) + return false; + if (this._data != temp._data) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._data); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._data); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._data); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._data); + } + ; + return false; + } + if (!thcycle) { + if (!java.util.Arrays.equals(this._data, temp._data)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._data); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._data); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._data); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._data); + } + } + } else if (temp._data != null) + return false; + if (this._dataReference != null) { + if (temp._dataReference == null) + return false; + if (this._dataReference != temp._dataReference) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._dataReference); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._dataReference); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker + .releaseCycleHandle(this._dataReference); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._dataReference); + } + ; + return false; + } + if (!thcycle) { + if (!this._dataReference.equals(temp._dataReference)) { + org.castor.util.CycleBreaker + .releaseCycleHandle(this._dataReference); + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._dataReference); + return false; + } + org.castor.util.CycleBreaker + .releaseCycleHandle(this._dataReference); + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._dataReference); + } + } + } else if (temp._dataReference != null) + return false; + return true; } + return false; + } - /** - * Returns the value of field 'choiceValue'. The field - * 'choiceValue' has the following description: Internal choice - * value storage - * - * @return the value of field 'ChoiceValue'. - */ - public java.lang.Object getChoiceValue( - ) { - return this._choiceValue; - } + /** + * Returns the value of field 'choiceValue'. The field 'choiceValue' has the + * following description: Internal choice value storage + * + * @return the value of field 'ChoiceValue'. + */ + public java.lang.Object getChoiceValue() { + return this._choiceValue; + } - /** - * Returns the value of field 'data'. - * - * @return the value of field 'Data'. - */ - public byte[] getData( - ) { - return this._data; - } + /** + * Returns the value of field 'data'. + * + * @return the value of field 'Data'. + */ + public byte[] getData() { + return this._data; + } - /** - * Returns the value of field 'dataReference'. - * - * @return the value of field 'DataReference'. - */ - public java.lang.String getDataReference( - ) { - return this._dataReference; - } + /** + * Returns the value of field 'dataReference'. + * + * @return the value of field 'DataReference'. + */ + public java.lang.String getDataReference() { + return this._dataReference; + } - /** - * Overrides the java.lang.Object.hashCode method. - *

- * The following steps came from Effective Java Programming - * Language Guide by Joshua Bloch, Chapter 3 - * - * @return a hash code value for the object. - */ - public int hashCode( - ) { - int result = super.hashCode(); - - long tmp; - if (_choiceValue != null - && !org.castor.util.CycleBreaker.startingToCycle(_choiceValue)) { - result = 37 * result + _choiceValue.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_choiceValue); - } - if (_data != null - && !org.castor.util.CycleBreaker.startingToCycle(_data)) { - result = 37 * result + _data.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_data); - } - if (_dataReference != null - && !org.castor.util.CycleBreaker.startingToCycle(_dataReference)) { - result = 37 * result + _dataReference.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_dataReference); - } - - return result; - } + /** + * Overrides the java.lang.Object.hashCode method. + *

+ * The following steps came from Effective Java Programming Language + * Guide by Joshua Bloch, Chapter 3 + * + * @return a hash code value for the object. + */ + public int hashCode() { + int result = super.hashCode(); - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { - return false; - } - return true; + long tmp; + if (_choiceValue != null + && !org.castor.util.CycleBreaker.startingToCycle(_choiceValue)) { + result = 37 * result + _choiceValue.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_choiceValue); } - - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); + if (_data != null && !org.castor.util.CycleBreaker.startingToCycle(_data)) { + result = 37 * result + _data.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_data); } - - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); + if (_dataReference != null + && !org.castor.util.CycleBreaker.startingToCycle(_dataReference)) { + result = 37 * result + _dataReference.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_dataReference); } - /** - * Sets the value of field 'data'. - * - * @param data the value of field 'data'. - */ - public void setData( - final byte[] data) { - this._data = data; - this._choiceValue = data; - } + return result; + } - /** - * Sets the value of field 'dataReference'. - * - * @param dataReference the value of field 'dataReference'. - */ - public void setDataReference( - final java.lang.String dataReference) { - this._dataReference = dataReference; - this._choiceValue = dataReference; + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() { + try { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) { + return false; } + return true; + } - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled uk.ac.vamsas.objects.core.AppData - */ - public static uk.ac.vamsas.objects.core.AppData unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (uk.ac.vamsas.objects.core.AppData) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.AppData.class, reader); - } + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, out); + } - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); - } + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, handler); + } + + /** + * Sets the value of field 'data'. + * + * @param data + * the value of field 'data'. + */ + public void setData(final byte[] data) { + this._data = data; + this._choiceValue = data; + } + + /** + * Sets the value of field 'dataReference'. + * + * @param dataReference + * the value of field 'dataReference'. + */ + public void setDataReference(final java.lang.String dataReference) { + this._dataReference = dataReference; + this._choiceValue = dataReference; + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @return the unmarshaled uk.ac.vamsas.objects.core.AppData + */ + public static uk.ac.vamsas.objects.core.AppData unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + return (uk.ac.vamsas.objects.core.AppData) Unmarshaller.unmarshal( + uk.ac.vamsas.objects.core.AppData.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/uk/ac/vamsas/objects/core/ApplicationData.java b/src/uk/ac/vamsas/objects/core/ApplicationData.java index ea61bca..b980483 100644 --- a/src/uk/ac/vamsas/objects/core/ApplicationData.java +++ b/src/uk/ac/vamsas/objects/core/ApplicationData.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import org.exolab.castor.xml.Marshaller; @@ -17,753 +31,767 @@ import org.exolab.castor.xml.Unmarshaller; /** * Class ApplicationData. * - * @version $Revision$ $Date$ + * @version $Revision$ $Date: 2007-06-28 14:51:44 +0100 (Thu, 28 Jun 2007) + * $ */ -public class ApplicationData extends uk.ac.vamsas.objects.core.AppData -implements java.io.Serializable -{ - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Version string describing the application specific - * data storage version used - */ - private java.lang.String _version; - - /** - * Canonical name of application - */ - private java.lang.String _name; - - /** - * Field _userList. - */ - private java.util.Vector _userList; - - /** - * Field _common. - */ - private uk.ac.vamsas.objects.core.Common _common; - - /** - * Field _instanceList. - */ - private java.util.Vector _instanceList; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public ApplicationData() { - super(); - this._userList = new java.util.Vector(); - this._instanceList = new java.util.Vector(); - } - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * - * - * @param vInstance - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addInstance( - final uk.ac.vamsas.objects.core.Instance vInstance) - throws java.lang.IndexOutOfBoundsException { - this._instanceList.addElement(vInstance); - } - - /** - * - * - * @param index - * @param vInstance - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addInstance( - final int index, - final uk.ac.vamsas.objects.core.Instance vInstance) - throws java.lang.IndexOutOfBoundsException { - this._instanceList.add(index, vInstance); - } - - /** - * - * - * @param vUser - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addUser( - final uk.ac.vamsas.objects.core.User vUser) - throws java.lang.IndexOutOfBoundsException { - this._userList.addElement(vUser); - } - - /** - * - * - * @param index - * @param vUser - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addUser( - final int index, - final uk.ac.vamsas.objects.core.User vUser) - throws java.lang.IndexOutOfBoundsException { - this._userList.add(index, vUser); - } - - /** - * Method enumerateInstance. - * - * @return an Enumeration over all - * uk.ac.vamsas.objects.core.Instance elements - */ - public java.util.Enumeration enumerateInstance( - ) { - return this._instanceList.elements(); - } - - /** - * Method enumerateUser. - * - * @return an Enumeration over all - * uk.ac.vamsas.objects.core.User elements - */ - public java.util.Enumeration enumerateUser( - ) { - return this._userList.elements(); - } - - /** - * Overrides the java.lang.Object.equals method. - * - * @param obj - * @return true if the objects are equal. - */ - public boolean equals( - final java.lang.Object obj) { - if ( this == obj ) - return true; - - if (super.equals(obj)==false) +public class ApplicationData extends uk.ac.vamsas.objects.core.AppData + implements java.io.Serializable { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Version string describing the application specific data storage version + * used + */ + private java.lang.String _version; + + /** + * Canonical name of application + */ + private java.lang.String _name; + + /** + * Field _userList. + */ + private java.util.Vector _userList; + + /** + * Field _common. + */ + private uk.ac.vamsas.objects.core.Common _common; + + /** + * Field _instanceList. + */ + private java.util.Vector _instanceList; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public ApplicationData() { + super(); + this._userList = new java.util.Vector(); + this._instanceList = new java.util.Vector(); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * + * + * @param vInstance + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addInstance(final uk.ac.vamsas.objects.core.Instance vInstance) + throws java.lang.IndexOutOfBoundsException { + this._instanceList.addElement(vInstance); + } + + /** + * + * + * @param index + * @param vInstance + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addInstance(final int index, + final uk.ac.vamsas.objects.core.Instance vInstance) + throws java.lang.IndexOutOfBoundsException { + this._instanceList.add(index, vInstance); + } + + /** + * + * + * @param vUser + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addUser(final uk.ac.vamsas.objects.core.User vUser) + throws java.lang.IndexOutOfBoundsException { + this._userList.addElement(vUser); + } + + /** + * + * + * @param index + * @param vUser + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addUser(final int index, + final uk.ac.vamsas.objects.core.User vUser) + throws java.lang.IndexOutOfBoundsException { + this._userList.add(index, vUser); + } + + /** + * Method enumerateInstance. + * + * @return an Enumeration over all uk.ac.vamsas.objects.core.Instance elements + */ + public java.util.Enumeration enumerateInstance() { + return this._instanceList.elements(); + } + + /** + * Method enumerateUser. + * + * @return an Enumeration over all uk.ac.vamsas.objects.core.User elements + */ + public java.util.Enumeration enumerateUser() { + return this._userList.elements(); + } + + /** + * Overrides the java.lang.Object.equals method. + * + * @param obj + * @return true if the objects are equal. + */ + public boolean equals(final java.lang.Object obj) { + if (this == obj) + return true; + + if (super.equals(obj) == false) + return false; + + if (obj instanceof ApplicationData) { + + ApplicationData temp = (ApplicationData) obj; + boolean thcycle; + boolean tmcycle; + if (this._version != null) { + if (temp._version == null) + return false; + if (this._version != temp._version) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._version); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._version); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._version); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._version); + } + ; return false; - - if (obj instanceof ApplicationData) { - - ApplicationData temp = (ApplicationData)obj; - boolean thcycle; - boolean tmcycle; - if (this._version != null) { - if (temp._version == null) return false; - if (this._version != temp._version) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._version); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._version); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._version); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._version); }; - return false; - } - if (!thcycle) { - if (!this._version.equals(temp._version)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._version); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._version); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._version); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._version); - } - } - } else if (temp._version != null) - return false; - if (this._name != null) { - if (temp._name == null) return false; - if (this._name != temp._name) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._name); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._name); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._name); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._name); }; - return false; - } - if (!thcycle) { - if (!this._name.equals(temp._name)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._name); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._name); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._name); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._name); - } - } - } else if (temp._name != null) - return false; - if (this._userList != null) { - if (temp._userList == null) return false; - if (this._userList != temp._userList) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._userList); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._userList); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._userList); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._userList); }; - return false; - } - if (!thcycle) { - if (!this._userList.equals(temp._userList)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._userList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._userList); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._userList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._userList); - } - } - } else if (temp._userList != null) - return false; - if (this._common != null) { - if (temp._common == null) return false; - if (this._common != temp._common) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._common); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._common); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._common); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._common); }; - return false; - } - if (!thcycle) { - if (!this._common.equals(temp._common)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._common); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._common); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._common); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._common); - } - } - } else if (temp._common != null) - return false; - if (this._instanceList != null) { - if (temp._instanceList == null) return false; - if (this._instanceList != temp._instanceList) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._instanceList); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._instanceList); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._instanceList); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._instanceList); }; - return false; - } - if (!thcycle) { - if (!this._instanceList.equals(temp._instanceList)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._instanceList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._instanceList); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._instanceList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._instanceList); - } - } - } else if (temp._instanceList != null) - return false; - return true; + } + if (!thcycle) { + if (!this._version.equals(temp._version)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._version); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._version); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._version); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._version); + } } + } else if (temp._version != null) return false; - } - - /** - * Returns the value of field 'common'. - * - * @return the value of field 'Common'. - */ - public uk.ac.vamsas.objects.core.Common getCommon( - ) { - return this._common; - } - - /** - * Method getInstance. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the uk.ac.vamsas.objects.core.Instance - * at the given index - */ - public uk.ac.vamsas.objects.core.Instance getInstance( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._instanceList.size()) { - throw new IndexOutOfBoundsException("getInstance: Index value '" + index + "' not in range [0.." + (this._instanceList.size() - 1) + "]"); - } - - return (uk.ac.vamsas.objects.core.Instance) _instanceList.get(index); - } - - /** - * Method getInstance.Returns the contents of the collection in - * an Array.

Note: Just in case the collection contents - * are changing in another thread, we pass a 0-length Array of - * the correct type into the API call. This way we know - * that the Array returned is of exactly the correct length. - * - * @return this collection as an Array - */ - public uk.ac.vamsas.objects.core.Instance[] getInstance( - ) { - uk.ac.vamsas.objects.core.Instance[] array = new uk.ac.vamsas.objects.core.Instance[0]; - return (uk.ac.vamsas.objects.core.Instance[]) this._instanceList.toArray(array); - } - - /** - * Method getInstanceAsReference.Returns a reference to - * '_instanceList'. No type checking is performed on any - * modifications to the Vector. - * - * @return a reference to the Vector backing this class - */ - public java.util.Vector getInstanceAsReference( - ) { - return this._instanceList; - } - - /** - * Method getInstanceCount. - * - * @return the size of this collection - */ - public int getInstanceCount( - ) { - return this._instanceList.size(); - } - - /** - * Returns the value of field 'name'. The field 'name' has the - * following description: Canonical name of application - * - * @return the value of field 'Name'. - */ - public java.lang.String getName( - ) { - return this._name; - } - - /** - * Method getUser. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the uk.ac.vamsas.objects.core.User at - * the given index - */ - public uk.ac.vamsas.objects.core.User getUser( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._userList.size()) { - throw new IndexOutOfBoundsException("getUser: Index value '" + index + "' not in range [0.." + (this._userList.size() - 1) + "]"); - } - - return (uk.ac.vamsas.objects.core.User) _userList.get(index); - } - - /** - * Method getUser.Returns the contents of the collection in an - * Array.

Note: Just in case the collection contents are - * changing in another thread, we pass a 0-length Array of the - * correct type into the API call. This way we know - * that the Array returned is of exactly the correct length. - * - * @return this collection as an Array - */ - public uk.ac.vamsas.objects.core.User[] getUser( - ) { - uk.ac.vamsas.objects.core.User[] array = new uk.ac.vamsas.objects.core.User[0]; - return (uk.ac.vamsas.objects.core.User[]) this._userList.toArray(array); - } - - /** - * Method getUserAsReference.Returns a reference to - * '_userList'. No type checking is performed on any - * modifications to the Vector. - * - * @return a reference to the Vector backing this class - */ - public java.util.Vector getUserAsReference( - ) { - return this._userList; - } - - /** - * Method getUserCount. - * - * @return the size of this collection - */ - public int getUserCount( - ) { - return this._userList.size(); - } - - /** - * Returns the value of field 'version'. The field 'version' - * has the following description: Version string describing the - * application specific - * data storage version used - * - * @return the value of field 'Version'. - */ - public java.lang.String getVersion( - ) { - return this._version; - } - - /** - * Overrides the java.lang.Object.hashCode method. - *

- * The following steps came from Effective Java Programming - * Language Guide by Joshua Bloch, Chapter 3 - * - * @return a hash code value for the object. - */ - public int hashCode( - ) { - int result = super.hashCode(); - - long tmp; - if (_version != null - && !org.castor.util.CycleBreaker.startingToCycle(_version)) { - result = 37 * result + _version.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_version); - } - if (_name != null - && !org.castor.util.CycleBreaker.startingToCycle(_name)) { - result = 37 * result + _name.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_name); - } - if (_userList != null - && !org.castor.util.CycleBreaker.startingToCycle(_userList)) { - result = 37 * result + _userList.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_userList); - } - if (_common != null - && !org.castor.util.CycleBreaker.startingToCycle(_common)) { - result = 37 * result + _common.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_common); - } - if (_instanceList != null - && !org.castor.util.CycleBreaker.startingToCycle(_instanceList)) { - result = 37 * result + _instanceList.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_instanceList); - } - - return result; - } - - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { + if (this._name != null) { + if (temp._name == null) + return false; + if (this._name != temp._name) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._name); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._name); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._name); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._name); + } + ; return false; + } + if (!thcycle) { + if (!this._name.equals(temp._name)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._name); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._name); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._name); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._name); + } } - return true; - } - - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } - - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } - - /** - */ - public void removeAllInstance( - ) { - this._instanceList.clear(); - } - - /** - */ - public void removeAllUser( - ) { - this._userList.clear(); - } - - /** - * Method removeInstance. - * - * @param vInstance - * @return true if the object was removed from the collection. - */ - public boolean removeInstance( - final uk.ac.vamsas.objects.core.Instance vInstance) { - boolean removed = _instanceList.remove(vInstance); - return removed; - } - - /** - * Method removeInstanceAt. - * - * @param index - * @return the element removed from the collection - */ - public uk.ac.vamsas.objects.core.Instance removeInstanceAt( - final int index) { - java.lang.Object obj = this._instanceList.remove(index); - return (uk.ac.vamsas.objects.core.Instance) obj; - } - - /** - * Method removeUser. - * - * @param vUser - * @return true if the object was removed from the collection. - */ - public boolean removeUser( - final uk.ac.vamsas.objects.core.User vUser) { - boolean removed = _userList.remove(vUser); - return removed; - } - - /** - * Method removeUserAt. - * - * @param index - * @return the element removed from the collection - */ - public uk.ac.vamsas.objects.core.User removeUserAt( - final int index) { - java.lang.Object obj = this._userList.remove(index); - return (uk.ac.vamsas.objects.core.User) obj; - } - - /** - * Sets the value of field 'common'. - * - * @param common the value of field 'common'. - */ - public void setCommon( - final uk.ac.vamsas.objects.core.Common common) { - this._common = common; - } - - /** - * - * - * @param index - * @param vInstance - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setInstance( - final int index, - final uk.ac.vamsas.objects.core.Instance vInstance) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._instanceList.size()) { - throw new IndexOutOfBoundsException("setInstance: Index value '" + index + "' not in range [0.." + (this._instanceList.size() - 1) + "]"); - } - - this._instanceList.set(index, vInstance); - } - - /** - * - * - * @param vInstanceArray - */ - public void setInstance( - final uk.ac.vamsas.objects.core.Instance[] vInstanceArray) { - //-- copy array - _instanceList.clear(); - - for (int i = 0; i < vInstanceArray.length; i++) { - this._instanceList.add(vInstanceArray[i]); + } else if (temp._name != null) + return false; + if (this._userList != null) { + if (temp._userList == null) + return false; + if (this._userList != temp._userList) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._userList); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._userList); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._userList); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._userList); + } + ; + return false; + } + if (!thcycle) { + if (!this._userList.equals(temp._userList)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._userList); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._userList); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._userList); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._userList); + } } - } - - /** - * Sets the value of '_instanceList' by copying the given - * Vector. All elements will be checked for type safety. - * - * @param vInstanceList the Vector to copy. - */ - public void setInstance( - final java.util.Vector vInstanceList) { - // copy vector - this._instanceList.clear(); - - this._instanceList.addAll(vInstanceList); - } - - /** - * Sets the value of '_instanceList' by setting it to the given - * Vector. No type checking is performed. - * @deprecated - * - * @param instanceVector the Vector to set. - */ - public void setInstanceAsReference( - final java.util.Vector instanceVector) { - this._instanceList = instanceVector; - } - - /** - * Sets the value of field 'name'. The field 'name' has the - * following description: Canonical name of application - * - * @param name the value of field 'name'. - */ - public void setName( - final java.lang.String name) { - this._name = name; - } - - /** - * - * - * @param index - * @param vUser - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setUser( - final int index, - final uk.ac.vamsas.objects.core.User vUser) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._userList.size()) { - throw new IndexOutOfBoundsException("setUser: Index value '" + index + "' not in range [0.." + (this._userList.size() - 1) + "]"); + } else if (temp._userList != null) + return false; + if (this._common != null) { + if (temp._common == null) + return false; + if (this._common != temp._common) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._common); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._common); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._common); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._common); + } + ; + return false; + } + if (!thcycle) { + if (!this._common.equals(temp._common)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._common); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._common); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._common); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._common); + } } - - this._userList.set(index, vUser); - } - - /** - * - * - * @param vUserArray - */ - public void setUser( - final uk.ac.vamsas.objects.core.User[] vUserArray) { - //-- copy array - _userList.clear(); - - for (int i = 0; i < vUserArray.length; i++) { - this._userList.add(vUserArray[i]); + } else if (temp._common != null) + return false; + if (this._instanceList != null) { + if (temp._instanceList == null) + return false; + if (this._instanceList != temp._instanceList) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._instanceList); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._instanceList); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker + .releaseCycleHandle(this._instanceList); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._instanceList); + } + ; + return false; + } + if (!thcycle) { + if (!this._instanceList.equals(temp._instanceList)) { + org.castor.util.CycleBreaker + .releaseCycleHandle(this._instanceList); + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._instanceList); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._instanceList); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._instanceList); + } } - } - - /** - * Sets the value of '_userList' by copying the given Vector. - * All elements will be checked for type safety. - * - * @param vUserList the Vector to copy. - */ - public void setUser( - final java.util.Vector vUserList) { - // copy vector - this._userList.clear(); - - this._userList.addAll(vUserList); - } - - /** - * Sets the value of '_userList' by setting it to the given - * Vector. No type checking is performed. - * @deprecated - * - * @param userVector the Vector to set. - */ - public void setUserAsReference( - final java.util.Vector userVector) { - this._userList = userVector; - } - - /** - * Sets the value of field 'version'. The field 'version' has - * the following description: Version string describing the - * application specific - * data storage version used - * - * @param version the value of field 'version'. - */ - public void setVersion( - final java.lang.String version) { - this._version = version; - } - - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled uk.ac.vamsas.objects.core.AppData - */ - public static uk.ac.vamsas.objects.core.AppData unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (uk.ac.vamsas.objects.core.AppData) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.ApplicationData.class, reader); - } - - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); - } + } else if (temp._instanceList != null) + return false; + return true; + } + return false; + } + + /** + * Returns the value of field 'common'. + * + * @return the value of field 'Common'. + */ + public uk.ac.vamsas.objects.core.Common getCommon() { + return this._common; + } + + /** + * Method getInstance. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the uk.ac.vamsas.objects.core.Instance at the given + * index + */ + public uk.ac.vamsas.objects.core.Instance getInstance(final int index) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._instanceList.size()) { + throw new IndexOutOfBoundsException("getInstance: Index value '" + index + + "' not in range [0.." + (this._instanceList.size() - 1) + "]"); + } + + return (uk.ac.vamsas.objects.core.Instance) _instanceList.get(index); + } + + /** + * Method getInstance.Returns the contents of the collection in an Array. + *

+ * Note: Just in case the collection contents are changing in another thread, + * we pass a 0-length Array of the correct type into the API call. This way we + * know that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public uk.ac.vamsas.objects.core.Instance[] getInstance() { + uk.ac.vamsas.objects.core.Instance[] array = new uk.ac.vamsas.objects.core.Instance[0]; + return (uk.ac.vamsas.objects.core.Instance[]) this._instanceList + .toArray(array); + } + + /** + * Method getInstanceAsReference.Returns a reference to '_instanceList'. No + * type checking is performed on any modifications to the Vector. + * + * @return a reference to the Vector backing this class + */ + public java.util.Vector getInstanceAsReference() { + return this._instanceList; + } + + /** + * Method getInstanceCount. + * + * @return the size of this collection + */ + public int getInstanceCount() { + return this._instanceList.size(); + } + + /** + * Returns the value of field 'name'. The field 'name' has the following + * description: Canonical name of application + * + * @return the value of field 'Name'. + */ + public java.lang.String getName() { + return this._name; + } + + /** + * Method getUser. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the uk.ac.vamsas.objects.core.User at the given index + */ + public uk.ac.vamsas.objects.core.User getUser(final int index) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._userList.size()) { + throw new IndexOutOfBoundsException("getUser: Index value '" + index + + "' not in range [0.." + (this._userList.size() - 1) + "]"); + } + + return (uk.ac.vamsas.objects.core.User) _userList.get(index); + } + + /** + * Method getUser.Returns the contents of the collection in an Array. + *

+ * Note: Just in case the collection contents are changing in another thread, + * we pass a 0-length Array of the correct type into the API call. This way we + * know that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public uk.ac.vamsas.objects.core.User[] getUser() { + uk.ac.vamsas.objects.core.User[] array = new uk.ac.vamsas.objects.core.User[0]; + return (uk.ac.vamsas.objects.core.User[]) this._userList.toArray(array); + } + + /** + * Method getUserAsReference.Returns a reference to '_userList'. No type + * checking is performed on any modifications to the Vector. + * + * @return a reference to the Vector backing this class + */ + public java.util.Vector getUserAsReference() { + return this._userList; + } + + /** + * Method getUserCount. + * + * @return the size of this collection + */ + public int getUserCount() { + return this._userList.size(); + } + + /** + * Returns the value of field 'version'. The field 'version' has the following + * description: Version string describing the application specific data + * storage version used + * + * @return the value of field 'Version'. + */ + public java.lang.String getVersion() { + return this._version; + } + + /** + * Overrides the java.lang.Object.hashCode method. + *

+ * The following steps came from Effective Java Programming Language + * Guide by Joshua Bloch, Chapter 3 + * + * @return a hash code value for the object. + */ + public int hashCode() { + int result = super.hashCode(); + + long tmp; + if (_version != null + && !org.castor.util.CycleBreaker.startingToCycle(_version)) { + result = 37 * result + _version.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_version); + } + if (_name != null && !org.castor.util.CycleBreaker.startingToCycle(_name)) { + result = 37 * result + _name.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_name); + } + if (_userList != null + && !org.castor.util.CycleBreaker.startingToCycle(_userList)) { + result = 37 * result + _userList.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_userList); + } + if (_common != null + && !org.castor.util.CycleBreaker.startingToCycle(_common)) { + result = 37 * result + _common.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_common); + } + if (_instanceList != null + && !org.castor.util.CycleBreaker.startingToCycle(_instanceList)) { + result = 37 * result + _instanceList.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_instanceList); + } + + return result; + } + + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() { + try { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) { + return false; + } + return true; + } + + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, out); + } + + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, handler); + } + + /** + */ + public void removeAllInstance() { + this._instanceList.clear(); + } + + /** + */ + public void removeAllUser() { + this._userList.clear(); + } + + /** + * Method removeInstance. + * + * @param vInstance + * @return true if the object was removed from the collection. + */ + public boolean removeInstance( + final uk.ac.vamsas.objects.core.Instance vInstance) { + boolean removed = _instanceList.remove(vInstance); + return removed; + } + + /** + * Method removeInstanceAt. + * + * @param index + * @return the element removed from the collection + */ + public uk.ac.vamsas.objects.core.Instance removeInstanceAt(final int index) { + java.lang.Object obj = this._instanceList.remove(index); + return (uk.ac.vamsas.objects.core.Instance) obj; + } + + /** + * Method removeUser. + * + * @param vUser + * @return true if the object was removed from the collection. + */ + public boolean removeUser(final uk.ac.vamsas.objects.core.User vUser) { + boolean removed = _userList.remove(vUser); + return removed; + } + + /** + * Method removeUserAt. + * + * @param index + * @return the element removed from the collection + */ + public uk.ac.vamsas.objects.core.User removeUserAt(final int index) { + java.lang.Object obj = this._userList.remove(index); + return (uk.ac.vamsas.objects.core.User) obj; + } + + /** + * Sets the value of field 'common'. + * + * @param common + * the value of field 'common'. + */ + public void setCommon(final uk.ac.vamsas.objects.core.Common common) { + this._common = common; + } + + /** + * + * + * @param index + * @param vInstance + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setInstance(final int index, + final uk.ac.vamsas.objects.core.Instance vInstance) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._instanceList.size()) { + throw new IndexOutOfBoundsException("setInstance: Index value '" + index + + "' not in range [0.." + (this._instanceList.size() - 1) + "]"); + } + + this._instanceList.set(index, vInstance); + } + + /** + * + * + * @param vInstanceArray + */ + public void setInstance( + final uk.ac.vamsas.objects.core.Instance[] vInstanceArray) { + // -- copy array + _instanceList.clear(); + + for (int i = 0; i < vInstanceArray.length; i++) { + this._instanceList.add(vInstanceArray[i]); + } + } + + /** + * Sets the value of '_instanceList' by copying the given Vector. All elements + * will be checked for type safety. + * + * @param vInstanceList + * the Vector to copy. + */ + public void setInstance(final java.util.Vector vInstanceList) { + // copy vector + this._instanceList.clear(); + + this._instanceList.addAll(vInstanceList); + } + + /** + * Sets the value of '_instanceList' by setting it to the given Vector. No + * type checking is performed. + * + * @deprecated + * + * @param instanceVector + * the Vector to set. + */ + public void setInstanceAsReference(final java.util.Vector instanceVector) { + this._instanceList = instanceVector; + } + + /** + * Sets the value of field 'name'. The field 'name' has the following + * description: Canonical name of application + * + * @param name + * the value of field 'name'. + */ + public void setName(final java.lang.String name) { + this._name = name; + } + + /** + * + * + * @param index + * @param vUser + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setUser(final int index, + final uk.ac.vamsas.objects.core.User vUser) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._userList.size()) { + throw new IndexOutOfBoundsException("setUser: Index value '" + index + + "' not in range [0.." + (this._userList.size() - 1) + "]"); + } + + this._userList.set(index, vUser); + } + + /** + * + * + * @param vUserArray + */ + public void setUser(final uk.ac.vamsas.objects.core.User[] vUserArray) { + // -- copy array + _userList.clear(); + + for (int i = 0; i < vUserArray.length; i++) { + this._userList.add(vUserArray[i]); + } + } + + /** + * Sets the value of '_userList' by copying the given Vector. All elements + * will be checked for type safety. + * + * @param vUserList + * the Vector to copy. + */ + public void setUser(final java.util.Vector vUserList) { + // copy vector + this._userList.clear(); + + this._userList.addAll(vUserList); + } + + /** + * Sets the value of '_userList' by setting it to the given Vector. No type + * checking is performed. + * + * @deprecated + * + * @param userVector + * the Vector to set. + */ + public void setUserAsReference(final java.util.Vector userVector) { + this._userList = userVector; + } + + /** + * Sets the value of field 'version'. The field 'version' has the following + * description: Version string describing the application specific data + * storage version used + * + * @param version + * the value of field 'version'. + */ + public void setVersion(final java.lang.String version) { + this._version = version; + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @return the unmarshaled uk.ac.vamsas.objects.core.AppData + */ + public static uk.ac.vamsas.objects.core.AppData unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + return (uk.ac.vamsas.objects.core.AppData) Unmarshaller.unmarshal( + uk.ac.vamsas.objects.core.ApplicationData.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/uk/ac/vamsas/objects/core/Attachment.java b/src/uk/ac/vamsas/objects/core/Attachment.java index b7c741f..10b36ec 100644 --- a/src/uk/ac/vamsas/objects/core/Attachment.java +++ b/src/uk/ac/vamsas/objects/core/Attachment.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import org.exolab.castor.xml.Marshaller; @@ -19,394 +33,394 @@ import org.exolab.castor.xml.Unmarshaller; * * @version $Revision$ $Date$ */ -public class Attachment extends uk.ac.vamsas.objects.core.AppData -implements java.io.Serializable -{ - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * true implies data will be decompresses with Zip - * before presenting to application - */ - private boolean _compressed = false; - - /** - * keeps track of state for field: _compressed +public class Attachment extends uk.ac.vamsas.objects.core.AppData implements + java.io.Serializable { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * true implies data will be decompresses with Zip before presenting to + * application + */ + private boolean _compressed = false; + + /** + * keeps track of state for field: _compressed + */ + private boolean _has_compressed; + + /** + * Type of arbitrary data - TODO: decide format - use (extended) MIME types ? + */ + private java.lang.String _type; + + /** + * Object the arbitrary data is associated with + * + */ + private java.lang.Object _objectref; + + /** + * Primary Key for vamsas object referencing + * + */ + private java.lang.String _id; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public Attachment() { + super(); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** */ - private boolean _has_compressed; - - /** - * Type of arbitrary data - TODO: decide format - use - * (extended) MIME types ? - */ - private java.lang.String _type; - - /** - * Object the arbitrary data is associated with - * - */ - private java.lang.Object _objectref; - - /** - * Primary Key for vamsas object referencing - * - */ - private java.lang.String _id; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public Attachment() { - super(); - } - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - */ - public void deleteCompressed( - ) { - this._has_compressed= false; - } - - /** - * Overrides the java.lang.Object.equals method. - * - * @param obj - * @return true if the objects are equal. - */ - public boolean equals( - final java.lang.Object obj) { - if ( this == obj ) - return true; - - if (super.equals(obj)==false) + public void deleteCompressed() { + this._has_compressed = false; + } + + /** + * Overrides the java.lang.Object.equals method. + * + * @param obj + * @return true if the objects are equal. + */ + public boolean equals(final java.lang.Object obj) { + if (this == obj) + return true; + + if (super.equals(obj) == false) + return false; + + if (obj instanceof Attachment) { + + Attachment temp = (Attachment) obj; + boolean thcycle; + boolean tmcycle; + if (this._compressed != temp._compressed) + return false; + if (this._has_compressed != temp._has_compressed) + return false; + if (this._type != null) { + if (temp._type == null) + return false; + if (this._type != temp._type) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._type); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._type); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._type); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._type); + } + ; return false; - - if (obj instanceof Attachment) { - - Attachment temp = (Attachment)obj; - boolean thcycle; - boolean tmcycle; - if (this._compressed != temp._compressed) - return false; - if (this._has_compressed != temp._has_compressed) - return false; - if (this._type != null) { - if (temp._type == null) return false; - if (this._type != temp._type) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._type); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._type); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._type); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._type); }; - return false; - } - if (!thcycle) { - if (!this._type.equals(temp._type)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._type); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._type); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._type); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._type); - } - } - } else if (temp._type != null) - return false; - if (this._objectref != null) { - if (temp._objectref == null) return false; - if (this._objectref != temp._objectref) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._objectref); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._objectref); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._objectref); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._objectref); }; - return false; - } - if (!thcycle) { - if (!this._objectref.equals(temp._objectref)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._objectref); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._objectref); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._objectref); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._objectref); - } - } - } else if (temp._objectref != null) - return false; - if (this._id != null) { - if (temp._id == null) return false; - if (this._id != temp._id) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._id); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._id); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._id); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); }; - return false; - } - if (!thcycle) { - if (!this._id.equals(temp._id)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._id); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._id); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); - } - } - } else if (temp._id != null) - return false; - return true; + } + if (!thcycle) { + if (!this._type.equals(temp._type)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._type); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._type); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._type); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._type); + } } + } else if (temp._type != null) return false; - } - - /** - * Returns the value of field 'compressed'. The field - * 'compressed' has the following description: true implies - * data will be decompresses with Zip - * before presenting to application - * - * @return the value of field 'Compressed'. - */ - public boolean getCompressed( - ) { - return this._compressed; - } - - /** - * Returns the value of field 'id'. The field 'id' has the - * following description: Primary Key for vamsas object - * referencing - * - * - * @return the value of field 'Id'. - */ - public java.lang.String getId( - ) { - return this._id; - } - - /** - * Returns the value of field 'objectref'. The field - * 'objectref' has the following description: Object the - * arbitrary data is associated with - * - * - * @return the value of field 'Objectref'. - */ - public java.lang.Object getObjectref( - ) { - return this._objectref; - } - - /** - * Returns the value of field 'type'. The field 'type' has the - * following description: Type of arbitrary data - TODO: decide - * format - use - * (extended) MIME types ? - * - * @return the value of field 'Type'. - */ - public java.lang.String getType( - ) { - return this._type; - } - - /** - * Method hasCompressed. - * - * @return true if at least one Compressed has been added - */ - public boolean hasCompressed( - ) { - return this._has_compressed; - } - - /** - * Overrides the java.lang.Object.hashCode method. - *

- * The following steps came from Effective Java Programming - * Language Guide by Joshua Bloch, Chapter 3 - * - * @return a hash code value for the object. - */ - public int hashCode( - ) { - int result = super.hashCode(); - - long tmp; - result = 37 * result + (_compressed?0:1); - if (_type != null - && !org.castor.util.CycleBreaker.startingToCycle(_type)) { - result = 37 * result + _type.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_type); - } - if (_objectref != null - && !org.castor.util.CycleBreaker.startingToCycle(_objectref)) { - result = 37 * result + _objectref.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_objectref); - } - if (_id != null - && !org.castor.util.CycleBreaker.startingToCycle(_id)) { - result = 37 * result + _id.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_id); + if (this._objectref != null) { + if (temp._objectref == null) + return false; + if (this._objectref != temp._objectref) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._objectref); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._objectref); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._objectref); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._objectref); + } + ; + return false; + } + if (!thcycle) { + if (!this._objectref.equals(temp._objectref)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._objectref); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._objectref); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._objectref); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._objectref); + } } - - return result; - } - - /** - * Returns the value of field 'compressed'. The field - * 'compressed' has the following description: true implies - * data will be decompresses with Zip - * before presenting to application - * - * @return the value of field 'Compressed'. - */ - public boolean isCompressed( - ) { - return this._compressed; - } - - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { + } else if (temp._objectref != null) + return false; + if (this._id != null) { + if (temp._id == null) + return false; + if (this._id != temp._id) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._id); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._id); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._id); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); + } + ; return false; + } + if (!thcycle) { + if (!this._id.equals(temp._id)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._id); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._id); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); + } } - return true; - } - - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } - - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } - - /** - * Sets the value of field 'compressed'. The field 'compressed' - * has the following description: true implies data will be - * decompresses with Zip - * before presenting to application - * - * @param compressed the value of field 'compressed'. - */ - public void setCompressed( - final boolean compressed) { - this._compressed = compressed; - this._has_compressed = true; - } - - /** - * 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( - final java.lang.String id) { - this._id = id; + } else if (temp._id != null) + return false; + return true; } - - /** - * Sets the value of field 'objectref'. The field 'objectref' - * has the following description: Object the arbitrary data is - * associated with - * - * - * @param objectref the value of field 'objectref'. - */ - public void setObjectref( - final java.lang.Object objectref) { - this._objectref = objectref; + return false; + } + + /** + * Returns the value of field 'compressed'. The field 'compressed' has the + * following description: true implies data will be decompresses with Zip + * before presenting to application + * + * @return the value of field 'Compressed'. + */ + public boolean getCompressed() { + return this._compressed; + } + + /** + * Returns the value of field 'id'. The field 'id' has the following + * description: Primary Key for vamsas object referencing + * + * + * @return the value of field 'Id'. + */ + public java.lang.String getId() { + return this._id; + } + + /** + * Returns the value of field 'objectref'. The field 'objectref' has the + * following description: Object the arbitrary data is associated with + * + * + * @return the value of field 'Objectref'. + */ + public java.lang.Object getObjectref() { + return this._objectref; + } + + /** + * Returns the value of field 'type'. The field 'type' has the following + * description: Type of arbitrary data - TODO: decide format - use (extended) + * MIME types ? + * + * @return the value of field 'Type'. + */ + public java.lang.String getType() { + return this._type; + } + + /** + * Method hasCompressed. + * + * @return true if at least one Compressed has been added + */ + public boolean hasCompressed() { + return this._has_compressed; + } + + /** + * Overrides the java.lang.Object.hashCode method. + *

+ * The following steps came from Effective Java Programming Language + * Guide by Joshua Bloch, Chapter 3 + * + * @return a hash code value for the object. + */ + public int hashCode() { + int result = super.hashCode(); + + long tmp; + result = 37 * result + (_compressed ? 0 : 1); + if (_type != null && !org.castor.util.CycleBreaker.startingToCycle(_type)) { + result = 37 * result + _type.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_type); } - - /** - * Sets the value of field 'type'. The field 'type' has the - * following description: Type of arbitrary data - TODO: decide - * format - use - * (extended) MIME types ? - * - * @param type the value of field 'type'. - */ - public void setType( - final java.lang.String type) { - this._type = type; + if (_objectref != null + && !org.castor.util.CycleBreaker.startingToCycle(_objectref)) { + result = 37 * result + _objectref.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_objectref); } - - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled uk.ac.vamsas.objects.core.AppData - */ - public static uk.ac.vamsas.objects.core.AppData unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (uk.ac.vamsas.objects.core.AppData) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.Attachment.class, reader); + if (_id != null && !org.castor.util.CycleBreaker.startingToCycle(_id)) { + result = 37 * result + _id.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_id); } - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); + return result; + } + + /** + * Returns the value of field 'compressed'. The field 'compressed' has the + * following description: true implies data will be decompresses with Zip + * before presenting to application + * + * @return the value of field 'Compressed'. + */ + public boolean isCompressed() { + return this._compressed; + } + + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() { + try { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) { + return false; } + return true; + } + + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, out); + } + + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, handler); + } + + /** + * Sets the value of field 'compressed'. The field 'compressed' has the + * following description: true implies data will be decompresses with Zip + * before presenting to application + * + * @param compressed + * the value of field 'compressed'. + */ + public void setCompressed(final boolean compressed) { + this._compressed = compressed; + this._has_compressed = true; + } + + /** + * 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(final java.lang.String id) { + this._id = id; + } + + /** + * Sets the value of field 'objectref'. The field 'objectref' has the + * following description: Object the arbitrary data is associated with + * + * + * @param objectref + * the value of field 'objectref'. + */ + public void setObjectref(final java.lang.Object objectref) { + this._objectref = objectref; + } + + /** + * Sets the value of field 'type'. The field 'type' has the following + * description: Type of arbitrary data - TODO: decide format - use (extended) + * MIME types ? + * + * @param type + * the value of field 'type'. + */ + public void setType(final java.lang.String type) { + this._type = type; + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @return the unmarshaled uk.ac.vamsas.objects.core.AppData + */ + public static uk.ac.vamsas.objects.core.AppData unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + return (uk.ac.vamsas.objects.core.AppData) Unmarshaller.unmarshal( + uk.ac.vamsas.objects.core.Attachment.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/uk/ac/vamsas/objects/core/Common.java b/src/uk/ac/vamsas/objects/core/Common.java index cda263d..03e74ba 100644 --- a/src/uk/ac/vamsas/objects/core/Common.java +++ b/src/uk/ac/vamsas/objects/core/Common.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import org.exolab.castor.xml.Marshaller; @@ -19,136 +33,133 @@ import org.exolab.castor.xml.Unmarshaller; * * @version $Revision$ $Date$ */ -public class Common extends uk.ac.vamsas.objects.core.AppData -implements java.io.Serializable -{ - - - //----------------/ - //- Constructors -/ - //----------------/ - - public Common() { - super(); - } +public class Common extends uk.ac.vamsas.objects.core.AppData implements + java.io.Serializable { + // ----------------/ + // - Constructors -/ + // ----------------/ - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Overrides the java.lang.Object.equals method. - * - * @param obj - * @return true if the objects are equal. - */ - public boolean equals( - final java.lang.Object obj) { - if ( this == obj ) - return true; - - if (super.equals(obj)==false) - return false; - - if (obj instanceof Common) { - - return true; - } - return false; - } + public Common() { + super(); + } - /** - * Overrides the java.lang.Object.hashCode method. - *

- * The following steps came from Effective Java Programming - * Language Guide by Joshua Bloch, Chapter 3 - * - * @return a hash code value for the object. - */ - public int hashCode( - ) { - int result = super.hashCode(); - - long tmp; - - return result; - } + // -----------/ + // - Methods -/ + // -----------/ - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { - return false; - } - return true; - } + /** + * Overrides the java.lang.Object.equals method. + * + * @param obj + * @return true if the objects are equal. + */ + public boolean equals(final java.lang.Object obj) { + if (this == obj) + return true; - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } + if (super.equals(obj) == false) + return false; - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } + if (obj instanceof Common) { - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled uk.ac.vamsas.objects.core.AppData - */ - public static uk.ac.vamsas.objects.core.AppData unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (uk.ac.vamsas.objects.core.AppData) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.Common.class, reader); + return true; } - - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); + return false; + } + + /** + * Overrides the java.lang.Object.hashCode method. + *

+ * The following steps came from Effective Java Programming Language + * Guide by Joshua Bloch, Chapter 3 + * + * @return a hash code value for the object. + */ + public int hashCode() { + int result = super.hashCode(); + + long tmp; + + return result; + } + + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() { + try { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) { + return false; } + return true; + } + + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, out); + } + + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, handler); + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @return the unmarshaled uk.ac.vamsas.objects.core.AppData + */ + public static uk.ac.vamsas.objects.core.AppData unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + return (uk.ac.vamsas.objects.core.AppData) Unmarshaller.unmarshal( + uk.ac.vamsas.objects.core.Common.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/uk/ac/vamsas/objects/core/DataSet.java b/src/uk/ac/vamsas/objects/core/DataSet.java index ae4506b..150771c 100644 --- a/src/uk/ac/vamsas/objects/core/DataSet.java +++ b/src/uk/ac/vamsas/objects/core/DataSet.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import org.exolab.castor.xml.Marshaller; @@ -17,1362 +31,1415 @@ import org.exolab.castor.xml.Unmarshaller; /** * Class DataSet. * - * @version $Revision$ $Date$ + * @version $Revision$ $Date: 2007-06-28 14:51:44 +0100 (Thu, 28 Jun 2007) + * $ */ -public class DataSet extends uk.ac.vamsas.client.Vobject -implements java.io.Serializable -{ - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Primary Key for vamsas object referencing - */ - private java.lang.String _id; - - /** - * Field _sequenceList. - */ - private java.util.Vector _sequenceList; - - /** - * Field _sequenceMappingList. - */ - private java.util.Vector _sequenceMappingList; - - /** - * Field _dataSetAnnotationsList. - */ - private java.util.Vector _dataSetAnnotationsList; - - /** - * Field _alignmentList. - */ - private java.util.Vector _alignmentList; - - /** - * Field _treeList. - */ - private java.util.Vector _treeList; - - /** - * Field _provenance. - */ - private uk.ac.vamsas.objects.core.Provenance _provenance; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public DataSet() { - super(); - this._sequenceList = new java.util.Vector(); - this._sequenceMappingList = new java.util.Vector(); - this._dataSetAnnotationsList = new java.util.Vector(); - this._alignmentList = new java.util.Vector(); - this._treeList = new java.util.Vector(); - } - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * - * - * @param vAlignment - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addAlignment( - final uk.ac.vamsas.objects.core.Alignment vAlignment) - throws java.lang.IndexOutOfBoundsException { - this._alignmentList.addElement(vAlignment); - } - - /** - * - * - * @param index - * @param vAlignment - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addAlignment( - final int index, - final uk.ac.vamsas.objects.core.Alignment vAlignment) - throws java.lang.IndexOutOfBoundsException { - this._alignmentList.add(index, vAlignment); - } - - /** - * - * - * @param vDataSetAnnotations - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addDataSetAnnotations( - final uk.ac.vamsas.objects.core.DataSetAnnotations vDataSetAnnotations) - throws java.lang.IndexOutOfBoundsException { - this._dataSetAnnotationsList.addElement(vDataSetAnnotations); - } - - /** - * - * - * @param index - * @param vDataSetAnnotations - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addDataSetAnnotations( - final int index, - final uk.ac.vamsas.objects.core.DataSetAnnotations vDataSetAnnotations) - throws java.lang.IndexOutOfBoundsException { - this._dataSetAnnotationsList.add(index, vDataSetAnnotations); - } - - /** - * - * - * @param vSequence - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addSequence( - final uk.ac.vamsas.objects.core.Sequence vSequence) - throws java.lang.IndexOutOfBoundsException { - this._sequenceList.addElement(vSequence); - } - - /** - * - * - * @param index - * @param vSequence - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addSequence( - final int index, - final uk.ac.vamsas.objects.core.Sequence vSequence) - throws java.lang.IndexOutOfBoundsException { - this._sequenceList.add(index, vSequence); - } - - /** - * - * - * @param vSequenceMapping - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addSequenceMapping( - final uk.ac.vamsas.objects.core.SequenceMapping vSequenceMapping) - throws java.lang.IndexOutOfBoundsException { - this._sequenceMappingList.addElement(vSequenceMapping); - } - - /** - * - * - * @param index - * @param vSequenceMapping - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addSequenceMapping( - final int index, - final uk.ac.vamsas.objects.core.SequenceMapping vSequenceMapping) - throws java.lang.IndexOutOfBoundsException { - this._sequenceMappingList.add(index, vSequenceMapping); - } - - /** - * - * - * @param vTree - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addTree( - final uk.ac.vamsas.objects.core.Tree vTree) - throws java.lang.IndexOutOfBoundsException { - this._treeList.addElement(vTree); - } - - /** - * - * - * @param index - * @param vTree - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addTree( - final int index, - final uk.ac.vamsas.objects.core.Tree vTree) - throws java.lang.IndexOutOfBoundsException { - this._treeList.add(index, vTree); - } - - /** - * Method enumerateAlignment. - * - * @return an Enumeration over all - * uk.ac.vamsas.objects.core.Alignment elements - */ - public java.util.Enumeration enumerateAlignment( - ) { - return this._alignmentList.elements(); - } - - /** - * Method enumerateDataSetAnnotations. - * - * @return an Enumeration over all - * uk.ac.vamsas.objects.core.DataSetAnnotations elements - */ - public java.util.Enumeration enumerateDataSetAnnotations( - ) { - return this._dataSetAnnotationsList.elements(); - } - - /** - * Method enumerateSequence. - * - * @return an Enumeration over all - * uk.ac.vamsas.objects.core.Sequence elements - */ - public java.util.Enumeration enumerateSequence( - ) { - return this._sequenceList.elements(); - } - - /** - * Method enumerateSequenceMapping. - * - * @return an Enumeration over all - * uk.ac.vamsas.objects.core.SequenceMapping elements - */ - public java.util.Enumeration enumerateSequenceMapping( - ) { - return this._sequenceMappingList.elements(); - } - - /** - * Method enumerateTree. - * - * @return an Enumeration over all - * uk.ac.vamsas.objects.core.Tree elements - */ - public java.util.Enumeration enumerateTree( - ) { - return this._treeList.elements(); - } - - /** - * Overrides the java.lang.Object.equals method. - * - * @param obj - * @return true if the objects are equal. - */ - public boolean equals( - final java.lang.Object obj) { - if ( this == obj ) - return true; - - if (super.equals(obj)==false) +public class DataSet extends uk.ac.vamsas.client.Vobject implements + java.io.Serializable { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Primary Key for vamsas object referencing + */ + private java.lang.String _id; + + /** + * Field _sequenceList. + */ + private java.util.Vector _sequenceList; + + /** + * Field _sequenceMappingList. + */ + private java.util.Vector _sequenceMappingList; + + /** + * Field _dataSetAnnotationsList. + */ + private java.util.Vector _dataSetAnnotationsList; + + /** + * Field _alignmentList. + */ + private java.util.Vector _alignmentList; + + /** + * Field _treeList. + */ + private java.util.Vector _treeList; + + /** + * Field _provenance. + */ + private uk.ac.vamsas.objects.core.Provenance _provenance; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public DataSet() { + super(); + this._sequenceList = new java.util.Vector(); + this._sequenceMappingList = new java.util.Vector(); + this._dataSetAnnotationsList = new java.util.Vector(); + this._alignmentList = new java.util.Vector(); + this._treeList = new java.util.Vector(); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * + * + * @param vAlignment + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addAlignment(final uk.ac.vamsas.objects.core.Alignment vAlignment) + throws java.lang.IndexOutOfBoundsException { + this._alignmentList.addElement(vAlignment); + } + + /** + * + * + * @param index + * @param vAlignment + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addAlignment(final int index, + final uk.ac.vamsas.objects.core.Alignment vAlignment) + throws java.lang.IndexOutOfBoundsException { + this._alignmentList.add(index, vAlignment); + } + + /** + * + * + * @param vDataSetAnnotations + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addDataSetAnnotations( + final uk.ac.vamsas.objects.core.DataSetAnnotations vDataSetAnnotations) + throws java.lang.IndexOutOfBoundsException { + this._dataSetAnnotationsList.addElement(vDataSetAnnotations); + } + + /** + * + * + * @param index + * @param vDataSetAnnotations + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addDataSetAnnotations(final int index, + final uk.ac.vamsas.objects.core.DataSetAnnotations vDataSetAnnotations) + throws java.lang.IndexOutOfBoundsException { + this._dataSetAnnotationsList.add(index, vDataSetAnnotations); + } + + /** + * + * + * @param vSequence + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addSequence(final uk.ac.vamsas.objects.core.Sequence vSequence) + throws java.lang.IndexOutOfBoundsException { + this._sequenceList.addElement(vSequence); + } + + /** + * + * + * @param index + * @param vSequence + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addSequence(final int index, + final uk.ac.vamsas.objects.core.Sequence vSequence) + throws java.lang.IndexOutOfBoundsException { + this._sequenceList.add(index, vSequence); + } + + /** + * + * + * @param vSequenceMapping + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addSequenceMapping( + final uk.ac.vamsas.objects.core.SequenceMapping vSequenceMapping) + throws java.lang.IndexOutOfBoundsException { + this._sequenceMappingList.addElement(vSequenceMapping); + } + + /** + * + * + * @param index + * @param vSequenceMapping + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addSequenceMapping(final int index, + final uk.ac.vamsas.objects.core.SequenceMapping vSequenceMapping) + throws java.lang.IndexOutOfBoundsException { + this._sequenceMappingList.add(index, vSequenceMapping); + } + + /** + * + * + * @param vTree + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addTree(final uk.ac.vamsas.objects.core.Tree vTree) + throws java.lang.IndexOutOfBoundsException { + this._treeList.addElement(vTree); + } + + /** + * + * + * @param index + * @param vTree + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addTree(final int index, + final uk.ac.vamsas.objects.core.Tree vTree) + throws java.lang.IndexOutOfBoundsException { + this._treeList.add(index, vTree); + } + + /** + * Method enumerateAlignment. + * + * @return an Enumeration over all uk.ac.vamsas.objects.core.Alignment + * elements + */ + public java.util.Enumeration enumerateAlignment() { + return this._alignmentList.elements(); + } + + /** + * Method enumerateDataSetAnnotations. + * + * @return an Enumeration over all + * uk.ac.vamsas.objects.core.DataSetAnnotations elements + */ + public java.util.Enumeration enumerateDataSetAnnotations() { + return this._dataSetAnnotationsList.elements(); + } + + /** + * Method enumerateSequence. + * + * @return an Enumeration over all uk.ac.vamsas.objects.core.Sequence elements + */ + public java.util.Enumeration enumerateSequence() { + return this._sequenceList.elements(); + } + + /** + * Method enumerateSequenceMapping. + * + * @return an Enumeration over all uk.ac.vamsas.objects.core.SequenceMapping + * elements + */ + public java.util.Enumeration enumerateSequenceMapping() { + return this._sequenceMappingList.elements(); + } + + /** + * Method enumerateTree. + * + * @return an Enumeration over all uk.ac.vamsas.objects.core.Tree elements + */ + public java.util.Enumeration enumerateTree() { + return this._treeList.elements(); + } + + /** + * Overrides the java.lang.Object.equals method. + * + * @param obj + * @return true if the objects are equal. + */ + public boolean equals(final java.lang.Object obj) { + if (this == obj) + return true; + + if (super.equals(obj) == false) + return false; + + if (obj instanceof DataSet) { + + DataSet temp = (DataSet) obj; + boolean thcycle; + boolean tmcycle; + if (this._id != null) { + if (temp._id == null) + return false; + if (this._id != temp._id) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._id); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._id); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._id); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); + } + ; return false; - - if (obj instanceof DataSet) { - - DataSet temp = (DataSet)obj; - boolean thcycle; - boolean tmcycle; - if (this._id != null) { - if (temp._id == null) return false; - if (this._id != temp._id) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._id); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._id); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._id); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); }; - return false; - } - if (!thcycle) { - if (!this._id.equals(temp._id)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._id); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._id); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); - } - } - } else if (temp._id != null) - return false; - if (this._sequenceList != null) { - if (temp._sequenceList == null) return false; - if (this._sequenceList != temp._sequenceList) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._sequenceList); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._sequenceList); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._sequenceList); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._sequenceList); }; - return false; - } - if (!thcycle) { - if (!this._sequenceList.equals(temp._sequenceList)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._sequenceList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._sequenceList); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._sequenceList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._sequenceList); - } - } - } else if (temp._sequenceList != null) - return false; - if (this._sequenceMappingList != null) { - if (temp._sequenceMappingList == null) return false; - if (this._sequenceMappingList != temp._sequenceMappingList) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._sequenceMappingList); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._sequenceMappingList); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._sequenceMappingList); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._sequenceMappingList); }; - return false; - } - if (!thcycle) { - if (!this._sequenceMappingList.equals(temp._sequenceMappingList)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._sequenceMappingList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._sequenceMappingList); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._sequenceMappingList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._sequenceMappingList); - } - } - } else if (temp._sequenceMappingList != null) - return false; - if (this._dataSetAnnotationsList != null) { - if (temp._dataSetAnnotationsList == null) return false; - if (this._dataSetAnnotationsList != temp._dataSetAnnotationsList) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._dataSetAnnotationsList); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._dataSetAnnotationsList); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._dataSetAnnotationsList); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._dataSetAnnotationsList); }; - return false; - } - if (!thcycle) { - if (!this._dataSetAnnotationsList.equals(temp._dataSetAnnotationsList)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._dataSetAnnotationsList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._dataSetAnnotationsList); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._dataSetAnnotationsList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._dataSetAnnotationsList); - } - } - } else if (temp._dataSetAnnotationsList != null) - return false; - if (this._alignmentList != null) { - if (temp._alignmentList == null) return false; - if (this._alignmentList != temp._alignmentList) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._alignmentList); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._alignmentList); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._alignmentList); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._alignmentList); }; - return false; - } - if (!thcycle) { - if (!this._alignmentList.equals(temp._alignmentList)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._alignmentList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._alignmentList); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._alignmentList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._alignmentList); - } - } - } else if (temp._alignmentList != null) - return false; - if (this._treeList != null) { - if (temp._treeList == null) return false; - if (this._treeList != temp._treeList) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._treeList); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._treeList); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._treeList); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._treeList); }; - return false; - } - if (!thcycle) { - if (!this._treeList.equals(temp._treeList)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._treeList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._treeList); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._treeList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._treeList); - } - } - } else if (temp._treeList != null) - return false; - if (this._provenance != null) { - if (temp._provenance == null) return false; - if (this._provenance != temp._provenance) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._provenance); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._provenance); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance); }; - return false; - } - if (!thcycle) { - if (!this._provenance.equals(temp._provenance)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance); - } - } - } else if (temp._provenance != null) - return false; - return true; + } + if (!thcycle) { + if (!this._id.equals(temp._id)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._id); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._id); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); + } } + } else if (temp._id != null) return false; - } - - /** - * Method getAlignment. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the uk.ac.vamsas.objects.core.Alignment - * at the given index - */ - public uk.ac.vamsas.objects.core.Alignment getAlignment( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._alignmentList.size()) { - throw new IndexOutOfBoundsException("getAlignment: Index value '" + index + "' not in range [0.." + (this._alignmentList.size() - 1) + "]"); - } - - return (uk.ac.vamsas.objects.core.Alignment) _alignmentList.get(index); - } - - /** - * Method getAlignment.Returns the contents of the collection - * in an Array.

Note: Just in case the collection contents - * are changing in another thread, we pass a 0-length Array of - * the correct type into the API call. This way we know - * that the Array returned is of exactly the correct length. - * - * @return this collection as an Array - */ - public uk.ac.vamsas.objects.core.Alignment[] getAlignment( - ) { - uk.ac.vamsas.objects.core.Alignment[] array = new uk.ac.vamsas.objects.core.Alignment[0]; - return (uk.ac.vamsas.objects.core.Alignment[]) this._alignmentList.toArray(array); - } - - /** - * Method getAlignmentAsReference.Returns a reference to - * '_alignmentList'. No type checking is performed on any - * modifications to the Vector. - * - * @return a reference to the Vector backing this class - */ - public java.util.Vector getAlignmentAsReference( - ) { - return this._alignmentList; - } - - /** - * Method getAlignmentCount. - * - * @return the size of this collection - */ - public int getAlignmentCount( - ) { - return this._alignmentList.size(); - } - - /** - * Method getDataSetAnnotations. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the - * uk.ac.vamsas.objects.core.DataSetAnnotations at the given - * index - */ - public uk.ac.vamsas.objects.core.DataSetAnnotations getDataSetAnnotations( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._dataSetAnnotationsList.size()) { - throw new IndexOutOfBoundsException("getDataSetAnnotations: Index value '" + index + "' not in range [0.." + (this._dataSetAnnotationsList.size() - 1) + "]"); - } - - return (uk.ac.vamsas.objects.core.DataSetAnnotations) _dataSetAnnotationsList.get(index); - } - - /** - * Method getDataSetAnnotations.Returns the contents of the - * collection in an Array.

Note: Just in case the - * collection contents are changing in another thread, we pass - * a 0-length Array of the correct type into the API call. - * This way we know that the Array returned is of - * exactly the correct length. - * - * @return this collection as an Array - */ - public uk.ac.vamsas.objects.core.DataSetAnnotations[] getDataSetAnnotations( - ) { - uk.ac.vamsas.objects.core.DataSetAnnotations[] array = new uk.ac.vamsas.objects.core.DataSetAnnotations[0]; - return (uk.ac.vamsas.objects.core.DataSetAnnotations[]) this._dataSetAnnotationsList.toArray(array); - } - - /** - * Method getDataSetAnnotationsAsReference.Returns a reference - * to '_dataSetAnnotationsList'. No type checking is performed - * on any modifications to the Vector. - * - * @return a reference to the Vector backing this class - */ - public java.util.Vector getDataSetAnnotationsAsReference( - ) { - return this._dataSetAnnotationsList; - } - - /** - * Method getDataSetAnnotationsCount. - * - * @return the size of this collection - */ - public int getDataSetAnnotationsCount( - ) { - return this._dataSetAnnotationsList.size(); - } - - /** - * Returns the value of field 'id'. The field 'id' has the - * following description: Primary Key for vamsas object - * referencing - * - * @return the value of field 'Id'. - */ - public java.lang.String getId( - ) { - return this._id; - } - - /** - * Returns the value of field 'provenance'. - * - * @return the value of field 'Provenance'. - */ - public uk.ac.vamsas.objects.core.Provenance getProvenance( - ) { - return this._provenance; - } - - /** - * Method getSequence. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the uk.ac.vamsas.objects.core.Sequence - * at the given index - */ - public uk.ac.vamsas.objects.core.Sequence getSequence( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._sequenceList.size()) { - throw new IndexOutOfBoundsException("getSequence: Index value '" + index + "' not in range [0.." + (this._sequenceList.size() - 1) + "]"); - } - - return (uk.ac.vamsas.objects.core.Sequence) _sequenceList.get(index); - } - - /** - * Method getSequence.Returns the contents of the collection in - * an Array.

Note: Just in case the collection contents - * are changing in another thread, we pass a 0-length Array of - * the correct type into the API call. This way we know - * that the Array returned is of exactly the correct length. - * - * @return this collection as an Array - */ - public uk.ac.vamsas.objects.core.Sequence[] getSequence( - ) { - uk.ac.vamsas.objects.core.Sequence[] array = new uk.ac.vamsas.objects.core.Sequence[0]; - return (uk.ac.vamsas.objects.core.Sequence[]) this._sequenceList.toArray(array); - } - - /** - * Method getSequenceAsReference.Returns a reference to - * '_sequenceList'. No type checking is performed on any - * modifications to the Vector. - * - * @return a reference to the Vector backing this class - */ - public java.util.Vector getSequenceAsReference( - ) { - return this._sequenceList; - } - - /** - * Method getSequenceCount. - * - * @return the size of this collection - */ - public int getSequenceCount( - ) { - return this._sequenceList.size(); - } - - /** - * Method getSequenceMapping. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the - * uk.ac.vamsas.objects.core.SequenceMapping at the given index - */ - public uk.ac.vamsas.objects.core.SequenceMapping getSequenceMapping( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._sequenceMappingList.size()) { - throw new IndexOutOfBoundsException("getSequenceMapping: Index value '" + index + "' not in range [0.." + (this._sequenceMappingList.size() - 1) + "]"); - } - - return (uk.ac.vamsas.objects.core.SequenceMapping) _sequenceMappingList.get(index); - } - - /** - * Method getSequenceMapping.Returns the contents of the - * collection in an Array.

Note: Just in case the - * collection contents are changing in another thread, we pass - * a 0-length Array of the correct type into the API call. - * This way we know that the Array returned is of - * exactly the correct length. - * - * @return this collection as an Array - */ - public uk.ac.vamsas.objects.core.SequenceMapping[] getSequenceMapping( - ) { - uk.ac.vamsas.objects.core.SequenceMapping[] array = new uk.ac.vamsas.objects.core.SequenceMapping[0]; - return (uk.ac.vamsas.objects.core.SequenceMapping[]) this._sequenceMappingList.toArray(array); - } - - /** - * Method getSequenceMappingAsReference.Returns a reference to - * '_sequenceMappingList'. No type checking is performed on any - * modifications to the Vector. - * - * @return a reference to the Vector backing this class - */ - public java.util.Vector getSequenceMappingAsReference( - ) { - return this._sequenceMappingList; - } - - /** - * Method getSequenceMappingCount. - * - * @return the size of this collection - */ - public int getSequenceMappingCount( - ) { - return this._sequenceMappingList.size(); - } - - /** - * Method getTree. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the uk.ac.vamsas.objects.core.Tree at - * the given index - */ - public uk.ac.vamsas.objects.core.Tree getTree( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._treeList.size()) { - throw new IndexOutOfBoundsException("getTree: Index value '" + index + "' not in range [0.." + (this._treeList.size() - 1) + "]"); - } - - return (uk.ac.vamsas.objects.core.Tree) _treeList.get(index); - } - - /** - * Method getTree.Returns the contents of the collection in an - * Array.

Note: Just in case the collection contents are - * changing in another thread, we pass a 0-length Array of the - * correct type into the API call. This way we know - * that the Array returned is of exactly the correct length. - * - * @return this collection as an Array - */ - public uk.ac.vamsas.objects.core.Tree[] getTree( - ) { - uk.ac.vamsas.objects.core.Tree[] array = new uk.ac.vamsas.objects.core.Tree[0]; - return (uk.ac.vamsas.objects.core.Tree[]) this._treeList.toArray(array); - } - - /** - * Method getTreeAsReference.Returns a reference to - * '_treeList'. No type checking is performed on any - * modifications to the Vector. - * - * @return a reference to the Vector backing this class - */ - public java.util.Vector getTreeAsReference( - ) { - return this._treeList; - } - - /** - * Method getTreeCount. - * - * @return the size of this collection - */ - public int getTreeCount( - ) { - return this._treeList.size(); - } - - /** - * Overrides the java.lang.Object.hashCode method. - *

- * The following steps came from Effective Java Programming - * Language Guide by Joshua Bloch, Chapter 3 - * - * @return a hash code value for the object. - */ - public int hashCode( - ) { - int result = super.hashCode(); - - long tmp; - if (_id != null - && !org.castor.util.CycleBreaker.startingToCycle(_id)) { - result = 37 * result + _id.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_id); - } - if (_sequenceList != null - && !org.castor.util.CycleBreaker.startingToCycle(_sequenceList)) { - result = 37 * result + _sequenceList.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_sequenceList); - } - if (_sequenceMappingList != null - && !org.castor.util.CycleBreaker.startingToCycle(_sequenceMappingList)) { - result = 37 * result + _sequenceMappingList.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_sequenceMappingList); - } - if (_dataSetAnnotationsList != null - && !org.castor.util.CycleBreaker.startingToCycle(_dataSetAnnotationsList)) { - result = 37 * result + _dataSetAnnotationsList.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_dataSetAnnotationsList); - } - if (_alignmentList != null - && !org.castor.util.CycleBreaker.startingToCycle(_alignmentList)) { - result = 37 * result + _alignmentList.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_alignmentList); - } - if (_treeList != null - && !org.castor.util.CycleBreaker.startingToCycle(_treeList)) { - result = 37 * result + _treeList.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_treeList); - } - if (_provenance != null - && !org.castor.util.CycleBreaker.startingToCycle(_provenance)) { - result = 37 * result + _provenance.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_provenance); - } - - return result; - } - - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { + if (this._sequenceList != null) { + if (temp._sequenceList == null) + return false; + if (this._sequenceList != temp._sequenceList) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._sequenceList); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._sequenceList); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker + .releaseCycleHandle(this._sequenceList); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._sequenceList); + } + ; return false; + } + if (!thcycle) { + if (!this._sequenceList.equals(temp._sequenceList)) { + org.castor.util.CycleBreaker + .releaseCycleHandle(this._sequenceList); + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._sequenceList); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._sequenceList); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._sequenceList); + } } - return true; - } - - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } - - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } - - /** - * Method removeAlignment. - * - * @param vAlignment - * @return true if the object was removed from the collection. - */ - public boolean removeAlignment( - final uk.ac.vamsas.objects.core.Alignment vAlignment) { - boolean removed = _alignmentList.remove(vAlignment); - return removed; - } - - /** - * Method removeAlignmentAt. - * - * @param index - * @return the element removed from the collection - */ - public uk.ac.vamsas.objects.core.Alignment removeAlignmentAt( - final int index) { - java.lang.Object obj = this._alignmentList.remove(index); - return (uk.ac.vamsas.objects.core.Alignment) obj; - } - - /** - */ - public void removeAllAlignment( - ) { - this._alignmentList.clear(); - } - - /** - */ - public void removeAllDataSetAnnotations( - ) { - this._dataSetAnnotationsList.clear(); - } - - /** - */ - public void removeAllSequence( - ) { - this._sequenceList.clear(); - } - - /** - */ - public void removeAllSequenceMapping( - ) { - this._sequenceMappingList.clear(); - } - - /** - */ - public void removeAllTree( - ) { - this._treeList.clear(); - } - - /** - * Method removeDataSetAnnotations. - * - * @param vDataSetAnnotations - * @return true if the object was removed from the collection. - */ - public boolean removeDataSetAnnotations( - final uk.ac.vamsas.objects.core.DataSetAnnotations vDataSetAnnotations) { - boolean removed = _dataSetAnnotationsList.remove(vDataSetAnnotations); - return removed; - } - - /** - * Method removeDataSetAnnotationsAt. - * - * @param index - * @return the element removed from the collection - */ - public uk.ac.vamsas.objects.core.DataSetAnnotations removeDataSetAnnotationsAt( - final int index) { - java.lang.Object obj = this._dataSetAnnotationsList.remove(index); - return (uk.ac.vamsas.objects.core.DataSetAnnotations) obj; - } - - /** - * Method removeSequence. - * - * @param vSequence - * @return true if the object was removed from the collection. - */ - public boolean removeSequence( - final uk.ac.vamsas.objects.core.Sequence vSequence) { - boolean removed = _sequenceList.remove(vSequence); - return removed; - } - - /** - * Method removeSequenceAt. - * - * @param index - * @return the element removed from the collection - */ - public uk.ac.vamsas.objects.core.Sequence removeSequenceAt( - final int index) { - java.lang.Object obj = this._sequenceList.remove(index); - return (uk.ac.vamsas.objects.core.Sequence) obj; - } - - /** - * Method removeSequenceMapping. - * - * @param vSequenceMapping - * @return true if the object was removed from the collection. - */ - public boolean removeSequenceMapping( - final uk.ac.vamsas.objects.core.SequenceMapping vSequenceMapping) { - boolean removed = _sequenceMappingList.remove(vSequenceMapping); - return removed; - } - - /** - * Method removeSequenceMappingAt. - * - * @param index - * @return the element removed from the collection - */ - public uk.ac.vamsas.objects.core.SequenceMapping removeSequenceMappingAt( - final int index) { - java.lang.Object obj = this._sequenceMappingList.remove(index); - return (uk.ac.vamsas.objects.core.SequenceMapping) obj; - } - - /** - * Method removeTree. - * - * @param vTree - * @return true if the object was removed from the collection. - */ - public boolean removeTree( - final uk.ac.vamsas.objects.core.Tree vTree) { - boolean removed = _treeList.remove(vTree); - return removed; - } - - /** - * Method removeTreeAt. - * - * @param index - * @return the element removed from the collection - */ - public uk.ac.vamsas.objects.core.Tree removeTreeAt( - final int index) { - java.lang.Object obj = this._treeList.remove(index); - return (uk.ac.vamsas.objects.core.Tree) obj; - } - - /** - * - * - * @param index - * @param vAlignment - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setAlignment( - final int index, - final uk.ac.vamsas.objects.core.Alignment vAlignment) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._alignmentList.size()) { - throw new IndexOutOfBoundsException("setAlignment: Index value '" + index + "' not in range [0.." + (this._alignmentList.size() - 1) + "]"); - } - - this._alignmentList.set(index, vAlignment); - } - - /** - * - * - * @param vAlignmentArray - */ - public void setAlignment( - final uk.ac.vamsas.objects.core.Alignment[] vAlignmentArray) { - //-- copy array - _alignmentList.clear(); - - for (int i = 0; i < vAlignmentArray.length; i++) { - this._alignmentList.add(vAlignmentArray[i]); - } - } - - /** - * Sets the value of '_alignmentList' by copying the given - * Vector. All elements will be checked for type safety. - * - * @param vAlignmentList the Vector to copy. - */ - public void setAlignment( - final java.util.Vector vAlignmentList) { - // copy vector - this._alignmentList.clear(); - - this._alignmentList.addAll(vAlignmentList); - } - - /** - * Sets the value of '_alignmentList' by setting it to the - * given Vector. No type checking is performed. - * @deprecated - * - * @param alignmentVector the Vector to set. - */ - public void setAlignmentAsReference( - final java.util.Vector alignmentVector) { - this._alignmentList = alignmentVector; - } - - /** - * - * - * @param index - * @param vDataSetAnnotations - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setDataSetAnnotations( - final int index, - final uk.ac.vamsas.objects.core.DataSetAnnotations vDataSetAnnotations) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._dataSetAnnotationsList.size()) { - throw new IndexOutOfBoundsException("setDataSetAnnotations: Index value '" + index + "' not in range [0.." + (this._dataSetAnnotationsList.size() - 1) + "]"); - } - - this._dataSetAnnotationsList.set(index, vDataSetAnnotations); - } - - /** - * - * - * @param vDataSetAnnotationsArray - */ - public void setDataSetAnnotations( - final uk.ac.vamsas.objects.core.DataSetAnnotations[] vDataSetAnnotationsArray) { - //-- copy array - _dataSetAnnotationsList.clear(); - - for (int i = 0; i < vDataSetAnnotationsArray.length; i++) { - this._dataSetAnnotationsList.add(vDataSetAnnotationsArray[i]); - } - } - - /** - * Sets the value of '_dataSetAnnotationsList' by copying the - * given Vector. All elements will be checked for type safety. - * - * @param vDataSetAnnotationsList the Vector to copy. - */ - public void setDataSetAnnotations( - final java.util.Vector vDataSetAnnotationsList) { - // copy vector - this._dataSetAnnotationsList.clear(); - - this._dataSetAnnotationsList.addAll(vDataSetAnnotationsList); - } - - /** - * Sets the value of '_dataSetAnnotationsList' by setting it to - * the given Vector. No type checking is performed. - * @deprecated - * - * @param dataSetAnnotationsVector the Vector to set. - */ - public void setDataSetAnnotationsAsReference( - final java.util.Vector dataSetAnnotationsVector) { - this._dataSetAnnotationsList = dataSetAnnotationsVector; - } - - /** - * 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( - final java.lang.String id) { - this._id = id; - } - - /** - * Sets the value of field 'provenance'. - * - * @param provenance the value of field 'provenance'. - */ - public void setProvenance( - final uk.ac.vamsas.objects.core.Provenance provenance) { - this._provenance = provenance; - } - - /** - * - * - * @param index - * @param vSequence - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setSequence( - final int index, - final uk.ac.vamsas.objects.core.Sequence vSequence) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._sequenceList.size()) { - throw new IndexOutOfBoundsException("setSequence: Index value '" + index + "' not in range [0.." + (this._sequenceList.size() - 1) + "]"); - } - - this._sequenceList.set(index, vSequence); - } - - /** - * - * - * @param vSequenceArray - */ - public void setSequence( - final uk.ac.vamsas.objects.core.Sequence[] vSequenceArray) { - //-- copy array - _sequenceList.clear(); - - for (int i = 0; i < vSequenceArray.length; i++) { - this._sequenceList.add(vSequenceArray[i]); + } else if (temp._sequenceList != null) + return false; + if (this._sequenceMappingList != null) { + if (temp._sequenceMappingList == null) + return false; + if (this._sequenceMappingList != temp._sequenceMappingList) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._sequenceMappingList); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._sequenceMappingList); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker + .releaseCycleHandle(this._sequenceMappingList); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._sequenceMappingList); + } + ; + return false; + } + if (!thcycle) { + if (!this._sequenceMappingList.equals(temp._sequenceMappingList)) { + org.castor.util.CycleBreaker + .releaseCycleHandle(this._sequenceMappingList); + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._sequenceMappingList); + return false; + } + org.castor.util.CycleBreaker + .releaseCycleHandle(this._sequenceMappingList); + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._sequenceMappingList); + } } - } - - /** - * Sets the value of '_sequenceList' by copying the given - * Vector. All elements will be checked for type safety. - * - * @param vSequenceList the Vector to copy. - */ - public void setSequence( - final java.util.Vector vSequenceList) { - // copy vector - this._sequenceList.clear(); - - this._sequenceList.addAll(vSequenceList); - } - - /** - * Sets the value of '_sequenceList' by setting it to the given - * Vector. No type checking is performed. - * @deprecated - * - * @param sequenceVector the Vector to set. - */ - public void setSequenceAsReference( - final java.util.Vector sequenceVector) { - this._sequenceList = sequenceVector; - } - - /** - * - * - * @param index - * @param vSequenceMapping - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setSequenceMapping( - final int index, - final uk.ac.vamsas.objects.core.SequenceMapping vSequenceMapping) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._sequenceMappingList.size()) { - throw new IndexOutOfBoundsException("setSequenceMapping: Index value '" + index + "' not in range [0.." + (this._sequenceMappingList.size() - 1) + "]"); + } else if (temp._sequenceMappingList != null) + return false; + if (this._dataSetAnnotationsList != null) { + if (temp._dataSetAnnotationsList == null) + return false; + if (this._dataSetAnnotationsList != temp._dataSetAnnotationsList) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._dataSetAnnotationsList); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._dataSetAnnotationsList); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker + .releaseCycleHandle(this._dataSetAnnotationsList); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._dataSetAnnotationsList); + } + ; + return false; + } + if (!thcycle) { + if (!this._dataSetAnnotationsList + .equals(temp._dataSetAnnotationsList)) { + org.castor.util.CycleBreaker + .releaseCycleHandle(this._dataSetAnnotationsList); + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._dataSetAnnotationsList); + return false; + } + org.castor.util.CycleBreaker + .releaseCycleHandle(this._dataSetAnnotationsList); + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._dataSetAnnotationsList); + } } - - this._sequenceMappingList.set(index, vSequenceMapping); - } - - /** - * - * - * @param vSequenceMappingArray - */ - public void setSequenceMapping( - final uk.ac.vamsas.objects.core.SequenceMapping[] vSequenceMappingArray) { - //-- copy array - _sequenceMappingList.clear(); - - for (int i = 0; i < vSequenceMappingArray.length; i++) { - this._sequenceMappingList.add(vSequenceMappingArray[i]); + } else if (temp._dataSetAnnotationsList != null) + return false; + if (this._alignmentList != null) { + if (temp._alignmentList == null) + return false; + if (this._alignmentList != temp._alignmentList) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._alignmentList); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._alignmentList); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker + .releaseCycleHandle(this._alignmentList); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._alignmentList); + } + ; + return false; + } + if (!thcycle) { + if (!this._alignmentList.equals(temp._alignmentList)) { + org.castor.util.CycleBreaker + .releaseCycleHandle(this._alignmentList); + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._alignmentList); + return false; + } + org.castor.util.CycleBreaker + .releaseCycleHandle(this._alignmentList); + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._alignmentList); + } } - } - - /** - * Sets the value of '_sequenceMappingList' by copying the - * given Vector. All elements will be checked for type safety. - * - * @param vSequenceMappingList the Vector to copy. - */ - public void setSequenceMapping( - final java.util.Vector vSequenceMappingList) { - // copy vector - this._sequenceMappingList.clear(); - - this._sequenceMappingList.addAll(vSequenceMappingList); - } - - /** - * Sets the value of '_sequenceMappingList' by setting it to - * the given Vector. No type checking is performed. - * @deprecated - * - * @param sequenceMappingVector the Vector to set. - */ - public void setSequenceMappingAsReference( - final java.util.Vector sequenceMappingVector) { - this._sequenceMappingList = sequenceMappingVector; - } - - /** - * - * - * @param index - * @param vTree - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setTree( - final int index, - final uk.ac.vamsas.objects.core.Tree vTree) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._treeList.size()) { - throw new IndexOutOfBoundsException("setTree: Index value '" + index + "' not in range [0.." + (this._treeList.size() - 1) + "]"); + } else if (temp._alignmentList != null) + return false; + if (this._treeList != null) { + if (temp._treeList == null) + return false; + if (this._treeList != temp._treeList) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._treeList); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._treeList); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._treeList); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._treeList); + } + ; + return false; + } + if (!thcycle) { + if (!this._treeList.equals(temp._treeList)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._treeList); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._treeList); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._treeList); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._treeList); + } } - - this._treeList.set(index, vTree); - } - - /** - * - * - * @param vTreeArray - */ - public void setTree( - final uk.ac.vamsas.objects.core.Tree[] vTreeArray) { - //-- copy array - _treeList.clear(); - - for (int i = 0; i < vTreeArray.length; i++) { - this._treeList.add(vTreeArray[i]); + } else if (temp._treeList != null) + return false; + if (this._provenance != null) { + if (temp._provenance == null) + return false; + if (this._provenance != temp._provenance) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._provenance); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._provenance); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance); + } + ; + return false; + } + if (!thcycle) { + if (!this._provenance.equals(temp._provenance)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance); + } } - } - - /** - * Sets the value of '_treeList' by copying the given Vector. - * All elements will be checked for type safety. - * - * @param vTreeList the Vector to copy. - */ - public void setTree( - final java.util.Vector vTreeList) { - // copy vector - this._treeList.clear(); - - this._treeList.addAll(vTreeList); - } - - /** - * Sets the value of '_treeList' by setting it to the given - * Vector. No type checking is performed. - * @deprecated - * - * @param treeVector the Vector to set. - */ - public void setTreeAsReference( - final java.util.Vector treeVector) { - this._treeList = treeVector; - } - - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled uk.ac.vamsas.objects.core.DataSet - */ - public static uk.ac.vamsas.objects.core.DataSet unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (uk.ac.vamsas.objects.core.DataSet) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.DataSet.class, reader); - } - - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); - } + } else if (temp._provenance != null) + return false; + return true; + } + return false; + } + + /** + * Method getAlignment. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the uk.ac.vamsas.objects.core.Alignment at the given + * index + */ + public uk.ac.vamsas.objects.core.Alignment getAlignment(final int index) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._alignmentList.size()) { + throw new IndexOutOfBoundsException("getAlignment: Index value '" + index + + "' not in range [0.." + (this._alignmentList.size() - 1) + "]"); + } + + return (uk.ac.vamsas.objects.core.Alignment) _alignmentList.get(index); + } + + /** + * Method getAlignment.Returns the contents of the collection in an Array. + *

+ * Note: Just in case the collection contents are changing in another thread, + * we pass a 0-length Array of the correct type into the API call. This way we + * know that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public uk.ac.vamsas.objects.core.Alignment[] getAlignment() { + uk.ac.vamsas.objects.core.Alignment[] array = new uk.ac.vamsas.objects.core.Alignment[0]; + return (uk.ac.vamsas.objects.core.Alignment[]) this._alignmentList + .toArray(array); + } + + /** + * Method getAlignmentAsReference.Returns a reference to '_alignmentList'. No + * type checking is performed on any modifications to the Vector. + * + * @return a reference to the Vector backing this class + */ + public java.util.Vector getAlignmentAsReference() { + return this._alignmentList; + } + + /** + * Method getAlignmentCount. + * + * @return the size of this collection + */ + public int getAlignmentCount() { + return this._alignmentList.size(); + } + + /** + * Method getDataSetAnnotations. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the uk.ac.vamsas.objects.core.DataSetAnnotations at + * the given index + */ + public uk.ac.vamsas.objects.core.DataSetAnnotations getDataSetAnnotations( + final int index) throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._dataSetAnnotationsList.size()) { + throw new IndexOutOfBoundsException( + "getDataSetAnnotations: Index value '" + index + + "' not in range [0.." + + (this._dataSetAnnotationsList.size() - 1) + "]"); + } + + return (uk.ac.vamsas.objects.core.DataSetAnnotations) _dataSetAnnotationsList + .get(index); + } + + /** + * Method getDataSetAnnotations.Returns the contents of the collection in an + * Array. + *

+ * Note: Just in case the collection contents are changing in another thread, + * we pass a 0-length Array of the correct type into the API call. This way we + * know that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public uk.ac.vamsas.objects.core.DataSetAnnotations[] getDataSetAnnotations() { + uk.ac.vamsas.objects.core.DataSetAnnotations[] array = new uk.ac.vamsas.objects.core.DataSetAnnotations[0]; + return (uk.ac.vamsas.objects.core.DataSetAnnotations[]) this._dataSetAnnotationsList + .toArray(array); + } + + /** + * Method getDataSetAnnotationsAsReference.Returns a reference to + * '_dataSetAnnotationsList'. No type checking is performed on any + * modifications to the Vector. + * + * @return a reference to the Vector backing this class + */ + public java.util.Vector getDataSetAnnotationsAsReference() { + return this._dataSetAnnotationsList; + } + + /** + * Method getDataSetAnnotationsCount. + * + * @return the size of this collection + */ + public int getDataSetAnnotationsCount() { + return this._dataSetAnnotationsList.size(); + } + + /** + * Returns the value of field 'id'. The field 'id' has the following + * description: Primary Key for vamsas object referencing + * + * @return the value of field 'Id'. + */ + public java.lang.String getId() { + return this._id; + } + + /** + * Returns the value of field 'provenance'. + * + * @return the value of field 'Provenance'. + */ + public uk.ac.vamsas.objects.core.Provenance getProvenance() { + return this._provenance; + } + + /** + * Method getSequence. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the uk.ac.vamsas.objects.core.Sequence at the given + * index + */ + public uk.ac.vamsas.objects.core.Sequence getSequence(final int index) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._sequenceList.size()) { + throw new IndexOutOfBoundsException("getSequence: Index value '" + index + + "' not in range [0.." + (this._sequenceList.size() - 1) + "]"); + } + + return (uk.ac.vamsas.objects.core.Sequence) _sequenceList.get(index); + } + + /** + * Method getSequence.Returns the contents of the collection in an Array. + *

+ * Note: Just in case the collection contents are changing in another thread, + * we pass a 0-length Array of the correct type into the API call. This way we + * know that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public uk.ac.vamsas.objects.core.Sequence[] getSequence() { + uk.ac.vamsas.objects.core.Sequence[] array = new uk.ac.vamsas.objects.core.Sequence[0]; + return (uk.ac.vamsas.objects.core.Sequence[]) this._sequenceList + .toArray(array); + } + + /** + * Method getSequenceAsReference.Returns a reference to '_sequenceList'. No + * type checking is performed on any modifications to the Vector. + * + * @return a reference to the Vector backing this class + */ + public java.util.Vector getSequenceAsReference() { + return this._sequenceList; + } + + /** + * Method getSequenceCount. + * + * @return the size of this collection + */ + public int getSequenceCount() { + return this._sequenceList.size(); + } + + /** + * Method getSequenceMapping. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the uk.ac.vamsas.objects.core.SequenceMapping at the + * given index + */ + public uk.ac.vamsas.objects.core.SequenceMapping getSequenceMapping( + final int index) throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._sequenceMappingList.size()) { + throw new IndexOutOfBoundsException("getSequenceMapping: Index value '" + + index + "' not in range [0.." + + (this._sequenceMappingList.size() - 1) + "]"); + } + + return (uk.ac.vamsas.objects.core.SequenceMapping) _sequenceMappingList + .get(index); + } + + /** + * Method getSequenceMapping.Returns the contents of the collection in an + * Array. + *

+ * Note: Just in case the collection contents are changing in another thread, + * we pass a 0-length Array of the correct type into the API call. This way we + * know that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public uk.ac.vamsas.objects.core.SequenceMapping[] getSequenceMapping() { + uk.ac.vamsas.objects.core.SequenceMapping[] array = new uk.ac.vamsas.objects.core.SequenceMapping[0]; + return (uk.ac.vamsas.objects.core.SequenceMapping[]) this._sequenceMappingList + .toArray(array); + } + + /** + * Method getSequenceMappingAsReference.Returns a reference to + * '_sequenceMappingList'. No type checking is performed on any modifications + * to the Vector. + * + * @return a reference to the Vector backing this class + */ + public java.util.Vector getSequenceMappingAsReference() { + return this._sequenceMappingList; + } + + /** + * Method getSequenceMappingCount. + * + * @return the size of this collection + */ + public int getSequenceMappingCount() { + return this._sequenceMappingList.size(); + } + + /** + * Method getTree. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the uk.ac.vamsas.objects.core.Tree at the given index + */ + public uk.ac.vamsas.objects.core.Tree getTree(final int index) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._treeList.size()) { + throw new IndexOutOfBoundsException("getTree: Index value '" + index + + "' not in range [0.." + (this._treeList.size() - 1) + "]"); + } + + return (uk.ac.vamsas.objects.core.Tree) _treeList.get(index); + } + + /** + * Method getTree.Returns the contents of the collection in an Array. + *

+ * Note: Just in case the collection contents are changing in another thread, + * we pass a 0-length Array of the correct type into the API call. This way we + * know that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public uk.ac.vamsas.objects.core.Tree[] getTree() { + uk.ac.vamsas.objects.core.Tree[] array = new uk.ac.vamsas.objects.core.Tree[0]; + return (uk.ac.vamsas.objects.core.Tree[]) this._treeList.toArray(array); + } + + /** + * Method getTreeAsReference.Returns a reference to '_treeList'. No type + * checking is performed on any modifications to the Vector. + * + * @return a reference to the Vector backing this class + */ + public java.util.Vector getTreeAsReference() { + return this._treeList; + } + + /** + * Method getTreeCount. + * + * @return the size of this collection + */ + public int getTreeCount() { + return this._treeList.size(); + } + + /** + * Overrides the java.lang.Object.hashCode method. + *

+ * The following steps came from Effective Java Programming Language + * Guide by Joshua Bloch, Chapter 3 + * + * @return a hash code value for the object. + */ + public int hashCode() { + int result = super.hashCode(); + + long tmp; + if (_id != null && !org.castor.util.CycleBreaker.startingToCycle(_id)) { + result = 37 * result + _id.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_id); + } + if (_sequenceList != null + && !org.castor.util.CycleBreaker.startingToCycle(_sequenceList)) { + result = 37 * result + _sequenceList.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_sequenceList); + } + if (_sequenceMappingList != null + && !org.castor.util.CycleBreaker.startingToCycle(_sequenceMappingList)) { + result = 37 * result + _sequenceMappingList.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_sequenceMappingList); + } + if (_dataSetAnnotationsList != null + && !org.castor.util.CycleBreaker + .startingToCycle(_dataSetAnnotationsList)) { + result = 37 * result + _dataSetAnnotationsList.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_dataSetAnnotationsList); + } + if (_alignmentList != null + && !org.castor.util.CycleBreaker.startingToCycle(_alignmentList)) { + result = 37 * result + _alignmentList.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_alignmentList); + } + if (_treeList != null + && !org.castor.util.CycleBreaker.startingToCycle(_treeList)) { + result = 37 * result + _treeList.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_treeList); + } + if (_provenance != null + && !org.castor.util.CycleBreaker.startingToCycle(_provenance)) { + result = 37 * result + _provenance.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_provenance); + } + + return result; + } + + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() { + try { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) { + return false; + } + return true; + } + + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, out); + } + + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, handler); + } + + /** + * Method removeAlignment. + * + * @param vAlignment + * @return true if the object was removed from the collection. + */ + public boolean removeAlignment( + final uk.ac.vamsas.objects.core.Alignment vAlignment) { + boolean removed = _alignmentList.remove(vAlignment); + return removed; + } + + /** + * Method removeAlignmentAt. + * + * @param index + * @return the element removed from the collection + */ + public uk.ac.vamsas.objects.core.Alignment removeAlignmentAt(final int index) { + java.lang.Object obj = this._alignmentList.remove(index); + return (uk.ac.vamsas.objects.core.Alignment) obj; + } + + /** + */ + public void removeAllAlignment() { + this._alignmentList.clear(); + } + + /** + */ + public void removeAllDataSetAnnotations() { + this._dataSetAnnotationsList.clear(); + } + + /** + */ + public void removeAllSequence() { + this._sequenceList.clear(); + } + + /** + */ + public void removeAllSequenceMapping() { + this._sequenceMappingList.clear(); + } + + /** + */ + public void removeAllTree() { + this._treeList.clear(); + } + + /** + * Method removeDataSetAnnotations. + * + * @param vDataSetAnnotations + * @return true if the object was removed from the collection. + */ + public boolean removeDataSetAnnotations( + final uk.ac.vamsas.objects.core.DataSetAnnotations vDataSetAnnotations) { + boolean removed = _dataSetAnnotationsList.remove(vDataSetAnnotations); + return removed; + } + + /** + * Method removeDataSetAnnotationsAt. + * + * @param index + * @return the element removed from the collection + */ + public uk.ac.vamsas.objects.core.DataSetAnnotations removeDataSetAnnotationsAt( + final int index) { + java.lang.Object obj = this._dataSetAnnotationsList.remove(index); + return (uk.ac.vamsas.objects.core.DataSetAnnotations) obj; + } + + /** + * Method removeSequence. + * + * @param vSequence + * @return true if the object was removed from the collection. + */ + public boolean removeSequence( + final uk.ac.vamsas.objects.core.Sequence vSequence) { + boolean removed = _sequenceList.remove(vSequence); + return removed; + } + + /** + * Method removeSequenceAt. + * + * @param index + * @return the element removed from the collection + */ + public uk.ac.vamsas.objects.core.Sequence removeSequenceAt(final int index) { + java.lang.Object obj = this._sequenceList.remove(index); + return (uk.ac.vamsas.objects.core.Sequence) obj; + } + + /** + * Method removeSequenceMapping. + * + * @param vSequenceMapping + * @return true if the object was removed from the collection. + */ + public boolean removeSequenceMapping( + final uk.ac.vamsas.objects.core.SequenceMapping vSequenceMapping) { + boolean removed = _sequenceMappingList.remove(vSequenceMapping); + return removed; + } + + /** + * Method removeSequenceMappingAt. + * + * @param index + * @return the element removed from the collection + */ + public uk.ac.vamsas.objects.core.SequenceMapping removeSequenceMappingAt( + final int index) { + java.lang.Object obj = this._sequenceMappingList.remove(index); + return (uk.ac.vamsas.objects.core.SequenceMapping) obj; + } + + /** + * Method removeTree. + * + * @param vTree + * @return true if the object was removed from the collection. + */ + public boolean removeTree(final uk.ac.vamsas.objects.core.Tree vTree) { + boolean removed = _treeList.remove(vTree); + return removed; + } + + /** + * Method removeTreeAt. + * + * @param index + * @return the element removed from the collection + */ + public uk.ac.vamsas.objects.core.Tree removeTreeAt(final int index) { + java.lang.Object obj = this._treeList.remove(index); + return (uk.ac.vamsas.objects.core.Tree) obj; + } + + /** + * + * + * @param index + * @param vAlignment + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setAlignment(final int index, + final uk.ac.vamsas.objects.core.Alignment vAlignment) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._alignmentList.size()) { + throw new IndexOutOfBoundsException("setAlignment: Index value '" + index + + "' not in range [0.." + (this._alignmentList.size() - 1) + "]"); + } + + this._alignmentList.set(index, vAlignment); + } + + /** + * + * + * @param vAlignmentArray + */ + public void setAlignment( + final uk.ac.vamsas.objects.core.Alignment[] vAlignmentArray) { + // -- copy array + _alignmentList.clear(); + + for (int i = 0; i < vAlignmentArray.length; i++) { + this._alignmentList.add(vAlignmentArray[i]); + } + } + + /** + * Sets the value of '_alignmentList' by copying the given Vector. All + * elements will be checked for type safety. + * + * @param vAlignmentList + * the Vector to copy. + */ + public void setAlignment(final java.util.Vector vAlignmentList) { + // copy vector + this._alignmentList.clear(); + + this._alignmentList.addAll(vAlignmentList); + } + + /** + * Sets the value of '_alignmentList' by setting it to the given Vector. No + * type checking is performed. + * + * @deprecated + * + * @param alignmentVector + * the Vector to set. + */ + public void setAlignmentAsReference(final java.util.Vector alignmentVector) { + this._alignmentList = alignmentVector; + } + + /** + * + * + * @param index + * @param vDataSetAnnotations + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setDataSetAnnotations(final int index, + final uk.ac.vamsas.objects.core.DataSetAnnotations vDataSetAnnotations) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._dataSetAnnotationsList.size()) { + throw new IndexOutOfBoundsException( + "setDataSetAnnotations: Index value '" + index + + "' not in range [0.." + + (this._dataSetAnnotationsList.size() - 1) + "]"); + } + + this._dataSetAnnotationsList.set(index, vDataSetAnnotations); + } + + /** + * + * + * @param vDataSetAnnotationsArray + */ + public void setDataSetAnnotations( + final uk.ac.vamsas.objects.core.DataSetAnnotations[] vDataSetAnnotationsArray) { + // -- copy array + _dataSetAnnotationsList.clear(); + + for (int i = 0; i < vDataSetAnnotationsArray.length; i++) { + this._dataSetAnnotationsList.add(vDataSetAnnotationsArray[i]); + } + } + + /** + * Sets the value of '_dataSetAnnotationsList' by copying the given Vector. + * All elements will be checked for type safety. + * + * @param vDataSetAnnotationsList + * the Vector to copy. + */ + public void setDataSetAnnotations( + final java.util.Vector vDataSetAnnotationsList) { + // copy vector + this._dataSetAnnotationsList.clear(); + + this._dataSetAnnotationsList.addAll(vDataSetAnnotationsList); + } + + /** + * Sets the value of '_dataSetAnnotationsList' by setting it to the given + * Vector. No type checking is performed. + * + * @deprecated + * + * @param dataSetAnnotationsVector + * the Vector to set. + */ + public void setDataSetAnnotationsAsReference( + final java.util.Vector dataSetAnnotationsVector) { + this._dataSetAnnotationsList = dataSetAnnotationsVector; + } + + /** + * 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(final java.lang.String id) { + this._id = id; + } + + /** + * Sets the value of field 'provenance'. + * + * @param provenance + * the value of field 'provenance'. + */ + public void setProvenance( + final uk.ac.vamsas.objects.core.Provenance provenance) { + this._provenance = provenance; + } + + /** + * + * + * @param index + * @param vSequence + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setSequence(final int index, + final uk.ac.vamsas.objects.core.Sequence vSequence) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._sequenceList.size()) { + throw new IndexOutOfBoundsException("setSequence: Index value '" + index + + "' not in range [0.." + (this._sequenceList.size() - 1) + "]"); + } + + this._sequenceList.set(index, vSequence); + } + + /** + * + * + * @param vSequenceArray + */ + public void setSequence( + final uk.ac.vamsas.objects.core.Sequence[] vSequenceArray) { + // -- copy array + _sequenceList.clear(); + + for (int i = 0; i < vSequenceArray.length; i++) { + this._sequenceList.add(vSequenceArray[i]); + } + } + + /** + * Sets the value of '_sequenceList' by copying the given Vector. All elements + * will be checked for type safety. + * + * @param vSequenceList + * the Vector to copy. + */ + public void setSequence(final java.util.Vector vSequenceList) { + // copy vector + this._sequenceList.clear(); + + this._sequenceList.addAll(vSequenceList); + } + + /** + * Sets the value of '_sequenceList' by setting it to the given Vector. No + * type checking is performed. + * + * @deprecated + * + * @param sequenceVector + * the Vector to set. + */ + public void setSequenceAsReference(final java.util.Vector sequenceVector) { + this._sequenceList = sequenceVector; + } + + /** + * + * + * @param index + * @param vSequenceMapping + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setSequenceMapping(final int index, + final uk.ac.vamsas.objects.core.SequenceMapping vSequenceMapping) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._sequenceMappingList.size()) { + throw new IndexOutOfBoundsException("setSequenceMapping: Index value '" + + index + "' not in range [0.." + + (this._sequenceMappingList.size() - 1) + "]"); + } + + this._sequenceMappingList.set(index, vSequenceMapping); + } + + /** + * + * + * @param vSequenceMappingArray + */ + public void setSequenceMapping( + final uk.ac.vamsas.objects.core.SequenceMapping[] vSequenceMappingArray) { + // -- copy array + _sequenceMappingList.clear(); + + for (int i = 0; i < vSequenceMappingArray.length; i++) { + this._sequenceMappingList.add(vSequenceMappingArray[i]); + } + } + + /** + * Sets the value of '_sequenceMappingList' by copying the given Vector. All + * elements will be checked for type safety. + * + * @param vSequenceMappingList + * the Vector to copy. + */ + public void setSequenceMapping(final java.util.Vector vSequenceMappingList) { + // copy vector + this._sequenceMappingList.clear(); + + this._sequenceMappingList.addAll(vSequenceMappingList); + } + + /** + * Sets the value of '_sequenceMappingList' by setting it to the given Vector. + * No type checking is performed. + * + * @deprecated + * + * @param sequenceMappingVector + * the Vector to set. + */ + public void setSequenceMappingAsReference( + final java.util.Vector sequenceMappingVector) { + this._sequenceMappingList = sequenceMappingVector; + } + + /** + * + * + * @param index + * @param vTree + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setTree(final int index, + final uk.ac.vamsas.objects.core.Tree vTree) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._treeList.size()) { + throw new IndexOutOfBoundsException("setTree: Index value '" + index + + "' not in range [0.." + (this._treeList.size() - 1) + "]"); + } + + this._treeList.set(index, vTree); + } + + /** + * + * + * @param vTreeArray + */ + public void setTree(final uk.ac.vamsas.objects.core.Tree[] vTreeArray) { + // -- copy array + _treeList.clear(); + + for (int i = 0; i < vTreeArray.length; i++) { + this._treeList.add(vTreeArray[i]); + } + } + + /** + * Sets the value of '_treeList' by copying the given Vector. All elements + * will be checked for type safety. + * + * @param vTreeList + * the Vector to copy. + */ + public void setTree(final java.util.Vector vTreeList) { + // copy vector + this._treeList.clear(); + + this._treeList.addAll(vTreeList); + } + + /** + * Sets the value of '_treeList' by setting it to the given Vector. No type + * checking is performed. + * + * @deprecated + * + * @param treeVector + * the Vector to set. + */ + public void setTreeAsReference(final java.util.Vector treeVector) { + this._treeList = treeVector; + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @return the unmarshaled uk.ac.vamsas.objects.core.DataSet + */ + public static uk.ac.vamsas.objects.core.DataSet unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + return (uk.ac.vamsas.objects.core.DataSet) Unmarshaller.unmarshal( + uk.ac.vamsas.objects.core.DataSet.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/uk/ac/vamsas/objects/core/DataSetAnnotations.java b/src/uk/ac/vamsas/objects/core/DataSetAnnotations.java index 861f0fe..43bc9f9 100644 --- a/src/uk/ac/vamsas/objects/core/DataSetAnnotations.java +++ b/src/uk/ac/vamsas/objects/core/DataSetAnnotations.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import org.exolab.castor.xml.Marshaller; @@ -17,418 +31,418 @@ import org.exolab.castor.xml.Unmarshaller; /** * Class DataSetAnnotations. * - * @version $Revision$ $Date$ + * @version $Revision$ $Date: 2007-06-28 14:51:44 +0100 (Thu, 28 Jun 2007) + * $ */ -public class DataSetAnnotations extends uk.ac.vamsas.objects.core.RangeAnnotation -implements java.io.Serializable -{ - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * annotation is associated with a - * particular dataset sequence - */ - private java.util.Vector _seqRef; - - /** - * Field _provenance. - */ - private uk.ac.vamsas.objects.core.Provenance _provenance; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public DataSetAnnotations() { - super(); - this._seqRef = new java.util.Vector(); - } - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * - * - * @param vSeqRef - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addSeqRef( - final java.lang.Object vSeqRef) - throws java.lang.IndexOutOfBoundsException { - this._seqRef.addElement(vSeqRef); - } - - /** - * - * - * @param index - * @param vSeqRef - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addSeqRef( - final int index, - final java.lang.Object vSeqRef) - throws java.lang.IndexOutOfBoundsException { - this._seqRef.add(index, vSeqRef); - } - - /** - * Method enumerateSeqRef. - * - * @return an Enumeration over all java.lang.Object elements - */ - public java.util.Enumeration enumerateSeqRef( - ) { - return this._seqRef.elements(); - } - - /** - * Overrides the java.lang.Object.equals method. - * - * @param obj - * @return true if the objects are equal. - */ - public boolean equals( - final java.lang.Object obj) { - if ( this == obj ) - return true; - - if (super.equals(obj)==false) +public class DataSetAnnotations extends + uk.ac.vamsas.objects.core.RangeAnnotation implements java.io.Serializable { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * annotation is associated with a particular dataset sequence + */ + private java.util.Vector _seqRef; + + /** + * Field _provenance. + */ + private uk.ac.vamsas.objects.core.Provenance _provenance; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public DataSetAnnotations() { + super(); + this._seqRef = new java.util.Vector(); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * + * + * @param vSeqRef + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addSeqRef(final java.lang.Object vSeqRef) + throws java.lang.IndexOutOfBoundsException { + this._seqRef.addElement(vSeqRef); + } + + /** + * + * + * @param index + * @param vSeqRef + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addSeqRef(final int index, final java.lang.Object vSeqRef) + throws java.lang.IndexOutOfBoundsException { + this._seqRef.add(index, vSeqRef); + } + + /** + * Method enumerateSeqRef. + * + * @return an Enumeration over all java.lang.Object elements + */ + public java.util.Enumeration enumerateSeqRef() { + return this._seqRef.elements(); + } + + /** + * Overrides the java.lang.Object.equals method. + * + * @param obj + * @return true if the objects are equal. + */ + public boolean equals(final java.lang.Object obj) { + if (this == obj) + return true; + + if (super.equals(obj) == false) + return false; + + if (obj instanceof DataSetAnnotations) { + + DataSetAnnotations temp = (DataSetAnnotations) obj; + boolean thcycle; + boolean tmcycle; + if (this._seqRef != null) { + if (temp._seqRef == null) + return false; + if (this._seqRef != temp._seqRef) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._seqRef); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._seqRef); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._seqRef); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._seqRef); + } + ; return false; - - if (obj instanceof DataSetAnnotations) { - - DataSetAnnotations temp = (DataSetAnnotations)obj; - boolean thcycle; - boolean tmcycle; - if (this._seqRef != null) { - if (temp._seqRef == null) return false; - if (this._seqRef != temp._seqRef) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._seqRef); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._seqRef); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._seqRef); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._seqRef); }; - return false; - } - if (!thcycle) { - if (!this._seqRef.equals(temp._seqRef)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._seqRef); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._seqRef); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._seqRef); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._seqRef); - } - } - } else if (temp._seqRef != null) - return false; - if (this._provenance != null) { - if (temp._provenance == null) return false; - if (this._provenance != temp._provenance) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._provenance); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._provenance); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance); }; - return false; - } - if (!thcycle) { - if (!this._provenance.equals(temp._provenance)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance); - } - } - } else if (temp._provenance != null) - return false; - return true; + } + if (!thcycle) { + if (!this._seqRef.equals(temp._seqRef)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._seqRef); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._seqRef); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._seqRef); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._seqRef); + } } + } else if (temp._seqRef != null) return false; - } - - /** - * Returns the value of field 'provenance'. - * - * @return the value of field 'Provenance'. - */ - public uk.ac.vamsas.objects.core.Provenance getProvenance( - ) { - return this._provenance; - } - - /** - * Method getSeqRef. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the java.lang.Object at the given index - */ - public java.lang.Object getSeqRef( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._seqRef.size()) { - throw new IndexOutOfBoundsException("getSeqRef: Index value '" + index + "' not in range [0.." + (this._seqRef.size() - 1) + "]"); - } - - return _seqRef.get(index); - } - - /** - * Method getSeqRef.Returns the contents of the collection in - * an Array.

Note: Just in case the collection contents - * are changing in another thread, we pass a 0-length Array of - * the correct type into the API call. This way we know - * that the Array returned is of exactly the correct length. - * - * @return this collection as an Array - */ - public java.lang.Object[] getSeqRef( - ) { - java.lang.Object[] array = new java.lang.Object[0]; - return (java.lang.Object[]) this._seqRef.toArray(array); - } - - /** - * Method getSeqRefAsReference.Returns a reference to - * '_seqRef'. No type checking is performed on any - * modifications to the Vector. - * - * @return a reference to the Vector backing this class - */ - public java.util.Vector getSeqRefAsReference( - ) { - return this._seqRef; - } - - /** - * Method getSeqRefCount. - * - * @return the size of this collection - */ - public int getSeqRefCount( - ) { - return this._seqRef.size(); - } - - /** - * Overrides the java.lang.Object.hashCode method. - *

- * The following steps came from Effective Java Programming - * Language Guide by Joshua Bloch, Chapter 3 - * - * @return a hash code value for the object. - */ - public int hashCode( - ) { - int result = super.hashCode(); - - long tmp; - if (_seqRef != null - && !org.castor.util.CycleBreaker.startingToCycle(_seqRef)) { - result = 37 * result + _seqRef.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_seqRef); - } - if (_provenance != null - && !org.castor.util.CycleBreaker.startingToCycle(_provenance)) { - result = 37 * result + _provenance.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_provenance); - } - - return result; - } - - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { + if (this._provenance != null) { + if (temp._provenance == null) + return false; + if (this._provenance != temp._provenance) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._provenance); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._provenance); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance); + } + ; return false; + } + if (!thcycle) { + if (!this._provenance.equals(temp._provenance)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance); + } } - return true; - } - - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } - - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } - - /** - */ - public void removeAllSeqRef( - ) { - this._seqRef.clear(); + } else if (temp._provenance != null) + return false; + return true; } - - /** - * Method removeSeqRef. - * - * @param vSeqRef - * @return true if the object was removed from the collection. - */ - public boolean removeSeqRef( - final java.lang.Object vSeqRef) { - boolean removed = _seqRef.remove(vSeqRef); - return removed; + return false; + } + + /** + * Returns the value of field 'provenance'. + * + * @return the value of field 'Provenance'. + */ + public uk.ac.vamsas.objects.core.Provenance getProvenance() { + return this._provenance; + } + + /** + * Method getSeqRef. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the java.lang.Object at the given index + */ + public java.lang.Object getSeqRef(final int index) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._seqRef.size()) { + throw new IndexOutOfBoundsException("getSeqRef: Index value '" + index + + "' not in range [0.." + (this._seqRef.size() - 1) + "]"); } - /** - * Method removeSeqRefAt. - * - * @param index - * @return the element removed from the collection - */ - public java.lang.Object removeSeqRefAt( - final int index) { - java.lang.Object obj = this._seqRef.remove(index); - return obj; + return _seqRef.get(index); + } + + /** + * Method getSeqRef.Returns the contents of the collection in an Array. + *

+ * Note: Just in case the collection contents are changing in another thread, + * we pass a 0-length Array of the correct type into the API call. This way we + * know that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public java.lang.Object[] getSeqRef() { + java.lang.Object[] array = new java.lang.Object[0]; + return (java.lang.Object[]) this._seqRef.toArray(array); + } + + /** + * Method getSeqRefAsReference.Returns a reference to '_seqRef'. No type + * checking is performed on any modifications to the Vector. + * + * @return a reference to the Vector backing this class + */ + public java.util.Vector getSeqRefAsReference() { + return this._seqRef; + } + + /** + * Method getSeqRefCount. + * + * @return the size of this collection + */ + public int getSeqRefCount() { + return this._seqRef.size(); + } + + /** + * Overrides the java.lang.Object.hashCode method. + *

+ * The following steps came from Effective Java Programming Language + * Guide by Joshua Bloch, Chapter 3 + * + * @return a hash code value for the object. + */ + public int hashCode() { + int result = super.hashCode(); + + long tmp; + if (_seqRef != null + && !org.castor.util.CycleBreaker.startingToCycle(_seqRef)) { + result = 37 * result + _seqRef.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_seqRef); } - - /** - * Sets the value of field 'provenance'. - * - * @param provenance the value of field 'provenance'. - */ - public void setProvenance( - final uk.ac.vamsas.objects.core.Provenance provenance) { - this._provenance = provenance; + if (_provenance != null + && !org.castor.util.CycleBreaker.startingToCycle(_provenance)) { + result = 37 * result + _provenance.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_provenance); } - /** - * - * - * @param index - * @param vSeqRef - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setSeqRef( - final int index, - final java.lang.Object vSeqRef) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._seqRef.size()) { - throw new IndexOutOfBoundsException("setSeqRef: Index value '" + index + "' not in range [0.." + (this._seqRef.size() - 1) + "]"); - } - - this._seqRef.set(index, vSeqRef); + return result; + } + + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() { + try { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) { + return false; } - - /** - * - * - * @param vSeqRefArray + return true; + } + + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, out); + } + + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, handler); + } + + /** */ - public void setSeqRef( - final java.lang.Object[] vSeqRefArray) { - //-- copy array - _seqRef.clear(); - - for (int i = 0; i < vSeqRefArray.length; i++) { - this._seqRef.add(vSeqRefArray[i]); - } + public void removeAllSeqRef() { + this._seqRef.clear(); + } + + /** + * Method removeSeqRef. + * + * @param vSeqRef + * @return true if the object was removed from the collection. + */ + public boolean removeSeqRef(final java.lang.Object vSeqRef) { + boolean removed = _seqRef.remove(vSeqRef); + return removed; + } + + /** + * Method removeSeqRefAt. + * + * @param index + * @return the element removed from the collection + */ + public java.lang.Object removeSeqRefAt(final int index) { + java.lang.Object obj = this._seqRef.remove(index); + return obj; + } + + /** + * Sets the value of field 'provenance'. + * + * @param provenance + * the value of field 'provenance'. + */ + public void setProvenance( + final uk.ac.vamsas.objects.core.Provenance provenance) { + this._provenance = provenance; + } + + /** + * + * + * @param index + * @param vSeqRef + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setSeqRef(final int index, final java.lang.Object vSeqRef) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._seqRef.size()) { + throw new IndexOutOfBoundsException("setSeqRef: Index value '" + index + + "' not in range [0.." + (this._seqRef.size() - 1) + "]"); } - /** - * Sets the value of '_seqRef' by copying the given Vector. All - * elements will be checked for type safety. - * - * @param vSeqRefList the Vector to copy. - */ - public void setSeqRef( - final java.util.Vector vSeqRefList) { - // copy vector - this._seqRef.clear(); - - this._seqRef.addAll(vSeqRefList); - } + this._seqRef.set(index, vSeqRef); + } - /** - * Sets the value of '_seqRef' by setting it to the given - * Vector. No type checking is performed. - * @deprecated - * - * @param seqRefVector the Vector to set. - */ - public void setSeqRefAsReference( - final java.util.Vector seqRefVector) { - this._seqRef = seqRefVector; - } + /** + * + * + * @param vSeqRefArray + */ + public void setSeqRef(final java.lang.Object[] vSeqRefArray) { + // -- copy array + _seqRef.clear(); - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled uk.ac.vamsas.objects.core.RangeType - */ - public static uk.ac.vamsas.objects.core.RangeType unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (uk.ac.vamsas.objects.core.RangeType) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.DataSetAnnotations.class, reader); - } - - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); + for (int i = 0; i < vSeqRefArray.length; i++) { + this._seqRef.add(vSeqRefArray[i]); } + } + + /** + * Sets the value of '_seqRef' by copying the given Vector. All elements will + * be checked for type safety. + * + * @param vSeqRefList + * the Vector to copy. + */ + public void setSeqRef(final java.util.Vector vSeqRefList) { + // copy vector + this._seqRef.clear(); + + this._seqRef.addAll(vSeqRefList); + } + + /** + * Sets the value of '_seqRef' by setting it to the given Vector. No type + * checking is performed. + * + * @deprecated + * + * @param seqRefVector + * the Vector to set. + */ + public void setSeqRefAsReference(final java.util.Vector seqRefVector) { + this._seqRef = seqRefVector; + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @return the unmarshaled uk.ac.vamsas.objects.core.RangeType + */ + public static uk.ac.vamsas.objects.core.RangeType unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + return (uk.ac.vamsas.objects.core.RangeType) Unmarshaller.unmarshal( + uk.ac.vamsas.objects.core.DataSetAnnotations.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/uk/ac/vamsas/objects/core/DbRef.java b/src/uk/ac/vamsas/objects/core/DbRef.java index 7206791..59905b0 100644 --- a/src/uk/ac/vamsas/objects/core/DbRef.java +++ b/src/uk/ac/vamsas/objects/core/DbRef.java @@ -1,1085 +1,1102 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import org.exolab.castor.xml.Marshaller; import org.exolab.castor.xml.Unmarshaller; /** - * Store a list of database references - * for this sequence record - with optional mapping - * from database sequence to the given sequence record + * Store a list of database references for this sequence record - with optional + * mapping from database sequence to the given sequence record * - * @version $Revision$ $Date$ + * @version $Revision$ $Date: 2007-06-29 13:23:12 +0100 (Fri, 29 Jun 2007) + * $ */ -public class DbRef extends uk.ac.vamsas.client.Vobject -implements java.io.Serializable -{ - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * TODO Database Naming - * Convention: either start using LSID (so - * change type to URI) or leave this as an - * uncontrolled/unspecified string ID - * - */ - private java.lang.String _source; - - /** - * Version must be specified - - * - */ - private java.lang.String _version; - - /** - * TODO: make some specification - * of the database field from which this - * accessionId is taken from - should that be a - * special property of the dbRef object ? - * - */ - private java.lang.String _accessionId; - - /** - * Primary Key for vamsas object - * referencing - */ - private java.lang.String _id; - - /** - * the local mapType maps from the parent - * sequence coordinate frame to the reference - * frame defined by the dbRef element. - * The mapped mapType is the mapped range defined - * on the dbRef element's reference frame. - * Conventionally, the unit attribute defaults to 1, or - * will be inferred from the local sequence's - * dictionary type and any dictionary type associated - * with the database being mapped to. - * However, it may be used to avoid ambiguity. - * - */ - private java.util.Vector _mapList; - - /** - * Field _linkList. - */ - private java.util.Vector _linkList; - - /** - * Field _propertyList. - */ - private java.util.Vector _propertyList; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public DbRef() { - super(); - this._mapList = new java.util.Vector(); - this._linkList = new java.util.Vector(); - this._propertyList = new java.util.Vector(); - } - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * - * - * @param vLink - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addLink( - final uk.ac.vamsas.objects.core.Link vLink) - throws java.lang.IndexOutOfBoundsException { - this._linkList.addElement(vLink); - } - - /** - * - * - * @param index - * @param vLink - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addLink( - final int index, - final uk.ac.vamsas.objects.core.Link vLink) - throws java.lang.IndexOutOfBoundsException { - this._linkList.add(index, vLink); - } - - /** - * - * - * @param vMap - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addMap( - final uk.ac.vamsas.objects.core.Map vMap) - throws java.lang.IndexOutOfBoundsException { - this._mapList.addElement(vMap); - } - - /** - * - * - * @param index - * @param vMap - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addMap( - final int index, - final uk.ac.vamsas.objects.core.Map vMap) - throws java.lang.IndexOutOfBoundsException { - this._mapList.add(index, vMap); - } - - /** - * - * - * @param vProperty - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addProperty( - final uk.ac.vamsas.objects.core.Property vProperty) - throws java.lang.IndexOutOfBoundsException { - this._propertyList.addElement(vProperty); - } - - /** - * - * - * @param index - * @param vProperty - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addProperty( - final int index, - final uk.ac.vamsas.objects.core.Property vProperty) - throws java.lang.IndexOutOfBoundsException { - this._propertyList.add(index, vProperty); - } - - /** - * Method enumerateLink. - * - * @return an Enumeration over all - * uk.ac.vamsas.objects.core.Link elements - */ - public java.util.Enumeration enumerateLink( - ) { - return this._linkList.elements(); - } - - /** - * Method enumerateMap. - * - * @return an Enumeration over all - * uk.ac.vamsas.objects.core.Map elements - */ - public java.util.Enumeration enumerateMap( - ) { - return this._mapList.elements(); - } - - /** - * Method enumerateProperty. - * - * @return an Enumeration over all - * uk.ac.vamsas.objects.core.Property elements - */ - public java.util.Enumeration enumerateProperty( - ) { - return this._propertyList.elements(); - } - - /** - * Overrides the java.lang.Object.equals method. - * - * @param obj - * @return true if the objects are equal. - */ - public boolean equals( - final java.lang.Object obj) { - if ( this == obj ) - return true; - - if (super.equals(obj)==false) +public class DbRef extends uk.ac.vamsas.client.Vobject implements + java.io.Serializable { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * TODO Database Naming Convention: either start using LSID (so change type to + * URI) or leave this as an uncontrolled/unspecified string ID + * + */ + private java.lang.String _source; + + /** + * Version must be specified - + * + */ + private java.lang.String _version; + + /** + * TODO: make some specification of the database field from which this + * accessionId is taken from - should that be a special property of the dbRef + * object ? + * + */ + private java.lang.String _accessionId; + + /** + * Primary Key for vamsas object referencing + */ + private java.lang.String _id; + + /** + * the local mapType maps from the parent sequence coordinate frame to the + * reference frame defined by the dbRef element. The mapped mapType is the + * mapped range defined on the dbRef element's reference frame. + * Conventionally, the unit attribute defaults to 1, or will be inferred from + * the local sequence's dictionary type and any dictionary type associated + * with the database being mapped to. However, it may be used to avoid + * ambiguity. + * + */ + private java.util.Vector _mapList; + + /** + * Field _linkList. + */ + private java.util.Vector _linkList; + + /** + * Field _propertyList. + */ + private java.util.Vector _propertyList; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public DbRef() { + super(); + this._mapList = new java.util.Vector(); + this._linkList = new java.util.Vector(); + this._propertyList = new java.util.Vector(); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * + * + * @param vLink + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addLink(final uk.ac.vamsas.objects.core.Link vLink) + throws java.lang.IndexOutOfBoundsException { + this._linkList.addElement(vLink); + } + + /** + * + * + * @param index + * @param vLink + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addLink(final int index, + final uk.ac.vamsas.objects.core.Link vLink) + throws java.lang.IndexOutOfBoundsException { + this._linkList.add(index, vLink); + } + + /** + * + * + * @param vMap + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addMap(final uk.ac.vamsas.objects.core.Map vMap) + throws java.lang.IndexOutOfBoundsException { + this._mapList.addElement(vMap); + } + + /** + * + * + * @param index + * @param vMap + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addMap(final int index, final uk.ac.vamsas.objects.core.Map vMap) + throws java.lang.IndexOutOfBoundsException { + this._mapList.add(index, vMap); + } + + /** + * + * + * @param vProperty + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addProperty(final uk.ac.vamsas.objects.core.Property vProperty) + throws java.lang.IndexOutOfBoundsException { + this._propertyList.addElement(vProperty); + } + + /** + * + * + * @param index + * @param vProperty + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addProperty(final int index, + final uk.ac.vamsas.objects.core.Property vProperty) + throws java.lang.IndexOutOfBoundsException { + this._propertyList.add(index, vProperty); + } + + /** + * Method enumerateLink. + * + * @return an Enumeration over all uk.ac.vamsas.objects.core.Link elements + */ + public java.util.Enumeration enumerateLink() { + return this._linkList.elements(); + } + + /** + * Method enumerateMap. + * + * @return an Enumeration over all uk.ac.vamsas.objects.core.Map elements + */ + public java.util.Enumeration enumerateMap() { + return this._mapList.elements(); + } + + /** + * Method enumerateProperty. + * + * @return an Enumeration over all uk.ac.vamsas.objects.core.Property elements + */ + public java.util.Enumeration enumerateProperty() { + return this._propertyList.elements(); + } + + /** + * Overrides the java.lang.Object.equals method. + * + * @param obj + * @return true if the objects are equal. + */ + public boolean equals(final java.lang.Object obj) { + if (this == obj) + return true; + + if (super.equals(obj) == false) + return false; + + if (obj instanceof DbRef) { + + DbRef temp = (DbRef) obj; + boolean thcycle; + boolean tmcycle; + if (this._source != null) { + if (temp._source == null) + return false; + if (this._source != temp._source) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._source); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._source); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._source); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._source); + } + ; return false; - - if (obj instanceof DbRef) { - - DbRef temp = (DbRef)obj; - boolean thcycle; - boolean tmcycle; - if (this._source != null) { - if (temp._source == null) return false; - if (this._source != temp._source) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._source); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._source); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._source); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._source); }; - return false; - } - if (!thcycle) { - if (!this._source.equals(temp._source)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._source); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._source); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._source); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._source); - } - } - } else if (temp._source != null) - return false; - if (this._version != null) { - if (temp._version == null) return false; - if (this._version != temp._version) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._version); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._version); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._version); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._version); }; - return false; - } - if (!thcycle) { - if (!this._version.equals(temp._version)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._version); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._version); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._version); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._version); - } - } - } else if (temp._version != null) - return false; - if (this._accessionId != null) { - if (temp._accessionId == null) return false; - if (this._accessionId != temp._accessionId) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._accessionId); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._accessionId); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._accessionId); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._accessionId); }; - return false; - } - if (!thcycle) { - if (!this._accessionId.equals(temp._accessionId)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._accessionId); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._accessionId); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._accessionId); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._accessionId); - } - } - } else if (temp._accessionId != null) - return false; - if (this._id != null) { - if (temp._id == null) return false; - if (this._id != temp._id) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._id); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._id); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._id); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); }; - return false; - } - if (!thcycle) { - if (!this._id.equals(temp._id)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._id); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._id); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); - } - } - } else if (temp._id != null) - return false; - if (this._mapList != null) { - if (temp._mapList == null) return false; - if (this._mapList != temp._mapList) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._mapList); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._mapList); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._mapList); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._mapList); }; - return false; - } - if (!thcycle) { - if (!this._mapList.equals(temp._mapList)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._mapList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._mapList); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._mapList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._mapList); - } - } - } else if (temp._mapList != null) - return false; - if (this._linkList != null) { - if (temp._linkList == null) return false; - if (this._linkList != temp._linkList) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._linkList); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._linkList); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._linkList); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._linkList); }; - return false; - } - if (!thcycle) { - if (!this._linkList.equals(temp._linkList)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._linkList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._linkList); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._linkList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._linkList); - } - } - } else if (temp._linkList != null) - return false; - if (this._propertyList != null) { - if (temp._propertyList == null) return false; - if (this._propertyList != temp._propertyList) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._propertyList); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._propertyList); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._propertyList); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._propertyList); }; - return false; - } - if (!thcycle) { - if (!this._propertyList.equals(temp._propertyList)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._propertyList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._propertyList); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._propertyList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._propertyList); - } - } - } else if (temp._propertyList != null) - return false; - return true; + } + if (!thcycle) { + if (!this._source.equals(temp._source)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._source); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._source); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._source); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._source); + } } + } else if (temp._source != null) return false; - } - - /** - * Returns the value of field 'accessionId'. The field - * 'accessionId' has the following description: TODO: make some - * specification - * of the database field from which this - * accessionId is taken from - should that be a - * special property of the dbRef object ? - * - * - * @return the value of field 'AccessionId'. - */ - public java.lang.String getAccessionId( - ) { - return this._accessionId; - } - - /** - * Returns the value of field 'id'. The field 'id' has the - * following description: Primary Key for vamsas object - * referencing - * - * @return the value of field 'Id'. - */ - public java.lang.String getId( - ) { - return this._id; - } - - /** - * Method getLink. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the uk.ac.vamsas.objects.core.Link at - * the given index - */ - public uk.ac.vamsas.objects.core.Link getLink( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._linkList.size()) { - throw new IndexOutOfBoundsException("getLink: Index value '" + index + "' not in range [0.." + (this._linkList.size() - 1) + "]"); - } - - return (uk.ac.vamsas.objects.core.Link) _linkList.get(index); - } - - /** - * Method getLink.Returns the contents of the collection in an - * Array.

Note: Just in case the collection contents are - * changing in another thread, we pass a 0-length Array of the - * correct type into the API call. This way we know - * that the Array returned is of exactly the correct length. - * - * @return this collection as an Array - */ - public uk.ac.vamsas.objects.core.Link[] getLink( - ) { - uk.ac.vamsas.objects.core.Link[] array = new uk.ac.vamsas.objects.core.Link[0]; - return (uk.ac.vamsas.objects.core.Link[]) this._linkList.toArray(array); - } - - /** - * Method getLinkAsReference.Returns a reference to - * '_linkList'. No type checking is performed on any - * modifications to the Vector. - * - * @return a reference to the Vector backing this class - */ - public java.util.Vector getLinkAsReference( - ) { - return this._linkList; - } - - /** - * Method getLinkCount. - * - * @return the size of this collection - */ - public int getLinkCount( - ) { - return this._linkList.size(); - } - - /** - * Method getMap. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the uk.ac.vamsas.objects.core.Map at - * the given index - */ - public uk.ac.vamsas.objects.core.Map getMap( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._mapList.size()) { - throw new IndexOutOfBoundsException("getMap: Index value '" + index + "' not in range [0.." + (this._mapList.size() - 1) + "]"); - } - - return (uk.ac.vamsas.objects.core.Map) _mapList.get(index); - } - - /** - * Method getMap.Returns the contents of the collection in an - * Array.

Note: Just in case the collection contents are - * changing in another thread, we pass a 0-length Array of the - * correct type into the API call. This way we know - * that the Array returned is of exactly the correct length. - * - * @return this collection as an Array - */ - public uk.ac.vamsas.objects.core.Map[] getMap( - ) { - uk.ac.vamsas.objects.core.Map[] array = new uk.ac.vamsas.objects.core.Map[0]; - return (uk.ac.vamsas.objects.core.Map[]) this._mapList.toArray(array); - } - - /** - * Method getMapAsReference.Returns a reference to '_mapList'. - * No type checking is performed on any modifications to the - * Vector. - * - * @return a reference to the Vector backing this class - */ - public java.util.Vector getMapAsReference( - ) { - return this._mapList; - } - - /** - * Method getMapCount. - * - * @return the size of this collection - */ - public int getMapCount( - ) { - return this._mapList.size(); - } - - /** - * Method getProperty. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the uk.ac.vamsas.objects.core.Property - * at the given index - */ - public uk.ac.vamsas.objects.core.Property getProperty( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._propertyList.size()) { - throw new IndexOutOfBoundsException("getProperty: Index value '" + index + "' not in range [0.." + (this._propertyList.size() - 1) + "]"); - } - - return (uk.ac.vamsas.objects.core.Property) _propertyList.get(index); - } - - /** - * Method getProperty.Returns the contents of the collection in - * an Array.

Note: Just in case the collection contents - * are changing in another thread, we pass a 0-length Array of - * the correct type into the API call. This way we know - * that the Array returned is of exactly the correct length. - * - * @return this collection as an Array - */ - public uk.ac.vamsas.objects.core.Property[] getProperty( - ) { - uk.ac.vamsas.objects.core.Property[] array = new uk.ac.vamsas.objects.core.Property[0]; - return (uk.ac.vamsas.objects.core.Property[]) this._propertyList.toArray(array); - } - - /** - * Method getPropertyAsReference.Returns a reference to - * '_propertyList'. No type checking is performed on any - * modifications to the Vector. - * - * @return a reference to the Vector backing this class - */ - public java.util.Vector getPropertyAsReference( - ) { - return this._propertyList; - } - - /** - * Method getPropertyCount. - * - * @return the size of this collection - */ - public int getPropertyCount( - ) { - return this._propertyList.size(); - } - - /** - * Returns the value of field 'source'. The field 'source' has - * the following description: TODO Database Naming - * Convention: either start using LSID (so - * change type to URI) or leave this as an - * uncontrolled/unspecified string ID - * - * - * @return the value of field 'Source'. - */ - public java.lang.String getSource( - ) { - return this._source; - } - - /** - * Returns the value of field 'version'. The field 'version' - * has the following description: Version must be specified - - * - * - * @return the value of field 'Version'. - */ - public java.lang.String getVersion( - ) { - return this._version; - } - - /** - * Overrides the java.lang.Object.hashCode method. - *

- * The following steps came from Effective Java Programming - * Language Guide by Joshua Bloch, Chapter 3 - * - * @return a hash code value for the object. - */ - public int hashCode( - ) { - int result = super.hashCode(); - - long tmp; - if (_source != null - && !org.castor.util.CycleBreaker.startingToCycle(_source)) { - result = 37 * result + _source.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_source); - } - if (_version != null - && !org.castor.util.CycleBreaker.startingToCycle(_version)) { - result = 37 * result + _version.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_version); - } - if (_accessionId != null - && !org.castor.util.CycleBreaker.startingToCycle(_accessionId)) { - result = 37 * result + _accessionId.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_accessionId); + if (this._version != null) { + if (temp._version == null) + return false; + if (this._version != temp._version) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._version); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._version); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._version); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._version); + } + ; + return false; + } + if (!thcycle) { + if (!this._version.equals(temp._version)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._version); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._version); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._version); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._version); + } } - if (_id != null - && !org.castor.util.CycleBreaker.startingToCycle(_id)) { - result = 37 * result + _id.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_id); + } else if (temp._version != null) + return false; + if (this._accessionId != null) { + if (temp._accessionId == null) + return false; + if (this._accessionId != temp._accessionId) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._accessionId); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._accessionId); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker + .releaseCycleHandle(this._accessionId); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._accessionId); + } + ; + return false; + } + if (!thcycle) { + if (!this._accessionId.equals(temp._accessionId)) { + org.castor.util.CycleBreaker + .releaseCycleHandle(this._accessionId); + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._accessionId); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._accessionId); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._accessionId); + } } - if (_mapList != null - && !org.castor.util.CycleBreaker.startingToCycle(_mapList)) { - result = 37 * result + _mapList.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_mapList); + } else if (temp._accessionId != null) + return false; + if (this._id != null) { + if (temp._id == null) + return false; + if (this._id != temp._id) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._id); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._id); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._id); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); + } + ; + return false; + } + if (!thcycle) { + if (!this._id.equals(temp._id)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._id); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._id); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); + } } - if (_linkList != null - && !org.castor.util.CycleBreaker.startingToCycle(_linkList)) { - result = 37 * result + _linkList.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_linkList); + } else if (temp._id != null) + return false; + if (this._mapList != null) { + if (temp._mapList == null) + return false; + if (this._mapList != temp._mapList) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._mapList); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._mapList); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._mapList); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._mapList); + } + ; + return false; + } + if (!thcycle) { + if (!this._mapList.equals(temp._mapList)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._mapList); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._mapList); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._mapList); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._mapList); + } } - if (_propertyList != null - && !org.castor.util.CycleBreaker.startingToCycle(_propertyList)) { - result = 37 * result + _propertyList.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_propertyList); + } else if (temp._mapList != null) + return false; + if (this._linkList != null) { + if (temp._linkList == null) + return false; + if (this._linkList != temp._linkList) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._linkList); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._linkList); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._linkList); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._linkList); + } + ; + return false; + } + if (!thcycle) { + if (!this._linkList.equals(temp._linkList)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._linkList); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._linkList); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._linkList); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._linkList); + } } - - return result; - } - - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { + } else if (temp._linkList != null) + return false; + if (this._propertyList != null) { + if (temp._propertyList == null) + return false; + if (this._propertyList != temp._propertyList) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._propertyList); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._propertyList); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker + .releaseCycleHandle(this._propertyList); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._propertyList); + } + ; return false; + } + if (!thcycle) { + if (!this._propertyList.equals(temp._propertyList)) { + org.castor.util.CycleBreaker + .releaseCycleHandle(this._propertyList); + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._propertyList); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._propertyList); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._propertyList); + } } - return true; - } - - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } - - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } - - /** - */ - public void removeAllLink( - ) { - this._linkList.clear(); - } - - /** - */ - public void removeAllMap( - ) { - this._mapList.clear(); - } - - /** - */ - public void removeAllProperty( - ) { - this._propertyList.clear(); - } - - /** - * Method removeLink. - * - * @param vLink - * @return true if the object was removed from the collection. - */ - public boolean removeLink( - final uk.ac.vamsas.objects.core.Link vLink) { - boolean removed = _linkList.remove(vLink); - return removed; - } - - /** - * Method removeLinkAt. - * - * @param index - * @return the element removed from the collection - */ - public uk.ac.vamsas.objects.core.Link removeLinkAt( - final int index) { - java.lang.Object obj = this._linkList.remove(index); - return (uk.ac.vamsas.objects.core.Link) obj; + } else if (temp._propertyList != null) + return false; + return true; } - - /** - * Method removeMap. - * - * @param vMap - * @return true if the object was removed from the collection. - */ - public boolean removeMap( - final uk.ac.vamsas.objects.core.Map vMap) { - boolean removed = _mapList.remove(vMap); - return removed; + return false; + } + + /** + * Returns the value of field 'accessionId'. The field 'accessionId' has the + * following description: TODO: make some specification of the database field + * from which this accessionId is taken from - should that be a special + * property of the dbRef object ? + * + * + * @return the value of field 'AccessionId'. + */ + public java.lang.String getAccessionId() { + return this._accessionId; + } + + /** + * Returns the value of field 'id'. The field 'id' has the following + * description: Primary Key for vamsas object referencing + * + * @return the value of field 'Id'. + */ + public java.lang.String getId() { + return this._id; + } + + /** + * Method getLink. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the uk.ac.vamsas.objects.core.Link at the given index + */ + public uk.ac.vamsas.objects.core.Link getLink(final int index) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._linkList.size()) { + throw new IndexOutOfBoundsException("getLink: Index value '" + index + + "' not in range [0.." + (this._linkList.size() - 1) + "]"); } - /** - * Method removeMapAt. - * - * @param index - * @return the element removed from the collection - */ - public uk.ac.vamsas.objects.core.Map removeMapAt( - final int index) { - java.lang.Object obj = this._mapList.remove(index); - return (uk.ac.vamsas.objects.core.Map) obj; + return (uk.ac.vamsas.objects.core.Link) _linkList.get(index); + } + + /** + * Method getLink.Returns the contents of the collection in an Array. + *

+ * Note: Just in case the collection contents are changing in another thread, + * we pass a 0-length Array of the correct type into the API call. This way we + * know that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public uk.ac.vamsas.objects.core.Link[] getLink() { + uk.ac.vamsas.objects.core.Link[] array = new uk.ac.vamsas.objects.core.Link[0]; + return (uk.ac.vamsas.objects.core.Link[]) this._linkList.toArray(array); + } + + /** + * Method getLinkAsReference.Returns a reference to '_linkList'. No type + * checking is performed on any modifications to the Vector. + * + * @return a reference to the Vector backing this class + */ + public java.util.Vector getLinkAsReference() { + return this._linkList; + } + + /** + * Method getLinkCount. + * + * @return the size of this collection + */ + public int getLinkCount() { + return this._linkList.size(); + } + + /** + * Method getMap. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the uk.ac.vamsas.objects.core.Map at the given index + */ + public uk.ac.vamsas.objects.core.Map getMap(final int index) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._mapList.size()) { + throw new IndexOutOfBoundsException("getMap: Index value '" + index + + "' not in range [0.." + (this._mapList.size() - 1) + "]"); } - /** - * Method removeProperty. - * - * @param vProperty - * @return true if the object was removed from the collection. - */ - public boolean removeProperty( - final uk.ac.vamsas.objects.core.Property vProperty) { - boolean removed = _propertyList.remove(vProperty); - return removed; + return (uk.ac.vamsas.objects.core.Map) _mapList.get(index); + } + + /** + * Method getMap.Returns the contents of the collection in an Array. + *

+ * Note: Just in case the collection contents are changing in another thread, + * we pass a 0-length Array of the correct type into the API call. This way we + * know that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public uk.ac.vamsas.objects.core.Map[] getMap() { + uk.ac.vamsas.objects.core.Map[] array = new uk.ac.vamsas.objects.core.Map[0]; + return (uk.ac.vamsas.objects.core.Map[]) this._mapList.toArray(array); + } + + /** + * Method getMapAsReference.Returns a reference to '_mapList'. No type + * checking is performed on any modifications to the Vector. + * + * @return a reference to the Vector backing this class + */ + public java.util.Vector getMapAsReference() { + return this._mapList; + } + + /** + * Method getMapCount. + * + * @return the size of this collection + */ + public int getMapCount() { + return this._mapList.size(); + } + + /** + * Method getProperty. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the uk.ac.vamsas.objects.core.Property at the given + * index + */ + public uk.ac.vamsas.objects.core.Property getProperty(final int index) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._propertyList.size()) { + throw new IndexOutOfBoundsException("getProperty: Index value '" + index + + "' not in range [0.." + (this._propertyList.size() - 1) + "]"); } - /** - * Method removePropertyAt. - * - * @param index - * @return the element removed from the collection - */ - public uk.ac.vamsas.objects.core.Property removePropertyAt( - final int index) { - java.lang.Object obj = this._propertyList.remove(index); - return (uk.ac.vamsas.objects.core.Property) obj; + return (uk.ac.vamsas.objects.core.Property) _propertyList.get(index); + } + + /** + * Method getProperty.Returns the contents of the collection in an Array. + *

+ * Note: Just in case the collection contents are changing in another thread, + * we pass a 0-length Array of the correct type into the API call. This way we + * know that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public uk.ac.vamsas.objects.core.Property[] getProperty() { + uk.ac.vamsas.objects.core.Property[] array = new uk.ac.vamsas.objects.core.Property[0]; + return (uk.ac.vamsas.objects.core.Property[]) this._propertyList + .toArray(array); + } + + /** + * Method getPropertyAsReference.Returns a reference to '_propertyList'. No + * type checking is performed on any modifications to the Vector. + * + * @return a reference to the Vector backing this class + */ + public java.util.Vector getPropertyAsReference() { + return this._propertyList; + } + + /** + * Method getPropertyCount. + * + * @return the size of this collection + */ + public int getPropertyCount() { + return this._propertyList.size(); + } + + /** + * Returns the value of field 'source'. The field 'source' has the following + * description: TODO Database Naming Convention: either start using LSID (so + * change type to URI) or leave this as an uncontrolled/unspecified string ID + * + * + * @return the value of field 'Source'. + */ + public java.lang.String getSource() { + return this._source; + } + + /** + * Returns the value of field 'version'. The field 'version' has the following + * description: Version must be specified - + * + * + * @return the value of field 'Version'. + */ + public java.lang.String getVersion() { + return this._version; + } + + /** + * Overrides the java.lang.Object.hashCode method. + *

+ * The following steps came from Effective Java Programming Language + * Guide by Joshua Bloch, Chapter 3 + * + * @return a hash code value for the object. + */ + public int hashCode() { + int result = super.hashCode(); + + long tmp; + if (_source != null + && !org.castor.util.CycleBreaker.startingToCycle(_source)) { + result = 37 * result + _source.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_source); } - - /** - * Sets the value of field 'accessionId'. The field - * 'accessionId' has the following description: TODO: make some - * specification - * of the database field from which this - * accessionId is taken from - should that be a - * special property of the dbRef object ? - * - * - * @param accessionId the value of field 'accessionId'. - */ - public void setAccessionId( - final java.lang.String accessionId) { - this._accessionId = accessionId; + if (_version != null + && !org.castor.util.CycleBreaker.startingToCycle(_version)) { + result = 37 * result + _version.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_version); } - - /** - * 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( - final java.lang.String id) { - this._id = id; + if (_accessionId != null + && !org.castor.util.CycleBreaker.startingToCycle(_accessionId)) { + result = 37 * result + _accessionId.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_accessionId); } - - /** - * - * - * @param index - * @param vLink - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setLink( - final int index, - final uk.ac.vamsas.objects.core.Link vLink) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._linkList.size()) { - throw new IndexOutOfBoundsException("setLink: Index value '" + index + "' not in range [0.." + (this._linkList.size() - 1) + "]"); - } - - this._linkList.set(index, vLink); + if (_id != null && !org.castor.util.CycleBreaker.startingToCycle(_id)) { + result = 37 * result + _id.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_id); } - - /** - * - * - * @param vLinkArray - */ - public void setLink( - final uk.ac.vamsas.objects.core.Link[] vLinkArray) { - //-- copy array - _linkList.clear(); - - for (int i = 0; i < vLinkArray.length; i++) { - this._linkList.add(vLinkArray[i]); - } + if (_mapList != null + && !org.castor.util.CycleBreaker.startingToCycle(_mapList)) { + result = 37 * result + _mapList.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_mapList); } - - /** - * Sets the value of '_linkList' by copying the given Vector. - * All elements will be checked for type safety. - * - * @param vLinkList the Vector to copy. - */ - public void setLink( - final java.util.Vector vLinkList) { - // copy vector - this._linkList.clear(); - - this._linkList.addAll(vLinkList); + if (_linkList != null + && !org.castor.util.CycleBreaker.startingToCycle(_linkList)) { + result = 37 * result + _linkList.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_linkList); } - - /** - * Sets the value of '_linkList' by setting it to the given - * Vector. No type checking is performed. - * @deprecated - * - * @param linkVector the Vector to set. - */ - public void setLinkAsReference( - final java.util.Vector linkVector) { - this._linkList = linkVector; + if (_propertyList != null + && !org.castor.util.CycleBreaker.startingToCycle(_propertyList)) { + result = 37 * result + _propertyList.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_propertyList); } - /** - * - * - * @param index - * @param vMap - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setMap( - final int index, - final uk.ac.vamsas.objects.core.Map vMap) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._mapList.size()) { - throw new IndexOutOfBoundsException("setMap: Index value '" + index + "' not in range [0.." + (this._mapList.size() - 1) + "]"); - } - - this._mapList.set(index, vMap); + return result; + } + + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() { + try { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) { + return false; } - - /** - * - * - * @param vMapArray - */ - public void setMap( - final uk.ac.vamsas.objects.core.Map[] vMapArray) { - //-- copy array - _mapList.clear(); - - for (int i = 0; i < vMapArray.length; i++) { - this._mapList.add(vMapArray[i]); - } + return true; + } + + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, out); + } + + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, handler); + } + + /** + */ + public void removeAllLink() { + this._linkList.clear(); + } + + /** + */ + public void removeAllMap() { + this._mapList.clear(); + } + + /** + */ + public void removeAllProperty() { + this._propertyList.clear(); + } + + /** + * Method removeLink. + * + * @param vLink + * @return true if the object was removed from the collection. + */ + public boolean removeLink(final uk.ac.vamsas.objects.core.Link vLink) { + boolean removed = _linkList.remove(vLink); + return removed; + } + + /** + * Method removeLinkAt. + * + * @param index + * @return the element removed from the collection + */ + public uk.ac.vamsas.objects.core.Link removeLinkAt(final int index) { + java.lang.Object obj = this._linkList.remove(index); + return (uk.ac.vamsas.objects.core.Link) obj; + } + + /** + * Method removeMap. + * + * @param vMap + * @return true if the object was removed from the collection. + */ + public boolean removeMap(final uk.ac.vamsas.objects.core.Map vMap) { + boolean removed = _mapList.remove(vMap); + return removed; + } + + /** + * Method removeMapAt. + * + * @param index + * @return the element removed from the collection + */ + public uk.ac.vamsas.objects.core.Map removeMapAt(final int index) { + java.lang.Object obj = this._mapList.remove(index); + return (uk.ac.vamsas.objects.core.Map) obj; + } + + /** + * Method removeProperty. + * + * @param vProperty + * @return true if the object was removed from the collection. + */ + public boolean removeProperty( + final uk.ac.vamsas.objects.core.Property vProperty) { + boolean removed = _propertyList.remove(vProperty); + return removed; + } + + /** + * Method removePropertyAt. + * + * @param index + * @return the element removed from the collection + */ + public uk.ac.vamsas.objects.core.Property removePropertyAt(final int index) { + java.lang.Object obj = this._propertyList.remove(index); + return (uk.ac.vamsas.objects.core.Property) obj; + } + + /** + * Sets the value of field 'accessionId'. The field 'accessionId' has the + * following description: TODO: make some specification of the database field + * from which this accessionId is taken from - should that be a special + * property of the dbRef object ? + * + * + * @param accessionId + * the value of field 'accessionId'. + */ + public void setAccessionId(final java.lang.String accessionId) { + this._accessionId = accessionId; + } + + /** + * 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(final java.lang.String id) { + this._id = id; + } + + /** + * + * + * @param index + * @param vLink + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setLink(final int index, + final uk.ac.vamsas.objects.core.Link vLink) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._linkList.size()) { + throw new IndexOutOfBoundsException("setLink: Index value '" + index + + "' not in range [0.." + (this._linkList.size() - 1) + "]"); } - /** - * Sets the value of '_mapList' by copying the given Vector. - * All elements will be checked for type safety. - * - * @param vMapList the Vector to copy. - */ - public void setMap( - final java.util.Vector vMapList) { - // copy vector - this._mapList.clear(); - - this._mapList.addAll(vMapList); - } + this._linkList.set(index, vLink); + } - /** - * Sets the value of '_mapList' by setting it to the given - * Vector. No type checking is performed. - * @deprecated - * - * @param mapVector the Vector to set. - */ - public void setMapAsReference( - final java.util.Vector mapVector) { - this._mapList = mapVector; - } + /** + * + * + * @param vLinkArray + */ + public void setLink(final uk.ac.vamsas.objects.core.Link[] vLinkArray) { + // -- copy array + _linkList.clear(); - /** - * - * - * @param index - * @param vProperty - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setProperty( - final int index, - final uk.ac.vamsas.objects.core.Property vProperty) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._propertyList.size()) { - throw new IndexOutOfBoundsException("setProperty: Index value '" + index + "' not in range [0.." + (this._propertyList.size() - 1) + "]"); - } - - this._propertyList.set(index, vProperty); + for (int i = 0; i < vLinkArray.length; i++) { + this._linkList.add(vLinkArray[i]); } - - /** - * - * - * @param vPropertyArray - */ - public void setProperty( - final uk.ac.vamsas.objects.core.Property[] vPropertyArray) { - //-- copy array - _propertyList.clear(); - - for (int i = 0; i < vPropertyArray.length; i++) { - this._propertyList.add(vPropertyArray[i]); - } + } + + /** + * Sets the value of '_linkList' by copying the given Vector. All elements + * will be checked for type safety. + * + * @param vLinkList + * the Vector to copy. + */ + public void setLink(final java.util.Vector vLinkList) { + // copy vector + this._linkList.clear(); + + this._linkList.addAll(vLinkList); + } + + /** + * Sets the value of '_linkList' by setting it to the given Vector. No type + * checking is performed. + * + * @deprecated + * + * @param linkVector + * the Vector to set. + */ + public void setLinkAsReference(final java.util.Vector linkVector) { + this._linkList = linkVector; + } + + /** + * + * + * @param index + * @param vMap + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setMap(final int index, final uk.ac.vamsas.objects.core.Map vMap) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._mapList.size()) { + throw new IndexOutOfBoundsException("setMap: Index value '" + index + + "' not in range [0.." + (this._mapList.size() - 1) + "]"); } - /** - * Sets the value of '_propertyList' by copying the given - * Vector. All elements will be checked for type safety. - * - * @param vPropertyList the Vector to copy. - */ - public void setProperty( - final java.util.Vector vPropertyList) { - // copy vector - this._propertyList.clear(); - - this._propertyList.addAll(vPropertyList); - } + this._mapList.set(index, vMap); + } - /** - * Sets the value of '_propertyList' by setting it to the given - * Vector. No type checking is performed. - * @deprecated - * - * @param propertyVector the Vector to set. - */ - public void setPropertyAsReference( - final java.util.Vector propertyVector) { - this._propertyList = propertyVector; - } + /** + * + * + * @param vMapArray + */ + public void setMap(final uk.ac.vamsas.objects.core.Map[] vMapArray) { + // -- copy array + _mapList.clear(); - /** - * Sets the value of field 'source'. The field 'source' has the - * following description: TODO Database Naming - * Convention: either start using LSID (so - * change type to URI) or leave this as an - * uncontrolled/unspecified string ID - * - * - * @param source the value of field 'source'. - */ - public void setSource( - final java.lang.String source) { - this._source = source; + for (int i = 0; i < vMapArray.length; i++) { + this._mapList.add(vMapArray[i]); } - - /** - * Sets the value of field 'version'. The field 'version' has - * the following description: Version must be specified - - * - * - * @param version the value of field 'version'. - */ - public void setVersion( - final java.lang.String version) { - this._version = version; + } + + /** + * Sets the value of '_mapList' by copying the given Vector. All elements will + * be checked for type safety. + * + * @param vMapList + * the Vector to copy. + */ + public void setMap(final java.util.Vector vMapList) { + // copy vector + this._mapList.clear(); + + this._mapList.addAll(vMapList); + } + + /** + * Sets the value of '_mapList' by setting it to the given Vector. No type + * checking is performed. + * + * @deprecated + * + * @param mapVector + * the Vector to set. + */ + public void setMapAsReference(final java.util.Vector mapVector) { + this._mapList = mapVector; + } + + /** + * + * + * @param index + * @param vProperty + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setProperty(final int index, + final uk.ac.vamsas.objects.core.Property vProperty) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._propertyList.size()) { + throw new IndexOutOfBoundsException("setProperty: Index value '" + index + + "' not in range [0.." + (this._propertyList.size() - 1) + "]"); } - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled uk.ac.vamsas.objects.core.DbRef - */ - public static uk.ac.vamsas.objects.core.DbRef unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (uk.ac.vamsas.objects.core.DbRef) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.DbRef.class, reader); - } - - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); + this._propertyList.set(index, vProperty); + } + + /** + * + * + * @param vPropertyArray + */ + public void setProperty( + final uk.ac.vamsas.objects.core.Property[] vPropertyArray) { + // -- copy array + _propertyList.clear(); + + for (int i = 0; i < vPropertyArray.length; i++) { + this._propertyList.add(vPropertyArray[i]); } + } + + /** + * Sets the value of '_propertyList' by copying the given Vector. All elements + * will be checked for type safety. + * + * @param vPropertyList + * the Vector to copy. + */ + public void setProperty(final java.util.Vector vPropertyList) { + // copy vector + this._propertyList.clear(); + + this._propertyList.addAll(vPropertyList); + } + + /** + * Sets the value of '_propertyList' by setting it to the given Vector. No + * type checking is performed. + * + * @deprecated + * + * @param propertyVector + * the Vector to set. + */ + public void setPropertyAsReference(final java.util.Vector propertyVector) { + this._propertyList = propertyVector; + } + + /** + * Sets the value of field 'source'. The field 'source' has the following + * description: TODO Database Naming Convention: either start using LSID (so + * change type to URI) or leave this as an uncontrolled/unspecified string ID + * + * + * @param source + * the value of field 'source'. + */ + public void setSource(final java.lang.String source) { + this._source = source; + } + + /** + * Sets the value of field 'version'. The field 'version' has the following + * description: Version must be specified - + * + * + * @param version + * the value of field 'version'. + */ + public void setVersion(final java.lang.String version) { + this._version = version; + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @return the unmarshaled uk.ac.vamsas.objects.core.DbRef + */ + public static uk.ac.vamsas.objects.core.DbRef unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + return (uk.ac.vamsas.objects.core.DbRef) Unmarshaller.unmarshal( + uk.ac.vamsas.objects.core.DbRef.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/uk/ac/vamsas/objects/core/Entry.java b/src/uk/ac/vamsas/objects/core/Entry.java index 3415765..ac6093c 100644 --- a/src/uk/ac/vamsas/objects/core/Entry.java +++ b/src/uk/ac/vamsas/objects/core/Entry.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import org.exolab.castor.xml.Marshaller; @@ -17,1085 +31,1105 @@ import org.exolab.castor.xml.Unmarshaller; /** * Class Entry. * - * @version $Revision$ $Date$ + * @version $Revision$ $Date: 2007-06-28 14:51:44 +0100 (Thu, 28 Jun 2007) + * $ */ -public class Entry extends uk.ac.vamsas.client.Vobject -implements java.io.Serializable -{ - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Primary Key for vamsas object referencing - * - */ - private java.lang.String _id; - - /** - * Who - */ - private java.lang.String _user; - - /** - * With which application - */ - private java.lang.String _app; - - /** - * Did what - */ - private java.lang.String _action; - - /** - * When - */ - private java.util.Date _date; - - /** - * additional information - */ - private java.util.Vector _propertyList; - - /** - * parameter for the action - */ - private java.util.Vector _paramList; - - /** - * bioinformatic objects input to action - * - */ - private java.util.Vector _inputList; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public Entry() { - super(); - this._propertyList = new java.util.Vector(); - this._paramList = new java.util.Vector(); - this._inputList = new java.util.Vector(); - } - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * - * - * @param vInput - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addInput( - final uk.ac.vamsas.objects.core.Input vInput) - throws java.lang.IndexOutOfBoundsException { - this._inputList.addElement(vInput); - } - - /** - * - * - * @param index - * @param vInput - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addInput( - final int index, - final uk.ac.vamsas.objects.core.Input vInput) - throws java.lang.IndexOutOfBoundsException { - this._inputList.add(index, vInput); - } - - /** - * - * - * @param vParam - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addParam( - final uk.ac.vamsas.objects.core.Param vParam) - throws java.lang.IndexOutOfBoundsException { - this._paramList.addElement(vParam); - } - - /** - * - * - * @param index - * @param vParam - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addParam( - final int index, - final uk.ac.vamsas.objects.core.Param vParam) - throws java.lang.IndexOutOfBoundsException { - this._paramList.add(index, vParam); - } - - /** - * - * - * @param vProperty - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addProperty( - final uk.ac.vamsas.objects.core.Property vProperty) - throws java.lang.IndexOutOfBoundsException { - this._propertyList.addElement(vProperty); - } - - /** - * - * - * @param index - * @param vProperty - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addProperty( - final int index, - final uk.ac.vamsas.objects.core.Property vProperty) - throws java.lang.IndexOutOfBoundsException { - this._propertyList.add(index, vProperty); - } - - /** - * Method enumerateInput. - * - * @return an Enumeration over all - * uk.ac.vamsas.objects.core.Input elements - */ - public java.util.Enumeration enumerateInput( - ) { - return this._inputList.elements(); - } - - /** - * Method enumerateParam. - * - * @return an Enumeration over all - * uk.ac.vamsas.objects.core.Param elements - */ - public java.util.Enumeration enumerateParam( - ) { - return this._paramList.elements(); - } - - /** - * Method enumerateProperty. - * - * @return an Enumeration over all - * uk.ac.vamsas.objects.core.Property elements - */ - public java.util.Enumeration enumerateProperty( - ) { - return this._propertyList.elements(); - } - - /** - * Overrides the java.lang.Object.equals method. - * - * @param obj - * @return true if the objects are equal. - */ - public boolean equals( - final java.lang.Object obj) { - if ( this == obj ) - return true; - - if (super.equals(obj)==false) +public class Entry extends uk.ac.vamsas.client.Vobject implements + java.io.Serializable { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Primary Key for vamsas object referencing + * + */ + private java.lang.String _id; + + /** + * Who + */ + private java.lang.String _user; + + /** + * With which application + */ + private java.lang.String _app; + + /** + * Did what + */ + private java.lang.String _action; + + /** + * When + */ + private java.util.Date _date; + + /** + * additional information + */ + private java.util.Vector _propertyList; + + /** + * parameter for the action + */ + private java.util.Vector _paramList; + + /** + * bioinformatic objects input to action + * + */ + private java.util.Vector _inputList; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public Entry() { + super(); + this._propertyList = new java.util.Vector(); + this._paramList = new java.util.Vector(); + this._inputList = new java.util.Vector(); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * + * + * @param vInput + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addInput(final uk.ac.vamsas.objects.core.Input vInput) + throws java.lang.IndexOutOfBoundsException { + this._inputList.addElement(vInput); + } + + /** + * + * + * @param index + * @param vInput + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addInput(final int index, + final uk.ac.vamsas.objects.core.Input vInput) + throws java.lang.IndexOutOfBoundsException { + this._inputList.add(index, vInput); + } + + /** + * + * + * @param vParam + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addParam(final uk.ac.vamsas.objects.core.Param vParam) + throws java.lang.IndexOutOfBoundsException { + this._paramList.addElement(vParam); + } + + /** + * + * + * @param index + * @param vParam + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addParam(final int index, + final uk.ac.vamsas.objects.core.Param vParam) + throws java.lang.IndexOutOfBoundsException { + this._paramList.add(index, vParam); + } + + /** + * + * + * @param vProperty + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addProperty(final uk.ac.vamsas.objects.core.Property vProperty) + throws java.lang.IndexOutOfBoundsException { + this._propertyList.addElement(vProperty); + } + + /** + * + * + * @param index + * @param vProperty + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addProperty(final int index, + final uk.ac.vamsas.objects.core.Property vProperty) + throws java.lang.IndexOutOfBoundsException { + this._propertyList.add(index, vProperty); + } + + /** + * Method enumerateInput. + * + * @return an Enumeration over all uk.ac.vamsas.objects.core.Input elements + */ + public java.util.Enumeration enumerateInput() { + return this._inputList.elements(); + } + + /** + * Method enumerateParam. + * + * @return an Enumeration over all uk.ac.vamsas.objects.core.Param elements + */ + public java.util.Enumeration enumerateParam() { + return this._paramList.elements(); + } + + /** + * Method enumerateProperty. + * + * @return an Enumeration over all uk.ac.vamsas.objects.core.Property elements + */ + public java.util.Enumeration enumerateProperty() { + return this._propertyList.elements(); + } + + /** + * Overrides the java.lang.Object.equals method. + * + * @param obj + * @return true if the objects are equal. + */ + public boolean equals(final java.lang.Object obj) { + if (this == obj) + return true; + + if (super.equals(obj) == false) + return false; + + if (obj instanceof Entry) { + + Entry temp = (Entry) obj; + boolean thcycle; + boolean tmcycle; + if (this._id != null) { + if (temp._id == null) + return false; + if (this._id != temp._id) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._id); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._id); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._id); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); + } + ; return false; - - if (obj instanceof Entry) { - - Entry temp = (Entry)obj; - boolean thcycle; - boolean tmcycle; - if (this._id != null) { - if (temp._id == null) return false; - if (this._id != temp._id) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._id); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._id); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._id); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); }; - return false; - } - if (!thcycle) { - if (!this._id.equals(temp._id)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._id); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._id); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); - } - } - } else if (temp._id != null) - return false; - if (this._user != null) { - if (temp._user == null) return false; - if (this._user != temp._user) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._user); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._user); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._user); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._user); }; - return false; - } - if (!thcycle) { - if (!this._user.equals(temp._user)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._user); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._user); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._user); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._user); - } - } - } else if (temp._user != null) - return false; - if (this._app != null) { - if (temp._app == null) return false; - if (this._app != temp._app) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._app); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._app); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._app); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._app); }; - return false; - } - if (!thcycle) { - if (!this._app.equals(temp._app)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._app); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._app); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._app); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._app); - } - } - } else if (temp._app != null) - return false; - if (this._action != null) { - if (temp._action == null) return false; - if (this._action != temp._action) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._action); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._action); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._action); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._action); }; - return false; - } - if (!thcycle) { - if (!this._action.equals(temp._action)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._action); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._action); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._action); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._action); - } - } - } else if (temp._action != null) - return false; - if (this._date != null) { - if (temp._date == null) return false; - if (this._date != temp._date) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._date); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._date); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._date); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._date); }; - return false; - } - if (!thcycle) { - if (!this._date.equals(temp._date)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._date); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._date); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._date); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._date); - } - } - } else if (temp._date != null) - return false; - if (this._propertyList != null) { - if (temp._propertyList == null) return false; - if (this._propertyList != temp._propertyList) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._propertyList); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._propertyList); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._propertyList); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._propertyList); }; - return false; - } - if (!thcycle) { - if (!this._propertyList.equals(temp._propertyList)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._propertyList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._propertyList); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._propertyList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._propertyList); - } - } - } else if (temp._propertyList != null) - return false; - if (this._paramList != null) { - if (temp._paramList == null) return false; - if (this._paramList != temp._paramList) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._paramList); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._paramList); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._paramList); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._paramList); }; - return false; - } - if (!thcycle) { - if (!this._paramList.equals(temp._paramList)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._paramList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._paramList); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._paramList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._paramList); - } - } - } else if (temp._paramList != null) - return false; - if (this._inputList != null) { - if (temp._inputList == null) return false; - if (this._inputList != temp._inputList) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._inputList); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._inputList); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._inputList); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._inputList); }; - return false; - } - if (!thcycle) { - if (!this._inputList.equals(temp._inputList)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._inputList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._inputList); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._inputList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._inputList); - } - } - } else if (temp._inputList != null) - return false; - return true; + } + if (!thcycle) { + if (!this._id.equals(temp._id)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._id); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._id); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); + } } + } else if (temp._id != null) return false; - } - - /** - * Returns the value of field 'action'. The field 'action' has - * the following description: Did what - * - * @return the value of field 'Action'. - */ - public java.lang.String getAction( - ) { - return this._action; - } - - /** - * Returns the value of field 'app'. The field 'app' has the - * following description: With which application - * - * @return the value of field 'App'. - */ - public java.lang.String getApp( - ) { - return this._app; - } - - /** - * Returns the value of field 'date'. The field 'date' has the - * following description: When - * - * @return the value of field 'Date'. - */ - public java.util.Date getDate( - ) { - return this._date; - } - - /** - * Returns the value of field 'id'. The field 'id' has the - * following description: Primary Key for vamsas object - * referencing - * - * - * @return the value of field 'Id'. - */ - public java.lang.String getId( - ) { - return this._id; - } - - /** - * Method getInput. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the uk.ac.vamsas.objects.core.Input at - * the given index - */ - public uk.ac.vamsas.objects.core.Input getInput( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._inputList.size()) { - throw new IndexOutOfBoundsException("getInput: Index value '" + index + "' not in range [0.." + (this._inputList.size() - 1) + "]"); - } - - return (uk.ac.vamsas.objects.core.Input) _inputList.get(index); - } - - /** - * Method getInput.Returns the contents of the collection in an - * Array.

Note: Just in case the collection contents are - * changing in another thread, we pass a 0-length Array of the - * correct type into the API call. This way we know - * that the Array returned is of exactly the correct length. - * - * @return this collection as an Array - */ - public uk.ac.vamsas.objects.core.Input[] getInput( - ) { - uk.ac.vamsas.objects.core.Input[] array = new uk.ac.vamsas.objects.core.Input[0]; - return (uk.ac.vamsas.objects.core.Input[]) this._inputList.toArray(array); - } - - /** - * Method getInputAsReference.Returns a reference to - * '_inputList'. No type checking is performed on any - * modifications to the Vector. - * - * @return a reference to the Vector backing this class - */ - public java.util.Vector getInputAsReference( - ) { - return this._inputList; - } - - /** - * Method getInputCount. - * - * @return the size of this collection - */ - public int getInputCount( - ) { - return this._inputList.size(); - } - - /** - * Method getParam. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the uk.ac.vamsas.objects.core.Param at - * the given index - */ - public uk.ac.vamsas.objects.core.Param getParam( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._paramList.size()) { - throw new IndexOutOfBoundsException("getParam: Index value '" + index + "' not in range [0.." + (this._paramList.size() - 1) + "]"); - } - - return (uk.ac.vamsas.objects.core.Param) _paramList.get(index); - } - - /** - * Method getParam.Returns the contents of the collection in an - * Array.

Note: Just in case the collection contents are - * changing in another thread, we pass a 0-length Array of the - * correct type into the API call. This way we know - * that the Array returned is of exactly the correct length. - * - * @return this collection as an Array - */ - public uk.ac.vamsas.objects.core.Param[] getParam( - ) { - uk.ac.vamsas.objects.core.Param[] array = new uk.ac.vamsas.objects.core.Param[0]; - return (uk.ac.vamsas.objects.core.Param[]) this._paramList.toArray(array); - } - - /** - * Method getParamAsReference.Returns a reference to - * '_paramList'. No type checking is performed on any - * modifications to the Vector. - * - * @return a reference to the Vector backing this class - */ - public java.util.Vector getParamAsReference( - ) { - return this._paramList; - } - - /** - * Method getParamCount. - * - * @return the size of this collection - */ - public int getParamCount( - ) { - return this._paramList.size(); - } - - /** - * Method getProperty. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the uk.ac.vamsas.objects.core.Property - * at the given index - */ - public uk.ac.vamsas.objects.core.Property getProperty( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._propertyList.size()) { - throw new IndexOutOfBoundsException("getProperty: Index value '" + index + "' not in range [0.." + (this._propertyList.size() - 1) + "]"); - } - - return (uk.ac.vamsas.objects.core.Property) _propertyList.get(index); - } - - /** - * Method getProperty.Returns the contents of the collection in - * an Array.

Note: Just in case the collection contents - * are changing in another thread, we pass a 0-length Array of - * the correct type into the API call. This way we know - * that the Array returned is of exactly the correct length. - * - * @return this collection as an Array - */ - public uk.ac.vamsas.objects.core.Property[] getProperty( - ) { - uk.ac.vamsas.objects.core.Property[] array = new uk.ac.vamsas.objects.core.Property[0]; - return (uk.ac.vamsas.objects.core.Property[]) this._propertyList.toArray(array); - } - - /** - * Method getPropertyAsReference.Returns a reference to - * '_propertyList'. No type checking is performed on any - * modifications to the Vector. - * - * @return a reference to the Vector backing this class - */ - public java.util.Vector getPropertyAsReference( - ) { - return this._propertyList; - } - - /** - * Method getPropertyCount. - * - * @return the size of this collection - */ - public int getPropertyCount( - ) { - return this._propertyList.size(); - } - - /** - * Returns the value of field 'user'. The field 'user' has the - * following description: Who - * - * @return the value of field 'User'. - */ - public java.lang.String getUser( - ) { - return this._user; - } - - /** - * Overrides the java.lang.Object.hashCode method. - *

- * The following steps came from Effective Java Programming - * Language Guide by Joshua Bloch, Chapter 3 - * - * @return a hash code value for the object. - */ - public int hashCode( - ) { - int result = super.hashCode(); - - long tmp; - if (_id != null - && !org.castor.util.CycleBreaker.startingToCycle(_id)) { - result = 37 * result + _id.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_id); - } - if (_user != null - && !org.castor.util.CycleBreaker.startingToCycle(_user)) { - result = 37 * result + _user.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_user); - } - if (_app != null - && !org.castor.util.CycleBreaker.startingToCycle(_app)) { - result = 37 * result + _app.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_app); + if (this._user != null) { + if (temp._user == null) + return false; + if (this._user != temp._user) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._user); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._user); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._user); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._user); + } + ; + return false; + } + if (!thcycle) { + if (!this._user.equals(temp._user)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._user); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._user); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._user); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._user); + } } - if (_action != null - && !org.castor.util.CycleBreaker.startingToCycle(_action)) { - result = 37 * result + _action.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_action); + } else if (temp._user != null) + return false; + if (this._app != null) { + if (temp._app == null) + return false; + if (this._app != temp._app) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._app); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._app); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._app); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._app); + } + ; + return false; + } + if (!thcycle) { + if (!this._app.equals(temp._app)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._app); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._app); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._app); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._app); + } } - if (_date != null - && !org.castor.util.CycleBreaker.startingToCycle(_date)) { - result = 37 * result + _date.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_date); + } else if (temp._app != null) + return false; + if (this._action != null) { + if (temp._action == null) + return false; + if (this._action != temp._action) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._action); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._action); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._action); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._action); + } + ; + return false; + } + if (!thcycle) { + if (!this._action.equals(temp._action)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._action); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._action); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._action); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._action); + } } - if (_propertyList != null - && !org.castor.util.CycleBreaker.startingToCycle(_propertyList)) { - result = 37 * result + _propertyList.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_propertyList); + } else if (temp._action != null) + return false; + if (this._date != null) { + if (temp._date == null) + return false; + if (this._date != temp._date) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._date); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._date); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._date); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._date); + } + ; + return false; + } + if (!thcycle) { + if (!this._date.equals(temp._date)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._date); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._date); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._date); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._date); + } } - if (_paramList != null - && !org.castor.util.CycleBreaker.startingToCycle(_paramList)) { - result = 37 * result + _paramList.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_paramList); + } else if (temp._date != null) + return false; + if (this._propertyList != null) { + if (temp._propertyList == null) + return false; + if (this._propertyList != temp._propertyList) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._propertyList); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._propertyList); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker + .releaseCycleHandle(this._propertyList); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._propertyList); + } + ; + return false; + } + if (!thcycle) { + if (!this._propertyList.equals(temp._propertyList)) { + org.castor.util.CycleBreaker + .releaseCycleHandle(this._propertyList); + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._propertyList); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._propertyList); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._propertyList); + } } - if (_inputList != null - && !org.castor.util.CycleBreaker.startingToCycle(_inputList)) { - result = 37 * result + _inputList.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_inputList); + } else if (temp._propertyList != null) + return false; + if (this._paramList != null) { + if (temp._paramList == null) + return false; + if (this._paramList != temp._paramList) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._paramList); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._paramList); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._paramList); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._paramList); + } + ; + return false; + } + if (!thcycle) { + if (!this._paramList.equals(temp._paramList)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._paramList); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._paramList); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._paramList); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._paramList); + } } - - return result; - } - - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { + } else if (temp._paramList != null) + return false; + if (this._inputList != null) { + if (temp._inputList == null) + return false; + if (this._inputList != temp._inputList) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._inputList); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._inputList); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._inputList); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._inputList); + } + ; return false; + } + if (!thcycle) { + if (!this._inputList.equals(temp._inputList)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._inputList); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._inputList); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._inputList); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._inputList); + } } - return true; - } - - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } - - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } - - /** - */ - public void removeAllInput( - ) { - this._inputList.clear(); - } - - /** - */ - public void removeAllParam( - ) { - this._paramList.clear(); - } - - /** - */ - public void removeAllProperty( - ) { - this._propertyList.clear(); - } - - /** - * Method removeInput. - * - * @param vInput - * @return true if the object was removed from the collection. - */ - public boolean removeInput( - final uk.ac.vamsas.objects.core.Input vInput) { - boolean removed = _inputList.remove(vInput); - return removed; + } else if (temp._inputList != null) + return false; + return true; } - - /** - * Method removeInputAt. - * - * @param index - * @return the element removed from the collection - */ - public uk.ac.vamsas.objects.core.Input removeInputAt( - final int index) { - java.lang.Object obj = this._inputList.remove(index); - return (uk.ac.vamsas.objects.core.Input) obj; + return false; + } + + /** + * Returns the value of field 'action'. The field 'action' has the following + * description: Did what + * + * @return the value of field 'Action'. + */ + public java.lang.String getAction() { + return this._action; + } + + /** + * Returns the value of field 'app'. The field 'app' has the following + * description: With which application + * + * @return the value of field 'App'. + */ + public java.lang.String getApp() { + return this._app; + } + + /** + * Returns the value of field 'date'. The field 'date' has the following + * description: When + * + * @return the value of field 'Date'. + */ + public java.util.Date getDate() { + return this._date; + } + + /** + * Returns the value of field 'id'. The field 'id' has the following + * description: Primary Key for vamsas object referencing + * + * + * @return the value of field 'Id'. + */ + public java.lang.String getId() { + return this._id; + } + + /** + * Method getInput. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the uk.ac.vamsas.objects.core.Input at the given index + */ + public uk.ac.vamsas.objects.core.Input getInput(final int index) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._inputList.size()) { + throw new IndexOutOfBoundsException("getInput: Index value '" + index + + "' not in range [0.." + (this._inputList.size() - 1) + "]"); } - /** - * Method removeParam. - * - * @param vParam - * @return true if the object was removed from the collection. - */ - public boolean removeParam( - final uk.ac.vamsas.objects.core.Param vParam) { - boolean removed = _paramList.remove(vParam); - return removed; + return (uk.ac.vamsas.objects.core.Input) _inputList.get(index); + } + + /** + * Method getInput.Returns the contents of the collection in an Array. + *

+ * Note: Just in case the collection contents are changing in another thread, + * we pass a 0-length Array of the correct type into the API call. This way we + * know that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public uk.ac.vamsas.objects.core.Input[] getInput() { + uk.ac.vamsas.objects.core.Input[] array = new uk.ac.vamsas.objects.core.Input[0]; + return (uk.ac.vamsas.objects.core.Input[]) this._inputList.toArray(array); + } + + /** + * Method getInputAsReference.Returns a reference to '_inputList'. No type + * checking is performed on any modifications to the Vector. + * + * @return a reference to the Vector backing this class + */ + public java.util.Vector getInputAsReference() { + return this._inputList; + } + + /** + * Method getInputCount. + * + * @return the size of this collection + */ + public int getInputCount() { + return this._inputList.size(); + } + + /** + * Method getParam. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the uk.ac.vamsas.objects.core.Param at the given index + */ + public uk.ac.vamsas.objects.core.Param getParam(final int index) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._paramList.size()) { + throw new IndexOutOfBoundsException("getParam: Index value '" + index + + "' not in range [0.." + (this._paramList.size() - 1) + "]"); } - /** - * Method removeParamAt. - * - * @param index - * @return the element removed from the collection - */ - public uk.ac.vamsas.objects.core.Param removeParamAt( - final int index) { - java.lang.Object obj = this._paramList.remove(index); - return (uk.ac.vamsas.objects.core.Param) obj; + return (uk.ac.vamsas.objects.core.Param) _paramList.get(index); + } + + /** + * Method getParam.Returns the contents of the collection in an Array. + *

+ * Note: Just in case the collection contents are changing in another thread, + * we pass a 0-length Array of the correct type into the API call. This way we + * know that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public uk.ac.vamsas.objects.core.Param[] getParam() { + uk.ac.vamsas.objects.core.Param[] array = new uk.ac.vamsas.objects.core.Param[0]; + return (uk.ac.vamsas.objects.core.Param[]) this._paramList.toArray(array); + } + + /** + * Method getParamAsReference.Returns a reference to '_paramList'. No type + * checking is performed on any modifications to the Vector. + * + * @return a reference to the Vector backing this class + */ + public java.util.Vector getParamAsReference() { + return this._paramList; + } + + /** + * Method getParamCount. + * + * @return the size of this collection + */ + public int getParamCount() { + return this._paramList.size(); + } + + /** + * Method getProperty. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the uk.ac.vamsas.objects.core.Property at the given + * index + */ + public uk.ac.vamsas.objects.core.Property getProperty(final int index) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._propertyList.size()) { + throw new IndexOutOfBoundsException("getProperty: Index value '" + index + + "' not in range [0.." + (this._propertyList.size() - 1) + "]"); } - /** - * Method removeProperty. - * - * @param vProperty - * @return true if the object was removed from the collection. - */ - public boolean removeProperty( - final uk.ac.vamsas.objects.core.Property vProperty) { - boolean removed = _propertyList.remove(vProperty); - return removed; + return (uk.ac.vamsas.objects.core.Property) _propertyList.get(index); + } + + /** + * Method getProperty.Returns the contents of the collection in an Array. + *

+ * Note: Just in case the collection contents are changing in another thread, + * we pass a 0-length Array of the correct type into the API call. This way we + * know that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public uk.ac.vamsas.objects.core.Property[] getProperty() { + uk.ac.vamsas.objects.core.Property[] array = new uk.ac.vamsas.objects.core.Property[0]; + return (uk.ac.vamsas.objects.core.Property[]) this._propertyList + .toArray(array); + } + + /** + * Method getPropertyAsReference.Returns a reference to '_propertyList'. No + * type checking is performed on any modifications to the Vector. + * + * @return a reference to the Vector backing this class + */ + public java.util.Vector getPropertyAsReference() { + return this._propertyList; + } + + /** + * Method getPropertyCount. + * + * @return the size of this collection + */ + public int getPropertyCount() { + return this._propertyList.size(); + } + + /** + * Returns the value of field 'user'. The field 'user' has the following + * description: Who + * + * @return the value of field 'User'. + */ + public java.lang.String getUser() { + return this._user; + } + + /** + * Overrides the java.lang.Object.hashCode method. + *

+ * The following steps came from Effective Java Programming Language + * Guide by Joshua Bloch, Chapter 3 + * + * @return a hash code value for the object. + */ + public int hashCode() { + int result = super.hashCode(); + + long tmp; + if (_id != null && !org.castor.util.CycleBreaker.startingToCycle(_id)) { + result = 37 * result + _id.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_id); } - - /** - * Method removePropertyAt. - * - * @param index - * @return the element removed from the collection - */ - public uk.ac.vamsas.objects.core.Property removePropertyAt( - final int index) { - java.lang.Object obj = this._propertyList.remove(index); - return (uk.ac.vamsas.objects.core.Property) obj; + if (_user != null && !org.castor.util.CycleBreaker.startingToCycle(_user)) { + result = 37 * result + _user.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_user); } - - /** - * Sets the value of field 'action'. The field 'action' has the - * following description: Did what - * - * @param action the value of field 'action'. - */ - public void setAction( - final java.lang.String action) { - this._action = action; + if (_app != null && !org.castor.util.CycleBreaker.startingToCycle(_app)) { + result = 37 * result + _app.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_app); } - - /** - * Sets the value of field 'app'. The field 'app' has the - * following description: With which application - * - * @param app the value of field 'app'. - */ - public void setApp( - final java.lang.String app) { - this._app = app; + if (_action != null + && !org.castor.util.CycleBreaker.startingToCycle(_action)) { + result = 37 * result + _action.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_action); } - - /** - * Sets the value of field 'date'. The field 'date' has the - * following description: When - * - * @param date the value of field 'date'. - */ - public void setDate( - final java.util.Date date) { - this._date = date; - } - - /** - * 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( - final java.lang.String id) { - this._id = id; - } - - /** - * - * - * @param index - * @param vInput - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setInput( - final int index, - final uk.ac.vamsas.objects.core.Input vInput) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._inputList.size()) { - throw new IndexOutOfBoundsException("setInput: Index value '" + index + "' not in range [0.." + (this._inputList.size() - 1) + "]"); - } - - this._inputList.set(index, vInput); + if (_date != null && !org.castor.util.CycleBreaker.startingToCycle(_date)) { + result = 37 * result + _date.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_date); } - - /** - * - * - * @param vInputArray - */ - public void setInput( - final uk.ac.vamsas.objects.core.Input[] vInputArray) { - //-- copy array - _inputList.clear(); - - for (int i = 0; i < vInputArray.length; i++) { - this._inputList.add(vInputArray[i]); - } + if (_propertyList != null + && !org.castor.util.CycleBreaker.startingToCycle(_propertyList)) { + result = 37 * result + _propertyList.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_propertyList); } - - /** - * Sets the value of '_inputList' by copying the given Vector. - * All elements will be checked for type safety. - * - * @param vInputList the Vector to copy. - */ - public void setInput( - final java.util.Vector vInputList) { - // copy vector - this._inputList.clear(); - - this._inputList.addAll(vInputList); + if (_paramList != null + && !org.castor.util.CycleBreaker.startingToCycle(_paramList)) { + result = 37 * result + _paramList.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_paramList); } - - /** - * Sets the value of '_inputList' by setting it to the given - * Vector. No type checking is performed. - * @deprecated - * - * @param inputVector the Vector to set. - */ - public void setInputAsReference( - final java.util.Vector inputVector) { - this._inputList = inputVector; + if (_inputList != null + && !org.castor.util.CycleBreaker.startingToCycle(_inputList)) { + result = 37 * result + _inputList.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_inputList); } - /** - * - * - * @param index - * @param vParam - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setParam( - final int index, - final uk.ac.vamsas.objects.core.Param vParam) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._paramList.size()) { - throw new IndexOutOfBoundsException("setParam: Index value '" + index + "' not in range [0.." + (this._paramList.size() - 1) + "]"); - } - - this._paramList.set(index, vParam); + return result; + } + + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() { + try { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) { + return false; } - - /** - * - * - * @param vParamArray - */ - public void setParam( - final uk.ac.vamsas.objects.core.Param[] vParamArray) { - //-- copy array - _paramList.clear(); - - for (int i = 0; i < vParamArray.length; i++) { - this._paramList.add(vParamArray[i]); - } + return true; + } + + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, out); + } + + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, handler); + } + + /** + */ + public void removeAllInput() { + this._inputList.clear(); + } + + /** + */ + public void removeAllParam() { + this._paramList.clear(); + } + + /** + */ + public void removeAllProperty() { + this._propertyList.clear(); + } + + /** + * Method removeInput. + * + * @param vInput + * @return true if the object was removed from the collection. + */ + public boolean removeInput(final uk.ac.vamsas.objects.core.Input vInput) { + boolean removed = _inputList.remove(vInput); + return removed; + } + + /** + * Method removeInputAt. + * + * @param index + * @return the element removed from the collection + */ + public uk.ac.vamsas.objects.core.Input removeInputAt(final int index) { + java.lang.Object obj = this._inputList.remove(index); + return (uk.ac.vamsas.objects.core.Input) obj; + } + + /** + * Method removeParam. + * + * @param vParam + * @return true if the object was removed from the collection. + */ + public boolean removeParam(final uk.ac.vamsas.objects.core.Param vParam) { + boolean removed = _paramList.remove(vParam); + return removed; + } + + /** + * Method removeParamAt. + * + * @param index + * @return the element removed from the collection + */ + public uk.ac.vamsas.objects.core.Param removeParamAt(final int index) { + java.lang.Object obj = this._paramList.remove(index); + return (uk.ac.vamsas.objects.core.Param) obj; + } + + /** + * Method removeProperty. + * + * @param vProperty + * @return true if the object was removed from the collection. + */ + public boolean removeProperty( + final uk.ac.vamsas.objects.core.Property vProperty) { + boolean removed = _propertyList.remove(vProperty); + return removed; + } + + /** + * Method removePropertyAt. + * + * @param index + * @return the element removed from the collection + */ + public uk.ac.vamsas.objects.core.Property removePropertyAt(final int index) { + java.lang.Object obj = this._propertyList.remove(index); + return (uk.ac.vamsas.objects.core.Property) obj; + } + + /** + * Sets the value of field 'action'. The field 'action' has the following + * description: Did what + * + * @param action + * the value of field 'action'. + */ + public void setAction(final java.lang.String action) { + this._action = action; + } + + /** + * Sets the value of field 'app'. The field 'app' has the following + * description: With which application + * + * @param app + * the value of field 'app'. + */ + public void setApp(final java.lang.String app) { + this._app = app; + } + + /** + * Sets the value of field 'date'. The field 'date' has the following + * description: When + * + * @param date + * the value of field 'date'. + */ + public void setDate(final java.util.Date date) { + this._date = date; + } + + /** + * 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(final java.lang.String id) { + this._id = id; + } + + /** + * + * + * @param index + * @param vInput + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setInput(final int index, + final uk.ac.vamsas.objects.core.Input vInput) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._inputList.size()) { + throw new IndexOutOfBoundsException("setInput: Index value '" + index + + "' not in range [0.." + (this._inputList.size() - 1) + "]"); } - /** - * Sets the value of '_paramList' by copying the given Vector. - * All elements will be checked for type safety. - * - * @param vParamList the Vector to copy. - */ - public void setParam( - final java.util.Vector vParamList) { - // copy vector - this._paramList.clear(); - - this._paramList.addAll(vParamList); - } + this._inputList.set(index, vInput); + } - /** - * Sets the value of '_paramList' by setting it to the given - * Vector. No type checking is performed. - * @deprecated - * - * @param paramVector the Vector to set. - */ - public void setParamAsReference( - final java.util.Vector paramVector) { - this._paramList = paramVector; - } + /** + * + * + * @param vInputArray + */ + public void setInput(final uk.ac.vamsas.objects.core.Input[] vInputArray) { + // -- copy array + _inputList.clear(); - /** - * - * - * @param index - * @param vProperty - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setProperty( - final int index, - final uk.ac.vamsas.objects.core.Property vProperty) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._propertyList.size()) { - throw new IndexOutOfBoundsException("setProperty: Index value '" + index + "' not in range [0.." + (this._propertyList.size() - 1) + "]"); - } - - this._propertyList.set(index, vProperty); + for (int i = 0; i < vInputArray.length; i++) { + this._inputList.add(vInputArray[i]); } - - /** - * - * - * @param vPropertyArray - */ - public void setProperty( - final uk.ac.vamsas.objects.core.Property[] vPropertyArray) { - //-- copy array - _propertyList.clear(); - - for (int i = 0; i < vPropertyArray.length; i++) { - this._propertyList.add(vPropertyArray[i]); - } + } + + /** + * Sets the value of '_inputList' by copying the given Vector. All elements + * will be checked for type safety. + * + * @param vInputList + * the Vector to copy. + */ + public void setInput(final java.util.Vector vInputList) { + // copy vector + this._inputList.clear(); + + this._inputList.addAll(vInputList); + } + + /** + * Sets the value of '_inputList' by setting it to the given Vector. No type + * checking is performed. + * + * @deprecated + * + * @param inputVector + * the Vector to set. + */ + public void setInputAsReference(final java.util.Vector inputVector) { + this._inputList = inputVector; + } + + /** + * + * + * @param index + * @param vParam + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setParam(final int index, + final uk.ac.vamsas.objects.core.Param vParam) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._paramList.size()) { + throw new IndexOutOfBoundsException("setParam: Index value '" + index + + "' not in range [0.." + (this._paramList.size() - 1) + "]"); } - /** - * Sets the value of '_propertyList' by copying the given - * Vector. All elements will be checked for type safety. - * - * @param vPropertyList the Vector to copy. - */ - public void setProperty( - final java.util.Vector vPropertyList) { - // copy vector - this._propertyList.clear(); - - this._propertyList.addAll(vPropertyList); - } + this._paramList.set(index, vParam); + } - /** - * Sets the value of '_propertyList' by setting it to the given - * Vector. No type checking is performed. - * @deprecated - * - * @param propertyVector the Vector to set. - */ - public void setPropertyAsReference( - final java.util.Vector propertyVector) { - this._propertyList = propertyVector; - } + /** + * + * + * @param vParamArray + */ + public void setParam(final uk.ac.vamsas.objects.core.Param[] vParamArray) { + // -- copy array + _paramList.clear(); - /** - * Sets the value of field 'user'. The field 'user' has the - * following description: Who - * - * @param user the value of field 'user'. - */ - public void setUser( - final java.lang.String user) { - this._user = user; + for (int i = 0; i < vParamArray.length; i++) { + this._paramList.add(vParamArray[i]); } - - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled uk.ac.vamsas.objects.core.Entry - */ - public static uk.ac.vamsas.objects.core.Entry unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (uk.ac.vamsas.objects.core.Entry) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.Entry.class, reader); + } + + /** + * Sets the value of '_paramList' by copying the given Vector. All elements + * will be checked for type safety. + * + * @param vParamList + * the Vector to copy. + */ + public void setParam(final java.util.Vector vParamList) { + // copy vector + this._paramList.clear(); + + this._paramList.addAll(vParamList); + } + + /** + * Sets the value of '_paramList' by setting it to the given Vector. No type + * checking is performed. + * + * @deprecated + * + * @param paramVector + * the Vector to set. + */ + public void setParamAsReference(final java.util.Vector paramVector) { + this._paramList = paramVector; + } + + /** + * + * + * @param index + * @param vProperty + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setProperty(final int index, + final uk.ac.vamsas.objects.core.Property vProperty) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._propertyList.size()) { + throw new IndexOutOfBoundsException("setProperty: Index value '" + index + + "' not in range [0.." + (this._propertyList.size() - 1) + "]"); } - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); + this._propertyList.set(index, vProperty); + } + + /** + * + * + * @param vPropertyArray + */ + public void setProperty( + final uk.ac.vamsas.objects.core.Property[] vPropertyArray) { + // -- copy array + _propertyList.clear(); + + for (int i = 0; i < vPropertyArray.length; i++) { + this._propertyList.add(vPropertyArray[i]); } + } + + /** + * Sets the value of '_propertyList' by copying the given Vector. All elements + * will be checked for type safety. + * + * @param vPropertyList + * the Vector to copy. + */ + public void setProperty(final java.util.Vector vPropertyList) { + // copy vector + this._propertyList.clear(); + + this._propertyList.addAll(vPropertyList); + } + + /** + * Sets the value of '_propertyList' by setting it to the given Vector. No + * type checking is performed. + * + * @deprecated + * + * @param propertyVector + * the Vector to set. + */ + public void setPropertyAsReference(final java.util.Vector propertyVector) { + this._propertyList = propertyVector; + } + + /** + * Sets the value of field 'user'. The field 'user' has the following + * description: Who + * + * @param user + * the value of field 'user'. + */ + public void setUser(final java.lang.String user) { + this._user = user; + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @return the unmarshaled uk.ac.vamsas.objects.core.Entry + */ + public static uk.ac.vamsas.objects.core.Entry unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + return (uk.ac.vamsas.objects.core.Entry) Unmarshaller.unmarshal( + uk.ac.vamsas.objects.core.Entry.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/uk/ac/vamsas/objects/core/Glyph.java b/src/uk/ac/vamsas/objects/core/Glyph.java index e96b4fd..20fe7d6 100644 --- a/src/uk/ac/vamsas/objects/core/Glyph.java +++ b/src/uk/ac/vamsas/objects/core/Glyph.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import org.exolab.castor.xml.Marshaller; @@ -16,272 +30,271 @@ import org.exolab.castor.xml.Unmarshaller; /** * Discrete symbol - possibly graphically represented - * + * * * @version $Revision$ $Date$ */ -public class Glyph extends uk.ac.vamsas.client.Vobject -implements java.io.Serializable -{ +public class Glyph extends uk.ac.vamsas.client.Vobject implements + java.io.Serializable { + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ + /** + * internal content storage + */ + private java.lang.String _content = ""; - /** - * internal content storage - */ - private java.lang.String _content = ""; + /** + * specifies the symbol dictionary for this glyph - eg utf8 (the default), + * aasecstr_3 or kd_hydrophobicity - the content is not validated so + * applications must ensure they gracefully deal with invalid entries here + */ + private java.lang.String _dict = "utf8"; - /** - * specifies the symbol dictionary for this - * glyph - eg utf8 (the default), aasecstr_3 or - * kd_hydrophobicity - the content is not validated so - * applications must ensure they gracefully deal with - * invalid entries here - */ - private java.lang.String _dict = "utf8"; + // ----------------/ + // - Constructors -/ + // ----------------/ + public Glyph() { + super(); + setContent(""); + setDict("utf8"); + } - //----------------/ - //- Constructors -/ - //----------------/ + // -----------/ + // - Methods -/ + // -----------/ - public Glyph() { - super(); - setContent(""); - setDict("utf8"); - } + /** + * Overrides the java.lang.Object.equals method. + * + * @param obj + * @return true if the objects are equal. + */ + public boolean equals(final java.lang.Object obj) { + if (this == obj) + return true; + if (super.equals(obj) == false) + return false; - //-----------/ - //- Methods -/ - //-----------/ + if (obj instanceof Glyph) { - /** - * Overrides the java.lang.Object.equals method. - * - * @param obj - * @return true if the objects are equal. - */ - public boolean equals( - final java.lang.Object obj) { - if ( this == obj ) - return true; - - if (super.equals(obj)==false) + Glyph temp = (Glyph) obj; + boolean thcycle; + boolean tmcycle; + if (this._content != null) { + if (temp._content == null) + return false; + if (this._content != temp._content) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._content); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._content); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._content); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._content); + } + ; return false; - - if (obj instanceof Glyph) { - - Glyph temp = (Glyph)obj; - boolean thcycle; - boolean tmcycle; - if (this._content != null) { - if (temp._content == null) return false; - if (this._content != temp._content) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._content); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._content); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._content); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._content); }; - return false; - } - if (!thcycle) { - if (!this._content.equals(temp._content)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._content); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._content); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._content); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._content); - } - } - } else if (temp._content != null) - return false; - if (this._dict != null) { - if (temp._dict == null) return false; - if (this._dict != temp._dict) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._dict); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._dict); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._dict); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._dict); }; - return false; - } - if (!thcycle) { - if (!this._dict.equals(temp._dict)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._dict); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._dict); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._dict); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._dict); - } - } - } else if (temp._dict != null) - return false; - return true; + } + if (!thcycle) { + if (!this._content.equals(temp._content)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._content); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._content); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._content); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._content); + } } + } else if (temp._content != null) return false; + if (this._dict != null) { + if (temp._dict == null) + return false; + if (this._dict != temp._dict) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._dict); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._dict); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._dict); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._dict); + } + ; + return false; + } + if (!thcycle) { + if (!this._dict.equals(temp._dict)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._dict); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._dict); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._dict); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._dict); + } + } + } else if (temp._dict != null) + return false; + return true; } + return false; + } - /** - * Returns the value of field 'content'. The field 'content' - * has the following description: internal content storage - * - * @return the value of field 'Content'. - */ - public java.lang.String getContent( - ) { - return this._content; - } + /** + * Returns the value of field 'content'. The field 'content' has the following + * description: internal content storage + * + * @return the value of field 'Content'. + */ + public java.lang.String getContent() { + return this._content; + } - /** - * Returns the value of field 'dict'. The field 'dict' has the - * following description: specifies the symbol dictionary for - * this - * glyph - eg utf8 (the default), aasecstr_3 or - * kd_hydrophobicity - the content is not validated so - * applications must ensure they gracefully deal with - * invalid entries here - * - * @return the value of field 'Dict'. - */ - public java.lang.String getDict( - ) { - return this._dict; - } + /** + * Returns the value of field 'dict'. The field 'dict' has the following + * description: specifies the symbol dictionary for this glyph - eg utf8 (the + * default), aasecstr_3 or kd_hydrophobicity - the content is not validated so + * applications must ensure they gracefully deal with invalid entries here + * + * @return the value of field 'Dict'. + */ + public java.lang.String getDict() { + return this._dict; + } - /** - * Overrides the java.lang.Object.hashCode method. - *

- * The following steps came from Effective Java Programming - * Language Guide by Joshua Bloch, Chapter 3 - * - * @return a hash code value for the object. - */ - public int hashCode( - ) { - int result = super.hashCode(); - - long tmp; - if (_content != null - && !org.castor.util.CycleBreaker.startingToCycle(_content)) { - result = 37 * result + _content.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_content); - } - if (_dict != null - && !org.castor.util.CycleBreaker.startingToCycle(_dict)) { - result = 37 * result + _dict.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_dict); - } - - return result; - } + /** + * Overrides the java.lang.Object.hashCode method. + *

+ * The following steps came from Effective Java Programming Language + * Guide by Joshua Bloch, Chapter 3 + * + * @return a hash code value for the object. + */ + public int hashCode() { + int result = super.hashCode(); - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { - return false; - } - return true; + long tmp; + if (_content != null + && !org.castor.util.CycleBreaker.startingToCycle(_content)) { + result = 37 * result + _content.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_content); } - - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); + if (_dict != null && !org.castor.util.CycleBreaker.startingToCycle(_dict)) { + result = 37 * result + _dict.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_dict); } - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } + return result; + } - /** - * Sets the value of field 'content'. The field 'content' has - * the following description: internal content storage - * - * @param content the value of field 'content'. - */ - public void setContent( - final java.lang.String content) { - this._content = content; + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() { + try { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) { + return false; } + return true; + } - /** - * Sets the value of field 'dict'. The field 'dict' has the - * following description: specifies the symbol dictionary for - * this - * glyph - eg utf8 (the default), aasecstr_3 or - * kd_hydrophobicity - the content is not validated so - * applications must ensure they gracefully deal with - * invalid entries here - * - * @param dict the value of field 'dict'. - */ - public void setDict( - final java.lang.String dict) { - this._dict = dict; - } + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, out); + } - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled uk.ac.vamsas.objects.core.Glyph - */ - public static uk.ac.vamsas.objects.core.Glyph unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (uk.ac.vamsas.objects.core.Glyph) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.Glyph.class, reader); - } + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, handler); + } - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); - } + /** + * Sets the value of field 'content'. The field 'content' has the following + * description: internal content storage + * + * @param content + * the value of field 'content'. + */ + public void setContent(final java.lang.String content) { + this._content = content; + } + + /** + * Sets the value of field 'dict'. The field 'dict' has the following + * description: specifies the symbol dictionary for this glyph - eg utf8 (the + * default), aasecstr_3 or kd_hydrophobicity - the content is not validated so + * applications must ensure they gracefully deal with invalid entries here + * + * @param dict + * the value of field 'dict'. + */ + public void setDict(final java.lang.String dict) { + this._dict = dict; + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @return the unmarshaled uk.ac.vamsas.objects.core.Glyph + */ + public static uk.ac.vamsas.objects.core.Glyph unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + return (uk.ac.vamsas.objects.core.Glyph) Unmarshaller.unmarshal( + uk.ac.vamsas.objects.core.Glyph.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/uk/ac/vamsas/objects/core/Input.java b/src/uk/ac/vamsas/objects/core/Input.java index b5b2de9..3911cdc 100644 --- a/src/uk/ac/vamsas/objects/core/Input.java +++ b/src/uk/ac/vamsas/objects/core/Input.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import org.exolab.castor.xml.Marshaller; @@ -19,416 +33,412 @@ import org.exolab.castor.xml.Unmarshaller; * * @version $Revision$ $Date$ */ -public class Input extends uk.ac.vamsas.objects.core.RangeType -implements java.io.Serializable -{ - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _name. - */ - private java.lang.String _name; - - /** - * Reference Frame for rangeType specfication - * - */ - private java.util.Vector _objRef; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public Input() { - super(); - this._objRef = new java.util.Vector(); - } - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * - * - * @param vObjRef - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addObjRef( - final java.lang.Object vObjRef) - throws java.lang.IndexOutOfBoundsException { - this._objRef.addElement(vObjRef); - } - - /** - * - * - * @param index - * @param vObjRef - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addObjRef( - final int index, - final java.lang.Object vObjRef) - throws java.lang.IndexOutOfBoundsException { - this._objRef.add(index, vObjRef); - } - - /** - * Method enumerateObjRef. - * - * @return an Enumeration over all java.lang.Object elements - */ - public java.util.Enumeration enumerateObjRef( - ) { - return this._objRef.elements(); - } - - /** - * Overrides the java.lang.Object.equals method. - * - * @param obj - * @return true if the objects are equal. - */ - public boolean equals( - final java.lang.Object obj) { - if ( this == obj ) - return true; - - if (super.equals(obj)==false) +public class Input extends uk.ac.vamsas.objects.core.RangeType implements + java.io.Serializable { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _name. + */ + private java.lang.String _name; + + /** + * Reference Frame for rangeType specfication + * + */ + private java.util.Vector _objRef; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public Input() { + super(); + this._objRef = new java.util.Vector(); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * + * + * @param vObjRef + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addObjRef(final java.lang.Object vObjRef) + throws java.lang.IndexOutOfBoundsException { + this._objRef.addElement(vObjRef); + } + + /** + * + * + * @param index + * @param vObjRef + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addObjRef(final int index, final java.lang.Object vObjRef) + throws java.lang.IndexOutOfBoundsException { + this._objRef.add(index, vObjRef); + } + + /** + * Method enumerateObjRef. + * + * @return an Enumeration over all java.lang.Object elements + */ + public java.util.Enumeration enumerateObjRef() { + return this._objRef.elements(); + } + + /** + * Overrides the java.lang.Object.equals method. + * + * @param obj + * @return true if the objects are equal. + */ + public boolean equals(final java.lang.Object obj) { + if (this == obj) + return true; + + if (super.equals(obj) == false) + return false; + + if (obj instanceof Input) { + + Input temp = (Input) obj; + boolean thcycle; + boolean tmcycle; + if (this._name != null) { + if (temp._name == null) + return false; + if (this._name != temp._name) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._name); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._name); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._name); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._name); + } + ; return false; - - if (obj instanceof Input) { - - Input temp = (Input)obj; - boolean thcycle; - boolean tmcycle; - if (this._name != null) { - if (temp._name == null) return false; - if (this._name != temp._name) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._name); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._name); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._name); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._name); }; - return false; - } - if (!thcycle) { - if (!this._name.equals(temp._name)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._name); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._name); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._name); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._name); - } - } - } else if (temp._name != null) - return false; - if (this._objRef != null) { - if (temp._objRef == null) return false; - if (this._objRef != temp._objRef) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._objRef); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._objRef); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._objRef); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._objRef); }; - return false; - } - if (!thcycle) { - if (!this._objRef.equals(temp._objRef)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._objRef); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._objRef); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._objRef); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._objRef); - } - } - } else if (temp._objRef != null) - return false; - return true; + } + if (!thcycle) { + if (!this._name.equals(temp._name)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._name); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._name); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._name); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._name); + } } + } else if (temp._name != null) return false; - } - - /** - * Returns the value of field 'name'. - * - * @return the value of field 'Name'. - */ - public java.lang.String getName( - ) { - return this._name; - } - - /** - * Method getObjRef. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the java.lang.Object at the given index - */ - public java.lang.Object getObjRef( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._objRef.size()) { - throw new IndexOutOfBoundsException("getObjRef: Index value '" + index + "' not in range [0.." + (this._objRef.size() - 1) + "]"); - } - - return _objRef.get(index); - } - - /** - * Method getObjRef.Returns the contents of the collection in - * an Array.

Note: Just in case the collection contents - * are changing in another thread, we pass a 0-length Array of - * the correct type into the API call. This way we know - * that the Array returned is of exactly the correct length. - * - * @return this collection as an Array - */ - public java.lang.Object[] getObjRef( - ) { - java.lang.Object[] array = new java.lang.Object[0]; - return (java.lang.Object[]) this._objRef.toArray(array); - } - - /** - * Method getObjRefAsReference.Returns a reference to - * '_objRef'. No type checking is performed on any - * modifications to the Vector. - * - * @return a reference to the Vector backing this class - */ - public java.util.Vector getObjRefAsReference( - ) { - return this._objRef; - } - - /** - * Method getObjRefCount. - * - * @return the size of this collection - */ - public int getObjRefCount( - ) { - return this._objRef.size(); - } - - /** - * Overrides the java.lang.Object.hashCode method. - *

- * The following steps came from Effective Java Programming - * Language Guide by Joshua Bloch, Chapter 3 - * - * @return a hash code value for the object. - */ - public int hashCode( - ) { - int result = super.hashCode(); - - long tmp; - if (_name != null - && !org.castor.util.CycleBreaker.startingToCycle(_name)) { - result = 37 * result + _name.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_name); - } - if (_objRef != null - && !org.castor.util.CycleBreaker.startingToCycle(_objRef)) { - result = 37 * result + _objRef.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_objRef); - } - - return result; - } - - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { + if (this._objRef != null) { + if (temp._objRef == null) + return false; + if (this._objRef != temp._objRef) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._objRef); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._objRef); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._objRef); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._objRef); + } + ; return false; + } + if (!thcycle) { + if (!this._objRef.equals(temp._objRef)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._objRef); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._objRef); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._objRef); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._objRef); + } } - return true; - } - - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } - - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } - - /** - */ - public void removeAllObjRef( - ) { - this._objRef.clear(); + } else if (temp._objRef != null) + return false; + return true; } - - /** - * Method removeObjRef. - * - * @param vObjRef - * @return true if the object was removed from the collection. - */ - public boolean removeObjRef( - final java.lang.Object vObjRef) { - boolean removed = _objRef.remove(vObjRef); - return removed; + return false; + } + + /** + * Returns the value of field 'name'. + * + * @return the value of field 'Name'. + */ + public java.lang.String getName() { + return this._name; + } + + /** + * Method getObjRef. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the java.lang.Object at the given index + */ + public java.lang.Object getObjRef(final int index) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._objRef.size()) { + throw new IndexOutOfBoundsException("getObjRef: Index value '" + index + + "' not in range [0.." + (this._objRef.size() - 1) + "]"); } - /** - * Method removeObjRefAt. - * - * @param index - * @return the element removed from the collection - */ - public java.lang.Object removeObjRefAt( - final int index) { - java.lang.Object obj = this._objRef.remove(index); - return obj; + return _objRef.get(index); + } + + /** + * Method getObjRef.Returns the contents of the collection in an Array. + *

+ * Note: Just in case the collection contents are changing in another thread, + * we pass a 0-length Array of the correct type into the API call. This way we + * know that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public java.lang.Object[] getObjRef() { + java.lang.Object[] array = new java.lang.Object[0]; + return (java.lang.Object[]) this._objRef.toArray(array); + } + + /** + * Method getObjRefAsReference.Returns a reference to '_objRef'. No type + * checking is performed on any modifications to the Vector. + * + * @return a reference to the Vector backing this class + */ + public java.util.Vector getObjRefAsReference() { + return this._objRef; + } + + /** + * Method getObjRefCount. + * + * @return the size of this collection + */ + public int getObjRefCount() { + return this._objRef.size(); + } + + /** + * Overrides the java.lang.Object.hashCode method. + *

+ * The following steps came from Effective Java Programming Language + * Guide by Joshua Bloch, Chapter 3 + * + * @return a hash code value for the object. + */ + public int hashCode() { + int result = super.hashCode(); + + long tmp; + if (_name != null && !org.castor.util.CycleBreaker.startingToCycle(_name)) { + result = 37 * result + _name.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_name); } - - /** - * Sets the value of field 'name'. - * - * @param name the value of field 'name'. - */ - public void setName( - final java.lang.String name) { - this._name = name; + if (_objRef != null + && !org.castor.util.CycleBreaker.startingToCycle(_objRef)) { + result = 37 * result + _objRef.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_objRef); } - /** - * - * - * @param index - * @param vObjRef - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setObjRef( - final int index, - final java.lang.Object vObjRef) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._objRef.size()) { - throw new IndexOutOfBoundsException("setObjRef: Index value '" + index + "' not in range [0.." + (this._objRef.size() - 1) + "]"); - } - - this._objRef.set(index, vObjRef); + return result; + } + + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() { + try { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) { + return false; } - - /** - * - * - * @param vObjRefArray + return true; + } + + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, out); + } + + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, handler); + } + + /** */ - public void setObjRef( - final java.lang.Object[] vObjRefArray) { - //-- copy array - _objRef.clear(); - - for (int i = 0; i < vObjRefArray.length; i++) { - this._objRef.add(vObjRefArray[i]); - } + public void removeAllObjRef() { + this._objRef.clear(); + } + + /** + * Method removeObjRef. + * + * @param vObjRef + * @return true if the object was removed from the collection. + */ + public boolean removeObjRef(final java.lang.Object vObjRef) { + boolean removed = _objRef.remove(vObjRef); + return removed; + } + + /** + * Method removeObjRefAt. + * + * @param index + * @return the element removed from the collection + */ + public java.lang.Object removeObjRefAt(final int index) { + java.lang.Object obj = this._objRef.remove(index); + return obj; + } + + /** + * Sets the value of field 'name'. + * + * @param name + * the value of field 'name'. + */ + public void setName(final java.lang.String name) { + this._name = name; + } + + /** + * + * + * @param index + * @param vObjRef + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setObjRef(final int index, final java.lang.Object vObjRef) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._objRef.size()) { + throw new IndexOutOfBoundsException("setObjRef: Index value '" + index + + "' not in range [0.." + (this._objRef.size() - 1) + "]"); } - /** - * Sets the value of '_objRef' by copying the given Vector. All - * elements will be checked for type safety. - * - * @param vObjRefList the Vector to copy. - */ - public void setObjRef( - final java.util.Vector vObjRefList) { - // copy vector - this._objRef.clear(); - - this._objRef.addAll(vObjRefList); - } + this._objRef.set(index, vObjRef); + } - /** - * Sets the value of '_objRef' by setting it to the given - * Vector. No type checking is performed. - * @deprecated - * - * @param objRefVector the Vector to set. - */ - public void setObjRefAsReference( - final java.util.Vector objRefVector) { - this._objRef = objRefVector; - } + /** + * + * + * @param vObjRefArray + */ + public void setObjRef(final java.lang.Object[] vObjRefArray) { + // -- copy array + _objRef.clear(); - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled uk.ac.vamsas.objects.core.RangeType - */ - public static uk.ac.vamsas.objects.core.RangeType unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (uk.ac.vamsas.objects.core.RangeType) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.Input.class, reader); - } - - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); + for (int i = 0; i < vObjRefArray.length; i++) { + this._objRef.add(vObjRefArray[i]); } + } + + /** + * Sets the value of '_objRef' by copying the given Vector. All elements will + * be checked for type safety. + * + * @param vObjRefList + * the Vector to copy. + */ + public void setObjRef(final java.util.Vector vObjRefList) { + // copy vector + this._objRef.clear(); + + this._objRef.addAll(vObjRefList); + } + + /** + * Sets the value of '_objRef' by setting it to the given Vector. No type + * checking is performed. + * + * @deprecated + * + * @param objRefVector + * the Vector to set. + */ + public void setObjRefAsReference(final java.util.Vector objRefVector) { + this._objRef = objRefVector; + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @return the unmarshaled uk.ac.vamsas.objects.core.RangeType + */ + public static uk.ac.vamsas.objects.core.RangeType unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + return (uk.ac.vamsas.objects.core.RangeType) Unmarshaller.unmarshal( + uk.ac.vamsas.objects.core.Input.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/uk/ac/vamsas/objects/core/Instance.java b/src/uk/ac/vamsas/objects/core/Instance.java index 9ffd596..a116b6a 100644 --- a/src/uk/ac/vamsas/objects/core/Instance.java +++ b/src/uk/ac/vamsas/objects/core/Instance.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import org.exolab.castor.xml.Marshaller; @@ -19,196 +33,197 @@ import org.exolab.castor.xml.Unmarshaller; * * @version $Revision$ $Date$ */ -public class Instance extends uk.ac.vamsas.objects.core.AppData -implements java.io.Serializable -{ - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _urn. - */ - private java.lang.String _urn; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public Instance() { - super(); - } - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Overrides the java.lang.Object.equals method. - * - * @param obj - * @return true if the objects are equal. - */ - public boolean equals( - final java.lang.Object obj) { - if ( this == obj ) - return true; - - if (super.equals(obj)==false) +public class Instance extends uk.ac.vamsas.objects.core.AppData implements + java.io.Serializable { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _urn. + */ + private java.lang.String _urn; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public Instance() { + super(); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * Overrides the java.lang.Object.equals method. + * + * @param obj + * @return true if the objects are equal. + */ + public boolean equals(final java.lang.Object obj) { + if (this == obj) + return true; + + if (super.equals(obj) == false) + return false; + + if (obj instanceof Instance) { + + Instance temp = (Instance) obj; + boolean thcycle; + boolean tmcycle; + if (this._urn != null) { + if (temp._urn == null) + return false; + if (this._urn != temp._urn) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._urn); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._urn); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._urn); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._urn); + } + ; return false; - - if (obj instanceof Instance) { - - Instance temp = (Instance)obj; - boolean thcycle; - boolean tmcycle; - if (this._urn != null) { - if (temp._urn == null) return false; - if (this._urn != temp._urn) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._urn); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._urn); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._urn); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._urn); }; - return false; - } - if (!thcycle) { - if (!this._urn.equals(temp._urn)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._urn); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._urn); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._urn); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._urn); - } - } - } else if (temp._urn != null) - return false; - return true; + } + if (!thcycle) { + if (!this._urn.equals(temp._urn)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._urn); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._urn); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._urn); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._urn); + } } + } else if (temp._urn != null) return false; + return true; } - - /** - * Returns the value of field 'urn'. - * - * @return the value of field 'Urn'. - */ - public java.lang.String getUrn( - ) { - return this._urn; - } - - /** - * Overrides the java.lang.Object.hashCode method. - *

- * The following steps came from Effective Java Programming - * Language Guide by Joshua Bloch, Chapter 3 - * - * @return a hash code value for the object. - */ - public int hashCode( - ) { - int result = super.hashCode(); - - long tmp; - if (_urn != null - && !org.castor.util.CycleBreaker.startingToCycle(_urn)) { - result = 37 * result + _urn.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_urn); - } - - return result; - } - - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { - return false; - } - return true; - } - - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } - - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } - - /** - * Sets the value of field 'urn'. - * - * @param urn the value of field 'urn'. - */ - public void setUrn( - final java.lang.String urn) { - this._urn = urn; - } - - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled uk.ac.vamsas.objects.core.AppData - */ - public static uk.ac.vamsas.objects.core.AppData unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (uk.ac.vamsas.objects.core.AppData) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.Instance.class, reader); + return false; + } + + /** + * Returns the value of field 'urn'. + * + * @return the value of field 'Urn'. + */ + public java.lang.String getUrn() { + return this._urn; + } + + /** + * Overrides the java.lang.Object.hashCode method. + *

+ * The following steps came from Effective Java Programming Language + * Guide by Joshua Bloch, Chapter 3 + * + * @return a hash code value for the object. + */ + public int hashCode() { + int result = super.hashCode(); + + long tmp; + if (_urn != null && !org.castor.util.CycleBreaker.startingToCycle(_urn)) { + result = 37 * result + _urn.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_urn); } - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); + return result; + } + + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() { + try { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) { + return false; } + return true; + } + + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, out); + } + + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, handler); + } + + /** + * Sets the value of field 'urn'. + * + * @param urn + * the value of field 'urn'. + */ + public void setUrn(final java.lang.String urn) { + this._urn = urn; + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @return the unmarshaled uk.ac.vamsas.objects.core.AppData + */ + public static uk.ac.vamsas.objects.core.AppData unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + return (uk.ac.vamsas.objects.core.AppData) Unmarshaller.unmarshal( + uk.ac.vamsas.objects.core.Instance.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/uk/ac/vamsas/objects/core/Link.java b/src/uk/ac/vamsas/objects/core/Link.java index 17633cf..5c34acb 100644 --- a/src/uk/ac/vamsas/objects/core/Link.java +++ b/src/uk/ac/vamsas/objects/core/Link.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import org.exolab.castor.xml.Marshaller; @@ -19,253 +33,260 @@ import org.exolab.castor.xml.Unmarshaller; * * @version $Revision$ $Date$ */ -public class Link extends uk.ac.vamsas.client.Vobject -implements java.io.Serializable -{ +public class Link extends uk.ac.vamsas.client.Vobject implements + java.io.Serializable { + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ + /** + * internal content storage + */ + private java.lang.String _content = ""; - /** - * internal content storage - */ - private java.lang.String _content = ""; + /** + * The URI + */ + private java.lang.String _href; - /** - * The URI - */ - private java.lang.String _href; + // ----------------/ + // - Constructors -/ + // ----------------/ + public Link() { + super(); + setContent(""); + } - //----------------/ - //- Constructors -/ - //----------------/ + // -----------/ + // - Methods -/ + // -----------/ - public Link() { - super(); - setContent(""); - } + /** + * Overrides the java.lang.Object.equals method. + * + * @param obj + * @return true if the objects are equal. + */ + public boolean equals(final java.lang.Object obj) { + if (this == obj) + return true; + if (super.equals(obj) == false) + return false; - //-----------/ - //- Methods -/ - //-----------/ + if (obj instanceof Link) { - /** - * Overrides the java.lang.Object.equals method. - * - * @param obj - * @return true if the objects are equal. - */ - public boolean equals( - final java.lang.Object obj) { - if ( this == obj ) - return true; - - if (super.equals(obj)==false) + Link temp = (Link) obj; + boolean thcycle; + boolean tmcycle; + if (this._content != null) { + if (temp._content == null) + return false; + if (this._content != temp._content) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._content); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._content); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._content); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._content); + } + ; return false; - - if (obj instanceof Link) { - - Link temp = (Link)obj; - boolean thcycle; - boolean tmcycle; - if (this._content != null) { - if (temp._content == null) return false; - if (this._content != temp._content) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._content); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._content); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._content); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._content); }; - return false; - } - if (!thcycle) { - if (!this._content.equals(temp._content)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._content); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._content); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._content); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._content); - } - } - } else if (temp._content != null) - return false; - if (this._href != null) { - if (temp._href == null) return false; - if (this._href != temp._href) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._href); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._href); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._href); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._href); }; - return false; - } - if (!thcycle) { - if (!this._href.equals(temp._href)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._href); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._href); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._href); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._href); - } - } - } else if (temp._href != null) - return false; - return true; + } + if (!thcycle) { + if (!this._content.equals(temp._content)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._content); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._content); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._content); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._content); + } } + } else if (temp._content != null) return false; + if (this._href != null) { + if (temp._href == null) + return false; + if (this._href != temp._href) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._href); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._href); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._href); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._href); + } + ; + return false; + } + if (!thcycle) { + if (!this._href.equals(temp._href)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._href); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._href); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._href); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._href); + } + } + } else if (temp._href != null) + return false; + return true; } + return false; + } - /** - * Returns the value of field 'content'. The field 'content' - * has the following description: internal content storage - * - * @return the value of field 'Content'. - */ - public java.lang.String getContent( - ) { - return this._content; - } + /** + * Returns the value of field 'content'. The field 'content' has the following + * description: internal content storage + * + * @return the value of field 'Content'. + */ + public java.lang.String getContent() { + return this._content; + } - /** - * Returns the value of field 'href'. The field 'href' has the - * following description: The URI - * - * @return the value of field 'Href'. - */ - public java.lang.String getHref( - ) { - return this._href; - } + /** + * Returns the value of field 'href'. The field 'href' has the following + * description: The URI + * + * @return the value of field 'Href'. + */ + public java.lang.String getHref() { + return this._href; + } - /** - * Overrides the java.lang.Object.hashCode method. - *

- * The following steps came from Effective Java Programming - * Language Guide by Joshua Bloch, Chapter 3 - * - * @return a hash code value for the object. - */ - public int hashCode( - ) { - int result = super.hashCode(); - - long tmp; - if (_content != null - && !org.castor.util.CycleBreaker.startingToCycle(_content)) { - result = 37 * result + _content.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_content); - } - if (_href != null - && !org.castor.util.CycleBreaker.startingToCycle(_href)) { - result = 37 * result + _href.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_href); - } - - return result; - } + /** + * Overrides the java.lang.Object.hashCode method. + *

+ * The following steps came from Effective Java Programming Language + * Guide by Joshua Bloch, Chapter 3 + * + * @return a hash code value for the object. + */ + public int hashCode() { + int result = super.hashCode(); - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { - return false; - } - return true; + long tmp; + if (_content != null + && !org.castor.util.CycleBreaker.startingToCycle(_content)) { + result = 37 * result + _content.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_content); } - - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); + if (_href != null && !org.castor.util.CycleBreaker.startingToCycle(_href)) { + result = 37 * result + _href.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_href); } - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } + return result; + } - /** - * Sets the value of field 'content'. The field 'content' has - * the following description: internal content storage - * - * @param content the value of field 'content'. - */ - public void setContent( - final java.lang.String content) { - this._content = content; + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() { + try { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) { + return false; } + return true; + } - /** - * Sets the value of field 'href'. The field 'href' has the - * following description: The URI - * - * @param href the value of field 'href'. - */ - public void setHref( - final java.lang.String href) { - this._href = href; - } + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, out); + } - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled uk.ac.vamsas.objects.core.Link - */ - public static uk.ac.vamsas.objects.core.Link unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (uk.ac.vamsas.objects.core.Link) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.Link.class, reader); - } + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, handler); + } - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); - } + /** + * Sets the value of field 'content'. The field 'content' has the following + * description: internal content storage + * + * @param content + * the value of field 'content'. + */ + public void setContent(final java.lang.String content) { + this._content = content; + } + + /** + * Sets the value of field 'href'. The field 'href' has the following + * description: The URI + * + * @param href + * the value of field 'href'. + */ + public void setHref(final java.lang.String href) { + this._href = href; + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @return the unmarshaled uk.ac.vamsas.objects.core.Link + */ + public static uk.ac.vamsas.objects.core.Link unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + return (uk.ac.vamsas.objects.core.Link) Unmarshaller.unmarshal( + uk.ac.vamsas.objects.core.Link.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/uk/ac/vamsas/objects/core/Local.java b/src/uk/ac/vamsas/objects/core/Local.java index 8b58b7c..e291177 100644 --- a/src/uk/ac/vamsas/objects/core/Local.java +++ b/src/uk/ac/vamsas/objects/core/Local.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import org.exolab.castor.xml.Marshaller; @@ -19,136 +33,132 @@ import org.exolab.castor.xml.Unmarshaller; * * @version $Revision$ $Date$ */ -public class Local extends MapRangeType -implements java.io.Serializable -{ - - - //----------------/ - //- Constructors -/ - //----------------/ - - public Local() { - super(); - } +public class Local extends MapRangeType implements java.io.Serializable { + // ----------------/ + // - Constructors -/ + // ----------------/ - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Overrides the java.lang.Object.equals method. - * - * @param obj - * @return true if the objects are equal. - */ - public boolean equals( - final java.lang.Object obj) { - if ( this == obj ) - return true; - - if (super.equals(obj)==false) - return false; - - if (obj instanceof Local) { - - return true; - } - return false; - } + public Local() { + super(); + } - /** - * Overrides the java.lang.Object.hashCode method. - *

- * The following steps came from Effective Java Programming - * Language Guide by Joshua Bloch, Chapter 3 - * - * @return a hash code value for the object. - */ - public int hashCode( - ) { - int result = super.hashCode(); - - long tmp; - - return result; - } + // -----------/ + // - Methods -/ + // -----------/ - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { - return false; - } - return true; - } + /** + * Overrides the java.lang.Object.equals method. + * + * @param obj + * @return true if the objects are equal. + */ + public boolean equals(final java.lang.Object obj) { + if (this == obj) + return true; - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } + if (super.equals(obj) == false) + return false; - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } + if (obj instanceof Local) { - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled uk.ac.vamsas.objects.core.RangeType - */ - public static uk.ac.vamsas.objects.core.RangeType unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (uk.ac.vamsas.objects.core.RangeType) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.Local.class, reader); + return true; } - - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); + return false; + } + + /** + * Overrides the java.lang.Object.hashCode method. + *

+ * The following steps came from Effective Java Programming Language + * Guide by Joshua Bloch, Chapter 3 + * + * @return a hash code value for the object. + */ + public int hashCode() { + int result = super.hashCode(); + + long tmp; + + return result; + } + + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() { + try { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) { + return false; } + return true; + } + + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, out); + } + + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, handler); + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @return the unmarshaled uk.ac.vamsas.objects.core.RangeType + */ + public static uk.ac.vamsas.objects.core.RangeType unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + return (uk.ac.vamsas.objects.core.RangeType) Unmarshaller.unmarshal( + uk.ac.vamsas.objects.core.Local.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/uk/ac/vamsas/objects/core/LockFile.java b/src/uk/ac/vamsas/objects/core/LockFile.java index cb41ef9..418e743 100644 --- a/src/uk/ac/vamsas/objects/core/LockFile.java +++ b/src/uk/ac/vamsas/objects/core/LockFile.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import org.exolab.castor.xml.Marshaller; @@ -17,201 +31,204 @@ import org.exolab.castor.xml.Unmarshaller; /** * Class LockFile. * - * @version $Revision$ $Date$ + * @version $Revision$ $Date: 2007-06-28 14:51:44 +0100 (Thu, 28 Jun 2007) + * $ */ -public class LockFile extends uk.ac.vamsas.client.Vobject -implements java.io.Serializable -{ - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * internal content storage - */ - private java.lang.String _content = ""; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public LockFile() { - super(); - setContent(""); - } - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Overrides the java.lang.Object.equals method. - * - * @param obj - * @return true if the objects are equal. - */ - public boolean equals( - final java.lang.Object obj) { - if ( this == obj ) - return true; - - if (super.equals(obj)==false) +public class LockFile extends uk.ac.vamsas.client.Vobject implements + java.io.Serializable { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * internal content storage + */ + private java.lang.String _content = ""; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public LockFile() { + super(); + setContent(""); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * Overrides the java.lang.Object.equals method. + * + * @param obj + * @return true if the objects are equal. + */ + public boolean equals(final java.lang.Object obj) { + if (this == obj) + return true; + + if (super.equals(obj) == false) + return false; + + if (obj instanceof LockFile) { + + LockFile temp = (LockFile) obj; + boolean thcycle; + boolean tmcycle; + if (this._content != null) { + if (temp._content == null) + return false; + if (this._content != temp._content) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._content); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._content); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._content); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._content); + } + ; return false; - - if (obj instanceof LockFile) { - - LockFile temp = (LockFile)obj; - boolean thcycle; - boolean tmcycle; - if (this._content != null) { - if (temp._content == null) return false; - if (this._content != temp._content) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._content); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._content); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._content); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._content); }; - return false; - } - if (!thcycle) { - if (!this._content.equals(temp._content)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._content); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._content); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._content); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._content); - } - } - } else if (temp._content != null) - return false; - return true; + } + if (!thcycle) { + if (!this._content.equals(temp._content)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._content); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._content); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._content); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._content); + } } + } else if (temp._content != null) return false; + return true; } - - /** - * Returns the value of field 'content'. The field 'content' - * has the following description: internal content storage - * - * @return the value of field 'Content'. - */ - public java.lang.String getContent( - ) { - return this._content; - } - - /** - * Overrides the java.lang.Object.hashCode method. - *

- * The following steps came from Effective Java Programming - * Language Guide by Joshua Bloch, Chapter 3 - * - * @return a hash code value for the object. - */ - public int hashCode( - ) { - int result = super.hashCode(); - - long tmp; - if (_content != null - && !org.castor.util.CycleBreaker.startingToCycle(_content)) { - result = 37 * result + _content.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_content); - } - - return result; - } - - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { - return false; - } - return true; - } - - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } - - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } - - /** - * Sets the value of field 'content'. The field 'content' has - * the following description: internal content storage - * - * @param content the value of field 'content'. - */ - public void setContent( - final java.lang.String content) { - this._content = content; - } - - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled uk.ac.vamsas.objects.core.LockFile - */ - public static uk.ac.vamsas.objects.core.LockFile unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (uk.ac.vamsas.objects.core.LockFile) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.LockFile.class, reader); + return false; + } + + /** + * Returns the value of field 'content'. The field 'content' has the following + * description: internal content storage + * + * @return the value of field 'Content'. + */ + public java.lang.String getContent() { + return this._content; + } + + /** + * Overrides the java.lang.Object.hashCode method. + *

+ * The following steps came from Effective Java Programming Language + * Guide by Joshua Bloch, Chapter 3 + * + * @return a hash code value for the object. + */ + public int hashCode() { + int result = super.hashCode(); + + long tmp; + if (_content != null + && !org.castor.util.CycleBreaker.startingToCycle(_content)) { + result = 37 * result + _content.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_content); } - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); + return result; + } + + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() { + try { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) { + return false; } + return true; + } + + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, out); + } + + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, handler); + } + + /** + * Sets the value of field 'content'. The field 'content' has the following + * description: internal content storage + * + * @param content + * the value of field 'content'. + */ + public void setContent(final java.lang.String content) { + this._content = content; + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @return the unmarshaled uk.ac.vamsas.objects.core.LockFile + */ + public static uk.ac.vamsas.objects.core.LockFile unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + return (uk.ac.vamsas.objects.core.LockFile) Unmarshaller.unmarshal( + uk.ac.vamsas.objects.core.LockFile.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/uk/ac/vamsas/objects/core/Map.java b/src/uk/ac/vamsas/objects/core/Map.java index 561589c..06ea745 100644 --- a/src/uk/ac/vamsas/objects/core/Map.java +++ b/src/uk/ac/vamsas/objects/core/Map.java @@ -1,224 +1,235 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import org.exolab.castor.xml.Marshaller; import org.exolab.castor.xml.Unmarshaller; /** - * the local mapType maps from the parent - * sequence coordinate frame to the reference - * frame defined by the dbRef element. - * The mapped mapType is the mapped range defined - * on the dbRef element's reference frame. - * Conventionally, the unit attribute defaults to 1, or - * will be inferred from the local sequence's - * dictionary type and any dictionary type associated - * with the database being mapped to. - * However, it may be used to avoid ambiguity. - * + * the local mapType maps from the parent sequence coordinate frame to the + * reference frame defined by the dbRef element. The mapped mapType is the + * mapped range defined on the dbRef element's reference frame. Conventionally, + * the unit attribute defaults to 1, or will be inferred from the local + * sequence's dictionary type and any dictionary type associated with the + * database being mapped to. However, it may be used to avoid ambiguity. + * * * @version $Revision$ $Date$ */ -public class Map extends uk.ac.vamsas.objects.core.MapType -implements java.io.Serializable -{ - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _id. - */ - private java.lang.String _id; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public Map() { - super(); - } - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Overrides the java.lang.Object.equals method. - * - * @param obj - * @return true if the objects are equal. - */ - public boolean equals( - final java.lang.Object obj) { - if ( this == obj ) - return true; - - if (super.equals(obj)==false) +public class Map extends uk.ac.vamsas.objects.core.MapType implements + java.io.Serializable { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _id. + */ + private java.lang.String _id; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public Map() { + super(); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * Overrides the java.lang.Object.equals method. + * + * @param obj + * @return true if the objects are equal. + */ + public boolean equals(final java.lang.Object obj) { + if (this == obj) + return true; + + if (super.equals(obj) == false) + return false; + + if (obj instanceof Map) { + + Map temp = (Map) obj; + boolean thcycle; + boolean tmcycle; + if (this._id != null) { + if (temp._id == null) + return false; + if (this._id != temp._id) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._id); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._id); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._id); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); + } + ; return false; - - if (obj instanceof Map) { - - Map temp = (Map)obj; - boolean thcycle; - boolean tmcycle; - if (this._id != null) { - if (temp._id == null) return false; - if (this._id != temp._id) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._id); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._id); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._id); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); }; - return false; - } - if (!thcycle) { - if (!this._id.equals(temp._id)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._id); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._id); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); - } - } - } else if (temp._id != null) - return false; - return true; + } + if (!thcycle) { + if (!this._id.equals(temp._id)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._id); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._id); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); + } } + } else if (temp._id != null) return false; + return true; } - - /** - * Returns the value of field 'id'. - * - * @return the value of field 'Id'. - */ - public java.lang.String getId( - ) { - return this._id; - } - - /** - * Overrides the java.lang.Object.hashCode method. - *

- * The following steps came from Effective Java Programming - * Language Guide by Joshua Bloch, Chapter 3 - * - * @return a hash code value for the object. - */ - public int hashCode( - ) { - int result = super.hashCode(); - - long tmp; - if (_id != null - && !org.castor.util.CycleBreaker.startingToCycle(_id)) { - result = 37 * result + _id.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_id); - } - - return result; - } - - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { - return false; - } - return true; - } - - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } - - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } - - /** - * Sets the value of field 'id'. - * - * @param id the value of field 'id'. - */ - public void setId( - final java.lang.String id) { - this._id = id; - } - - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled uk.ac.vamsas.objects.core.MapType - */ - public static uk.ac.vamsas.objects.core.MapType unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (uk.ac.vamsas.objects.core.MapType) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.Map.class, reader); + return false; + } + + /** + * Returns the value of field 'id'. + * + * @return the value of field 'Id'. + */ + public java.lang.String getId() { + return this._id; + } + + /** + * Overrides the java.lang.Object.hashCode method. + *

+ * The following steps came from Effective Java Programming Language + * Guide by Joshua Bloch, Chapter 3 + * + * @return a hash code value for the object. + */ + public int hashCode() { + int result = super.hashCode(); + + long tmp; + if (_id != null && !org.castor.util.CycleBreaker.startingToCycle(_id)) { + result = 37 * result + _id.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_id); } - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); + return result; + } + + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() { + try { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) { + return false; } + return true; + } + + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, out); + } + + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, handler); + } + + /** + * Sets the value of field 'id'. + * + * @param id + * the value of field 'id'. + */ + public void setId(final java.lang.String id) { + this._id = id; + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @return the unmarshaled uk.ac.vamsas.objects.core.MapType + */ + public static uk.ac.vamsas.objects.core.MapType unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + return (uk.ac.vamsas.objects.core.MapType) Unmarshaller.unmarshal( + uk.ac.vamsas.objects.core.Map.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/uk/ac/vamsas/objects/core/MapList.java b/src/uk/ac/vamsas/objects/core/MapList.java index af7ebb6..770d07f 100644 --- a/src/uk/ac/vamsas/objects/core/MapList.java +++ b/src/uk/ac/vamsas/objects/core/MapList.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import org.exolab.castor.xml.Marshaller; @@ -19,384 +33,358 @@ import org.exolab.castor.xml.Unmarshaller; * * @version $Revision$ $Date$ */ -public class MapList extends uk.ac.vamsas.client.Vobject -implements java.io.Serializable -{ - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Offset to first position in dataset sequence record that - * start - * position on 'onto' maps to - */ - private long _from = 0; - - /** - * keeps track of state for field: _from - */ - private boolean _has_from; - - /** - * Offset to last position in dataset sequence record that end - * position on 'onto' maps to - */ - private long _to = 0; - - /** - * keeps track of state for field: _to - */ - private boolean _has_to; - - /** - * Offset to first position in database entry that first (or - * offset) - * position in sequence maps to - */ - private long _start; - - /** - * keeps track of state for field: _start - */ - private boolean _has_start; - - /** - * Offset to last position in database entry that last (offset) - * position in sequence maps to - */ - private long _end; - - /** - * keeps track of state for field: _end - */ - private boolean _has_end; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public MapList() { - super(); - } - - - //-----------/ - //- Methods -/ - //-----------/ - - /** +public class MapList extends uk.ac.vamsas.client.Vobject implements + java.io.Serializable { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Offset to first position in dataset sequence record that start position on + * 'onto' maps to + */ + private long _from = 0; + + /** + * keeps track of state for field: _from + */ + private boolean _has_from; + + /** + * Offset to last position in dataset sequence record that end position on + * 'onto' maps to + */ + private long _to = 0; + + /** + * keeps track of state for field: _to + */ + private boolean _has_to; + + /** + * Offset to first position in database entry that first (or offset) position + * in sequence maps to + */ + private long _start; + + /** + * keeps track of state for field: _start + */ + private boolean _has_start; + + /** + * Offset to last position in database entry that last (offset) position in + * sequence maps to + */ + private long _end; + + /** + * keeps track of state for field: _end + */ + private boolean _has_end; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public MapList() { + super(); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** */ - public void deleteEnd( - ) { - this._has_end= false; - } - - /** - */ - public void deleteFrom( - ) { - this._has_from= false; - } + public void deleteEnd() { + this._has_end = false; + } - /** + /** */ - public void deleteStart( - ) { - this._has_start= false; - } + public void deleteFrom() { + this._has_from = false; + } - /** + /** */ - public void deleteTo( - ) { - this._has_to= false; - } + public void deleteStart() { + this._has_start = false; + } - /** - * Overrides the java.lang.Object.equals method. - * - * @param obj - * @return true if the objects are equal. + /** */ - public boolean equals( - final java.lang.Object obj) { - if ( this == obj ) - return true; - - if (super.equals(obj)==false) - return false; - - if (obj instanceof MapList) { - - MapList temp = (MapList)obj; - if (this._from != temp._from) - return false; - if (this._has_from != temp._has_from) - return false; - if (this._to != temp._to) - return false; - if (this._has_to != temp._has_to) - return false; - if (this._start != temp._start) - return false; - if (this._has_start != temp._has_start) - return false; - if (this._end != temp._end) - return false; - if (this._has_end != temp._has_end) - return false; - return true; - } + public void deleteTo() { + this._has_to = false; + } + + /** + * Overrides the java.lang.Object.equals method. + * + * @param obj + * @return true if the objects are equal. + */ + public boolean equals(final java.lang.Object obj) { + if (this == obj) + return true; + + if (super.equals(obj) == false) + return false; + + if (obj instanceof MapList) { + + MapList temp = (MapList) obj; + if (this._from != temp._from) return false; + if (this._has_from != temp._has_from) + return false; + if (this._to != temp._to) + return false; + if (this._has_to != temp._has_to) + return false; + if (this._start != temp._start) + return false; + if (this._has_start != temp._has_start) + return false; + if (this._end != temp._end) + return false; + if (this._has_end != temp._has_end) + return false; + return true; } - - /** - * Returns the value of field 'end'. The field 'end' has the - * following description: Offset to last position in database - * entry that last (offset) - * position in sequence maps to - * - * @return the value of field 'End'. - */ - public long getEnd( - ) { - return this._end; - } - - /** - * Returns the value of field 'from'. The field 'from' has the - * following description: Offset to first position in dataset - * sequence record that start - * position on 'onto' maps to - * - * @return the value of field 'From'. - */ - public long getFrom( - ) { - return this._from; - } - - /** - * Returns the value of field 'start'. The field 'start' has - * the following description: Offset to first position in - * database entry that first (or offset) - * position in sequence maps to - * - * @return the value of field 'Start'. - */ - public long getStart( - ) { - return this._start; - } - - /** - * Returns the value of field 'to'. The field 'to' has the - * following description: Offset to last position in dataset - * sequence record that end - * position on 'onto' maps to - * - * @return the value of field 'To'. - */ - public long getTo( - ) { - return this._to; - } - - /** - * Method hasEnd. - * - * @return true if at least one End has been added - */ - public boolean hasEnd( - ) { - return this._has_end; - } - - /** - * Method hasFrom. - * - * @return true if at least one From has been added - */ - public boolean hasFrom( - ) { - return this._has_from; - } - - /** - * Method hasStart. - * - * @return true if at least one Start has been added - */ - public boolean hasStart( - ) { - return this._has_start; - } - - /** - * Method hasTo. - * - * @return true if at least one To has been added - */ - public boolean hasTo( - ) { - return this._has_to; - } - - /** - * Overrides the java.lang.Object.hashCode method. - *

- * The following steps came from Effective Java Programming - * Language Guide by Joshua Bloch, Chapter 3 - * - * @return a hash code value for the object. - */ - public int hashCode( - ) { - int result = super.hashCode(); - - long tmp; - result = 37 * result + (int)(_from^(_from>>>32)); - result = 37 * result + (int)(_to^(_to>>>32)); - result = 37 * result + (int)(_start^(_start>>>32)); - result = 37 * result + (int)(_end^(_end>>>32)); - - return result; - } - - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { - return false; - } - return true; - } - - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } - - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } - - /** - * Sets the value of field 'end'. The field 'end' has the - * following description: Offset to last position in database - * entry that last (offset) - * position in sequence maps to - * - * @param end the value of field 'end'. - */ - public void setEnd( - final long end) { - this._end = end; - this._has_end = true; - } - - /** - * Sets the value of field 'from'. The field 'from' has the - * following description: Offset to first position in dataset - * sequence record that start - * position on 'onto' maps to - * - * @param from the value of field 'from'. - */ - public void setFrom( - final long from) { - this._from = from; - this._has_from = true; - } - - /** - * Sets the value of field 'start'. The field 'start' has the - * following description: Offset to first position in database - * entry that first (or offset) - * position in sequence maps to - * - * @param start the value of field 'start'. - */ - public void setStart( - final long start) { - this._start = start; - this._has_start = true; - } - - /** - * Sets the value of field 'to'. The field 'to' has the - * following description: Offset to last position in dataset - * sequence record that end - * position on 'onto' maps to - * - * @param to the value of field 'to'. - */ - public void setTo( - final long to) { - this._to = to; - this._has_to = true; - } - - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled uk.ac.vamsas.objects.core.MapList - */ - public static uk.ac.vamsas.objects.core.MapList unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (uk.ac.vamsas.objects.core.MapList) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.MapList.class, reader); - } - - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); + return false; + } + + /** + * Returns the value of field 'end'. The field 'end' has the following + * description: Offset to last position in database entry that last (offset) + * position in sequence maps to + * + * @return the value of field 'End'. + */ + public long getEnd() { + return this._end; + } + + /** + * Returns the value of field 'from'. The field 'from' has the following + * description: Offset to first position in dataset sequence record that start + * position on 'onto' maps to + * + * @return the value of field 'From'. + */ + public long getFrom() { + return this._from; + } + + /** + * Returns the value of field 'start'. The field 'start' has the following + * description: Offset to first position in database entry that first (or + * offset) position in sequence maps to + * + * @return the value of field 'Start'. + */ + public long getStart() { + return this._start; + } + + /** + * Returns the value of field 'to'. The field 'to' has the following + * description: Offset to last position in dataset sequence record that end + * position on 'onto' maps to + * + * @return the value of field 'To'. + */ + public long getTo() { + return this._to; + } + + /** + * Method hasEnd. + * + * @return true if at least one End has been added + */ + public boolean hasEnd() { + return this._has_end; + } + + /** + * Method hasFrom. + * + * @return true if at least one From has been added + */ + public boolean hasFrom() { + return this._has_from; + } + + /** + * Method hasStart. + * + * @return true if at least one Start has been added + */ + public boolean hasStart() { + return this._has_start; + } + + /** + * Method hasTo. + * + * @return true if at least one To has been added + */ + public boolean hasTo() { + return this._has_to; + } + + /** + * Overrides the java.lang.Object.hashCode method. + *

+ * The following steps came from Effective Java Programming Language + * Guide by Joshua Bloch, Chapter 3 + * + * @return a hash code value for the object. + */ + public int hashCode() { + int result = super.hashCode(); + + long tmp; + result = 37 * result + (int) (_from ^ (_from >>> 32)); + result = 37 * result + (int) (_to ^ (_to >>> 32)); + result = 37 * result + (int) (_start ^ (_start >>> 32)); + result = 37 * result + (int) (_end ^ (_end >>> 32)); + + return result; + } + + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() { + try { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) { + return false; } + return true; + } + + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, out); + } + + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, handler); + } + + /** + * Sets the value of field 'end'. The field 'end' has the following + * description: Offset to last position in database entry that last (offset) + * position in sequence maps to + * + * @param end + * the value of field 'end'. + */ + public void setEnd(final long end) { + this._end = end; + this._has_end = true; + } + + /** + * Sets the value of field 'from'. The field 'from' has the following + * description: Offset to first position in dataset sequence record that start + * position on 'onto' maps to + * + * @param from + * the value of field 'from'. + */ + public void setFrom(final long from) { + this._from = from; + this._has_from = true; + } + + /** + * Sets the value of field 'start'. The field 'start' has the following + * description: Offset to first position in database entry that first (or + * offset) position in sequence maps to + * + * @param start + * the value of field 'start'. + */ + public void setStart(final long start) { + this._start = start; + this._has_start = true; + } + + /** + * Sets the value of field 'to'. The field 'to' has the following description: + * Offset to last position in dataset sequence record that end position on + * 'onto' maps to + * + * @param to + * the value of field 'to'. + */ + public void setTo(final long to) { + this._to = to; + this._has_to = true; + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @return the unmarshaled uk.ac.vamsas.objects.core.MapList + */ + public static uk.ac.vamsas.objects.core.MapList unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + return (uk.ac.vamsas.objects.core.MapList) Unmarshaller.unmarshal( + uk.ac.vamsas.objects.core.MapList.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/uk/ac/vamsas/objects/core/MapRangeType.java b/src/uk/ac/vamsas/objects/core/MapRangeType.java index c390687..e5d5ee9 100644 --- a/src/uk/ac/vamsas/objects/core/MapRangeType.java +++ b/src/uk/ac/vamsas/objects/core/MapRangeType.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import org.exolab.castor.xml.Marshaller; @@ -19,222 +33,204 @@ import org.exolab.castor.xml.Unmarshaller; * * @version $Revision$ $Date$ */ -public class MapRangeType extends uk.ac.vamsas.objects.core.RangeType -implements java.io.Serializable -{ - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * number of dictionary symbol widths involved in each - * mapped position on this sequence (for example, 3 for a dna - * sequence exon - * region that is being mapped to a protein sequence). This is - * optional, - * since the unit can be usually be inferred from the - * dictionary type of - * each sequence involved in the mapping. - */ - private long _unit; - - /** - * keeps track of state for field: _unit +public class MapRangeType extends uk.ac.vamsas.objects.core.RangeType implements + java.io.Serializable { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * number of dictionary symbol widths involved in each mapped position on this + * sequence (for example, 3 for a dna sequence exon region that is being + * mapped to a protein sequence). This is optional, since the unit can be + * usually be inferred from the dictionary type of each sequence involved in + * the mapping. + */ + private long _unit; + + /** + * keeps track of state for field: _unit + */ + private boolean _has_unit; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public MapRangeType() { + super(); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** */ - private boolean _has_unit; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public MapRangeType() { - super(); - } - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - */ - public void deleteUnit( - ) { - this._has_unit= false; - } - - /** - * Overrides the java.lang.Object.equals method. - * - * @param obj - * @return true if the objects are equal. - */ - public boolean equals( - final java.lang.Object obj) { - if ( this == obj ) - return true; - - if (super.equals(obj)==false) - return false; - - if (obj instanceof MapRangeType) { - - MapRangeType temp = (MapRangeType)obj; - boolean thcycle; - boolean tmcycle; - if (this._unit != temp._unit) - return false; - if (this._has_unit != temp._has_unit) - return false; - return true; - } + public void deleteUnit() { + this._has_unit = false; + } + + /** + * Overrides the java.lang.Object.equals method. + * + * @param obj + * @return true if the objects are equal. + */ + public boolean equals(final java.lang.Object obj) { + if (this == obj) + return true; + + if (super.equals(obj) == false) + return false; + + if (obj instanceof MapRangeType) { + + MapRangeType temp = (MapRangeType) obj; + boolean thcycle; + boolean tmcycle; + if (this._unit != temp._unit) return false; + if (this._has_unit != temp._has_unit) + return false; + return true; } - - /** - * Returns the value of field 'unit'. The field 'unit' has the - * following description: number of dictionary symbol widths - * involved in each - * mapped position on this sequence (for example, 3 for a dna - * sequence exon - * region that is being mapped to a protein sequence). This is - * optional, - * since the unit can be usually be inferred from the - * dictionary type of - * each sequence involved in the mapping. - * - * @return the value of field 'Unit'. - */ - public long getUnit( - ) { - return this._unit; - } - - /** - * Method hasUnit. - * - * @return true if at least one Unit has been added - */ - public boolean hasUnit( - ) { - return this._has_unit; - } - - /** - * Overrides the java.lang.Object.hashCode method. - *

- * The following steps came from Effective Java Programming - * Language Guide by Joshua Bloch, Chapter 3 - * - * @return a hash code value for the object. - */ - public int hashCode( - ) { - int result = super.hashCode(); - - long tmp; - result = 37 * result + (int)(_unit^(_unit>>>32)); - - return result; - } - - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { - return false; - } - return true; - } - - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } - - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } - - /** - * Sets the value of field 'unit'. The field 'unit' has the - * following description: number of dictionary symbol widths - * involved in each - * mapped position on this sequence (for example, 3 for a dna - * sequence exon - * region that is being mapped to a protein sequence). This is - * optional, - * since the unit can be usually be inferred from the - * dictionary type of - * each sequence involved in the mapping. - * - * @param unit the value of field 'unit'. - */ - public void setUnit( - final long unit) { - this._unit = unit; - this._has_unit = true; - } - - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled uk.ac.vamsas.objects.core.RangeType - */ - public static uk.ac.vamsas.objects.core.RangeType unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (uk.ac.vamsas.objects.core.RangeType) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.MapRangeType.class, reader); - } - - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); + return false; + } + + /** + * Returns the value of field 'unit'. The field 'unit' has the following + * description: number of dictionary symbol widths involved in each mapped + * position on this sequence (for example, 3 for a dna sequence exon region + * that is being mapped to a protein sequence). This is optional, since the + * unit can be usually be inferred from the dictionary type of each sequence + * involved in the mapping. + * + * @return the value of field 'Unit'. + */ + public long getUnit() { + return this._unit; + } + + /** + * Method hasUnit. + * + * @return true if at least one Unit has been added + */ + public boolean hasUnit() { + return this._has_unit; + } + + /** + * Overrides the java.lang.Object.hashCode method. + *

+ * The following steps came from Effective Java Programming Language + * Guide by Joshua Bloch, Chapter 3 + * + * @return a hash code value for the object. + */ + public int hashCode() { + int result = super.hashCode(); + + long tmp; + result = 37 * result + (int) (_unit ^ (_unit >>> 32)); + + return result; + } + + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() { + try { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) { + return false; } + return true; + } + + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, out); + } + + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, handler); + } + + /** + * Sets the value of field 'unit'. The field 'unit' has the following + * description: number of dictionary symbol widths involved in each mapped + * position on this sequence (for example, 3 for a dna sequence exon region + * that is being mapped to a protein sequence). This is optional, since the + * unit can be usually be inferred from the dictionary type of each sequence + * involved in the mapping. + * + * @param unit + * the value of field 'unit'. + */ + public void setUnit(final long unit) { + this._unit = unit; + this._has_unit = true; + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @return the unmarshaled uk.ac.vamsas.objects.core.RangeType + */ + public static uk.ac.vamsas.objects.core.RangeType unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + return (uk.ac.vamsas.objects.core.RangeType) Unmarshaller.unmarshal( + uk.ac.vamsas.objects.core.MapRangeType.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/uk/ac/vamsas/objects/core/MapType.java b/src/uk/ac/vamsas/objects/core/MapType.java index 130f17d..601f4cc 100644 --- a/src/uk/ac/vamsas/objects/core/MapType.java +++ b/src/uk/ac/vamsas/objects/core/MapType.java @@ -1,266 +1,286 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import org.exolab.castor.xml.Marshaller; import org.exolab.castor.xml.Unmarshaller; /** - * Two sets of ranges defined between objects - usually sequences, - * indicating which - * regions on each are mapped. + * Two sets of ranges defined between objects - usually sequences, indicating + * which regions on each are mapped. * * @version $Revision$ $Date$ */ -public class MapType extends uk.ac.vamsas.client.Vobject -implements java.io.Serializable -{ +public class MapType extends uk.ac.vamsas.client.Vobject implements + java.io.Serializable { + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** + /** */ - private uk.ac.vamsas.objects.core.Local _local; + private uk.ac.vamsas.objects.core.Local _local; - /** + /** */ - private uk.ac.vamsas.objects.core.Mapped _mapped; + private uk.ac.vamsas.objects.core.Mapped _mapped; + // ----------------/ + // - Constructors -/ + // ----------------/ - //----------------/ - //- Constructors -/ - //----------------/ + public MapType() { + super(); + } - public MapType() { - super(); - } + // -----------/ + // - Methods -/ + // -----------/ + /** + * Overrides the java.lang.Object.equals method. + * + * @param obj + * @return true if the objects are equal. + */ + public boolean equals(final java.lang.Object obj) { + if (this == obj) + return true; - //-----------/ - //- Methods -/ - //-----------/ + if (super.equals(obj) == false) + return false; - /** - * Overrides the java.lang.Object.equals method. - * - * @param obj - * @return true if the objects are equal. - */ - public boolean equals( - final java.lang.Object obj) { - if ( this == obj ) - return true; - - if (super.equals(obj)==false) + if (obj instanceof MapType) { + + MapType temp = (MapType) obj; + boolean thcycle; + boolean tmcycle; + if (this._local != null) { + if (temp._local == null) + return false; + if (this._local != temp._local) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._local); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._local); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._local); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._local); + } + ; return false; - - if (obj instanceof MapType) { - - MapType temp = (MapType)obj; - boolean thcycle; - boolean tmcycle; - if (this._local != null) { - if (temp._local == null) return false; - if (this._local != temp._local) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._local); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._local); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._local); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._local); }; - return false; - } - if (!thcycle) { - if (!this._local.equals(temp._local)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._local); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._local); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._local); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._local); - } - } - } else if (temp._local != null) - return false; - if (this._mapped != null) { - if (temp._mapped == null) return false; - if (this._mapped != temp._mapped) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._mapped); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._mapped); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._mapped); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._mapped); }; - return false; - } - if (!thcycle) { - if (!this._mapped.equals(temp._mapped)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._mapped); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._mapped); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._mapped); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._mapped); - } - } - } else if (temp._mapped != null) - return false; - return true; + } + if (!thcycle) { + if (!this._local.equals(temp._local)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._local); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._local); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._local); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._local); + } } + } else if (temp._local != null) return false; + if (this._mapped != null) { + if (temp._mapped == null) + return false; + if (this._mapped != temp._mapped) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._mapped); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._mapped); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._mapped); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._mapped); + } + ; + return false; + } + if (!thcycle) { + if (!this._mapped.equals(temp._mapped)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._mapped); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._mapped); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._mapped); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._mapped); + } + } + } else if (temp._mapped != null) + return false; + return true; } + return false; + } - /** - * Returns the value of field 'local'. - * - * @return the value of field 'Local'. - */ - public uk.ac.vamsas.objects.core.Local getLocal( - ) { - return this._local; - } + /** + * Returns the value of field 'local'. + * + * @return the value of field 'Local'. + */ + public uk.ac.vamsas.objects.core.Local getLocal() { + return this._local; + } - /** - * Returns the value of field 'mapped'. - * - * @return the value of field 'Mapped'. - */ - public uk.ac.vamsas.objects.core.Mapped getMapped( - ) { - return this._mapped; - } + /** + * Returns the value of field 'mapped'. + * + * @return the value of field 'Mapped'. + */ + public uk.ac.vamsas.objects.core.Mapped getMapped() { + return this._mapped; + } - /** - * Overrides the java.lang.Object.hashCode method. - *

- * The following steps came from Effective Java Programming - * Language Guide by Joshua Bloch, Chapter 3 - * - * @return a hash code value for the object. - */ - public int hashCode( - ) { - int result = super.hashCode(); - - long tmp; - if (_local != null - && !org.castor.util.CycleBreaker.startingToCycle(_local)) { - result = 37 * result + _local.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_local); - } - if (_mapped != null - && !org.castor.util.CycleBreaker.startingToCycle(_mapped)) { - result = 37 * result + _mapped.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_mapped); - } - - return result; - } + /** + * Overrides the java.lang.Object.hashCode method. + *

+ * The following steps came from Effective Java Programming Language + * Guide by Joshua Bloch, Chapter 3 + * + * @return a hash code value for the object. + */ + public int hashCode() { + int result = super.hashCode(); - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { - return false; - } - return true; + long tmp; + if (_local != null && !org.castor.util.CycleBreaker.startingToCycle(_local)) { + result = 37 * result + _local.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_local); } - - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); + if (_mapped != null + && !org.castor.util.CycleBreaker.startingToCycle(_mapped)) { + result = 37 * result + _mapped.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_mapped); } - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } + return result; + } - /** - * Sets the value of field 'local'. - * - * @param local the value of field 'local'. - */ - public void setLocal( - final uk.ac.vamsas.objects.core.Local local) { - this._local = local; + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() { + try { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) { + return false; } + return true; + } - /** - * Sets the value of field 'mapped'. - * - * @param mapped the value of field 'mapped'. - */ - public void setMapped( - final uk.ac.vamsas.objects.core.Mapped mapped) { - this._mapped = mapped; - } + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, out); + } - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled uk.ac.vamsas.objects.core.MapType - */ - public static uk.ac.vamsas.objects.core.MapType unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (uk.ac.vamsas.objects.core.MapType) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.MapType.class, reader); - } + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, handler); + } - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); - } + /** + * Sets the value of field 'local'. + * + * @param local + * the value of field 'local'. + */ + public void setLocal(final uk.ac.vamsas.objects.core.Local local) { + this._local = local; + } + + /** + * Sets the value of field 'mapped'. + * + * @param mapped + * the value of field 'mapped'. + */ + public void setMapped(final uk.ac.vamsas.objects.core.Mapped mapped) { + this._mapped = mapped; + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @return the unmarshaled uk.ac.vamsas.objects.core.MapType + */ + public static uk.ac.vamsas.objects.core.MapType unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + return (uk.ac.vamsas.objects.core.MapType) Unmarshaller.unmarshal( + uk.ac.vamsas.objects.core.MapType.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/uk/ac/vamsas/objects/core/Mapped.java b/src/uk/ac/vamsas/objects/core/Mapped.java index 4d3161f..497d29a 100644 --- a/src/uk/ac/vamsas/objects/core/Mapped.java +++ b/src/uk/ac/vamsas/objects/core/Mapped.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import org.exolab.castor.xml.Marshaller; @@ -19,136 +33,132 @@ import org.exolab.castor.xml.Unmarshaller; * * @version $Revision$ $Date$ */ -public class Mapped extends MapRangeType -implements java.io.Serializable -{ - - - //----------------/ - //- Constructors -/ - //----------------/ - - public Mapped() { - super(); - } +public class Mapped extends MapRangeType implements java.io.Serializable { + // ----------------/ + // - Constructors -/ + // ----------------/ - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Overrides the java.lang.Object.equals method. - * - * @param obj - * @return true if the objects are equal. - */ - public boolean equals( - final java.lang.Object obj) { - if ( this == obj ) - return true; - - if (super.equals(obj)==false) - return false; - - if (obj instanceof Mapped) { - - return true; - } - return false; - } + public Mapped() { + super(); + } - /** - * Overrides the java.lang.Object.hashCode method. - *

- * The following steps came from Effective Java Programming - * Language Guide by Joshua Bloch, Chapter 3 - * - * @return a hash code value for the object. - */ - public int hashCode( - ) { - int result = super.hashCode(); - - long tmp; - - return result; - } + // -----------/ + // - Methods -/ + // -----------/ - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { - return false; - } - return true; - } + /** + * Overrides the java.lang.Object.equals method. + * + * @param obj + * @return true if the objects are equal. + */ + public boolean equals(final java.lang.Object obj) { + if (this == obj) + return true; - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } + if (super.equals(obj) == false) + return false; - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } + if (obj instanceof Mapped) { - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled uk.ac.vamsas.objects.core.RangeType - */ - public static uk.ac.vamsas.objects.core.RangeType unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (uk.ac.vamsas.objects.core.RangeType) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.Mapped.class, reader); + return true; } - - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); + return false; + } + + /** + * Overrides the java.lang.Object.hashCode method. + *

+ * The following steps came from Effective Java Programming Language + * Guide by Joshua Bloch, Chapter 3 + * + * @return a hash code value for the object. + */ + public int hashCode() { + int result = super.hashCode(); + + long tmp; + + return result; + } + + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() { + try { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) { + return false; } + return true; + } + + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, out); + } + + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, handler); + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @return the unmarshaled uk.ac.vamsas.objects.core.RangeType + */ + public static uk.ac.vamsas.objects.core.RangeType unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + return (uk.ac.vamsas.objects.core.RangeType) Unmarshaller.unmarshal( + uk.ac.vamsas.objects.core.Mapped.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/uk/ac/vamsas/objects/core/Mapping.java b/src/uk/ac/vamsas/objects/core/Mapping.java index 97eadf1..7ab5e0a 100644 --- a/src/uk/ac/vamsas/objects/core/Mapping.java +++ b/src/uk/ac/vamsas/objects/core/Mapping.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import org.exolab.castor.xml.Marshaller; @@ -19,184 +33,177 @@ import org.exolab.castor.xml.Unmarshaller; * * @version $Revision$ $Date$ */ -public class Mapping extends uk.ac.vamsas.objects.core.MapList -implements java.io.Serializable -{ - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * object to which the mapping is being mapped - * - */ - private java.lang.Object _onto; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public Mapping() { - super(); - } - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Overrides the java.lang.Object.equals method. - * - * @param obj - * @return true if the objects are equal. - */ - public boolean equals( - final java.lang.Object obj) { - if ( this == obj ) - return true; - - if (super.equals(obj)==false) - return false; - - if (obj instanceof Mapping) { - - Mapping temp = (Mapping)obj; - if (this._onto != null) { - if (temp._onto == null) return false; - else if (!(this._onto.equals(temp._onto))) - return false; - } - else if (temp._onto != null) - return false; - return true; - } +public class Mapping extends uk.ac.vamsas.objects.core.MapList implements + java.io.Serializable { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * object to which the mapping is being mapped + * + */ + private java.lang.Object _onto; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public Mapping() { + super(); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * Overrides the java.lang.Object.equals method. + * + * @param obj + * @return true if the objects are equal. + */ + public boolean equals(final java.lang.Object obj) { + if (this == obj) + return true; + + if (super.equals(obj) == false) + return false; + + if (obj instanceof Mapping) { + + Mapping temp = (Mapping) obj; + if (this._onto != null) { + if (temp._onto == null) + return false; + else if (!(this._onto.equals(temp._onto))) + return false; + } else if (temp._onto != null) return false; + return true; } - - /** - * Returns the value of field 'onto'. The field 'onto' has the - * following description: object to which the mapping is being - * mapped - * - * - * @return the value of field 'Onto'. - */ - public java.lang.Object getOnto( - ) { - return this._onto; - } - - /** - * Overrides the java.lang.Object.hashCode method. - *

- * The following steps came from Effective Java Programming - * Language Guide by Joshua Bloch, Chapter 3 - * - * @return a hash code value for the object. - */ - public int hashCode( - ) { - int result = super.hashCode(); - - long tmp; - if (_onto != null) { - result = 37 * result + _onto.hashCode(); - } - - return result; - } - - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { - return false; - } - return true; - } - - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } - - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } - - /** - * Sets the value of field 'onto'. The field 'onto' has the - * following description: object to which the mapping is being - * mapped - * - * - * @param onto the value of field 'onto'. - */ - public void setOnto( - final java.lang.Object onto) { - this._onto = onto; - } - - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled uk.ac.vamsas.objects.core.MapList - */ - public static uk.ac.vamsas.objects.core.MapList unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (uk.ac.vamsas.objects.core.MapList) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.Mapping.class, reader); + return false; + } + + /** + * Returns the value of field 'onto'. The field 'onto' has the following + * description: object to which the mapping is being mapped + * + * + * @return the value of field 'Onto'. + */ + public java.lang.Object getOnto() { + return this._onto; + } + + /** + * Overrides the java.lang.Object.hashCode method. + *

+ * The following steps came from Effective Java Programming Language + * Guide by Joshua Bloch, Chapter 3 + * + * @return a hash code value for the object. + */ + public int hashCode() { + int result = super.hashCode(); + + long tmp; + if (_onto != null) { + result = 37 * result + _onto.hashCode(); } - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); + return result; + } + + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() { + try { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) { + return false; } + return true; + } + + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, out); + } + + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, handler); + } + + /** + * Sets the value of field 'onto'. The field 'onto' has the following + * description: object to which the mapping is being mapped + * + * + * @param onto + * the value of field 'onto'. + */ + public void setOnto(final java.lang.Object onto) { + this._onto = onto; + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @return the unmarshaled uk.ac.vamsas.objects.core.MapList + */ + public static uk.ac.vamsas.objects.core.MapList unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + return (uk.ac.vamsas.objects.core.MapList) Unmarshaller.unmarshal( + uk.ac.vamsas.objects.core.Mapping.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/uk/ac/vamsas/objects/core/Newick.java b/src/uk/ac/vamsas/objects/core/Newick.java index 2813c56..ac9e2cf 100644 --- a/src/uk/ac/vamsas/objects/core/Newick.java +++ b/src/uk/ac/vamsas/objects/core/Newick.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import org.exolab.castor.xml.Marshaller; @@ -17,364 +31,383 @@ import org.exolab.castor.xml.Unmarshaller; /** * Class Newick. * - * @version $Revision$ $Date$ + * @version $Revision$ $Date: 2007-06-28 14:51:44 +0100 (Thu, 28 Jun 2007) + * $ */ -public class Newick extends uk.ac.vamsas.client.Vobject -implements java.io.Serializable -{ +public class Newick extends uk.ac.vamsas.client.Vobject implements + java.io.Serializable { + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ + /** + * internal content storage + */ + private java.lang.String _content = ""; - /** - * internal content storage - */ - private java.lang.String _content = ""; + /** + * Field _title. + */ + private java.lang.String _title; - /** - * Field _title. - */ - private java.lang.String _title; + /** + * Primary Key for vamsas object referencing + * + */ + private java.lang.String _id; - /** - * Primary Key for vamsas object referencing - * - */ - private java.lang.String _id; + /** + * Field _modifiable. + */ + private java.lang.String _modifiable; - /** - * Field _modifiable. - */ - private java.lang.String _modifiable; + // ----------------/ + // - Constructors -/ + // ----------------/ + public Newick() { + super(); + setContent(""); + } - //----------------/ - //- Constructors -/ - //----------------/ + // -----------/ + // - Methods -/ + // -----------/ - public Newick() { - super(); - setContent(""); - } + /** + * Overrides the java.lang.Object.equals method. + * + * @param obj + * @return true if the objects are equal. + */ + public boolean equals(final java.lang.Object obj) { + if (this == obj) + return true; + + if (super.equals(obj) == false) + return false; + if (obj instanceof Newick) { - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Overrides the java.lang.Object.equals method. - * - * @param obj - * @return true if the objects are equal. - */ - public boolean equals( - final java.lang.Object obj) { - if ( this == obj ) - return true; - - if (super.equals(obj)==false) + Newick temp = (Newick) obj; + boolean thcycle; + boolean tmcycle; + if (this._content != null) { + if (temp._content == null) + return false; + if (this._content != temp._content) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._content); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._content); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._content); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._content); + } + ; + return false; + } + if (!thcycle) { + if (!this._content.equals(temp._content)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._content); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._content); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._content); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._content); + } + } + } else if (temp._content != null) + return false; + if (this._title != null) { + if (temp._title == null) + return false; + if (this._title != temp._title) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._title); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._title); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._title); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._title); + } + ; return false; - - if (obj instanceof Newick) { - - Newick temp = (Newick)obj; - boolean thcycle; - boolean tmcycle; - if (this._content != null) { - if (temp._content == null) return false; - if (this._content != temp._content) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._content); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._content); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._content); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._content); }; - return false; - } - if (!thcycle) { - if (!this._content.equals(temp._content)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._content); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._content); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._content); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._content); - } - } - } else if (temp._content != null) - return false; - if (this._title != null) { - if (temp._title == null) return false; - if (this._title != temp._title) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._title); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._title); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._title); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._title); }; - return false; - } - if (!thcycle) { - if (!this._title.equals(temp._title)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._title); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._title); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._title); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._title); - } - } - } else if (temp._title != null) - return false; - if (this._id != null) { - if (temp._id == null) return false; - if (this._id != temp._id) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._id); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._id); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._id); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); }; - return false; - } - if (!thcycle) { - if (!this._id.equals(temp._id)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._id); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._id); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); - } - } - } else if (temp._id != null) - return false; - if (this._modifiable != null) { - if (temp._modifiable == null) return false; - if (this._modifiable != temp._modifiable) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._modifiable); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._modifiable); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._modifiable); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._modifiable); }; - return false; - } - if (!thcycle) { - if (!this._modifiable.equals(temp._modifiable)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._modifiable); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._modifiable); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._modifiable); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._modifiable); - } - } - } else if (temp._modifiable != null) - return false; - return true; + } + if (!thcycle) { + if (!this._title.equals(temp._title)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._title); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._title); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._title); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._title); + } } + } else if (temp._title != null) return false; + if (this._id != null) { + if (temp._id == null) + return false; + if (this._id != temp._id) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._id); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._id); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._id); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); + } + ; + return false; + } + if (!thcycle) { + if (!this._id.equals(temp._id)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._id); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._id); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); + } + } + } else if (temp._id != null) + return false; + if (this._modifiable != null) { + if (temp._modifiable == null) + return false; + if (this._modifiable != temp._modifiable) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._modifiable); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._modifiable); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._modifiable); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._modifiable); + } + ; + return false; + } + if (!thcycle) { + if (!this._modifiable.equals(temp._modifiable)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._modifiable); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._modifiable); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._modifiable); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._modifiable); + } + } + } else if (temp._modifiable != null) + return false; + return true; } + return false; + } - /** - * Returns the value of field 'content'. The field 'content' - * has the following description: internal content storage - * - * @return the value of field 'Content'. - */ - public java.lang.String getContent( - ) { - return this._content; - } + /** + * Returns the value of field 'content'. The field 'content' has the following + * description: internal content storage + * + * @return the value of field 'Content'. + */ + public java.lang.String getContent() { + return this._content; + } - /** - * Returns the value of field 'id'. The field 'id' has the - * following description: Primary Key for vamsas object - * referencing - * - * - * @return the value of field 'Id'. - */ - public java.lang.String getId( - ) { - return this._id; - } + /** + * Returns the value of field 'id'. The field 'id' has the following + * description: Primary Key for vamsas object referencing + * + * + * @return the value of field 'Id'. + */ + public java.lang.String getId() { + return this._id; + } - /** - * Returns the value of field 'modifiable'. - * - * @return the value of field 'Modifiable'. - */ - public java.lang.String getModifiable( - ) { - return this._modifiable; - } + /** + * Returns the value of field 'modifiable'. + * + * @return the value of field 'Modifiable'. + */ + public java.lang.String getModifiable() { + return this._modifiable; + } - /** - * Returns the value of field 'title'. - * - * @return the value of field 'Title'. - */ - public java.lang.String getTitle( - ) { - return this._title; - } + /** + * Returns the value of field 'title'. + * + * @return the value of field 'Title'. + */ + public java.lang.String getTitle() { + return this._title; + } - /** - * Overrides the java.lang.Object.hashCode method. - *

- * The following steps came from Effective Java Programming - * Language Guide by Joshua Bloch, Chapter 3 - * - * @return a hash code value for the object. - */ - public int hashCode( - ) { - int result = super.hashCode(); - - long tmp; - if (_content != null - && !org.castor.util.CycleBreaker.startingToCycle(_content)) { - result = 37 * result + _content.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_content); - } - if (_title != null - && !org.castor.util.CycleBreaker.startingToCycle(_title)) { - result = 37 * result + _title.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_title); - } - if (_id != null - && !org.castor.util.CycleBreaker.startingToCycle(_id)) { - result = 37 * result + _id.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_id); - } - if (_modifiable != null - && !org.castor.util.CycleBreaker.startingToCycle(_modifiable)) { - result = 37 * result + _modifiable.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_modifiable); - } - - return result; - } + /** + * Overrides the java.lang.Object.hashCode method. + *

+ * The following steps came from Effective Java Programming Language + * Guide by Joshua Bloch, Chapter 3 + * + * @return a hash code value for the object. + */ + public int hashCode() { + int result = super.hashCode(); - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { - return false; - } - return true; + long tmp; + if (_content != null + && !org.castor.util.CycleBreaker.startingToCycle(_content)) { + result = 37 * result + _content.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_content); } - - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); + if (_title != null && !org.castor.util.CycleBreaker.startingToCycle(_title)) { + result = 37 * result + _title.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_title); } - - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); + if (_id != null && !org.castor.util.CycleBreaker.startingToCycle(_id)) { + result = 37 * result + _id.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_id); } - - /** - * Sets the value of field 'content'. The field 'content' has - * the following description: internal content storage - * - * @param content the value of field 'content'. - */ - public void setContent( - final java.lang.String content) { - this._content = content; + if (_modifiable != null + && !org.castor.util.CycleBreaker.startingToCycle(_modifiable)) { + result = 37 * result + _modifiable.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_modifiable); } - /** - * 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( - final java.lang.String id) { - this._id = id; - } + return result; + } - /** - * Sets the value of field 'modifiable'. - * - * @param modifiable the value of field 'modifiable'. - */ - public void setModifiable( - final java.lang.String modifiable) { - this._modifiable = modifiable; + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() { + try { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) { + return false; } + return true; + } - /** - * Sets the value of field 'title'. - * - * @param title the value of field 'title'. - */ - public void setTitle( - final java.lang.String title) { - this._title = title; - } + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, out); + } - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled uk.ac.vamsas.objects.core.Newick - */ - public static uk.ac.vamsas.objects.core.Newick unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (uk.ac.vamsas.objects.core.Newick) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.Newick.class, reader); - } + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, handler); + } - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); - } + /** + * Sets the value of field 'content'. The field 'content' has the following + * description: internal content storage + * + * @param content + * the value of field 'content'. + */ + public void setContent(final java.lang.String content) { + this._content = content; + } + + /** + * 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(final java.lang.String id) { + this._id = id; + } + + /** + * Sets the value of field 'modifiable'. + * + * @param modifiable + * the value of field 'modifiable'. + */ + public void setModifiable(final java.lang.String modifiable) { + this._modifiable = modifiable; + } + + /** + * Sets the value of field 'title'. + * + * @param title + * the value of field 'title'. + */ + public void setTitle(final java.lang.String title) { + this._title = title; + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @return the unmarshaled uk.ac.vamsas.objects.core.Newick + */ + public static uk.ac.vamsas.objects.core.Newick unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + return (uk.ac.vamsas.objects.core.Newick) Unmarshaller.unmarshal( + uk.ac.vamsas.objects.core.Newick.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/uk/ac/vamsas/objects/core/NodeType.java b/src/uk/ac/vamsas/objects/core/NodeType.java index 488c0ee..1109722 100644 --- a/src/uk/ac/vamsas/objects/core/NodeType.java +++ b/src/uk/ac/vamsas/objects/core/NodeType.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import org.exolab.castor.xml.Marshaller; @@ -19,805 +33,828 @@ import org.exolab.castor.xml.Unmarshaller; * * @version $Revision$ $Date$ */ -public class NodeType extends uk.ac.vamsas.client.Vobject -implements java.io.Serializable -{ - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Primary Key for vamsas object referencing - */ - private java.lang.String _id; - - /** - * Field _modifiable. - */ - private java.lang.String _modifiable; - - /** - * Short name for this node - */ - private java.lang.String _name; - - /** - * Descriptive text for this node - */ - private java.lang.String _description; - - /** - * Direct associations between this node and any vamsas - * objects - */ - private java.util.Vector _vrefList; - - /** - * Field _propertyList. - */ - private java.util.Vector _propertyList; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public NodeType() { - super(); - this._vrefList = new java.util.Vector(); - this._propertyList = new java.util.Vector(); - } - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * - * - * @param vProperty - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addProperty( - final uk.ac.vamsas.objects.core.Property vProperty) - throws java.lang.IndexOutOfBoundsException { - this._propertyList.addElement(vProperty); - } - - /** - * - * - * @param index - * @param vProperty - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addProperty( - final int index, - final uk.ac.vamsas.objects.core.Property vProperty) - throws java.lang.IndexOutOfBoundsException { - this._propertyList.add(index, vProperty); - } - - /** - * - * - * @param vVref - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addVref( - final uk.ac.vamsas.objects.core.Vref vVref) - throws java.lang.IndexOutOfBoundsException { - this._vrefList.addElement(vVref); - } - - /** - * - * - * @param index - * @param vVref - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addVref( - final int index, - final uk.ac.vamsas.objects.core.Vref vVref) - throws java.lang.IndexOutOfBoundsException { - this._vrefList.add(index, vVref); - } - - /** - * Method enumerateProperty. - * - * @return an Enumeration over all - * uk.ac.vamsas.objects.core.Property elements - */ - public java.util.Enumeration enumerateProperty( - ) { - return this._propertyList.elements(); - } - - /** - * Method enumerateVref. - * - * @return an Enumeration over all - * uk.ac.vamsas.objects.core.Vref elements - */ - public java.util.Enumeration enumerateVref( - ) { - return this._vrefList.elements(); - } - - /** - * Overrides the java.lang.Object.equals method. - * - * @param obj - * @return true if the objects are equal. - */ - public boolean equals( - final java.lang.Object obj) { - if ( this == obj ) - return true; - - if (super.equals(obj)==false) +public class NodeType extends uk.ac.vamsas.client.Vobject implements + java.io.Serializable { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Primary Key for vamsas object referencing + */ + private java.lang.String _id; + + /** + * Field _modifiable. + */ + private java.lang.String _modifiable; + + /** + * Short name for this node + */ + private java.lang.String _name; + + /** + * Descriptive text for this node + */ + private java.lang.String _description; + + /** + * Direct associations between this node and any vamsas objects + */ + private java.util.Vector _vrefList; + + /** + * Field _propertyList. + */ + private java.util.Vector _propertyList; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public NodeType() { + super(); + this._vrefList = new java.util.Vector(); + this._propertyList = new java.util.Vector(); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * + * + * @param vProperty + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addProperty(final uk.ac.vamsas.objects.core.Property vProperty) + throws java.lang.IndexOutOfBoundsException { + this._propertyList.addElement(vProperty); + } + + /** + * + * + * @param index + * @param vProperty + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addProperty(final int index, + final uk.ac.vamsas.objects.core.Property vProperty) + throws java.lang.IndexOutOfBoundsException { + this._propertyList.add(index, vProperty); + } + + /** + * + * + * @param vVref + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addVref(final uk.ac.vamsas.objects.core.Vref vVref) + throws java.lang.IndexOutOfBoundsException { + this._vrefList.addElement(vVref); + } + + /** + * + * + * @param index + * @param vVref + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addVref(final int index, + final uk.ac.vamsas.objects.core.Vref vVref) + throws java.lang.IndexOutOfBoundsException { + this._vrefList.add(index, vVref); + } + + /** + * Method enumerateProperty. + * + * @return an Enumeration over all uk.ac.vamsas.objects.core.Property elements + */ + public java.util.Enumeration enumerateProperty() { + return this._propertyList.elements(); + } + + /** + * Method enumerateVref. + * + * @return an Enumeration over all uk.ac.vamsas.objects.core.Vref elements + */ + public java.util.Enumeration enumerateVref() { + return this._vrefList.elements(); + } + + /** + * Overrides the java.lang.Object.equals method. + * + * @param obj + * @return true if the objects are equal. + */ + public boolean equals(final java.lang.Object obj) { + if (this == obj) + return true; + + if (super.equals(obj) == false) + return false; + + if (obj instanceof NodeType) { + + NodeType temp = (NodeType) obj; + boolean thcycle; + boolean tmcycle; + if (this._id != null) { + if (temp._id == null) + return false; + if (this._id != temp._id) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._id); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._id); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._id); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); + } + ; return false; - - if (obj instanceof NodeType) { - - NodeType temp = (NodeType)obj; - boolean thcycle; - boolean tmcycle; - if (this._id != null) { - if (temp._id == null) return false; - if (this._id != temp._id) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._id); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._id); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._id); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); }; - return false; - } - if (!thcycle) { - if (!this._id.equals(temp._id)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._id); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._id); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); - } - } - } else if (temp._id != null) - return false; - if (this._modifiable != null) { - if (temp._modifiable == null) return false; - if (this._modifiable != temp._modifiable) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._modifiable); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._modifiable); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._modifiable); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._modifiable); }; - return false; - } - if (!thcycle) { - if (!this._modifiable.equals(temp._modifiable)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._modifiable); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._modifiable); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._modifiable); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._modifiable); - } - } - } else if (temp._modifiable != null) - return false; - if (this._name != null) { - if (temp._name == null) return false; - if (this._name != temp._name) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._name); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._name); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._name); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._name); }; - return false; - } - if (!thcycle) { - if (!this._name.equals(temp._name)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._name); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._name); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._name); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._name); - } - } - } else if (temp._name != null) - return false; - if (this._description != null) { - if (temp._description == null) return false; - if (this._description != temp._description) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._description); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._description); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._description); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._description); }; - return false; - } - if (!thcycle) { - if (!this._description.equals(temp._description)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._description); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._description); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._description); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._description); - } - } - } else if (temp._description != null) - return false; - if (this._vrefList != null) { - if (temp._vrefList == null) return false; - if (this._vrefList != temp._vrefList) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._vrefList); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._vrefList); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._vrefList); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._vrefList); }; - return false; - } - if (!thcycle) { - if (!this._vrefList.equals(temp._vrefList)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._vrefList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._vrefList); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._vrefList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._vrefList); - } - } - } else if (temp._vrefList != null) - return false; - if (this._propertyList != null) { - if (temp._propertyList == null) return false; - if (this._propertyList != temp._propertyList) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._propertyList); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._propertyList); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._propertyList); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._propertyList); }; - return false; - } - if (!thcycle) { - if (!this._propertyList.equals(temp._propertyList)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._propertyList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._propertyList); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._propertyList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._propertyList); - } - } - } else if (temp._propertyList != null) - return false; - return true; + } + if (!thcycle) { + if (!this._id.equals(temp._id)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._id); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._id); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); + } } + } else if (temp._id != null) return false; - } - - /** - * Returns the value of field 'description'. The field - * 'description' has the following description: Descriptive - * text for this node - * - * @return the value of field 'Description'. - */ - public java.lang.String getDescription( - ) { - return this._description; - } - - /** - * Returns the value of field 'id'. The field 'id' has the - * following description: Primary Key for vamsas object - * referencing - * - * @return the value of field 'Id'. - */ - public java.lang.String getId( - ) { - return this._id; - } - - /** - * Returns the value of field 'modifiable'. - * - * @return the value of field 'Modifiable'. - */ - public java.lang.String getModifiable( - ) { - return this._modifiable; - } - - /** - * Returns the value of field 'name'. The field 'name' has the - * following description: Short name for this node - * - * @return the value of field 'Name'. - */ - public java.lang.String getName( - ) { - return this._name; - } - - /** - * Method getProperty. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the uk.ac.vamsas.objects.core.Property - * at the given index - */ - public uk.ac.vamsas.objects.core.Property getProperty( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._propertyList.size()) { - throw new IndexOutOfBoundsException("getProperty: Index value '" + index + "' not in range [0.." + (this._propertyList.size() - 1) + "]"); - } - - return (uk.ac.vamsas.objects.core.Property) _propertyList.get(index); - } - - /** - * Method getProperty.Returns the contents of the collection in - * an Array.

Note: Just in case the collection contents - * are changing in another thread, we pass a 0-length Array of - * the correct type into the API call. This way we know - * that the Array returned is of exactly the correct length. - * - * @return this collection as an Array - */ - public uk.ac.vamsas.objects.core.Property[] getProperty( - ) { - uk.ac.vamsas.objects.core.Property[] array = new uk.ac.vamsas.objects.core.Property[0]; - return (uk.ac.vamsas.objects.core.Property[]) this._propertyList.toArray(array); - } - - /** - * Method getPropertyAsReference.Returns a reference to - * '_propertyList'. No type checking is performed on any - * modifications to the Vector. - * - * @return a reference to the Vector backing this class - */ - public java.util.Vector getPropertyAsReference( - ) { - return this._propertyList; - } - - /** - * Method getPropertyCount. - * - * @return the size of this collection - */ - public int getPropertyCount( - ) { - return this._propertyList.size(); - } - - /** - * Method getVref. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the uk.ac.vamsas.objects.core.Vref at - * the given index - */ - public uk.ac.vamsas.objects.core.Vref getVref( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._vrefList.size()) { - throw new IndexOutOfBoundsException("getVref: Index value '" + index + "' not in range [0.." + (this._vrefList.size() - 1) + "]"); - } - - return (uk.ac.vamsas.objects.core.Vref) _vrefList.get(index); - } - - /** - * Method getVref.Returns the contents of the collection in an - * Array.

Note: Just in case the collection contents are - * changing in another thread, we pass a 0-length Array of the - * correct type into the API call. This way we know - * that the Array returned is of exactly the correct length. - * - * @return this collection as an Array - */ - public uk.ac.vamsas.objects.core.Vref[] getVref( - ) { - uk.ac.vamsas.objects.core.Vref[] array = new uk.ac.vamsas.objects.core.Vref[0]; - return (uk.ac.vamsas.objects.core.Vref[]) this._vrefList.toArray(array); - } - - /** - * Method getVrefAsReference.Returns a reference to - * '_vrefList'. No type checking is performed on any - * modifications to the Vector. - * - * @return a reference to the Vector backing this class - */ - public java.util.Vector getVrefAsReference( - ) { - return this._vrefList; - } - - /** - * Method getVrefCount. - * - * @return the size of this collection - */ - public int getVrefCount( - ) { - return this._vrefList.size(); - } - - /** - * Overrides the java.lang.Object.hashCode method. - *

- * The following steps came from Effective Java Programming - * Language Guide by Joshua Bloch, Chapter 3 - * - * @return a hash code value for the object. - */ - public int hashCode( - ) { - int result = super.hashCode(); - - long tmp; - if (_id != null - && !org.castor.util.CycleBreaker.startingToCycle(_id)) { - result = 37 * result + _id.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_id); - } - if (_modifiable != null - && !org.castor.util.CycleBreaker.startingToCycle(_modifiable)) { - result = 37 * result + _modifiable.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_modifiable); - } - if (_name != null - && !org.castor.util.CycleBreaker.startingToCycle(_name)) { - result = 37 * result + _name.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_name); - } - if (_description != null - && !org.castor.util.CycleBreaker.startingToCycle(_description)) { - result = 37 * result + _description.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_description); - } - if (_vrefList != null - && !org.castor.util.CycleBreaker.startingToCycle(_vrefList)) { - result = 37 * result + _vrefList.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_vrefList); - } - if (_propertyList != null - && !org.castor.util.CycleBreaker.startingToCycle(_propertyList)) { - result = 37 * result + _propertyList.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_propertyList); - } - - return result; - } - - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { + if (this._modifiable != null) { + if (temp._modifiable == null) + return false; + if (this._modifiable != temp._modifiable) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._modifiable); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._modifiable); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._modifiable); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._modifiable); + } + ; return false; + } + if (!thcycle) { + if (!this._modifiable.equals(temp._modifiable)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._modifiable); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._modifiable); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._modifiable); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._modifiable); + } } - return true; - } - - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } - - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } - - /** - */ - public void removeAllProperty( - ) { - this._propertyList.clear(); - } - - /** - */ - public void removeAllVref( - ) { - this._vrefList.clear(); - } - - /** - * Method removeProperty. - * - * @param vProperty - * @return true if the object was removed from the collection. - */ - public boolean removeProperty( - final uk.ac.vamsas.objects.core.Property vProperty) { - boolean removed = _propertyList.remove(vProperty); - return removed; - } - - /** - * Method removePropertyAt. - * - * @param index - * @return the element removed from the collection - */ - public uk.ac.vamsas.objects.core.Property removePropertyAt( - final int index) { - java.lang.Object obj = this._propertyList.remove(index); - return (uk.ac.vamsas.objects.core.Property) obj; - } - - /** - * Method removeVref. - * - * @param vVref - * @return true if the object was removed from the collection. - */ - public boolean removeVref( - final uk.ac.vamsas.objects.core.Vref vVref) { - boolean removed = _vrefList.remove(vVref); - return removed; - } - - /** - * Method removeVrefAt. - * - * @param index - * @return the element removed from the collection - */ - public uk.ac.vamsas.objects.core.Vref removeVrefAt( - final int index) { - java.lang.Object obj = this._vrefList.remove(index); - return (uk.ac.vamsas.objects.core.Vref) obj; - } - - /** - * Sets the value of field 'description'. The field - * 'description' has the following description: Descriptive - * text for this node - * - * @param description the value of field 'description'. - */ - public void setDescription( - final java.lang.String description) { - this._description = description; - } - - /** - * 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( - final java.lang.String id) { - this._id = id; - } - - /** - * Sets the value of field 'modifiable'. - * - * @param modifiable the value of field 'modifiable'. - */ - public void setModifiable( - final java.lang.String modifiable) { - this._modifiable = modifiable; - } - - /** - * Sets the value of field 'name'. The field 'name' has the - * following description: Short name for this node - * - * @param name the value of field 'name'. - */ - public void setName( - final java.lang.String name) { - this._name = name; - } - - /** - * - * - * @param index - * @param vProperty - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setProperty( - final int index, - final uk.ac.vamsas.objects.core.Property vProperty) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._propertyList.size()) { - throw new IndexOutOfBoundsException("setProperty: Index value '" + index + "' not in range [0.." + (this._propertyList.size() - 1) + "]"); + } else if (temp._modifiable != null) + return false; + if (this._name != null) { + if (temp._name == null) + return false; + if (this._name != temp._name) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._name); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._name); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._name); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._name); + } + ; + return false; + } + if (!thcycle) { + if (!this._name.equals(temp._name)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._name); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._name); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._name); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._name); + } } - - this._propertyList.set(index, vProperty); - } - - /** - * - * - * @param vPropertyArray - */ - public void setProperty( - final uk.ac.vamsas.objects.core.Property[] vPropertyArray) { - //-- copy array - _propertyList.clear(); - - for (int i = 0; i < vPropertyArray.length; i++) { - this._propertyList.add(vPropertyArray[i]); + } else if (temp._name != null) + return false; + if (this._description != null) { + if (temp._description == null) + return false; + if (this._description != temp._description) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._description); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._description); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker + .releaseCycleHandle(this._description); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._description); + } + ; + return false; + } + if (!thcycle) { + if (!this._description.equals(temp._description)) { + org.castor.util.CycleBreaker + .releaseCycleHandle(this._description); + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._description); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._description); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._description); + } } - } - - /** - * Sets the value of '_propertyList' by copying the given - * Vector. All elements will be checked for type safety. - * - * @param vPropertyList the Vector to copy. - */ - public void setProperty( - final java.util.Vector vPropertyList) { - // copy vector - this._propertyList.clear(); - - this._propertyList.addAll(vPropertyList); - } - - /** - * Sets the value of '_propertyList' by setting it to the given - * Vector. No type checking is performed. - * @deprecated - * - * @param propertyVector the Vector to set. - */ - public void setPropertyAsReference( - final java.util.Vector propertyVector) { - this._propertyList = propertyVector; - } - - /** - * - * - * @param index - * @param vVref - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setVref( - final int index, - final uk.ac.vamsas.objects.core.Vref vVref) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._vrefList.size()) { - throw new IndexOutOfBoundsException("setVref: Index value '" + index + "' not in range [0.." + (this._vrefList.size() - 1) + "]"); + } else if (temp._description != null) + return false; + if (this._vrefList != null) { + if (temp._vrefList == null) + return false; + if (this._vrefList != temp._vrefList) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._vrefList); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._vrefList); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._vrefList); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._vrefList); + } + ; + return false; + } + if (!thcycle) { + if (!this._vrefList.equals(temp._vrefList)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._vrefList); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._vrefList); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._vrefList); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._vrefList); + } } - - this._vrefList.set(index, vVref); - } - - /** - * - * - * @param vVrefArray - */ - public void setVref( - final uk.ac.vamsas.objects.core.Vref[] vVrefArray) { - //-- copy array - _vrefList.clear(); - - for (int i = 0; i < vVrefArray.length; i++) { - this._vrefList.add(vVrefArray[i]); + } else if (temp._vrefList != null) + return false; + if (this._propertyList != null) { + if (temp._propertyList == null) + return false; + if (this._propertyList != temp._propertyList) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._propertyList); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._propertyList); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker + .releaseCycleHandle(this._propertyList); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._propertyList); + } + ; + return false; + } + if (!thcycle) { + if (!this._propertyList.equals(temp._propertyList)) { + org.castor.util.CycleBreaker + .releaseCycleHandle(this._propertyList); + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._propertyList); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._propertyList); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._propertyList); + } } - } - - /** - * Sets the value of '_vrefList' by copying the given Vector. - * All elements will be checked for type safety. - * - * @param vVrefList the Vector to copy. - */ - public void setVref( - final java.util.Vector vVrefList) { - // copy vector - this._vrefList.clear(); - - this._vrefList.addAll(vVrefList); - } - - /** - * Sets the value of '_vrefList' by setting it to the given - * Vector. No type checking is performed. - * @deprecated - * - * @param vrefVector the Vector to set. - */ - public void setVrefAsReference( - final java.util.Vector vrefVector) { - this._vrefList = vrefVector; - } - - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled uk.ac.vamsas.objects.core.NodeType - */ - public static uk.ac.vamsas.objects.core.NodeType unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (uk.ac.vamsas.objects.core.NodeType) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.NodeType.class, reader); - } - - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); - } + } else if (temp._propertyList != null) + return false; + return true; + } + return false; + } + + /** + * Returns the value of field 'description'. The field 'description' has the + * following description: Descriptive text for this node + * + * @return the value of field 'Description'. + */ + public java.lang.String getDescription() { + return this._description; + } + + /** + * Returns the value of field 'id'. The field 'id' has the following + * description: Primary Key for vamsas object referencing + * + * @return the value of field 'Id'. + */ + public java.lang.String getId() { + return this._id; + } + + /** + * Returns the value of field 'modifiable'. + * + * @return the value of field 'Modifiable'. + */ + public java.lang.String getModifiable() { + return this._modifiable; + } + + /** + * Returns the value of field 'name'. The field 'name' has the following + * description: Short name for this node + * + * @return the value of field 'Name'. + */ + public java.lang.String getName() { + return this._name; + } + + /** + * Method getProperty. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the uk.ac.vamsas.objects.core.Property at the given + * index + */ + public uk.ac.vamsas.objects.core.Property getProperty(final int index) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._propertyList.size()) { + throw new IndexOutOfBoundsException("getProperty: Index value '" + index + + "' not in range [0.." + (this._propertyList.size() - 1) + "]"); + } + + return (uk.ac.vamsas.objects.core.Property) _propertyList.get(index); + } + + /** + * Method getProperty.Returns the contents of the collection in an Array. + *

+ * Note: Just in case the collection contents are changing in another thread, + * we pass a 0-length Array of the correct type into the API call. This way we + * know that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public uk.ac.vamsas.objects.core.Property[] getProperty() { + uk.ac.vamsas.objects.core.Property[] array = new uk.ac.vamsas.objects.core.Property[0]; + return (uk.ac.vamsas.objects.core.Property[]) this._propertyList + .toArray(array); + } + + /** + * Method getPropertyAsReference.Returns a reference to '_propertyList'. No + * type checking is performed on any modifications to the Vector. + * + * @return a reference to the Vector backing this class + */ + public java.util.Vector getPropertyAsReference() { + return this._propertyList; + } + + /** + * Method getPropertyCount. + * + * @return the size of this collection + */ + public int getPropertyCount() { + return this._propertyList.size(); + } + + /** + * Method getVref. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the uk.ac.vamsas.objects.core.Vref at the given index + */ + public uk.ac.vamsas.objects.core.Vref getVref(final int index) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._vrefList.size()) { + throw new IndexOutOfBoundsException("getVref: Index value '" + index + + "' not in range [0.." + (this._vrefList.size() - 1) + "]"); + } + + return (uk.ac.vamsas.objects.core.Vref) _vrefList.get(index); + } + + /** + * Method getVref.Returns the contents of the collection in an Array. + *

+ * Note: Just in case the collection contents are changing in another thread, + * we pass a 0-length Array of the correct type into the API call. This way we + * know that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public uk.ac.vamsas.objects.core.Vref[] getVref() { + uk.ac.vamsas.objects.core.Vref[] array = new uk.ac.vamsas.objects.core.Vref[0]; + return (uk.ac.vamsas.objects.core.Vref[]) this._vrefList.toArray(array); + } + + /** + * Method getVrefAsReference.Returns a reference to '_vrefList'. No type + * checking is performed on any modifications to the Vector. + * + * @return a reference to the Vector backing this class + */ + public java.util.Vector getVrefAsReference() { + return this._vrefList; + } + + /** + * Method getVrefCount. + * + * @return the size of this collection + */ + public int getVrefCount() { + return this._vrefList.size(); + } + + /** + * Overrides the java.lang.Object.hashCode method. + *

+ * The following steps came from Effective Java Programming Language + * Guide by Joshua Bloch, Chapter 3 + * + * @return a hash code value for the object. + */ + public int hashCode() { + int result = super.hashCode(); + + long tmp; + if (_id != null && !org.castor.util.CycleBreaker.startingToCycle(_id)) { + result = 37 * result + _id.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_id); + } + if (_modifiable != null + && !org.castor.util.CycleBreaker.startingToCycle(_modifiable)) { + result = 37 * result + _modifiable.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_modifiable); + } + if (_name != null && !org.castor.util.CycleBreaker.startingToCycle(_name)) { + result = 37 * result + _name.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_name); + } + if (_description != null + && !org.castor.util.CycleBreaker.startingToCycle(_description)) { + result = 37 * result + _description.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_description); + } + if (_vrefList != null + && !org.castor.util.CycleBreaker.startingToCycle(_vrefList)) { + result = 37 * result + _vrefList.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_vrefList); + } + if (_propertyList != null + && !org.castor.util.CycleBreaker.startingToCycle(_propertyList)) { + result = 37 * result + _propertyList.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_propertyList); + } + + return result; + } + + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() { + try { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) { + return false; + } + return true; + } + + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, out); + } + + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, handler); + } + + /** + */ + public void removeAllProperty() { + this._propertyList.clear(); + } + + /** + */ + public void removeAllVref() { + this._vrefList.clear(); + } + + /** + * Method removeProperty. + * + * @param vProperty + * @return true if the object was removed from the collection. + */ + public boolean removeProperty( + final uk.ac.vamsas.objects.core.Property vProperty) { + boolean removed = _propertyList.remove(vProperty); + return removed; + } + + /** + * Method removePropertyAt. + * + * @param index + * @return the element removed from the collection + */ + public uk.ac.vamsas.objects.core.Property removePropertyAt(final int index) { + java.lang.Object obj = this._propertyList.remove(index); + return (uk.ac.vamsas.objects.core.Property) obj; + } + + /** + * Method removeVref. + * + * @param vVref + * @return true if the object was removed from the collection. + */ + public boolean removeVref(final uk.ac.vamsas.objects.core.Vref vVref) { + boolean removed = _vrefList.remove(vVref); + return removed; + } + + /** + * Method removeVrefAt. + * + * @param index + * @return the element removed from the collection + */ + public uk.ac.vamsas.objects.core.Vref removeVrefAt(final int index) { + java.lang.Object obj = this._vrefList.remove(index); + return (uk.ac.vamsas.objects.core.Vref) obj; + } + + /** + * Sets the value of field 'description'. The field 'description' has the + * following description: Descriptive text for this node + * + * @param description + * the value of field 'description'. + */ + public void setDescription(final java.lang.String description) { + this._description = description; + } + + /** + * 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(final java.lang.String id) { + this._id = id; + } + + /** + * Sets the value of field 'modifiable'. + * + * @param modifiable + * the value of field 'modifiable'. + */ + public void setModifiable(final java.lang.String modifiable) { + this._modifiable = modifiable; + } + + /** + * Sets the value of field 'name'. The field 'name' has the following + * description: Short name for this node + * + * @param name + * the value of field 'name'. + */ + public void setName(final java.lang.String name) { + this._name = name; + } + + /** + * + * + * @param index + * @param vProperty + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setProperty(final int index, + final uk.ac.vamsas.objects.core.Property vProperty) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._propertyList.size()) { + throw new IndexOutOfBoundsException("setProperty: Index value '" + index + + "' not in range [0.." + (this._propertyList.size() - 1) + "]"); + } + + this._propertyList.set(index, vProperty); + } + + /** + * + * + * @param vPropertyArray + */ + public void setProperty( + final uk.ac.vamsas.objects.core.Property[] vPropertyArray) { + // -- copy array + _propertyList.clear(); + + for (int i = 0; i < vPropertyArray.length; i++) { + this._propertyList.add(vPropertyArray[i]); + } + } + + /** + * Sets the value of '_propertyList' by copying the given Vector. All elements + * will be checked for type safety. + * + * @param vPropertyList + * the Vector to copy. + */ + public void setProperty(final java.util.Vector vPropertyList) { + // copy vector + this._propertyList.clear(); + + this._propertyList.addAll(vPropertyList); + } + + /** + * Sets the value of '_propertyList' by setting it to the given Vector. No + * type checking is performed. + * + * @deprecated + * + * @param propertyVector + * the Vector to set. + */ + public void setPropertyAsReference(final java.util.Vector propertyVector) { + this._propertyList = propertyVector; + } + + /** + * + * + * @param index + * @param vVref + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setVref(final int index, + final uk.ac.vamsas.objects.core.Vref vVref) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._vrefList.size()) { + throw new IndexOutOfBoundsException("setVref: Index value '" + index + + "' not in range [0.." + (this._vrefList.size() - 1) + "]"); + } + + this._vrefList.set(index, vVref); + } + + /** + * + * + * @param vVrefArray + */ + public void setVref(final uk.ac.vamsas.objects.core.Vref[] vVrefArray) { + // -- copy array + _vrefList.clear(); + + for (int i = 0; i < vVrefArray.length; i++) { + this._vrefList.add(vVrefArray[i]); + } + } + + /** + * Sets the value of '_vrefList' by copying the given Vector. All elements + * will be checked for type safety. + * + * @param vVrefList + * the Vector to copy. + */ + public void setVref(final java.util.Vector vVrefList) { + // copy vector + this._vrefList.clear(); + + this._vrefList.addAll(vVrefList); + } + + /** + * Sets the value of '_vrefList' by setting it to the given Vector. No type + * checking is performed. + * + * @deprecated + * + * @param vrefVector + * the Vector to set. + */ + public void setVrefAsReference(final java.util.Vector vrefVector) { + this._vrefList = vrefVector; + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @return the unmarshaled uk.ac.vamsas.objects.core.NodeType + */ + public static uk.ac.vamsas.objects.core.NodeType unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + return (uk.ac.vamsas.objects.core.NodeType) Unmarshaller.unmarshal( + uk.ac.vamsas.objects.core.NodeType.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/uk/ac/vamsas/objects/core/Param.java b/src/uk/ac/vamsas/objects/core/Param.java index e9cece2..d55f705 100644 --- a/src/uk/ac/vamsas/objects/core/Param.java +++ b/src/uk/ac/vamsas/objects/core/Param.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import org.exolab.castor.xml.Marshaller; @@ -19,316 +33,323 @@ import org.exolab.castor.xml.Unmarshaller; * * @version $Revision$ $Date$ */ -public class Param extends uk.ac.vamsas.client.Vobject -implements java.io.Serializable -{ +public class Param extends uk.ac.vamsas.client.Vobject implements + java.io.Serializable { + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ + /** + * internal content storage + */ + private java.lang.String _content = ""; - /** - * internal content storage - */ - private java.lang.String _content = ""; + /** + * Field _name. + */ + private java.lang.String _name; - /** - * Field _name. - */ - private java.lang.String _name; + /** + * The type specifies how the property will be parsed. Empty property strings + * are allowed, and can be used to prototype the input to a document. TODO: + * specify allowed types + */ + private java.lang.String _type; - /** - * The type specifies how the property will be parsed. - * Empty property strings are allowed, and can be used to - * prototype the - * input to a document. TODO: specify allowed types - */ - private java.lang.String _type; + // ----------------/ + // - Constructors -/ + // ----------------/ + public Param() { + super(); + setContent(""); + } - //----------------/ - //- Constructors -/ - //----------------/ + // -----------/ + // - Methods -/ + // -----------/ - public Param() { - super(); - setContent(""); - } + /** + * Overrides the java.lang.Object.equals method. + * + * @param obj + * @return true if the objects are equal. + */ + public boolean equals(final java.lang.Object obj) { + if (this == obj) + return true; + if (super.equals(obj) == false) + return false; - //-----------/ - //- Methods -/ - //-----------/ + if (obj instanceof Param) { - /** - * Overrides the java.lang.Object.equals method. - * - * @param obj - * @return true if the objects are equal. - */ - public boolean equals( - final java.lang.Object obj) { - if ( this == obj ) - return true; - - if (super.equals(obj)==false) + Param temp = (Param) obj; + boolean thcycle; + boolean tmcycle; + if (this._content != null) { + if (temp._content == null) + return false; + if (this._content != temp._content) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._content); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._content); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._content); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._content); + } + ; + return false; + } + if (!thcycle) { + if (!this._content.equals(temp._content)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._content); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._content); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._content); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._content); + } + } + } else if (temp._content != null) + return false; + if (this._name != null) { + if (temp._name == null) + return false; + if (this._name != temp._name) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._name); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._name); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._name); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._name); + } + ; + return false; + } + if (!thcycle) { + if (!this._name.equals(temp._name)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._name); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._name); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._name); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._name); + } + } + } else if (temp._name != null) + return false; + if (this._type != null) { + if (temp._type == null) + return false; + if (this._type != temp._type) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._type); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._type); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._type); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._type); + } + ; return false; - - if (obj instanceof Param) { - - Param temp = (Param)obj; - boolean thcycle; - boolean tmcycle; - if (this._content != null) { - if (temp._content == null) return false; - if (this._content != temp._content) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._content); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._content); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._content); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._content); }; - return false; - } - if (!thcycle) { - if (!this._content.equals(temp._content)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._content); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._content); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._content); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._content); - } - } - } else if (temp._content != null) - return false; - if (this._name != null) { - if (temp._name == null) return false; - if (this._name != temp._name) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._name); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._name); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._name); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._name); }; - return false; - } - if (!thcycle) { - if (!this._name.equals(temp._name)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._name); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._name); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._name); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._name); - } - } - } else if (temp._name != null) - return false; - if (this._type != null) { - if (temp._type == null) return false; - if (this._type != temp._type) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._type); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._type); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._type); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._type); }; - return false; - } - if (!thcycle) { - if (!this._type.equals(temp._type)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._type); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._type); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._type); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._type); - } - } - } else if (temp._type != null) - return false; - return true; + } + if (!thcycle) { + if (!this._type.equals(temp._type)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._type); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._type); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._type); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._type); + } } + } else if (temp._type != null) return false; + return true; } + return false; + } - /** - * Returns the value of field 'content'. The field 'content' - * has the following description: internal content storage - * - * @return the value of field 'Content'. - */ - public java.lang.String getContent( - ) { - return this._content; - } + /** + * Returns the value of field 'content'. The field 'content' has the following + * description: internal content storage + * + * @return the value of field 'Content'. + */ + public java.lang.String getContent() { + return this._content; + } - /** - * Returns the value of field 'name'. - * - * @return the value of field 'Name'. - */ - public java.lang.String getName( - ) { - return this._name; - } + /** + * Returns the value of field 'name'. + * + * @return the value of field 'Name'. + */ + public java.lang.String getName() { + return this._name; + } - /** - * Returns the value of field 'type'. The field 'type' has the - * following description: The type specifies how the property - * will be parsed. - * Empty property strings are allowed, and can be used to - * prototype the - * input to a document. TODO: specify allowed types - * - * @return the value of field 'Type'. - */ - public java.lang.String getType( - ) { - return this._type; - } + /** + * Returns the value of field 'type'. The field 'type' has the following + * description: The type specifies how the property will be parsed. Empty + * property strings are allowed, and can be used to prototype the input to a + * document. TODO: specify allowed types + * + * @return the value of field 'Type'. + */ + public java.lang.String getType() { + return this._type; + } - /** - * Overrides the java.lang.Object.hashCode method. - *

- * The following steps came from Effective Java Programming - * Language Guide by Joshua Bloch, Chapter 3 - * - * @return a hash code value for the object. - */ - public int hashCode( - ) { - int result = super.hashCode(); - - long tmp; - if (_content != null - && !org.castor.util.CycleBreaker.startingToCycle(_content)) { - result = 37 * result + _content.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_content); - } - if (_name != null - && !org.castor.util.CycleBreaker.startingToCycle(_name)) { - result = 37 * result + _name.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_name); - } - if (_type != null - && !org.castor.util.CycleBreaker.startingToCycle(_type)) { - result = 37 * result + _type.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_type); - } - - return result; - } + /** + * Overrides the java.lang.Object.hashCode method. + *

+ * The following steps came from Effective Java Programming Language + * Guide by Joshua Bloch, Chapter 3 + * + * @return a hash code value for the object. + */ + public int hashCode() { + int result = super.hashCode(); - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { - return false; - } - return true; + long tmp; + if (_content != null + && !org.castor.util.CycleBreaker.startingToCycle(_content)) { + result = 37 * result + _content.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_content); } - - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); + if (_name != null && !org.castor.util.CycleBreaker.startingToCycle(_name)) { + result = 37 * result + _name.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_name); } - - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); + if (_type != null && !org.castor.util.CycleBreaker.startingToCycle(_type)) { + result = 37 * result + _type.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_type); } - /** - * Sets the value of field 'content'. The field 'content' has - * the following description: internal content storage - * - * @param content the value of field 'content'. - */ - public void setContent( - final java.lang.String content) { - this._content = content; - } + return result; + } - /** - * Sets the value of field 'name'. - * - * @param name the value of field 'name'. - */ - public void setName( - final java.lang.String name) { - this._name = name; + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() { + try { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) { + return false; } + return true; + } - /** - * Sets the value of field 'type'. The field 'type' has the - * following description: The type specifies how the property - * will be parsed. - * Empty property strings are allowed, and can be used to - * prototype the - * input to a document. TODO: specify allowed types - * - * @param type the value of field 'type'. - */ - public void setType( - final java.lang.String type) { - this._type = type; - } + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, out); + } - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled uk.ac.vamsas.objects.core.Param - */ - public static uk.ac.vamsas.objects.core.Param unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (uk.ac.vamsas.objects.core.Param) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.Param.class, reader); - } + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, handler); + } - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); - } + /** + * Sets the value of field 'content'. The field 'content' has the following + * description: internal content storage + * + * @param content + * the value of field 'content'. + */ + public void setContent(final java.lang.String content) { + this._content = content; + } + + /** + * Sets the value of field 'name'. + * + * @param name + * the value of field 'name'. + */ + public void setName(final java.lang.String name) { + this._name = name; + } + + /** + * Sets the value of field 'type'. The field 'type' has the following + * description: The type specifies how the property will be parsed. Empty + * property strings are allowed, and can be used to prototype the input to a + * document. TODO: specify allowed types + * + * @param type + * the value of field 'type'. + */ + public void setType(final java.lang.String type) { + this._type = type; + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @return the unmarshaled uk.ac.vamsas.objects.core.Param + */ + public static uk.ac.vamsas.objects.core.Param unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + return (uk.ac.vamsas.objects.core.Param) Unmarshaller.unmarshal( + uk.ac.vamsas.objects.core.Param.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/uk/ac/vamsas/objects/core/Pos.java b/src/uk/ac/vamsas/objects/core/Pos.java index 3877be5..4b7a48f 100644 --- a/src/uk/ac/vamsas/objects/core/Pos.java +++ b/src/uk/ac/vamsas/objects/core/Pos.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import org.exolab.castor.xml.Marshaller; @@ -16,201 +30,194 @@ import org.exolab.castor.xml.Unmarshaller; /** * a position within the associated object's coordinate system - * + * * * @version $Revision$ $Date$ */ -public class Pos extends uk.ac.vamsas.client.Vobject -implements java.io.Serializable -{ - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _i. - */ - private int _i; - - /** - * keeps track of state for field: _i - */ - private boolean _has_i; +public class Pos extends uk.ac.vamsas.client.Vobject implements + java.io.Serializable { + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ - //----------------/ - //- Constructors -/ - //----------------/ + /** + * Field _i. + */ + private int _i; - public Pos() { - super(); - } + /** + * keeps track of state for field: _i + */ + private boolean _has_i; + // ----------------/ + // - Constructors -/ + // ----------------/ - //-----------/ - //- Methods -/ - //-----------/ + public Pos() { + super(); + } - /** - */ - public void deleteI( - ) { - this._has_i= false; - } + // -----------/ + // - Methods -/ + // -----------/ - /** - * Overrides the java.lang.Object.equals method. - * - * @param obj - * @return true if the objects are equal. + /** */ - public boolean equals( - final java.lang.Object obj) { - if ( this == obj ) - return true; - - if (super.equals(obj)==false) - return false; - - if (obj instanceof Pos) { - - Pos temp = (Pos)obj; - boolean thcycle; - boolean tmcycle; - if (this._i != temp._i) - return false; - if (this._has_i != temp._has_i) - return false; - return true; - } + public void deleteI() { + this._has_i = false; + } + + /** + * Overrides the java.lang.Object.equals method. + * + * @param obj + * @return true if the objects are equal. + */ + public boolean equals(final java.lang.Object obj) { + if (this == obj) + return true; + + if (super.equals(obj) == false) + return false; + + if (obj instanceof Pos) { + + Pos temp = (Pos) obj; + boolean thcycle; + boolean tmcycle; + if (this._i != temp._i) return false; + if (this._has_i != temp._has_i) + return false; + return true; } - - /** - * Returns the value of field 'i'. - * - * @return the value of field 'I'. - */ - public int getI( - ) { - return this._i; - } - - /** - * Method hasI. - * - * @return true if at least one I has been added - */ - public boolean hasI( - ) { - return this._has_i; - } - - /** - * Overrides the java.lang.Object.hashCode method. - *

- * The following steps came from Effective Java Programming - * Language Guide by Joshua Bloch, Chapter 3 - * - * @return a hash code value for the object. - */ - public int hashCode( - ) { - int result = super.hashCode(); - - long tmp; - result = 37 * result + _i; - - return result; - } - - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { - return false; - } - return true; - } - - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } - - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } - - /** - * Sets the value of field 'i'. - * - * @param i the value of field 'i'. - */ - public void setI( - final int i) { - this._i = i; - this._has_i = true; - } - - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled uk.ac.vamsas.objects.core.Pos - */ - public static uk.ac.vamsas.objects.core.Pos unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (uk.ac.vamsas.objects.core.Pos) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.Pos.class, reader); - } - - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); + return false; + } + + /** + * Returns the value of field 'i'. + * + * @return the value of field 'I'. + */ + public int getI() { + return this._i; + } + + /** + * Method hasI. + * + * @return true if at least one I has been added + */ + public boolean hasI() { + return this._has_i; + } + + /** + * Overrides the java.lang.Object.hashCode method. + *

+ * The following steps came from Effective Java Programming Language + * Guide by Joshua Bloch, Chapter 3 + * + * @return a hash code value for the object. + */ + public int hashCode() { + int result = super.hashCode(); + + long tmp; + result = 37 * result + _i; + + return result; + } + + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() { + try { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) { + return false; } + return true; + } + + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, out); + } + + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, handler); + } + + /** + * Sets the value of field 'i'. + * + * @param i + * the value of field 'i'. + */ + public void setI(final int i) { + this._i = i; + this._has_i = true; + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @return the unmarshaled uk.ac.vamsas.objects.core.Pos + */ + public static uk.ac.vamsas.objects.core.Pos unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + return (uk.ac.vamsas.objects.core.Pos) Unmarshaller.unmarshal( + uk.ac.vamsas.objects.core.Pos.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/uk/ac/vamsas/objects/core/Property.java b/src/uk/ac/vamsas/objects/core/Property.java index bccf4bd..1c63807 100644 --- a/src/uk/ac/vamsas/objects/core/Property.java +++ b/src/uk/ac/vamsas/objects/core/Property.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import org.exolab.castor.xml.Marshaller; @@ -19,316 +33,323 @@ import org.exolab.castor.xml.Unmarshaller; * * @version $Revision$ $Date$ */ -public class Property extends uk.ac.vamsas.client.Vobject -implements java.io.Serializable -{ +public class Property extends uk.ac.vamsas.client.Vobject implements + java.io.Serializable { + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ + /** + * internal content storage + */ + private java.lang.String _content = ""; - /** - * internal content storage - */ - private java.lang.String _content = ""; + /** + * Field _name. + */ + private java.lang.String _name; - /** - * Field _name. - */ - private java.lang.String _name; + /** + * The type specifies how the property will be parsed. Empty property strings + * are allowed, and can be used to prototype the input to a document. TODO: + * specify allowed types + */ + private java.lang.String _type; - /** - * The type specifies how the property will be parsed. - * Empty property strings are allowed, and can be used to - * prototype the - * input to a document. TODO: specify allowed types - */ - private java.lang.String _type; + // ----------------/ + // - Constructors -/ + // ----------------/ + public Property() { + super(); + setContent(""); + } - //----------------/ - //- Constructors -/ - //----------------/ + // -----------/ + // - Methods -/ + // -----------/ - public Property() { - super(); - setContent(""); - } + /** + * Overrides the java.lang.Object.equals method. + * + * @param obj + * @return true if the objects are equal. + */ + public boolean equals(final java.lang.Object obj) { + if (this == obj) + return true; + if (super.equals(obj) == false) + return false; - //-----------/ - //- Methods -/ - //-----------/ + if (obj instanceof Property) { - /** - * Overrides the java.lang.Object.equals method. - * - * @param obj - * @return true if the objects are equal. - */ - public boolean equals( - final java.lang.Object obj) { - if ( this == obj ) - return true; - - if (super.equals(obj)==false) + Property temp = (Property) obj; + boolean thcycle; + boolean tmcycle; + if (this._content != null) { + if (temp._content == null) + return false; + if (this._content != temp._content) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._content); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._content); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._content); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._content); + } + ; + return false; + } + if (!thcycle) { + if (!this._content.equals(temp._content)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._content); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._content); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._content); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._content); + } + } + } else if (temp._content != null) + return false; + if (this._name != null) { + if (temp._name == null) + return false; + if (this._name != temp._name) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._name); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._name); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._name); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._name); + } + ; + return false; + } + if (!thcycle) { + if (!this._name.equals(temp._name)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._name); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._name); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._name); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._name); + } + } + } else if (temp._name != null) + return false; + if (this._type != null) { + if (temp._type == null) + return false; + if (this._type != temp._type) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._type); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._type); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._type); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._type); + } + ; return false; - - if (obj instanceof Property) { - - Property temp = (Property)obj; - boolean thcycle; - boolean tmcycle; - if (this._content != null) { - if (temp._content == null) return false; - if (this._content != temp._content) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._content); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._content); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._content); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._content); }; - return false; - } - if (!thcycle) { - if (!this._content.equals(temp._content)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._content); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._content); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._content); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._content); - } - } - } else if (temp._content != null) - return false; - if (this._name != null) { - if (temp._name == null) return false; - if (this._name != temp._name) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._name); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._name); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._name); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._name); }; - return false; - } - if (!thcycle) { - if (!this._name.equals(temp._name)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._name); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._name); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._name); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._name); - } - } - } else if (temp._name != null) - return false; - if (this._type != null) { - if (temp._type == null) return false; - if (this._type != temp._type) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._type); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._type); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._type); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._type); }; - return false; - } - if (!thcycle) { - if (!this._type.equals(temp._type)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._type); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._type); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._type); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._type); - } - } - } else if (temp._type != null) - return false; - return true; + } + if (!thcycle) { + if (!this._type.equals(temp._type)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._type); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._type); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._type); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._type); + } } + } else if (temp._type != null) return false; + return true; } + return false; + } - /** - * Returns the value of field 'content'. The field 'content' - * has the following description: internal content storage - * - * @return the value of field 'Content'. - */ - public java.lang.String getContent( - ) { - return this._content; - } + /** + * Returns the value of field 'content'. The field 'content' has the following + * description: internal content storage + * + * @return the value of field 'Content'. + */ + public java.lang.String getContent() { + return this._content; + } - /** - * Returns the value of field 'name'. - * - * @return the value of field 'Name'. - */ - public java.lang.String getName( - ) { - return this._name; - } + /** + * Returns the value of field 'name'. + * + * @return the value of field 'Name'. + */ + public java.lang.String getName() { + return this._name; + } - /** - * Returns the value of field 'type'. The field 'type' has the - * following description: The type specifies how the property - * will be parsed. - * Empty property strings are allowed, and can be used to - * prototype the - * input to a document. TODO: specify allowed types - * - * @return the value of field 'Type'. - */ - public java.lang.String getType( - ) { - return this._type; - } + /** + * Returns the value of field 'type'. The field 'type' has the following + * description: The type specifies how the property will be parsed. Empty + * property strings are allowed, and can be used to prototype the input to a + * document. TODO: specify allowed types + * + * @return the value of field 'Type'. + */ + public java.lang.String getType() { + return this._type; + } - /** - * Overrides the java.lang.Object.hashCode method. - *

- * The following steps came from Effective Java Programming - * Language Guide by Joshua Bloch, Chapter 3 - * - * @return a hash code value for the object. - */ - public int hashCode( - ) { - int result = super.hashCode(); - - long tmp; - if (_content != null - && !org.castor.util.CycleBreaker.startingToCycle(_content)) { - result = 37 * result + _content.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_content); - } - if (_name != null - && !org.castor.util.CycleBreaker.startingToCycle(_name)) { - result = 37 * result + _name.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_name); - } - if (_type != null - && !org.castor.util.CycleBreaker.startingToCycle(_type)) { - result = 37 * result + _type.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_type); - } - - return result; - } + /** + * Overrides the java.lang.Object.hashCode method. + *

+ * The following steps came from Effective Java Programming Language + * Guide by Joshua Bloch, Chapter 3 + * + * @return a hash code value for the object. + */ + public int hashCode() { + int result = super.hashCode(); - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { - return false; - } - return true; + long tmp; + if (_content != null + && !org.castor.util.CycleBreaker.startingToCycle(_content)) { + result = 37 * result + _content.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_content); } - - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); + if (_name != null && !org.castor.util.CycleBreaker.startingToCycle(_name)) { + result = 37 * result + _name.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_name); } - - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); + if (_type != null && !org.castor.util.CycleBreaker.startingToCycle(_type)) { + result = 37 * result + _type.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_type); } - /** - * Sets the value of field 'content'. The field 'content' has - * the following description: internal content storage - * - * @param content the value of field 'content'. - */ - public void setContent( - final java.lang.String content) { - this._content = content; - } + return result; + } - /** - * Sets the value of field 'name'. - * - * @param name the value of field 'name'. - */ - public void setName( - final java.lang.String name) { - this._name = name; + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() { + try { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) { + return false; } + return true; + } - /** - * Sets the value of field 'type'. The field 'type' has the - * following description: The type specifies how the property - * will be parsed. - * Empty property strings are allowed, and can be used to - * prototype the - * input to a document. TODO: specify allowed types - * - * @param type the value of field 'type'. - */ - public void setType( - final java.lang.String type) { - this._type = type; - } + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, out); + } - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled uk.ac.vamsas.objects.core.Property - */ - public static uk.ac.vamsas.objects.core.Property unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (uk.ac.vamsas.objects.core.Property) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.Property.class, reader); - } + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, handler); + } - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); - } + /** + * Sets the value of field 'content'. The field 'content' has the following + * description: internal content storage + * + * @param content + * the value of field 'content'. + */ + public void setContent(final java.lang.String content) { + this._content = content; + } + + /** + * Sets the value of field 'name'. + * + * @param name + * the value of field 'name'. + */ + public void setName(final java.lang.String name) { + this._name = name; + } + + /** + * Sets the value of field 'type'. The field 'type' has the following + * description: The type specifies how the property will be parsed. Empty + * property strings are allowed, and can be used to prototype the input to a + * document. TODO: specify allowed types + * + * @param type + * the value of field 'type'. + */ + public void setType(final java.lang.String type) { + this._type = type; + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @return the unmarshaled uk.ac.vamsas.objects.core.Property + */ + public static uk.ac.vamsas.objects.core.Property unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + return (uk.ac.vamsas.objects.core.Property) Unmarshaller.unmarshal( + uk.ac.vamsas.objects.core.Property.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/uk/ac/vamsas/objects/core/Provenance.java b/src/uk/ac/vamsas/objects/core/Provenance.java index 12dc17b..54b5ae1 100644 --- a/src/uk/ac/vamsas/objects/core/Provenance.java +++ b/src/uk/ac/vamsas/objects/core/Provenance.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import org.exolab.castor.xml.Marshaller; @@ -17,367 +31,361 @@ import org.exolab.castor.xml.Unmarshaller; /** * Class Provenance. * - * @version $Revision$ $Date$ + * @version $Revision$ $Date: 2007-06-28 14:51:44 +0100 (Thu, 28 Jun 2007) + * $ */ -public class Provenance extends uk.ac.vamsas.client.Vobject -implements java.io.Serializable -{ - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _entryList. - */ - private java.util.Vector _entryList; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public Provenance() { - super(); - this._entryList = new java.util.Vector(); - } - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * - * - * @param vEntry - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addEntry( - final uk.ac.vamsas.objects.core.Entry vEntry) - throws java.lang.IndexOutOfBoundsException { - this._entryList.addElement(vEntry); - } - - /** - * - * - * @param index - * @param vEntry - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addEntry( - final int index, - final uk.ac.vamsas.objects.core.Entry vEntry) - throws java.lang.IndexOutOfBoundsException { - this._entryList.add(index, vEntry); - } - - /** - * Method enumerateEntry. - * - * @return an Enumeration over all - * uk.ac.vamsas.objects.core.Entry elements - */ - public java.util.Enumeration enumerateEntry( - ) { - return this._entryList.elements(); - } - - /** - * Overrides the java.lang.Object.equals method. - * - * @param obj - * @return true if the objects are equal. - */ - public boolean equals( - final java.lang.Object obj) { - if ( this == obj ) - return true; - - if (super.equals(obj)==false) +public class Provenance extends uk.ac.vamsas.client.Vobject implements + java.io.Serializable { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _entryList. + */ + private java.util.Vector _entryList; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public Provenance() { + super(); + this._entryList = new java.util.Vector(); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * + * + * @param vEntry + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addEntry(final uk.ac.vamsas.objects.core.Entry vEntry) + throws java.lang.IndexOutOfBoundsException { + this._entryList.addElement(vEntry); + } + + /** + * + * + * @param index + * @param vEntry + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addEntry(final int index, + final uk.ac.vamsas.objects.core.Entry vEntry) + throws java.lang.IndexOutOfBoundsException { + this._entryList.add(index, vEntry); + } + + /** + * Method enumerateEntry. + * + * @return an Enumeration over all uk.ac.vamsas.objects.core.Entry elements + */ + public java.util.Enumeration enumerateEntry() { + return this._entryList.elements(); + } + + /** + * Overrides the java.lang.Object.equals method. + * + * @param obj + * @return true if the objects are equal. + */ + public boolean equals(final java.lang.Object obj) { + if (this == obj) + return true; + + if (super.equals(obj) == false) + return false; + + if (obj instanceof Provenance) { + + Provenance temp = (Provenance) obj; + boolean thcycle; + boolean tmcycle; + if (this._entryList != null) { + if (temp._entryList == null) + return false; + if (this._entryList != temp._entryList) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._entryList); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._entryList); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._entryList); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._entryList); + } + ; return false; - - if (obj instanceof Provenance) { - - Provenance temp = (Provenance)obj; - boolean thcycle; - boolean tmcycle; - if (this._entryList != null) { - if (temp._entryList == null) return false; - if (this._entryList != temp._entryList) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._entryList); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._entryList); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._entryList); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._entryList); }; - return false; - } - if (!thcycle) { - if (!this._entryList.equals(temp._entryList)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._entryList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._entryList); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._entryList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._entryList); - } - } - } else if (temp._entryList != null) - return false; - return true; + } + if (!thcycle) { + if (!this._entryList.equals(temp._entryList)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._entryList); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._entryList); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._entryList); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._entryList); + } } + } else if (temp._entryList != null) return false; + return true; } - - /** - * Method getEntry. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the uk.ac.vamsas.objects.core.Entry at - * the given index - */ - public uk.ac.vamsas.objects.core.Entry getEntry( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._entryList.size()) { - throw new IndexOutOfBoundsException("getEntry: Index value '" + index + "' not in range [0.." + (this._entryList.size() - 1) + "]"); - } - - return (uk.ac.vamsas.objects.core.Entry) _entryList.get(index); - } - - /** - * Method getEntry.Returns the contents of the collection in an - * Array.

Note: Just in case the collection contents are - * changing in another thread, we pass a 0-length Array of the - * correct type into the API call. This way we know - * that the Array returned is of exactly the correct length. - * - * @return this collection as an Array - */ - public uk.ac.vamsas.objects.core.Entry[] getEntry( - ) { - uk.ac.vamsas.objects.core.Entry[] array = new uk.ac.vamsas.objects.core.Entry[0]; - return (uk.ac.vamsas.objects.core.Entry[]) this._entryList.toArray(array); - } - - /** - * Method getEntryAsReference.Returns a reference to - * '_entryList'. No type checking is performed on any - * modifications to the Vector. - * - * @return a reference to the Vector backing this class - */ - public java.util.Vector getEntryAsReference( - ) { - return this._entryList; - } - - /** - * Method getEntryCount. - * - * @return the size of this collection - */ - public int getEntryCount( - ) { - return this._entryList.size(); - } - - /** - * Overrides the java.lang.Object.hashCode method. - *

- * The following steps came from Effective Java Programming - * Language Guide by Joshua Bloch, Chapter 3 - * - * @return a hash code value for the object. - */ - public int hashCode( - ) { - int result = super.hashCode(); - - long tmp; - if (_entryList != null - && !org.castor.util.CycleBreaker.startingToCycle(_entryList)) { - result = 37 * result + _entryList.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_entryList); - } - - return result; - } - - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { - return false; - } - return true; - } - - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } - - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } - - /** - */ - public void removeAllEntry( - ) { - this._entryList.clear(); - } - - /** - * Method removeEntry. - * - * @param vEntry - * @return true if the object was removed from the collection. - */ - public boolean removeEntry( - final uk.ac.vamsas.objects.core.Entry vEntry) { - boolean removed = _entryList.remove(vEntry); - return removed; + return false; + } + + /** + * Method getEntry. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the uk.ac.vamsas.objects.core.Entry at the given index + */ + public uk.ac.vamsas.objects.core.Entry getEntry(final int index) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._entryList.size()) { + throw new IndexOutOfBoundsException("getEntry: Index value '" + index + + "' not in range [0.." + (this._entryList.size() - 1) + "]"); } - /** - * Method removeEntryAt. - * - * @param index - * @return the element removed from the collection - */ - public uk.ac.vamsas.objects.core.Entry removeEntryAt( - final int index) { - java.lang.Object obj = this._entryList.remove(index); - return (uk.ac.vamsas.objects.core.Entry) obj; - } - - /** - * - * - * @param index - * @param vEntry - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setEntry( - final int index, - final uk.ac.vamsas.objects.core.Entry vEntry) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._entryList.size()) { - throw new IndexOutOfBoundsException("setEntry: Index value '" + index + "' not in range [0.." + (this._entryList.size() - 1) + "]"); - } - - this._entryList.set(index, vEntry); + return (uk.ac.vamsas.objects.core.Entry) _entryList.get(index); + } + + /** + * Method getEntry.Returns the contents of the collection in an Array. + *

+ * Note: Just in case the collection contents are changing in another thread, + * we pass a 0-length Array of the correct type into the API call. This way we + * know that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public uk.ac.vamsas.objects.core.Entry[] getEntry() { + uk.ac.vamsas.objects.core.Entry[] array = new uk.ac.vamsas.objects.core.Entry[0]; + return (uk.ac.vamsas.objects.core.Entry[]) this._entryList.toArray(array); + } + + /** + * Method getEntryAsReference.Returns a reference to '_entryList'. No type + * checking is performed on any modifications to the Vector. + * + * @return a reference to the Vector backing this class + */ + public java.util.Vector getEntryAsReference() { + return this._entryList; + } + + /** + * Method getEntryCount. + * + * @return the size of this collection + */ + public int getEntryCount() { + return this._entryList.size(); + } + + /** + * Overrides the java.lang.Object.hashCode method. + *

+ * The following steps came from Effective Java Programming Language + * Guide by Joshua Bloch, Chapter 3 + * + * @return a hash code value for the object. + */ + public int hashCode() { + int result = super.hashCode(); + + long tmp; + if (_entryList != null + && !org.castor.util.CycleBreaker.startingToCycle(_entryList)) { + result = 37 * result + _entryList.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_entryList); } - /** - * - * - * @param vEntryArray - */ - public void setEntry( - final uk.ac.vamsas.objects.core.Entry[] vEntryArray) { - //-- copy array - _entryList.clear(); - - for (int i = 0; i < vEntryArray.length; i++) { - this._entryList.add(vEntryArray[i]); - } + return result; + } + + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() { + try { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) { + return false; } - - /** - * Sets the value of '_entryList' by copying the given Vector. - * All elements will be checked for type safety. - * - * @param vEntryList the Vector to copy. + return true; + } + + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, out); + } + + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, handler); + } + + /** */ - public void setEntry( - final java.util.Vector vEntryList) { - // copy vector - this._entryList.clear(); - - this._entryList.addAll(vEntryList); + public void removeAllEntry() { + this._entryList.clear(); + } + + /** + * Method removeEntry. + * + * @param vEntry + * @return true if the object was removed from the collection. + */ + public boolean removeEntry(final uk.ac.vamsas.objects.core.Entry vEntry) { + boolean removed = _entryList.remove(vEntry); + return removed; + } + + /** + * Method removeEntryAt. + * + * @param index + * @return the element removed from the collection + */ + public uk.ac.vamsas.objects.core.Entry removeEntryAt(final int index) { + java.lang.Object obj = this._entryList.remove(index); + return (uk.ac.vamsas.objects.core.Entry) obj; + } + + /** + * + * + * @param index + * @param vEntry + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setEntry(final int index, + final uk.ac.vamsas.objects.core.Entry vEntry) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._entryList.size()) { + throw new IndexOutOfBoundsException("setEntry: Index value '" + index + + "' not in range [0.." + (this._entryList.size() - 1) + "]"); } - /** - * Sets the value of '_entryList' by setting it to the given - * Vector. No type checking is performed. - * @deprecated - * - * @param entryVector the Vector to set. - */ - public void setEntryAsReference( - final java.util.Vector entryVector) { - this._entryList = entryVector; - } + this._entryList.set(index, vEntry); + } - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled uk.ac.vamsas.objects.core.Provenance - */ - public static uk.ac.vamsas.objects.core.Provenance unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (uk.ac.vamsas.objects.core.Provenance) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.Provenance.class, reader); - } + /** + * + * + * @param vEntryArray + */ + public void setEntry(final uk.ac.vamsas.objects.core.Entry[] vEntryArray) { + // -- copy array + _entryList.clear(); - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); + for (int i = 0; i < vEntryArray.length; i++) { + this._entryList.add(vEntryArray[i]); } + } + + /** + * Sets the value of '_entryList' by copying the given Vector. All elements + * will be checked for type safety. + * + * @param vEntryList + * the Vector to copy. + */ + public void setEntry(final java.util.Vector vEntryList) { + // copy vector + this._entryList.clear(); + + this._entryList.addAll(vEntryList); + } + + /** + * Sets the value of '_entryList' by setting it to the given Vector. No type + * checking is performed. + * + * @deprecated + * + * @param entryVector + * the Vector to set. + */ + public void setEntryAsReference(final java.util.Vector entryVector) { + this._entryList = entryVector; + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @return the unmarshaled uk.ac.vamsas.objects.core.Provenance + */ + public static uk.ac.vamsas.objects.core.Provenance unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + return (uk.ac.vamsas.objects.core.Provenance) Unmarshaller.unmarshal( + uk.ac.vamsas.objects.core.Provenance.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/uk/ac/vamsas/objects/core/Range.java b/src/uk/ac/vamsas/objects/core/Range.java index 11d84d3..7889a17 100644 --- a/src/uk/ac/vamsas/objects/core/Range.java +++ b/src/uk/ac/vamsas/objects/core/Range.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import org.exolab.castor.xml.Marshaller; @@ -19,354 +33,338 @@ import org.exolab.castor.xml.Unmarshaller; * * @version $Revision$ $Date$ */ -public class Range extends uk.ac.vamsas.client.Vobject -implements java.io.Serializable -{ - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _seqAStart. - */ - private int _seqAStart; - - /** - * keeps track of state for field: _seqAStart - */ - private boolean _has_seqAStart; - - /** - * Field _seqAEnd. - */ - private int _seqAEnd; - - /** - * keeps track of state for field: _seqAEnd - */ - private boolean _has_seqAEnd; - - /** - * Field _seqBStart. - */ - private int _seqBStart; - - /** - * keeps track of state for field: _seqBStart - */ - private boolean _has_seqBStart; - - /** - * Field _seqBEnd. - */ - private int _seqBEnd; - - /** - * keeps track of state for field: _seqBEnd - */ - private boolean _has_seqBEnd; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public Range() { - super(); - } - - - //-----------/ - //- Methods -/ - //-----------/ - - /** +public class Range extends uk.ac.vamsas.client.Vobject implements + java.io.Serializable { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _seqAStart. + */ + private int _seqAStart; + + /** + * keeps track of state for field: _seqAStart + */ + private boolean _has_seqAStart; + + /** + * Field _seqAEnd. + */ + private int _seqAEnd; + + /** + * keeps track of state for field: _seqAEnd + */ + private boolean _has_seqAEnd; + + /** + * Field _seqBStart. + */ + private int _seqBStart; + + /** + * keeps track of state for field: _seqBStart + */ + private boolean _has_seqBStart; + + /** + * Field _seqBEnd. + */ + private int _seqBEnd; + + /** + * keeps track of state for field: _seqBEnd + */ + private boolean _has_seqBEnd; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public Range() { + super(); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** */ - public void deleteSeqAEnd( - ) { - this._has_seqAEnd= false; - } - - /** - */ - public void deleteSeqAStart( - ) { - this._has_seqAStart= false; - } + public void deleteSeqAEnd() { + this._has_seqAEnd = false; + } - /** + /** */ - public void deleteSeqBEnd( - ) { - this._has_seqBEnd= false; - } + public void deleteSeqAStart() { + this._has_seqAStart = false; + } - /** + /** */ - public void deleteSeqBStart( - ) { - this._has_seqBStart= false; - } + public void deleteSeqBEnd() { + this._has_seqBEnd = false; + } - /** - * Overrides the java.lang.Object.equals method. - * - * @param obj - * @return true if the objects are equal. + /** */ - public boolean equals( - final java.lang.Object obj) { - if ( this == obj ) - return true; - - if (super.equals(obj)==false) - return false; - - if (obj instanceof Range) { - - Range temp = (Range)obj; - if (this._seqAStart != temp._seqAStart) - return false; - if (this._has_seqAStart != temp._has_seqAStart) - return false; - if (this._seqAEnd != temp._seqAEnd) - return false; - if (this._has_seqAEnd != temp._has_seqAEnd) - return false; - if (this._seqBStart != temp._seqBStart) - return false; - if (this._has_seqBStart != temp._has_seqBStart) - return false; - if (this._seqBEnd != temp._seqBEnd) - return false; - if (this._has_seqBEnd != temp._has_seqBEnd) - return false; - return true; - } + public void deleteSeqBStart() { + this._has_seqBStart = false; + } + + /** + * Overrides the java.lang.Object.equals method. + * + * @param obj + * @return true if the objects are equal. + */ + public boolean equals(final java.lang.Object obj) { + if (this == obj) + return true; + + if (super.equals(obj) == false) + return false; + + if (obj instanceof Range) { + + Range temp = (Range) obj; + if (this._seqAStart != temp._seqAStart) return false; + if (this._has_seqAStart != temp._has_seqAStart) + return false; + if (this._seqAEnd != temp._seqAEnd) + return false; + if (this._has_seqAEnd != temp._has_seqAEnd) + return false; + if (this._seqBStart != temp._seqBStart) + return false; + if (this._has_seqBStart != temp._has_seqBStart) + return false; + if (this._seqBEnd != temp._seqBEnd) + return false; + if (this._has_seqBEnd != temp._has_seqBEnd) + return false; + return true; } - - /** - * Returns the value of field 'seqAEnd'. - * - * @return the value of field 'SeqAEnd'. - */ - public int getSeqAEnd( - ) { - return this._seqAEnd; - } - - /** - * Returns the value of field 'seqAStart'. - * - * @return the value of field 'SeqAStart'. - */ - public int getSeqAStart( - ) { - return this._seqAStart; - } - - /** - * Returns the value of field 'seqBEnd'. - * - * @return the value of field 'SeqBEnd'. - */ - public int getSeqBEnd( - ) { - return this._seqBEnd; - } - - /** - * Returns the value of field 'seqBStart'. - * - * @return the value of field 'SeqBStart'. - */ - public int getSeqBStart( - ) { - return this._seqBStart; - } - - /** - * Method hasSeqAEnd. - * - * @return true if at least one SeqAEnd has been added - */ - public boolean hasSeqAEnd( - ) { - return this._has_seqAEnd; - } - - /** - * Method hasSeqAStart. - * - * @return true if at least one SeqAStart has been added - */ - public boolean hasSeqAStart( - ) { - return this._has_seqAStart; - } - - /** - * Method hasSeqBEnd. - * - * @return true if at least one SeqBEnd has been added - */ - public boolean hasSeqBEnd( - ) { - return this._has_seqBEnd; - } - - /** - * Method hasSeqBStart. - * - * @return true if at least one SeqBStart has been added - */ - public boolean hasSeqBStart( - ) { - return this._has_seqBStart; - } - - /** - * Overrides the java.lang.Object.hashCode method. - *

- * The following steps came from Effective Java Programming - * Language Guide by Joshua Bloch, Chapter 3 - * - * @return a hash code value for the object. - */ - public int hashCode( - ) { - int result = super.hashCode(); - - long tmp; - result = 37 * result + _seqAStart; - result = 37 * result + _seqAEnd; - result = 37 * result + _seqBStart; - result = 37 * result + _seqBEnd; - - return result; - } - - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { - return false; - } - return true; - } - - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } - - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } - - /** - * Sets the value of field 'seqAEnd'. - * - * @param seqAEnd the value of field 'seqAEnd'. - */ - public void setSeqAEnd( - final int seqAEnd) { - this._seqAEnd = seqAEnd; - this._has_seqAEnd = true; - } - - /** - * Sets the value of field 'seqAStart'. - * - * @param seqAStart the value of field 'seqAStart'. - */ - public void setSeqAStart( - final int seqAStart) { - this._seqAStart = seqAStart; - this._has_seqAStart = true; - } - - /** - * Sets the value of field 'seqBEnd'. - * - * @param seqBEnd the value of field 'seqBEnd'. - */ - public void setSeqBEnd( - final int seqBEnd) { - this._seqBEnd = seqBEnd; - this._has_seqBEnd = true; - } - - /** - * Sets the value of field 'seqBStart'. - * - * @param seqBStart the value of field 'seqBStart'. - */ - public void setSeqBStart( - final int seqBStart) { - this._seqBStart = seqBStart; - this._has_seqBStart = true; - } - - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled uk.ac.vamsas.objects.core.Range - */ - public static uk.ac.vamsas.objects.core.Range unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (uk.ac.vamsas.objects.core.Range) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.Range.class, reader); - } - - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); + return false; + } + + /** + * Returns the value of field 'seqAEnd'. + * + * @return the value of field 'SeqAEnd'. + */ + public int getSeqAEnd() { + return this._seqAEnd; + } + + /** + * Returns the value of field 'seqAStart'. + * + * @return the value of field 'SeqAStart'. + */ + public int getSeqAStart() { + return this._seqAStart; + } + + /** + * Returns the value of field 'seqBEnd'. + * + * @return the value of field 'SeqBEnd'. + */ + public int getSeqBEnd() { + return this._seqBEnd; + } + + /** + * Returns the value of field 'seqBStart'. + * + * @return the value of field 'SeqBStart'. + */ + public int getSeqBStart() { + return this._seqBStart; + } + + /** + * Method hasSeqAEnd. + * + * @return true if at least one SeqAEnd has been added + */ + public boolean hasSeqAEnd() { + return this._has_seqAEnd; + } + + /** + * Method hasSeqAStart. + * + * @return true if at least one SeqAStart has been added + */ + public boolean hasSeqAStart() { + return this._has_seqAStart; + } + + /** + * Method hasSeqBEnd. + * + * @return true if at least one SeqBEnd has been added + */ + public boolean hasSeqBEnd() { + return this._has_seqBEnd; + } + + /** + * Method hasSeqBStart. + * + * @return true if at least one SeqBStart has been added + */ + public boolean hasSeqBStart() { + return this._has_seqBStart; + } + + /** + * Overrides the java.lang.Object.hashCode method. + *

+ * The following steps came from Effective Java Programming Language + * Guide by Joshua Bloch, Chapter 3 + * + * @return a hash code value for the object. + */ + public int hashCode() { + int result = super.hashCode(); + + long tmp; + result = 37 * result + _seqAStart; + result = 37 * result + _seqAEnd; + result = 37 * result + _seqBStart; + result = 37 * result + _seqBEnd; + + return result; + } + + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() { + try { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) { + return false; } + return true; + } + + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, out); + } + + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, handler); + } + + /** + * Sets the value of field 'seqAEnd'. + * + * @param seqAEnd + * the value of field 'seqAEnd'. + */ + public void setSeqAEnd(final int seqAEnd) { + this._seqAEnd = seqAEnd; + this._has_seqAEnd = true; + } + + /** + * Sets the value of field 'seqAStart'. + * + * @param seqAStart + * the value of field 'seqAStart'. + */ + public void setSeqAStart(final int seqAStart) { + this._seqAStart = seqAStart; + this._has_seqAStart = true; + } + + /** + * Sets the value of field 'seqBEnd'. + * + * @param seqBEnd + * the value of field 'seqBEnd'. + */ + public void setSeqBEnd(final int seqBEnd) { + this._seqBEnd = seqBEnd; + this._has_seqBEnd = true; + } + + /** + * Sets the value of field 'seqBStart'. + * + * @param seqBStart + * the value of field 'seqBStart'. + */ + public void setSeqBStart(final int seqBStart) { + this._seqBStart = seqBStart; + this._has_seqBStart = true; + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @return the unmarshaled uk.ac.vamsas.objects.core.Range + */ + public static uk.ac.vamsas.objects.core.Range unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + return (uk.ac.vamsas.objects.core.Range) Unmarshaller.unmarshal( + uk.ac.vamsas.objects.core.Range.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/uk/ac/vamsas/objects/core/RangeAnnotation.java b/src/uk/ac/vamsas/objects/core/RangeAnnotation.java index 2a2adda..07c3d41 100644 --- a/src/uk/ac/vamsas/objects/core/RangeAnnotation.java +++ b/src/uk/ac/vamsas/objects/core/RangeAnnotation.java @@ -1,1493 +1,1528 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import org.exolab.castor.xml.Marshaller; import org.exolab.castor.xml.Unmarshaller; /** - * Annotation for a rangeSpec - values can be attached for the - * whole - * specification, and to each position within the spec. following - * the orientation - * specified by the ordered set of rangeSpec (pos, seg) elements. + * Annotation for a rangeSpec - values can be attached for the whole + * specification, and to each position within the spec. following the + * orientation specified by the ordered set of rangeSpec (pos, seg) elements. * * @version $Revision$ $Date$ */ -public class RangeAnnotation extends uk.ac.vamsas.objects.core.RangeType -implements java.io.Serializable -{ - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Primary Key for vamsas object referencing - * - */ - private java.lang.String _id; - - /** - * Field _modifiable. - */ - private java.lang.String _modifiable; - - /** - * Annotation with the same non-empty group name are grouped - * together - */ - private java.lang.String _group = ""; - - /** - * A Das Feature has both a type and a Type ID. We go the - * route of requiring the type string to be taken from a - * controlled - * vocabulary if an application expects others to make sense - * of it. The - * type may qualified - so uniprot:CHAIN is a valid type name, - * and - * considered distinct from someotherDB:CHAIN - */ - private java.lang.String _type; - - /** - * Short, meaningful name for the annotation - if this - * is absent, then the type string should be used in its - * place. - * - */ - private java.lang.String _label; - - /** - * Human readable description of the annotation - * - */ - private java.lang.String _description; - - /** - * TODO: specify this - we have considered taking the GO - * evidence codes as a model for assessing a measure of - * quality to an - * annotation. - */ - private java.lang.String _status; - - /** - * Annotation Element position maps to ordered positions - * defined by the sequence of rangeType pos positions or - * concatenated - * seg start/end segments. - */ - private java.util.Vector _annotationElementList; - - /** - * Ordered set of optionally named float values for the - * whole annotation - */ - private java.util.Vector _scoreList; - - /** - * Field _linkList. - */ - private java.util.Vector _linkList; - - /** - * Note:These are mutable so an application should check - * them each time. - */ - private java.util.Vector _propertyList; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public RangeAnnotation() { - super(); - setGroup(""); - this._annotationElementList = new java.util.Vector(); - this._scoreList = new java.util.Vector(); - this._linkList = new java.util.Vector(); - this._propertyList = new java.util.Vector(); - } - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * - * - * @param vAnnotationElement - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addAnnotationElement( - final uk.ac.vamsas.objects.core.AnnotationElement vAnnotationElement) - throws java.lang.IndexOutOfBoundsException { - this._annotationElementList.addElement(vAnnotationElement); - } - - /** - * - * - * @param index - * @param vAnnotationElement - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addAnnotationElement( - final int index, - final uk.ac.vamsas.objects.core.AnnotationElement vAnnotationElement) - throws java.lang.IndexOutOfBoundsException { - this._annotationElementList.add(index, vAnnotationElement); - } - - /** - * - * - * @param vLink - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addLink( - final uk.ac.vamsas.objects.core.Link vLink) - throws java.lang.IndexOutOfBoundsException { - this._linkList.addElement(vLink); - } - - /** - * - * - * @param index - * @param vLink - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addLink( - final int index, - final uk.ac.vamsas.objects.core.Link vLink) - throws java.lang.IndexOutOfBoundsException { - this._linkList.add(index, vLink); - } - - /** - * - * - * @param vProperty - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addProperty( - final uk.ac.vamsas.objects.core.Property vProperty) - throws java.lang.IndexOutOfBoundsException { - this._propertyList.addElement(vProperty); - } - - /** - * - * - * @param index - * @param vProperty - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addProperty( - final int index, - final uk.ac.vamsas.objects.core.Property vProperty) - throws java.lang.IndexOutOfBoundsException { - this._propertyList.add(index, vProperty); - } - - /** - * - * - * @param vScore - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addScore( - final uk.ac.vamsas.objects.core.Score vScore) - throws java.lang.IndexOutOfBoundsException { - this._scoreList.addElement(vScore); - } - - /** - * - * - * @param index - * @param vScore - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addScore( - final int index, - final uk.ac.vamsas.objects.core.Score vScore) - throws java.lang.IndexOutOfBoundsException { - this._scoreList.add(index, vScore); - } - - /** - * Method enumerateAnnotationElement. - * - * @return an Enumeration over all - * uk.ac.vamsas.objects.core.AnnotationElement elements - */ - public java.util.Enumeration enumerateAnnotationElement( - ) { - return this._annotationElementList.elements(); - } - - /** - * Method enumerateLink. - * - * @return an Enumeration over all - * uk.ac.vamsas.objects.core.Link elements - */ - public java.util.Enumeration enumerateLink( - ) { - return this._linkList.elements(); - } - - /** - * Method enumerateProperty. - * - * @return an Enumeration over all - * uk.ac.vamsas.objects.core.Property elements - */ - public java.util.Enumeration enumerateProperty( - ) { - return this._propertyList.elements(); - } - - /** - * Method enumerateScore. - * - * @return an Enumeration over all - * uk.ac.vamsas.objects.core.Score elements - */ - public java.util.Enumeration enumerateScore( - ) { - return this._scoreList.elements(); - } - - /** - * Overrides the java.lang.Object.equals method. - * - * @param obj - * @return true if the objects are equal. - */ - public boolean equals( - final java.lang.Object obj) { - if ( this == obj ) - return true; - - if (super.equals(obj)==false) +public class RangeAnnotation extends uk.ac.vamsas.objects.core.RangeType + implements java.io.Serializable { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Primary Key for vamsas object referencing + * + */ + private java.lang.String _id; + + /** + * Field _modifiable. + */ + private java.lang.String _modifiable; + + /** + * Annotation with the same non-empty group name are grouped together + */ + private java.lang.String _group = ""; + + /** + * A Das Feature has both a type and a Type ID. We go the route of requiring + * the type string to be taken from a controlled vocabulary if an application + * expects others to make sense of it. The type may qualified - so + * uniprot:CHAIN is a valid type name, and considered distinct from + * someotherDB:CHAIN + */ + private java.lang.String _type; + + /** + * Short, meaningful name for the annotation - if this is absent, then the + * type string should be used in its place. + * + */ + private java.lang.String _label; + + /** + * Human readable description of the annotation + * + */ + private java.lang.String _description; + + /** + * TODO: specify this - we have considered taking the GO evidence codes as a + * model for assessing a measure of quality to an annotation. + */ + private java.lang.String _status; + + /** + * Annotation Element position maps to ordered positions defined by the + * sequence of rangeType pos positions or concatenated seg start/end segments. + */ + private java.util.Vector _annotationElementList; + + /** + * Ordered set of optionally named float values for the whole annotation + */ + private java.util.Vector _scoreList; + + /** + * Field _linkList. + */ + private java.util.Vector _linkList; + + /** + * Note:These are mutable so an application should check them each time. + */ + private java.util.Vector _propertyList; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public RangeAnnotation() { + super(); + setGroup(""); + this._annotationElementList = new java.util.Vector(); + this._scoreList = new java.util.Vector(); + this._linkList = new java.util.Vector(); + this._propertyList = new java.util.Vector(); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * + * + * @param vAnnotationElement + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addAnnotationElement( + final uk.ac.vamsas.objects.core.AnnotationElement vAnnotationElement) + throws java.lang.IndexOutOfBoundsException { + this._annotationElementList.addElement(vAnnotationElement); + } + + /** + * + * + * @param index + * @param vAnnotationElement + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addAnnotationElement(final int index, + final uk.ac.vamsas.objects.core.AnnotationElement vAnnotationElement) + throws java.lang.IndexOutOfBoundsException { + this._annotationElementList.add(index, vAnnotationElement); + } + + /** + * + * + * @param vLink + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addLink(final uk.ac.vamsas.objects.core.Link vLink) + throws java.lang.IndexOutOfBoundsException { + this._linkList.addElement(vLink); + } + + /** + * + * + * @param index + * @param vLink + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addLink(final int index, + final uk.ac.vamsas.objects.core.Link vLink) + throws java.lang.IndexOutOfBoundsException { + this._linkList.add(index, vLink); + } + + /** + * + * + * @param vProperty + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addProperty(final uk.ac.vamsas.objects.core.Property vProperty) + throws java.lang.IndexOutOfBoundsException { + this._propertyList.addElement(vProperty); + } + + /** + * + * + * @param index + * @param vProperty + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addProperty(final int index, + final uk.ac.vamsas.objects.core.Property vProperty) + throws java.lang.IndexOutOfBoundsException { + this._propertyList.add(index, vProperty); + } + + /** + * + * + * @param vScore + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addScore(final uk.ac.vamsas.objects.core.Score vScore) + throws java.lang.IndexOutOfBoundsException { + this._scoreList.addElement(vScore); + } + + /** + * + * + * @param index + * @param vScore + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addScore(final int index, + final uk.ac.vamsas.objects.core.Score vScore) + throws java.lang.IndexOutOfBoundsException { + this._scoreList.add(index, vScore); + } + + /** + * Method enumerateAnnotationElement. + * + * @return an Enumeration over all uk.ac.vamsas.objects.core.AnnotationElement + * elements + */ + public java.util.Enumeration enumerateAnnotationElement() { + return this._annotationElementList.elements(); + } + + /** + * Method enumerateLink. + * + * @return an Enumeration over all uk.ac.vamsas.objects.core.Link elements + */ + public java.util.Enumeration enumerateLink() { + return this._linkList.elements(); + } + + /** + * Method enumerateProperty. + * + * @return an Enumeration over all uk.ac.vamsas.objects.core.Property elements + */ + public java.util.Enumeration enumerateProperty() { + return this._propertyList.elements(); + } + + /** + * Method enumerateScore. + * + * @return an Enumeration over all uk.ac.vamsas.objects.core.Score elements + */ + public java.util.Enumeration enumerateScore() { + return this._scoreList.elements(); + } + + /** + * Overrides the java.lang.Object.equals method. + * + * @param obj + * @return true if the objects are equal. + */ + public boolean equals(final java.lang.Object obj) { + if (this == obj) + return true; + + if (super.equals(obj) == false) + return false; + + if (obj instanceof RangeAnnotation) { + + RangeAnnotation temp = (RangeAnnotation) obj; + boolean thcycle; + boolean tmcycle; + if (this._id != null) { + if (temp._id == null) + return false; + if (this._id != temp._id) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._id); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._id); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._id); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); + } + ; return false; - - if (obj instanceof RangeAnnotation) { - - RangeAnnotation temp = (RangeAnnotation)obj; - boolean thcycle; - boolean tmcycle; - if (this._id != null) { - if (temp._id == null) return false; - if (this._id != temp._id) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._id); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._id); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._id); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); }; - return false; - } - if (!thcycle) { - if (!this._id.equals(temp._id)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._id); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._id); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); - } - } - } else if (temp._id != null) - return false; - if (this._modifiable != null) { - if (temp._modifiable == null) return false; - if (this._modifiable != temp._modifiable) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._modifiable); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._modifiable); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._modifiable); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._modifiable); }; - return false; - } - if (!thcycle) { - if (!this._modifiable.equals(temp._modifiable)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._modifiable); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._modifiable); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._modifiable); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._modifiable); - } - } - } else if (temp._modifiable != null) - return false; - if (this._group != null) { - if (temp._group == null) return false; - if (this._group != temp._group) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._group); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._group); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._group); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._group); }; - return false; - } - if (!thcycle) { - if (!this._group.equals(temp._group)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._group); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._group); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._group); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._group); - } - } - } else if (temp._group != null) - return false; - if (this._type != null) { - if (temp._type == null) return false; - if (this._type != temp._type) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._type); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._type); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._type); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._type); }; - return false; - } - if (!thcycle) { - if (!this._type.equals(temp._type)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._type); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._type); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._type); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._type); - } - } - } else if (temp._type != null) - return false; - if (this._label != null) { - if (temp._label == null) return false; - if (this._label != temp._label) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._label); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._label); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._label); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._label); }; - return false; - } - if (!thcycle) { - if (!this._label.equals(temp._label)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._label); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._label); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._label); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._label); - } - } - } else if (temp._label != null) - return false; - if (this._description != null) { - if (temp._description == null) return false; - if (this._description != temp._description) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._description); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._description); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._description); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._description); }; - return false; - } - if (!thcycle) { - if (!this._description.equals(temp._description)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._description); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._description); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._description); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._description); - } - } - } else if (temp._description != null) - return false; - if (this._status != null) { - if (temp._status == null) return false; - if (this._status != temp._status) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._status); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._status); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._status); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._status); }; - return false; - } - if (!thcycle) { - if (!this._status.equals(temp._status)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._status); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._status); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._status); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._status); - } - } - } else if (temp._status != null) - return false; - if (this._annotationElementList != null) { - if (temp._annotationElementList == null) return false; - if (this._annotationElementList != temp._annotationElementList) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._annotationElementList); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._annotationElementList); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._annotationElementList); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._annotationElementList); }; - return false; - } - if (!thcycle) { - if (!this._annotationElementList.equals(temp._annotationElementList)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._annotationElementList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._annotationElementList); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._annotationElementList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._annotationElementList); - } - } - } else if (temp._annotationElementList != null) - return false; - if (this._scoreList != null) { - if (temp._scoreList == null) return false; - if (this._scoreList != temp._scoreList) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._scoreList); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._scoreList); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._scoreList); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._scoreList); }; - return false; - } - if (!thcycle) { - if (!this._scoreList.equals(temp._scoreList)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._scoreList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._scoreList); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._scoreList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._scoreList); - } - } - } else if (temp._scoreList != null) - return false; - if (this._linkList != null) { - if (temp._linkList == null) return false; - if (this._linkList != temp._linkList) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._linkList); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._linkList); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._linkList); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._linkList); }; - return false; - } - if (!thcycle) { - if (!this._linkList.equals(temp._linkList)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._linkList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._linkList); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._linkList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._linkList); - } - } - } else if (temp._linkList != null) - return false; - if (this._propertyList != null) { - if (temp._propertyList == null) return false; - if (this._propertyList != temp._propertyList) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._propertyList); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._propertyList); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._propertyList); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._propertyList); }; - return false; - } - if (!thcycle) { - if (!this._propertyList.equals(temp._propertyList)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._propertyList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._propertyList); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._propertyList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._propertyList); - } - } - } else if (temp._propertyList != null) - return false; - return true; + } + if (!thcycle) { + if (!this._id.equals(temp._id)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._id); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._id); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); + } } + } else if (temp._id != null) return false; - } - - /** - * Method getAnnotationElement. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the - * uk.ac.vamsas.objects.core.AnnotationElement at the given inde - */ - public uk.ac.vamsas.objects.core.AnnotationElement getAnnotationElement( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._annotationElementList.size()) { - throw new IndexOutOfBoundsException("getAnnotationElement: Index value '" + index + "' not in range [0.." + (this._annotationElementList.size() - 1) + "]"); - } - - return (uk.ac.vamsas.objects.core.AnnotationElement) _annotationElementList.get(index); - } - - /** - * Method getAnnotationElement.Returns the contents of the - * collection in an Array.

Note: Just in case the - * collection contents are changing in another thread, we pass - * a 0-length Array of the correct type into the API call. - * This way we know that the Array returned is of - * exactly the correct length. - * - * @return this collection as an Array - */ - public uk.ac.vamsas.objects.core.AnnotationElement[] getAnnotationElement( - ) { - uk.ac.vamsas.objects.core.AnnotationElement[] array = new uk.ac.vamsas.objects.core.AnnotationElement[0]; - return (uk.ac.vamsas.objects.core.AnnotationElement[]) this._annotationElementList.toArray(array); - } - - /** - * Method getAnnotationElementAsReference.Returns a reference - * to '_annotationElementList'. No type checking is performed - * on any modifications to the Vector. - * - * @return a reference to the Vector backing this class - */ - public java.util.Vector getAnnotationElementAsReference( - ) { - return this._annotationElementList; - } - - /** - * Method getAnnotationElementCount. - * - * @return the size of this collection - */ - public int getAnnotationElementCount( - ) { - return this._annotationElementList.size(); - } - - /** - * Returns the value of field 'description'. The field - * 'description' has the following description: Human readable - * description of the annotation - * - * - * @return the value of field 'Description'. - */ - public java.lang.String getDescription( - ) { - return this._description; - } - - /** - * Returns the value of field 'group'. The field 'group' has - * the following description: Annotation with the same - * non-empty group name are grouped - * together - * - * @return the value of field 'Group'. - */ - public java.lang.String getGroup( - ) { - return this._group; - } - - /** - * Returns the value of field 'id'. The field 'id' has the - * following description: Primary Key for vamsas object - * referencing - * - * - * @return the value of field 'Id'. - */ - public java.lang.String getId( - ) { - return this._id; - } - - /** - * Returns the value of field 'label'. The field 'label' has - * the following description: Short, meaningful name for the - * annotation - if this - * is absent, then the type string should be used in its - * place. - * - * - * @return the value of field 'Label'. - */ - public java.lang.String getLabel( - ) { - return this._label; - } - - /** - * Method getLink. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the uk.ac.vamsas.objects.core.Link at - * the given index - */ - public uk.ac.vamsas.objects.core.Link getLink( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._linkList.size()) { - throw new IndexOutOfBoundsException("getLink: Index value '" + index + "' not in range [0.." + (this._linkList.size() - 1) + "]"); - } - - return (uk.ac.vamsas.objects.core.Link) _linkList.get(index); - } - - /** - * Method getLink.Returns the contents of the collection in an - * Array.

Note: Just in case the collection contents are - * changing in another thread, we pass a 0-length Array of the - * correct type into the API call. This way we know - * that the Array returned is of exactly the correct length. - * - * @return this collection as an Array - */ - public uk.ac.vamsas.objects.core.Link[] getLink( - ) { - uk.ac.vamsas.objects.core.Link[] array = new uk.ac.vamsas.objects.core.Link[0]; - return (uk.ac.vamsas.objects.core.Link[]) this._linkList.toArray(array); - } - - /** - * Method getLinkAsReference.Returns a reference to - * '_linkList'. No type checking is performed on any - * modifications to the Vector. - * - * @return a reference to the Vector backing this class - */ - public java.util.Vector getLinkAsReference( - ) { - return this._linkList; - } - - /** - * Method getLinkCount. - * - * @return the size of this collection - */ - public int getLinkCount( - ) { - return this._linkList.size(); - } - - /** - * Returns the value of field 'modifiable'. - * - * @return the value of field 'Modifiable'. - */ - public java.lang.String getModifiable( - ) { - return this._modifiable; - } - - /** - * Method getProperty. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the uk.ac.vamsas.objects.core.Property - * at the given index - */ - public uk.ac.vamsas.objects.core.Property getProperty( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._propertyList.size()) { - throw new IndexOutOfBoundsException("getProperty: Index value '" + index + "' not in range [0.." + (this._propertyList.size() - 1) + "]"); - } - - return (uk.ac.vamsas.objects.core.Property) _propertyList.get(index); - } - - /** - * Method getProperty.Returns the contents of the collection in - * an Array.

Note: Just in case the collection contents - * are changing in another thread, we pass a 0-length Array of - * the correct type into the API call. This way we know - * that the Array returned is of exactly the correct length. - * - * @return this collection as an Array - */ - public uk.ac.vamsas.objects.core.Property[] getProperty( - ) { - uk.ac.vamsas.objects.core.Property[] array = new uk.ac.vamsas.objects.core.Property[0]; - return (uk.ac.vamsas.objects.core.Property[]) this._propertyList.toArray(array); - } - - /** - * Method getPropertyAsReference.Returns a reference to - * '_propertyList'. No type checking is performed on any - * modifications to the Vector. - * - * @return a reference to the Vector backing this class - */ - public java.util.Vector getPropertyAsReference( - ) { - return this._propertyList; - } - - /** - * Method getPropertyCount. - * - * @return the size of this collection - */ - public int getPropertyCount( - ) { - return this._propertyList.size(); - } - - /** - * Method getScore. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the uk.ac.vamsas.objects.core.Score at - * the given index - */ - public uk.ac.vamsas.objects.core.Score getScore( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._scoreList.size()) { - throw new IndexOutOfBoundsException("getScore: Index value '" + index + "' not in range [0.." + (this._scoreList.size() - 1) + "]"); - } - - return (uk.ac.vamsas.objects.core.Score) _scoreList.get(index); - } - - /** - * Method getScore.Returns the contents of the collection in an - * Array.

Note: Just in case the collection contents are - * changing in another thread, we pass a 0-length Array of the - * correct type into the API call. This way we know - * that the Array returned is of exactly the correct length. - * - * @return this collection as an Array - */ - public uk.ac.vamsas.objects.core.Score[] getScore( - ) { - uk.ac.vamsas.objects.core.Score[] array = new uk.ac.vamsas.objects.core.Score[0]; - return (uk.ac.vamsas.objects.core.Score[]) this._scoreList.toArray(array); - } - - /** - * Method getScoreAsReference.Returns a reference to - * '_scoreList'. No type checking is performed on any - * modifications to the Vector. - * - * @return a reference to the Vector backing this class - */ - public java.util.Vector getScoreAsReference( - ) { - return this._scoreList; - } - - /** - * Method getScoreCount. - * - * @return the size of this collection - */ - public int getScoreCount( - ) { - return this._scoreList.size(); - } - - /** - * Returns the value of field 'status'. The field 'status' has - * the following description: TODO: specify this - we have - * considered taking the GO - * evidence codes as a model for assessing a measure of - * quality to an - * annotation. - * - * @return the value of field 'Status'. - */ - public java.lang.String getStatus( - ) { - return this._status; - } - - /** - * Returns the value of field 'type'. The field 'type' has the - * following description: A Das Feature has both a type and a - * Type ID. We go the - * route of requiring the type string to be taken from a - * controlled - * vocabulary if an application expects others to make sense - * of it. The - * type may qualified - so uniprot:CHAIN is a valid type name, - * and - * considered distinct from someotherDB:CHAIN - * - * @return the value of field 'Type'. - */ - public java.lang.String getType( - ) { - return this._type; - } - - /** - * Overrides the java.lang.Object.hashCode method. - *

- * The following steps came from Effective Java Programming - * Language Guide by Joshua Bloch, Chapter 3 - * - * @return a hash code value for the object. - */ - public int hashCode( - ) { - int result = super.hashCode(); - - long tmp; - if (_id != null - && !org.castor.util.CycleBreaker.startingToCycle(_id)) { - result = 37 * result + _id.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_id); - } - if (_modifiable != null - && !org.castor.util.CycleBreaker.startingToCycle(_modifiable)) { - result = 37 * result + _modifiable.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_modifiable); - } - if (_group != null - && !org.castor.util.CycleBreaker.startingToCycle(_group)) { - result = 37 * result + _group.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_group); - } - if (_type != null - && !org.castor.util.CycleBreaker.startingToCycle(_type)) { - result = 37 * result + _type.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_type); - } - if (_label != null - && !org.castor.util.CycleBreaker.startingToCycle(_label)) { - result = 37 * result + _label.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_label); - } - if (_description != null - && !org.castor.util.CycleBreaker.startingToCycle(_description)) { - result = 37 * result + _description.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_description); - } - if (_status != null - && !org.castor.util.CycleBreaker.startingToCycle(_status)) { - result = 37 * result + _status.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_status); - } - if (_annotationElementList != null - && !org.castor.util.CycleBreaker.startingToCycle(_annotationElementList)) { - result = 37 * result + _annotationElementList.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_annotationElementList); - } - if (_scoreList != null - && !org.castor.util.CycleBreaker.startingToCycle(_scoreList)) { - result = 37 * result + _scoreList.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_scoreList); - } - if (_linkList != null - && !org.castor.util.CycleBreaker.startingToCycle(_linkList)) { - result = 37 * result + _linkList.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_linkList); - } - if (_propertyList != null - && !org.castor.util.CycleBreaker.startingToCycle(_propertyList)) { - result = 37 * result + _propertyList.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_propertyList); + if (this._modifiable != null) { + if (temp._modifiable == null) + return false; + if (this._modifiable != temp._modifiable) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._modifiable); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._modifiable); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._modifiable); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._modifiable); + } + ; + return false; + } + if (!thcycle) { + if (!this._modifiable.equals(temp._modifiable)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._modifiable); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._modifiable); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._modifiable); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._modifiable); + } } - - return result; - } - - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { + } else if (temp._modifiable != null) + return false; + if (this._group != null) { + if (temp._group == null) + return false; + if (this._group != temp._group) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._group); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._group); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._group); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._group); + } + ; return false; + } + if (!thcycle) { + if (!this._group.equals(temp._group)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._group); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._group); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._group); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._group); + } } - return true; - } - - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } - - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } - - /** - */ - public void removeAllAnnotationElement( - ) { - this._annotationElementList.clear(); - } - - /** - */ - public void removeAllLink( - ) { - this._linkList.clear(); - } - - /** - */ - public void removeAllProperty( - ) { - this._propertyList.clear(); - } - - /** - */ - public void removeAllScore( - ) { - this._scoreList.clear(); - } - - /** - * Method removeAnnotationElement. - * - * @param vAnnotationElement - * @return true if the object was removed from the collection. - */ - public boolean removeAnnotationElement( - final uk.ac.vamsas.objects.core.AnnotationElement vAnnotationElement) { - boolean removed = _annotationElementList.remove(vAnnotationElement); - return removed; - } - - /** - * Method removeAnnotationElementAt. - * - * @param index - * @return the element removed from the collection - */ - public uk.ac.vamsas.objects.core.AnnotationElement removeAnnotationElementAt( - final int index) { - java.lang.Object obj = this._annotationElementList.remove(index); - return (uk.ac.vamsas.objects.core.AnnotationElement) obj; - } - - /** - * Method removeLink. - * - * @param vLink - * @return true if the object was removed from the collection. - */ - public boolean removeLink( - final uk.ac.vamsas.objects.core.Link vLink) { - boolean removed = _linkList.remove(vLink); - return removed; - } - - /** - * Method removeLinkAt. - * - * @param index - * @return the element removed from the collection - */ - public uk.ac.vamsas.objects.core.Link removeLinkAt( - final int index) { - java.lang.Object obj = this._linkList.remove(index); - return (uk.ac.vamsas.objects.core.Link) obj; - } - - /** - * Method removeProperty. - * - * @param vProperty - * @return true if the object was removed from the collection. - */ - public boolean removeProperty( - final uk.ac.vamsas.objects.core.Property vProperty) { - boolean removed = _propertyList.remove(vProperty); - return removed; - } - - /** - * Method removePropertyAt. - * - * @param index - * @return the element removed from the collection - */ - public uk.ac.vamsas.objects.core.Property removePropertyAt( - final int index) { - java.lang.Object obj = this._propertyList.remove(index); - return (uk.ac.vamsas.objects.core.Property) obj; - } - - /** - * Method removeScore. - * - * @param vScore - * @return true if the object was removed from the collection. - */ - public boolean removeScore( - final uk.ac.vamsas.objects.core.Score vScore) { - boolean removed = _scoreList.remove(vScore); - return removed; - } - - /** - * Method removeScoreAt. - * - * @param index - * @return the element removed from the collection - */ - public uk.ac.vamsas.objects.core.Score removeScoreAt( - final int index) { - java.lang.Object obj = this._scoreList.remove(index); - return (uk.ac.vamsas.objects.core.Score) obj; - } - - /** - * - * - * @param index - * @param vAnnotationElement - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setAnnotationElement( - final int index, - final uk.ac.vamsas.objects.core.AnnotationElement vAnnotationElement) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._annotationElementList.size()) { - throw new IndexOutOfBoundsException("setAnnotationElement: Index value '" + index + "' not in range [0.." + (this._annotationElementList.size() - 1) + "]"); + } else if (temp._group != null) + return false; + if (this._type != null) { + if (temp._type == null) + return false; + if (this._type != temp._type) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._type); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._type); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._type); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._type); + } + ; + return false; + } + if (!thcycle) { + if (!this._type.equals(temp._type)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._type); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._type); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._type); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._type); + } } - - this._annotationElementList.set(index, vAnnotationElement); - } - - /** - * - * - * @param vAnnotationElementArray - */ - public void setAnnotationElement( - final uk.ac.vamsas.objects.core.AnnotationElement[] vAnnotationElementArray) { - //-- copy array - _annotationElementList.clear(); - - for (int i = 0; i < vAnnotationElementArray.length; i++) { - this._annotationElementList.add(vAnnotationElementArray[i]); + } else if (temp._type != null) + return false; + if (this._label != null) { + if (temp._label == null) + return false; + if (this._label != temp._label) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._label); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._label); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._label); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._label); + } + ; + return false; + } + if (!thcycle) { + if (!this._label.equals(temp._label)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._label); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._label); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._label); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._label); + } } - } - - /** - * Sets the value of '_annotationElementList' by copying the - * given Vector. All elements will be checked for type safety. - * - * @param vAnnotationElementList the Vector to copy. - */ - public void setAnnotationElement( - final java.util.Vector vAnnotationElementList) { - // copy vector - this._annotationElementList.clear(); - - this._annotationElementList.addAll(vAnnotationElementList); - } - - /** - * Sets the value of '_annotationElementList' by setting it to - * the given Vector. No type checking is performed. - * @deprecated - * - * @param annotationElementVector the Vector to set. - */ - public void setAnnotationElementAsReference( - final java.util.Vector annotationElementVector) { - this._annotationElementList = annotationElementVector; - } - - /** - * Sets the value of field 'description'. The field - * 'description' has the following description: Human readable - * description of the annotation - * - * - * @param description the value of field 'description'. - */ - public void setDescription( - final java.lang.String description) { - this._description = description; - } - - /** - * Sets the value of field 'group'. The field 'group' has the - * following description: Annotation with the same non-empty - * group name are grouped - * together - * - * @param group the value of field 'group'. - */ - public void setGroup( - final java.lang.String group) { - this._group = group; - } - - /** - * 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( - final java.lang.String id) { - this._id = id; - } - - /** - * Sets the value of field 'label'. The field 'label' has the - * following description: Short, meaningful name for the - * annotation - if this - * is absent, then the type string should be used in its - * place. - * - * - * @param label the value of field 'label'. - */ - public void setLabel( - final java.lang.String label) { - this._label = label; - } - - /** - * - * - * @param index - * @param vLink - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setLink( - final int index, - final uk.ac.vamsas.objects.core.Link vLink) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._linkList.size()) { - throw new IndexOutOfBoundsException("setLink: Index value '" + index + "' not in range [0.." + (this._linkList.size() - 1) + "]"); + } else if (temp._label != null) + return false; + if (this._description != null) { + if (temp._description == null) + return false; + if (this._description != temp._description) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._description); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._description); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker + .releaseCycleHandle(this._description); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._description); + } + ; + return false; + } + if (!thcycle) { + if (!this._description.equals(temp._description)) { + org.castor.util.CycleBreaker + .releaseCycleHandle(this._description); + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._description); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._description); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._description); + } } - - this._linkList.set(index, vLink); - } - - /** - * - * - * @param vLinkArray - */ - public void setLink( - final uk.ac.vamsas.objects.core.Link[] vLinkArray) { - //-- copy array - _linkList.clear(); - - for (int i = 0; i < vLinkArray.length; i++) { - this._linkList.add(vLinkArray[i]); + } else if (temp._description != null) + return false; + if (this._status != null) { + if (temp._status == null) + return false; + if (this._status != temp._status) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._status); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._status); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._status); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._status); + } + ; + return false; + } + if (!thcycle) { + if (!this._status.equals(temp._status)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._status); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._status); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._status); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._status); + } } - } - - /** - * Sets the value of '_linkList' by copying the given Vector. - * All elements will be checked for type safety. - * - * @param vLinkList the Vector to copy. - */ - public void setLink( - final java.util.Vector vLinkList) { - // copy vector - this._linkList.clear(); - - this._linkList.addAll(vLinkList); - } - - /** - * Sets the value of '_linkList' by setting it to the given - * Vector. No type checking is performed. - * @deprecated - * - * @param linkVector the Vector to set. - */ - public void setLinkAsReference( - final java.util.Vector linkVector) { - this._linkList = linkVector; - } - - /** - * Sets the value of field 'modifiable'. - * - * @param modifiable the value of field 'modifiable'. - */ - public void setModifiable( - final java.lang.String modifiable) { - this._modifiable = modifiable; - } - - /** - * - * - * @param index - * @param vProperty - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setProperty( - final int index, - final uk.ac.vamsas.objects.core.Property vProperty) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._propertyList.size()) { - throw new IndexOutOfBoundsException("setProperty: Index value '" + index + "' not in range [0.." + (this._propertyList.size() - 1) + "]"); + } else if (temp._status != null) + return false; + if (this._annotationElementList != null) { + if (temp._annotationElementList == null) + return false; + if (this._annotationElementList != temp._annotationElementList) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._annotationElementList); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._annotationElementList); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker + .releaseCycleHandle(this._annotationElementList); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._annotationElementList); + } + ; + return false; + } + if (!thcycle) { + if (!this._annotationElementList + .equals(temp._annotationElementList)) { + org.castor.util.CycleBreaker + .releaseCycleHandle(this._annotationElementList); + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._annotationElementList); + return false; + } + org.castor.util.CycleBreaker + .releaseCycleHandle(this._annotationElementList); + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._annotationElementList); + } } - - this._propertyList.set(index, vProperty); - } - - /** - * - * - * @param vPropertyArray - */ - public void setProperty( - final uk.ac.vamsas.objects.core.Property[] vPropertyArray) { - //-- copy array - _propertyList.clear(); - - for (int i = 0; i < vPropertyArray.length; i++) { - this._propertyList.add(vPropertyArray[i]); + } else if (temp._annotationElementList != null) + return false; + if (this._scoreList != null) { + if (temp._scoreList == null) + return false; + if (this._scoreList != temp._scoreList) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._scoreList); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._scoreList); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._scoreList); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._scoreList); + } + ; + return false; + } + if (!thcycle) { + if (!this._scoreList.equals(temp._scoreList)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._scoreList); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._scoreList); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._scoreList); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._scoreList); + } } - } - - /** - * Sets the value of '_propertyList' by copying the given - * Vector. All elements will be checked for type safety. - * - * @param vPropertyList the Vector to copy. - */ - public void setProperty( - final java.util.Vector vPropertyList) { - // copy vector - this._propertyList.clear(); - - this._propertyList.addAll(vPropertyList); - } - - /** - * Sets the value of '_propertyList' by setting it to the given - * Vector. No type checking is performed. - * @deprecated - * - * @param propertyVector the Vector to set. - */ - public void setPropertyAsReference( - final java.util.Vector propertyVector) { - this._propertyList = propertyVector; - } - - /** - * - * - * @param index - * @param vScore - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setScore( - final int index, - final uk.ac.vamsas.objects.core.Score vScore) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._scoreList.size()) { - throw new IndexOutOfBoundsException("setScore: Index value '" + index + "' not in range [0.." + (this._scoreList.size() - 1) + "]"); + } else if (temp._scoreList != null) + return false; + if (this._linkList != null) { + if (temp._linkList == null) + return false; + if (this._linkList != temp._linkList) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._linkList); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._linkList); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._linkList); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._linkList); + } + ; + return false; + } + if (!thcycle) { + if (!this._linkList.equals(temp._linkList)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._linkList); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._linkList); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._linkList); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._linkList); + } } - - this._scoreList.set(index, vScore); - } - - /** - * - * - * @param vScoreArray - */ - public void setScore( - final uk.ac.vamsas.objects.core.Score[] vScoreArray) { - //-- copy array - _scoreList.clear(); - - for (int i = 0; i < vScoreArray.length; i++) { - this._scoreList.add(vScoreArray[i]); + } else if (temp._linkList != null) + return false; + if (this._propertyList != null) { + if (temp._propertyList == null) + return false; + if (this._propertyList != temp._propertyList) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._propertyList); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._propertyList); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker + .releaseCycleHandle(this._propertyList); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._propertyList); + } + ; + return false; + } + if (!thcycle) { + if (!this._propertyList.equals(temp._propertyList)) { + org.castor.util.CycleBreaker + .releaseCycleHandle(this._propertyList); + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._propertyList); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._propertyList); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._propertyList); + } } - } - - /** - * Sets the value of '_scoreList' by copying the given Vector. - * All elements will be checked for type safety. - * - * @param vScoreList the Vector to copy. - */ - public void setScore( - final java.util.Vector vScoreList) { - // copy vector - this._scoreList.clear(); - - this._scoreList.addAll(vScoreList); - } - - /** - * Sets the value of '_scoreList' by setting it to the given - * Vector. No type checking is performed. - * @deprecated - * - * @param scoreVector the Vector to set. - */ - public void setScoreAsReference( - final java.util.Vector scoreVector) { - this._scoreList = scoreVector; - } - - /** - * Sets the value of field 'status'. The field 'status' has the - * following description: TODO: specify this - we have - * considered taking the GO - * evidence codes as a model for assessing a measure of - * quality to an - * annotation. - * - * @param status the value of field 'status'. - */ - public void setStatus( - final java.lang.String status) { - this._status = status; - } - - /** - * Sets the value of field 'type'. The field 'type' has the - * following description: A Das Feature has both a type and a - * Type ID. We go the - * route of requiring the type string to be taken from a - * controlled - * vocabulary if an application expects others to make sense - * of it. The - * type may qualified - so uniprot:CHAIN is a valid type name, - * and - * considered distinct from someotherDB:CHAIN - * - * @param type the value of field 'type'. - */ - public void setType( - final java.lang.String type) { - this._type = type; - } - - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled uk.ac.vamsas.objects.core.RangeType - */ - public static uk.ac.vamsas.objects.core.RangeType unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (uk.ac.vamsas.objects.core.RangeType) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.RangeAnnotation.class, reader); - } - - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); - } + } else if (temp._propertyList != null) + return false; + return true; + } + return false; + } + + /** + * Method getAnnotationElement. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the uk.ac.vamsas.objects.core.AnnotationElement at the + * given inde + */ + public uk.ac.vamsas.objects.core.AnnotationElement getAnnotationElement( + final int index) throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._annotationElementList.size()) { + throw new IndexOutOfBoundsException("getAnnotationElement: Index value '" + + index + "' not in range [0.." + + (this._annotationElementList.size() - 1) + "]"); + } + + return (uk.ac.vamsas.objects.core.AnnotationElement) _annotationElementList + .get(index); + } + + /** + * Method getAnnotationElement.Returns the contents of the collection in an + * Array. + *

+ * Note: Just in case the collection contents are changing in another thread, + * we pass a 0-length Array of the correct type into the API call. This way we + * know that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public uk.ac.vamsas.objects.core.AnnotationElement[] getAnnotationElement() { + uk.ac.vamsas.objects.core.AnnotationElement[] array = new uk.ac.vamsas.objects.core.AnnotationElement[0]; + return (uk.ac.vamsas.objects.core.AnnotationElement[]) this._annotationElementList + .toArray(array); + } + + /** + * Method getAnnotationElementAsReference.Returns a reference to + * '_annotationElementList'. No type checking is performed on any + * modifications to the Vector. + * + * @return a reference to the Vector backing this class + */ + public java.util.Vector getAnnotationElementAsReference() { + return this._annotationElementList; + } + + /** + * Method getAnnotationElementCount. + * + * @return the size of this collection + */ + public int getAnnotationElementCount() { + return this._annotationElementList.size(); + } + + /** + * Returns the value of field 'description'. The field 'description' has the + * following description: Human readable description of the annotation + * + * + * @return the value of field 'Description'. + */ + public java.lang.String getDescription() { + return this._description; + } + + /** + * Returns the value of field 'group'. The field 'group' has the following + * description: Annotation with the same non-empty group name are grouped + * together + * + * @return the value of field 'Group'. + */ + public java.lang.String getGroup() { + return this._group; + } + + /** + * Returns the value of field 'id'. The field 'id' has the following + * description: Primary Key for vamsas object referencing + * + * + * @return the value of field 'Id'. + */ + public java.lang.String getId() { + return this._id; + } + + /** + * Returns the value of field 'label'. The field 'label' has the following + * description: Short, meaningful name for the annotation - if this is absent, + * then the type string should be used in its place. + * + * + * @return the value of field 'Label'. + */ + public java.lang.String getLabel() { + return this._label; + } + + /** + * Method getLink. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the uk.ac.vamsas.objects.core.Link at the given index + */ + public uk.ac.vamsas.objects.core.Link getLink(final int index) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._linkList.size()) { + throw new IndexOutOfBoundsException("getLink: Index value '" + index + + "' not in range [0.." + (this._linkList.size() - 1) + "]"); + } + + return (uk.ac.vamsas.objects.core.Link) _linkList.get(index); + } + + /** + * Method getLink.Returns the contents of the collection in an Array. + *

+ * Note: Just in case the collection contents are changing in another thread, + * we pass a 0-length Array of the correct type into the API call. This way we + * know that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public uk.ac.vamsas.objects.core.Link[] getLink() { + uk.ac.vamsas.objects.core.Link[] array = new uk.ac.vamsas.objects.core.Link[0]; + return (uk.ac.vamsas.objects.core.Link[]) this._linkList.toArray(array); + } + + /** + * Method getLinkAsReference.Returns a reference to '_linkList'. No type + * checking is performed on any modifications to the Vector. + * + * @return a reference to the Vector backing this class + */ + public java.util.Vector getLinkAsReference() { + return this._linkList; + } + + /** + * Method getLinkCount. + * + * @return the size of this collection + */ + public int getLinkCount() { + return this._linkList.size(); + } + + /** + * Returns the value of field 'modifiable'. + * + * @return the value of field 'Modifiable'. + */ + public java.lang.String getModifiable() { + return this._modifiable; + } + + /** + * Method getProperty. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the uk.ac.vamsas.objects.core.Property at the given + * index + */ + public uk.ac.vamsas.objects.core.Property getProperty(final int index) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._propertyList.size()) { + throw new IndexOutOfBoundsException("getProperty: Index value '" + index + + "' not in range [0.." + (this._propertyList.size() - 1) + "]"); + } + + return (uk.ac.vamsas.objects.core.Property) _propertyList.get(index); + } + + /** + * Method getProperty.Returns the contents of the collection in an Array. + *

+ * Note: Just in case the collection contents are changing in another thread, + * we pass a 0-length Array of the correct type into the API call. This way we + * know that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public uk.ac.vamsas.objects.core.Property[] getProperty() { + uk.ac.vamsas.objects.core.Property[] array = new uk.ac.vamsas.objects.core.Property[0]; + return (uk.ac.vamsas.objects.core.Property[]) this._propertyList + .toArray(array); + } + + /** + * Method getPropertyAsReference.Returns a reference to '_propertyList'. No + * type checking is performed on any modifications to the Vector. + * + * @return a reference to the Vector backing this class + */ + public java.util.Vector getPropertyAsReference() { + return this._propertyList; + } + + /** + * Method getPropertyCount. + * + * @return the size of this collection + */ + public int getPropertyCount() { + return this._propertyList.size(); + } + + /** + * Method getScore. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the uk.ac.vamsas.objects.core.Score at the given index + */ + public uk.ac.vamsas.objects.core.Score getScore(final int index) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._scoreList.size()) { + throw new IndexOutOfBoundsException("getScore: Index value '" + index + + "' not in range [0.." + (this._scoreList.size() - 1) + "]"); + } + + return (uk.ac.vamsas.objects.core.Score) _scoreList.get(index); + } + + /** + * Method getScore.Returns the contents of the collection in an Array. + *

+ * Note: Just in case the collection contents are changing in another thread, + * we pass a 0-length Array of the correct type into the API call. This way we + * know that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public uk.ac.vamsas.objects.core.Score[] getScore() { + uk.ac.vamsas.objects.core.Score[] array = new uk.ac.vamsas.objects.core.Score[0]; + return (uk.ac.vamsas.objects.core.Score[]) this._scoreList.toArray(array); + } + + /** + * Method getScoreAsReference.Returns a reference to '_scoreList'. No type + * checking is performed on any modifications to the Vector. + * + * @return a reference to the Vector backing this class + */ + public java.util.Vector getScoreAsReference() { + return this._scoreList; + } + + /** + * Method getScoreCount. + * + * @return the size of this collection + */ + public int getScoreCount() { + return this._scoreList.size(); + } + + /** + * Returns the value of field 'status'. The field 'status' has the following + * description: TODO: specify this - we have considered taking the GO evidence + * codes as a model for assessing a measure of quality to an annotation. + * + * @return the value of field 'Status'. + */ + public java.lang.String getStatus() { + return this._status; + } + + /** + * Returns the value of field 'type'. The field 'type' has the following + * description: A Das Feature has both a type and a Type ID. We go the route + * of requiring the type string to be taken from a controlled vocabulary if an + * application expects others to make sense of it. The type may qualified - so + * uniprot:CHAIN is a valid type name, and considered distinct from + * someotherDB:CHAIN + * + * @return the value of field 'Type'. + */ + public java.lang.String getType() { + return this._type; + } + + /** + * Overrides the java.lang.Object.hashCode method. + *

+ * The following steps came from Effective Java Programming Language + * Guide by Joshua Bloch, Chapter 3 + * + * @return a hash code value for the object. + */ + public int hashCode() { + int result = super.hashCode(); + + long tmp; + if (_id != null && !org.castor.util.CycleBreaker.startingToCycle(_id)) { + result = 37 * result + _id.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_id); + } + if (_modifiable != null + && !org.castor.util.CycleBreaker.startingToCycle(_modifiable)) { + result = 37 * result + _modifiable.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_modifiable); + } + if (_group != null && !org.castor.util.CycleBreaker.startingToCycle(_group)) { + result = 37 * result + _group.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_group); + } + if (_type != null && !org.castor.util.CycleBreaker.startingToCycle(_type)) { + result = 37 * result + _type.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_type); + } + if (_label != null && !org.castor.util.CycleBreaker.startingToCycle(_label)) { + result = 37 * result + _label.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_label); + } + if (_description != null + && !org.castor.util.CycleBreaker.startingToCycle(_description)) { + result = 37 * result + _description.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_description); + } + if (_status != null + && !org.castor.util.CycleBreaker.startingToCycle(_status)) { + result = 37 * result + _status.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_status); + } + if (_annotationElementList != null + && !org.castor.util.CycleBreaker + .startingToCycle(_annotationElementList)) { + result = 37 * result + _annotationElementList.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_annotationElementList); + } + if (_scoreList != null + && !org.castor.util.CycleBreaker.startingToCycle(_scoreList)) { + result = 37 * result + _scoreList.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_scoreList); + } + if (_linkList != null + && !org.castor.util.CycleBreaker.startingToCycle(_linkList)) { + result = 37 * result + _linkList.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_linkList); + } + if (_propertyList != null + && !org.castor.util.CycleBreaker.startingToCycle(_propertyList)) { + result = 37 * result + _propertyList.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_propertyList); + } + + return result; + } + + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() { + try { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) { + return false; + } + return true; + } + + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, out); + } + + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, handler); + } + + /** + */ + public void removeAllAnnotationElement() { + this._annotationElementList.clear(); + } + + /** + */ + public void removeAllLink() { + this._linkList.clear(); + } + + /** + */ + public void removeAllProperty() { + this._propertyList.clear(); + } + + /** + */ + public void removeAllScore() { + this._scoreList.clear(); + } + + /** + * Method removeAnnotationElement. + * + * @param vAnnotationElement + * @return true if the object was removed from the collection. + */ + public boolean removeAnnotationElement( + final uk.ac.vamsas.objects.core.AnnotationElement vAnnotationElement) { + boolean removed = _annotationElementList.remove(vAnnotationElement); + return removed; + } + + /** + * Method removeAnnotationElementAt. + * + * @param index + * @return the element removed from the collection + */ + public uk.ac.vamsas.objects.core.AnnotationElement removeAnnotationElementAt( + final int index) { + java.lang.Object obj = this._annotationElementList.remove(index); + return (uk.ac.vamsas.objects.core.AnnotationElement) obj; + } + + /** + * Method removeLink. + * + * @param vLink + * @return true if the object was removed from the collection. + */ + public boolean removeLink(final uk.ac.vamsas.objects.core.Link vLink) { + boolean removed = _linkList.remove(vLink); + return removed; + } + + /** + * Method removeLinkAt. + * + * @param index + * @return the element removed from the collection + */ + public uk.ac.vamsas.objects.core.Link removeLinkAt(final int index) { + java.lang.Object obj = this._linkList.remove(index); + return (uk.ac.vamsas.objects.core.Link) obj; + } + + /** + * Method removeProperty. + * + * @param vProperty + * @return true if the object was removed from the collection. + */ + public boolean removeProperty( + final uk.ac.vamsas.objects.core.Property vProperty) { + boolean removed = _propertyList.remove(vProperty); + return removed; + } + + /** + * Method removePropertyAt. + * + * @param index + * @return the element removed from the collection + */ + public uk.ac.vamsas.objects.core.Property removePropertyAt(final int index) { + java.lang.Object obj = this._propertyList.remove(index); + return (uk.ac.vamsas.objects.core.Property) obj; + } + + /** + * Method removeScore. + * + * @param vScore + * @return true if the object was removed from the collection. + */ + public boolean removeScore(final uk.ac.vamsas.objects.core.Score vScore) { + boolean removed = _scoreList.remove(vScore); + return removed; + } + + /** + * Method removeScoreAt. + * + * @param index + * @return the element removed from the collection + */ + public uk.ac.vamsas.objects.core.Score removeScoreAt(final int index) { + java.lang.Object obj = this._scoreList.remove(index); + return (uk.ac.vamsas.objects.core.Score) obj; + } + + /** + * + * + * @param index + * @param vAnnotationElement + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setAnnotationElement(final int index, + final uk.ac.vamsas.objects.core.AnnotationElement vAnnotationElement) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._annotationElementList.size()) { + throw new IndexOutOfBoundsException("setAnnotationElement: Index value '" + + index + "' not in range [0.." + + (this._annotationElementList.size() - 1) + "]"); + } + + this._annotationElementList.set(index, vAnnotationElement); + } + + /** + * + * + * @param vAnnotationElementArray + */ + public void setAnnotationElement( + final uk.ac.vamsas.objects.core.AnnotationElement[] vAnnotationElementArray) { + // -- copy array + _annotationElementList.clear(); + + for (int i = 0; i < vAnnotationElementArray.length; i++) { + this._annotationElementList.add(vAnnotationElementArray[i]); + } + } + + /** + * Sets the value of '_annotationElementList' by copying the given Vector. All + * elements will be checked for type safety. + * + * @param vAnnotationElementList + * the Vector to copy. + */ + public void setAnnotationElement(final java.util.Vector vAnnotationElementList) { + // copy vector + this._annotationElementList.clear(); + + this._annotationElementList.addAll(vAnnotationElementList); + } + + /** + * Sets the value of '_annotationElementList' by setting it to the given + * Vector. No type checking is performed. + * + * @deprecated + * + * @param annotationElementVector + * the Vector to set. + */ + public void setAnnotationElementAsReference( + final java.util.Vector annotationElementVector) { + this._annotationElementList = annotationElementVector; + } + + /** + * Sets the value of field 'description'. The field 'description' has the + * following description: Human readable description of the annotation + * + * + * @param description + * the value of field 'description'. + */ + public void setDescription(final java.lang.String description) { + this._description = description; + } + + /** + * Sets the value of field 'group'. The field 'group' has the following + * description: Annotation with the same non-empty group name are grouped + * together + * + * @param group + * the value of field 'group'. + */ + public void setGroup(final java.lang.String group) { + this._group = group; + } + + /** + * 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(final java.lang.String id) { + this._id = id; + } + + /** + * Sets the value of field 'label'. The field 'label' has the following + * description: Short, meaningful name for the annotation - if this is absent, + * then the type string should be used in its place. + * + * + * @param label + * the value of field 'label'. + */ + public void setLabel(final java.lang.String label) { + this._label = label; + } + + /** + * + * + * @param index + * @param vLink + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setLink(final int index, + final uk.ac.vamsas.objects.core.Link vLink) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._linkList.size()) { + throw new IndexOutOfBoundsException("setLink: Index value '" + index + + "' not in range [0.." + (this._linkList.size() - 1) + "]"); + } + + this._linkList.set(index, vLink); + } + + /** + * + * + * @param vLinkArray + */ + public void setLink(final uk.ac.vamsas.objects.core.Link[] vLinkArray) { + // -- copy array + _linkList.clear(); + + for (int i = 0; i < vLinkArray.length; i++) { + this._linkList.add(vLinkArray[i]); + } + } + + /** + * Sets the value of '_linkList' by copying the given Vector. All elements + * will be checked for type safety. + * + * @param vLinkList + * the Vector to copy. + */ + public void setLink(final java.util.Vector vLinkList) { + // copy vector + this._linkList.clear(); + + this._linkList.addAll(vLinkList); + } + + /** + * Sets the value of '_linkList' by setting it to the given Vector. No type + * checking is performed. + * + * @deprecated + * + * @param linkVector + * the Vector to set. + */ + public void setLinkAsReference(final java.util.Vector linkVector) { + this._linkList = linkVector; + } + + /** + * Sets the value of field 'modifiable'. + * + * @param modifiable + * the value of field 'modifiable'. + */ + public void setModifiable(final java.lang.String modifiable) { + this._modifiable = modifiable; + } + + /** + * + * + * @param index + * @param vProperty + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setProperty(final int index, + final uk.ac.vamsas.objects.core.Property vProperty) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._propertyList.size()) { + throw new IndexOutOfBoundsException("setProperty: Index value '" + index + + "' not in range [0.." + (this._propertyList.size() - 1) + "]"); + } + + this._propertyList.set(index, vProperty); + } + + /** + * + * + * @param vPropertyArray + */ + public void setProperty( + final uk.ac.vamsas.objects.core.Property[] vPropertyArray) { + // -- copy array + _propertyList.clear(); + + for (int i = 0; i < vPropertyArray.length; i++) { + this._propertyList.add(vPropertyArray[i]); + } + } + + /** + * Sets the value of '_propertyList' by copying the given Vector. All elements + * will be checked for type safety. + * + * @param vPropertyList + * the Vector to copy. + */ + public void setProperty(final java.util.Vector vPropertyList) { + // copy vector + this._propertyList.clear(); + + this._propertyList.addAll(vPropertyList); + } + + /** + * Sets the value of '_propertyList' by setting it to the given Vector. No + * type checking is performed. + * + * @deprecated + * + * @param propertyVector + * the Vector to set. + */ + public void setPropertyAsReference(final java.util.Vector propertyVector) { + this._propertyList = propertyVector; + } + + /** + * + * + * @param index + * @param vScore + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setScore(final int index, + final uk.ac.vamsas.objects.core.Score vScore) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._scoreList.size()) { + throw new IndexOutOfBoundsException("setScore: Index value '" + index + + "' not in range [0.." + (this._scoreList.size() - 1) + "]"); + } + + this._scoreList.set(index, vScore); + } + + /** + * + * + * @param vScoreArray + */ + public void setScore(final uk.ac.vamsas.objects.core.Score[] vScoreArray) { + // -- copy array + _scoreList.clear(); + + for (int i = 0; i < vScoreArray.length; i++) { + this._scoreList.add(vScoreArray[i]); + } + } + + /** + * Sets the value of '_scoreList' by copying the given Vector. All elements + * will be checked for type safety. + * + * @param vScoreList + * the Vector to copy. + */ + public void setScore(final java.util.Vector vScoreList) { + // copy vector + this._scoreList.clear(); + + this._scoreList.addAll(vScoreList); + } + + /** + * Sets the value of '_scoreList' by setting it to the given Vector. No type + * checking is performed. + * + * @deprecated + * + * @param scoreVector + * the Vector to set. + */ + public void setScoreAsReference(final java.util.Vector scoreVector) { + this._scoreList = scoreVector; + } + + /** + * Sets the value of field 'status'. The field 'status' has the following + * description: TODO: specify this - we have considered taking the GO evidence + * codes as a model for assessing a measure of quality to an annotation. + * + * @param status + * the value of field 'status'. + */ + public void setStatus(final java.lang.String status) { + this._status = status; + } + + /** + * Sets the value of field 'type'. The field 'type' has the following + * description: A Das Feature has both a type and a Type ID. We go the route + * of requiring the type string to be taken from a controlled vocabulary if an + * application expects others to make sense of it. The type may qualified - so + * uniprot:CHAIN is a valid type name, and considered distinct from + * someotherDB:CHAIN + * + * @param type + * the value of field 'type'. + */ + public void setType(final java.lang.String type) { + this._type = type; + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @return the unmarshaled uk.ac.vamsas.objects.core.RangeType + */ + public static uk.ac.vamsas.objects.core.RangeType unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + return (uk.ac.vamsas.objects.core.RangeType) Unmarshaller.unmarshal( + uk.ac.vamsas.objects.core.RangeAnnotation.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/uk/ac/vamsas/objects/core/RangeType.java b/src/uk/ac/vamsas/objects/core/RangeType.java index 3e1f6da..b2573e9 100644 --- a/src/uk/ac/vamsas/objects/core/RangeType.java +++ b/src/uk/ac/vamsas/objects/core/RangeType.java @@ -1,601 +1,600 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core; /** - * Specify an ordered set of positions and/or regions on the - * principle - * dimension of some associated vamsas object Keeping to jaxb-1.0 - * specification for the moment - this choice should - * become a substitution group when we use jaxb-2.0 capable - * bindings - * + * Specify an ordered set of positions and/or regions on the principle dimension + * of some associated vamsas object Keeping to jaxb-1.0 specification for the + * moment - this choice should become a substitution group when we use jaxb-2.0 + * capable bindings + * * * @version $Revision$ $Date$ */ -public abstract class RangeType extends uk.ac.vamsas.client.Vobject -implements java.io.Serializable -{ - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Internal choice value storage - */ - private java.lang.Object _choiceValue; - - /** - * a position within the associated object's coordinate system - * - */ - private java.util.Vector _posList; - - /** - * a region from start to end, with flag for inclusivity of - * terminii - */ - private java.util.Vector _segList; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public RangeType() { - super(); - this._posList = new java.util.Vector(); - this._segList = new java.util.Vector(); - } - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * - * - * @param vPos - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addPos( - final uk.ac.vamsas.objects.core.Pos vPos) - throws java.lang.IndexOutOfBoundsException { - this._posList.addElement(vPos); - } - - /** - * - * - * @param index - * @param vPos - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addPos( - final int index, - final uk.ac.vamsas.objects.core.Pos vPos) - throws java.lang.IndexOutOfBoundsException { - this._posList.add(index, vPos); - } - - /** - * - * - * @param vSeg - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addSeg( - final uk.ac.vamsas.objects.core.Seg vSeg) - throws java.lang.IndexOutOfBoundsException { - this._segList.addElement(vSeg); - } - - /** - * - * - * @param index - * @param vSeg - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addSeg( - final int index, - final uk.ac.vamsas.objects.core.Seg vSeg) - throws java.lang.IndexOutOfBoundsException { - this._segList.add(index, vSeg); - } - - /** - * Method enumeratePos. - * - * @return an Enumeration over all - * uk.ac.vamsas.objects.core.Pos elements - */ - public java.util.Enumeration enumeratePos( - ) { - return this._posList.elements(); - } - - /** - * Method enumerateSeg. - * - * @return an Enumeration over all - * uk.ac.vamsas.objects.core.Seg elements - */ - public java.util.Enumeration enumerateSeg( - ) { - return this._segList.elements(); - } - - /** - * Overrides the java.lang.Object.equals method. - * - * @param obj - * @return true if the objects are equal. - */ - public boolean equals( - final java.lang.Object obj) { - if ( this == obj ) - return true; - - if (super.equals(obj)==false) +public abstract class RangeType extends uk.ac.vamsas.client.Vobject implements + java.io.Serializable { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Internal choice value storage + */ + private java.lang.Object _choiceValue; + + /** + * a position within the associated object's coordinate system + * + */ + private java.util.Vector _posList; + + /** + * a region from start to end, with flag for inclusivity of terminii + */ + private java.util.Vector _segList; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public RangeType() { + super(); + this._posList = new java.util.Vector(); + this._segList = new java.util.Vector(); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * + * + * @param vPos + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addPos(final uk.ac.vamsas.objects.core.Pos vPos) + throws java.lang.IndexOutOfBoundsException { + this._posList.addElement(vPos); + } + + /** + * + * + * @param index + * @param vPos + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addPos(final int index, final uk.ac.vamsas.objects.core.Pos vPos) + throws java.lang.IndexOutOfBoundsException { + this._posList.add(index, vPos); + } + + /** + * + * + * @param vSeg + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addSeg(final uk.ac.vamsas.objects.core.Seg vSeg) + throws java.lang.IndexOutOfBoundsException { + this._segList.addElement(vSeg); + } + + /** + * + * + * @param index + * @param vSeg + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addSeg(final int index, final uk.ac.vamsas.objects.core.Seg vSeg) + throws java.lang.IndexOutOfBoundsException { + this._segList.add(index, vSeg); + } + + /** + * Method enumeratePos. + * + * @return an Enumeration over all uk.ac.vamsas.objects.core.Pos elements + */ + public java.util.Enumeration enumeratePos() { + return this._posList.elements(); + } + + /** + * Method enumerateSeg. + * + * @return an Enumeration over all uk.ac.vamsas.objects.core.Seg elements + */ + public java.util.Enumeration enumerateSeg() { + return this._segList.elements(); + } + + /** + * Overrides the java.lang.Object.equals method. + * + * @param obj + * @return true if the objects are equal. + */ + public boolean equals(final java.lang.Object obj) { + if (this == obj) + return true; + + if (super.equals(obj) == false) + return false; + + if (obj instanceof RangeType) { + + RangeType temp = (RangeType) obj; + boolean thcycle; + boolean tmcycle; + if (this._choiceValue != null) { + if (temp._choiceValue == null) + return false; + if (this._choiceValue != temp._choiceValue) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._choiceValue); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._choiceValue); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker + .releaseCycleHandle(this._choiceValue); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._choiceValue); + } + ; return false; - - if (obj instanceof RangeType) { - - RangeType temp = (RangeType)obj; - boolean thcycle; - boolean tmcycle; - if (this._choiceValue != null) { - if (temp._choiceValue == null) return false; - if (this._choiceValue != temp._choiceValue) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._choiceValue); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._choiceValue); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._choiceValue); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._choiceValue); }; - return false; - } - if (!thcycle) { - if (!this._choiceValue.equals(temp._choiceValue)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._choiceValue); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._choiceValue); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._choiceValue); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._choiceValue); - } - } - } else if (temp._choiceValue != null) - return false; - if (this._posList != null) { - if (temp._posList == null) return false; - if (this._posList != temp._posList) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._posList); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._posList); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._posList); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._posList); }; - return false; - } - if (!thcycle) { - if (!this._posList.equals(temp._posList)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._posList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._posList); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._posList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._posList); - } - } - } else if (temp._posList != null) - return false; - if (this._segList != null) { - if (temp._segList == null) return false; - if (this._segList != temp._segList) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._segList); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._segList); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._segList); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._segList); }; - return false; - } - if (!thcycle) { - if (!this._segList.equals(temp._segList)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._segList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._segList); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._segList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._segList); - } - } - } else if (temp._segList != null) - return false; - return true; + } + if (!thcycle) { + if (!this._choiceValue.equals(temp._choiceValue)) { + org.castor.util.CycleBreaker + .releaseCycleHandle(this._choiceValue); + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._choiceValue); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._choiceValue); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._choiceValue); + } } + } else if (temp._choiceValue != null) return false; - } - - /** - * Returns the value of field 'choiceValue'. The field - * 'choiceValue' has the following description: Internal choice - * value storage - * - * @return the value of field 'ChoiceValue'. - */ - public java.lang.Object getChoiceValue( - ) { - return this._choiceValue; - } - - /** - * Method getPos. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the uk.ac.vamsas.objects.core.Pos at - * the given index - */ - public uk.ac.vamsas.objects.core.Pos getPos( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._posList.size()) { - throw new IndexOutOfBoundsException("getPos: Index value '" + index + "' not in range [0.." + (this._posList.size() - 1) + "]"); - } - - return (uk.ac.vamsas.objects.core.Pos) _posList.get(index); - } - - /** - * Method getPos.Returns the contents of the collection in an - * Array.

Note: Just in case the collection contents are - * changing in another thread, we pass a 0-length Array of the - * correct type into the API call. This way we know - * that the Array returned is of exactly the correct length. - * - * @return this collection as an Array - */ - public uk.ac.vamsas.objects.core.Pos[] getPos( - ) { - uk.ac.vamsas.objects.core.Pos[] array = new uk.ac.vamsas.objects.core.Pos[0]; - return (uk.ac.vamsas.objects.core.Pos[]) this._posList.toArray(array); - } - - /** - * Method getPosAsReference.Returns a reference to '_posList'. - * No type checking is performed on any modifications to the - * Vector. - * - * @return a reference to the Vector backing this class - */ - public java.util.Vector getPosAsReference( - ) { - return this._posList; - } - - /** - * Method getPosCount. - * - * @return the size of this collection - */ - public int getPosCount( - ) { - return this._posList.size(); - } - - /** - * Method getSeg. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the uk.ac.vamsas.objects.core.Seg at - * the given index - */ - public uk.ac.vamsas.objects.core.Seg getSeg( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._segList.size()) { - throw new IndexOutOfBoundsException("getSeg: Index value '" + index + "' not in range [0.." + (this._segList.size() - 1) + "]"); - } - - return (uk.ac.vamsas.objects.core.Seg) _segList.get(index); - } - - /** - * Method getSeg.Returns the contents of the collection in an - * Array.

Note: Just in case the collection contents are - * changing in another thread, we pass a 0-length Array of the - * correct type into the API call. This way we know - * that the Array returned is of exactly the correct length. - * - * @return this collection as an Array - */ - public uk.ac.vamsas.objects.core.Seg[] getSeg( - ) { - uk.ac.vamsas.objects.core.Seg[] array = new uk.ac.vamsas.objects.core.Seg[0]; - return (uk.ac.vamsas.objects.core.Seg[]) this._segList.toArray(array); - } - - /** - * Method getSegAsReference.Returns a reference to '_segList'. - * No type checking is performed on any modifications to the - * Vector. - * - * @return a reference to the Vector backing this class - */ - public java.util.Vector getSegAsReference( - ) { - return this._segList; - } - - /** - * Method getSegCount. - * - * @return the size of this collection - */ - public int getSegCount( - ) { - return this._segList.size(); - } - - /** - * Overrides the java.lang.Object.hashCode method. - *

- * The following steps came from Effective Java Programming - * Language Guide by Joshua Bloch, Chapter 3 - * - * @return a hash code value for the object. - */ - public int hashCode( - ) { - int result = super.hashCode(); - - long tmp; - if (_choiceValue != null - && !org.castor.util.CycleBreaker.startingToCycle(_choiceValue)) { - result = 37 * result + _choiceValue.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_choiceValue); - } - if (_posList != null - && !org.castor.util.CycleBreaker.startingToCycle(_posList)) { - result = 37 * result + _posList.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_posList); - } - if (_segList != null - && !org.castor.util.CycleBreaker.startingToCycle(_segList)) { - result = 37 * result + _segList.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_segList); - } - - return result; - } - - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { + if (this._posList != null) { + if (temp._posList == null) + return false; + if (this._posList != temp._posList) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._posList); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._posList); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._posList); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._posList); + } + ; return false; + } + if (!thcycle) { + if (!this._posList.equals(temp._posList)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._posList); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._posList); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._posList); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._posList); + } } - return true; - } - - /** - */ - public void removeAllPos( - ) { - this._posList.clear(); - } - - /** - */ - public void removeAllSeg( - ) { - this._segList.clear(); - } - - /** - * Method removePos. - * - * @param vPos - * @return true if the object was removed from the collection. - */ - public boolean removePos( - final uk.ac.vamsas.objects.core.Pos vPos) { - boolean removed = _posList.remove(vPos); - return removed; - } - - /** - * Method removePosAt. - * - * @param index - * @return the element removed from the collection - */ - public uk.ac.vamsas.objects.core.Pos removePosAt( - final int index) { - java.lang.Object obj = this._posList.remove(index); - return (uk.ac.vamsas.objects.core.Pos) obj; - } - - /** - * Method removeSeg. - * - * @param vSeg - * @return true if the object was removed from the collection. - */ - public boolean removeSeg( - final uk.ac.vamsas.objects.core.Seg vSeg) { - boolean removed = _segList.remove(vSeg); - return removed; - } - - /** - * Method removeSegAt. - * - * @param index - * @return the element removed from the collection - */ - public uk.ac.vamsas.objects.core.Seg removeSegAt( - final int index) { - java.lang.Object obj = this._segList.remove(index); - return (uk.ac.vamsas.objects.core.Seg) obj; - } - - /** - * - * - * @param index - * @param vPos - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setPos( - final int index, - final uk.ac.vamsas.objects.core.Pos vPos) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._posList.size()) { - throw new IndexOutOfBoundsException("setPos: Index value '" + index + "' not in range [0.." + (this._posList.size() - 1) + "]"); - } - - this._posList.set(index, vPos); - } - - /** - * - * - * @param vPosArray - */ - public void setPos( - final uk.ac.vamsas.objects.core.Pos[] vPosArray) { - //-- copy array - _posList.clear(); - - for (int i = 0; i < vPosArray.length; i++) { - this._posList.add(vPosArray[i]); - } - } - - /** - * Sets the value of '_posList' by copying the given Vector. - * All elements will be checked for type safety. - * - * @param vPosList the Vector to copy. - */ - public void setPos( - final java.util.Vector vPosList) { - // copy vector - this._posList.clear(); - - this._posList.addAll(vPosList); - } - - /** - * Sets the value of '_posList' by setting it to the given - * Vector. No type checking is performed. - * @deprecated - * - * @param posVector the Vector to set. - */ - public void setPosAsReference( - final java.util.Vector posVector) { - this._posList = posVector; - } - - /** - * - * - * @param index - * @param vSeg - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setSeg( - final int index, - final uk.ac.vamsas.objects.core.Seg vSeg) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._segList.size()) { - throw new IndexOutOfBoundsException("setSeg: Index value '" + index + "' not in range [0.." + (this._segList.size() - 1) + "]"); - } - - this._segList.set(index, vSeg); - } - - /** - * - * - * @param vSegArray - */ - public void setSeg( - final uk.ac.vamsas.objects.core.Seg[] vSegArray) { - //-- copy array - _segList.clear(); - - for (int i = 0; i < vSegArray.length; i++) { - this._segList.add(vSegArray[i]); + } else if (temp._posList != null) + return false; + if (this._segList != null) { + if (temp._segList == null) + return false; + if (this._segList != temp._segList) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._segList); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._segList); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._segList); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._segList); + } + ; + return false; + } + if (!thcycle) { + if (!this._segList.equals(temp._segList)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._segList); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._segList); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._segList); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._segList); + } } - } - - /** - * Sets the value of '_segList' by copying the given Vector. - * All elements will be checked for type safety. - * - * @param vSegList the Vector to copy. - */ - public void setSeg( - final java.util.Vector vSegList) { - // copy vector - this._segList.clear(); - - this._segList.addAll(vSegList); - } - - /** - * Sets the value of '_segList' by setting it to the given - * Vector. No type checking is performed. - * @deprecated - * - * @param segVector the Vector to set. - */ - public void setSegAsReference( - final java.util.Vector segVector) { - this._segList = segVector; - } - - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); - } + } else if (temp._segList != null) + return false; + return true; + } + return false; + } + + /** + * Returns the value of field 'choiceValue'. The field 'choiceValue' has the + * following description: Internal choice value storage + * + * @return the value of field 'ChoiceValue'. + */ + public java.lang.Object getChoiceValue() { + return this._choiceValue; + } + + /** + * Method getPos. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the uk.ac.vamsas.objects.core.Pos at the given index + */ + public uk.ac.vamsas.objects.core.Pos getPos(final int index) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._posList.size()) { + throw new IndexOutOfBoundsException("getPos: Index value '" + index + + "' not in range [0.." + (this._posList.size() - 1) + "]"); + } + + return (uk.ac.vamsas.objects.core.Pos) _posList.get(index); + } + + /** + * Method getPos.Returns the contents of the collection in an Array. + *

+ * Note: Just in case the collection contents are changing in another thread, + * we pass a 0-length Array of the correct type into the API call. This way we + * know that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public uk.ac.vamsas.objects.core.Pos[] getPos() { + uk.ac.vamsas.objects.core.Pos[] array = new uk.ac.vamsas.objects.core.Pos[0]; + return (uk.ac.vamsas.objects.core.Pos[]) this._posList.toArray(array); + } + + /** + * Method getPosAsReference.Returns a reference to '_posList'. No type + * checking is performed on any modifications to the Vector. + * + * @return a reference to the Vector backing this class + */ + public java.util.Vector getPosAsReference() { + return this._posList; + } + + /** + * Method getPosCount. + * + * @return the size of this collection + */ + public int getPosCount() { + return this._posList.size(); + } + + /** + * Method getSeg. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the uk.ac.vamsas.objects.core.Seg at the given index + */ + public uk.ac.vamsas.objects.core.Seg getSeg(final int index) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._segList.size()) { + throw new IndexOutOfBoundsException("getSeg: Index value '" + index + + "' not in range [0.." + (this._segList.size() - 1) + "]"); + } + + return (uk.ac.vamsas.objects.core.Seg) _segList.get(index); + } + + /** + * Method getSeg.Returns the contents of the collection in an Array. + *

+ * Note: Just in case the collection contents are changing in another thread, + * we pass a 0-length Array of the correct type into the API call. This way we + * know that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public uk.ac.vamsas.objects.core.Seg[] getSeg() { + uk.ac.vamsas.objects.core.Seg[] array = new uk.ac.vamsas.objects.core.Seg[0]; + return (uk.ac.vamsas.objects.core.Seg[]) this._segList.toArray(array); + } + + /** + * Method getSegAsReference.Returns a reference to '_segList'. No type + * checking is performed on any modifications to the Vector. + * + * @return a reference to the Vector backing this class + */ + public java.util.Vector getSegAsReference() { + return this._segList; + } + + /** + * Method getSegCount. + * + * @return the size of this collection + */ + public int getSegCount() { + return this._segList.size(); + } + + /** + * Overrides the java.lang.Object.hashCode method. + *

+ * The following steps came from Effective Java Programming Language + * Guide by Joshua Bloch, Chapter 3 + * + * @return a hash code value for the object. + */ + public int hashCode() { + int result = super.hashCode(); + + long tmp; + if (_choiceValue != null + && !org.castor.util.CycleBreaker.startingToCycle(_choiceValue)) { + result = 37 * result + _choiceValue.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_choiceValue); + } + if (_posList != null + && !org.castor.util.CycleBreaker.startingToCycle(_posList)) { + result = 37 * result + _posList.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_posList); + } + if (_segList != null + && !org.castor.util.CycleBreaker.startingToCycle(_segList)) { + result = 37 * result + _segList.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_segList); + } + + return result; + } + + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() { + try { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) { + return false; + } + return true; + } + + /** + */ + public void removeAllPos() { + this._posList.clear(); + } + + /** + */ + public void removeAllSeg() { + this._segList.clear(); + } + + /** + * Method removePos. + * + * @param vPos + * @return true if the object was removed from the collection. + */ + public boolean removePos(final uk.ac.vamsas.objects.core.Pos vPos) { + boolean removed = _posList.remove(vPos); + return removed; + } + + /** + * Method removePosAt. + * + * @param index + * @return the element removed from the collection + */ + public uk.ac.vamsas.objects.core.Pos removePosAt(final int index) { + java.lang.Object obj = this._posList.remove(index); + return (uk.ac.vamsas.objects.core.Pos) obj; + } + + /** + * Method removeSeg. + * + * @param vSeg + * @return true if the object was removed from the collection. + */ + public boolean removeSeg(final uk.ac.vamsas.objects.core.Seg vSeg) { + boolean removed = _segList.remove(vSeg); + return removed; + } + + /** + * Method removeSegAt. + * + * @param index + * @return the element removed from the collection + */ + public uk.ac.vamsas.objects.core.Seg removeSegAt(final int index) { + java.lang.Object obj = this._segList.remove(index); + return (uk.ac.vamsas.objects.core.Seg) obj; + } + + /** + * + * + * @param index + * @param vPos + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setPos(final int index, final uk.ac.vamsas.objects.core.Pos vPos) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._posList.size()) { + throw new IndexOutOfBoundsException("setPos: Index value '" + index + + "' not in range [0.." + (this._posList.size() - 1) + "]"); + } + + this._posList.set(index, vPos); + } + + /** + * + * + * @param vPosArray + */ + public void setPos(final uk.ac.vamsas.objects.core.Pos[] vPosArray) { + // -- copy array + _posList.clear(); + + for (int i = 0; i < vPosArray.length; i++) { + this._posList.add(vPosArray[i]); + } + } + + /** + * Sets the value of '_posList' by copying the given Vector. All elements will + * be checked for type safety. + * + * @param vPosList + * the Vector to copy. + */ + public void setPos(final java.util.Vector vPosList) { + // copy vector + this._posList.clear(); + + this._posList.addAll(vPosList); + } + + /** + * Sets the value of '_posList' by setting it to the given Vector. No type + * checking is performed. + * + * @deprecated + * + * @param posVector + * the Vector to set. + */ + public void setPosAsReference(final java.util.Vector posVector) { + this._posList = posVector; + } + + /** + * + * + * @param index + * @param vSeg + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setSeg(final int index, final uk.ac.vamsas.objects.core.Seg vSeg) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._segList.size()) { + throw new IndexOutOfBoundsException("setSeg: Index value '" + index + + "' not in range [0.." + (this._segList.size() - 1) + "]"); + } + + this._segList.set(index, vSeg); + } + + /** + * + * + * @param vSegArray + */ + public void setSeg(final uk.ac.vamsas.objects.core.Seg[] vSegArray) { + // -- copy array + _segList.clear(); + + for (int i = 0; i < vSegArray.length; i++) { + this._segList.add(vSegArray[i]); + } + } + + /** + * Sets the value of '_segList' by copying the given Vector. All elements will + * be checked for type safety. + * + * @param vSegList + * the Vector to copy. + */ + public void setSeg(final java.util.Vector vSegList) { + // copy vector + this._segList.clear(); + + this._segList.addAll(vSegList); + } + + /** + * Sets the value of '_segList' by setting it to the given Vector. No type + * checking is performed. + * + * @deprecated + * + * @param segVector + * the Vector to set. + */ + public void setSegAsReference(final java.util.Vector segVector) { + this._segList = segVector; + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/uk/ac/vamsas/objects/core/ReferenceType.java b/src/uk/ac/vamsas/objects/core/ReferenceType.java index 6c06137..e6a98da 100644 --- a/src/uk/ac/vamsas/objects/core/ReferenceType.java +++ b/src/uk/ac/vamsas/objects/core/ReferenceType.java @@ -1,499 +1,510 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import org.exolab.castor.xml.Marshaller; import org.exolab.castor.xml.Unmarshaller; /** - * base type for citing arbitrary links between vamsas objects - * Optional human readable description of the relationship - * + * base type for citing arbitrary links between vamsas objects Optional human + * readable description of the relationship + * * * @version $Revision$ $Date$ */ -public class ReferenceType extends uk.ac.vamsas.client.Vobject -implements java.io.Serializable -{ - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * internal content storage - */ - private java.lang.String _content = ""; - - /** - * Primary Key for vamsas object referencing - * - */ - private java.lang.String _id; - - /** - * List of one or more vamsas object - * references - */ - private java.util.Vector _refs; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public ReferenceType() { - super(); - setContent(""); - this._refs = new java.util.Vector(); - } - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * - * - * @param vRefs - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addRefs( - final java.lang.Object vRefs) - throws java.lang.IndexOutOfBoundsException { - this._refs.addElement(vRefs); - } - - /** - * - * - * @param index - * @param vRefs - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addRefs( - final int index, - final java.lang.Object vRefs) - throws java.lang.IndexOutOfBoundsException { - this._refs.add(index, vRefs); - } - - /** - * Method enumerateRefs. - * - * @return an Enumeration over all java.lang.Object elements - */ - public java.util.Enumeration enumerateRefs( - ) { - return this._refs.elements(); - } - - /** - * Overrides the java.lang.Object.equals method. - * - * @param obj - * @return true if the objects are equal. - */ - public boolean equals( - final java.lang.Object obj) { - if ( this == obj ) - return true; - - if (super.equals(obj)==false) +public class ReferenceType extends uk.ac.vamsas.client.Vobject implements + java.io.Serializable { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * internal content storage + */ + private java.lang.String _content = ""; + + /** + * Primary Key for vamsas object referencing + * + */ + private java.lang.String _id; + + /** + * List of one or more vamsas object references + */ + private java.util.Vector _refs; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public ReferenceType() { + super(); + setContent(""); + this._refs = new java.util.Vector(); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * + * + * @param vRefs + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addRefs(final java.lang.Object vRefs) + throws java.lang.IndexOutOfBoundsException { + this._refs.addElement(vRefs); + } + + /** + * + * + * @param index + * @param vRefs + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addRefs(final int index, final java.lang.Object vRefs) + throws java.lang.IndexOutOfBoundsException { + this._refs.add(index, vRefs); + } + + /** + * Method enumerateRefs. + * + * @return an Enumeration over all java.lang.Object elements + */ + public java.util.Enumeration enumerateRefs() { + return this._refs.elements(); + } + + /** + * Overrides the java.lang.Object.equals method. + * + * @param obj + * @return true if the objects are equal. + */ + public boolean equals(final java.lang.Object obj) { + if (this == obj) + return true; + + if (super.equals(obj) == false) + return false; + + if (obj instanceof ReferenceType) { + + ReferenceType temp = (ReferenceType) obj; + boolean thcycle; + boolean tmcycle; + if (this._content != null) { + if (temp._content == null) + return false; + if (this._content != temp._content) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._content); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._content); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._content); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._content); + } + ; return false; - - if (obj instanceof ReferenceType) { - - ReferenceType temp = (ReferenceType)obj; - boolean thcycle; - boolean tmcycle; - if (this._content != null) { - if (temp._content == null) return false; - if (this._content != temp._content) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._content); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._content); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._content); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._content); }; - return false; - } - if (!thcycle) { - if (!this._content.equals(temp._content)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._content); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._content); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._content); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._content); - } - } - } else if (temp._content != null) - return false; - if (this._id != null) { - if (temp._id == null) return false; - if (this._id != temp._id) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._id); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._id); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._id); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); }; - return false; - } - if (!thcycle) { - if (!this._id.equals(temp._id)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._id); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._id); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); - } - } - } else if (temp._id != null) - return false; - if (this._refs != null) { - if (temp._refs == null) return false; - if (this._refs != temp._refs) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._refs); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._refs); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._refs); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._refs); }; - return false; - } - if (!thcycle) { - if (!this._refs.equals(temp._refs)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._refs); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._refs); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._refs); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._refs); - } - } - } else if (temp._refs != null) - return false; - return true; + } + if (!thcycle) { + if (!this._content.equals(temp._content)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._content); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._content); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._content); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._content); + } } + } else if (temp._content != null) return false; - } - - /** - * Returns the value of field 'content'. The field 'content' - * has the following description: internal content storage - * - * @return the value of field 'Content'. - */ - public java.lang.String getContent( - ) { - return this._content; - } - - /** - * Returns the value of field 'id'. The field 'id' has the - * following description: Primary Key for vamsas object - * referencing - * - * - * @return the value of field 'Id'. - */ - public java.lang.String getId( - ) { - return this._id; - } - - /** - * Method getRefs. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the java.lang.Object at the given index - */ - public java.lang.Object getRefs( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._refs.size()) { - throw new IndexOutOfBoundsException("getRefs: Index value '" + index + "' not in range [0.." + (this._refs.size() - 1) + "]"); - } - - return _refs.get(index); - } - - /** - * Method getRefs.Returns the contents of the collection in an - * Array.

Note: Just in case the collection contents are - * changing in another thread, we pass a 0-length Array of the - * correct type into the API call. This way we know - * that the Array returned is of exactly the correct length. - * - * @return this collection as an Array - */ - public java.lang.Object[] getRefs( - ) { - java.lang.Object[] array = new java.lang.Object[0]; - return (java.lang.Object[]) this._refs.toArray(array); - } - - /** - * Method getRefsAsReference.Returns a reference to '_refs'. No - * type checking is performed on any modifications to the - * Vector. - * - * @return a reference to the Vector backing this class - */ - public java.util.Vector getRefsAsReference( - ) { - return this._refs; - } - - /** - * Method getRefsCount. - * - * @return the size of this collection - */ - public int getRefsCount( - ) { - return this._refs.size(); - } - - /** - * Overrides the java.lang.Object.hashCode method. - *

- * The following steps came from Effective Java Programming - * Language Guide by Joshua Bloch, Chapter 3 - * - * @return a hash code value for the object. - */ - public int hashCode( - ) { - int result = super.hashCode(); - - long tmp; - if (_content != null - && !org.castor.util.CycleBreaker.startingToCycle(_content)) { - result = 37 * result + _content.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_content); - } - if (_id != null - && !org.castor.util.CycleBreaker.startingToCycle(_id)) { - result = 37 * result + _id.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_id); - } - if (_refs != null - && !org.castor.util.CycleBreaker.startingToCycle(_refs)) { - result = 37 * result + _refs.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_refs); + if (this._id != null) { + if (temp._id == null) + return false; + if (this._id != temp._id) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._id); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._id); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._id); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); + } + ; + return false; + } + if (!thcycle) { + if (!this._id.equals(temp._id)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._id); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._id); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); + } } - - return result; - } - - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { + } else if (temp._id != null) + return false; + if (this._refs != null) { + if (temp._refs == null) + return false; + if (this._refs != temp._refs) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._refs); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._refs); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._refs); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._refs); + } + ; return false; + } + if (!thcycle) { + if (!this._refs.equals(temp._refs)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._refs); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._refs); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._refs); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._refs); + } } - return true; - } - - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } - - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } - - /** - */ - public void removeAllRefs( - ) { - this._refs.clear(); + } else if (temp._refs != null) + return false; + return true; } - - /** - * Method removeRefs. - * - * @param vRefs - * @return true if the object was removed from the collection. - */ - public boolean removeRefs( - final java.lang.Object vRefs) { - boolean removed = _refs.remove(vRefs); - return removed; + return false; + } + + /** + * Returns the value of field 'content'. The field 'content' has the following + * description: internal content storage + * + * @return the value of field 'Content'. + */ + public java.lang.String getContent() { + return this._content; + } + + /** + * Returns the value of field 'id'. The field 'id' has the following + * description: Primary Key for vamsas object referencing + * + * + * @return the value of field 'Id'. + */ + public java.lang.String getId() { + return this._id; + } + + /** + * Method getRefs. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the java.lang.Object at the given index + */ + public java.lang.Object getRefs(final int index) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._refs.size()) { + throw new IndexOutOfBoundsException("getRefs: Index value '" + index + + "' not in range [0.." + (this._refs.size() - 1) + "]"); } - /** - * Method removeRefsAt. - * - * @param index - * @return the element removed from the collection - */ - public java.lang.Object removeRefsAt( - final int index) { - java.lang.Object obj = this._refs.remove(index); - return obj; + return _refs.get(index); + } + + /** + * Method getRefs.Returns the contents of the collection in an Array. + *

+ * Note: Just in case the collection contents are changing in another thread, + * we pass a 0-length Array of the correct type into the API call. This way we + * know that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public java.lang.Object[] getRefs() { + java.lang.Object[] array = new java.lang.Object[0]; + return (java.lang.Object[]) this._refs.toArray(array); + } + + /** + * Method getRefsAsReference.Returns a reference to '_refs'. No type checking + * is performed on any modifications to the Vector. + * + * @return a reference to the Vector backing this class + */ + public java.util.Vector getRefsAsReference() { + return this._refs; + } + + /** + * Method getRefsCount. + * + * @return the size of this collection + */ + public int getRefsCount() { + return this._refs.size(); + } + + /** + * Overrides the java.lang.Object.hashCode method. + *

+ * The following steps came from Effective Java Programming Language + * Guide by Joshua Bloch, Chapter 3 + * + * @return a hash code value for the object. + */ + public int hashCode() { + int result = super.hashCode(); + + long tmp; + if (_content != null + && !org.castor.util.CycleBreaker.startingToCycle(_content)) { + result = 37 * result + _content.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_content); } - - /** - * Sets the value of field 'content'. The field 'content' has - * the following description: internal content storage - * - * @param content the value of field 'content'. - */ - public void setContent( - final java.lang.String content) { - this._content = content; - } - - /** - * 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( - final java.lang.String id) { - this._id = id; + if (_id != null && !org.castor.util.CycleBreaker.startingToCycle(_id)) { + result = 37 * result + _id.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_id); } - - /** - * - * - * @param index - * @param vRefs - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setRefs( - final int index, - final java.lang.Object vRefs) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._refs.size()) { - throw new IndexOutOfBoundsException("setRefs: Index value '" + index + "' not in range [0.." + (this._refs.size() - 1) + "]"); - } - - this._refs.set(index, vRefs); + if (_refs != null && !org.castor.util.CycleBreaker.startingToCycle(_refs)) { + result = 37 * result + _refs.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_refs); } - /** - * - * - * @param vRefsArray - */ - public void setRefs( - final java.lang.Object[] vRefsArray) { - //-- copy array - _refs.clear(); - - for (int i = 0; i < vRefsArray.length; i++) { - this._refs.add(vRefsArray[i]); - } + return result; + } + + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() { + try { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) { + return false; } - - /** - * Sets the value of '_refs' by copying the given Vector. All - * elements will be checked for type safety. - * - * @param vRefsList the Vector to copy. + return true; + } + + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, out); + } + + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, handler); + } + + /** */ - public void setRefs( - final java.util.Vector vRefsList) { - // copy vector - this._refs.clear(); - - this._refs.addAll(vRefsList); + public void removeAllRefs() { + this._refs.clear(); + } + + /** + * Method removeRefs. + * + * @param vRefs + * @return true if the object was removed from the collection. + */ + public boolean removeRefs(final java.lang.Object vRefs) { + boolean removed = _refs.remove(vRefs); + return removed; + } + + /** + * Method removeRefsAt. + * + * @param index + * @return the element removed from the collection + */ + public java.lang.Object removeRefsAt(final int index) { + java.lang.Object obj = this._refs.remove(index); + return obj; + } + + /** + * Sets the value of field 'content'. The field 'content' has the following + * description: internal content storage + * + * @param content + * the value of field 'content'. + */ + public void setContent(final java.lang.String content) { + this._content = content; + } + + /** + * 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(final java.lang.String id) { + this._id = id; + } + + /** + * + * + * @param index + * @param vRefs + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setRefs(final int index, final java.lang.Object vRefs) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._refs.size()) { + throw new IndexOutOfBoundsException("setRefs: Index value '" + index + + "' not in range [0.." + (this._refs.size() - 1) + "]"); } - /** - * Sets the value of '_refs' by setting it to the given Vector. - * No type checking is performed. - * @deprecated - * - * @param refsVector the Vector to set. - */ - public void setRefsAsReference( - final java.util.Vector refsVector) { - this._refs = refsVector; - } + this._refs.set(index, vRefs); + } - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled - * uk.ac.vamsas.objects.core.ReferenceType - */ - public static uk.ac.vamsas.objects.core.ReferenceType unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (uk.ac.vamsas.objects.core.ReferenceType) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.ReferenceType.class, reader); - } + /** + * + * + * @param vRefsArray + */ + public void setRefs(final java.lang.Object[] vRefsArray) { + // -- copy array + _refs.clear(); - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); + for (int i = 0; i < vRefsArray.length; i++) { + this._refs.add(vRefsArray[i]); } + } + + /** + * Sets the value of '_refs' by copying the given Vector. All elements will be + * checked for type safety. + * + * @param vRefsList + * the Vector to copy. + */ + public void setRefs(final java.util.Vector vRefsList) { + // copy vector + this._refs.clear(); + + this._refs.addAll(vRefsList); + } + + /** + * Sets the value of '_refs' by setting it to the given Vector. No type + * checking is performed. + * + * @deprecated + * + * @param refsVector + * the Vector to set. + */ + public void setRefsAsReference(final java.util.Vector refsVector) { + this._refs = refsVector; + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @return the unmarshaled uk.ac.vamsas.objects.core.ReferenceType + */ + public static uk.ac.vamsas.objects.core.ReferenceType unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + return (uk.ac.vamsas.objects.core.ReferenceType) Unmarshaller.unmarshal( + uk.ac.vamsas.objects.core.ReferenceType.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/uk/ac/vamsas/objects/core/Score.java b/src/uk/ac/vamsas/objects/core/Score.java index 357deb2..bf0ce88 100644 --- a/src/uk/ac/vamsas/objects/core/Score.java +++ b/src/uk/ac/vamsas/objects/core/Score.java @@ -1,271 +1,282 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import org.exolab.castor.xml.Marshaller; import org.exolab.castor.xml.Unmarshaller; /** - * Ordered set of optionally named float values for the - * whole annotation + * Ordered set of optionally named float values for the whole annotation * * @version $Revision$ $Date$ */ -public class Score extends uk.ac.vamsas.client.Vobject -implements java.io.Serializable -{ +public class Score extends uk.ac.vamsas.client.Vobject implements + java.io.Serializable { + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ + /** + * internal content storage + */ + private float _content; - /** - * internal content storage - */ - private float _content; + /** + * keeps track of state for field: _content + */ + private boolean _has_content; - /** - * keeps track of state for field: _content - */ - private boolean _has_content; + /** + * Field _name. + */ + private java.lang.String _name = "score"; - /** - * Field _name. - */ - private java.lang.String _name = "score"; + // ----------------/ + // - Constructors -/ + // ----------------/ + public Score() { + super(); + setName("score"); + } - //----------------/ - //- Constructors -/ - //----------------/ + // -----------/ + // - Methods -/ + // -----------/ - public Score() { - super(); - setName("score"); - } + /** + */ + public void deleteContent() { + this._has_content = false; + } + /** + * Overrides the java.lang.Object.equals method. + * + * @param obj + * @return true if the objects are equal. + */ + public boolean equals(final java.lang.Object obj) { + if (this == obj) + return true; - //-----------/ - //- Methods -/ - //-----------/ + if (super.equals(obj) == false) + return false; - /** - */ - public void deleteContent( - ) { - this._has_content= false; - } + if (obj instanceof Score) { - /** - * Overrides the java.lang.Object.equals method. - * - * @param obj - * @return true if the objects are equal. - */ - public boolean equals( - final java.lang.Object obj) { - if ( this == obj ) - return true; - - if (super.equals(obj)==false) + Score temp = (Score) obj; + boolean thcycle; + boolean tmcycle; + if (this._content != temp._content) + return false; + if (this._has_content != temp._has_content) + return false; + if (this._name != null) { + if (temp._name == null) + return false; + if (this._name != temp._name) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._name); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._name); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._name); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._name); + } + ; return false; - - if (obj instanceof Score) { - - Score temp = (Score)obj; - boolean thcycle; - boolean tmcycle; - if (this._content != temp._content) - return false; - if (this._has_content != temp._has_content) - return false; - if (this._name != null) { - if (temp._name == null) return false; - if (this._name != temp._name) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._name); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._name); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._name); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._name); }; - return false; - } - if (!thcycle) { - if (!this._name.equals(temp._name)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._name); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._name); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._name); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._name); - } - } - } else if (temp._name != null) - return false; - return true; + } + if (!thcycle) { + if (!this._name.equals(temp._name)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._name); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._name); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._name); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._name); + } } + } else if (temp._name != null) return false; + return true; } + return false; + } - /** - * Returns the value of field 'content'. The field 'content' - * has the following description: internal content storage - * - * @return the value of field 'Content'. - */ - public float getContent( - ) { - return this._content; - } + /** + * Returns the value of field 'content'. The field 'content' has the following + * description: internal content storage + * + * @return the value of field 'Content'. + */ + public float getContent() { + return this._content; + } - /** - * Returns the value of field 'name'. - * - * @return the value of field 'Name'. - */ - public java.lang.String getName( - ) { - return this._name; - } + /** + * Returns the value of field 'name'. + * + * @return the value of field 'Name'. + */ + public java.lang.String getName() { + return this._name; + } - /** - * Method hasContent. - * - * @return true if at least one Content has been added - */ - public boolean hasContent( - ) { - return this._has_content; - } + /** + * Method hasContent. + * + * @return true if at least one Content has been added + */ + public boolean hasContent() { + return this._has_content; + } - /** - * Overrides the java.lang.Object.hashCode method. - *

- * The following steps came from Effective Java Programming - * Language Guide by Joshua Bloch, Chapter 3 - * - * @return a hash code value for the object. - */ - public int hashCode( - ) { - int result = super.hashCode(); - - long tmp; - result = 37 * result + java.lang.Float.floatToIntBits(_content); - if (_name != null - && !org.castor.util.CycleBreaker.startingToCycle(_name)) { - result = 37 * result + _name.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_name); - } - - return result; - } + /** + * Overrides the java.lang.Object.hashCode method. + *

+ * The following steps came from Effective Java Programming Language + * Guide by Joshua Bloch, Chapter 3 + * + * @return a hash code value for the object. + */ + public int hashCode() { + int result = super.hashCode(); - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { - return false; - } - return true; + long tmp; + result = 37 * result + java.lang.Float.floatToIntBits(_content); + if (_name != null && !org.castor.util.CycleBreaker.startingToCycle(_name)) { + result = 37 * result + _name.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_name); } - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } + return result; + } - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() { + try { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) { + return false; } + return true; + } - /** - * Sets the value of field 'content'. The field 'content' has - * the following description: internal content storage - * - * @param content the value of field 'content'. - */ - public void setContent( - final float content) { - this._content = content; - this._has_content = true; - } + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, out); + } - /** - * Sets the value of field 'name'. - * - * @param name the value of field 'name'. - */ - public void setName( - final java.lang.String name) { - this._name = name; - } + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, handler); + } - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled uk.ac.vamsas.objects.core.Score - */ - public static uk.ac.vamsas.objects.core.Score unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (uk.ac.vamsas.objects.core.Score) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.Score.class, reader); - } + /** + * Sets the value of field 'content'. The field 'content' has the following + * description: internal content storage + * + * @param content + * the value of field 'content'. + */ + public void setContent(final float content) { + this._content = content; + this._has_content = true; + } - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); - } + /** + * Sets the value of field 'name'. + * + * @param name + * the value of field 'name'. + */ + public void setName(final java.lang.String name) { + this._name = name; + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @return the unmarshaled uk.ac.vamsas.objects.core.Score + */ + public static uk.ac.vamsas.objects.core.Score unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + return (uk.ac.vamsas.objects.core.Score) Unmarshaller.unmarshal( + uk.ac.vamsas.objects.core.Score.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/uk/ac/vamsas/objects/core/Seg.java b/src/uk/ac/vamsas/objects/core/Seg.java index 5174b80..5ad851d 100644 --- a/src/uk/ac/vamsas/objects/core/Seg.java +++ b/src/uk/ac/vamsas/objects/core/Seg.java @@ -1,350 +1,342 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import org.exolab.castor.xml.Marshaller; import org.exolab.castor.xml.Unmarshaller; /** - * a region from start to end, with flag for inclusivity of - * terminii + * a region from start to end, with flag for inclusivity of terminii * * @version $Revision$ $Date$ */ -public class Seg extends uk.ac.vamsas.client.Vobject -implements java.io.Serializable -{ - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _start. - */ - private int _start; - - /** - * keeps track of state for field: _start - */ - private boolean _has_start; - - /** - * Field _end. - */ - private int _end; - - /** - * keeps track of state for field: _end - */ - private boolean _has_end; - - /** - * when false, a consecutive range like 'start=1, end=2' - * means the region lying after position 1 and before position - * 2 - * - */ - private boolean _inclusive; - - /** - * keeps track of state for field: _inclusive - */ - private boolean _has_inclusive; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public Seg() { - super(); - } - - - //-----------/ - //- Methods -/ - //-----------/ - - /** +public class Seg extends uk.ac.vamsas.client.Vobject implements + java.io.Serializable { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _start. + */ + private int _start; + + /** + * keeps track of state for field: _start + */ + private boolean _has_start; + + /** + * Field _end. + */ + private int _end; + + /** + * keeps track of state for field: _end + */ + private boolean _has_end; + + /** + * when false, a consecutive range like 'start=1, end=2' means the region + * lying after position 1 and before position 2 + * + */ + private boolean _inclusive; + + /** + * keeps track of state for field: _inclusive + */ + private boolean _has_inclusive; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public Seg() { + super(); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** */ - public void deleteEnd( - ) { - this._has_end= false; - } + public void deleteEnd() { + this._has_end = false; + } - /** + /** */ - public void deleteInclusive( - ) { - this._has_inclusive= false; - } + public void deleteInclusive() { + this._has_inclusive = false; + } - /** + /** */ - public void deleteStart( - ) { - this._has_start= false; - } - - /** - * Overrides the java.lang.Object.equals method. - * - * @param obj - * @return true if the objects are equal. - */ - public boolean equals( - final java.lang.Object obj) { - if ( this == obj ) - return true; - - if (super.equals(obj)==false) - return false; - - if (obj instanceof Seg) { - - Seg temp = (Seg)obj; - boolean thcycle; - boolean tmcycle; - if (this._start != temp._start) - return false; - if (this._has_start != temp._has_start) - return false; - if (this._end != temp._end) - return false; - if (this._has_end != temp._has_end) - return false; - if (this._inclusive != temp._inclusive) - return false; - if (this._has_inclusive != temp._has_inclusive) - return false; - return true; - } + public void deleteStart() { + this._has_start = false; + } + + /** + * Overrides the java.lang.Object.equals method. + * + * @param obj + * @return true if the objects are equal. + */ + public boolean equals(final java.lang.Object obj) { + if (this == obj) + return true; + + if (super.equals(obj) == false) + return false; + + if (obj instanceof Seg) { + + Seg temp = (Seg) obj; + boolean thcycle; + boolean tmcycle; + if (this._start != temp._start) return false; + if (this._has_start != temp._has_start) + return false; + if (this._end != temp._end) + return false; + if (this._has_end != temp._has_end) + return false; + if (this._inclusive != temp._inclusive) + return false; + if (this._has_inclusive != temp._has_inclusive) + return false; + return true; } - - /** - * Returns the value of field 'end'. - * - * @return the value of field 'End'. - */ - public int getEnd( - ) { - return this._end; - } - - /** - * Returns the value of field 'inclusive'. The field - * 'inclusive' has the following description: when false, a - * consecutive range like 'start=1, end=2' - * means the region lying after position 1 and before position - * 2 - * - * - * @return the value of field 'Inclusive'. - */ - public boolean getInclusive( - ) { - return this._inclusive; - } - - /** - * Returns the value of field 'start'. - * - * @return the value of field 'Start'. - */ - public int getStart( - ) { - return this._start; - } - - /** - * Method hasEnd. - * - * @return true if at least one End has been added - */ - public boolean hasEnd( - ) { - return this._has_end; - } - - /** - * Method hasInclusive. - * - * @return true if at least one Inclusive has been added - */ - public boolean hasInclusive( - ) { - return this._has_inclusive; - } - - /** - * Method hasStart. - * - * @return true if at least one Start has been added - */ - public boolean hasStart( - ) { - return this._has_start; - } - - /** - * Overrides the java.lang.Object.hashCode method. - *

- * The following steps came from Effective Java Programming - * Language Guide by Joshua Bloch, Chapter 3 - * - * @return a hash code value for the object. - */ - public int hashCode( - ) { - int result = super.hashCode(); - - long tmp; - result = 37 * result + _start; - result = 37 * result + _end; - result = 37 * result + (_inclusive?0:1); - - return result; - } - - /** - * Returns the value of field 'inclusive'. The field - * 'inclusive' has the following description: when false, a - * consecutive range like 'start=1, end=2' - * means the region lying after position 1 and before position - * 2 - * - * - * @return the value of field 'Inclusive'. - */ - public boolean isInclusive( - ) { - return this._inclusive; - } - - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { - return false; - } - return true; - } - - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } - - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } - - /** - * Sets the value of field 'end'. - * - * @param end the value of field 'end'. - */ - public void setEnd( - final int end) { - this._end = end; - this._has_end = true; - } - - /** - * Sets the value of field 'inclusive'. The field 'inclusive' - * has the following description: when false, a consecutive - * range like 'start=1, end=2' - * means the region lying after position 1 and before position - * 2 - * - * - * @param inclusive the value of field 'inclusive'. - */ - public void setInclusive( - final boolean inclusive) { - this._inclusive = inclusive; - this._has_inclusive = true; - } - - /** - * Sets the value of field 'start'. - * - * @param start the value of field 'start'. - */ - public void setStart( - final int start) { - this._start = start; - this._has_start = true; - } - - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled uk.ac.vamsas.objects.core.Seg - */ - public static uk.ac.vamsas.objects.core.Seg unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (uk.ac.vamsas.objects.core.Seg) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.Seg.class, reader); - } - - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); + return false; + } + + /** + * Returns the value of field 'end'. + * + * @return the value of field 'End'. + */ + public int getEnd() { + return this._end; + } + + /** + * Returns the value of field 'inclusive'. The field 'inclusive' has the + * following description: when false, a consecutive range like 'start=1, + * end=2' means the region lying after position 1 and before position 2 + * + * + * @return the value of field 'Inclusive'. + */ + public boolean getInclusive() { + return this._inclusive; + } + + /** + * Returns the value of field 'start'. + * + * @return the value of field 'Start'. + */ + public int getStart() { + return this._start; + } + + /** + * Method hasEnd. + * + * @return true if at least one End has been added + */ + public boolean hasEnd() { + return this._has_end; + } + + /** + * Method hasInclusive. + * + * @return true if at least one Inclusive has been added + */ + public boolean hasInclusive() { + return this._has_inclusive; + } + + /** + * Method hasStart. + * + * @return true if at least one Start has been added + */ + public boolean hasStart() { + return this._has_start; + } + + /** + * Overrides the java.lang.Object.hashCode method. + *

+ * The following steps came from Effective Java Programming Language + * Guide by Joshua Bloch, Chapter 3 + * + * @return a hash code value for the object. + */ + public int hashCode() { + int result = super.hashCode(); + + long tmp; + result = 37 * result + _start; + result = 37 * result + _end; + result = 37 * result + (_inclusive ? 0 : 1); + + return result; + } + + /** + * Returns the value of field 'inclusive'. The field 'inclusive' has the + * following description: when false, a consecutive range like 'start=1, + * end=2' means the region lying after position 1 and before position 2 + * + * + * @return the value of field 'Inclusive'. + */ + public boolean isInclusive() { + return this._inclusive; + } + + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() { + try { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) { + return false; } + return true; + } + + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, out); + } + + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, handler); + } + + /** + * Sets the value of field 'end'. + * + * @param end + * the value of field 'end'. + */ + public void setEnd(final int end) { + this._end = end; + this._has_end = true; + } + + /** + * Sets the value of field 'inclusive'. The field 'inclusive' has the + * following description: when false, a consecutive range like 'start=1, + * end=2' means the region lying after position 1 and before position 2 + * + * + * @param inclusive + * the value of field 'inclusive'. + */ + public void setInclusive(final boolean inclusive) { + this._inclusive = inclusive; + this._has_inclusive = true; + } + + /** + * Sets the value of field 'start'. + * + * @param start + * the value of field 'start'. + */ + public void setStart(final int start) { + this._start = start; + this._has_start = true; + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @return the unmarshaled uk.ac.vamsas.objects.core.Seg + */ + public static uk.ac.vamsas.objects.core.Seg unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + return (uk.ac.vamsas.objects.core.Seg) Unmarshaller.unmarshal( + uk.ac.vamsas.objects.core.Seg.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/uk/ac/vamsas/objects/core/Sequence.java b/src/uk/ac/vamsas/objects/core/Sequence.java index 519f57a..461b7d1 100644 --- a/src/uk/ac/vamsas/objects/core/Sequence.java +++ b/src/uk/ac/vamsas/objects/core/Sequence.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import org.exolab.castor.xml.Marshaller; @@ -17,708 +31,707 @@ import org.exolab.castor.xml.Unmarshaller; /** * Class Sequence. * - * @version $Revision$ $Date$ + * @version $Revision$ $Date: 2007-06-28 14:51:44 +0100 (Thu, 28 Jun 2007) + * $ */ -public class Sequence extends uk.ac.vamsas.objects.core.SequenceType -implements java.io.Serializable -{ - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Primary Key for vamsas object referencing - * - */ - private java.lang.String _id; - - /** - * symbol class for sequence - * - */ - private java.lang.String _dictionary; - - /** - * Store a list of database references - * for this sequence record - with optional mapping - * from database sequence to the given sequence record - */ - private java.util.Vector _dbRefList; - - /** - * explicitly named cross reference to - * other objects in the document. - */ - private java.util.Vector _vxrefList; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public Sequence() { - super(); - this._dbRefList = new java.util.Vector(); - this._vxrefList = new java.util.Vector(); - } - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * - * - * @param vDbRef - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addDbRef( - final uk.ac.vamsas.objects.core.DbRef vDbRef) - throws java.lang.IndexOutOfBoundsException { - this._dbRefList.addElement(vDbRef); - } - - /** - * - * - * @param index - * @param vDbRef - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addDbRef( - final int index, - final uk.ac.vamsas.objects.core.DbRef vDbRef) - throws java.lang.IndexOutOfBoundsException { - this._dbRefList.add(index, vDbRef); - } - - /** - * - * - * @param vVxref - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addVxref( - final uk.ac.vamsas.objects.core.Vxref vVxref) - throws java.lang.IndexOutOfBoundsException { - this._vxrefList.addElement(vVxref); - } - - /** - * - * - * @param index - * @param vVxref - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addVxref( - final int index, - final uk.ac.vamsas.objects.core.Vxref vVxref) - throws java.lang.IndexOutOfBoundsException { - this._vxrefList.add(index, vVxref); - } - - /** - * Method enumerateDbRef. - * - * @return an Enumeration over all - * uk.ac.vamsas.objects.core.DbRef elements - */ - public java.util.Enumeration enumerateDbRef( - ) { - return this._dbRefList.elements(); - } - - /** - * Method enumerateVxref. - * - * @return an Enumeration over all - * uk.ac.vamsas.objects.core.Vxref elements - */ - public java.util.Enumeration enumerateVxref( - ) { - return this._vxrefList.elements(); - } - - /** - * Overrides the java.lang.Object.equals method. - * - * @param obj - * @return true if the objects are equal. - */ - public boolean equals( - final java.lang.Object obj) { - if ( this == obj ) - return true; - - if (super.equals(obj)==false) +public class Sequence extends uk.ac.vamsas.objects.core.SequenceType implements + java.io.Serializable { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Primary Key for vamsas object referencing + * + */ + private java.lang.String _id; + + /** + * symbol class for sequence + * + */ + private java.lang.String _dictionary; + + /** + * Store a list of database references for this sequence record - with + * optional mapping from database sequence to the given sequence record + */ + private java.util.Vector _dbRefList; + + /** + * explicitly named cross reference to other objects in the document. + */ + private java.util.Vector _vxrefList; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public Sequence() { + super(); + this._dbRefList = new java.util.Vector(); + this._vxrefList = new java.util.Vector(); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * + * + * @param vDbRef + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addDbRef(final uk.ac.vamsas.objects.core.DbRef vDbRef) + throws java.lang.IndexOutOfBoundsException { + this._dbRefList.addElement(vDbRef); + } + + /** + * + * + * @param index + * @param vDbRef + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addDbRef(final int index, + final uk.ac.vamsas.objects.core.DbRef vDbRef) + throws java.lang.IndexOutOfBoundsException { + this._dbRefList.add(index, vDbRef); + } + + /** + * + * + * @param vVxref + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addVxref(final uk.ac.vamsas.objects.core.Vxref vVxref) + throws java.lang.IndexOutOfBoundsException { + this._vxrefList.addElement(vVxref); + } + + /** + * + * + * @param index + * @param vVxref + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addVxref(final int index, + final uk.ac.vamsas.objects.core.Vxref vVxref) + throws java.lang.IndexOutOfBoundsException { + this._vxrefList.add(index, vVxref); + } + + /** + * Method enumerateDbRef. + * + * @return an Enumeration over all uk.ac.vamsas.objects.core.DbRef elements + */ + public java.util.Enumeration enumerateDbRef() { + return this._dbRefList.elements(); + } + + /** + * Method enumerateVxref. + * + * @return an Enumeration over all uk.ac.vamsas.objects.core.Vxref elements + */ + public java.util.Enumeration enumerateVxref() { + return this._vxrefList.elements(); + } + + /** + * Overrides the java.lang.Object.equals method. + * + * @param obj + * @return true if the objects are equal. + */ + public boolean equals(final java.lang.Object obj) { + if (this == obj) + return true; + + if (super.equals(obj) == false) + return false; + + if (obj instanceof Sequence) { + + Sequence temp = (Sequence) obj; + boolean thcycle; + boolean tmcycle; + if (this._id != null) { + if (temp._id == null) + return false; + if (this._id != temp._id) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._id); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._id); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._id); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); + } + ; return false; - - if (obj instanceof Sequence) { - - Sequence temp = (Sequence)obj; - boolean thcycle; - boolean tmcycle; - if (this._id != null) { - if (temp._id == null) return false; - if (this._id != temp._id) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._id); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._id); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._id); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); }; - return false; - } - if (!thcycle) { - if (!this._id.equals(temp._id)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._id); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._id); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); - } - } - } else if (temp._id != null) - return false; - if (this._dictionary != null) { - if (temp._dictionary == null) return false; - if (this._dictionary != temp._dictionary) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._dictionary); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._dictionary); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._dictionary); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._dictionary); }; - return false; - } - if (!thcycle) { - if (!this._dictionary.equals(temp._dictionary)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._dictionary); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._dictionary); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._dictionary); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._dictionary); - } - } - } else if (temp._dictionary != null) - return false; - if (this._dbRefList != null) { - if (temp._dbRefList == null) return false; - if (this._dbRefList != temp._dbRefList) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._dbRefList); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._dbRefList); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._dbRefList); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._dbRefList); }; - return false; - } - if (!thcycle) { - if (!this._dbRefList.equals(temp._dbRefList)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._dbRefList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._dbRefList); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._dbRefList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._dbRefList); - } - } - } else if (temp._dbRefList != null) - return false; - if (this._vxrefList != null) { - if (temp._vxrefList == null) return false; - if (this._vxrefList != temp._vxrefList) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._vxrefList); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._vxrefList); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._vxrefList); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._vxrefList); }; - return false; - } - if (!thcycle) { - if (!this._vxrefList.equals(temp._vxrefList)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._vxrefList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._vxrefList); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._vxrefList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._vxrefList); - } - } - } else if (temp._vxrefList != null) - return false; - return true; + } + if (!thcycle) { + if (!this._id.equals(temp._id)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._id); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._id); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); + } } + } else if (temp._id != null) return false; - } - - /** - * Method getDbRef. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the uk.ac.vamsas.objects.core.DbRef at - * the given index - */ - public uk.ac.vamsas.objects.core.DbRef getDbRef( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._dbRefList.size()) { - throw new IndexOutOfBoundsException("getDbRef: Index value '" + index + "' not in range [0.." + (this._dbRefList.size() - 1) + "]"); - } - - return (uk.ac.vamsas.objects.core.DbRef) _dbRefList.get(index); - } - - /** - * Method getDbRef.Returns the contents of the collection in an - * Array.

Note: Just in case the collection contents are - * changing in another thread, we pass a 0-length Array of the - * correct type into the API call. This way we know - * that the Array returned is of exactly the correct length. - * - * @return this collection as an Array - */ - public uk.ac.vamsas.objects.core.DbRef[] getDbRef( - ) { - uk.ac.vamsas.objects.core.DbRef[] array = new uk.ac.vamsas.objects.core.DbRef[0]; - return (uk.ac.vamsas.objects.core.DbRef[]) this._dbRefList.toArray(array); - } - - /** - * Method getDbRefAsReference.Returns a reference to - * '_dbRefList'. No type checking is performed on any - * modifications to the Vector. - * - * @return a reference to the Vector backing this class - */ - public java.util.Vector getDbRefAsReference( - ) { - return this._dbRefList; - } - - /** - * Method getDbRefCount. - * - * @return the size of this collection - */ - public int getDbRefCount( - ) { - return this._dbRefList.size(); - } - - /** - * Returns the value of field 'dictionary'. The field - * 'dictionary' has the following description: symbol class for - * sequence - * - * - * @return the value of field 'Dictionary'. - */ - public java.lang.String getDictionary( - ) { - return this._dictionary; - } - - /** - * Returns the value of field 'id'. The field 'id' has the - * following description: Primary Key for vamsas object - * referencing - * - * - * @return the value of field 'Id'. - */ - public java.lang.String getId( - ) { - return this._id; - } - - /** - * Method getVxref. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the uk.ac.vamsas.objects.core.Vxref at - * the given index - */ - public uk.ac.vamsas.objects.core.Vxref getVxref( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._vxrefList.size()) { - throw new IndexOutOfBoundsException("getVxref: Index value '" + index + "' not in range [0.." + (this._vxrefList.size() - 1) + "]"); - } - - return (uk.ac.vamsas.objects.core.Vxref) _vxrefList.get(index); - } - - /** - * Method getVxref.Returns the contents of the collection in an - * Array.

Note: Just in case the collection contents are - * changing in another thread, we pass a 0-length Array of the - * correct type into the API call. This way we know - * that the Array returned is of exactly the correct length. - * - * @return this collection as an Array - */ - public uk.ac.vamsas.objects.core.Vxref[] getVxref( - ) { - uk.ac.vamsas.objects.core.Vxref[] array = new uk.ac.vamsas.objects.core.Vxref[0]; - return (uk.ac.vamsas.objects.core.Vxref[]) this._vxrefList.toArray(array); - } - - /** - * Method getVxrefAsReference.Returns a reference to - * '_vxrefList'. No type checking is performed on any - * modifications to the Vector. - * - * @return a reference to the Vector backing this class - */ - public java.util.Vector getVxrefAsReference( - ) { - return this._vxrefList; - } - - /** - * Method getVxrefCount. - * - * @return the size of this collection - */ - public int getVxrefCount( - ) { - return this._vxrefList.size(); - } - - /** - * Overrides the java.lang.Object.hashCode method. - *

- * The following steps came from Effective Java Programming - * Language Guide by Joshua Bloch, Chapter 3 - * - * @return a hash code value for the object. - */ - public int hashCode( - ) { - int result = super.hashCode(); - - long tmp; - if (_id != null - && !org.castor.util.CycleBreaker.startingToCycle(_id)) { - result = 37 * result + _id.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_id); - } - if (_dictionary != null - && !org.castor.util.CycleBreaker.startingToCycle(_dictionary)) { - result = 37 * result + _dictionary.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_dictionary); - } - if (_dbRefList != null - && !org.castor.util.CycleBreaker.startingToCycle(_dbRefList)) { - result = 37 * result + _dbRefList.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_dbRefList); - } - if (_vxrefList != null - && !org.castor.util.CycleBreaker.startingToCycle(_vxrefList)) { - result = 37 * result + _vxrefList.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_vxrefList); - } - - return result; - } - - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { + if (this._dictionary != null) { + if (temp._dictionary == null) + return false; + if (this._dictionary != temp._dictionary) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._dictionary); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._dictionary); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._dictionary); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._dictionary); + } + ; return false; + } + if (!thcycle) { + if (!this._dictionary.equals(temp._dictionary)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._dictionary); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._dictionary); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._dictionary); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._dictionary); + } } - return true; - } - - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } - - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } - - /** - */ - public void removeAllDbRef( - ) { - this._dbRefList.clear(); - } - - /** - */ - public void removeAllVxref( - ) { - this._vxrefList.clear(); - } - - /** - * Method removeDbRef. - * - * @param vDbRef - * @return true if the object was removed from the collection. - */ - public boolean removeDbRef( - final uk.ac.vamsas.objects.core.DbRef vDbRef) { - boolean removed = _dbRefList.remove(vDbRef); - return removed; - } - - /** - * Method removeDbRefAt. - * - * @param index - * @return the element removed from the collection - */ - public uk.ac.vamsas.objects.core.DbRef removeDbRefAt( - final int index) { - java.lang.Object obj = this._dbRefList.remove(index); - return (uk.ac.vamsas.objects.core.DbRef) obj; - } - - /** - * Method removeVxref. - * - * @param vVxref - * @return true if the object was removed from the collection. - */ - public boolean removeVxref( - final uk.ac.vamsas.objects.core.Vxref vVxref) { - boolean removed = _vxrefList.remove(vVxref); - return removed; - } - - /** - * Method removeVxrefAt. - * - * @param index - * @return the element removed from the collection - */ - public uk.ac.vamsas.objects.core.Vxref removeVxrefAt( - final int index) { - java.lang.Object obj = this._vxrefList.remove(index); - return (uk.ac.vamsas.objects.core.Vxref) obj; - } - - /** - * - * - * @param index - * @param vDbRef - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setDbRef( - final int index, - final uk.ac.vamsas.objects.core.DbRef vDbRef) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._dbRefList.size()) { - throw new IndexOutOfBoundsException("setDbRef: Index value '" + index + "' not in range [0.." + (this._dbRefList.size() - 1) + "]"); - } - - this._dbRefList.set(index, vDbRef); - } - - /** - * - * - * @param vDbRefArray - */ - public void setDbRef( - final uk.ac.vamsas.objects.core.DbRef[] vDbRefArray) { - //-- copy array - _dbRefList.clear(); - - for (int i = 0; i < vDbRefArray.length; i++) { - this._dbRefList.add(vDbRefArray[i]); - } - } - - /** - * Sets the value of '_dbRefList' by copying the given Vector. - * All elements will be checked for type safety. - * - * @param vDbRefList the Vector to copy. - */ - public void setDbRef( - final java.util.Vector vDbRefList) { - // copy vector - this._dbRefList.clear(); - - this._dbRefList.addAll(vDbRefList); - } - - /** - * Sets the value of '_dbRefList' by setting it to the given - * Vector. No type checking is performed. - * @deprecated - * - * @param dbRefVector the Vector to set. - */ - public void setDbRefAsReference( - final java.util.Vector dbRefVector) { - this._dbRefList = dbRefVector; - } - - /** - * Sets the value of field 'dictionary'. The field 'dictionary' - * has the following description: symbol class for sequence - * - * - * @param dictionary the value of field 'dictionary'. - */ - public void setDictionary( - final java.lang.String dictionary) { - this._dictionary = dictionary; - } - - /** - * 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( - final java.lang.String id) { - this._id = id; - } - - /** - * - * - * @param index - * @param vVxref - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setVxref( - final int index, - final uk.ac.vamsas.objects.core.Vxref vVxref) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._vxrefList.size()) { - throw new IndexOutOfBoundsException("setVxref: Index value '" + index + "' not in range [0.." + (this._vxrefList.size() - 1) + "]"); + } else if (temp._dictionary != null) + return false; + if (this._dbRefList != null) { + if (temp._dbRefList == null) + return false; + if (this._dbRefList != temp._dbRefList) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._dbRefList); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._dbRefList); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._dbRefList); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._dbRefList); + } + ; + return false; + } + if (!thcycle) { + if (!this._dbRefList.equals(temp._dbRefList)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._dbRefList); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._dbRefList); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._dbRefList); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._dbRefList); + } } - - this._vxrefList.set(index, vVxref); - } - - /** - * - * - * @param vVxrefArray - */ - public void setVxref( - final uk.ac.vamsas.objects.core.Vxref[] vVxrefArray) { - //-- copy array - _vxrefList.clear(); - - for (int i = 0; i < vVxrefArray.length; i++) { - this._vxrefList.add(vVxrefArray[i]); + } else if (temp._dbRefList != null) + return false; + if (this._vxrefList != null) { + if (temp._vxrefList == null) + return false; + if (this._vxrefList != temp._vxrefList) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._vxrefList); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._vxrefList); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._vxrefList); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._vxrefList); + } + ; + return false; + } + if (!thcycle) { + if (!this._vxrefList.equals(temp._vxrefList)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._vxrefList); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._vxrefList); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._vxrefList); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._vxrefList); + } } - } - - /** - * Sets the value of '_vxrefList' by copying the given Vector. - * All elements will be checked for type safety. - * - * @param vVxrefList the Vector to copy. - */ - public void setVxref( - final java.util.Vector vVxrefList) { - // copy vector - this._vxrefList.clear(); - - this._vxrefList.addAll(vVxrefList); - } - - /** - * Sets the value of '_vxrefList' by setting it to the given - * Vector. No type checking is performed. - * @deprecated - * - * @param vxrefVector the Vector to set. - */ - public void setVxrefAsReference( - final java.util.Vector vxrefVector) { - this._vxrefList = vxrefVector; - } - - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled uk.ac.vamsas.objects.core.SequenceTyp - */ - public static uk.ac.vamsas.objects.core.SequenceType unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (uk.ac.vamsas.objects.core.SequenceType) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.Sequence.class, reader); - } - - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); - } + } else if (temp._vxrefList != null) + return false; + return true; + } + return false; + } + + /** + * Method getDbRef. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the uk.ac.vamsas.objects.core.DbRef at the given index + */ + public uk.ac.vamsas.objects.core.DbRef getDbRef(final int index) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._dbRefList.size()) { + throw new IndexOutOfBoundsException("getDbRef: Index value '" + index + + "' not in range [0.." + (this._dbRefList.size() - 1) + "]"); + } + + return (uk.ac.vamsas.objects.core.DbRef) _dbRefList.get(index); + } + + /** + * Method getDbRef.Returns the contents of the collection in an Array. + *

+ * Note: Just in case the collection contents are changing in another thread, + * we pass a 0-length Array of the correct type into the API call. This way we + * know that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public uk.ac.vamsas.objects.core.DbRef[] getDbRef() { + uk.ac.vamsas.objects.core.DbRef[] array = new uk.ac.vamsas.objects.core.DbRef[0]; + return (uk.ac.vamsas.objects.core.DbRef[]) this._dbRefList.toArray(array); + } + + /** + * Method getDbRefAsReference.Returns a reference to '_dbRefList'. No type + * checking is performed on any modifications to the Vector. + * + * @return a reference to the Vector backing this class + */ + public java.util.Vector getDbRefAsReference() { + return this._dbRefList; + } + + /** + * Method getDbRefCount. + * + * @return the size of this collection + */ + public int getDbRefCount() { + return this._dbRefList.size(); + } + + /** + * Returns the value of field 'dictionary'. The field 'dictionary' has the + * following description: symbol class for sequence + * + * + * @return the value of field 'Dictionary'. + */ + public java.lang.String getDictionary() { + return this._dictionary; + } + + /** + * Returns the value of field 'id'. The field 'id' has the following + * description: Primary Key for vamsas object referencing + * + * + * @return the value of field 'Id'. + */ + public java.lang.String getId() { + return this._id; + } + + /** + * Method getVxref. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the uk.ac.vamsas.objects.core.Vxref at the given index + */ + public uk.ac.vamsas.objects.core.Vxref getVxref(final int index) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._vxrefList.size()) { + throw new IndexOutOfBoundsException("getVxref: Index value '" + index + + "' not in range [0.." + (this._vxrefList.size() - 1) + "]"); + } + + return (uk.ac.vamsas.objects.core.Vxref) _vxrefList.get(index); + } + + /** + * Method getVxref.Returns the contents of the collection in an Array. + *

+ * Note: Just in case the collection contents are changing in another thread, + * we pass a 0-length Array of the correct type into the API call. This way we + * know that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public uk.ac.vamsas.objects.core.Vxref[] getVxref() { + uk.ac.vamsas.objects.core.Vxref[] array = new uk.ac.vamsas.objects.core.Vxref[0]; + return (uk.ac.vamsas.objects.core.Vxref[]) this._vxrefList.toArray(array); + } + + /** + * Method getVxrefAsReference.Returns a reference to '_vxrefList'. No type + * checking is performed on any modifications to the Vector. + * + * @return a reference to the Vector backing this class + */ + public java.util.Vector getVxrefAsReference() { + return this._vxrefList; + } + + /** + * Method getVxrefCount. + * + * @return the size of this collection + */ + public int getVxrefCount() { + return this._vxrefList.size(); + } + + /** + * Overrides the java.lang.Object.hashCode method. + *

+ * The following steps came from Effective Java Programming Language + * Guide by Joshua Bloch, Chapter 3 + * + * @return a hash code value for the object. + */ + public int hashCode() { + int result = super.hashCode(); + + long tmp; + if (_id != null && !org.castor.util.CycleBreaker.startingToCycle(_id)) { + result = 37 * result + _id.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_id); + } + if (_dictionary != null + && !org.castor.util.CycleBreaker.startingToCycle(_dictionary)) { + result = 37 * result + _dictionary.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_dictionary); + } + if (_dbRefList != null + && !org.castor.util.CycleBreaker.startingToCycle(_dbRefList)) { + result = 37 * result + _dbRefList.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_dbRefList); + } + if (_vxrefList != null + && !org.castor.util.CycleBreaker.startingToCycle(_vxrefList)) { + result = 37 * result + _vxrefList.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_vxrefList); + } + + return result; + } + + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() { + try { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) { + return false; + } + return true; + } + + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, out); + } + + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, handler); + } + + /** + */ + public void removeAllDbRef() { + this._dbRefList.clear(); + } + + /** + */ + public void removeAllVxref() { + this._vxrefList.clear(); + } + + /** + * Method removeDbRef. + * + * @param vDbRef + * @return true if the object was removed from the collection. + */ + public boolean removeDbRef(final uk.ac.vamsas.objects.core.DbRef vDbRef) { + boolean removed = _dbRefList.remove(vDbRef); + return removed; + } + + /** + * Method removeDbRefAt. + * + * @param index + * @return the element removed from the collection + */ + public uk.ac.vamsas.objects.core.DbRef removeDbRefAt(final int index) { + java.lang.Object obj = this._dbRefList.remove(index); + return (uk.ac.vamsas.objects.core.DbRef) obj; + } + + /** + * Method removeVxref. + * + * @param vVxref + * @return true if the object was removed from the collection. + */ + public boolean removeVxref(final uk.ac.vamsas.objects.core.Vxref vVxref) { + boolean removed = _vxrefList.remove(vVxref); + return removed; + } + + /** + * Method removeVxrefAt. + * + * @param index + * @return the element removed from the collection + */ + public uk.ac.vamsas.objects.core.Vxref removeVxrefAt(final int index) { + java.lang.Object obj = this._vxrefList.remove(index); + return (uk.ac.vamsas.objects.core.Vxref) obj; + } + + /** + * + * + * @param index + * @param vDbRef + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setDbRef(final int index, + final uk.ac.vamsas.objects.core.DbRef vDbRef) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._dbRefList.size()) { + throw new IndexOutOfBoundsException("setDbRef: Index value '" + index + + "' not in range [0.." + (this._dbRefList.size() - 1) + "]"); + } + + this._dbRefList.set(index, vDbRef); + } + + /** + * + * + * @param vDbRefArray + */ + public void setDbRef(final uk.ac.vamsas.objects.core.DbRef[] vDbRefArray) { + // -- copy array + _dbRefList.clear(); + + for (int i = 0; i < vDbRefArray.length; i++) { + this._dbRefList.add(vDbRefArray[i]); + } + } + + /** + * Sets the value of '_dbRefList' by copying the given Vector. All elements + * will be checked for type safety. + * + * @param vDbRefList + * the Vector to copy. + */ + public void setDbRef(final java.util.Vector vDbRefList) { + // copy vector + this._dbRefList.clear(); + + this._dbRefList.addAll(vDbRefList); + } + + /** + * Sets the value of '_dbRefList' by setting it to the given Vector. No type + * checking is performed. + * + * @deprecated + * + * @param dbRefVector + * the Vector to set. + */ + public void setDbRefAsReference(final java.util.Vector dbRefVector) { + this._dbRefList = dbRefVector; + } + + /** + * Sets the value of field 'dictionary'. The field 'dictionary' has the + * following description: symbol class for sequence + * + * + * @param dictionary + * the value of field 'dictionary'. + */ + public void setDictionary(final java.lang.String dictionary) { + this._dictionary = dictionary; + } + + /** + * 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(final java.lang.String id) { + this._id = id; + } + + /** + * + * + * @param index + * @param vVxref + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setVxref(final int index, + final uk.ac.vamsas.objects.core.Vxref vVxref) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._vxrefList.size()) { + throw new IndexOutOfBoundsException("setVxref: Index value '" + index + + "' not in range [0.." + (this._vxrefList.size() - 1) + "]"); + } + + this._vxrefList.set(index, vVxref); + } + + /** + * + * + * @param vVxrefArray + */ + public void setVxref(final uk.ac.vamsas.objects.core.Vxref[] vVxrefArray) { + // -- copy array + _vxrefList.clear(); + + for (int i = 0; i < vVxrefArray.length; i++) { + this._vxrefList.add(vVxrefArray[i]); + } + } + + /** + * Sets the value of '_vxrefList' by copying the given Vector. All elements + * will be checked for type safety. + * + * @param vVxrefList + * the Vector to copy. + */ + public void setVxref(final java.util.Vector vVxrefList) { + // copy vector + this._vxrefList.clear(); + + this._vxrefList.addAll(vVxrefList); + } + + /** + * Sets the value of '_vxrefList' by setting it to the given Vector. No type + * checking is performed. + * + * @deprecated + * + * @param vxrefVector + * the Vector to set. + */ + public void setVxrefAsReference(final java.util.Vector vxrefVector) { + this._vxrefList = vxrefVector; + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @return the unmarshaled uk.ac.vamsas.objects.core.SequenceTyp + */ + public static uk.ac.vamsas.objects.core.SequenceType unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + return (uk.ac.vamsas.objects.core.SequenceType) Unmarshaller.unmarshal( + uk.ac.vamsas.objects.core.Sequence.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/uk/ac/vamsas/objects/core/SequenceMapping.java b/src/uk/ac/vamsas/objects/core/SequenceMapping.java index 7f7bcb0..9370bae 100644 --- a/src/uk/ac/vamsas/objects/core/SequenceMapping.java +++ b/src/uk/ac/vamsas/objects/core/SequenceMapping.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import org.exolab.castor.xml.Marshaller; @@ -19,362 +33,376 @@ import org.exolab.castor.xml.Unmarshaller; * * @version $Revision$ $Date$ */ -public class SequenceMapping extends uk.ac.vamsas.objects.core.MapType -implements java.io.Serializable -{ +public class SequenceMapping extends uk.ac.vamsas.objects.core.MapType + implements java.io.Serializable { + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ + /** + * Object on which the local range is defined. + */ + private java.lang.Object _loc; - /** - * Object on which the local - * range is defined. - */ - private java.lang.Object _loc; + /** + * Object on which the mapped range is defined. + */ + private java.lang.Object _map; - /** - * Object on which the mapped - * range is defined. - */ - private java.lang.Object _map; + /** + * Field _id. + */ + private java.lang.String _id; - /** - * Field _id. - */ - private java.lang.String _id; + /** + * Field _provenance. + */ + private uk.ac.vamsas.objects.core.Provenance _provenance; - /** - * Field _provenance. - */ - private uk.ac.vamsas.objects.core.Provenance _provenance; + // ----------------/ + // - Constructors -/ + // ----------------/ + public SequenceMapping() { + super(); + } - //----------------/ - //- Constructors -/ - //----------------/ + // -----------/ + // - Methods -/ + // -----------/ - public SequenceMapping() { - super(); - } + /** + * Overrides the java.lang.Object.equals method. + * + * @param obj + * @return true if the objects are equal. + */ + public boolean equals(final java.lang.Object obj) { + if (this == obj) + return true; + + if (super.equals(obj) == false) + return false; + if (obj instanceof SequenceMapping) { - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Overrides the java.lang.Object.equals method. - * - * @param obj - * @return true if the objects are equal. - */ - public boolean equals( - final java.lang.Object obj) { - if ( this == obj ) - return true; - - if (super.equals(obj)==false) + SequenceMapping temp = (SequenceMapping) obj; + boolean thcycle; + boolean tmcycle; + if (this._loc != null) { + if (temp._loc == null) + return false; + if (this._loc != temp._loc) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._loc); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._loc); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._loc); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._loc); + } + ; + return false; + } + if (!thcycle) { + if (!this._loc.equals(temp._loc)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._loc); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._loc); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._loc); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._loc); + } + } + } else if (temp._loc != null) + return false; + if (this._map != null) { + if (temp._map == null) + return false; + if (this._map != temp._map) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._map); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._map); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._map); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._map); + } + ; return false; - - if (obj instanceof SequenceMapping) { - - SequenceMapping temp = (SequenceMapping)obj; - boolean thcycle; - boolean tmcycle; - if (this._loc != null) { - if (temp._loc == null) return false; - if (this._loc != temp._loc) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._loc); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._loc); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._loc); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._loc); }; - return false; - } - if (!thcycle) { - if (!this._loc.equals(temp._loc)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._loc); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._loc); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._loc); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._loc); - } - } - } else if (temp._loc != null) - return false; - if (this._map != null) { - if (temp._map == null) return false; - if (this._map != temp._map) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._map); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._map); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._map); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._map); }; - return false; - } - if (!thcycle) { - if (!this._map.equals(temp._map)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._map); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._map); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._map); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._map); - } - } - } else if (temp._map != null) - return false; - if (this._id != null) { - if (temp._id == null) return false; - if (this._id != temp._id) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._id); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._id); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._id); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); }; - return false; - } - if (!thcycle) { - if (!this._id.equals(temp._id)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._id); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._id); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); - } - } - } else if (temp._id != null) - return false; - if (this._provenance != null) { - if (temp._provenance == null) return false; - if (this._provenance != temp._provenance) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._provenance); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._provenance); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance); }; - return false; - } - if (!thcycle) { - if (!this._provenance.equals(temp._provenance)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance); - } - } - } else if (temp._provenance != null) - return false; - return true; + } + if (!thcycle) { + if (!this._map.equals(temp._map)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._map); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._map); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._map); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._map); + } } + } else if (temp._map != null) return false; + if (this._id != null) { + if (temp._id == null) + return false; + if (this._id != temp._id) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._id); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._id); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._id); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); + } + ; + return false; + } + if (!thcycle) { + if (!this._id.equals(temp._id)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._id); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._id); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); + } + } + } else if (temp._id != null) + return false; + if (this._provenance != null) { + if (temp._provenance == null) + return false; + if (this._provenance != temp._provenance) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._provenance); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._provenance); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance); + } + ; + return false; + } + if (!thcycle) { + if (!this._provenance.equals(temp._provenance)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance); + } + } + } else if (temp._provenance != null) + return false; + return true; } + return false; + } - /** - * Returns the value of field 'id'. - * - * @return the value of field 'Id'. - */ - public java.lang.String getId( - ) { - return this._id; - } + /** + * Returns the value of field 'id'. + * + * @return the value of field 'Id'. + */ + public java.lang.String getId() { + return this._id; + } - /** - * Returns the value of field 'loc'. The field 'loc' has the - * following description: Object on which the local - * range is defined. - * - * @return the value of field 'Loc'. - */ - public java.lang.Object getLoc( - ) { - return this._loc; - } + /** + * Returns the value of field 'loc'. The field 'loc' has the following + * description: Object on which the local range is defined. + * + * @return the value of field 'Loc'. + */ + public java.lang.Object getLoc() { + return this._loc; + } - /** - * Returns the value of field 'map'. The field 'map' has the - * following description: Object on which the mapped - * range is defined. - * - * @return the value of field 'Map'. - */ - public java.lang.Object getMap( - ) { - return this._map; - } + /** + * Returns the value of field 'map'. The field 'map' has the following + * description: Object on which the mapped range is defined. + * + * @return the value of field 'Map'. + */ + public java.lang.Object getMap() { + return this._map; + } - /** - * Returns the value of field 'provenance'. - * - * @return the value of field 'Provenance'. - */ - public uk.ac.vamsas.objects.core.Provenance getProvenance( - ) { - return this._provenance; - } + /** + * Returns the value of field 'provenance'. + * + * @return the value of field 'Provenance'. + */ + public uk.ac.vamsas.objects.core.Provenance getProvenance() { + return this._provenance; + } - /** - * Overrides the java.lang.Object.hashCode method. - *

- * The following steps came from Effective Java Programming - * Language Guide by Joshua Bloch, Chapter 3 - * - * @return a hash code value for the object. - */ - public int hashCode( - ) { - int result = super.hashCode(); - - long tmp; - if (_loc != null - && !org.castor.util.CycleBreaker.startingToCycle(_loc)) { - result = 37 * result + _loc.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_loc); - } - if (_map != null - && !org.castor.util.CycleBreaker.startingToCycle(_map)) { - result = 37 * result + _map.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_map); - } - if (_id != null - && !org.castor.util.CycleBreaker.startingToCycle(_id)) { - result = 37 * result + _id.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_id); - } - if (_provenance != null - && !org.castor.util.CycleBreaker.startingToCycle(_provenance)) { - result = 37 * result + _provenance.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_provenance); - } - - return result; - } + /** + * Overrides the java.lang.Object.hashCode method. + *

+ * The following steps came from Effective Java Programming Language + * Guide by Joshua Bloch, Chapter 3 + * + * @return a hash code value for the object. + */ + public int hashCode() { + int result = super.hashCode(); - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { - return false; - } - return true; + long tmp; + if (_loc != null && !org.castor.util.CycleBreaker.startingToCycle(_loc)) { + result = 37 * result + _loc.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_loc); } - - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); + if (_map != null && !org.castor.util.CycleBreaker.startingToCycle(_map)) { + result = 37 * result + _map.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_map); } - - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); + if (_id != null && !org.castor.util.CycleBreaker.startingToCycle(_id)) { + result = 37 * result + _id.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_id); } - - /** - * Sets the value of field 'id'. - * - * @param id the value of field 'id'. - */ - public void setId( - final java.lang.String id) { - this._id = id; + if (_provenance != null + && !org.castor.util.CycleBreaker.startingToCycle(_provenance)) { + result = 37 * result + _provenance.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_provenance); } - /** - * Sets the value of field 'loc'. The field 'loc' has the - * following description: Object on which the local - * range is defined. - * - * @param loc the value of field 'loc'. - */ - public void setLoc( - final java.lang.Object loc) { - this._loc = loc; - } + return result; + } - /** - * Sets the value of field 'map'. The field 'map' has the - * following description: Object on which the mapped - * range is defined. - * - * @param map the value of field 'map'. - */ - public void setMap( - final java.lang.Object map) { - this._map = map; + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() { + try { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) { + return false; } + return true; + } - /** - * Sets the value of field 'provenance'. - * - * @param provenance the value of field 'provenance'. - */ - public void setProvenance( - final uk.ac.vamsas.objects.core.Provenance provenance) { - this._provenance = provenance; - } + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, out); + } - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled uk.ac.vamsas.objects.core.MapType - */ - public static uk.ac.vamsas.objects.core.MapType unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (uk.ac.vamsas.objects.core.MapType) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.SequenceMapping.class, reader); - } + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, handler); + } - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); - } + /** + * Sets the value of field 'id'. + * + * @param id + * the value of field 'id'. + */ + public void setId(final java.lang.String id) { + this._id = id; + } + + /** + * Sets the value of field 'loc'. The field 'loc' has the following + * description: Object on which the local range is defined. + * + * @param loc + * the value of field 'loc'. + */ + public void setLoc(final java.lang.Object loc) { + this._loc = loc; + } + + /** + * Sets the value of field 'map'. The field 'map' has the following + * description: Object on which the mapped range is defined. + * + * @param map + * the value of field 'map'. + */ + public void setMap(final java.lang.Object map) { + this._map = map; + } + + /** + * Sets the value of field 'provenance'. + * + * @param provenance + * the value of field 'provenance'. + */ + public void setProvenance( + final uk.ac.vamsas.objects.core.Provenance provenance) { + this._provenance = provenance; + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @return the unmarshaled uk.ac.vamsas.objects.core.MapType + */ + public static uk.ac.vamsas.objects.core.MapType unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + return (uk.ac.vamsas.objects.core.MapType) Unmarshaller.unmarshal( + uk.ac.vamsas.objects.core.SequenceMapping.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/uk/ac/vamsas/objects/core/SequenceType.java b/src/uk/ac/vamsas/objects/core/SequenceType.java index 1a89b6c..1655f75 100644 --- a/src/uk/ac/vamsas/objects/core/SequenceType.java +++ b/src/uk/ac/vamsas/objects/core/SequenceType.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import org.exolab.castor.xml.Marshaller; @@ -17,629 +31,650 @@ import org.exolab.castor.xml.Unmarshaller; /** * Class SequenceType. * - * @version $Revision$ $Date$ + * @version $Revision$ $Date: 2007-06-28 14:51:44 +0100 (Thu, 28 Jun 2007) + * $ */ -public class SequenceType extends uk.ac.vamsas.client.Vobject -implements java.io.Serializable -{ - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _start. - */ - private long _start; - - /** - * keeps track of state for field: _start - */ - private boolean _has_start; - - /** - * Field _end. - */ - private long _end; - - /** - * keeps track of state for field: _end - */ - private boolean _has_end; - - /** - * Field _sequence. - */ - private java.lang.String _sequence; - - /** - * Field _name. - */ - private java.lang.String _name; - - /** - * Field _description. - */ - private java.lang.String _description; - - /** - * additional typed properties - */ - private java.util.Vector _propertyList; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public SequenceType() { - super(); - this._propertyList = new java.util.Vector(); - } - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * - * - * @param vProperty - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addProperty( - final uk.ac.vamsas.objects.core.Property vProperty) - throws java.lang.IndexOutOfBoundsException { - this._propertyList.addElement(vProperty); - } - - /** - * - * - * @param index - * @param vProperty - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addProperty( - final int index, - final uk.ac.vamsas.objects.core.Property vProperty) - throws java.lang.IndexOutOfBoundsException { - this._propertyList.add(index, vProperty); - } - - /** - */ - public void deleteEnd( - ) { - this._has_end= false; - } - - /** - */ - public void deleteStart( - ) { - this._has_start= false; - } - - /** - * Method enumerateProperty. - * - * @return an Enumeration over all - * uk.ac.vamsas.objects.core.Property elements - */ - public java.util.Enumeration enumerateProperty( - ) { - return this._propertyList.elements(); - } - - /** - * Overrides the java.lang.Object.equals method. - * - * @param obj - * @return true if the objects are equal. - */ - public boolean equals( - final java.lang.Object obj) { - if ( this == obj ) - return true; - - if (super.equals(obj)==false) +public class SequenceType extends uk.ac.vamsas.client.Vobject implements + java.io.Serializable { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _start. + */ + private long _start; + + /** + * keeps track of state for field: _start + */ + private boolean _has_start; + + /** + * Field _end. + */ + private long _end; + + /** + * keeps track of state for field: _end + */ + private boolean _has_end; + + /** + * Field _sequence. + */ + private java.lang.String _sequence; + + /** + * Field _name. + */ + private java.lang.String _name; + + /** + * Field _description. + */ + private java.lang.String _description; + + /** + * additional typed properties + */ + private java.util.Vector _propertyList; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public SequenceType() { + super(); + this._propertyList = new java.util.Vector(); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * + * + * @param vProperty + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addProperty(final uk.ac.vamsas.objects.core.Property vProperty) + throws java.lang.IndexOutOfBoundsException { + this._propertyList.addElement(vProperty); + } + + /** + * + * + * @param index + * @param vProperty + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addProperty(final int index, + final uk.ac.vamsas.objects.core.Property vProperty) + throws java.lang.IndexOutOfBoundsException { + this._propertyList.add(index, vProperty); + } + + /** + */ + public void deleteEnd() { + this._has_end = false; + } + + /** + */ + public void deleteStart() { + this._has_start = false; + } + + /** + * Method enumerateProperty. + * + * @return an Enumeration over all uk.ac.vamsas.objects.core.Property elements + */ + public java.util.Enumeration enumerateProperty() { + return this._propertyList.elements(); + } + + /** + * Overrides the java.lang.Object.equals method. + * + * @param obj + * @return true if the objects are equal. + */ + public boolean equals(final java.lang.Object obj) { + if (this == obj) + return true; + + if (super.equals(obj) == false) + return false; + + if (obj instanceof SequenceType) { + + SequenceType temp = (SequenceType) obj; + boolean thcycle; + boolean tmcycle; + if (this._start != temp._start) + return false; + if (this._has_start != temp._has_start) + return false; + if (this._end != temp._end) + return false; + if (this._has_end != temp._has_end) + return false; + if (this._sequence != null) { + if (temp._sequence == null) + return false; + if (this._sequence != temp._sequence) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._sequence); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._sequence); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._sequence); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._sequence); + } + ; return false; - - if (obj instanceof SequenceType) { - - SequenceType temp = (SequenceType)obj; - boolean thcycle; - boolean tmcycle; - if (this._start != temp._start) - return false; - if (this._has_start != temp._has_start) - return false; - if (this._end != temp._end) - return false; - if (this._has_end != temp._has_end) - return false; - if (this._sequence != null) { - if (temp._sequence == null) return false; - if (this._sequence != temp._sequence) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._sequence); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._sequence); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._sequence); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._sequence); }; - return false; - } - if (!thcycle) { - if (!this._sequence.equals(temp._sequence)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._sequence); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._sequence); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._sequence); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._sequence); - } - } - } else if (temp._sequence != null) - return false; - if (this._name != null) { - if (temp._name == null) return false; - if (this._name != temp._name) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._name); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._name); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._name); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._name); }; - return false; - } - if (!thcycle) { - if (!this._name.equals(temp._name)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._name); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._name); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._name); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._name); - } - } - } else if (temp._name != null) - return false; - if (this._description != null) { - if (temp._description == null) return false; - if (this._description != temp._description) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._description); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._description); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._description); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._description); }; - return false; - } - if (!thcycle) { - if (!this._description.equals(temp._description)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._description); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._description); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._description); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._description); - } - } - } else if (temp._description != null) - return false; - if (this._propertyList != null) { - if (temp._propertyList == null) return false; - if (this._propertyList != temp._propertyList) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._propertyList); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._propertyList); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._propertyList); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._propertyList); }; - return false; - } - if (!thcycle) { - if (!this._propertyList.equals(temp._propertyList)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._propertyList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._propertyList); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._propertyList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._propertyList); - } - } - } else if (temp._propertyList != null) - return false; - return true; + } + if (!thcycle) { + if (!this._sequence.equals(temp._sequence)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._sequence); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._sequence); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._sequence); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._sequence); + } } + } else if (temp._sequence != null) return false; - } - - /** - * Returns the value of field 'description'. - * - * @return the value of field 'Description'. - */ - public java.lang.String getDescription( - ) { - return this._description; - } - - /** - * Returns the value of field 'end'. - * - * @return the value of field 'End'. - */ - public long getEnd( - ) { - return this._end; - } - - /** - * Returns the value of field 'name'. - * - * @return the value of field 'Name'. - */ - public java.lang.String getName( - ) { - return this._name; - } - - /** - * Method getProperty. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the uk.ac.vamsas.objects.core.Property - * at the given index - */ - public uk.ac.vamsas.objects.core.Property getProperty( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._propertyList.size()) { - throw new IndexOutOfBoundsException("getProperty: Index value '" + index + "' not in range [0.." + (this._propertyList.size() - 1) + "]"); - } - - return (uk.ac.vamsas.objects.core.Property) _propertyList.get(index); - } - - /** - * Method getProperty.Returns the contents of the collection in - * an Array.

Note: Just in case the collection contents - * are changing in another thread, we pass a 0-length Array of - * the correct type into the API call. This way we know - * that the Array returned is of exactly the correct length. - * - * @return this collection as an Array - */ - public uk.ac.vamsas.objects.core.Property[] getProperty( - ) { - uk.ac.vamsas.objects.core.Property[] array = new uk.ac.vamsas.objects.core.Property[0]; - return (uk.ac.vamsas.objects.core.Property[]) this._propertyList.toArray(array); - } - - /** - * Method getPropertyAsReference.Returns a reference to - * '_propertyList'. No type checking is performed on any - * modifications to the Vector. - * - * @return a reference to the Vector backing this class - */ - public java.util.Vector getPropertyAsReference( - ) { - return this._propertyList; - } - - /** - * Method getPropertyCount. - * - * @return the size of this collection - */ - public int getPropertyCount( - ) { - return this._propertyList.size(); - } - - /** - * Returns the value of field 'sequence'. - * - * @return the value of field 'Sequence'. - */ - public java.lang.String getSequence( - ) { - return this._sequence; - } - - /** - * Returns the value of field 'start'. - * - * @return the value of field 'Start'. - */ - public long getStart( - ) { - return this._start; - } - - /** - * Method hasEnd. - * - * @return true if at least one End has been added - */ - public boolean hasEnd( - ) { - return this._has_end; - } - - /** - * Method hasStart. - * - * @return true if at least one Start has been added - */ - public boolean hasStart( - ) { - return this._has_start; - } - - /** - * Overrides the java.lang.Object.hashCode method. - *

- * The following steps came from Effective Java Programming - * Language Guide by Joshua Bloch, Chapter 3 - * - * @return a hash code value for the object. - */ - public int hashCode( - ) { - int result = super.hashCode(); - - long tmp; - result = 37 * result + (int)(_start^(_start>>>32)); - result = 37 * result + (int)(_end^(_end>>>32)); - if (_sequence != null - && !org.castor.util.CycleBreaker.startingToCycle(_sequence)) { - result = 37 * result + _sequence.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_sequence); - } - if (_name != null - && !org.castor.util.CycleBreaker.startingToCycle(_name)) { - result = 37 * result + _name.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_name); - } - if (_description != null - && !org.castor.util.CycleBreaker.startingToCycle(_description)) { - result = 37 * result + _description.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_description); - } - if (_propertyList != null - && !org.castor.util.CycleBreaker.startingToCycle(_propertyList)) { - result = 37 * result + _propertyList.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_propertyList); - } - - return result; - } - - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { + if (this._name != null) { + if (temp._name == null) + return false; + if (this._name != temp._name) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._name); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._name); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._name); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._name); + } + ; return false; + } + if (!thcycle) { + if (!this._name.equals(temp._name)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._name); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._name); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._name); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._name); + } } - return true; - } - - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } - - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } - - /** - */ - public void removeAllProperty( - ) { - this._propertyList.clear(); - } - - /** - * Method removeProperty. - * - * @param vProperty - * @return true if the object was removed from the collection. - */ - public boolean removeProperty( - final uk.ac.vamsas.objects.core.Property vProperty) { - boolean removed = _propertyList.remove(vProperty); - return removed; - } - - /** - * Method removePropertyAt. - * - * @param index - * @return the element removed from the collection - */ - public uk.ac.vamsas.objects.core.Property removePropertyAt( - final int index) { - java.lang.Object obj = this._propertyList.remove(index); - return (uk.ac.vamsas.objects.core.Property) obj; - } - - /** - * Sets the value of field 'description'. - * - * @param description the value of field 'description'. - */ - public void setDescription( - final java.lang.String description) { - this._description = description; - } - - /** - * Sets the value of field 'end'. - * - * @param end the value of field 'end'. - */ - public void setEnd( - final long end) { - this._end = end; - this._has_end = true; - } - - /** - * Sets the value of field 'name'. - * - * @param name the value of field 'name'. - */ - public void setName( - final java.lang.String name) { - this._name = name; - } - - /** - * - * - * @param index - * @param vProperty - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setProperty( - final int index, - final uk.ac.vamsas.objects.core.Property vProperty) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._propertyList.size()) { - throw new IndexOutOfBoundsException("setProperty: Index value '" + index + "' not in range [0.." + (this._propertyList.size() - 1) + "]"); + } else if (temp._name != null) + return false; + if (this._description != null) { + if (temp._description == null) + return false; + if (this._description != temp._description) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._description); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._description); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker + .releaseCycleHandle(this._description); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._description); + } + ; + return false; + } + if (!thcycle) { + if (!this._description.equals(temp._description)) { + org.castor.util.CycleBreaker + .releaseCycleHandle(this._description); + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._description); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._description); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._description); + } } - - this._propertyList.set(index, vProperty); - } - - /** - * - * - * @param vPropertyArray - */ - public void setProperty( - final uk.ac.vamsas.objects.core.Property[] vPropertyArray) { - //-- copy array - _propertyList.clear(); - - for (int i = 0; i < vPropertyArray.length; i++) { - this._propertyList.add(vPropertyArray[i]); + } else if (temp._description != null) + return false; + if (this._propertyList != null) { + if (temp._propertyList == null) + return false; + if (this._propertyList != temp._propertyList) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._propertyList); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._propertyList); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker + .releaseCycleHandle(this._propertyList); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._propertyList); + } + ; + return false; + } + if (!thcycle) { + if (!this._propertyList.equals(temp._propertyList)) { + org.castor.util.CycleBreaker + .releaseCycleHandle(this._propertyList); + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._propertyList); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._propertyList); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._propertyList); + } } - } - - /** - * Sets the value of '_propertyList' by copying the given - * Vector. All elements will be checked for type safety. - * - * @param vPropertyList the Vector to copy. - */ - public void setProperty( - final java.util.Vector vPropertyList) { - // copy vector - this._propertyList.clear(); - - this._propertyList.addAll(vPropertyList); - } - - /** - * Sets the value of '_propertyList' by setting it to the given - * Vector. No type checking is performed. - * @deprecated - * - * @param propertyVector the Vector to set. - */ - public void setPropertyAsReference( - final java.util.Vector propertyVector) { - this._propertyList = propertyVector; - } - - /** - * Sets the value of field 'sequence'. - * - * @param sequence the value of field 'sequence'. - */ - public void setSequence( - final java.lang.String sequence) { - this._sequence = sequence; - } - - /** - * Sets the value of field 'start'. - * - * @param start the value of field 'start'. - */ - public void setStart( - final long start) { - this._start = start; - this._has_start = true; - } - - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled uk.ac.vamsas.objects.core.SequenceTyp - */ - public static uk.ac.vamsas.objects.core.SequenceType unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (uk.ac.vamsas.objects.core.SequenceType) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.SequenceType.class, reader); - } - - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); - } + } else if (temp._propertyList != null) + return false; + return true; + } + return false; + } + + /** + * Returns the value of field 'description'. + * + * @return the value of field 'Description'. + */ + public java.lang.String getDescription() { + return this._description; + } + + /** + * Returns the value of field 'end'. + * + * @return the value of field 'End'. + */ + public long getEnd() { + return this._end; + } + + /** + * Returns the value of field 'name'. + * + * @return the value of field 'Name'. + */ + public java.lang.String getName() { + return this._name; + } + + /** + * Method getProperty. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the uk.ac.vamsas.objects.core.Property at the given + * index + */ + public uk.ac.vamsas.objects.core.Property getProperty(final int index) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._propertyList.size()) { + throw new IndexOutOfBoundsException("getProperty: Index value '" + index + + "' not in range [0.." + (this._propertyList.size() - 1) + "]"); + } + + return (uk.ac.vamsas.objects.core.Property) _propertyList.get(index); + } + + /** + * Method getProperty.Returns the contents of the collection in an Array. + *

+ * Note: Just in case the collection contents are changing in another thread, + * we pass a 0-length Array of the correct type into the API call. This way we + * know that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public uk.ac.vamsas.objects.core.Property[] getProperty() { + uk.ac.vamsas.objects.core.Property[] array = new uk.ac.vamsas.objects.core.Property[0]; + return (uk.ac.vamsas.objects.core.Property[]) this._propertyList + .toArray(array); + } + + /** + * Method getPropertyAsReference.Returns a reference to '_propertyList'. No + * type checking is performed on any modifications to the Vector. + * + * @return a reference to the Vector backing this class + */ + public java.util.Vector getPropertyAsReference() { + return this._propertyList; + } + + /** + * Method getPropertyCount. + * + * @return the size of this collection + */ + public int getPropertyCount() { + return this._propertyList.size(); + } + + /** + * Returns the value of field 'sequence'. + * + * @return the value of field 'Sequence'. + */ + public java.lang.String getSequence() { + return this._sequence; + } + + /** + * Returns the value of field 'start'. + * + * @return the value of field 'Start'. + */ + public long getStart() { + return this._start; + } + + /** + * Method hasEnd. + * + * @return true if at least one End has been added + */ + public boolean hasEnd() { + return this._has_end; + } + + /** + * Method hasStart. + * + * @return true if at least one Start has been added + */ + public boolean hasStart() { + return this._has_start; + } + + /** + * Overrides the java.lang.Object.hashCode method. + *

+ * The following steps came from Effective Java Programming Language + * Guide by Joshua Bloch, Chapter 3 + * + * @return a hash code value for the object. + */ + public int hashCode() { + int result = super.hashCode(); + + long tmp; + result = 37 * result + (int) (_start ^ (_start >>> 32)); + result = 37 * result + (int) (_end ^ (_end >>> 32)); + if (_sequence != null + && !org.castor.util.CycleBreaker.startingToCycle(_sequence)) { + result = 37 * result + _sequence.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_sequence); + } + if (_name != null && !org.castor.util.CycleBreaker.startingToCycle(_name)) { + result = 37 * result + _name.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_name); + } + if (_description != null + && !org.castor.util.CycleBreaker.startingToCycle(_description)) { + result = 37 * result + _description.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_description); + } + if (_propertyList != null + && !org.castor.util.CycleBreaker.startingToCycle(_propertyList)) { + result = 37 * result + _propertyList.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_propertyList); + } + + return result; + } + + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() { + try { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) { + return false; + } + return true; + } + + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, out); + } + + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, handler); + } + + /** + */ + public void removeAllProperty() { + this._propertyList.clear(); + } + + /** + * Method removeProperty. + * + * @param vProperty + * @return true if the object was removed from the collection. + */ + public boolean removeProperty( + final uk.ac.vamsas.objects.core.Property vProperty) { + boolean removed = _propertyList.remove(vProperty); + return removed; + } + + /** + * Method removePropertyAt. + * + * @param index + * @return the element removed from the collection + */ + public uk.ac.vamsas.objects.core.Property removePropertyAt(final int index) { + java.lang.Object obj = this._propertyList.remove(index); + return (uk.ac.vamsas.objects.core.Property) obj; + } + + /** + * Sets the value of field 'description'. + * + * @param description + * the value of field 'description'. + */ + public void setDescription(final java.lang.String description) { + this._description = description; + } + + /** + * Sets the value of field 'end'. + * + * @param end + * the value of field 'end'. + */ + public void setEnd(final long end) { + this._end = end; + this._has_end = true; + } + + /** + * Sets the value of field 'name'. + * + * @param name + * the value of field 'name'. + */ + public void setName(final java.lang.String name) { + this._name = name; + } + + /** + * + * + * @param index + * @param vProperty + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setProperty(final int index, + final uk.ac.vamsas.objects.core.Property vProperty) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._propertyList.size()) { + throw new IndexOutOfBoundsException("setProperty: Index value '" + index + + "' not in range [0.." + (this._propertyList.size() - 1) + "]"); + } + + this._propertyList.set(index, vProperty); + } + + /** + * + * + * @param vPropertyArray + */ + public void setProperty( + final uk.ac.vamsas.objects.core.Property[] vPropertyArray) { + // -- copy array + _propertyList.clear(); + + for (int i = 0; i < vPropertyArray.length; i++) { + this._propertyList.add(vPropertyArray[i]); + } + } + + /** + * Sets the value of '_propertyList' by copying the given Vector. All elements + * will be checked for type safety. + * + * @param vPropertyList + * the Vector to copy. + */ + public void setProperty(final java.util.Vector vPropertyList) { + // copy vector + this._propertyList.clear(); + + this._propertyList.addAll(vPropertyList); + } + + /** + * Sets the value of '_propertyList' by setting it to the given Vector. No + * type checking is performed. + * + * @deprecated + * + * @param propertyVector + * the Vector to set. + */ + public void setPropertyAsReference(final java.util.Vector propertyVector) { + this._propertyList = propertyVector; + } + + /** + * Sets the value of field 'sequence'. + * + * @param sequence + * the value of field 'sequence'. + */ + public void setSequence(final java.lang.String sequence) { + this._sequence = sequence; + } + + /** + * Sets the value of field 'start'. + * + * @param start + * the value of field 'start'. + */ + public void setStart(final long start) { + this._start = start; + this._has_start = true; + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @return the unmarshaled uk.ac.vamsas.objects.core.SequenceTyp + */ + public static uk.ac.vamsas.objects.core.SequenceType unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + return (uk.ac.vamsas.objects.core.SequenceType) Unmarshaller.unmarshal( + uk.ac.vamsas.objects.core.SequenceType.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/uk/ac/vamsas/objects/core/Tree.java b/src/uk/ac/vamsas/objects/core/Tree.java index 39eb763..12b8031 100644 --- a/src/uk/ac/vamsas/objects/core/Tree.java +++ b/src/uk/ac/vamsas/objects/core/Tree.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import org.exolab.castor.xml.Marshaller; @@ -17,1022 +31,1052 @@ import org.exolab.castor.xml.Unmarshaller; /** * Class Tree. * - * @version $Revision$ $Date$ + * @version $Revision$ $Date: 2007-06-28 14:51:44 +0100 (Thu, 28 Jun 2007) + * $ */ -public class Tree extends uk.ac.vamsas.client.Vobject -implements java.io.Serializable -{ - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Primary Key for vamsas object referencing - */ - private java.lang.String _id; - - /** - * Field _modifiable. - */ - private java.lang.String _modifiable; - - /** - * Field _title. - */ - private java.lang.String _title; - - /** - * Field _newickList. - */ - private java.util.Vector _newickList; - - /** - * node identity and mapping data between tree - * representations and vamsas document objects - */ - private java.util.Vector _treenodeList; - - /** - * Field _propertyList. - */ - private java.util.Vector _propertyList; - - /** - * Field _provenance. - */ - private uk.ac.vamsas.objects.core.Provenance _provenance; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public Tree() { - super(); - this._newickList = new java.util.Vector(); - this._treenodeList = new java.util.Vector(); - this._propertyList = new java.util.Vector(); - } - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * - * - * @param vNewick - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addNewick( - final uk.ac.vamsas.objects.core.Newick vNewick) - throws java.lang.IndexOutOfBoundsException { - this._newickList.addElement(vNewick); - } - - /** - * - * - * @param index - * @param vNewick - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addNewick( - final int index, - final uk.ac.vamsas.objects.core.Newick vNewick) - throws java.lang.IndexOutOfBoundsException { - this._newickList.add(index, vNewick); - } - - /** - * - * - * @param vProperty - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addProperty( - final uk.ac.vamsas.objects.core.Property vProperty) - throws java.lang.IndexOutOfBoundsException { - this._propertyList.addElement(vProperty); - } - - /** - * - * - * @param index - * @param vProperty - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addProperty( - final int index, - final uk.ac.vamsas.objects.core.Property vProperty) - throws java.lang.IndexOutOfBoundsException { - this._propertyList.add(index, vProperty); - } - - /** - * - * - * @param vTreenode - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addTreenode( - final uk.ac.vamsas.objects.core.Treenode vTreenode) - throws java.lang.IndexOutOfBoundsException { - this._treenodeList.addElement(vTreenode); - } - - /** - * - * - * @param index - * @param vTreenode - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addTreenode( - final int index, - final uk.ac.vamsas.objects.core.Treenode vTreenode) - throws java.lang.IndexOutOfBoundsException { - this._treenodeList.add(index, vTreenode); - } - - /** - * Method enumerateNewick. - * - * @return an Enumeration over all - * uk.ac.vamsas.objects.core.Newick elements - */ - public java.util.Enumeration enumerateNewick( - ) { - return this._newickList.elements(); - } - - /** - * Method enumerateProperty. - * - * @return an Enumeration over all - * uk.ac.vamsas.objects.core.Property elements - */ - public java.util.Enumeration enumerateProperty( - ) { - return this._propertyList.elements(); - } - - /** - * Method enumerateTreenode. - * - * @return an Enumeration over all - * uk.ac.vamsas.objects.core.Treenode elements - */ - public java.util.Enumeration enumerateTreenode( - ) { - return this._treenodeList.elements(); - } - - /** - * Overrides the java.lang.Object.equals method. - * - * @param obj - * @return true if the objects are equal. - */ - public boolean equals( - final java.lang.Object obj) { - if ( this == obj ) - return true; - - if (super.equals(obj)==false) +public class Tree extends uk.ac.vamsas.client.Vobject implements + java.io.Serializable { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Primary Key for vamsas object referencing + */ + private java.lang.String _id; + + /** + * Field _modifiable. + */ + private java.lang.String _modifiable; + + /** + * Field _title. + */ + private java.lang.String _title; + + /** + * Field _newickList. + */ + private java.util.Vector _newickList; + + /** + * node identity and mapping data between tree representations and vamsas + * document objects + */ + private java.util.Vector _treenodeList; + + /** + * Field _propertyList. + */ + private java.util.Vector _propertyList; + + /** + * Field _provenance. + */ + private uk.ac.vamsas.objects.core.Provenance _provenance; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public Tree() { + super(); + this._newickList = new java.util.Vector(); + this._treenodeList = new java.util.Vector(); + this._propertyList = new java.util.Vector(); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * + * + * @param vNewick + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addNewick(final uk.ac.vamsas.objects.core.Newick vNewick) + throws java.lang.IndexOutOfBoundsException { + this._newickList.addElement(vNewick); + } + + /** + * + * + * @param index + * @param vNewick + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addNewick(final int index, + final uk.ac.vamsas.objects.core.Newick vNewick) + throws java.lang.IndexOutOfBoundsException { + this._newickList.add(index, vNewick); + } + + /** + * + * + * @param vProperty + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addProperty(final uk.ac.vamsas.objects.core.Property vProperty) + throws java.lang.IndexOutOfBoundsException { + this._propertyList.addElement(vProperty); + } + + /** + * + * + * @param index + * @param vProperty + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addProperty(final int index, + final uk.ac.vamsas.objects.core.Property vProperty) + throws java.lang.IndexOutOfBoundsException { + this._propertyList.add(index, vProperty); + } + + /** + * + * + * @param vTreenode + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addTreenode(final uk.ac.vamsas.objects.core.Treenode vTreenode) + throws java.lang.IndexOutOfBoundsException { + this._treenodeList.addElement(vTreenode); + } + + /** + * + * + * @param index + * @param vTreenode + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addTreenode(final int index, + final uk.ac.vamsas.objects.core.Treenode vTreenode) + throws java.lang.IndexOutOfBoundsException { + this._treenodeList.add(index, vTreenode); + } + + /** + * Method enumerateNewick. + * + * @return an Enumeration over all uk.ac.vamsas.objects.core.Newick elements + */ + public java.util.Enumeration enumerateNewick() { + return this._newickList.elements(); + } + + /** + * Method enumerateProperty. + * + * @return an Enumeration over all uk.ac.vamsas.objects.core.Property elements + */ + public java.util.Enumeration enumerateProperty() { + return this._propertyList.elements(); + } + + /** + * Method enumerateTreenode. + * + * @return an Enumeration over all uk.ac.vamsas.objects.core.Treenode elements + */ + public java.util.Enumeration enumerateTreenode() { + return this._treenodeList.elements(); + } + + /** + * Overrides the java.lang.Object.equals method. + * + * @param obj + * @return true if the objects are equal. + */ + public boolean equals(final java.lang.Object obj) { + if (this == obj) + return true; + + if (super.equals(obj) == false) + return false; + + if (obj instanceof Tree) { + + Tree temp = (Tree) obj; + boolean thcycle; + boolean tmcycle; + if (this._id != null) { + if (temp._id == null) + return false; + if (this._id != temp._id) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._id); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._id); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._id); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); + } + ; return false; - - if (obj instanceof Tree) { - - Tree temp = (Tree)obj; - boolean thcycle; - boolean tmcycle; - if (this._id != null) { - if (temp._id == null) return false; - if (this._id != temp._id) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._id); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._id); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._id); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); }; - return false; - } - if (!thcycle) { - if (!this._id.equals(temp._id)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._id); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._id); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); - } - } - } else if (temp._id != null) - return false; - if (this._modifiable != null) { - if (temp._modifiable == null) return false; - if (this._modifiable != temp._modifiable) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._modifiable); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._modifiable); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._modifiable); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._modifiable); }; - return false; - } - if (!thcycle) { - if (!this._modifiable.equals(temp._modifiable)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._modifiable); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._modifiable); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._modifiable); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._modifiable); - } - } - } else if (temp._modifiable != null) - return false; - if (this._title != null) { - if (temp._title == null) return false; - if (this._title != temp._title) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._title); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._title); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._title); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._title); }; - return false; - } - if (!thcycle) { - if (!this._title.equals(temp._title)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._title); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._title); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._title); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._title); - } - } - } else if (temp._title != null) - return false; - if (this._newickList != null) { - if (temp._newickList == null) return false; - if (this._newickList != temp._newickList) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._newickList); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._newickList); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._newickList); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._newickList); }; - return false; - } - if (!thcycle) { - if (!this._newickList.equals(temp._newickList)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._newickList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._newickList); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._newickList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._newickList); - } - } - } else if (temp._newickList != null) - return false; - if (this._treenodeList != null) { - if (temp._treenodeList == null) return false; - if (this._treenodeList != temp._treenodeList) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._treenodeList); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._treenodeList); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._treenodeList); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._treenodeList); }; - return false; - } - if (!thcycle) { - if (!this._treenodeList.equals(temp._treenodeList)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._treenodeList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._treenodeList); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._treenodeList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._treenodeList); - } - } - } else if (temp._treenodeList != null) - return false; - if (this._propertyList != null) { - if (temp._propertyList == null) return false; - if (this._propertyList != temp._propertyList) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._propertyList); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._propertyList); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._propertyList); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._propertyList); }; - return false; - } - if (!thcycle) { - if (!this._propertyList.equals(temp._propertyList)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._propertyList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._propertyList); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._propertyList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._propertyList); - } - } - } else if (temp._propertyList != null) - return false; - if (this._provenance != null) { - if (temp._provenance == null) return false; - if (this._provenance != temp._provenance) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._provenance); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._provenance); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance); }; - return false; - } - if (!thcycle) { - if (!this._provenance.equals(temp._provenance)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance); - } - } - } else if (temp._provenance != null) - return false; - return true; + } + if (!thcycle) { + if (!this._id.equals(temp._id)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._id); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._id); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); + } } + } else if (temp._id != null) return false; - } - - /** - * Returns the value of field 'id'. The field 'id' has the - * following description: Primary Key for vamsas object - * referencing - * - * @return the value of field 'Id'. - */ - public java.lang.String getId( - ) { - return this._id; - } - - /** - * Returns the value of field 'modifiable'. - * - * @return the value of field 'Modifiable'. - */ - public java.lang.String getModifiable( - ) { - return this._modifiable; - } - - /** - * Method getNewick. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the uk.ac.vamsas.objects.core.Newick at - * the given index - */ - public uk.ac.vamsas.objects.core.Newick getNewick( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._newickList.size()) { - throw new IndexOutOfBoundsException("getNewick: Index value '" + index + "' not in range [0.." + (this._newickList.size() - 1) + "]"); - } - - return (uk.ac.vamsas.objects.core.Newick) _newickList.get(index); - } - - /** - * Method getNewick.Returns the contents of the collection in - * an Array.

Note: Just in case the collection contents - * are changing in another thread, we pass a 0-length Array of - * the correct type into the API call. This way we know - * that the Array returned is of exactly the correct length. - * - * @return this collection as an Array - */ - public uk.ac.vamsas.objects.core.Newick[] getNewick( - ) { - uk.ac.vamsas.objects.core.Newick[] array = new uk.ac.vamsas.objects.core.Newick[0]; - return (uk.ac.vamsas.objects.core.Newick[]) this._newickList.toArray(array); - } - - /** - * Method getNewickAsReference.Returns a reference to - * '_newickList'. No type checking is performed on any - * modifications to the Vector. - * - * @return a reference to the Vector backing this class - */ - public java.util.Vector getNewickAsReference( - ) { - return this._newickList; - } - - /** - * Method getNewickCount. - * - * @return the size of this collection - */ - public int getNewickCount( - ) { - return this._newickList.size(); - } - - /** - * Method getProperty. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the uk.ac.vamsas.objects.core.Property - * at the given index - */ - public uk.ac.vamsas.objects.core.Property getProperty( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._propertyList.size()) { - throw new IndexOutOfBoundsException("getProperty: Index value '" + index + "' not in range [0.." + (this._propertyList.size() - 1) + "]"); - } - - return (uk.ac.vamsas.objects.core.Property) _propertyList.get(index); - } - - /** - * Method getProperty.Returns the contents of the collection in - * an Array.

Note: Just in case the collection contents - * are changing in another thread, we pass a 0-length Array of - * the correct type into the API call. This way we know - * that the Array returned is of exactly the correct length. - * - * @return this collection as an Array - */ - public uk.ac.vamsas.objects.core.Property[] getProperty( - ) { - uk.ac.vamsas.objects.core.Property[] array = new uk.ac.vamsas.objects.core.Property[0]; - return (uk.ac.vamsas.objects.core.Property[]) this._propertyList.toArray(array); - } - - /** - * Method getPropertyAsReference.Returns a reference to - * '_propertyList'. No type checking is performed on any - * modifications to the Vector. - * - * @return a reference to the Vector backing this class - */ - public java.util.Vector getPropertyAsReference( - ) { - return this._propertyList; - } - - /** - * Method getPropertyCount. - * - * @return the size of this collection - */ - public int getPropertyCount( - ) { - return this._propertyList.size(); - } - - /** - * Returns the value of field 'provenance'. - * - * @return the value of field 'Provenance'. - */ - public uk.ac.vamsas.objects.core.Provenance getProvenance( - ) { - return this._provenance; - } - - /** - * Returns the value of field 'title'. - * - * @return the value of field 'Title'. - */ - public java.lang.String getTitle( - ) { - return this._title; - } - - /** - * Method getTreenode. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the uk.ac.vamsas.objects.core.Treenode - * at the given index - */ - public uk.ac.vamsas.objects.core.Treenode getTreenode( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._treenodeList.size()) { - throw new IndexOutOfBoundsException("getTreenode: Index value '" + index + "' not in range [0.." + (this._treenodeList.size() - 1) + "]"); - } - - return (uk.ac.vamsas.objects.core.Treenode) _treenodeList.get(index); - } - - /** - * Method getTreenode.Returns the contents of the collection in - * an Array.

Note: Just in case the collection contents - * are changing in another thread, we pass a 0-length Array of - * the correct type into the API call. This way we know - * that the Array returned is of exactly the correct length. - * - * @return this collection as an Array - */ - public uk.ac.vamsas.objects.core.Treenode[] getTreenode( - ) { - uk.ac.vamsas.objects.core.Treenode[] array = new uk.ac.vamsas.objects.core.Treenode[0]; - return (uk.ac.vamsas.objects.core.Treenode[]) this._treenodeList.toArray(array); - } - - /** - * Method getTreenodeAsReference.Returns a reference to - * '_treenodeList'. No type checking is performed on any - * modifications to the Vector. - * - * @return a reference to the Vector backing this class - */ - public java.util.Vector getTreenodeAsReference( - ) { - return this._treenodeList; - } - - /** - * Method getTreenodeCount. - * - * @return the size of this collection - */ - public int getTreenodeCount( - ) { - return this._treenodeList.size(); - } - - /** - * Overrides the java.lang.Object.hashCode method. - *

- * The following steps came from Effective Java Programming - * Language Guide by Joshua Bloch, Chapter 3 - * - * @return a hash code value for the object. - */ - public int hashCode( - ) { - int result = super.hashCode(); - - long tmp; - if (_id != null - && !org.castor.util.CycleBreaker.startingToCycle(_id)) { - result = 37 * result + _id.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_id); - } - if (_modifiable != null - && !org.castor.util.CycleBreaker.startingToCycle(_modifiable)) { - result = 37 * result + _modifiable.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_modifiable); - } - if (_title != null - && !org.castor.util.CycleBreaker.startingToCycle(_title)) { - result = 37 * result + _title.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_title); + if (this._modifiable != null) { + if (temp._modifiable == null) + return false; + if (this._modifiable != temp._modifiable) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._modifiable); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._modifiable); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._modifiable); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._modifiable); + } + ; + return false; + } + if (!thcycle) { + if (!this._modifiable.equals(temp._modifiable)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._modifiable); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._modifiable); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._modifiable); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._modifiable); + } } - if (_newickList != null - && !org.castor.util.CycleBreaker.startingToCycle(_newickList)) { - result = 37 * result + _newickList.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_newickList); + } else if (temp._modifiable != null) + return false; + if (this._title != null) { + if (temp._title == null) + return false; + if (this._title != temp._title) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._title); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._title); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._title); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._title); + } + ; + return false; + } + if (!thcycle) { + if (!this._title.equals(temp._title)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._title); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._title); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._title); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._title); + } } - if (_treenodeList != null - && !org.castor.util.CycleBreaker.startingToCycle(_treenodeList)) { - result = 37 * result + _treenodeList.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_treenodeList); + } else if (temp._title != null) + return false; + if (this._newickList != null) { + if (temp._newickList == null) + return false; + if (this._newickList != temp._newickList) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._newickList); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._newickList); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._newickList); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._newickList); + } + ; + return false; + } + if (!thcycle) { + if (!this._newickList.equals(temp._newickList)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._newickList); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._newickList); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._newickList); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._newickList); + } } - if (_propertyList != null - && !org.castor.util.CycleBreaker.startingToCycle(_propertyList)) { - result = 37 * result + _propertyList.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_propertyList); + } else if (temp._newickList != null) + return false; + if (this._treenodeList != null) { + if (temp._treenodeList == null) + return false; + if (this._treenodeList != temp._treenodeList) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._treenodeList); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._treenodeList); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker + .releaseCycleHandle(this._treenodeList); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._treenodeList); + } + ; + return false; + } + if (!thcycle) { + if (!this._treenodeList.equals(temp._treenodeList)) { + org.castor.util.CycleBreaker + .releaseCycleHandle(this._treenodeList); + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._treenodeList); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._treenodeList); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._treenodeList); + } } - if (_provenance != null - && !org.castor.util.CycleBreaker.startingToCycle(_provenance)) { - result = 37 * result + _provenance.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_provenance); + } else if (temp._treenodeList != null) + return false; + if (this._propertyList != null) { + if (temp._propertyList == null) + return false; + if (this._propertyList != temp._propertyList) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._propertyList); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._propertyList); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker + .releaseCycleHandle(this._propertyList); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._propertyList); + } + ; + return false; + } + if (!thcycle) { + if (!this._propertyList.equals(temp._propertyList)) { + org.castor.util.CycleBreaker + .releaseCycleHandle(this._propertyList); + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._propertyList); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._propertyList); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._propertyList); + } } - - return result; - } - - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { + } else if (temp._propertyList != null) + return false; + if (this._provenance != null) { + if (temp._provenance == null) + return false; + if (this._provenance != temp._provenance) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._provenance); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._provenance); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance); + } + ; return false; + } + if (!thcycle) { + if (!this._provenance.equals(temp._provenance)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance); + } } - return true; - } - - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } - - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } - - /** - */ - public void removeAllNewick( - ) { - this._newickList.clear(); - } - - /** - */ - public void removeAllProperty( - ) { - this._propertyList.clear(); - } - - /** - */ - public void removeAllTreenode( - ) { - this._treenodeList.clear(); - } - - /** - * Method removeNewick. - * - * @param vNewick - * @return true if the object was removed from the collection. - */ - public boolean removeNewick( - final uk.ac.vamsas.objects.core.Newick vNewick) { - boolean removed = _newickList.remove(vNewick); - return removed; - } - - /** - * Method removeNewickAt. - * - * @param index - * @return the element removed from the collection - */ - public uk.ac.vamsas.objects.core.Newick removeNewickAt( - final int index) { - java.lang.Object obj = this._newickList.remove(index); - return (uk.ac.vamsas.objects.core.Newick) obj; - } - - /** - * Method removeProperty. - * - * @param vProperty - * @return true if the object was removed from the collection. - */ - public boolean removeProperty( - final uk.ac.vamsas.objects.core.Property vProperty) { - boolean removed = _propertyList.remove(vProperty); - return removed; - } - - /** - * Method removePropertyAt. - * - * @param index - * @return the element removed from the collection - */ - public uk.ac.vamsas.objects.core.Property removePropertyAt( - final int index) { - java.lang.Object obj = this._propertyList.remove(index); - return (uk.ac.vamsas.objects.core.Property) obj; - } - - /** - * Method removeTreenode. - * - * @param vTreenode - * @return true if the object was removed from the collection. - */ - public boolean removeTreenode( - final uk.ac.vamsas.objects.core.Treenode vTreenode) { - boolean removed = _treenodeList.remove(vTreenode); - return removed; + } else if (temp._provenance != null) + return false; + return true; } - - /** - * Method removeTreenodeAt. - * - * @param index - * @return the element removed from the collection - */ - public uk.ac.vamsas.objects.core.Treenode removeTreenodeAt( - final int index) { - java.lang.Object obj = this._treenodeList.remove(index); - return (uk.ac.vamsas.objects.core.Treenode) obj; + return false; + } + + /** + * Returns the value of field 'id'. The field 'id' has the following + * description: Primary Key for vamsas object referencing + * + * @return the value of field 'Id'. + */ + public java.lang.String getId() { + return this._id; + } + + /** + * Returns the value of field 'modifiable'. + * + * @return the value of field 'Modifiable'. + */ + public java.lang.String getModifiable() { + return this._modifiable; + } + + /** + * Method getNewick. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the uk.ac.vamsas.objects.core.Newick at the given + * index + */ + public uk.ac.vamsas.objects.core.Newick getNewick(final int index) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._newickList.size()) { + throw new IndexOutOfBoundsException("getNewick: Index value '" + index + + "' not in range [0.." + (this._newickList.size() - 1) + "]"); } - /** - * 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( - final java.lang.String id) { - this._id = id; + return (uk.ac.vamsas.objects.core.Newick) _newickList.get(index); + } + + /** + * Method getNewick.Returns the contents of the collection in an Array. + *

+ * Note: Just in case the collection contents are changing in another thread, + * we pass a 0-length Array of the correct type into the API call. This way we + * know that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public uk.ac.vamsas.objects.core.Newick[] getNewick() { + uk.ac.vamsas.objects.core.Newick[] array = new uk.ac.vamsas.objects.core.Newick[0]; + return (uk.ac.vamsas.objects.core.Newick[]) this._newickList.toArray(array); + } + + /** + * Method getNewickAsReference.Returns a reference to '_newickList'. No type + * checking is performed on any modifications to the Vector. + * + * @return a reference to the Vector backing this class + */ + public java.util.Vector getNewickAsReference() { + return this._newickList; + } + + /** + * Method getNewickCount. + * + * @return the size of this collection + */ + public int getNewickCount() { + return this._newickList.size(); + } + + /** + * Method getProperty. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the uk.ac.vamsas.objects.core.Property at the given + * index + */ + public uk.ac.vamsas.objects.core.Property getProperty(final int index) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._propertyList.size()) { + throw new IndexOutOfBoundsException("getProperty: Index value '" + index + + "' not in range [0.." + (this._propertyList.size() - 1) + "]"); } - /** - * Sets the value of field 'modifiable'. - * - * @param modifiable the value of field 'modifiable'. - */ - public void setModifiable( - final java.lang.String modifiable) { - this._modifiable = modifiable; + return (uk.ac.vamsas.objects.core.Property) _propertyList.get(index); + } + + /** + * Method getProperty.Returns the contents of the collection in an Array. + *

+ * Note: Just in case the collection contents are changing in another thread, + * we pass a 0-length Array of the correct type into the API call. This way we + * know that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public uk.ac.vamsas.objects.core.Property[] getProperty() { + uk.ac.vamsas.objects.core.Property[] array = new uk.ac.vamsas.objects.core.Property[0]; + return (uk.ac.vamsas.objects.core.Property[]) this._propertyList + .toArray(array); + } + + /** + * Method getPropertyAsReference.Returns a reference to '_propertyList'. No + * type checking is performed on any modifications to the Vector. + * + * @return a reference to the Vector backing this class + */ + public java.util.Vector getPropertyAsReference() { + return this._propertyList; + } + + /** + * Method getPropertyCount. + * + * @return the size of this collection + */ + public int getPropertyCount() { + return this._propertyList.size(); + } + + /** + * Returns the value of field 'provenance'. + * + * @return the value of field 'Provenance'. + */ + public uk.ac.vamsas.objects.core.Provenance getProvenance() { + return this._provenance; + } + + /** + * Returns the value of field 'title'. + * + * @return the value of field 'Title'. + */ + public java.lang.String getTitle() { + return this._title; + } + + /** + * Method getTreenode. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the uk.ac.vamsas.objects.core.Treenode at the given + * index + */ + public uk.ac.vamsas.objects.core.Treenode getTreenode(final int index) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._treenodeList.size()) { + throw new IndexOutOfBoundsException("getTreenode: Index value '" + index + + "' not in range [0.." + (this._treenodeList.size() - 1) + "]"); } - /** - * - * - * @param index - * @param vNewick - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setNewick( - final int index, - final uk.ac.vamsas.objects.core.Newick vNewick) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._newickList.size()) { - throw new IndexOutOfBoundsException("setNewick: Index value '" + index + "' not in range [0.." + (this._newickList.size() - 1) + "]"); - } - - this._newickList.set(index, vNewick); + return (uk.ac.vamsas.objects.core.Treenode) _treenodeList.get(index); + } + + /** + * Method getTreenode.Returns the contents of the collection in an Array. + *

+ * Note: Just in case the collection contents are changing in another thread, + * we pass a 0-length Array of the correct type into the API call. This way we + * know that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public uk.ac.vamsas.objects.core.Treenode[] getTreenode() { + uk.ac.vamsas.objects.core.Treenode[] array = new uk.ac.vamsas.objects.core.Treenode[0]; + return (uk.ac.vamsas.objects.core.Treenode[]) this._treenodeList + .toArray(array); + } + + /** + * Method getTreenodeAsReference.Returns a reference to '_treenodeList'. No + * type checking is performed on any modifications to the Vector. + * + * @return a reference to the Vector backing this class + */ + public java.util.Vector getTreenodeAsReference() { + return this._treenodeList; + } + + /** + * Method getTreenodeCount. + * + * @return the size of this collection + */ + public int getTreenodeCount() { + return this._treenodeList.size(); + } + + /** + * Overrides the java.lang.Object.hashCode method. + *

+ * The following steps came from Effective Java Programming Language + * Guide by Joshua Bloch, Chapter 3 + * + * @return a hash code value for the object. + */ + public int hashCode() { + int result = super.hashCode(); + + long tmp; + if (_id != null && !org.castor.util.CycleBreaker.startingToCycle(_id)) { + result = 37 * result + _id.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_id); } - - /** - * - * - * @param vNewickArray - */ - public void setNewick( - final uk.ac.vamsas.objects.core.Newick[] vNewickArray) { - //-- copy array - _newickList.clear(); - - for (int i = 0; i < vNewickArray.length; i++) { - this._newickList.add(vNewickArray[i]); - } + if (_modifiable != null + && !org.castor.util.CycleBreaker.startingToCycle(_modifiable)) { + result = 37 * result + _modifiable.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_modifiable); } - - /** - * Sets the value of '_newickList' by copying the given Vector. - * All elements will be checked for type safety. - * - * @param vNewickList the Vector to copy. - */ - public void setNewick( - final java.util.Vector vNewickList) { - // copy vector - this._newickList.clear(); - - this._newickList.addAll(vNewickList); + if (_title != null && !org.castor.util.CycleBreaker.startingToCycle(_title)) { + result = 37 * result + _title.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_title); } - - /** - * Sets the value of '_newickList' by setting it to the given - * Vector. No type checking is performed. - * @deprecated - * - * @param newickVector the Vector to set. - */ - public void setNewickAsReference( - final java.util.Vector newickVector) { - this._newickList = newickVector; + if (_newickList != null + && !org.castor.util.CycleBreaker.startingToCycle(_newickList)) { + result = 37 * result + _newickList.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_newickList); } - - /** - * - * - * @param index - * @param vProperty - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setProperty( - final int index, - final uk.ac.vamsas.objects.core.Property vProperty) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._propertyList.size()) { - throw new IndexOutOfBoundsException("setProperty: Index value '" + index + "' not in range [0.." + (this._propertyList.size() - 1) + "]"); - } - - this._propertyList.set(index, vProperty); + if (_treenodeList != null + && !org.castor.util.CycleBreaker.startingToCycle(_treenodeList)) { + result = 37 * result + _treenodeList.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_treenodeList); } - - /** - * - * - * @param vPropertyArray - */ - public void setProperty( - final uk.ac.vamsas.objects.core.Property[] vPropertyArray) { - //-- copy array - _propertyList.clear(); - - for (int i = 0; i < vPropertyArray.length; i++) { - this._propertyList.add(vPropertyArray[i]); - } + if (_propertyList != null + && !org.castor.util.CycleBreaker.startingToCycle(_propertyList)) { + result = 37 * result + _propertyList.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_propertyList); } - - /** - * Sets the value of '_propertyList' by copying the given - * Vector. All elements will be checked for type safety. - * - * @param vPropertyList the Vector to copy. - */ - public void setProperty( - final java.util.Vector vPropertyList) { - // copy vector - this._propertyList.clear(); - - this._propertyList.addAll(vPropertyList); + if (_provenance != null + && !org.castor.util.CycleBreaker.startingToCycle(_provenance)) { + result = 37 * result + _provenance.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_provenance); } - /** - * Sets the value of '_propertyList' by setting it to the given - * Vector. No type checking is performed. - * @deprecated - * - * @param propertyVector the Vector to set. - */ - public void setPropertyAsReference( - final java.util.Vector propertyVector) { - this._propertyList = propertyVector; + return result; + } + + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() { + try { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) { + return false; } - - /** - * Sets the value of field 'provenance'. - * - * @param provenance the value of field 'provenance'. - */ - public void setProvenance( - final uk.ac.vamsas.objects.core.Provenance provenance) { - this._provenance = provenance; + return true; + } + + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, out); + } + + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, handler); + } + + /** + */ + public void removeAllNewick() { + this._newickList.clear(); + } + + /** + */ + public void removeAllProperty() { + this._propertyList.clear(); + } + + /** + */ + public void removeAllTreenode() { + this._treenodeList.clear(); + } + + /** + * Method removeNewick. + * + * @param vNewick + * @return true if the object was removed from the collection. + */ + public boolean removeNewick(final uk.ac.vamsas.objects.core.Newick vNewick) { + boolean removed = _newickList.remove(vNewick); + return removed; + } + + /** + * Method removeNewickAt. + * + * @param index + * @return the element removed from the collection + */ + public uk.ac.vamsas.objects.core.Newick removeNewickAt(final int index) { + java.lang.Object obj = this._newickList.remove(index); + return (uk.ac.vamsas.objects.core.Newick) obj; + } + + /** + * Method removeProperty. + * + * @param vProperty + * @return true if the object was removed from the collection. + */ + public boolean removeProperty( + final uk.ac.vamsas.objects.core.Property vProperty) { + boolean removed = _propertyList.remove(vProperty); + return removed; + } + + /** + * Method removePropertyAt. + * + * @param index + * @return the element removed from the collection + */ + public uk.ac.vamsas.objects.core.Property removePropertyAt(final int index) { + java.lang.Object obj = this._propertyList.remove(index); + return (uk.ac.vamsas.objects.core.Property) obj; + } + + /** + * Method removeTreenode. + * + * @param vTreenode + * @return true if the object was removed from the collection. + */ + public boolean removeTreenode( + final uk.ac.vamsas.objects.core.Treenode vTreenode) { + boolean removed = _treenodeList.remove(vTreenode); + return removed; + } + + /** + * Method removeTreenodeAt. + * + * @param index + * @return the element removed from the collection + */ + public uk.ac.vamsas.objects.core.Treenode removeTreenodeAt(final int index) { + java.lang.Object obj = this._treenodeList.remove(index); + return (uk.ac.vamsas.objects.core.Treenode) obj; + } + + /** + * 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(final java.lang.String id) { + this._id = id; + } + + /** + * Sets the value of field 'modifiable'. + * + * @param modifiable + * the value of field 'modifiable'. + */ + public void setModifiable(final java.lang.String modifiable) { + this._modifiable = modifiable; + } + + /** + * + * + * @param index + * @param vNewick + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setNewick(final int index, + final uk.ac.vamsas.objects.core.Newick vNewick) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._newickList.size()) { + throw new IndexOutOfBoundsException("setNewick: Index value '" + index + + "' not in range [0.." + (this._newickList.size() - 1) + "]"); } - /** - * Sets the value of field 'title'. - * - * @param title the value of field 'title'. - */ - public void setTitle( - final java.lang.String title) { - this._title = title; - } + this._newickList.set(index, vNewick); + } - /** - * - * - * @param index - * @param vTreenode - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setTreenode( - final int index, - final uk.ac.vamsas.objects.core.Treenode vTreenode) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._treenodeList.size()) { - throw new IndexOutOfBoundsException("setTreenode: Index value '" + index + "' not in range [0.." + (this._treenodeList.size() - 1) + "]"); - } - - this._treenodeList.set(index, vTreenode); - } + /** + * + * + * @param vNewickArray + */ + public void setNewick(final uk.ac.vamsas.objects.core.Newick[] vNewickArray) { + // -- copy array + _newickList.clear(); - /** - * - * - * @param vTreenodeArray - */ - public void setTreenode( - final uk.ac.vamsas.objects.core.Treenode[] vTreenodeArray) { - //-- copy array - _treenodeList.clear(); - - for (int i = 0; i < vTreenodeArray.length; i++) { - this._treenodeList.add(vTreenodeArray[i]); - } + for (int i = 0; i < vNewickArray.length; i++) { + this._newickList.add(vNewickArray[i]); } - - /** - * Sets the value of '_treenodeList' by copying the given - * Vector. All elements will be checked for type safety. - * - * @param vTreenodeList the Vector to copy. - */ - public void setTreenode( - final java.util.Vector vTreenodeList) { - // copy vector - this._treenodeList.clear(); - - this._treenodeList.addAll(vTreenodeList); + } + + /** + * Sets the value of '_newickList' by copying the given Vector. All elements + * will be checked for type safety. + * + * @param vNewickList + * the Vector to copy. + */ + public void setNewick(final java.util.Vector vNewickList) { + // copy vector + this._newickList.clear(); + + this._newickList.addAll(vNewickList); + } + + /** + * Sets the value of '_newickList' by setting it to the given Vector. No type + * checking is performed. + * + * @deprecated + * + * @param newickVector + * the Vector to set. + */ + public void setNewickAsReference(final java.util.Vector newickVector) { + this._newickList = newickVector; + } + + /** + * + * + * @param index + * @param vProperty + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setProperty(final int index, + final uk.ac.vamsas.objects.core.Property vProperty) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._propertyList.size()) { + throw new IndexOutOfBoundsException("setProperty: Index value '" + index + + "' not in range [0.." + (this._propertyList.size() - 1) + "]"); } - /** - * Sets the value of '_treenodeList' by setting it to the given - * Vector. No type checking is performed. - * @deprecated - * - * @param treenodeVector the Vector to set. - */ - public void setTreenodeAsReference( - final java.util.Vector treenodeVector) { - this._treenodeList = treenodeVector; + this._propertyList.set(index, vProperty); + } + + /** + * + * + * @param vPropertyArray + */ + public void setProperty( + final uk.ac.vamsas.objects.core.Property[] vPropertyArray) { + // -- copy array + _propertyList.clear(); + + for (int i = 0; i < vPropertyArray.length; i++) { + this._propertyList.add(vPropertyArray[i]); } - - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled uk.ac.vamsas.objects.core.Tree - */ - public static uk.ac.vamsas.objects.core.Tree unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (uk.ac.vamsas.objects.core.Tree) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.Tree.class, reader); + } + + /** + * Sets the value of '_propertyList' by copying the given Vector. All elements + * will be checked for type safety. + * + * @param vPropertyList + * the Vector to copy. + */ + public void setProperty(final java.util.Vector vPropertyList) { + // copy vector + this._propertyList.clear(); + + this._propertyList.addAll(vPropertyList); + } + + /** + * Sets the value of '_propertyList' by setting it to the given Vector. No + * type checking is performed. + * + * @deprecated + * + * @param propertyVector + * the Vector to set. + */ + public void setPropertyAsReference(final java.util.Vector propertyVector) { + this._propertyList = propertyVector; + } + + /** + * Sets the value of field 'provenance'. + * + * @param provenance + * the value of field 'provenance'. + */ + public void setProvenance( + final uk.ac.vamsas.objects.core.Provenance provenance) { + this._provenance = provenance; + } + + /** + * Sets the value of field 'title'. + * + * @param title + * the value of field 'title'. + */ + public void setTitle(final java.lang.String title) { + this._title = title; + } + + /** + * + * + * @param index + * @param vTreenode + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setTreenode(final int index, + final uk.ac.vamsas.objects.core.Treenode vTreenode) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._treenodeList.size()) { + throw new IndexOutOfBoundsException("setTreenode: Index value '" + index + + "' not in range [0.." + (this._treenodeList.size() - 1) + "]"); } - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); + this._treenodeList.set(index, vTreenode); + } + + /** + * + * + * @param vTreenodeArray + */ + public void setTreenode( + final uk.ac.vamsas.objects.core.Treenode[] vTreenodeArray) { + // -- copy array + _treenodeList.clear(); + + for (int i = 0; i < vTreenodeArray.length; i++) { + this._treenodeList.add(vTreenodeArray[i]); } + } + + /** + * Sets the value of '_treenodeList' by copying the given Vector. All elements + * will be checked for type safety. + * + * @param vTreenodeList + * the Vector to copy. + */ + public void setTreenode(final java.util.Vector vTreenodeList) { + // copy vector + this._treenodeList.clear(); + + this._treenodeList.addAll(vTreenodeList); + } + + /** + * Sets the value of '_treenodeList' by setting it to the given Vector. No + * type checking is performed. + * + * @deprecated + * + * @param treenodeVector + * the Vector to set. + */ + public void setTreenodeAsReference(final java.util.Vector treenodeVector) { + this._treenodeList = treenodeVector; + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @return the unmarshaled uk.ac.vamsas.objects.core.Tree + */ + public static uk.ac.vamsas.objects.core.Tree unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + return (uk.ac.vamsas.objects.core.Tree) Unmarshaller.unmarshal( + uk.ac.vamsas.objects.core.Tree.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/uk/ac/vamsas/objects/core/Treenode.java b/src/uk/ac/vamsas/objects/core/Treenode.java index 1a8620e..51ecd7e 100644 --- a/src/uk/ac/vamsas/objects/core/Treenode.java +++ b/src/uk/ac/vamsas/objects/core/Treenode.java @@ -1,448 +1,457 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import org.exolab.castor.xml.Marshaller; import org.exolab.castor.xml.Unmarshaller; /** - * node identity and mapping data between tree - * representations and vamsas document objects + * node identity and mapping data between tree representations and vamsas + * document objects * * @version $Revision$ $Date$ */ -public class Treenode extends uk.ac.vamsas.objects.core.NodeType -implements java.io.Serializable -{ - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * reference to one or more trees containing - * the node being described. - */ - private java.util.Vector _treeId; - - /** - * String uniquely identifying a particular - * node in the referenced tree according to the format of - * the tree representation that is referenced. - * - */ - private java.lang.String _nodespec; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public Treenode() { - super(); - this._treeId = new java.util.Vector(); - } - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * - * - * @param vTreeId - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addTreeId( - final java.lang.Object vTreeId) - throws java.lang.IndexOutOfBoundsException { - this._treeId.addElement(vTreeId); - } - - /** - * - * - * @param index - * @param vTreeId - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addTreeId( - final int index, - final java.lang.Object vTreeId) - throws java.lang.IndexOutOfBoundsException { - this._treeId.add(index, vTreeId); - } - - /** - * Method enumerateTreeId. - * - * @return an Enumeration over all java.lang.Object elements - */ - public java.util.Enumeration enumerateTreeId( - ) { - return this._treeId.elements(); - } - - /** - * Overrides the java.lang.Object.equals method. - * - * @param obj - * @return true if the objects are equal. - */ - public boolean equals( - final java.lang.Object obj) { - if ( this == obj ) - return true; - - if (super.equals(obj)==false) +public class Treenode extends uk.ac.vamsas.objects.core.NodeType implements + java.io.Serializable { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * reference to one or more trees containing the node being described. + */ + private java.util.Vector _treeId; + + /** + * String uniquely identifying a particular node in the referenced tree + * according to the format of the tree representation that is referenced. + * + */ + private java.lang.String _nodespec; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public Treenode() { + super(); + this._treeId = new java.util.Vector(); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * + * + * @param vTreeId + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addTreeId(final java.lang.Object vTreeId) + throws java.lang.IndexOutOfBoundsException { + this._treeId.addElement(vTreeId); + } + + /** + * + * + * @param index + * @param vTreeId + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addTreeId(final int index, final java.lang.Object vTreeId) + throws java.lang.IndexOutOfBoundsException { + this._treeId.add(index, vTreeId); + } + + /** + * Method enumerateTreeId. + * + * @return an Enumeration over all java.lang.Object elements + */ + public java.util.Enumeration enumerateTreeId() { + return this._treeId.elements(); + } + + /** + * Overrides the java.lang.Object.equals method. + * + * @param obj + * @return true if the objects are equal. + */ + public boolean equals(final java.lang.Object obj) { + if (this == obj) + return true; + + if (super.equals(obj) == false) + return false; + + if (obj instanceof Treenode) { + + Treenode temp = (Treenode) obj; + boolean thcycle; + boolean tmcycle; + if (this._treeId != null) { + if (temp._treeId == null) + return false; + if (this._treeId != temp._treeId) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._treeId); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._treeId); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._treeId); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._treeId); + } + ; return false; - - if (obj instanceof Treenode) { - - Treenode temp = (Treenode)obj; - boolean thcycle; - boolean tmcycle; - if (this._treeId != null) { - if (temp._treeId == null) return false; - if (this._treeId != temp._treeId) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._treeId); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._treeId); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._treeId); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._treeId); }; - return false; - } - if (!thcycle) { - if (!this._treeId.equals(temp._treeId)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._treeId); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._treeId); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._treeId); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._treeId); - } - } - } else if (temp._treeId != null) - return false; - if (this._nodespec != null) { - if (temp._nodespec == null) return false; - if (this._nodespec != temp._nodespec) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._nodespec); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._nodespec); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._nodespec); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._nodespec); }; - return false; - } - if (!thcycle) { - if (!this._nodespec.equals(temp._nodespec)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._nodespec); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._nodespec); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._nodespec); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._nodespec); - } - } - } else if (temp._nodespec != null) - return false; - return true; + } + if (!thcycle) { + if (!this._treeId.equals(temp._treeId)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._treeId); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._treeId); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._treeId); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._treeId); + } } + } else if (temp._treeId != null) return false; - } - - /** - * Returns the value of field 'nodespec'. The field 'nodespec' - * has the following description: String uniquely identifying a - * particular - * node in the referenced tree according to the format of - * the tree representation that is referenced. - * - * - * @return the value of field 'Nodespec'. - */ - public java.lang.String getNodespec( - ) { - return this._nodespec; - } - - /** - * Method getTreeId. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the java.lang.Object at the given index - */ - public java.lang.Object getTreeId( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._treeId.size()) { - throw new IndexOutOfBoundsException("getTreeId: Index value '" + index + "' not in range [0.." + (this._treeId.size() - 1) + "]"); - } - - return _treeId.get(index); - } - - /** - * Method getTreeId.Returns the contents of the collection in - * an Array.

Note: Just in case the collection contents - * are changing in another thread, we pass a 0-length Array of - * the correct type into the API call. This way we know - * that the Array returned is of exactly the correct length. - * - * @return this collection as an Array - */ - public java.lang.Object[] getTreeId( - ) { - java.lang.Object[] array = new java.lang.Object[0]; - return (java.lang.Object[]) this._treeId.toArray(array); - } - - /** - * Method getTreeIdAsReference.Returns a reference to - * '_treeId'. No type checking is performed on any - * modifications to the Vector. - * - * @return a reference to the Vector backing this class - */ - public java.util.Vector getTreeIdAsReference( - ) { - return this._treeId; - } - - /** - * Method getTreeIdCount. - * - * @return the size of this collection - */ - public int getTreeIdCount( - ) { - return this._treeId.size(); - } - - /** - * Overrides the java.lang.Object.hashCode method. - *

- * The following steps came from Effective Java Programming - * Language Guide by Joshua Bloch, Chapter 3 - * - * @return a hash code value for the object. - */ - public int hashCode( - ) { - int result = super.hashCode(); - - long tmp; - if (_treeId != null - && !org.castor.util.CycleBreaker.startingToCycle(_treeId)) { - result = 37 * result + _treeId.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_treeId); - } - if (_nodespec != null - && !org.castor.util.CycleBreaker.startingToCycle(_nodespec)) { - result = 37 * result + _nodespec.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_nodespec); - } - - return result; - } - - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { + if (this._nodespec != null) { + if (temp._nodespec == null) + return false; + if (this._nodespec != temp._nodespec) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._nodespec); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._nodespec); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._nodespec); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._nodespec); + } + ; return false; + } + if (!thcycle) { + if (!this._nodespec.equals(temp._nodespec)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._nodespec); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._nodespec); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._nodespec); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._nodespec); + } } - return true; - } - - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } - - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } - - /** - */ - public void removeAllTreeId( - ) { - this._treeId.clear(); + } else if (temp._nodespec != null) + return false; + return true; } - - /** - * Method removeTreeId. - * - * @param vTreeId - * @return true if the object was removed from the collection. - */ - public boolean removeTreeId( - final java.lang.Object vTreeId) { - boolean removed = _treeId.remove(vTreeId); - return removed; + return false; + } + + /** + * Returns the value of field 'nodespec'. The field 'nodespec' has the + * following description: String uniquely identifying a particular node in the + * referenced tree according to the format of the tree representation that is + * referenced. + * + * + * @return the value of field 'Nodespec'. + */ + public java.lang.String getNodespec() { + return this._nodespec; + } + + /** + * Method getTreeId. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the java.lang.Object at the given index + */ + public java.lang.Object getTreeId(final int index) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._treeId.size()) { + throw new IndexOutOfBoundsException("getTreeId: Index value '" + index + + "' not in range [0.." + (this._treeId.size() - 1) + "]"); } - /** - * Method removeTreeIdAt. - * - * @param index - * @return the element removed from the collection - */ - public java.lang.Object removeTreeIdAt( - final int index) { - java.lang.Object obj = this._treeId.remove(index); - return obj; + return _treeId.get(index); + } + + /** + * Method getTreeId.Returns the contents of the collection in an Array. + *

+ * Note: Just in case the collection contents are changing in another thread, + * we pass a 0-length Array of the correct type into the API call. This way we + * know that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public java.lang.Object[] getTreeId() { + java.lang.Object[] array = new java.lang.Object[0]; + return (java.lang.Object[]) this._treeId.toArray(array); + } + + /** + * Method getTreeIdAsReference.Returns a reference to '_treeId'. No type + * checking is performed on any modifications to the Vector. + * + * @return a reference to the Vector backing this class + */ + public java.util.Vector getTreeIdAsReference() { + return this._treeId; + } + + /** + * Method getTreeIdCount. + * + * @return the size of this collection + */ + public int getTreeIdCount() { + return this._treeId.size(); + } + + /** + * Overrides the java.lang.Object.hashCode method. + *

+ * The following steps came from Effective Java Programming Language + * Guide by Joshua Bloch, Chapter 3 + * + * @return a hash code value for the object. + */ + public int hashCode() { + int result = super.hashCode(); + + long tmp; + if (_treeId != null + && !org.castor.util.CycleBreaker.startingToCycle(_treeId)) { + result = 37 * result + _treeId.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_treeId); } - - /** - * Sets the value of field 'nodespec'. The field 'nodespec' has - * the following description: String uniquely identifying a - * particular - * node in the referenced tree according to the format of - * the tree representation that is referenced. - * - * - * @param nodespec the value of field 'nodespec'. - */ - public void setNodespec( - final java.lang.String nodespec) { - this._nodespec = nodespec; + if (_nodespec != null + && !org.castor.util.CycleBreaker.startingToCycle(_nodespec)) { + result = 37 * result + _nodespec.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_nodespec); } - /** - * - * - * @param index - * @param vTreeId - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setTreeId( - final int index, - final java.lang.Object vTreeId) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._treeId.size()) { - throw new IndexOutOfBoundsException("setTreeId: Index value '" + index + "' not in range [0.." + (this._treeId.size() - 1) + "]"); - } - - this._treeId.set(index, vTreeId); + return result; + } + + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() { + try { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) { + return false; } - - /** - * - * - * @param vTreeIdArray + return true; + } + + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, out); + } + + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, handler); + } + + /** */ - public void setTreeId( - final java.lang.Object[] vTreeIdArray) { - //-- copy array - _treeId.clear(); - - for (int i = 0; i < vTreeIdArray.length; i++) { - this._treeId.add(vTreeIdArray[i]); - } + public void removeAllTreeId() { + this._treeId.clear(); + } + + /** + * Method removeTreeId. + * + * @param vTreeId + * @return true if the object was removed from the collection. + */ + public boolean removeTreeId(final java.lang.Object vTreeId) { + boolean removed = _treeId.remove(vTreeId); + return removed; + } + + /** + * Method removeTreeIdAt. + * + * @param index + * @return the element removed from the collection + */ + public java.lang.Object removeTreeIdAt(final int index) { + java.lang.Object obj = this._treeId.remove(index); + return obj; + } + + /** + * Sets the value of field 'nodespec'. The field 'nodespec' has the following + * description: String uniquely identifying a particular node in the + * referenced tree according to the format of the tree representation that is + * referenced. + * + * + * @param nodespec + * the value of field 'nodespec'. + */ + public void setNodespec(final java.lang.String nodespec) { + this._nodespec = nodespec; + } + + /** + * + * + * @param index + * @param vTreeId + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setTreeId(final int index, final java.lang.Object vTreeId) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._treeId.size()) { + throw new IndexOutOfBoundsException("setTreeId: Index value '" + index + + "' not in range [0.." + (this._treeId.size() - 1) + "]"); } - /** - * Sets the value of '_treeId' by copying the given Vector. All - * elements will be checked for type safety. - * - * @param vTreeIdList the Vector to copy. - */ - public void setTreeId( - final java.util.Vector vTreeIdList) { - // copy vector - this._treeId.clear(); - - this._treeId.addAll(vTreeIdList); - } + this._treeId.set(index, vTreeId); + } - /** - * Sets the value of '_treeId' by setting it to the given - * Vector. No type checking is performed. - * @deprecated - * - * @param treeIdVector the Vector to set. - */ - public void setTreeIdAsReference( - final java.util.Vector treeIdVector) { - this._treeId = treeIdVector; - } + /** + * + * + * @param vTreeIdArray + */ + public void setTreeId(final java.lang.Object[] vTreeIdArray) { + // -- copy array + _treeId.clear(); - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled uk.ac.vamsas.objects.core.NodeType - */ - public static uk.ac.vamsas.objects.core.NodeType unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (uk.ac.vamsas.objects.core.NodeType) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.Treenode.class, reader); - } - - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); + for (int i = 0; i < vTreeIdArray.length; i++) { + this._treeId.add(vTreeIdArray[i]); } + } + + /** + * Sets the value of '_treeId' by copying the given Vector. All elements will + * be checked for type safety. + * + * @param vTreeIdList + * the Vector to copy. + */ + public void setTreeId(final java.util.Vector vTreeIdList) { + // copy vector + this._treeId.clear(); + + this._treeId.addAll(vTreeIdList); + } + + /** + * Sets the value of '_treeId' by setting it to the given Vector. No type + * checking is performed. + * + * @deprecated + * + * @param treeIdVector + * the Vector to set. + */ + public void setTreeIdAsReference(final java.util.Vector treeIdVector) { + this._treeId = treeIdVector; + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @return the unmarshaled uk.ac.vamsas.objects.core.NodeType + */ + public static uk.ac.vamsas.objects.core.NodeType unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + return (uk.ac.vamsas.objects.core.NodeType) Unmarshaller.unmarshal( + uk.ac.vamsas.objects.core.Treenode.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/uk/ac/vamsas/objects/core/User.java b/src/uk/ac/vamsas/objects/core/User.java index 0339959..957c99c 100644 --- a/src/uk/ac/vamsas/objects/core/User.java +++ b/src/uk/ac/vamsas/objects/core/User.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import org.exolab.castor.xml.Marshaller; @@ -17,250 +31,267 @@ import org.exolab.castor.xml.Unmarshaller; /** * Class User. * - * @version $Revision$ $Date$ + * @version $Revision$ $Date: 2007-06-28 14:51:44 +0100 (Thu, 28 Jun 2007) + * $ */ -public class User extends uk.ac.vamsas.objects.core.AppData -implements java.io.Serializable -{ +public class User extends uk.ac.vamsas.objects.core.AppData implements + java.io.Serializable { + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ + /** + * Field _fullname. + */ + private java.lang.String _fullname; - /** - * Field _fullname. - */ - private java.lang.String _fullname; + /** + * Field _organization. + */ + private java.lang.String _organization; - /** - * Field _organization. - */ - private java.lang.String _organization; + // ----------------/ + // - Constructors -/ + // ----------------/ + public User() { + super(); + } - //----------------/ - //- Constructors -/ - //----------------/ + // -----------/ + // - Methods -/ + // -----------/ - public User() { - super(); - } + /** + * Overrides the java.lang.Object.equals method. + * + * @param obj + * @return true if the objects are equal. + */ + public boolean equals(final java.lang.Object obj) { + if (this == obj) + return true; + if (super.equals(obj) == false) + return false; - //-----------/ - //- Methods -/ - //-----------/ + if (obj instanceof User) { - /** - * Overrides the java.lang.Object.equals method. - * - * @param obj - * @return true if the objects are equal. - */ - public boolean equals( - final java.lang.Object obj) { - if ( this == obj ) - return true; - - if (super.equals(obj)==false) + User temp = (User) obj; + boolean thcycle; + boolean tmcycle; + if (this._fullname != null) { + if (temp._fullname == null) + return false; + if (this._fullname != temp._fullname) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._fullname); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._fullname); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._fullname); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._fullname); + } + ; return false; - - if (obj instanceof User) { - - User temp = (User)obj; - boolean thcycle; - boolean tmcycle; - if (this._fullname != null) { - if (temp._fullname == null) return false; - if (this._fullname != temp._fullname) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._fullname); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._fullname); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._fullname); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._fullname); }; - return false; - } - if (!thcycle) { - if (!this._fullname.equals(temp._fullname)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._fullname); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._fullname); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._fullname); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._fullname); - } - } - } else if (temp._fullname != null) - return false; - if (this._organization != null) { - if (temp._organization == null) return false; - if (this._organization != temp._organization) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._organization); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._organization); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._organization); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._organization); }; - return false; - } - if (!thcycle) { - if (!this._organization.equals(temp._organization)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._organization); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._organization); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._organization); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._organization); - } - } - } else if (temp._organization != null) - return false; - return true; + } + if (!thcycle) { + if (!this._fullname.equals(temp._fullname)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._fullname); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._fullname); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._fullname); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._fullname); + } } + } else if (temp._fullname != null) return false; + if (this._organization != null) { + if (temp._organization == null) + return false; + if (this._organization != temp._organization) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._organization); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._organization); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker + .releaseCycleHandle(this._organization); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._organization); + } + ; + return false; + } + if (!thcycle) { + if (!this._organization.equals(temp._organization)) { + org.castor.util.CycleBreaker + .releaseCycleHandle(this._organization); + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._organization); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._organization); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._organization); + } + } + } else if (temp._organization != null) + return false; + return true; } + return false; + } - /** - * Returns the value of field 'fullname'. - * - * @return the value of field 'Fullname'. - */ - public java.lang.String getFullname( - ) { - return this._fullname; - } + /** + * Returns the value of field 'fullname'. + * + * @return the value of field 'Fullname'. + */ + public java.lang.String getFullname() { + return this._fullname; + } - /** - * Returns the value of field 'organization'. - * - * @return the value of field 'Organization'. - */ - public java.lang.String getOrganization( - ) { - return this._organization; - } + /** + * Returns the value of field 'organization'. + * + * @return the value of field 'Organization'. + */ + public java.lang.String getOrganization() { + return this._organization; + } - /** - * Overrides the java.lang.Object.hashCode method. - *

- * The following steps came from Effective Java Programming - * Language Guide by Joshua Bloch, Chapter 3 - * - * @return a hash code value for the object. - */ - public int hashCode( - ) { - int result = super.hashCode(); - - long tmp; - if (_fullname != null - && !org.castor.util.CycleBreaker.startingToCycle(_fullname)) { - result = 37 * result + _fullname.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_fullname); - } - if (_organization != null - && !org.castor.util.CycleBreaker.startingToCycle(_organization)) { - result = 37 * result + _organization.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_organization); - } - - return result; - } + /** + * Overrides the java.lang.Object.hashCode method. + *

+ * The following steps came from Effective Java Programming Language + * Guide by Joshua Bloch, Chapter 3 + * + * @return a hash code value for the object. + */ + public int hashCode() { + int result = super.hashCode(); - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { - return false; - } - return true; + long tmp; + if (_fullname != null + && !org.castor.util.CycleBreaker.startingToCycle(_fullname)) { + result = 37 * result + _fullname.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_fullname); } - - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); + if (_organization != null + && !org.castor.util.CycleBreaker.startingToCycle(_organization)) { + result = 37 * result + _organization.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_organization); } - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } + return result; + } - /** - * Sets the value of field 'fullname'. - * - * @param fullname the value of field 'fullname'. - */ - public void setFullname( - final java.lang.String fullname) { - this._fullname = fullname; + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() { + try { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) { + return false; } + return true; + } - /** - * Sets the value of field 'organization'. - * - * @param organization the value of field 'organization'. - */ - public void setOrganization( - final java.lang.String organization) { - this._organization = organization; - } + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, out); + } - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled uk.ac.vamsas.objects.core.AppData - */ - public static uk.ac.vamsas.objects.core.AppData unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (uk.ac.vamsas.objects.core.AppData) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.User.class, reader); - } + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, handler); + } - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); - } + /** + * Sets the value of field 'fullname'. + * + * @param fullname + * the value of field 'fullname'. + */ + public void setFullname(final java.lang.String fullname) { + this._fullname = fullname; + } + + /** + * Sets the value of field 'organization'. + * + * @param organization + * the value of field 'organization'. + */ + public void setOrganization(final java.lang.String organization) { + this._organization = organization; + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @return the unmarshaled uk.ac.vamsas.objects.core.AppData + */ + public static uk.ac.vamsas.objects.core.AppData unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + return (uk.ac.vamsas.objects.core.AppData) Unmarshaller.unmarshal( + uk.ac.vamsas.objects.core.User.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/uk/ac/vamsas/objects/core/VAMSAS.java b/src/uk/ac/vamsas/objects/core/VAMSAS.java index a762b20..320dcb5 100644 --- a/src/uk/ac/vamsas/objects/core/VAMSAS.java +++ b/src/uk/ac/vamsas/objects/core/VAMSAS.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import org.exolab.castor.xml.Marshaller; @@ -16,698 +30,706 @@ import org.exolab.castor.xml.Unmarshaller; /** * contains unassociated trees and a number of analysis sets - * * - * @version $Revision$ $Date$ + * + * @version $Revision$ $Date: 2007-06-28 14:51:44 +0100 (Thu, 28 Jun 2007) + * $ */ -public class VAMSAS extends uk.ac.vamsas.client.Vobject -implements java.io.Serializable -{ - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Primary Key for vamsas object referencing - */ - private java.lang.String _id; - - /** - * Field _modifiable. - */ - private java.lang.String _modifiable; - - /** - * Field _treeList. - */ - private java.util.Vector _treeList; - - /** - * Field _dataSetList. - */ - private java.util.Vector _dataSetList; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public VAMSAS() { - super(); - this._treeList = new java.util.Vector(); - this._dataSetList = new java.util.Vector(); - } - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * - * - * @param vDataSet - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addDataSet( - final uk.ac.vamsas.objects.core.DataSet vDataSet) - throws java.lang.IndexOutOfBoundsException { - this._dataSetList.addElement(vDataSet); - } - - /** - * - * - * @param index - * @param vDataSet - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addDataSet( - final int index, - final uk.ac.vamsas.objects.core.DataSet vDataSet) - throws java.lang.IndexOutOfBoundsException { - this._dataSetList.add(index, vDataSet); - } - - /** - * - * - * @param vTree - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addTree( - final uk.ac.vamsas.objects.core.Tree vTree) - throws java.lang.IndexOutOfBoundsException { - this._treeList.addElement(vTree); - } - - /** - * - * - * @param index - * @param vTree - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addTree( - final int index, - final uk.ac.vamsas.objects.core.Tree vTree) - throws java.lang.IndexOutOfBoundsException { - this._treeList.add(index, vTree); - } - - /** - * Method enumerateDataSet. - * - * @return an Enumeration over all - * uk.ac.vamsas.objects.core.DataSet elements - */ - public java.util.Enumeration enumerateDataSet( - ) { - return this._dataSetList.elements(); - } - - /** - * Method enumerateTree. - * - * @return an Enumeration over all - * uk.ac.vamsas.objects.core.Tree elements - */ - public java.util.Enumeration enumerateTree( - ) { - return this._treeList.elements(); - } - - /** - * Overrides the java.lang.Object.equals method. - * - * @param obj - * @return true if the objects are equal. - */ - public boolean equals( - final java.lang.Object obj) { - if ( this == obj ) - return true; - - if (super.equals(obj)==false) +public class VAMSAS extends uk.ac.vamsas.client.Vobject implements + java.io.Serializable { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Primary Key for vamsas object referencing + */ + private java.lang.String _id; + + /** + * Field _modifiable. + */ + private java.lang.String _modifiable; + + /** + * Field _treeList. + */ + private java.util.Vector _treeList; + + /** + * Field _dataSetList. + */ + private java.util.Vector _dataSetList; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public VAMSAS() { + super(); + this._treeList = new java.util.Vector(); + this._dataSetList = new java.util.Vector(); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * + * + * @param vDataSet + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addDataSet(final uk.ac.vamsas.objects.core.DataSet vDataSet) + throws java.lang.IndexOutOfBoundsException { + this._dataSetList.addElement(vDataSet); + } + + /** + * + * + * @param index + * @param vDataSet + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addDataSet(final int index, + final uk.ac.vamsas.objects.core.DataSet vDataSet) + throws java.lang.IndexOutOfBoundsException { + this._dataSetList.add(index, vDataSet); + } + + /** + * + * + * @param vTree + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addTree(final uk.ac.vamsas.objects.core.Tree vTree) + throws java.lang.IndexOutOfBoundsException { + this._treeList.addElement(vTree); + } + + /** + * + * + * @param index + * @param vTree + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addTree(final int index, + final uk.ac.vamsas.objects.core.Tree vTree) + throws java.lang.IndexOutOfBoundsException { + this._treeList.add(index, vTree); + } + + /** + * Method enumerateDataSet. + * + * @return an Enumeration over all uk.ac.vamsas.objects.core.DataSet elements + */ + public java.util.Enumeration enumerateDataSet() { + return this._dataSetList.elements(); + } + + /** + * Method enumerateTree. + * + * @return an Enumeration over all uk.ac.vamsas.objects.core.Tree elements + */ + public java.util.Enumeration enumerateTree() { + return this._treeList.elements(); + } + + /** + * Overrides the java.lang.Object.equals method. + * + * @param obj + * @return true if the objects are equal. + */ + public boolean equals(final java.lang.Object obj) { + if (this == obj) + return true; + + if (super.equals(obj) == false) + return false; + + if (obj instanceof VAMSAS) { + + VAMSAS temp = (VAMSAS) obj; + boolean thcycle; + boolean tmcycle; + if (this._id != null) { + if (temp._id == null) + return false; + if (this._id != temp._id) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._id); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._id); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._id); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); + } + ; return false; - - if (obj instanceof VAMSAS) { - - VAMSAS temp = (VAMSAS)obj; - boolean thcycle; - boolean tmcycle; - if (this._id != null) { - if (temp._id == null) return false; - if (this._id != temp._id) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._id); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._id); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._id); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); }; - return false; - } - if (!thcycle) { - if (!this._id.equals(temp._id)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._id); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._id); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); - } - } - } else if (temp._id != null) - return false; - if (this._modifiable != null) { - if (temp._modifiable == null) return false; - if (this._modifiable != temp._modifiable) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._modifiable); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._modifiable); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._modifiable); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._modifiable); }; - return false; - } - if (!thcycle) { - if (!this._modifiable.equals(temp._modifiable)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._modifiable); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._modifiable); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._modifiable); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._modifiable); - } - } - } else if (temp._modifiable != null) - return false; - if (this._treeList != null) { - if (temp._treeList == null) return false; - if (this._treeList != temp._treeList) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._treeList); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._treeList); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._treeList); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._treeList); }; - return false; - } - if (!thcycle) { - if (!this._treeList.equals(temp._treeList)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._treeList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._treeList); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._treeList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._treeList); - } - } - } else if (temp._treeList != null) - return false; - if (this._dataSetList != null) { - if (temp._dataSetList == null) return false; - if (this._dataSetList != temp._dataSetList) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._dataSetList); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._dataSetList); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._dataSetList); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._dataSetList); }; - return false; - } - if (!thcycle) { - if (!this._dataSetList.equals(temp._dataSetList)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._dataSetList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._dataSetList); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._dataSetList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._dataSetList); - } - } - } else if (temp._dataSetList != null) - return false; - return true; + } + if (!thcycle) { + if (!this._id.equals(temp._id)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._id); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._id); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); + } } + } else if (temp._id != null) return false; - } - - /** - * Method getDataSet. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the uk.ac.vamsas.objects.core.DataSet - * at the given index - */ - public uk.ac.vamsas.objects.core.DataSet getDataSet( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._dataSetList.size()) { - throw new IndexOutOfBoundsException("getDataSet: Index value '" + index + "' not in range [0.." + (this._dataSetList.size() - 1) + "]"); - } - - return (uk.ac.vamsas.objects.core.DataSet) _dataSetList.get(index); - } - - /** - * Method getDataSet.Returns the contents of the collection in - * an Array.

Note: Just in case the collection contents - * are changing in another thread, we pass a 0-length Array of - * the correct type into the API call. This way we know - * that the Array returned is of exactly the correct length. - * - * @return this collection as an Array - */ - public uk.ac.vamsas.objects.core.DataSet[] getDataSet( - ) { - uk.ac.vamsas.objects.core.DataSet[] array = new uk.ac.vamsas.objects.core.DataSet[0]; - return (uk.ac.vamsas.objects.core.DataSet[]) this._dataSetList.toArray(array); - } - - /** - * Method getDataSetAsReference.Returns a reference to - * '_dataSetList'. No type checking is performed on any - * modifications to the Vector. - * - * @return a reference to the Vector backing this class - */ - public java.util.Vector getDataSetAsReference( - ) { - return this._dataSetList; - } - - /** - * Method getDataSetCount. - * - * @return the size of this collection - */ - public int getDataSetCount( - ) { - return this._dataSetList.size(); - } - - /** - * Returns the value of field 'id'. The field 'id' has the - * following description: Primary Key for vamsas object - * referencing - * - * @return the value of field 'Id'. - */ - public java.lang.String getId( - ) { - return this._id; - } - - /** - * Returns the value of field 'modifiable'. - * - * @return the value of field 'Modifiable'. - */ - public java.lang.String getModifiable( - ) { - return this._modifiable; - } - - /** - * Method getTree. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the uk.ac.vamsas.objects.core.Tree at - * the given index - */ - public uk.ac.vamsas.objects.core.Tree getTree( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._treeList.size()) { - throw new IndexOutOfBoundsException("getTree: Index value '" + index + "' not in range [0.." + (this._treeList.size() - 1) + "]"); - } - - return (uk.ac.vamsas.objects.core.Tree) _treeList.get(index); - } - - /** - * Method getTree.Returns the contents of the collection in an - * Array.

Note: Just in case the collection contents are - * changing in another thread, we pass a 0-length Array of the - * correct type into the API call. This way we know - * that the Array returned is of exactly the correct length. - * - * @return this collection as an Array - */ - public uk.ac.vamsas.objects.core.Tree[] getTree( - ) { - uk.ac.vamsas.objects.core.Tree[] array = new uk.ac.vamsas.objects.core.Tree[0]; - return (uk.ac.vamsas.objects.core.Tree[]) this._treeList.toArray(array); - } - - /** - * Method getTreeAsReference.Returns a reference to - * '_treeList'. No type checking is performed on any - * modifications to the Vector. - * - * @return a reference to the Vector backing this class - */ - public java.util.Vector getTreeAsReference( - ) { - return this._treeList; - } - - /** - * Method getTreeCount. - * - * @return the size of this collection - */ - public int getTreeCount( - ) { - return this._treeList.size(); - } - - /** - * Overrides the java.lang.Object.hashCode method. - *

- * The following steps came from Effective Java Programming - * Language Guide by Joshua Bloch, Chapter 3 - * - * @return a hash code value for the object. - */ - public int hashCode( - ) { - int result = super.hashCode(); - - long tmp; - if (_id != null - && !org.castor.util.CycleBreaker.startingToCycle(_id)) { - result = 37 * result + _id.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_id); - } - if (_modifiable != null - && !org.castor.util.CycleBreaker.startingToCycle(_modifiable)) { - result = 37 * result + _modifiable.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_modifiable); - } - if (_treeList != null - && !org.castor.util.CycleBreaker.startingToCycle(_treeList)) { - result = 37 * result + _treeList.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_treeList); - } - if (_dataSetList != null - && !org.castor.util.CycleBreaker.startingToCycle(_dataSetList)) { - result = 37 * result + _dataSetList.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_dataSetList); - } - - return result; - } - - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { + if (this._modifiable != null) { + if (temp._modifiable == null) + return false; + if (this._modifiable != temp._modifiable) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._modifiable); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._modifiable); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._modifiable); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._modifiable); + } + ; return false; + } + if (!thcycle) { + if (!this._modifiable.equals(temp._modifiable)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._modifiable); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._modifiable); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._modifiable); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._modifiable); + } } - return true; - } - - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } - - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } - - /** - */ - public void removeAllDataSet( - ) { - this._dataSetList.clear(); - } - - /** - */ - public void removeAllTree( - ) { - this._treeList.clear(); - } - - /** - * Method removeDataSet. - * - * @param vDataSet - * @return true if the object was removed from the collection. - */ - public boolean removeDataSet( - final uk.ac.vamsas.objects.core.DataSet vDataSet) { - boolean removed = _dataSetList.remove(vDataSet); - return removed; - } - - /** - * Method removeDataSetAt. - * - * @param index - * @return the element removed from the collection - */ - public uk.ac.vamsas.objects.core.DataSet removeDataSetAt( - final int index) { - java.lang.Object obj = this._dataSetList.remove(index); - return (uk.ac.vamsas.objects.core.DataSet) obj; - } - - /** - * Method removeTree. - * - * @param vTree - * @return true if the object was removed from the collection. - */ - public boolean removeTree( - final uk.ac.vamsas.objects.core.Tree vTree) { - boolean removed = _treeList.remove(vTree); - return removed; - } - - /** - * Method removeTreeAt. - * - * @param index - * @return the element removed from the collection - */ - public uk.ac.vamsas.objects.core.Tree removeTreeAt( - final int index) { - java.lang.Object obj = this._treeList.remove(index); - return (uk.ac.vamsas.objects.core.Tree) obj; - } - - /** - * - * - * @param index - * @param vDataSet - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setDataSet( - final int index, - final uk.ac.vamsas.objects.core.DataSet vDataSet) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._dataSetList.size()) { - throw new IndexOutOfBoundsException("setDataSet: Index value '" + index + "' not in range [0.." + (this._dataSetList.size() - 1) + "]"); - } - - this._dataSetList.set(index, vDataSet); - } - - /** - * - * - * @param vDataSetArray - */ - public void setDataSet( - final uk.ac.vamsas.objects.core.DataSet[] vDataSetArray) { - //-- copy array - _dataSetList.clear(); - - for (int i = 0; i < vDataSetArray.length; i++) { - this._dataSetList.add(vDataSetArray[i]); - } - } - - /** - * Sets the value of '_dataSetList' by copying the given - * Vector. All elements will be checked for type safety. - * - * @param vDataSetList the Vector to copy. - */ - public void setDataSet( - final java.util.Vector vDataSetList) { - // copy vector - this._dataSetList.clear(); - - this._dataSetList.addAll(vDataSetList); - } - - /** - * Sets the value of '_dataSetList' by setting it to the given - * Vector. No type checking is performed. - * @deprecated - * - * @param dataSetVector the Vector to set. - */ - public void setDataSetAsReference( - final java.util.Vector dataSetVector) { - this._dataSetList = dataSetVector; - } - - /** - * 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( - final java.lang.String id) { - this._id = id; - } - - /** - * Sets the value of field 'modifiable'. - * - * @param modifiable the value of field 'modifiable'. - */ - public void setModifiable( - final java.lang.String modifiable) { - this._modifiable = modifiable; - } - - /** - * - * - * @param index - * @param vTree - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setTree( - final int index, - final uk.ac.vamsas.objects.core.Tree vTree) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._treeList.size()) { - throw new IndexOutOfBoundsException("setTree: Index value '" + index + "' not in range [0.." + (this._treeList.size() - 1) + "]"); + } else if (temp._modifiable != null) + return false; + if (this._treeList != null) { + if (temp._treeList == null) + return false; + if (this._treeList != temp._treeList) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._treeList); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._treeList); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._treeList); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._treeList); + } + ; + return false; + } + if (!thcycle) { + if (!this._treeList.equals(temp._treeList)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._treeList); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._treeList); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._treeList); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._treeList); + } } - - this._treeList.set(index, vTree); - } - - /** - * - * - * @param vTreeArray - */ - public void setTree( - final uk.ac.vamsas.objects.core.Tree[] vTreeArray) { - //-- copy array - _treeList.clear(); - - for (int i = 0; i < vTreeArray.length; i++) { - this._treeList.add(vTreeArray[i]); + } else if (temp._treeList != null) + return false; + if (this._dataSetList != null) { + if (temp._dataSetList == null) + return false; + if (this._dataSetList != temp._dataSetList) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._dataSetList); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._dataSetList); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker + .releaseCycleHandle(this._dataSetList); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._dataSetList); + } + ; + return false; + } + if (!thcycle) { + if (!this._dataSetList.equals(temp._dataSetList)) { + org.castor.util.CycleBreaker + .releaseCycleHandle(this._dataSetList); + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._dataSetList); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._dataSetList); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._dataSetList); + } } - } - - /** - * Sets the value of '_treeList' by copying the given Vector. - * All elements will be checked for type safety. - * - * @param vTreeList the Vector to copy. - */ - public void setTree( - final java.util.Vector vTreeList) { - // copy vector - this._treeList.clear(); - - this._treeList.addAll(vTreeList); - } - - /** - * Sets the value of '_treeList' by setting it to the given - * Vector. No type checking is performed. - * @deprecated - * - * @param treeVector the Vector to set. - */ - public void setTreeAsReference( - final java.util.Vector treeVector) { - this._treeList = treeVector; - } - - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled uk.ac.vamsas.objects.core.VAMSAS - */ - public static uk.ac.vamsas.objects.core.VAMSAS unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (uk.ac.vamsas.objects.core.VAMSAS) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.VAMSAS.class, reader); - } - - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); - } + } else if (temp._dataSetList != null) + return false; + return true; + } + return false; + } + + /** + * Method getDataSet. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the uk.ac.vamsas.objects.core.DataSet at the given + * index + */ + public uk.ac.vamsas.objects.core.DataSet getDataSet(final int index) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._dataSetList.size()) { + throw new IndexOutOfBoundsException("getDataSet: Index value '" + index + + "' not in range [0.." + (this._dataSetList.size() - 1) + "]"); + } + + return (uk.ac.vamsas.objects.core.DataSet) _dataSetList.get(index); + } + + /** + * Method getDataSet.Returns the contents of the collection in an Array. + *

+ * Note: Just in case the collection contents are changing in another thread, + * we pass a 0-length Array of the correct type into the API call. This way we + * know that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public uk.ac.vamsas.objects.core.DataSet[] getDataSet() { + uk.ac.vamsas.objects.core.DataSet[] array = new uk.ac.vamsas.objects.core.DataSet[0]; + return (uk.ac.vamsas.objects.core.DataSet[]) this._dataSetList + .toArray(array); + } + + /** + * Method getDataSetAsReference.Returns a reference to '_dataSetList'. No type + * checking is performed on any modifications to the Vector. + * + * @return a reference to the Vector backing this class + */ + public java.util.Vector getDataSetAsReference() { + return this._dataSetList; + } + + /** + * Method getDataSetCount. + * + * @return the size of this collection + */ + public int getDataSetCount() { + return this._dataSetList.size(); + } + + /** + * Returns the value of field 'id'. The field 'id' has the following + * description: Primary Key for vamsas object referencing + * + * @return the value of field 'Id'. + */ + public java.lang.String getId() { + return this._id; + } + + /** + * Returns the value of field 'modifiable'. + * + * @return the value of field 'Modifiable'. + */ + public java.lang.String getModifiable() { + return this._modifiable; + } + + /** + * Method getTree. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the uk.ac.vamsas.objects.core.Tree at the given index + */ + public uk.ac.vamsas.objects.core.Tree getTree(final int index) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._treeList.size()) { + throw new IndexOutOfBoundsException("getTree: Index value '" + index + + "' not in range [0.." + (this._treeList.size() - 1) + "]"); + } + + return (uk.ac.vamsas.objects.core.Tree) _treeList.get(index); + } + + /** + * Method getTree.Returns the contents of the collection in an Array. + *

+ * Note: Just in case the collection contents are changing in another thread, + * we pass a 0-length Array of the correct type into the API call. This way we + * know that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public uk.ac.vamsas.objects.core.Tree[] getTree() { + uk.ac.vamsas.objects.core.Tree[] array = new uk.ac.vamsas.objects.core.Tree[0]; + return (uk.ac.vamsas.objects.core.Tree[]) this._treeList.toArray(array); + } + + /** + * Method getTreeAsReference.Returns a reference to '_treeList'. No type + * checking is performed on any modifications to the Vector. + * + * @return a reference to the Vector backing this class + */ + public java.util.Vector getTreeAsReference() { + return this._treeList; + } + + /** + * Method getTreeCount. + * + * @return the size of this collection + */ + public int getTreeCount() { + return this._treeList.size(); + } + + /** + * Overrides the java.lang.Object.hashCode method. + *

+ * The following steps came from Effective Java Programming Language + * Guide by Joshua Bloch, Chapter 3 + * + * @return a hash code value for the object. + */ + public int hashCode() { + int result = super.hashCode(); + + long tmp; + if (_id != null && !org.castor.util.CycleBreaker.startingToCycle(_id)) { + result = 37 * result + _id.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_id); + } + if (_modifiable != null + && !org.castor.util.CycleBreaker.startingToCycle(_modifiable)) { + result = 37 * result + _modifiable.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_modifiable); + } + if (_treeList != null + && !org.castor.util.CycleBreaker.startingToCycle(_treeList)) { + result = 37 * result + _treeList.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_treeList); + } + if (_dataSetList != null + && !org.castor.util.CycleBreaker.startingToCycle(_dataSetList)) { + result = 37 * result + _dataSetList.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_dataSetList); + } + + return result; + } + + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() { + try { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) { + return false; + } + return true; + } + + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, out); + } + + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, handler); + } + + /** + */ + public void removeAllDataSet() { + this._dataSetList.clear(); + } + + /** + */ + public void removeAllTree() { + this._treeList.clear(); + } + + /** + * Method removeDataSet. + * + * @param vDataSet + * @return true if the object was removed from the collection. + */ + public boolean removeDataSet(final uk.ac.vamsas.objects.core.DataSet vDataSet) { + boolean removed = _dataSetList.remove(vDataSet); + return removed; + } + + /** + * Method removeDataSetAt. + * + * @param index + * @return the element removed from the collection + */ + public uk.ac.vamsas.objects.core.DataSet removeDataSetAt(final int index) { + java.lang.Object obj = this._dataSetList.remove(index); + return (uk.ac.vamsas.objects.core.DataSet) obj; + } + + /** + * Method removeTree. + * + * @param vTree + * @return true if the object was removed from the collection. + */ + public boolean removeTree(final uk.ac.vamsas.objects.core.Tree vTree) { + boolean removed = _treeList.remove(vTree); + return removed; + } + + /** + * Method removeTreeAt. + * + * @param index + * @return the element removed from the collection + */ + public uk.ac.vamsas.objects.core.Tree removeTreeAt(final int index) { + java.lang.Object obj = this._treeList.remove(index); + return (uk.ac.vamsas.objects.core.Tree) obj; + } + + /** + * + * + * @param index + * @param vDataSet + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setDataSet(final int index, + final uk.ac.vamsas.objects.core.DataSet vDataSet) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._dataSetList.size()) { + throw new IndexOutOfBoundsException("setDataSet: Index value '" + index + + "' not in range [0.." + (this._dataSetList.size() - 1) + "]"); + } + + this._dataSetList.set(index, vDataSet); + } + + /** + * + * + * @param vDataSetArray + */ + public void setDataSet(final uk.ac.vamsas.objects.core.DataSet[] vDataSetArray) { + // -- copy array + _dataSetList.clear(); + + for (int i = 0; i < vDataSetArray.length; i++) { + this._dataSetList.add(vDataSetArray[i]); + } + } + + /** + * Sets the value of '_dataSetList' by copying the given Vector. All elements + * will be checked for type safety. + * + * @param vDataSetList + * the Vector to copy. + */ + public void setDataSet(final java.util.Vector vDataSetList) { + // copy vector + this._dataSetList.clear(); + + this._dataSetList.addAll(vDataSetList); + } + + /** + * Sets the value of '_dataSetList' by setting it to the given Vector. No type + * checking is performed. + * + * @deprecated + * + * @param dataSetVector + * the Vector to set. + */ + public void setDataSetAsReference(final java.util.Vector dataSetVector) { + this._dataSetList = dataSetVector; + } + + /** + * 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(final java.lang.String id) { + this._id = id; + } + + /** + * Sets the value of field 'modifiable'. + * + * @param modifiable + * the value of field 'modifiable'. + */ + public void setModifiable(final java.lang.String modifiable) { + this._modifiable = modifiable; + } + + /** + * + * + * @param index + * @param vTree + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setTree(final int index, + final uk.ac.vamsas.objects.core.Tree vTree) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._treeList.size()) { + throw new IndexOutOfBoundsException("setTree: Index value '" + index + + "' not in range [0.." + (this._treeList.size() - 1) + "]"); + } + + this._treeList.set(index, vTree); + } + + /** + * + * + * @param vTreeArray + */ + public void setTree(final uk.ac.vamsas.objects.core.Tree[] vTreeArray) { + // -- copy array + _treeList.clear(); + + for (int i = 0; i < vTreeArray.length; i++) { + this._treeList.add(vTreeArray[i]); + } + } + + /** + * Sets the value of '_treeList' by copying the given Vector. All elements + * will be checked for type safety. + * + * @param vTreeList + * the Vector to copy. + */ + public void setTree(final java.util.Vector vTreeList) { + // copy vector + this._treeList.clear(); + + this._treeList.addAll(vTreeList); + } + + /** + * Sets the value of '_treeList' by setting it to the given Vector. No type + * checking is performed. + * + * @deprecated + * + * @param treeVector + * the Vector to set. + */ + public void setTreeAsReference(final java.util.Vector treeVector) { + this._treeList = treeVector; + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @return the unmarshaled uk.ac.vamsas.objects.core.VAMSAS + */ + public static uk.ac.vamsas.objects.core.VAMSAS unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + return (uk.ac.vamsas.objects.core.VAMSAS) Unmarshaller.unmarshal( + uk.ac.vamsas.objects.core.VAMSAS.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/uk/ac/vamsas/objects/core/VamsasDocument.java b/src/uk/ac/vamsas/objects/core/VamsasDocument.java index 10ee854..c964ec6 100644 --- a/src/uk/ac/vamsas/objects/core/VamsasDocument.java +++ b/src/uk/ac/vamsas/objects/core/VamsasDocument.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import org.exolab.castor.xml.Marshaller; @@ -17,971 +31,1013 @@ import org.exolab.castor.xml.Unmarshaller; /** * Class VamsasDocument. * - * @version $Revision$ $Date$ + * @version $Revision$ $Date: 2007-06-28 14:51:44 +0100 (Thu, 28 Jun 2007) + * $ */ -public class VamsasDocument extends uk.ac.vamsas.client.Vobject -implements java.io.Serializable -{ - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Vamsas Document Version Number - */ - private java.lang.String _version; - - /** - * Field _lockFile. - */ - private uk.ac.vamsas.objects.core.LockFile _lockFile; - - /** - * Field _provenance. - */ - private uk.ac.vamsas.objects.core.Provenance _provenance; - - /** - * contains unassociated trees and a number of analysis sets - * - */ - private java.util.Vector _VAMSASList; - - /** - * Field _applicationDataList. - */ - private java.util.Vector _applicationDataList; - - /** - * Field _attachmentList. - */ - private java.util.Vector _attachmentList; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public VamsasDocument() { - super(); - this._VAMSASList = new java.util.Vector(); - this._applicationDataList = new java.util.Vector(); - this._attachmentList = new java.util.Vector(); - } - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * - * - * @param vApplicationData - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addApplicationData( - final uk.ac.vamsas.objects.core.ApplicationData vApplicationData) - throws java.lang.IndexOutOfBoundsException { - this._applicationDataList.addElement(vApplicationData); - } - - /** - * - * - * @param index - * @param vApplicationData - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addApplicationData( - final int index, - final uk.ac.vamsas.objects.core.ApplicationData vApplicationData) - throws java.lang.IndexOutOfBoundsException { - this._applicationDataList.add(index, vApplicationData); - } - - /** - * - * - * @param vAttachment - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addAttachment( - final uk.ac.vamsas.objects.core.Attachment vAttachment) - throws java.lang.IndexOutOfBoundsException { - this._attachmentList.addElement(vAttachment); - } - - /** - * - * - * @param index - * @param vAttachment - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addAttachment( - final int index, - final uk.ac.vamsas.objects.core.Attachment vAttachment) - throws java.lang.IndexOutOfBoundsException { - this._attachmentList.add(index, vAttachment); - } - - /** - * - * - * @param vVAMSAS - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addVAMSAS( - final uk.ac.vamsas.objects.core.VAMSAS vVAMSAS) - throws java.lang.IndexOutOfBoundsException { - this._VAMSASList.addElement(vVAMSAS); - } - - /** - * - * - * @param index - * @param vVAMSAS - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addVAMSAS( - final int index, - final uk.ac.vamsas.objects.core.VAMSAS vVAMSAS) - throws java.lang.IndexOutOfBoundsException { - this._VAMSASList.add(index, vVAMSAS); - } - - /** - * Method enumerateApplicationData. - * - * @return an Enumeration over all - * uk.ac.vamsas.objects.core.ApplicationData elements - */ - public java.util.Enumeration enumerateApplicationData( - ) { - return this._applicationDataList.elements(); - } - - /** - * Method enumerateAttachment. - * - * @return an Enumeration over all - * uk.ac.vamsas.objects.core.Attachment elements - */ - public java.util.Enumeration enumerateAttachment( - ) { - return this._attachmentList.elements(); - } - - /** - * Method enumerateVAMSAS. - * - * @return an Enumeration over all - * uk.ac.vamsas.objects.core.VAMSAS elements - */ - public java.util.Enumeration enumerateVAMSAS( - ) { - return this._VAMSASList.elements(); - } - - /** - * Overrides the java.lang.Object.equals method. - * - * @param obj - * @return true if the objects are equal. - */ - public boolean equals( - final java.lang.Object obj) { - if ( this == obj ) - return true; - - if (super.equals(obj)==false) +public class VamsasDocument extends uk.ac.vamsas.client.Vobject implements + java.io.Serializable { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Vamsas Document Version Number + */ + private java.lang.String _version; + + /** + * Field _lockFile. + */ + private uk.ac.vamsas.objects.core.LockFile _lockFile; + + /** + * Field _provenance. + */ + private uk.ac.vamsas.objects.core.Provenance _provenance; + + /** + * contains unassociated trees and a number of analysis sets + * + */ + private java.util.Vector _VAMSASList; + + /** + * Field _applicationDataList. + */ + private java.util.Vector _applicationDataList; + + /** + * Field _attachmentList. + */ + private java.util.Vector _attachmentList; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public VamsasDocument() { + super(); + this._VAMSASList = new java.util.Vector(); + this._applicationDataList = new java.util.Vector(); + this._attachmentList = new java.util.Vector(); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * + * + * @param vApplicationData + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addApplicationData( + final uk.ac.vamsas.objects.core.ApplicationData vApplicationData) + throws java.lang.IndexOutOfBoundsException { + this._applicationDataList.addElement(vApplicationData); + } + + /** + * + * + * @param index + * @param vApplicationData + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addApplicationData(final int index, + final uk.ac.vamsas.objects.core.ApplicationData vApplicationData) + throws java.lang.IndexOutOfBoundsException { + this._applicationDataList.add(index, vApplicationData); + } + + /** + * + * + * @param vAttachment + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addAttachment( + final uk.ac.vamsas.objects.core.Attachment vAttachment) + throws java.lang.IndexOutOfBoundsException { + this._attachmentList.addElement(vAttachment); + } + + /** + * + * + * @param index + * @param vAttachment + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addAttachment(final int index, + final uk.ac.vamsas.objects.core.Attachment vAttachment) + throws java.lang.IndexOutOfBoundsException { + this._attachmentList.add(index, vAttachment); + } + + /** + * + * + * @param vVAMSAS + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addVAMSAS(final uk.ac.vamsas.objects.core.VAMSAS vVAMSAS) + throws java.lang.IndexOutOfBoundsException { + this._VAMSASList.addElement(vVAMSAS); + } + + /** + * + * + * @param index + * @param vVAMSAS + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addVAMSAS(final int index, + final uk.ac.vamsas.objects.core.VAMSAS vVAMSAS) + throws java.lang.IndexOutOfBoundsException { + this._VAMSASList.add(index, vVAMSAS); + } + + /** + * Method enumerateApplicationData. + * + * @return an Enumeration over all uk.ac.vamsas.objects.core.ApplicationData + * elements + */ + public java.util.Enumeration enumerateApplicationData() { + return this._applicationDataList.elements(); + } + + /** + * Method enumerateAttachment. + * + * @return an Enumeration over all uk.ac.vamsas.objects.core.Attachment + * elements + */ + public java.util.Enumeration enumerateAttachment() { + return this._attachmentList.elements(); + } + + /** + * Method enumerateVAMSAS. + * + * @return an Enumeration over all uk.ac.vamsas.objects.core.VAMSAS elements + */ + public java.util.Enumeration enumerateVAMSAS() { + return this._VAMSASList.elements(); + } + + /** + * Overrides the java.lang.Object.equals method. + * + * @param obj + * @return true if the objects are equal. + */ + public boolean equals(final java.lang.Object obj) { + if (this == obj) + return true; + + if (super.equals(obj) == false) + return false; + + if (obj instanceof VamsasDocument) { + + VamsasDocument temp = (VamsasDocument) obj; + boolean thcycle; + boolean tmcycle; + if (this._version != null) { + if (temp._version == null) + return false; + if (this._version != temp._version) { + thcycle = org.castor.util.CycleBreaker.startingToCycle(this._version); + tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._version); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._version); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._version); + } + ; return false; - - if (obj instanceof VamsasDocument) { - - VamsasDocument temp = (VamsasDocument)obj; - boolean thcycle; - boolean tmcycle; - if (this._version != null) { - if (temp._version == null) return false; - if (this._version != temp._version) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._version); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._version); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._version); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._version); }; - return false; - } - if (!thcycle) { - if (!this._version.equals(temp._version)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._version); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._version); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._version); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._version); - } - } - } else if (temp._version != null) - return false; - if (this._lockFile != null) { - if (temp._lockFile == null) return false; - if (this._lockFile != temp._lockFile) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._lockFile); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._lockFile); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._lockFile); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._lockFile); }; - return false; - } - if (!thcycle) { - if (!this._lockFile.equals(temp._lockFile)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._lockFile); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._lockFile); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._lockFile); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._lockFile); - } - } - } else if (temp._lockFile != null) - return false; - if (this._provenance != null) { - if (temp._provenance == null) return false; - if (this._provenance != temp._provenance) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._provenance); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._provenance); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance); }; - return false; - } - if (!thcycle) { - if (!this._provenance.equals(temp._provenance)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance); - } - } - } else if (temp._provenance != null) - return false; - if (this._VAMSASList != null) { - if (temp._VAMSASList == null) return false; - if (this._VAMSASList != temp._VAMSASList) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._VAMSASList); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._VAMSASList); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._VAMSASList); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._VAMSASList); }; - return false; - } - if (!thcycle) { - if (!this._VAMSASList.equals(temp._VAMSASList)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._VAMSASList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._VAMSASList); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._VAMSASList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._VAMSASList); - } - } - } else if (temp._VAMSASList != null) - return false; - if (this._applicationDataList != null) { - if (temp._applicationDataList == null) return false; - if (this._applicationDataList != temp._applicationDataList) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._applicationDataList); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._applicationDataList); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._applicationDataList); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._applicationDataList); }; - return false; - } - if (!thcycle) { - if (!this._applicationDataList.equals(temp._applicationDataList)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._applicationDataList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._applicationDataList); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._applicationDataList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._applicationDataList); - } - } - } else if (temp._applicationDataList != null) - return false; - if (this._attachmentList != null) { - if (temp._attachmentList == null) return false; - if (this._attachmentList != temp._attachmentList) { - thcycle=org.castor.util.CycleBreaker.startingToCycle(this._attachmentList); - tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._attachmentList); - if (thcycle!=tmcycle) { - if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._attachmentList); }; - if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._attachmentList); }; - return false; - } - if (!thcycle) { - if (!this._attachmentList.equals(temp._attachmentList)) { - org.castor.util.CycleBreaker.releaseCycleHandle(this._attachmentList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._attachmentList); - return false; - } - org.castor.util.CycleBreaker.releaseCycleHandle(this._attachmentList); - org.castor.util.CycleBreaker.releaseCycleHandle(temp._attachmentList); - } - } - } else if (temp._attachmentList != null) - return false; - return true; + } + if (!thcycle) { + if (!this._version.equals(temp._version)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._version); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._version); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._version); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._version); + } } + } else if (temp._version != null) return false; - } - - /** - * Method getApplicationData. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the - * uk.ac.vamsas.objects.core.ApplicationData at the given index - */ - public uk.ac.vamsas.objects.core.ApplicationData getApplicationData( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._applicationDataList.size()) { - throw new IndexOutOfBoundsException("getApplicationData: Index value '" + index + "' not in range [0.." + (this._applicationDataList.size() - 1) + "]"); - } - - return (uk.ac.vamsas.objects.core.ApplicationData) _applicationDataList.get(index); - } - - /** - * Method getApplicationData.Returns the contents of the - * collection in an Array.

Note: Just in case the - * collection contents are changing in another thread, we pass - * a 0-length Array of the correct type into the API call. - * This way we know that the Array returned is of - * exactly the correct length. - * - * @return this collection as an Array - */ - public uk.ac.vamsas.objects.core.ApplicationData[] getApplicationData( - ) { - uk.ac.vamsas.objects.core.ApplicationData[] array = new uk.ac.vamsas.objects.core.ApplicationData[0]; - return (uk.ac.vamsas.objects.core.ApplicationData[]) this._applicationDataList.toArray(array); - } - - /** - * Method getApplicationDataAsReference.Returns a reference to - * '_applicationDataList'. No type checking is performed on any - * modifications to the Vector. - * - * @return a reference to the Vector backing this class - */ - public java.util.Vector getApplicationDataAsReference( - ) { - return this._applicationDataList; - } - - /** - * Method getApplicationDataCount. - * - * @return the size of this collection - */ - public int getApplicationDataCount( - ) { - return this._applicationDataList.size(); - } - - /** - * Method getAttachment. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the - * uk.ac.vamsas.objects.core.Attachment at the given index - */ - public uk.ac.vamsas.objects.core.Attachment getAttachment( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._attachmentList.size()) { - throw new IndexOutOfBoundsException("getAttachment: Index value '" + index + "' not in range [0.." + (this._attachmentList.size() - 1) + "]"); - } - - return (uk.ac.vamsas.objects.core.Attachment) _attachmentList.get(index); - } - - /** - * Method getAttachment.Returns the contents of the collection - * in an Array.

Note: Just in case the collection contents - * are changing in another thread, we pass a 0-length Array of - * the correct type into the API call. This way we know - * that the Array returned is of exactly the correct length. - * - * @return this collection as an Array - */ - public uk.ac.vamsas.objects.core.Attachment[] getAttachment( - ) { - uk.ac.vamsas.objects.core.Attachment[] array = new uk.ac.vamsas.objects.core.Attachment[0]; - return (uk.ac.vamsas.objects.core.Attachment[]) this._attachmentList.toArray(array); - } - - /** - * Method getAttachmentAsReference.Returns a reference to - * '_attachmentList'. No type checking is performed on any - * modifications to the Vector. - * - * @return a reference to the Vector backing this class - */ - public java.util.Vector getAttachmentAsReference( - ) { - return this._attachmentList; - } - - /** - * Method getAttachmentCount. - * - * @return the size of this collection - */ - public int getAttachmentCount( - ) { - return this._attachmentList.size(); - } - - /** - * Returns the value of field 'lockFile'. - * - * @return the value of field 'LockFile'. - */ - public uk.ac.vamsas.objects.core.LockFile getLockFile( - ) { - return this._lockFile; - } - - /** - * Returns the value of field 'provenance'. - * - * @return the value of field 'Provenance'. - */ - public uk.ac.vamsas.objects.core.Provenance getProvenance( - ) { - return this._provenance; - } - - /** - * Method getVAMSAS. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the uk.ac.vamsas.objects.core.VAMSAS at - * the given index - */ - public uk.ac.vamsas.objects.core.VAMSAS getVAMSAS( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._VAMSASList.size()) { - throw new IndexOutOfBoundsException("getVAMSAS: Index value '" + index + "' not in range [0.." + (this._VAMSASList.size() - 1) + "]"); - } - - return (uk.ac.vamsas.objects.core.VAMSAS) _VAMSASList.get(index); - } - - /** - * Method getVAMSAS.Returns the contents of the collection in - * an Array.

Note: Just in case the collection contents - * are changing in another thread, we pass a 0-length Array of - * the correct type into the API call. This way we know - * that the Array returned is of exactly the correct length. - * - * @return this collection as an Array - */ - public uk.ac.vamsas.objects.core.VAMSAS[] getVAMSAS( - ) { - uk.ac.vamsas.objects.core.VAMSAS[] array = new uk.ac.vamsas.objects.core.VAMSAS[0]; - return (uk.ac.vamsas.objects.core.VAMSAS[]) this._VAMSASList.toArray(array); - } - - /** - * Method getVAMSASAsReference.Returns a reference to - * '_VAMSASList'. No type checking is performed on any - * modifications to the Vector. - * - * @return a reference to the Vector backing this class - */ - public java.util.Vector getVAMSASAsReference( - ) { - return this._VAMSASList; - } - - /** - * Method getVAMSASCount. - * - * @return the size of this collection - */ - public int getVAMSASCount( - ) { - return this._VAMSASList.size(); - } - - /** - * Returns the value of field 'version'. The field 'version' - * has the following description: Vamsas Document Version - * Number - * - * @return the value of field 'Version'. - */ - public java.lang.String getVersion( - ) { - return this._version; - } - - /** - * Overrides the java.lang.Object.hashCode method. - *

- * The following steps came from Effective Java Programming - * Language Guide by Joshua Bloch, Chapter 3 - * - * @return a hash code value for the object. - */ - public int hashCode( - ) { - int result = super.hashCode(); - - long tmp; - if (_version != null - && !org.castor.util.CycleBreaker.startingToCycle(_version)) { - result = 37 * result + _version.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_version); - } - if (_lockFile != null - && !org.castor.util.CycleBreaker.startingToCycle(_lockFile)) { - result = 37 * result + _lockFile.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_lockFile); - } - if (_provenance != null - && !org.castor.util.CycleBreaker.startingToCycle(_provenance)) { - result = 37 * result + _provenance.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_provenance); + if (this._lockFile != null) { + if (temp._lockFile == null) + return false; + if (this._lockFile != temp._lockFile) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._lockFile); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._lockFile); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._lockFile); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._lockFile); + } + ; + return false; + } + if (!thcycle) { + if (!this._lockFile.equals(temp._lockFile)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._lockFile); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._lockFile); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._lockFile); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._lockFile); + } } - if (_VAMSASList != null - && !org.castor.util.CycleBreaker.startingToCycle(_VAMSASList)) { - result = 37 * result + _VAMSASList.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_VAMSASList); + } else if (temp._lockFile != null) + return false; + if (this._provenance != null) { + if (temp._provenance == null) + return false; + if (this._provenance != temp._provenance) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._provenance); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._provenance); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance); + } + ; + return false; + } + if (!thcycle) { + if (!this._provenance.equals(temp._provenance)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance); + } } - if (_applicationDataList != null - && !org.castor.util.CycleBreaker.startingToCycle(_applicationDataList)) { - result = 37 * result + _applicationDataList.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_applicationDataList); + } else if (temp._provenance != null) + return false; + if (this._VAMSASList != null) { + if (temp._VAMSASList == null) + return false; + if (this._VAMSASList != temp._VAMSASList) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._VAMSASList); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._VAMSASList); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._VAMSASList); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker.releaseCycleHandle(temp._VAMSASList); + } + ; + return false; + } + if (!thcycle) { + if (!this._VAMSASList.equals(temp._VAMSASList)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._VAMSASList); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._VAMSASList); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._VAMSASList); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._VAMSASList); + } } - if (_attachmentList != null - && !org.castor.util.CycleBreaker.startingToCycle(_attachmentList)) { - result = 37 * result + _attachmentList.hashCode(); - org.castor.util.CycleBreaker.releaseCycleHandle(_attachmentList); + } else if (temp._VAMSASList != null) + return false; + if (this._applicationDataList != null) { + if (temp._applicationDataList == null) + return false; + if (this._applicationDataList != temp._applicationDataList) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._applicationDataList); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._applicationDataList); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker + .releaseCycleHandle(this._applicationDataList); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._applicationDataList); + } + ; + return false; + } + if (!thcycle) { + if (!this._applicationDataList.equals(temp._applicationDataList)) { + org.castor.util.CycleBreaker + .releaseCycleHandle(this._applicationDataList); + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._applicationDataList); + return false; + } + org.castor.util.CycleBreaker + .releaseCycleHandle(this._applicationDataList); + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._applicationDataList); + } } - - return result; - } - - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { + } else if (temp._applicationDataList != null) + return false; + if (this._attachmentList != null) { + if (temp._attachmentList == null) + return false; + if (this._attachmentList != temp._attachmentList) { + thcycle = org.castor.util.CycleBreaker + .startingToCycle(this._attachmentList); + tmcycle = org.castor.util.CycleBreaker + .startingToCycle(temp._attachmentList); + if (thcycle != tmcycle) { + if (!thcycle) { + org.castor.util.CycleBreaker + .releaseCycleHandle(this._attachmentList); + } + ; + if (!tmcycle) { + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._attachmentList); + } + ; return false; + } + if (!thcycle) { + if (!this._attachmentList.equals(temp._attachmentList)) { + org.castor.util.CycleBreaker + .releaseCycleHandle(this._attachmentList); + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._attachmentList); + return false; + } + org.castor.util.CycleBreaker + .releaseCycleHandle(this._attachmentList); + org.castor.util.CycleBreaker + .releaseCycleHandle(temp._attachmentList); + } } - return true; - } - - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } - - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } - - /** - */ - public void removeAllApplicationData( - ) { - this._applicationDataList.clear(); - } - - /** - */ - public void removeAllAttachment( - ) { - this._attachmentList.clear(); - } - - /** - */ - public void removeAllVAMSAS( - ) { - this._VAMSASList.clear(); - } - - /** - * Method removeApplicationData. - * - * @param vApplicationData - * @return true if the object was removed from the collection. - */ - public boolean removeApplicationData( - final uk.ac.vamsas.objects.core.ApplicationData vApplicationData) { - boolean removed = _applicationDataList.remove(vApplicationData); - return removed; - } - - /** - * Method removeApplicationDataAt. - * - * @param index - * @return the element removed from the collection - */ - public uk.ac.vamsas.objects.core.ApplicationData removeApplicationDataAt( - final int index) { - java.lang.Object obj = this._applicationDataList.remove(index); - return (uk.ac.vamsas.objects.core.ApplicationData) obj; - } - - /** - * Method removeAttachment. - * - * @param vAttachment - * @return true if the object was removed from the collection. - */ - public boolean removeAttachment( - final uk.ac.vamsas.objects.core.Attachment vAttachment) { - boolean removed = _attachmentList.remove(vAttachment); - return removed; + } else if (temp._attachmentList != null) + return false; + return true; } - - /** - * Method removeAttachmentAt. - * - * @param index - * @return the element removed from the collection - */ - public uk.ac.vamsas.objects.core.Attachment removeAttachmentAt( - final int index) { - java.lang.Object obj = this._attachmentList.remove(index); - return (uk.ac.vamsas.objects.core.Attachment) obj; + return false; + } + + /** + * Method getApplicationData. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the uk.ac.vamsas.objects.core.ApplicationData at the + * given index + */ + public uk.ac.vamsas.objects.core.ApplicationData getApplicationData( + final int index) throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._applicationDataList.size()) { + throw new IndexOutOfBoundsException("getApplicationData: Index value '" + + index + "' not in range [0.." + + (this._applicationDataList.size() - 1) + "]"); } - /** - * Method removeVAMSAS. - * - * @param vVAMSAS - * @return true if the object was removed from the collection. - */ - public boolean removeVAMSAS( - final uk.ac.vamsas.objects.core.VAMSAS vVAMSAS) { - boolean removed = _VAMSASList.remove(vVAMSAS); - return removed; + return (uk.ac.vamsas.objects.core.ApplicationData) _applicationDataList + .get(index); + } + + /** + * Method getApplicationData.Returns the contents of the collection in an + * Array. + *

+ * Note: Just in case the collection contents are changing in another thread, + * we pass a 0-length Array of the correct type into the API call. This way we + * know that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public uk.ac.vamsas.objects.core.ApplicationData[] getApplicationData() { + uk.ac.vamsas.objects.core.ApplicationData[] array = new uk.ac.vamsas.objects.core.ApplicationData[0]; + return (uk.ac.vamsas.objects.core.ApplicationData[]) this._applicationDataList + .toArray(array); + } + + /** + * Method getApplicationDataAsReference.Returns a reference to + * '_applicationDataList'. No type checking is performed on any modifications + * to the Vector. + * + * @return a reference to the Vector backing this class + */ + public java.util.Vector getApplicationDataAsReference() { + return this._applicationDataList; + } + + /** + * Method getApplicationDataCount. + * + * @return the size of this collection + */ + public int getApplicationDataCount() { + return this._applicationDataList.size(); + } + + /** + * Method getAttachment. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the uk.ac.vamsas.objects.core.Attachment at the given + * index + */ + public uk.ac.vamsas.objects.core.Attachment getAttachment(final int index) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._attachmentList.size()) { + throw new IndexOutOfBoundsException("getAttachment: Index value '" + + index + "' not in range [0.." + (this._attachmentList.size() - 1) + + "]"); } - /** - * Method removeVAMSASAt. - * - * @param index - * @return the element removed from the collection - */ - public uk.ac.vamsas.objects.core.VAMSAS removeVAMSASAt( - final int index) { - java.lang.Object obj = this._VAMSASList.remove(index); - return (uk.ac.vamsas.objects.core.VAMSAS) obj; + return (uk.ac.vamsas.objects.core.Attachment) _attachmentList.get(index); + } + + /** + * Method getAttachment.Returns the contents of the collection in an Array. + *

+ * Note: Just in case the collection contents are changing in another thread, + * we pass a 0-length Array of the correct type into the API call. This way we + * know that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public uk.ac.vamsas.objects.core.Attachment[] getAttachment() { + uk.ac.vamsas.objects.core.Attachment[] array = new uk.ac.vamsas.objects.core.Attachment[0]; + return (uk.ac.vamsas.objects.core.Attachment[]) this._attachmentList + .toArray(array); + } + + /** + * Method getAttachmentAsReference.Returns a reference to '_attachmentList'. + * No type checking is performed on any modifications to the Vector. + * + * @return a reference to the Vector backing this class + */ + public java.util.Vector getAttachmentAsReference() { + return this._attachmentList; + } + + /** + * Method getAttachmentCount. + * + * @return the size of this collection + */ + public int getAttachmentCount() { + return this._attachmentList.size(); + } + + /** + * Returns the value of field 'lockFile'. + * + * @return the value of field 'LockFile'. + */ + public uk.ac.vamsas.objects.core.LockFile getLockFile() { + return this._lockFile; + } + + /** + * Returns the value of field 'provenance'. + * + * @return the value of field 'Provenance'. + */ + public uk.ac.vamsas.objects.core.Provenance getProvenance() { + return this._provenance; + } + + /** + * Method getVAMSAS. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the uk.ac.vamsas.objects.core.VAMSAS at the given + * index + */ + public uk.ac.vamsas.objects.core.VAMSAS getVAMSAS(final int index) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._VAMSASList.size()) { + throw new IndexOutOfBoundsException("getVAMSAS: Index value '" + index + + "' not in range [0.." + (this._VAMSASList.size() - 1) + "]"); } - /** - * - * - * @param index - * @param vApplicationData - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setApplicationData( - final int index, - final uk.ac.vamsas.objects.core.ApplicationData vApplicationData) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._applicationDataList.size()) { - throw new IndexOutOfBoundsException("setApplicationData: Index value '" + index + "' not in range [0.." + (this._applicationDataList.size() - 1) + "]"); - } - - this._applicationDataList.set(index, vApplicationData); + return (uk.ac.vamsas.objects.core.VAMSAS) _VAMSASList.get(index); + } + + /** + * Method getVAMSAS.Returns the contents of the collection in an Array. + *

+ * Note: Just in case the collection contents are changing in another thread, + * we pass a 0-length Array of the correct type into the API call. This way we + * know that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public uk.ac.vamsas.objects.core.VAMSAS[] getVAMSAS() { + uk.ac.vamsas.objects.core.VAMSAS[] array = new uk.ac.vamsas.objects.core.VAMSAS[0]; + return (uk.ac.vamsas.objects.core.VAMSAS[]) this._VAMSASList.toArray(array); + } + + /** + * Method getVAMSASAsReference.Returns a reference to '_VAMSASList'. No type + * checking is performed on any modifications to the Vector. + * + * @return a reference to the Vector backing this class + */ + public java.util.Vector getVAMSASAsReference() { + return this._VAMSASList; + } + + /** + * Method getVAMSASCount. + * + * @return the size of this collection + */ + public int getVAMSASCount() { + return this._VAMSASList.size(); + } + + /** + * Returns the value of field 'version'. The field 'version' has the following + * description: Vamsas Document Version Number + * + * @return the value of field 'Version'. + */ + public java.lang.String getVersion() { + return this._version; + } + + /** + * Overrides the java.lang.Object.hashCode method. + *

+ * The following steps came from Effective Java Programming Language + * Guide by Joshua Bloch, Chapter 3 + * + * @return a hash code value for the object. + */ + public int hashCode() { + int result = super.hashCode(); + + long tmp; + if (_version != null + && !org.castor.util.CycleBreaker.startingToCycle(_version)) { + result = 37 * result + _version.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_version); } - - /** - * - * - * @param vApplicationDataArray - */ - public void setApplicationData( - final uk.ac.vamsas.objects.core.ApplicationData[] vApplicationDataArray) { - //-- copy array - _applicationDataList.clear(); - - for (int i = 0; i < vApplicationDataArray.length; i++) { - this._applicationDataList.add(vApplicationDataArray[i]); - } + if (_lockFile != null + && !org.castor.util.CycleBreaker.startingToCycle(_lockFile)) { + result = 37 * result + _lockFile.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_lockFile); } - - /** - * Sets the value of '_applicationDataList' by copying the - * given Vector. All elements will be checked for type safety. - * - * @param vApplicationDataList the Vector to copy. - */ - public void setApplicationData( - final java.util.Vector vApplicationDataList) { - // copy vector - this._applicationDataList.clear(); - - this._applicationDataList.addAll(vApplicationDataList); + if (_provenance != null + && !org.castor.util.CycleBreaker.startingToCycle(_provenance)) { + result = 37 * result + _provenance.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_provenance); } - - /** - * Sets the value of '_applicationDataList' by setting it to - * the given Vector. No type checking is performed. - * @deprecated - * - * @param applicationDataVector the Vector to set. - */ - public void setApplicationDataAsReference( - final java.util.Vector applicationDataVector) { - this._applicationDataList = applicationDataVector; + if (_VAMSASList != null + && !org.castor.util.CycleBreaker.startingToCycle(_VAMSASList)) { + result = 37 * result + _VAMSASList.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_VAMSASList); } - - /** - * - * - * @param index - * @param vAttachment - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setAttachment( - final int index, - final uk.ac.vamsas.objects.core.Attachment vAttachment) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._attachmentList.size()) { - throw new IndexOutOfBoundsException("setAttachment: Index value '" + index + "' not in range [0.." + (this._attachmentList.size() - 1) + "]"); - } - - this._attachmentList.set(index, vAttachment); + if (_applicationDataList != null + && !org.castor.util.CycleBreaker.startingToCycle(_applicationDataList)) { + result = 37 * result + _applicationDataList.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_applicationDataList); } - - /** - * - * - * @param vAttachmentArray - */ - public void setAttachment( - final uk.ac.vamsas.objects.core.Attachment[] vAttachmentArray) { - //-- copy array - _attachmentList.clear(); - - for (int i = 0; i < vAttachmentArray.length; i++) { - this._attachmentList.add(vAttachmentArray[i]); - } + if (_attachmentList != null + && !org.castor.util.CycleBreaker.startingToCycle(_attachmentList)) { + result = 37 * result + _attachmentList.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_attachmentList); } - /** - * Sets the value of '_attachmentList' by copying the given - * Vector. All elements will be checked for type safety. - * - * @param vAttachmentList the Vector to copy. - */ - public void setAttachment( - final java.util.Vector vAttachmentList) { - // copy vector - this._attachmentList.clear(); - - this._attachmentList.addAll(vAttachmentList); + return result; + } + + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() { + try { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) { + return false; } - - /** - * Sets the value of '_attachmentList' by setting it to the - * given Vector. No type checking is performed. - * @deprecated - * - * @param attachmentVector the Vector to set. + return true; + } + + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, out); + } + + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, handler); + } + + /** */ - public void setAttachmentAsReference( - final java.util.Vector attachmentVector) { - this._attachmentList = attachmentVector; - } + public void removeAllApplicationData() { + this._applicationDataList.clear(); + } - /** - * Sets the value of field 'lockFile'. - * - * @param lockFile the value of field 'lockFile'. + /** */ - public void setLockFile( - final uk.ac.vamsas.objects.core.LockFile lockFile) { - this._lockFile = lockFile; - } + public void removeAllAttachment() { + this._attachmentList.clear(); + } - /** - * Sets the value of field 'provenance'. - * - * @param provenance the value of field 'provenance'. + /** */ - public void setProvenance( - final uk.ac.vamsas.objects.core.Provenance provenance) { - this._provenance = provenance; + public void removeAllVAMSAS() { + this._VAMSASList.clear(); + } + + /** + * Method removeApplicationData. + * + * @param vApplicationData + * @return true if the object was removed from the collection. + */ + public boolean removeApplicationData( + final uk.ac.vamsas.objects.core.ApplicationData vApplicationData) { + boolean removed = _applicationDataList.remove(vApplicationData); + return removed; + } + + /** + * Method removeApplicationDataAt. + * + * @param index + * @return the element removed from the collection + */ + public uk.ac.vamsas.objects.core.ApplicationData removeApplicationDataAt( + final int index) { + java.lang.Object obj = this._applicationDataList.remove(index); + return (uk.ac.vamsas.objects.core.ApplicationData) obj; + } + + /** + * Method removeAttachment. + * + * @param vAttachment + * @return true if the object was removed from the collection. + */ + public boolean removeAttachment( + final uk.ac.vamsas.objects.core.Attachment vAttachment) { + boolean removed = _attachmentList.remove(vAttachment); + return removed; + } + + /** + * Method removeAttachmentAt. + * + * @param index + * @return the element removed from the collection + */ + public uk.ac.vamsas.objects.core.Attachment removeAttachmentAt(final int index) { + java.lang.Object obj = this._attachmentList.remove(index); + return (uk.ac.vamsas.objects.core.Attachment) obj; + } + + /** + * Method removeVAMSAS. + * + * @param vVAMSAS + * @return true if the object was removed from the collection. + */ + public boolean removeVAMSAS(final uk.ac.vamsas.objects.core.VAMSAS vVAMSAS) { + boolean removed = _VAMSASList.remove(vVAMSAS); + return removed; + } + + /** + * Method removeVAMSASAt. + * + * @param index + * @return the element removed from the collection + */ + public uk.ac.vamsas.objects.core.VAMSAS removeVAMSASAt(final int index) { + java.lang.Object obj = this._VAMSASList.remove(index); + return (uk.ac.vamsas.objects.core.VAMSAS) obj; + } + + /** + * + * + * @param index + * @param vApplicationData + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setApplicationData(final int index, + final uk.ac.vamsas.objects.core.ApplicationData vApplicationData) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._applicationDataList.size()) { + throw new IndexOutOfBoundsException("setApplicationData: Index value '" + + index + "' not in range [0.." + + (this._applicationDataList.size() - 1) + "]"); } - /** - * - * - * @param index - * @param vVAMSAS - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setVAMSAS( - final int index, - final uk.ac.vamsas.objects.core.VAMSAS vVAMSAS) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._VAMSASList.size()) { - throw new IndexOutOfBoundsException("setVAMSAS: Index value '" + index + "' not in range [0.." + (this._VAMSASList.size() - 1) + "]"); - } - - this._VAMSASList.set(index, vVAMSAS); + this._applicationDataList.set(index, vApplicationData); + } + + /** + * + * + * @param vApplicationDataArray + */ + public void setApplicationData( + final uk.ac.vamsas.objects.core.ApplicationData[] vApplicationDataArray) { + // -- copy array + _applicationDataList.clear(); + + for (int i = 0; i < vApplicationDataArray.length; i++) { + this._applicationDataList.add(vApplicationDataArray[i]); } - - /** - * - * - * @param vVAMSASArray - */ - public void setVAMSAS( - final uk.ac.vamsas.objects.core.VAMSAS[] vVAMSASArray) { - //-- copy array - _VAMSASList.clear(); - - for (int i = 0; i < vVAMSASArray.length; i++) { - this._VAMSASList.add(vVAMSASArray[i]); - } + } + + /** + * Sets the value of '_applicationDataList' by copying the given Vector. All + * elements will be checked for type safety. + * + * @param vApplicationDataList + * the Vector to copy. + */ + public void setApplicationData(final java.util.Vector vApplicationDataList) { + // copy vector + this._applicationDataList.clear(); + + this._applicationDataList.addAll(vApplicationDataList); + } + + /** + * Sets the value of '_applicationDataList' by setting it to the given Vector. + * No type checking is performed. + * + * @deprecated + * + * @param applicationDataVector + * the Vector to set. + */ + public void setApplicationDataAsReference( + final java.util.Vector applicationDataVector) { + this._applicationDataList = applicationDataVector; + } + + /** + * + * + * @param index + * @param vAttachment + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setAttachment(final int index, + final uk.ac.vamsas.objects.core.Attachment vAttachment) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._attachmentList.size()) { + throw new IndexOutOfBoundsException("setAttachment: Index value '" + + index + "' not in range [0.." + (this._attachmentList.size() - 1) + + "]"); } - /** - * Sets the value of '_VAMSASList' by copying the given Vector. - * All elements will be checked for type safety. - * - * @param vVAMSASList the Vector to copy. - */ - public void setVAMSAS( - final java.util.Vector vVAMSASList) { - // copy vector - this._VAMSASList.clear(); - - this._VAMSASList.addAll(vVAMSASList); + this._attachmentList.set(index, vAttachment); + } + + /** + * + * + * @param vAttachmentArray + */ + public void setAttachment( + final uk.ac.vamsas.objects.core.Attachment[] vAttachmentArray) { + // -- copy array + _attachmentList.clear(); + + for (int i = 0; i < vAttachmentArray.length; i++) { + this._attachmentList.add(vAttachmentArray[i]); } - - /** - * Sets the value of '_VAMSASList' by setting it to the given - * Vector. No type checking is performed. - * @deprecated - * - * @param VAMSASVector the Vector to set. - */ - public void setVAMSASAsReference( - final java.util.Vector VAMSASVector) { - this._VAMSASList = VAMSASVector; + } + + /** + * Sets the value of '_attachmentList' by copying the given Vector. All + * elements will be checked for type safety. + * + * @param vAttachmentList + * the Vector to copy. + */ + public void setAttachment(final java.util.Vector vAttachmentList) { + // copy vector + this._attachmentList.clear(); + + this._attachmentList.addAll(vAttachmentList); + } + + /** + * Sets the value of '_attachmentList' by setting it to the given Vector. No + * type checking is performed. + * + * @deprecated + * + * @param attachmentVector + * the Vector to set. + */ + public void setAttachmentAsReference(final java.util.Vector attachmentVector) { + this._attachmentList = attachmentVector; + } + + /** + * Sets the value of field 'lockFile'. + * + * @param lockFile + * the value of field 'lockFile'. + */ + public void setLockFile(final uk.ac.vamsas.objects.core.LockFile lockFile) { + this._lockFile = lockFile; + } + + /** + * Sets the value of field 'provenance'. + * + * @param provenance + * the value of field 'provenance'. + */ + public void setProvenance( + final uk.ac.vamsas.objects.core.Provenance provenance) { + this._provenance = provenance; + } + + /** + * + * + * @param index + * @param vVAMSAS + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setVAMSAS(final int index, + final uk.ac.vamsas.objects.core.VAMSAS vVAMSAS) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._VAMSASList.size()) { + throw new IndexOutOfBoundsException("setVAMSAS: Index value '" + index + + "' not in range [0.." + (this._VAMSASList.size() - 1) + "]"); } - /** - * Sets the value of field 'version'. The field 'version' has - * the following description: Vamsas Document Version Number - * - * @param version the value of field 'version'. - */ - public void setVersion( - final java.lang.String version) { - this._version = version; - } + this._VAMSASList.set(index, vVAMSAS); + } - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled - * uk.ac.vamsas.objects.core.VamsasDocument - */ - public static uk.ac.vamsas.objects.core.VamsasDocument unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (uk.ac.vamsas.objects.core.VamsasDocument) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.VamsasDocument.class, reader); - } + /** + * + * + * @param vVAMSASArray + */ + public void setVAMSAS(final uk.ac.vamsas.objects.core.VAMSAS[] vVAMSASArray) { + // -- copy array + _VAMSASList.clear(); - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); + for (int i = 0; i < vVAMSASArray.length; i++) { + this._VAMSASList.add(vVAMSASArray[i]); } + } + + /** + * Sets the value of '_VAMSASList' by copying the given Vector. All elements + * will be checked for type safety. + * + * @param vVAMSASList + * the Vector to copy. + */ + public void setVAMSAS(final java.util.Vector vVAMSASList) { + // copy vector + this._VAMSASList.clear(); + + this._VAMSASList.addAll(vVAMSASList); + } + + /** + * Sets the value of '_VAMSASList' by setting it to the given Vector. No type + * checking is performed. + * + * @deprecated + * + * @param VAMSASVector + * the Vector to set. + */ + public void setVAMSASAsReference(final java.util.Vector VAMSASVector) { + this._VAMSASList = VAMSASVector; + } + + /** + * Sets the value of field 'version'. The field 'version' has the following + * description: Vamsas Document Version Number + * + * @param version + * the value of field 'version'. + */ + public void setVersion(final java.lang.String version) { + this._version = version; + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @return the unmarshaled uk.ac.vamsas.objects.core.VamsasDocument + */ + public static uk.ac.vamsas.objects.core.VamsasDocument unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + return (uk.ac.vamsas.objects.core.VamsasDocument) Unmarshaller.unmarshal( + uk.ac.vamsas.objects.core.VamsasDocument.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/uk/ac/vamsas/objects/core/Vref.java b/src/uk/ac/vamsas/objects/core/Vref.java index 87f0444..78c50c5 100644 --- a/src/uk/ac/vamsas/objects/core/Vref.java +++ b/src/uk/ac/vamsas/objects/core/Vref.java @@ -1,156 +1,164 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import org.exolab.castor.xml.Marshaller; import org.exolab.castor.xml.Unmarshaller; /** - * Direct associations between this node and any vamsas - * objects + * Direct associations between this node and any vamsas objects * * @version $Revision$ $Date$ */ -public class Vref extends ReferenceType -implements java.io.Serializable -{ - - - //----------------/ - //- Constructors -/ - //----------------/ - - public Vref() { - super(); - } +public class Vref extends ReferenceType implements java.io.Serializable { + // ----------------/ + // - Constructors -/ + // ----------------/ - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Overrides the java.lang.Object.equals method. - * - * @param obj - * @return true if the objects are equal. - */ - public boolean equals( - final java.lang.Object obj) { - if ( this == obj ) - return true; - - if (super.equals(obj)==false) - return false; - - if (obj instanceof Vref) { - - return true; - } - return false; - } + public Vref() { + super(); + } - /** - * Overrides the java.lang.Object.hashCode method. - *

- * The following steps came from Effective Java Programming - * Language Guide by Joshua Bloch, Chapter 3 - * - * @return a hash code value for the object. - */ - public int hashCode( - ) { - int result = super.hashCode(); - - long tmp; - - return result; - } + // -----------/ + // - Methods -/ + // -----------/ - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { - return false; - } - return true; - } + /** + * Overrides the java.lang.Object.equals method. + * + * @param obj + * @return true if the objects are equal. + */ + public boolean equals(final java.lang.Object obj) { + if (this == obj) + return true; - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } + if (super.equals(obj) == false) + return false; - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } + if (obj instanceof Vref) { - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled - * uk.ac.vamsas.objects.core.ReferenceType - */ - public static uk.ac.vamsas.objects.core.ReferenceType unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (uk.ac.vamsas.objects.core.ReferenceType) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.Vref.class, reader); + return true; } - - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); + return false; + } + + /** + * Overrides the java.lang.Object.hashCode method. + *

+ * The following steps came from Effective Java Programming Language + * Guide by Joshua Bloch, Chapter 3 + * + * @return a hash code value for the object. + */ + public int hashCode() { + int result = super.hashCode(); + + long tmp; + + return result; + } + + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() { + try { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) { + return false; } + return true; + } + + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, out); + } + + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, handler); + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @return the unmarshaled uk.ac.vamsas.objects.core.ReferenceType + */ + public static uk.ac.vamsas.objects.core.ReferenceType unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + return (uk.ac.vamsas.objects.core.ReferenceType) Unmarshaller.unmarshal( + uk.ac.vamsas.objects.core.Vref.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/uk/ac/vamsas/objects/core/Vxref.java b/src/uk/ac/vamsas/objects/core/Vxref.java index 0614ee1..c000265 100644 --- a/src/uk/ac/vamsas/objects/core/Vxref.java +++ b/src/uk/ac/vamsas/objects/core/Vxref.java @@ -1,156 +1,164 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import org.exolab.castor.xml.Marshaller; import org.exolab.castor.xml.Unmarshaller; /** - * explicitly named cross reference to - * other objects in the document. + * explicitly named cross reference to other objects in the document. * * @version $Revision$ $Date$ */ -public class Vxref extends ReferenceType -implements java.io.Serializable -{ - - - //----------------/ - //- Constructors -/ - //----------------/ - - public Vxref() { - super(); - } +public class Vxref extends ReferenceType implements java.io.Serializable { + // ----------------/ + // - Constructors -/ + // ----------------/ - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Overrides the java.lang.Object.equals method. - * - * @param obj - * @return true if the objects are equal. - */ - public boolean equals( - final java.lang.Object obj) { - if ( this == obj ) - return true; - - if (super.equals(obj)==false) - return false; - - if (obj instanceof Vxref) { - - return true; - } - return false; - } + public Vxref() { + super(); + } - /** - * Overrides the java.lang.Object.hashCode method. - *

- * The following steps came from Effective Java Programming - * Language Guide by Joshua Bloch, Chapter 3 - * - * @return a hash code value for the object. - */ - public int hashCode( - ) { - int result = super.hashCode(); - - long tmp; - - return result; - } + // -----------/ + // - Methods -/ + // -----------/ - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { - return false; - } - return true; - } + /** + * Overrides the java.lang.Object.equals method. + * + * @param obj + * @return true if the objects are equal. + */ + public boolean equals(final java.lang.Object obj) { + if (this == obj) + return true; - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } + if (super.equals(obj) == false) + return false; - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } + if (obj instanceof Vxref) { - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled - * uk.ac.vamsas.objects.core.ReferenceType - */ - public static uk.ac.vamsas.objects.core.ReferenceType unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (uk.ac.vamsas.objects.core.ReferenceType) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.Vxref.class, reader); + return true; } - - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); + return false; + } + + /** + * Overrides the java.lang.Object.hashCode method. + *

+ * The following steps came from Effective Java Programming Language + * Guide by Joshua Bloch, Chapter 3 + * + * @return a hash code value for the object. + */ + public int hashCode() { + int result = super.hashCode(); + + long tmp; + + return result; + } + + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() { + try { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) { + return false; } + return true; + } + + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, out); + } + + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + Marshaller.marshal(this, handler); + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + * @return the unmarshaled uk.ac.vamsas.objects.core.ReferenceType + */ + public static uk.ac.vamsas.objects.core.ReferenceType unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + return (uk.ac.vamsas.objects.core.ReferenceType) Unmarshaller.unmarshal( + uk.ac.vamsas.objects.core.Vxref.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/uk/ac/vamsas/objects/core/descriptors/AlignmentAnnotationDescriptor.java b/src/uk/ac/vamsas/objects/core/descriptors/AlignmentAnnotationDescriptor.java index 3edd3e3..179b9e5 100644 --- a/src/uk/ac/vamsas/objects/core/descriptors/AlignmentAnnotationDescriptor.java +++ b/src/uk/ac/vamsas/objects/core/descriptors/AlignmentAnnotationDescriptor.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core.descriptors; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import uk.ac.vamsas.objects.core.AlignmentAnnotation; @@ -18,266 +32,266 @@ import uk.ac.vamsas.objects.core.AlignmentAnnotation; * * @version $Revision$ $Date$ */ -public class AlignmentAnnotationDescriptor extends uk.ac.vamsas.objects.core.descriptors.RangeAnnotationDescriptor { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _elementDefinition. - */ - private boolean _elementDefinition; - - /** - * Field _nsPrefix. - */ - private java.lang.String _nsPrefix; - - /** - * Field _nsURI. - */ - private java.lang.String _nsURI; - - /** - * Field _xmlName. - */ - private java.lang.String _xmlName; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public AlignmentAnnotationDescriptor() { - super(); - setExtendsWithoutFlatten(new uk.ac.vamsas.objects.core.descriptors.RangeAnnotationDescriptor()); - _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; - _xmlName = "AlignmentAnnotation"; - _elementDefinition = true; - - //-- set grouping compositor - setCompositorAsSequence(); - org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; - org.exolab.castor.mapping.FieldHandler handler = null; - org.exolab.castor.xml.FieldValidator fieldValidator = null; - //-- initialize attribute descriptors - - //-- _graph - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Boolean.TYPE, "_graph", "graph", org.exolab.castor.xml.NodeType.Attribute); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - AlignmentAnnotation target = (AlignmentAnnotation) object; - if (!target.hasGraph()) { return null; } - return (target.getGraph() ? java.lang.Boolean.TRUE : java.lang.Boolean.FALSE); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - AlignmentAnnotation target = (AlignmentAnnotation) object; - // ignore null values for non optional primitives - if (value == null) { return; } - - target.setGraph( ((java.lang.Boolean) value).booleanValue()); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return null; - } - }; - desc.setHandler(handler); - desc.setRequired(true); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _graph - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); - { //-- local scope - org.exolab.castor.xml.validators.BooleanValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.BooleanValidator(); - fieldValidator.setValidator(typeValidator); - } - desc.setValidator(fieldValidator); - //-- _seqrefs - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Object.class, "_seqrefs", "seqrefs", org.exolab.castor.xml.NodeType.Attribute); - desc.setReference(true); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - AlignmentAnnotation target = (AlignmentAnnotation) object; - return target.getSeqrefs(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - AlignmentAnnotation target = (AlignmentAnnotation) object; - target.addSeqrefs( (java.lang.Object) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public void resetValue(Object object) throws IllegalStateException, IllegalArgumentException { - try { - AlignmentAnnotation target = (AlignmentAnnotation) object; - target.removeAllSeqrefs(); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new java.lang.Object(); - } - }; - desc.setMultivalued(true); - desc.setHandler(handler); - desc.setMultivalued(true); - addFieldDescriptor(desc); - - //-- validation code for: _seqrefs - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(0); - { //-- local scope - org.exolab.castor.xml.validators.IdRefsValidator typeValidator = new org.exolab.castor.xml.validators.IdRefsValidator(); - fieldValidator.setValidator(typeValidator); - desc.setValidator(fieldValidator); - } - desc.setValidator(fieldValidator); - //-- initialize element descriptors - - //-- _provenance - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(uk.ac.vamsas.objects.core.Provenance.class, "_provenance", "Provenance", org.exolab.castor.xml.NodeType.Element); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - AlignmentAnnotation target = (AlignmentAnnotation) object; - return target.getProvenance(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - AlignmentAnnotation target = (AlignmentAnnotation) object; - target.setProvenance( (uk.ac.vamsas.objects.core.Provenance) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new uk.ac.vamsas.objects.core.Provenance(); - } - }; - desc.setHandler(handler); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setRequired(true); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _provenance - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); - { //-- local scope +public class AlignmentAnnotationDescriptor extends + uk.ac.vamsas.objects.core.descriptors.RangeAnnotationDescriptor { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _elementDefinition. + */ + private boolean _elementDefinition; + + /** + * Field _nsPrefix. + */ + private java.lang.String _nsPrefix; + + /** + * Field _nsURI. + */ + private java.lang.String _nsURI; + + /** + * Field _xmlName. + */ + private java.lang.String _xmlName; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public AlignmentAnnotationDescriptor() { + super(); + setExtendsWithoutFlatten(new uk.ac.vamsas.objects.core.descriptors.RangeAnnotationDescriptor()); + _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; + _xmlName = "AlignmentAnnotation"; + _elementDefinition = true; + + // -- set grouping compositor + setCompositorAsSequence(); + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + // -- initialize attribute descriptors + + // -- _graph + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.Boolean.TYPE, "_graph", "graph", + org.exolab.castor.xml.NodeType.Attribute); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + AlignmentAnnotation target = (AlignmentAnnotation) object; + if (!target.hasGraph()) { + return null; } - desc.setValidator(fieldValidator); - } + return (target.getGraph() ? java.lang.Boolean.TRUE + : java.lang.Boolean.FALSE); + } + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + AlignmentAnnotation target = (AlignmentAnnotation) object; + // ignore null values for non optional primitives + if (value == null) { + return; + } - //-----------/ - //- Methods -/ - //-----------/ + target.setGraph(((java.lang.Boolean) value).booleanValue()); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getAccessMode. - * - * @return the access mode specified for this class. - */ - public org.exolab.castor.mapping.AccessMode getAccessMode( - ) { + public java.lang.Object newInstance(java.lang.Object parent) { return null; - } + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); - /** - * Method getIdentity. - * - * @return the identity field, null if this class has no - * identity. - */ - public org.exolab.castor.mapping.FieldDescriptor getIdentity( - ) { - return super.getIdentity(); + // -- validation code for: _graph + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { // -- local scope + org.exolab.castor.xml.validators.BooleanValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.BooleanValidator(); + fieldValidator.setValidator(typeValidator); } + desc.setValidator(fieldValidator); + // -- _seqrefs + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.Object.class, "_seqrefs", "seqrefs", + org.exolab.castor.xml.NodeType.Attribute); + desc.setReference(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + AlignmentAnnotation target = (AlignmentAnnotation) object; + return target.getSeqrefs(); + } - /** - * Method getJavaClass. - * - * @return the Java class represented by this descriptor. - */ - public java.lang.Class getJavaClass( - ) { - return uk.ac.vamsas.objects.core.AlignmentAnnotation.class; - } + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + AlignmentAnnotation target = (AlignmentAnnotation) object; + target.addSeqrefs((java.lang.Object) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getNameSpacePrefix. - * - * @return the namespace prefix to use when marshaling as XML. - */ - public java.lang.String getNameSpacePrefix( - ) { - return _nsPrefix; - } + public void resetValue(Object object) throws IllegalStateException, + IllegalArgumentException { + try { + AlignmentAnnotation target = (AlignmentAnnotation) object; + target.removeAllSeqrefs(); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getNameSpaceURI. - * - * @return the namespace URI used when marshaling and - * unmarshaling as XML. - */ - public java.lang.String getNameSpaceURI( - ) { - return _nsURI; - } + public java.lang.Object newInstance(java.lang.Object parent) { + return new java.lang.Object(); + } + }; + desc.setMultivalued(true); + desc.setHandler(handler); + desc.setMultivalued(true); + addFieldDescriptor(desc); - /** - * Method getValidator. - * - * @return a specific validator for the class described by this - * ClassDescriptor. - */ - public org.exolab.castor.xml.TypeValidator getValidator( - ) { - return this; + // -- validation code for: _seqrefs + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { // -- local scope + org.exolab.castor.xml.validators.IdRefsValidator typeValidator = new org.exolab.castor.xml.validators.IdRefsValidator(); + fieldValidator.setValidator(typeValidator); + desc.setValidator(fieldValidator); } + desc.setValidator(fieldValidator); + // -- initialize element descriptors - /** - * Method getXMLName. - * - * @return the XML Name for the Class being described. - */ - public java.lang.String getXMLName( - ) { - return _xmlName; - } + // -- _provenance + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + uk.ac.vamsas.objects.core.Provenance.class, "_provenance", + "Provenance", org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + AlignmentAnnotation target = (AlignmentAnnotation) object; + return target.getProvenance(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + AlignmentAnnotation target = (AlignmentAnnotation) object; + target.setProvenance((uk.ac.vamsas.objects.core.Provenance) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return new uk.ac.vamsas.objects.core.Provenance(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); - /** - * Method isElementDefinition. - * - * @return true if XML schema definition of this Class is that - * of a global - * element or element with anonymous type definition. - */ - public boolean isElementDefinition( - ) { - return _elementDefinition; + // -- validation code for: _provenance + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { // -- local scope } + desc.setValidator(fieldValidator); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * Method getAccessMode. + * + * @return the access mode specified for this class. + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() { + return null; + } + + /** + * Method getIdentity. + * + * @return the identity field, null if this class has no identity. + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() { + return super.getIdentity(); + } + + /** + * Method getJavaClass. + * + * @return the Java class represented by this descriptor. + */ + public java.lang.Class getJavaClass() { + return uk.ac.vamsas.objects.core.AlignmentAnnotation.class; + } + + /** + * Method getNameSpacePrefix. + * + * @return the namespace prefix to use when marshaling as XML. + */ + public java.lang.String getNameSpacePrefix() { + return _nsPrefix; + } + + /** + * Method getNameSpaceURI. + * + * @return the namespace URI used when marshaling and unmarshaling as XML. + */ + public java.lang.String getNameSpaceURI() { + return _nsURI; + } + + /** + * Method getValidator. + * + * @return a specific validator for the class described by this + * ClassDescriptor. + */ + public org.exolab.castor.xml.TypeValidator getValidator() { + return this; + } + + /** + * Method getXMLName. + * + * @return the XML Name for the Class being described. + */ + public java.lang.String getXMLName() { + return _xmlName; + } + + /** + * Method isElementDefinition. + * + * @return true if XML schema definition of this Class is that of a global + * element or element with anonymous type definition. + */ + public boolean isElementDefinition() { + return _elementDefinition; + } } diff --git a/src/uk/ac/vamsas/objects/core/descriptors/AlignmentDescriptor.java b/src/uk/ac/vamsas/objects/core/descriptors/AlignmentDescriptor.java index 4d3607e..94d9c08 100644 --- a/src/uk/ac/vamsas/objects/core/descriptors/AlignmentDescriptor.java +++ b/src/uk/ac/vamsas/objects/core/descriptors/AlignmentDescriptor.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core.descriptors; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import uk.ac.vamsas.objects.core.Alignment; @@ -18,500 +32,520 @@ import uk.ac.vamsas.objects.core.Alignment; * * @version $Revision$ $Date$ */ -public class AlignmentDescriptor extends org.exolab.castor.xml.util.XMLClassDescriptorImpl { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _elementDefinition. - */ - private boolean _elementDefinition; - - /** - * Field _nsPrefix. - */ - private java.lang.String _nsPrefix; - - /** - * Field _nsURI. - */ - private java.lang.String _nsURI; - - /** - * Field _xmlName. - */ - private java.lang.String _xmlName; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public AlignmentDescriptor() { - super(); - _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; - _xmlName = "Alignment"; - _elementDefinition = true; - - //-- set grouping compositor - setCompositorAsSequence(); - org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; - org.exolab.castor.mapping.FieldHandler handler = null; - org.exolab.castor.xml.FieldValidator fieldValidator = null; - //-- initialize attribute descriptors - - //-- _gapChar - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_gapChar", "gapChar", 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 - { - Alignment target = (Alignment) object; - return target.getGapChar(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Alignment target = (Alignment) object; - target.setGapChar( (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); - desc.setRequired(true); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _gapChar - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); - { //-- local scope - org.exolab.castor.xml.validators.StringValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.StringValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setWhiteSpace("preserve"); +public class AlignmentDescriptor extends + org.exolab.castor.xml.util.XMLClassDescriptorImpl { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _elementDefinition. + */ + private boolean _elementDefinition; + + /** + * Field _nsPrefix. + */ + private java.lang.String _nsPrefix; + + /** + * Field _nsURI. + */ + private java.lang.String _nsURI; + + /** + * Field _xmlName. + */ + private java.lang.String _xmlName; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public AlignmentDescriptor() { + super(); + _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; + _xmlName = "Alignment"; + _elementDefinition = true; + + // -- set grouping compositor + setCompositorAsSequence(); + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + // -- initialize attribute descriptors + + // -- _gapChar + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_gapChar", "gapChar", + 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 { + Alignment target = (Alignment) object; + return target.getGapChar(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Alignment target = (Alignment) object; + target.setGapChar((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- _aligned - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Boolean.TYPE, "_aligned", "aligned", org.exolab.castor.xml.NodeType.Attribute); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - Alignment target = (Alignment) object; - if (!target.hasAligned()) { return null; } - return (target.getAligned() ? java.lang.Boolean.TRUE : java.lang.Boolean.FALSE); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Alignment target = (Alignment) object; - // if null, use delete method for optional primitives - if (value == null) { - target.deleteAligned(); - return; - } - target.setAligned( ((java.lang.Boolean) value).booleanValue()); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return null; - } - }; - desc.setHandler(handler); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _aligned - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope - org.exolab.castor.xml.validators.BooleanValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.BooleanValidator(); - fieldValidator.setValidator(typeValidator); + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return null; + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _gapChar + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { // -- local scope + org.exolab.castor.xml.validators.StringValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.StringValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setWhiteSpace("preserve"); + } + desc.setValidator(fieldValidator); + // -- _aligned + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.Boolean.TYPE, "_aligned", "aligned", + org.exolab.castor.xml.NodeType.Attribute); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + Alignment target = (Alignment) object; + if (!target.hasAligned()) { + return null; } - desc.setValidator(fieldValidator); - //-- _id - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_id", "id", org.exolab.castor.xml.NodeType.Attribute); - super.setIdentity(desc); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - Alignment target = (Alignment) object; - return target.getId(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Alignment target = (Alignment) object; - target.setId( (java.lang.String) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new java.lang.String(); - } - }; - desc.setHandler(handler); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _id - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope - org.exolab.castor.xml.validators.IdValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.IdValidator(); - fieldValidator.setValidator(typeValidator); + return (target.getAligned() ? java.lang.Boolean.TRUE + : java.lang.Boolean.FALSE); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Alignment target = (Alignment) object; + // if null, use delete method for optional primitives + if (value == null) { + target.deleteAligned(); + return; + } + target.setAligned(((java.lang.Boolean) value).booleanValue()); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- _modifiable - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_modifiable", "modifiable", 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 - { - Alignment target = (Alignment) object; - return target.getModifiable(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Alignment target = (Alignment) object; - target.setModifiable( (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); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _modifiable - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope - org.exolab.castor.xml.validators.StringValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.StringValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setWhiteSpace("preserve"); + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return null; + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _aligned + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { // -- local scope + org.exolab.castor.xml.validators.BooleanValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.BooleanValidator(); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + // -- _id + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_id", "id", + org.exolab.castor.xml.NodeType.Attribute); + super.setIdentity(desc); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + Alignment target = (Alignment) object; + return target.getId(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Alignment target = (Alignment) object; + target.setId((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- initialize element descriptors - - //-- _alignmentAnnotationList - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(uk.ac.vamsas.objects.core.AlignmentAnnotation.class, "_alignmentAnnotationList", "AlignmentAnnotation", org.exolab.castor.xml.NodeType.Element); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - Alignment target = (Alignment) object; - return target.getAlignmentAnnotation(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Alignment target = (Alignment) object; - target.addAlignmentAnnotation( (uk.ac.vamsas.objects.core.AlignmentAnnotation) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public void resetValue(Object object) throws IllegalStateException, IllegalArgumentException { - try { - Alignment target = (Alignment) object; - target.removeAllAlignmentAnnotation(); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new uk.ac.vamsas.objects.core.AlignmentAnnotation(); - } - }; - desc.setHandler(handler); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setMultivalued(true); - addFieldDescriptor(desc); - - //-- validation code for: _alignmentAnnotationList - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(0); - { //-- local scope + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return new java.lang.String(); + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _id + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { // -- local scope + org.exolab.castor.xml.validators.IdValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.IdValidator(); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + // -- _modifiable + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_modifiable", "modifiable", + 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 { + Alignment target = (Alignment) object; + return target.getModifiable(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Alignment target = (Alignment) object; + target.setModifiable((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- _treeList - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(uk.ac.vamsas.objects.core.Tree.class, "_treeList", "Tree", org.exolab.castor.xml.NodeType.Element); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - Alignment target = (Alignment) object; - return target.getTree(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Alignment target = (Alignment) object; - target.addTree( (uk.ac.vamsas.objects.core.Tree) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public void resetValue(Object object) throws IllegalStateException, IllegalArgumentException { - try { - Alignment target = (Alignment) object; - target.removeAllTree(); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new uk.ac.vamsas.objects.core.Tree(); - } - }; - desc.setHandler(handler); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setMultivalued(true); - addFieldDescriptor(desc); - - //-- validation code for: _treeList - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(0); - { //-- local scope + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return null; + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _modifiable + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { // -- local scope + org.exolab.castor.xml.validators.StringValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.StringValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setWhiteSpace("preserve"); + } + desc.setValidator(fieldValidator); + // -- initialize element descriptors + + // -- _alignmentAnnotationList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + uk.ac.vamsas.objects.core.AlignmentAnnotation.class, + "_alignmentAnnotationList", "AlignmentAnnotation", + org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + Alignment target = (Alignment) object; + return target.getAlignmentAnnotation(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Alignment target = (Alignment) object; + target + .addAlignmentAnnotation((uk.ac.vamsas.objects.core.AlignmentAnnotation) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- _alignmentSequenceList - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(uk.ac.vamsas.objects.core.AlignmentSequence.class, "_alignmentSequenceList", "alignmentSequence", org.exolab.castor.xml.NodeType.Element); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - Alignment target = (Alignment) object; - return target.getAlignmentSequence(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Alignment target = (Alignment) object; - target.addAlignmentSequence( (uk.ac.vamsas.objects.core.AlignmentSequence) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public void resetValue(Object object) throws IllegalStateException, IllegalArgumentException { - try { - Alignment target = (Alignment) object; - target.removeAllAlignmentSequence(); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new uk.ac.vamsas.objects.core.AlignmentSequence(); - } - }; - desc.setHandler(handler); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setRequired(true); - desc.setMultivalued(true); - addFieldDescriptor(desc); - - //-- validation code for: _alignmentSequenceList - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); - { //-- local scope + } + + public void resetValue(Object object) throws IllegalStateException, + IllegalArgumentException { + try { + Alignment target = (Alignment) object; + target.removeAllAlignmentAnnotation(); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- _propertyList - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(uk.ac.vamsas.objects.core.Property.class, "_propertyList", "property", org.exolab.castor.xml.NodeType.Element); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - Alignment target = (Alignment) object; - return target.getProperty(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Alignment target = (Alignment) object; - target.addProperty( (uk.ac.vamsas.objects.core.Property) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public void resetValue(Object object) throws IllegalStateException, IllegalArgumentException { - try { - Alignment target = (Alignment) object; - target.removeAllProperty(); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new uk.ac.vamsas.objects.core.Property(); - } - }; - desc.setHandler(handler); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setMultivalued(true); - addFieldDescriptor(desc); - - //-- validation code for: _propertyList - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(0); - { //-- local scope + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return new uk.ac.vamsas.objects.core.AlignmentAnnotation(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + // -- validation code for: _alignmentAnnotationList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { // -- local scope + } + desc.setValidator(fieldValidator); + // -- _treeList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + uk.ac.vamsas.objects.core.Tree.class, "_treeList", "Tree", + org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + Alignment target = (Alignment) object; + return target.getTree(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Alignment target = (Alignment) object; + target.addTree((uk.ac.vamsas.objects.core.Tree) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- _provenance - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(uk.ac.vamsas.objects.core.Provenance.class, "_provenance", "Provenance", org.exolab.castor.xml.NodeType.Element); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - Alignment target = (Alignment) object; - return target.getProvenance(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Alignment target = (Alignment) object; - target.setProvenance( (uk.ac.vamsas.objects.core.Provenance) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new uk.ac.vamsas.objects.core.Provenance(); - } - }; - desc.setHandler(handler); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setRequired(true); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _provenance - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); - { //-- local scope + } + + public void resetValue(Object object) throws IllegalStateException, + IllegalArgumentException { + try { + Alignment target = (Alignment) object; + target.removeAllTree(); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return new uk.ac.vamsas.objects.core.Tree(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + // -- validation code for: _treeList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { // -- local scope } + desc.setValidator(fieldValidator); + // -- _alignmentSequenceList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + uk.ac.vamsas.objects.core.AlignmentSequence.class, + "_alignmentSequenceList", "alignmentSequence", + org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + Alignment target = (Alignment) object; + return target.getAlignmentSequence(); + } + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Alignment target = (Alignment) object; + target + .addAlignmentSequence((uk.ac.vamsas.objects.core.AlignmentSequence) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - //-----------/ - //- Methods -/ - //-----------/ + public void resetValue(Object object) throws IllegalStateException, + IllegalArgumentException { + try { + Alignment target = (Alignment) object; + target.removeAllAlignmentSequence(); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getAccessMode. - * - * @return the access mode specified for this class. - */ - public org.exolab.castor.mapping.AccessMode getAccessMode( - ) { - return null; - } + public java.lang.Object newInstance(java.lang.Object parent) { + return new uk.ac.vamsas.objects.core.AlignmentSequence(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setRequired(true); + desc.setMultivalued(true); + addFieldDescriptor(desc); - /** - * Method getIdentity. - * - * @return the identity field, null if this class has no - * identity. - */ - public org.exolab.castor.mapping.FieldDescriptor getIdentity( - ) { - return super.getIdentity(); + // -- validation code for: _alignmentSequenceList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { // -- local scope } + desc.setValidator(fieldValidator); + // -- _propertyList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + uk.ac.vamsas.objects.core.Property.class, "_propertyList", "property", + org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + Alignment target = (Alignment) object; + return target.getProperty(); + } - /** - * Method getJavaClass. - * - * @return the Java class represented by this descriptor. - */ - public java.lang.Class getJavaClass( - ) { - return uk.ac.vamsas.objects.core.Alignment.class; - } + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Alignment target = (Alignment) object; + target.addProperty((uk.ac.vamsas.objects.core.Property) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getNameSpacePrefix. - * - * @return the namespace prefix to use when marshaling as XML. - */ - public java.lang.String getNameSpacePrefix( - ) { - return _nsPrefix; - } + public void resetValue(Object object) throws IllegalStateException, + IllegalArgumentException { + try { + Alignment target = (Alignment) object; + target.removeAllProperty(); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getNameSpaceURI. - * - * @return the namespace URI used when marshaling and - * unmarshaling as XML. - */ - public java.lang.String getNameSpaceURI( - ) { - return _nsURI; - } + public java.lang.Object newInstance(java.lang.Object parent) { + return new uk.ac.vamsas.objects.core.Property(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setMultivalued(true); + addFieldDescriptor(desc); - /** - * Method getValidator. - * - * @return a specific validator for the class described by this - * ClassDescriptor. - */ - public org.exolab.castor.xml.TypeValidator getValidator( - ) { - return this; + // -- validation code for: _propertyList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { // -- local scope } + desc.setValidator(fieldValidator); + // -- _provenance + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + uk.ac.vamsas.objects.core.Provenance.class, "_provenance", + "Provenance", org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + Alignment target = (Alignment) object; + return target.getProvenance(); + } - /** - * Method getXMLName. - * - * @return the XML Name for the Class being described. - */ - public java.lang.String getXMLName( - ) { - return _xmlName; - } + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Alignment target = (Alignment) object; + target.setProvenance((uk.ac.vamsas.objects.core.Provenance) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method isElementDefinition. - * - * @return true if XML schema definition of this Class is that - * of a global - * element or element with anonymous type definition. - */ - public boolean isElementDefinition( - ) { - return _elementDefinition; + public java.lang.Object newInstance(java.lang.Object parent) { + return new uk.ac.vamsas.objects.core.Provenance(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _provenance + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { // -- local scope } + desc.setValidator(fieldValidator); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * Method getAccessMode. + * + * @return the access mode specified for this class. + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() { + return null; + } + + /** + * Method getIdentity. + * + * @return the identity field, null if this class has no identity. + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() { + return super.getIdentity(); + } + + /** + * Method getJavaClass. + * + * @return the Java class represented by this descriptor. + */ + public java.lang.Class getJavaClass() { + return uk.ac.vamsas.objects.core.Alignment.class; + } + + /** + * Method getNameSpacePrefix. + * + * @return the namespace prefix to use when marshaling as XML. + */ + public java.lang.String getNameSpacePrefix() { + return _nsPrefix; + } + + /** + * Method getNameSpaceURI. + * + * @return the namespace URI used when marshaling and unmarshaling as XML. + */ + public java.lang.String getNameSpaceURI() { + return _nsURI; + } + + /** + * Method getValidator. + * + * @return a specific validator for the class described by this + * ClassDescriptor. + */ + public org.exolab.castor.xml.TypeValidator getValidator() { + return this; + } + + /** + * Method getXMLName. + * + * @return the XML Name for the Class being described. + */ + public java.lang.String getXMLName() { + return _xmlName; + } + + /** + * Method isElementDefinition. + * + * @return true if XML schema definition of this Class is that of a global + * element or element with anonymous type definition. + */ + public boolean isElementDefinition() { + return _elementDefinition; + } } diff --git a/src/uk/ac/vamsas/objects/core/descriptors/AlignmentSequenceAnnotationDescriptor.java b/src/uk/ac/vamsas/objects/core/descriptors/AlignmentSequenceAnnotationDescriptor.java index 44d0c00..ad6b662 100644 --- a/src/uk/ac/vamsas/objects/core/descriptors/AlignmentSequenceAnnotationDescriptor.java +++ b/src/uk/ac/vamsas/objects/core/descriptors/AlignmentSequenceAnnotationDescriptor.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core.descriptors; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation; @@ -18,220 +32,216 @@ import uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation; * * @version $Revision$ $Date$ */ -public class AlignmentSequenceAnnotationDescriptor extends uk.ac.vamsas.objects.core.descriptors.RangeAnnotationDescriptor { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _elementDefinition. - */ - private boolean _elementDefinition; - - /** - * Field _nsPrefix. - */ - private java.lang.String _nsPrefix; - - /** - * Field _nsURI. - */ - private java.lang.String _nsURI; - - /** - * Field _xmlName. - */ - private java.lang.String _xmlName; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public AlignmentSequenceAnnotationDescriptor() { - super(); - setExtendsWithoutFlatten(new uk.ac.vamsas.objects.core.descriptors.RangeAnnotationDescriptor()); - _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; - _xmlName = "AlignmentSequenceAnnotation"; - _elementDefinition = true; - - //-- set grouping compositor - setCompositorAsSequence(); - org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; - org.exolab.castor.mapping.FieldHandler handler = null; - org.exolab.castor.xml.FieldValidator fieldValidator = null; - //-- initialize attribute descriptors - - //-- _graph - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Boolean.TYPE, "_graph", "graph", org.exolab.castor.xml.NodeType.Attribute); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - AlignmentSequenceAnnotation target = (AlignmentSequenceAnnotation) object; - if (!target.hasGraph()) { return null; } - return (target.getGraph() ? java.lang.Boolean.TRUE : java.lang.Boolean.FALSE); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - AlignmentSequenceAnnotation target = (AlignmentSequenceAnnotation) object; - // ignore null values for non optional primitives - if (value == null) { return; } - - target.setGraph( ((java.lang.Boolean) value).booleanValue()); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return null; - } - }; - desc.setHandler(handler); - desc.setRequired(true); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _graph - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); - { //-- local scope - org.exolab.castor.xml.validators.BooleanValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.BooleanValidator(); - fieldValidator.setValidator(typeValidator); +public class AlignmentSequenceAnnotationDescriptor extends + uk.ac.vamsas.objects.core.descriptors.RangeAnnotationDescriptor { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _elementDefinition. + */ + private boolean _elementDefinition; + + /** + * Field _nsPrefix. + */ + private java.lang.String _nsPrefix; + + /** + * Field _nsURI. + */ + private java.lang.String _nsURI; + + /** + * Field _xmlName. + */ + private java.lang.String _xmlName; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public AlignmentSequenceAnnotationDescriptor() { + super(); + setExtendsWithoutFlatten(new uk.ac.vamsas.objects.core.descriptors.RangeAnnotationDescriptor()); + _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; + _xmlName = "AlignmentSequenceAnnotation"; + _elementDefinition = true; + + // -- set grouping compositor + setCompositorAsSequence(); + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + // -- initialize attribute descriptors + + // -- _graph + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.Boolean.TYPE, "_graph", "graph", + org.exolab.castor.xml.NodeType.Attribute); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + AlignmentSequenceAnnotation target = (AlignmentSequenceAnnotation) object; + if (!target.hasGraph()) { + return null; } - desc.setValidator(fieldValidator); - //-- initialize element descriptors - - //-- _provenance - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(uk.ac.vamsas.objects.core.Provenance.class, "_provenance", "Provenance", org.exolab.castor.xml.NodeType.Element); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - AlignmentSequenceAnnotation target = (AlignmentSequenceAnnotation) object; - return target.getProvenance(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - AlignmentSequenceAnnotation target = (AlignmentSequenceAnnotation) object; - target.setProvenance( (uk.ac.vamsas.objects.core.Provenance) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new uk.ac.vamsas.objects.core.Provenance(); - } - }; - desc.setHandler(handler); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setRequired(true); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _provenance - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); - { //-- local scope + return (target.getGraph() ? java.lang.Boolean.TRUE + : java.lang.Boolean.FALSE); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + AlignmentSequenceAnnotation target = (AlignmentSequenceAnnotation) object; + // ignore null values for non optional primitives + if (value == null) { + return; + } + + target.setGraph(((java.lang.Boolean) value).booleanValue()); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - } + } - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Method getAccessMode. - * - * @return the access mode specified for this class. - */ - public org.exolab.castor.mapping.AccessMode getAccessMode( - ) { + public java.lang.Object newInstance(java.lang.Object parent) { return null; + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _graph + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { // -- local scope + org.exolab.castor.xml.validators.BooleanValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.BooleanValidator(); + fieldValidator.setValidator(typeValidator); } - - /** - * Method getIdentity. - * - * @return the identity field, null if this class has no - * identity. - */ - public org.exolab.castor.mapping.FieldDescriptor getIdentity( - ) { - return super.getIdentity(); - } - - /** - * Method getJavaClass. - * - * @return the Java class represented by this descriptor. - */ - public java.lang.Class getJavaClass( - ) { - return uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation.class; - } - - /** - * Method getNameSpacePrefix. - * - * @return the namespace prefix to use when marshaling as XML. - */ - public java.lang.String getNameSpacePrefix( - ) { - return _nsPrefix; - } - - /** - * Method getNameSpaceURI. - * - * @return the namespace URI used when marshaling and - * unmarshaling as XML. - */ - public java.lang.String getNameSpaceURI( - ) { - return _nsURI; - } - - /** - * Method getValidator. - * - * @return a specific validator for the class described by this - * ClassDescriptor. - */ - public org.exolab.castor.xml.TypeValidator getValidator( - ) { - return this; - } - - /** - * Method getXMLName. - * - * @return the XML Name for the Class being described. - */ - public java.lang.String getXMLName( - ) { - return _xmlName; - } - - /** - * Method isElementDefinition. - * - * @return true if XML schema definition of this Class is that - * of a global - * element or element with anonymous type definition. - */ - public boolean isElementDefinition( - ) { - return _elementDefinition; + desc.setValidator(fieldValidator); + // -- initialize element descriptors + + // -- _provenance + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + uk.ac.vamsas.objects.core.Provenance.class, "_provenance", + "Provenance", org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + AlignmentSequenceAnnotation target = (AlignmentSequenceAnnotation) object; + return target.getProvenance(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + AlignmentSequenceAnnotation target = (AlignmentSequenceAnnotation) object; + target.setProvenance((uk.ac.vamsas.objects.core.Provenance) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return new uk.ac.vamsas.objects.core.Provenance(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _provenance + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { // -- local scope } + desc.setValidator(fieldValidator); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * Method getAccessMode. + * + * @return the access mode specified for this class. + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() { + return null; + } + + /** + * Method getIdentity. + * + * @return the identity field, null if this class has no identity. + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() { + return super.getIdentity(); + } + + /** + * Method getJavaClass. + * + * @return the Java class represented by this descriptor. + */ + public java.lang.Class getJavaClass() { + return uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation.class; + } + + /** + * Method getNameSpacePrefix. + * + * @return the namespace prefix to use when marshaling as XML. + */ + public java.lang.String getNameSpacePrefix() { + return _nsPrefix; + } + + /** + * Method getNameSpaceURI. + * + * @return the namespace URI used when marshaling and unmarshaling as XML. + */ + public java.lang.String getNameSpaceURI() { + return _nsURI; + } + + /** + * Method getValidator. + * + * @return a specific validator for the class described by this + * ClassDescriptor. + */ + public org.exolab.castor.xml.TypeValidator getValidator() { + return this; + } + + /** + * Method getXMLName. + * + * @return the XML Name for the Class being described. + */ + public java.lang.String getXMLName() { + return _xmlName; + } + + /** + * Method isElementDefinition. + * + * @return true if XML schema definition of this Class is that of a global + * element or element with anonymous type definition. + */ + public boolean isElementDefinition() { + return _elementDefinition; + } } diff --git a/src/uk/ac/vamsas/objects/core/descriptors/AlignmentSequenceDescriptor.java b/src/uk/ac/vamsas/objects/core/descriptors/AlignmentSequenceDescriptor.java index d1b7830..5478a26 100644 --- a/src/uk/ac/vamsas/objects/core/descriptors/AlignmentSequenceDescriptor.java +++ b/src/uk/ac/vamsas/objects/core/descriptors/AlignmentSequenceDescriptor.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core.descriptors; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import uk.ac.vamsas.objects.core.AlignmentSequence; @@ -18,260 +32,257 @@ import uk.ac.vamsas.objects.core.AlignmentSequence; * * @version $Revision$ $Date$ */ -public class AlignmentSequenceDescriptor extends uk.ac.vamsas.objects.core.descriptors.SequenceTypeDescriptor { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _elementDefinition. - */ - private boolean _elementDefinition; - - /** - * Field _nsPrefix. - */ - private java.lang.String _nsPrefix; - - /** - * Field _nsURI. - */ - private java.lang.String _nsURI; - - /** - * Field _xmlName. - */ - private java.lang.String _xmlName; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public AlignmentSequenceDescriptor() { - super(); - setExtendsWithoutFlatten(new uk.ac.vamsas.objects.core.descriptors.SequenceTypeDescriptor()); - _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; - _xmlName = "alignmentSequence"; - _elementDefinition = true; - - //-- set grouping compositor - setCompositorAsSequence(); - org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; - org.exolab.castor.mapping.FieldHandler handler = null; - org.exolab.castor.xml.FieldValidator fieldValidator = null; - //-- initialize attribute descriptors - - //-- _id - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_id", "id", org.exolab.castor.xml.NodeType.Attribute); - super.setIdentity(desc); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - AlignmentSequence target = (AlignmentSequence) object; - return target.getId(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - AlignmentSequence target = (AlignmentSequence) object; - target.setId( (java.lang.String) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new java.lang.String(); - } - }; - desc.setHandler(handler); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _id - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope - org.exolab.castor.xml.validators.IdValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.IdValidator(); - fieldValidator.setValidator(typeValidator); - } - desc.setValidator(fieldValidator); - //-- _refid - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Object.class, "_refid", "refid", org.exolab.castor.xml.NodeType.Attribute); - desc.setReference(true); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - AlignmentSequence target = (AlignmentSequence) object; - return target.getRefid(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - AlignmentSequence target = (AlignmentSequence) object; - target.setRefid( (java.lang.Object) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new java.lang.Object(); - } - }; - desc.setHandler(handler); - desc.setRequired(true); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _refid - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); - { //-- local scope - org.exolab.castor.xml.validators.IdRefValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.IdRefValidator(); - fieldValidator.setValidator(typeValidator); - } - desc.setValidator(fieldValidator); - //-- initialize element descriptors - - //-- _alignmentSequenceAnnotationList - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation.class, "_alignmentSequenceAnnotationList", "AlignmentSequenceAnnotation", org.exolab.castor.xml.NodeType.Element); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - AlignmentSequence target = (AlignmentSequence) object; - return target.getAlignmentSequenceAnnotation(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - AlignmentSequence target = (AlignmentSequence) object; - target.addAlignmentSequenceAnnotation( (uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public void resetValue(Object object) throws IllegalStateException, IllegalArgumentException { - try { - AlignmentSequence target = (AlignmentSequence) object; - target.removeAllAlignmentSequenceAnnotation(); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation(); - } - }; - desc.setHandler(handler); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setMultivalued(true); - addFieldDescriptor(desc); - - //-- validation code for: _alignmentSequenceAnnotationList - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(0); - { //-- local scope +public class AlignmentSequenceDescriptor extends + uk.ac.vamsas.objects.core.descriptors.SequenceTypeDescriptor { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _elementDefinition. + */ + private boolean _elementDefinition; + + /** + * Field _nsPrefix. + */ + private java.lang.String _nsPrefix; + + /** + * Field _nsURI. + */ + private java.lang.String _nsURI; + + /** + * Field _xmlName. + */ + private java.lang.String _xmlName; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public AlignmentSequenceDescriptor() { + super(); + setExtendsWithoutFlatten(new uk.ac.vamsas.objects.core.descriptors.SequenceTypeDescriptor()); + _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; + _xmlName = "alignmentSequence"; + _elementDefinition = true; + + // -- set grouping compositor + setCompositorAsSequence(); + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + // -- initialize attribute descriptors + + // -- _id + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_id", "id", + org.exolab.castor.xml.NodeType.Attribute); + super.setIdentity(desc); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + AlignmentSequence target = (AlignmentSequence) object; + return target.getId(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + AlignmentSequence target = (AlignmentSequence) object; + target.setId((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return new java.lang.String(); + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _id + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { // -- local scope + org.exolab.castor.xml.validators.IdValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.IdValidator(); + fieldValidator.setValidator(typeValidator); } + desc.setValidator(fieldValidator); + // -- _refid + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.Object.class, "_refid", "refid", + org.exolab.castor.xml.NodeType.Attribute); + desc.setReference(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + AlignmentSequence target = (AlignmentSequence) object; + return target.getRefid(); + } + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + AlignmentSequence target = (AlignmentSequence) object; + target.setRefid((java.lang.Object) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - //-----------/ - //- Methods -/ - //-----------/ + public java.lang.Object newInstance(java.lang.Object parent) { + return new java.lang.Object(); + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); - /** - * Method getAccessMode. - * - * @return the access mode specified for this class. - */ - public org.exolab.castor.mapping.AccessMode getAccessMode( - ) { - return null; + // -- validation code for: _refid + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { // -- local scope + org.exolab.castor.xml.validators.IdRefValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.IdRefValidator(); + fieldValidator.setValidator(typeValidator); } + desc.setValidator(fieldValidator); + // -- initialize element descriptors - /** - * Method getIdentity. - * - * @return the identity field, null if this class has no - * identity. - */ - public org.exolab.castor.mapping.FieldDescriptor getIdentity( - ) { - return super.getIdentity(); - } + // -- _alignmentSequenceAnnotationList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation.class, + "_alignmentSequenceAnnotationList", "AlignmentSequenceAnnotation", + org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + AlignmentSequence target = (AlignmentSequence) object; + return target.getAlignmentSequenceAnnotation(); + } - /** - * Method getJavaClass. - * - * @return the Java class represented by this descriptor. - */ - public java.lang.Class getJavaClass( - ) { - return uk.ac.vamsas.objects.core.AlignmentSequence.class; - } + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + AlignmentSequence target = (AlignmentSequence) object; + target + .addAlignmentSequenceAnnotation((uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getNameSpacePrefix. - * - * @return the namespace prefix to use when marshaling as XML. - */ - public java.lang.String getNameSpacePrefix( - ) { - return _nsPrefix; - } + public void resetValue(Object object) throws IllegalStateException, + IllegalArgumentException { + try { + AlignmentSequence target = (AlignmentSequence) object; + target.removeAllAlignmentSequenceAnnotation(); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getNameSpaceURI. - * - * @return the namespace URI used when marshaling and - * unmarshaling as XML. - */ - public java.lang.String getNameSpaceURI( - ) { - return _nsURI; - } + public java.lang.Object newInstance(java.lang.Object parent) { + return new uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setMultivalued(true); + addFieldDescriptor(desc); - /** - * Method getValidator. - * - * @return a specific validator for the class described by this - * ClassDescriptor. - */ - public org.exolab.castor.xml.TypeValidator getValidator( - ) { - return this; + // -- validation code for: _alignmentSequenceAnnotationList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { // -- local scope } + desc.setValidator(fieldValidator); + } - /** - * Method getXMLName. - * - * @return the XML Name for the Class being described. - */ - public java.lang.String getXMLName( - ) { - return _xmlName; - } + // -----------/ + // - Methods -/ + // -----------/ - /** - * Method isElementDefinition. - * - * @return true if XML schema definition of this Class is that - * of a global - * element or element with anonymous type definition. - */ - public boolean isElementDefinition( - ) { - return _elementDefinition; - } + /** + * Method getAccessMode. + * + * @return the access mode specified for this class. + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() { + return null; + } + + /** + * Method getIdentity. + * + * @return the identity field, null if this class has no identity. + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() { + return super.getIdentity(); + } + + /** + * Method getJavaClass. + * + * @return the Java class represented by this descriptor. + */ + public java.lang.Class getJavaClass() { + return uk.ac.vamsas.objects.core.AlignmentSequence.class; + } + + /** + * Method getNameSpacePrefix. + * + * @return the namespace prefix to use when marshaling as XML. + */ + public java.lang.String getNameSpacePrefix() { + return _nsPrefix; + } + + /** + * Method getNameSpaceURI. + * + * @return the namespace URI used when marshaling and unmarshaling as XML. + */ + public java.lang.String getNameSpaceURI() { + return _nsURI; + } + + /** + * Method getValidator. + * + * @return a specific validator for the class described by this + * ClassDescriptor. + */ + public org.exolab.castor.xml.TypeValidator getValidator() { + return this; + } + + /** + * Method getXMLName. + * + * @return the XML Name for the Class being described. + */ + public java.lang.String getXMLName() { + return _xmlName; + } + + /** + * Method isElementDefinition. + * + * @return true if XML schema definition of this Class is that of a global + * element or element with anonymous type definition. + */ + public boolean isElementDefinition() { + return _elementDefinition; + } } diff --git a/src/uk/ac/vamsas/objects/core/descriptors/AnnotationElementDescriptor.java b/src/uk/ac/vamsas/objects/core/descriptors/AnnotationElementDescriptor.java index 1e98793..159293b 100644 --- a/src/uk/ac/vamsas/objects/core/descriptors/AnnotationElementDescriptor.java +++ b/src/uk/ac/vamsas/objects/core/descriptors/AnnotationElementDescriptor.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core.descriptors; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import uk.ac.vamsas.objects.core.AnnotationElement; @@ -18,391 +32,403 @@ import uk.ac.vamsas.objects.core.AnnotationElement; * * @version $Revision$ $Date$ */ -public class AnnotationElementDescriptor extends org.exolab.castor.xml.util.XMLClassDescriptorImpl { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _elementDefinition. - */ - private boolean _elementDefinition; - - /** - * Field _nsPrefix. - */ - private java.lang.String _nsPrefix; - - /** - * Field _nsURI. - */ - private java.lang.String _nsURI; - - /** - * Field _xmlName. - */ - private java.lang.String _xmlName; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public AnnotationElementDescriptor() { - super(); - _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; - _xmlName = "annotationElement"; - _elementDefinition = true; - - //-- set grouping compositor - setCompositorAsSequence(); - org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; - org.exolab.castor.mapping.FieldHandler handler = null; - org.exolab.castor.xml.FieldValidator fieldValidator = null; - //-- initialize attribute descriptors - - //-- _position - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Long.TYPE, "_position", "position", org.exolab.castor.xml.NodeType.Attribute); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - AnnotationElement target = (AnnotationElement) object; - if (!target.hasPosition()) { return null; } - return new java.lang.Long(target.getPosition()); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - AnnotationElement target = (AnnotationElement) object; - // ignore null values for non optional primitives - if (value == null) { return; } - - target.setPosition( ((java.lang.Long) value).longValue()); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return null; - } - }; - desc.setHandler(handler); - desc.setRequired(true); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _position - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); - { //-- local scope - org.exolab.castor.xml.validators.LongValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.LongValidator(); - fieldValidator.setValidator(typeValidator); - } - desc.setValidator(fieldValidator); - //-- _after - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Boolean.TYPE, "_after", "after", org.exolab.castor.xml.NodeType.Attribute); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - AnnotationElement target = (AnnotationElement) object; - if (!target.hasAfter()) { return null; } - return (target.getAfter() ? java.lang.Boolean.TRUE : java.lang.Boolean.FALSE); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - AnnotationElement target = (AnnotationElement) object; - // if null, use delete method for optional primitives - if (value == null) { - target.deleteAfter(); - return; - } - target.setAfter( ((java.lang.Boolean) value).booleanValue()); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return null; - } - }; - desc.setHandler(handler); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _after - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope - org.exolab.castor.xml.validators.BooleanValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.BooleanValidator(); - fieldValidator.setValidator(typeValidator); +public class AnnotationElementDescriptor extends + org.exolab.castor.xml.util.XMLClassDescriptorImpl { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _elementDefinition. + */ + private boolean _elementDefinition; + + /** + * Field _nsPrefix. + */ + private java.lang.String _nsPrefix; + + /** + * Field _nsURI. + */ + private java.lang.String _nsURI; + + /** + * Field _xmlName. + */ + private java.lang.String _xmlName; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public AnnotationElementDescriptor() { + super(); + _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; + _xmlName = "annotationElement"; + _elementDefinition = true; + + // -- set grouping compositor + setCompositorAsSequence(); + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + // -- initialize attribute descriptors + + // -- _position + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.Long.TYPE, "_position", "position", + org.exolab.castor.xml.NodeType.Attribute); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + AnnotationElement target = (AnnotationElement) object; + if (!target.hasPosition()) { + return null; } - desc.setValidator(fieldValidator); - //-- _id - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_id", "id", org.exolab.castor.xml.NodeType.Attribute); - super.setIdentity(desc); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - AnnotationElement target = (AnnotationElement) object; - return target.getId(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - AnnotationElement target = (AnnotationElement) object; - target.setId( (java.lang.String) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new java.lang.String(); - } - }; - desc.setHandler(handler); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _id - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope - org.exolab.castor.xml.validators.IdValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.IdValidator(); - fieldValidator.setValidator(typeValidator); + return new java.lang.Long(target.getPosition()); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + AnnotationElement target = (AnnotationElement) object; + // ignore null values for non optional primitives + if (value == null) { + return; + } + + target.setPosition(((java.lang.Long) value).longValue()); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- initialize element descriptors - - //-- _description - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_description", "description", org.exolab.castor.xml.NodeType.Element); - desc.setImmutable(true); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - AnnotationElement target = (AnnotationElement) object; - return target.getDescription(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - AnnotationElement target = (AnnotationElement) object; - target.setDescription( (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); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _description - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope - org.exolab.castor.xml.validators.StringValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.StringValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setWhiteSpace("preserve"); + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return null; + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _position + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { // -- local scope + org.exolab.castor.xml.validators.LongValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.LongValidator(); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + // -- _after + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.Boolean.TYPE, "_after", "after", + org.exolab.castor.xml.NodeType.Attribute); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + AnnotationElement target = (AnnotationElement) object; + if (!target.hasAfter()) { + return null; } - desc.setValidator(fieldValidator); - //-- _glyphList - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(uk.ac.vamsas.objects.core.Glyph.class, "_glyphList", "glyph", org.exolab.castor.xml.NodeType.Element); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - AnnotationElement target = (AnnotationElement) object; - return target.getGlyph(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - AnnotationElement target = (AnnotationElement) object; - target.addGlyph( (uk.ac.vamsas.objects.core.Glyph) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public void resetValue(Object object) throws IllegalStateException, IllegalArgumentException { - try { - AnnotationElement target = (AnnotationElement) object; - target.removeAllGlyph(); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new uk.ac.vamsas.objects.core.Glyph(); - } - }; - desc.setHandler(handler); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setMultivalued(true); - addFieldDescriptor(desc); - - //-- validation code for: _glyphList - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(0); - { //-- local scope + return (target.getAfter() ? java.lang.Boolean.TRUE + : java.lang.Boolean.FALSE); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + AnnotationElement target = (AnnotationElement) object; + // if null, use delete method for optional primitives + if (value == null) { + target.deleteAfter(); + return; + } + target.setAfter(((java.lang.Boolean) value).booleanValue()); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- _valueList - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Float.TYPE, "_valueList", "value", org.exolab.castor.xml.NodeType.Element); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - AnnotationElement target = (AnnotationElement) object; - return target.getValue(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - AnnotationElement target = (AnnotationElement) object; - // ignore null values for non optional primitives - if (value == null) { return; } - - target.addValue( ((java.lang.Float) value).floatValue()); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public void resetValue(Object object) throws IllegalStateException, IllegalArgumentException { - try { - AnnotationElement target = (AnnotationElement) object; - target.removeAllValue(); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return null; - } - }; - desc.setHandler(handler); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setMultivalued(true); - addFieldDescriptor(desc); - - //-- validation code for: _valueList - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(0); - { //-- local scope - org.exolab.castor.xml.validators.FloatValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.FloatValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setMinInclusive((float) -3.4028235E38); - typeValidator.setMaxInclusive((float) 3.4028235E38); + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return null; + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _after + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { // -- local scope + org.exolab.castor.xml.validators.BooleanValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.BooleanValidator(); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + // -- _id + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_id", "id", + org.exolab.castor.xml.NodeType.Attribute); + super.setIdentity(desc); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + AnnotationElement target = (AnnotationElement) object; + return target.getId(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + AnnotationElement target = (AnnotationElement) object; + target.setId((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return new java.lang.String(); + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _id + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { // -- local scope + org.exolab.castor.xml.validators.IdValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.IdValidator(); + fieldValidator.setValidator(typeValidator); } + desc.setValidator(fieldValidator); + // -- initialize element descriptors + // -- _description + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_description", "description", + org.exolab.castor.xml.NodeType.Element); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + AnnotationElement target = (AnnotationElement) object; + return target.getDescription(); + } - //-----------/ - //- Methods -/ - //-----------/ + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + AnnotationElement target = (AnnotationElement) object; + target.setDescription((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getAccessMode. - * - * @return the access mode specified for this class. - */ - public org.exolab.castor.mapping.AccessMode getAccessMode( - ) { + public java.lang.Object newInstance(java.lang.Object parent) { return null; - } + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setMultivalued(false); + addFieldDescriptor(desc); - /** - * Method getIdentity. - * - * @return the identity field, null if this class has no - * identity. - */ - public org.exolab.castor.mapping.FieldDescriptor getIdentity( - ) { - return super.getIdentity(); + // -- validation code for: _description + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { // -- local scope + org.exolab.castor.xml.validators.StringValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.StringValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setWhiteSpace("preserve"); } + desc.setValidator(fieldValidator); + // -- _glyphList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + uk.ac.vamsas.objects.core.Glyph.class, "_glyphList", "glyph", + org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + AnnotationElement target = (AnnotationElement) object; + return target.getGlyph(); + } - /** - * Method getJavaClass. - * - * @return the Java class represented by this descriptor. - */ - public java.lang.Class getJavaClass( - ) { - return uk.ac.vamsas.objects.core.AnnotationElement.class; - } + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + AnnotationElement target = (AnnotationElement) object; + target.addGlyph((uk.ac.vamsas.objects.core.Glyph) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getNameSpacePrefix. - * - * @return the namespace prefix to use when marshaling as XML. - */ - public java.lang.String getNameSpacePrefix( - ) { - return _nsPrefix; - } + public void resetValue(Object object) throws IllegalStateException, + IllegalArgumentException { + try { + AnnotationElement target = (AnnotationElement) object; + target.removeAllGlyph(); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getNameSpaceURI. - * - * @return the namespace URI used when marshaling and - * unmarshaling as XML. - */ - public java.lang.String getNameSpaceURI( - ) { - return _nsURI; - } + public java.lang.Object newInstance(java.lang.Object parent) { + return new uk.ac.vamsas.objects.core.Glyph(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setMultivalued(true); + addFieldDescriptor(desc); - /** - * Method getValidator. - * - * @return a specific validator for the class described by this - * ClassDescriptor. - */ - public org.exolab.castor.xml.TypeValidator getValidator( - ) { - return this; + // -- validation code for: _glyphList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { // -- local scope } + desc.setValidator(fieldValidator); + // -- _valueList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.Float.TYPE, "_valueList", "value", + org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + AnnotationElement target = (AnnotationElement) object; + return target.getValue(); + } - /** - * Method getXMLName. - * - * @return the XML Name for the Class being described. - */ - public java.lang.String getXMLName( - ) { - return _xmlName; - } + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + AnnotationElement target = (AnnotationElement) object; + // ignore null values for non optional primitives + if (value == null) { + return; + } + + target.addValue(((java.lang.Float) value).floatValue()); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method isElementDefinition. - * - * @return true if XML schema definition of this Class is that - * of a global - * element or element with anonymous type definition. - */ - public boolean isElementDefinition( - ) { - return _elementDefinition; + public void resetValue(Object object) throws IllegalStateException, + IllegalArgumentException { + try { + AnnotationElement target = (AnnotationElement) object; + target.removeAllValue(); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return null; + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + // -- validation code for: _valueList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { // -- local scope + org.exolab.castor.xml.validators.FloatValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.FloatValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setMinInclusive((float) -3.4028235E38); + typeValidator.setMaxInclusive((float) 3.4028235E38); } + desc.setValidator(fieldValidator); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * Method getAccessMode. + * + * @return the access mode specified for this class. + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() { + return null; + } + + /** + * Method getIdentity. + * + * @return the identity field, null if this class has no identity. + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() { + return super.getIdentity(); + } + + /** + * Method getJavaClass. + * + * @return the Java class represented by this descriptor. + */ + public java.lang.Class getJavaClass() { + return uk.ac.vamsas.objects.core.AnnotationElement.class; + } + + /** + * Method getNameSpacePrefix. + * + * @return the namespace prefix to use when marshaling as XML. + */ + public java.lang.String getNameSpacePrefix() { + return _nsPrefix; + } + + /** + * Method getNameSpaceURI. + * + * @return the namespace URI used when marshaling and unmarshaling as XML. + */ + public java.lang.String getNameSpaceURI() { + return _nsURI; + } + + /** + * Method getValidator. + * + * @return a specific validator for the class described by this + * ClassDescriptor. + */ + public org.exolab.castor.xml.TypeValidator getValidator() { + return this; + } + + /** + * Method getXMLName. + * + * @return the XML Name for the Class being described. + */ + public java.lang.String getXMLName() { + return _xmlName; + } + + /** + * Method isElementDefinition. + * + * @return true if XML schema definition of this Class is that of a global + * element or element with anonymous type definition. + */ + public boolean isElementDefinition() { + return _elementDefinition; + } } diff --git a/src/uk/ac/vamsas/objects/core/descriptors/AppDataDescriptor.java b/src/uk/ac/vamsas/objects/core/descriptors/AppDataDescriptor.java index dab611a..21ce243 100644 --- a/src/uk/ac/vamsas/objects/core/descriptors/AppDataDescriptor.java +++ b/src/uk/ac/vamsas/objects/core/descriptors/AppDataDescriptor.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core.descriptors; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import uk.ac.vamsas.objects.core.AppData; @@ -18,218 +32,208 @@ import uk.ac.vamsas.objects.core.AppData; * * @version $Revision$ $Date$ */ -public class AppDataDescriptor extends org.exolab.castor.xml.util.XMLClassDescriptorImpl { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _elementDefinition. - */ - private boolean _elementDefinition; - - /** - * Field _nsPrefix. - */ - private java.lang.String _nsPrefix; - - /** - * Field _nsURI. - */ - private java.lang.String _nsURI; - - /** - * Field _xmlName. - */ - private java.lang.String _xmlName; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public AppDataDescriptor() { - super(); - _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; - _xmlName = "appData"; - _elementDefinition = false; - - //-- set grouping compositor - setCompositorAsChoice(); - org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; - org.exolab.castor.mapping.FieldHandler handler = null; - org.exolab.castor.xml.FieldValidator fieldValidator = null; - //-- initialize attribute descriptors - - //-- initialize element descriptors - - //-- _data - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(byte[].class, "_data", "data", org.exolab.castor.xml.NodeType.Element); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - AppData target = (AppData) object; - return target.getData(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - AppData target = (AppData) object; - target.setData( (byte[]) 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); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setRequired(true); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _data - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); - { //-- local scope - } - desc.setValidator(fieldValidator); - //-- _dataReference - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_dataReference", "dataReference", org.exolab.castor.xml.NodeType.Element); - desc.setImmutable(true); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - AppData target = (AppData) object; - return target.getDataReference(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - AppData target = (AppData) object; - target.setDataReference( (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); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setRequired(true); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _dataReference - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); - { //-- local scope - org.exolab.castor.xml.validators.StringValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.StringValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setWhiteSpace("preserve"); +public class AppDataDescriptor extends + org.exolab.castor.xml.util.XMLClassDescriptorImpl { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _elementDefinition. + */ + private boolean _elementDefinition; + + /** + * Field _nsPrefix. + */ + private java.lang.String _nsPrefix; + + /** + * Field _nsURI. + */ + private java.lang.String _nsURI; + + /** + * Field _xmlName. + */ + private java.lang.String _xmlName; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public AppDataDescriptor() { + super(); + _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; + _xmlName = "appData"; + _elementDefinition = false; + + // -- set grouping compositor + setCompositorAsChoice(); + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + // -- initialize attribute descriptors + + // -- initialize element descriptors + + // -- _data + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(byte[].class, + "_data", "data", org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + AppData target = (AppData) object; + return target.getData(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + AppData target = (AppData) object; + target.setData((byte[]) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - } - - - //-----------/ - //- Methods -/ - //-----------/ + } - /** - * Method getAccessMode. - * - * @return the access mode specified for this class. - */ - public org.exolab.castor.mapping.AccessMode getAccessMode( - ) { + public java.lang.Object newInstance(java.lang.Object parent) { return null; + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _data + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { // -- local scope } + desc.setValidator(fieldValidator); + // -- _dataReference + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_dataReference", "dataReference", + org.exolab.castor.xml.NodeType.Element); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + AppData target = (AppData) object; + return target.getDataReference(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + AppData target = (AppData) object; + target.setDataReference((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getIdentity. - * - * @return the identity field, null if this class has no - * identity. - */ - public org.exolab.castor.mapping.FieldDescriptor getIdentity( - ) { - return super.getIdentity(); - } - - /** - * Method getJavaClass. - * - * @return the Java class represented by this descriptor. - */ - public java.lang.Class getJavaClass( - ) { - return uk.ac.vamsas.objects.core.AppData.class; - } - - /** - * Method getNameSpacePrefix. - * - * @return the namespace prefix to use when marshaling as XML. - */ - public java.lang.String getNameSpacePrefix( - ) { - return _nsPrefix; - } - - /** - * Method getNameSpaceURI. - * - * @return the namespace URI used when marshaling and - * unmarshaling as XML. - */ - public java.lang.String getNameSpaceURI( - ) { - return _nsURI; - } - - /** - * Method getValidator. - * - * @return a specific validator for the class described by this - * ClassDescriptor. - */ - public org.exolab.castor.xml.TypeValidator getValidator( - ) { - return this; - } - - /** - * Method getXMLName. - * - * @return the XML Name for the Class being described. - */ - public java.lang.String getXMLName( - ) { - return _xmlName; - } - - /** - * Method isElementDefinition. - * - * @return true if XML schema definition of this Class is that - * of a global - * element or element with anonymous type definition. - */ - public boolean isElementDefinition( - ) { - return _elementDefinition; + public java.lang.Object newInstance(java.lang.Object parent) { + return null; + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _dataReference + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { // -- local scope + org.exolab.castor.xml.validators.StringValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.StringValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setWhiteSpace("preserve"); } + desc.setValidator(fieldValidator); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * Method getAccessMode. + * + * @return the access mode specified for this class. + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() { + return null; + } + + /** + * Method getIdentity. + * + * @return the identity field, null if this class has no identity. + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() { + return super.getIdentity(); + } + + /** + * Method getJavaClass. + * + * @return the Java class represented by this descriptor. + */ + public java.lang.Class getJavaClass() { + return uk.ac.vamsas.objects.core.AppData.class; + } + + /** + * Method getNameSpacePrefix. + * + * @return the namespace prefix to use when marshaling as XML. + */ + public java.lang.String getNameSpacePrefix() { + return _nsPrefix; + } + + /** + * Method getNameSpaceURI. + * + * @return the namespace URI used when marshaling and unmarshaling as XML. + */ + public java.lang.String getNameSpaceURI() { + return _nsURI; + } + + /** + * Method getValidator. + * + * @return a specific validator for the class described by this + * ClassDescriptor. + */ + public org.exolab.castor.xml.TypeValidator getValidator() { + return this; + } + + /** + * Method getXMLName. + * + * @return the XML Name for the Class being described. + */ + public java.lang.String getXMLName() { + return _xmlName; + } + + /** + * Method isElementDefinition. + * + * @return true if XML schema definition of this Class is that of a global + * element or element with anonymous type definition. + */ + public boolean isElementDefinition() { + return _elementDefinition; + } } diff --git a/src/uk/ac/vamsas/objects/core/descriptors/ApplicationDataDescriptor.java b/src/uk/ac/vamsas/objects/core/descriptors/ApplicationDataDescriptor.java index 79c6364..80688cd 100644 --- a/src/uk/ac/vamsas/objects/core/descriptors/ApplicationDataDescriptor.java +++ b/src/uk/ac/vamsas/objects/core/descriptors/ApplicationDataDescriptor.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core.descriptors; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import uk.ac.vamsas.objects.core.ApplicationData; @@ -18,339 +32,340 @@ import uk.ac.vamsas.objects.core.ApplicationData; * * @version $Revision$ $Date$ */ -public class ApplicationDataDescriptor extends uk.ac.vamsas.objects.core.descriptors.AppDataDescriptor { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _elementDefinition. - */ - private boolean _elementDefinition; - - /** - * Field _nsPrefix. - */ - private java.lang.String _nsPrefix; - - /** - * Field _nsURI. - */ - private java.lang.String _nsURI; - - /** - * Field _xmlName. - */ - private java.lang.String _xmlName; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public ApplicationDataDescriptor() { - super(); - setExtendsWithoutFlatten(new uk.ac.vamsas.objects.core.descriptors.AppDataDescriptor()); - _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; - _xmlName = "ApplicationData"; - _elementDefinition = true; - - //-- set grouping compositor - setCompositorAsSequence(); - org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; - org.exolab.castor.mapping.FieldHandler handler = null; - org.exolab.castor.xml.FieldValidator fieldValidator = null; - //-- initialize attribute descriptors - - //-- _version - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_version", "version", 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 - { - ApplicationData target = (ApplicationData) object; - return target.getVersion(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - ApplicationData target = (ApplicationData) object; - target.setVersion( (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); - desc.setRequired(true); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _version - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); - { //-- local scope - org.exolab.castor.xml.validators.StringValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.StringValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setWhiteSpace("preserve"); - } - desc.setValidator(fieldValidator); - //-- _name - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_name", "name", 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 - { - ApplicationData target = (ApplicationData) object; - return target.getName(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - ApplicationData target = (ApplicationData) object; - target.setName( (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); - desc.setRequired(true); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _name - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); - { //-- local scope - org.exolab.castor.xml.validators.StringValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.StringValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setWhiteSpace("preserve"); +public class ApplicationDataDescriptor extends + uk.ac.vamsas.objects.core.descriptors.AppDataDescriptor { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _elementDefinition. + */ + private boolean _elementDefinition; + + /** + * Field _nsPrefix. + */ + private java.lang.String _nsPrefix; + + /** + * Field _nsURI. + */ + private java.lang.String _nsURI; + + /** + * Field _xmlName. + */ + private java.lang.String _xmlName; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public ApplicationDataDescriptor() { + super(); + setExtendsWithoutFlatten(new uk.ac.vamsas.objects.core.descriptors.AppDataDescriptor()); + _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; + _xmlName = "ApplicationData"; + _elementDefinition = true; + + // -- set grouping compositor + setCompositorAsSequence(); + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + // -- initialize attribute descriptors + + // -- _version + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_version", "version", + 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 { + ApplicationData target = (ApplicationData) object; + return target.getVersion(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + ApplicationData target = (ApplicationData) object; + target.setVersion((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- initialize element descriptors - - //-- _userList - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(uk.ac.vamsas.objects.core.User.class, "_userList", "User", org.exolab.castor.xml.NodeType.Element); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - ApplicationData target = (ApplicationData) object; - return target.getUser(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - ApplicationData target = (ApplicationData) object; - target.addUser( (uk.ac.vamsas.objects.core.User) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public void resetValue(Object object) throws IllegalStateException, IllegalArgumentException { - try { - ApplicationData target = (ApplicationData) object; - target.removeAllUser(); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new uk.ac.vamsas.objects.core.User(); - } - }; - desc.setHandler(handler); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setMultivalued(true); - addFieldDescriptor(desc); - - //-- validation code for: _userList - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(0); - { //-- local scope + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return null; + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _version + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { // -- local scope + org.exolab.castor.xml.validators.StringValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.StringValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setWhiteSpace("preserve"); + } + desc.setValidator(fieldValidator); + // -- _name + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_name", "name", + 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 { + ApplicationData target = (ApplicationData) object; + return target.getName(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + ApplicationData target = (ApplicationData) object; + target.setName((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- _common - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(uk.ac.vamsas.objects.core.Common.class, "_common", "Common", org.exolab.castor.xml.NodeType.Element); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - ApplicationData target = (ApplicationData) object; - return target.getCommon(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - ApplicationData target = (ApplicationData) object; - target.setCommon( (uk.ac.vamsas.objects.core.Common) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new uk.ac.vamsas.objects.core.Common(); - } - }; - desc.setHandler(handler); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _common - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return null; + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _name + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { // -- local scope + org.exolab.castor.xml.validators.StringValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.StringValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setWhiteSpace("preserve"); + } + desc.setValidator(fieldValidator); + // -- initialize element descriptors + + // -- _userList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + uk.ac.vamsas.objects.core.User.class, "_userList", "User", + org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + ApplicationData target = (ApplicationData) object; + return target.getUser(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + ApplicationData target = (ApplicationData) object; + target.addUser((uk.ac.vamsas.objects.core.User) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- _instanceList - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(uk.ac.vamsas.objects.core.Instance.class, "_instanceList", "Instance", org.exolab.castor.xml.NodeType.Element); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - ApplicationData target = (ApplicationData) object; - return target.getInstance(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - ApplicationData target = (ApplicationData) object; - target.addInstance( (uk.ac.vamsas.objects.core.Instance) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public void resetValue(Object object) throws IllegalStateException, IllegalArgumentException { - try { - ApplicationData target = (ApplicationData) object; - target.removeAllInstance(); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new uk.ac.vamsas.objects.core.Instance(); - } - }; - desc.setHandler(handler); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setMultivalued(true); - addFieldDescriptor(desc); - - //-- validation code for: _instanceList - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(0); - { //-- local scope + } + + public void resetValue(Object object) throws IllegalStateException, + IllegalArgumentException { + try { + ApplicationData target = (ApplicationData) object; + target.removeAllUser(); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return new uk.ac.vamsas.objects.core.User(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + // -- validation code for: _userList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { // -- local scope } + desc.setValidator(fieldValidator); + // -- _common + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + uk.ac.vamsas.objects.core.Common.class, "_common", "Common", + org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + ApplicationData target = (ApplicationData) object; + return target.getCommon(); + } + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + ApplicationData target = (ApplicationData) object; + target.setCommon((uk.ac.vamsas.objects.core.Common) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - //-----------/ - //- Methods -/ - //-----------/ + public java.lang.Object newInstance(java.lang.Object parent) { + return new uk.ac.vamsas.objects.core.Common(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setMultivalued(false); + addFieldDescriptor(desc); - /** - * Method getAccessMode. - * - * @return the access mode specified for this class. - */ - public org.exolab.castor.mapping.AccessMode getAccessMode( - ) { - return null; + // -- validation code for: _common + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { // -- local scope } + desc.setValidator(fieldValidator); + // -- _instanceList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + uk.ac.vamsas.objects.core.Instance.class, "_instanceList", "Instance", + org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + ApplicationData target = (ApplicationData) object; + return target.getInstance(); + } - /** - * Method getIdentity. - * - * @return the identity field, null if this class has no - * identity. - */ - public org.exolab.castor.mapping.FieldDescriptor getIdentity( - ) { - return super.getIdentity(); - } + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + ApplicationData target = (ApplicationData) object; + target.addInstance((uk.ac.vamsas.objects.core.Instance) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getJavaClass. - * - * @return the Java class represented by this descriptor. - */ - public java.lang.Class getJavaClass( - ) { - return uk.ac.vamsas.objects.core.ApplicationData.class; - } + public void resetValue(Object object) throws IllegalStateException, + IllegalArgumentException { + try { + ApplicationData target = (ApplicationData) object; + target.removeAllInstance(); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getNameSpacePrefix. - * - * @return the namespace prefix to use when marshaling as XML. - */ - public java.lang.String getNameSpacePrefix( - ) { - return _nsPrefix; - } + public java.lang.Object newInstance(java.lang.Object parent) { + return new uk.ac.vamsas.objects.core.Instance(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setMultivalued(true); + addFieldDescriptor(desc); - /** - * Method getNameSpaceURI. - * - * @return the namespace URI used when marshaling and - * unmarshaling as XML. - */ - public java.lang.String getNameSpaceURI( - ) { - return _nsURI; + // -- validation code for: _instanceList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { // -- local scope } + desc.setValidator(fieldValidator); + } - /** - * Method getValidator. - * - * @return a specific validator for the class described by this - * ClassDescriptor. - */ - public org.exolab.castor.xml.TypeValidator getValidator( - ) { - return this; - } + // -----------/ + // - Methods -/ + // -----------/ - /** - * Method getXMLName. - * - * @return the XML Name for the Class being described. - */ - public java.lang.String getXMLName( - ) { - return _xmlName; - } + /** + * Method getAccessMode. + * + * @return the access mode specified for this class. + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() { + return null; + } - /** - * Method isElementDefinition. - * - * @return true if XML schema definition of this Class is that - * of a global - * element or element with anonymous type definition. - */ - public boolean isElementDefinition( - ) { - return _elementDefinition; - } + /** + * Method getIdentity. + * + * @return the identity field, null if this class has no identity. + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() { + return super.getIdentity(); + } + + /** + * Method getJavaClass. + * + * @return the Java class represented by this descriptor. + */ + public java.lang.Class getJavaClass() { + return uk.ac.vamsas.objects.core.ApplicationData.class; + } + + /** + * Method getNameSpacePrefix. + * + * @return the namespace prefix to use when marshaling as XML. + */ + public java.lang.String getNameSpacePrefix() { + return _nsPrefix; + } + + /** + * Method getNameSpaceURI. + * + * @return the namespace URI used when marshaling and unmarshaling as XML. + */ + public java.lang.String getNameSpaceURI() { + return _nsURI; + } + + /** + * Method getValidator. + * + * @return a specific validator for the class described by this + * ClassDescriptor. + */ + public org.exolab.castor.xml.TypeValidator getValidator() { + return this; + } + + /** + * Method getXMLName. + * + * @return the XML Name for the Class being described. + */ + public java.lang.String getXMLName() { + return _xmlName; + } + + /** + * Method isElementDefinition. + * + * @return true if XML schema definition of this Class is that of a global + * element or element with anonymous type definition. + */ + public boolean isElementDefinition() { + return _elementDefinition; + } } diff --git a/src/uk/ac/vamsas/objects/core/descriptors/AttachmentDescriptor.java b/src/uk/ac/vamsas/objects/core/descriptors/AttachmentDescriptor.java index d6b5823..be5adb4 100644 --- a/src/uk/ac/vamsas/objects/core/descriptors/AttachmentDescriptor.java +++ b/src/uk/ac/vamsas/objects/core/descriptors/AttachmentDescriptor.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core.descriptors; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import uk.ac.vamsas.objects.core.Attachment; @@ -18,295 +32,293 @@ import uk.ac.vamsas.objects.core.Attachment; * * @version $Revision$ $Date$ */ -public class AttachmentDescriptor extends uk.ac.vamsas.objects.core.descriptors.AppDataDescriptor { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _elementDefinition. - */ - private boolean _elementDefinition; - - /** - * Field _nsPrefix. - */ - private java.lang.String _nsPrefix; - - /** - * Field _nsURI. - */ - private java.lang.String _nsURI; - - /** - * Field _xmlName. - */ - private java.lang.String _xmlName; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public AttachmentDescriptor() { - super(); - setExtendsWithoutFlatten(new uk.ac.vamsas.objects.core.descriptors.AppDataDescriptor()); - _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; - _xmlName = "Attachment"; - _elementDefinition = true; - org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; - org.exolab.castor.mapping.FieldHandler handler = null; - org.exolab.castor.xml.FieldValidator fieldValidator = null; - //-- initialize attribute descriptors - - //-- _compressed - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Boolean.TYPE, "_compressed", "compressed", org.exolab.castor.xml.NodeType.Attribute); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - Attachment target = (Attachment) object; - if (!target.hasCompressed()) { return null; } - return (target.getCompressed() ? java.lang.Boolean.TRUE : java.lang.Boolean.FALSE); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Attachment target = (Attachment) object; - // if null, use delete method for optional primitives - if (value == null) { - target.deleteCompressed(); - return; - } - target.setCompressed( ((java.lang.Boolean) value).booleanValue()); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return null; - } - }; - desc.setHandler(handler); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _compressed - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope - org.exolab.castor.xml.validators.BooleanValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.BooleanValidator(); - fieldValidator.setValidator(typeValidator); - } - desc.setValidator(fieldValidator); - //-- _type - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_type", "type", 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 - { - Attachment target = (Attachment) object; - return target.getType(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Attachment target = (Attachment) object; - target.setType( (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); - desc.setRequired(true); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _type - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); - { //-- local scope - org.exolab.castor.xml.validators.StringValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.StringValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setWhiteSpace("preserve"); - } - desc.setValidator(fieldValidator); - //-- _objectref - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Object.class, "_objectref", "objectref", org.exolab.castor.xml.NodeType.Attribute); - desc.setReference(true); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - Attachment target = (Attachment) object; - return target.getObjectref(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Attachment target = (Attachment) object; - target.setObjectref( (java.lang.Object) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new java.lang.Object(); - } - }; - desc.setHandler(handler); - desc.setRequired(true); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _objectref - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); - { //-- local scope - org.exolab.castor.xml.validators.IdRefValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.IdRefValidator(); - fieldValidator.setValidator(typeValidator); +public class AttachmentDescriptor extends + uk.ac.vamsas.objects.core.descriptors.AppDataDescriptor { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _elementDefinition. + */ + private boolean _elementDefinition; + + /** + * Field _nsPrefix. + */ + private java.lang.String _nsPrefix; + + /** + * Field _nsURI. + */ + private java.lang.String _nsURI; + + /** + * Field _xmlName. + */ + private java.lang.String _xmlName; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public AttachmentDescriptor() { + super(); + setExtendsWithoutFlatten(new uk.ac.vamsas.objects.core.descriptors.AppDataDescriptor()); + _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; + _xmlName = "Attachment"; + _elementDefinition = true; + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + // -- initialize attribute descriptors + + // -- _compressed + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.Boolean.TYPE, "_compressed", "compressed", + org.exolab.castor.xml.NodeType.Attribute); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + Attachment target = (Attachment) object; + if (!target.hasCompressed()) { + return null; } - desc.setValidator(fieldValidator); - //-- _id - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_id", "id", org.exolab.castor.xml.NodeType.Attribute); - super.setIdentity(desc); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - Attachment target = (Attachment) object; - return target.getId(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Attachment target = (Attachment) object; - target.setId( (java.lang.String) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new java.lang.String(); - } - }; - desc.setHandler(handler); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _id - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope - org.exolab.castor.xml.validators.IdValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.IdValidator(); - fieldValidator.setValidator(typeValidator); + return (target.getCompressed() ? java.lang.Boolean.TRUE + : java.lang.Boolean.FALSE); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Attachment target = (Attachment) object; + // if null, use delete method for optional primitives + if (value == null) { + target.deleteCompressed(); + return; + } + target.setCompressed(((java.lang.Boolean) value).booleanValue()); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- initialize element descriptors - - } + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return null; + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + // -- validation code for: _compressed + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { // -- local scope + org.exolab.castor.xml.validators.BooleanValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.BooleanValidator(); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + // -- _type + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_type", "type", + 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 { + Attachment target = (Attachment) object; + return target.getType(); + } - //-----------/ - //- Methods -/ - //-----------/ + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Attachment target = (Attachment) object; + target.setType((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getAccessMode. - * - * @return the access mode specified for this class. - */ - public org.exolab.castor.mapping.AccessMode getAccessMode( - ) { + public java.lang.Object newInstance(java.lang.Object parent) { return null; - } + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); - /** - * Method getIdentity. - * - * @return the identity field, null if this class has no - * identity. - */ - public org.exolab.castor.mapping.FieldDescriptor getIdentity( - ) { - return super.getIdentity(); + // -- validation code for: _type + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { // -- local scope + org.exolab.castor.xml.validators.StringValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.StringValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setWhiteSpace("preserve"); } + desc.setValidator(fieldValidator); + // -- _objectref + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.Object.class, "_objectref", "objectref", + org.exolab.castor.xml.NodeType.Attribute); + desc.setReference(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + Attachment target = (Attachment) object; + return target.getObjectref(); + } - /** - * Method getJavaClass. - * - * @return the Java class represented by this descriptor. - */ - public java.lang.Class getJavaClass( - ) { - return uk.ac.vamsas.objects.core.Attachment.class; - } + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Attachment target = (Attachment) object; + target.setObjectref((java.lang.Object) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getNameSpacePrefix. - * - * @return the namespace prefix to use when marshaling as XML. - */ - public java.lang.String getNameSpacePrefix( - ) { - return _nsPrefix; - } + public java.lang.Object newInstance(java.lang.Object parent) { + return new java.lang.Object(); + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); - /** - * Method getNameSpaceURI. - * - * @return the namespace URI used when marshaling and - * unmarshaling as XML. - */ - public java.lang.String getNameSpaceURI( - ) { - return _nsURI; + // -- validation code for: _objectref + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { // -- local scope + org.exolab.castor.xml.validators.IdRefValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.IdRefValidator(); + fieldValidator.setValidator(typeValidator); } + desc.setValidator(fieldValidator); + // -- _id + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_id", "id", + org.exolab.castor.xml.NodeType.Attribute); + super.setIdentity(desc); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + Attachment target = (Attachment) object; + return target.getId(); + } - /** - * Method getValidator. - * - * @return a specific validator for the class described by this - * ClassDescriptor. - */ - public org.exolab.castor.xml.TypeValidator getValidator( - ) { - return this; - } + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Attachment target = (Attachment) object; + target.setId((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getXMLName. - * - * @return the XML Name for the Class being described. - */ - public java.lang.String getXMLName( - ) { - return _xmlName; - } + public java.lang.Object newInstance(java.lang.Object parent) { + return new java.lang.String(); + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); - /** - * Method isElementDefinition. - * - * @return true if XML schema definition of this Class is that - * of a global - * element or element with anonymous type definition. - */ - public boolean isElementDefinition( - ) { - return _elementDefinition; + // -- validation code for: _id + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { // -- local scope + org.exolab.castor.xml.validators.IdValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.IdValidator(); + fieldValidator.setValidator(typeValidator); } + desc.setValidator(fieldValidator); + // -- initialize element descriptors + + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * Method getAccessMode. + * + * @return the access mode specified for this class. + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() { + return null; + } + + /** + * Method getIdentity. + * + * @return the identity field, null if this class has no identity. + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() { + return super.getIdentity(); + } + + /** + * Method getJavaClass. + * + * @return the Java class represented by this descriptor. + */ + public java.lang.Class getJavaClass() { + return uk.ac.vamsas.objects.core.Attachment.class; + } + + /** + * Method getNameSpacePrefix. + * + * @return the namespace prefix to use when marshaling as XML. + */ + public java.lang.String getNameSpacePrefix() { + return _nsPrefix; + } + + /** + * Method getNameSpaceURI. + * + * @return the namespace URI used when marshaling and unmarshaling as XML. + */ + public java.lang.String getNameSpaceURI() { + return _nsURI; + } + + /** + * Method getValidator. + * + * @return a specific validator for the class described by this + * ClassDescriptor. + */ + public org.exolab.castor.xml.TypeValidator getValidator() { + return this; + } + + /** + * Method getXMLName. + * + * @return the XML Name for the Class being described. + */ + public java.lang.String getXMLName() { + return _xmlName; + } + + /** + * Method isElementDefinition. + * + * @return true if XML schema definition of this Class is that of a global + * element or element with anonymous type definition. + */ + public boolean isElementDefinition() { + return _elementDefinition; + } } diff --git a/src/uk/ac/vamsas/objects/core/descriptors/CommonDescriptor.java b/src/uk/ac/vamsas/objects/core/descriptors/CommonDescriptor.java index d4ec584..80c4608 100644 --- a/src/uk/ac/vamsas/objects/core/descriptors/CommonDescriptor.java +++ b/src/uk/ac/vamsas/objects/core/descriptors/CommonDescriptor.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core.descriptors; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import uk.ac.vamsas.objects.core.Common; @@ -18,134 +32,121 @@ import uk.ac.vamsas.objects.core.Common; * * @version $Revision$ $Date$ */ -public class CommonDescriptor extends uk.ac.vamsas.objects.core.descriptors.AppDataDescriptor { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _elementDefinition. - */ - private boolean _elementDefinition; - - /** - * Field _nsPrefix. - */ - private java.lang.String _nsPrefix; - - /** - * Field _nsURI. - */ - private java.lang.String _nsURI; - - /** - * Field _xmlName. - */ - private java.lang.String _xmlName; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public CommonDescriptor() { - super(); - setExtendsWithoutFlatten(new uk.ac.vamsas.objects.core.descriptors.AppDataDescriptor()); - _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; - _xmlName = "Common"; - _elementDefinition = true; - } - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Method getAccessMode. - * - * @return the access mode specified for this class. - */ - public org.exolab.castor.mapping.AccessMode getAccessMode( - ) { - return null; - } - - /** - * Method getIdentity. - * - * @return the identity field, null if this class has no - * identity. - */ - public org.exolab.castor.mapping.FieldDescriptor getIdentity( - ) { - return super.getIdentity(); - } - - /** - * Method getJavaClass. - * - * @return the Java class represented by this descriptor. - */ - public java.lang.Class getJavaClass( - ) { - return uk.ac.vamsas.objects.core.Common.class; - } - - /** - * Method getNameSpacePrefix. - * - * @return the namespace prefix to use when marshaling as XML. - */ - public java.lang.String getNameSpacePrefix( - ) { - return _nsPrefix; - } - - /** - * Method getNameSpaceURI. - * - * @return the namespace URI used when marshaling and - * unmarshaling as XML. - */ - public java.lang.String getNameSpaceURI( - ) { - return _nsURI; - } - - /** - * Method getValidator. - * - * @return a specific validator for the class described by this - * ClassDescriptor. - */ - public org.exolab.castor.xml.TypeValidator getValidator( - ) { - return this; - } - - /** - * Method getXMLName. - * - * @return the XML Name for the Class being described. - */ - public java.lang.String getXMLName( - ) { - return _xmlName; - } - - /** - * Method isElementDefinition. - * - * @return true if XML schema definition of this Class is that - * of a global - * element or element with anonymous type definition. - */ - public boolean isElementDefinition( - ) { - return _elementDefinition; - } +public class CommonDescriptor extends + uk.ac.vamsas.objects.core.descriptors.AppDataDescriptor { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _elementDefinition. + */ + private boolean _elementDefinition; + + /** + * Field _nsPrefix. + */ + private java.lang.String _nsPrefix; + + /** + * Field _nsURI. + */ + private java.lang.String _nsURI; + + /** + * Field _xmlName. + */ + private java.lang.String _xmlName; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public CommonDescriptor() { + super(); + setExtendsWithoutFlatten(new uk.ac.vamsas.objects.core.descriptors.AppDataDescriptor()); + _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; + _xmlName = "Common"; + _elementDefinition = true; + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * Method getAccessMode. + * + * @return the access mode specified for this class. + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() { + return null; + } + + /** + * Method getIdentity. + * + * @return the identity field, null if this class has no identity. + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() { + return super.getIdentity(); + } + + /** + * Method getJavaClass. + * + * @return the Java class represented by this descriptor. + */ + public java.lang.Class getJavaClass() { + return uk.ac.vamsas.objects.core.Common.class; + } + + /** + * Method getNameSpacePrefix. + * + * @return the namespace prefix to use when marshaling as XML. + */ + public java.lang.String getNameSpacePrefix() { + return _nsPrefix; + } + + /** + * Method getNameSpaceURI. + * + * @return the namespace URI used when marshaling and unmarshaling as XML. + */ + public java.lang.String getNameSpaceURI() { + return _nsURI; + } + + /** + * Method getValidator. + * + * @return a specific validator for the class described by this + * ClassDescriptor. + */ + public org.exolab.castor.xml.TypeValidator getValidator() { + return this; + } + + /** + * Method getXMLName. + * + * @return the XML Name for the Class being described. + */ + public java.lang.String getXMLName() { + return _xmlName; + } + + /** + * Method isElementDefinition. + * + * @return true if XML schema definition of this Class is that of a global + * element or element with anonymous type definition. + */ + public boolean isElementDefinition() { + return _elementDefinition; + } } diff --git a/src/uk/ac/vamsas/objects/core/descriptors/DataSetAnnotationsDescriptor.java b/src/uk/ac/vamsas/objects/core/descriptors/DataSetAnnotationsDescriptor.java index ec113d2..a829b07 100644 --- a/src/uk/ac/vamsas/objects/core/descriptors/DataSetAnnotationsDescriptor.java +++ b/src/uk/ac/vamsas/objects/core/descriptors/DataSetAnnotationsDescriptor.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core.descriptors; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import uk.ac.vamsas.objects.core.DataSetAnnotations; @@ -18,226 +32,219 @@ import uk.ac.vamsas.objects.core.DataSetAnnotations; * * @version $Revision$ $Date$ */ -public class DataSetAnnotationsDescriptor extends uk.ac.vamsas.objects.core.descriptors.RangeAnnotationDescriptor { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _elementDefinition. - */ - private boolean _elementDefinition; - - /** - * Field _nsPrefix. - */ - private java.lang.String _nsPrefix; - - /** - * Field _nsURI. - */ - private java.lang.String _nsURI; - - /** - * Field _xmlName. - */ - private java.lang.String _xmlName; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public DataSetAnnotationsDescriptor() { - super(); - setExtendsWithoutFlatten(new uk.ac.vamsas.objects.core.descriptors.RangeAnnotationDescriptor()); - _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; - _xmlName = "DataSetAnnotations"; - _elementDefinition = true; - - //-- set grouping compositor - setCompositorAsSequence(); - org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; - org.exolab.castor.mapping.FieldHandler handler = null; - org.exolab.castor.xml.FieldValidator fieldValidator = null; - //-- initialize attribute descriptors - - //-- _seqRef - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Object.class, "_seqRef", "seqRef", org.exolab.castor.xml.NodeType.Attribute); - desc.setReference(true); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - DataSetAnnotations target = (DataSetAnnotations) object; - return target.getSeqRef(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - DataSetAnnotations target = (DataSetAnnotations) object; - target.addSeqRef( (java.lang.Object) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public void resetValue(Object object) throws IllegalStateException, IllegalArgumentException { - try { - DataSetAnnotations target = (DataSetAnnotations) object; - target.removeAllSeqRef(); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new java.lang.Object(); - } - }; - desc.setMultivalued(true); - desc.setHandler(handler); - desc.setRequired(true); - desc.setMultivalued(true); - addFieldDescriptor(desc); - - //-- validation code for: _seqRef - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(0); - { //-- local scope - org.exolab.castor.xml.validators.IdRefsValidator typeValidator = new org.exolab.castor.xml.validators.IdRefsValidator(); - fieldValidator.setValidator(typeValidator); - desc.setValidator(fieldValidator); +public class DataSetAnnotationsDescriptor extends + uk.ac.vamsas.objects.core.descriptors.RangeAnnotationDescriptor { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _elementDefinition. + */ + private boolean _elementDefinition; + + /** + * Field _nsPrefix. + */ + private java.lang.String _nsPrefix; + + /** + * Field _nsURI. + */ + private java.lang.String _nsURI; + + /** + * Field _xmlName. + */ + private java.lang.String _xmlName; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public DataSetAnnotationsDescriptor() { + super(); + setExtendsWithoutFlatten(new uk.ac.vamsas.objects.core.descriptors.RangeAnnotationDescriptor()); + _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; + _xmlName = "DataSetAnnotations"; + _elementDefinition = true; + + // -- set grouping compositor + setCompositorAsSequence(); + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + // -- initialize attribute descriptors + + // -- _seqRef + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.Object.class, "_seqRef", "seqRef", + org.exolab.castor.xml.NodeType.Attribute); + desc.setReference(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + DataSetAnnotations target = (DataSetAnnotations) object; + return target.getSeqRef(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + DataSetAnnotations target = (DataSetAnnotations) object; + target.addSeqRef((java.lang.Object) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- initialize element descriptors - - //-- _provenance - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(uk.ac.vamsas.objects.core.Provenance.class, "_provenance", "Provenance", org.exolab.castor.xml.NodeType.Element); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - DataSetAnnotations target = (DataSetAnnotations) object; - return target.getProvenance(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - DataSetAnnotations target = (DataSetAnnotations) object; - target.setProvenance( (uk.ac.vamsas.objects.core.Provenance) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new uk.ac.vamsas.objects.core.Provenance(); - } - }; - desc.setHandler(handler); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setRequired(true); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _provenance - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); - { //-- local scope + } + + public void resetValue(Object object) throws IllegalStateException, + IllegalArgumentException { + try { + DataSetAnnotations target = (DataSetAnnotations) object; + target.removeAllSeqRef(); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - } - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Method getAccessMode. - * - * @return the access mode specified for this class. - */ - public org.exolab.castor.mapping.AccessMode getAccessMode( - ) { - return null; + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return new java.lang.Object(); + } + }; + desc.setMultivalued(true); + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + // -- validation code for: _seqRef + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { // -- local scope + org.exolab.castor.xml.validators.IdRefsValidator typeValidator = new org.exolab.castor.xml.validators.IdRefsValidator(); + fieldValidator.setValidator(typeValidator); + desc.setValidator(fieldValidator); } - - /** - * Method getIdentity. - * - * @return the identity field, null if this class has no - * identity. - */ - public org.exolab.castor.mapping.FieldDescriptor getIdentity( - ) { - return super.getIdentity(); - } - - /** - * Method getJavaClass. - * - * @return the Java class represented by this descriptor. - */ - public java.lang.Class getJavaClass( - ) { - return uk.ac.vamsas.objects.core.DataSetAnnotations.class; - } - - /** - * Method getNameSpacePrefix. - * - * @return the namespace prefix to use when marshaling as XML. - */ - public java.lang.String getNameSpacePrefix( - ) { - return _nsPrefix; - } - - /** - * Method getNameSpaceURI. - * - * @return the namespace URI used when marshaling and - * unmarshaling as XML. - */ - public java.lang.String getNameSpaceURI( - ) { - return _nsURI; - } - - /** - * Method getValidator. - * - * @return a specific validator for the class described by this - * ClassDescriptor. - */ - public org.exolab.castor.xml.TypeValidator getValidator( - ) { - return this; - } - - /** - * Method getXMLName. - * - * @return the XML Name for the Class being described. - */ - public java.lang.String getXMLName( - ) { - return _xmlName; - } - - /** - * Method isElementDefinition. - * - * @return true if XML schema definition of this Class is that - * of a global - * element or element with anonymous type definition. - */ - public boolean isElementDefinition( - ) { - return _elementDefinition; + desc.setValidator(fieldValidator); + // -- initialize element descriptors + + // -- _provenance + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + uk.ac.vamsas.objects.core.Provenance.class, "_provenance", + "Provenance", org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + DataSetAnnotations target = (DataSetAnnotations) object; + return target.getProvenance(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + DataSetAnnotations target = (DataSetAnnotations) object; + target.setProvenance((uk.ac.vamsas.objects.core.Provenance) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return new uk.ac.vamsas.objects.core.Provenance(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _provenance + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { // -- local scope } + desc.setValidator(fieldValidator); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * Method getAccessMode. + * + * @return the access mode specified for this class. + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() { + return null; + } + + /** + * Method getIdentity. + * + * @return the identity field, null if this class has no identity. + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() { + return super.getIdentity(); + } + + /** + * Method getJavaClass. + * + * @return the Java class represented by this descriptor. + */ + public java.lang.Class getJavaClass() { + return uk.ac.vamsas.objects.core.DataSetAnnotations.class; + } + + /** + * Method getNameSpacePrefix. + * + * @return the namespace prefix to use when marshaling as XML. + */ + public java.lang.String getNameSpacePrefix() { + return _nsPrefix; + } + + /** + * Method getNameSpaceURI. + * + * @return the namespace URI used when marshaling and unmarshaling as XML. + */ + public java.lang.String getNameSpaceURI() { + return _nsURI; + } + + /** + * Method getValidator. + * + * @return a specific validator for the class described by this + * ClassDescriptor. + */ + public org.exolab.castor.xml.TypeValidator getValidator() { + return this; + } + + /** + * Method getXMLName. + * + * @return the XML Name for the Class being described. + */ + public java.lang.String getXMLName() { + return _xmlName; + } + + /** + * Method isElementDefinition. + * + * @return true if XML schema definition of this Class is that of a global + * element or element with anonymous type definition. + */ + public boolean isElementDefinition() { + return _elementDefinition; + } } diff --git a/src/uk/ac/vamsas/objects/core/descriptors/DataSetDescriptor.java b/src/uk/ac/vamsas/objects/core/descriptors/DataSetDescriptor.java index f677adf..16d6cc2 100644 --- a/src/uk/ac/vamsas/objects/core/descriptors/DataSetDescriptor.java +++ b/src/uk/ac/vamsas/objects/core/descriptors/DataSetDescriptor.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core.descriptors; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import uk.ac.vamsas.objects.core.DataSet; @@ -18,425 +32,440 @@ import uk.ac.vamsas.objects.core.DataSet; * * @version $Revision$ $Date$ */ -public class DataSetDescriptor extends org.exolab.castor.xml.util.XMLClassDescriptorImpl { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _elementDefinition. - */ - private boolean _elementDefinition; - - /** - * Field _nsPrefix. - */ - private java.lang.String _nsPrefix; - - /** - * Field _nsURI. - */ - private java.lang.String _nsURI; - - /** - * Field _xmlName. - */ - private java.lang.String _xmlName; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public DataSetDescriptor() { - super(); - _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; - _xmlName = "DataSet"; - _elementDefinition = true; - - //-- set grouping compositor - setCompositorAsSequence(); - org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; - org.exolab.castor.mapping.FieldHandler handler = null; - org.exolab.castor.xml.FieldValidator fieldValidator = null; - //-- initialize attribute descriptors - - //-- _id - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_id", "id", org.exolab.castor.xml.NodeType.Attribute); - super.setIdentity(desc); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - DataSet target = (DataSet) object; - return target.getId(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - DataSet target = (DataSet) object; - target.setId( (java.lang.String) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new java.lang.String(); - } - }; - desc.setHandler(handler); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _id - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope - org.exolab.castor.xml.validators.IdValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.IdValidator(); - fieldValidator.setValidator(typeValidator); +public class DataSetDescriptor extends + org.exolab.castor.xml.util.XMLClassDescriptorImpl { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _elementDefinition. + */ + private boolean _elementDefinition; + + /** + * Field _nsPrefix. + */ + private java.lang.String _nsPrefix; + + /** + * Field _nsURI. + */ + private java.lang.String _nsURI; + + /** + * Field _xmlName. + */ + private java.lang.String _xmlName; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public DataSetDescriptor() { + super(); + _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; + _xmlName = "DataSet"; + _elementDefinition = true; + + // -- set grouping compositor + setCompositorAsSequence(); + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + // -- initialize attribute descriptors + + // -- _id + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_id", "id", + org.exolab.castor.xml.NodeType.Attribute); + super.setIdentity(desc); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + DataSet target = (DataSet) object; + return target.getId(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + DataSet target = (DataSet) object; + target.setId((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- initialize element descriptors - - //-- _sequenceList - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(uk.ac.vamsas.objects.core.Sequence.class, "_sequenceList", "Sequence", org.exolab.castor.xml.NodeType.Element); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - DataSet target = (DataSet) object; - return target.getSequence(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - DataSet target = (DataSet) object; - target.addSequence( (uk.ac.vamsas.objects.core.Sequence) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public void resetValue(Object object) throws IllegalStateException, IllegalArgumentException { - try { - DataSet target = (DataSet) object; - target.removeAllSequence(); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new uk.ac.vamsas.objects.core.Sequence(); - } - }; - desc.setHandler(handler); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setRequired(true); - desc.setMultivalued(true); - addFieldDescriptor(desc); - - //-- validation code for: _sequenceList - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); - { //-- local scope + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return new java.lang.String(); + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _id + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { // -- local scope + org.exolab.castor.xml.validators.IdValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.IdValidator(); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + // -- initialize element descriptors + + // -- _sequenceList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + uk.ac.vamsas.objects.core.Sequence.class, "_sequenceList", "Sequence", + org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + DataSet target = (DataSet) object; + return target.getSequence(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + DataSet target = (DataSet) object; + target.addSequence((uk.ac.vamsas.objects.core.Sequence) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- _sequenceMappingList - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(uk.ac.vamsas.objects.core.SequenceMapping.class, "_sequenceMappingList", "sequenceMapping", org.exolab.castor.xml.NodeType.Element); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - DataSet target = (DataSet) object; - return target.getSequenceMapping(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - DataSet target = (DataSet) object; - target.addSequenceMapping( (uk.ac.vamsas.objects.core.SequenceMapping) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public void resetValue(Object object) throws IllegalStateException, IllegalArgumentException { - try { - DataSet target = (DataSet) object; - target.removeAllSequenceMapping(); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new uk.ac.vamsas.objects.core.SequenceMapping(); - } - }; - desc.setHandler(handler); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setMultivalued(true); - addFieldDescriptor(desc); - - //-- validation code for: _sequenceMappingList - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(0); - { //-- local scope + } + + public void resetValue(Object object) throws IllegalStateException, + IllegalArgumentException { + try { + DataSet target = (DataSet) object; + target.removeAllSequence(); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- _dataSetAnnotationsList - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(uk.ac.vamsas.objects.core.DataSetAnnotations.class, "_dataSetAnnotationsList", "DataSetAnnotations", org.exolab.castor.xml.NodeType.Element); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - DataSet target = (DataSet) object; - return target.getDataSetAnnotations(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - DataSet target = (DataSet) object; - target.addDataSetAnnotations( (uk.ac.vamsas.objects.core.DataSetAnnotations) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public void resetValue(Object object) throws IllegalStateException, IllegalArgumentException { - try { - DataSet target = (DataSet) object; - target.removeAllDataSetAnnotations(); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new uk.ac.vamsas.objects.core.DataSetAnnotations(); - } - }; - desc.setHandler(handler); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setMultivalued(true); - addFieldDescriptor(desc); - - //-- validation code for: _dataSetAnnotationsList - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(0); - { //-- local scope + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return new uk.ac.vamsas.objects.core.Sequence(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setRequired(true); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + // -- validation code for: _sequenceList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { // -- local scope + } + desc.setValidator(fieldValidator); + // -- _sequenceMappingList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + uk.ac.vamsas.objects.core.SequenceMapping.class, + "_sequenceMappingList", "sequenceMapping", + org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + DataSet target = (DataSet) object; + return target.getSequenceMapping(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + DataSet target = (DataSet) object; + target + .addSequenceMapping((uk.ac.vamsas.objects.core.SequenceMapping) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- _alignmentList - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(uk.ac.vamsas.objects.core.Alignment.class, "_alignmentList", "Alignment", org.exolab.castor.xml.NodeType.Element); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - DataSet target = (DataSet) object; - return target.getAlignment(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - DataSet target = (DataSet) object; - target.addAlignment( (uk.ac.vamsas.objects.core.Alignment) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public void resetValue(Object object) throws IllegalStateException, IllegalArgumentException { - try { - DataSet target = (DataSet) object; - target.removeAllAlignment(); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new uk.ac.vamsas.objects.core.Alignment(); - } - }; - desc.setHandler(handler); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setMultivalued(true); - addFieldDescriptor(desc); - - //-- validation code for: _alignmentList - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(0); - { //-- local scope + } + + public void resetValue(Object object) throws IllegalStateException, + IllegalArgumentException { + try { + DataSet target = (DataSet) object; + target.removeAllSequenceMapping(); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- _treeList - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(uk.ac.vamsas.objects.core.Tree.class, "_treeList", "Tree", org.exolab.castor.xml.NodeType.Element); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - DataSet target = (DataSet) object; - return target.getTree(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - DataSet target = (DataSet) object; - target.addTree( (uk.ac.vamsas.objects.core.Tree) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public void resetValue(Object object) throws IllegalStateException, IllegalArgumentException { - try { - DataSet target = (DataSet) object; - target.removeAllTree(); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new uk.ac.vamsas.objects.core.Tree(); - } - }; - desc.setHandler(handler); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setMultivalued(true); - addFieldDescriptor(desc); - - //-- validation code for: _treeList - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(0); - { //-- local scope + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return new uk.ac.vamsas.objects.core.SequenceMapping(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + // -- validation code for: _sequenceMappingList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { // -- local scope + } + desc.setValidator(fieldValidator); + // -- _dataSetAnnotationsList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + uk.ac.vamsas.objects.core.DataSetAnnotations.class, + "_dataSetAnnotationsList", "DataSetAnnotations", + org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + DataSet target = (DataSet) object; + return target.getDataSetAnnotations(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + DataSet target = (DataSet) object; + target + .addDataSetAnnotations((uk.ac.vamsas.objects.core.DataSetAnnotations) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- _provenance - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(uk.ac.vamsas.objects.core.Provenance.class, "_provenance", "Provenance", org.exolab.castor.xml.NodeType.Element); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - DataSet target = (DataSet) object; - return target.getProvenance(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - DataSet target = (DataSet) object; - target.setProvenance( (uk.ac.vamsas.objects.core.Provenance) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new uk.ac.vamsas.objects.core.Provenance(); - } - }; - desc.setHandler(handler); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setRequired(true); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _provenance - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); - { //-- local scope + } + + public void resetValue(Object object) throws IllegalStateException, + IllegalArgumentException { + try { + DataSet target = (DataSet) object; + target.removeAllDataSetAnnotations(); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return new uk.ac.vamsas.objects.core.DataSetAnnotations(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + // -- validation code for: _dataSetAnnotationsList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { // -- local scope } + desc.setValidator(fieldValidator); + // -- _alignmentList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + uk.ac.vamsas.objects.core.Alignment.class, "_alignmentList", + "Alignment", org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + DataSet target = (DataSet) object; + return target.getAlignment(); + } + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + DataSet target = (DataSet) object; + target.addAlignment((uk.ac.vamsas.objects.core.Alignment) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - //-----------/ - //- Methods -/ - //-----------/ + public void resetValue(Object object) throws IllegalStateException, + IllegalArgumentException { + try { + DataSet target = (DataSet) object; + target.removeAllAlignment(); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getAccessMode. - * - * @return the access mode specified for this class. - */ - public org.exolab.castor.mapping.AccessMode getAccessMode( - ) { - return null; - } + public java.lang.Object newInstance(java.lang.Object parent) { + return new uk.ac.vamsas.objects.core.Alignment(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setMultivalued(true); + addFieldDescriptor(desc); - /** - * Method getIdentity. - * - * @return the identity field, null if this class has no - * identity. - */ - public org.exolab.castor.mapping.FieldDescriptor getIdentity( - ) { - return super.getIdentity(); + // -- validation code for: _alignmentList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { // -- local scope } + desc.setValidator(fieldValidator); + // -- _treeList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + uk.ac.vamsas.objects.core.Tree.class, "_treeList", "Tree", + org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + DataSet target = (DataSet) object; + return target.getTree(); + } - /** - * Method getJavaClass. - * - * @return the Java class represented by this descriptor. - */ - public java.lang.Class getJavaClass( - ) { - return uk.ac.vamsas.objects.core.DataSet.class; - } + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + DataSet target = (DataSet) object; + target.addTree((uk.ac.vamsas.objects.core.Tree) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getNameSpacePrefix. - * - * @return the namespace prefix to use when marshaling as XML. - */ - public java.lang.String getNameSpacePrefix( - ) { - return _nsPrefix; - } + public void resetValue(Object object) throws IllegalStateException, + IllegalArgumentException { + try { + DataSet target = (DataSet) object; + target.removeAllTree(); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getNameSpaceURI. - * - * @return the namespace URI used when marshaling and - * unmarshaling as XML. - */ - public java.lang.String getNameSpaceURI( - ) { - return _nsURI; - } + public java.lang.Object newInstance(java.lang.Object parent) { + return new uk.ac.vamsas.objects.core.Tree(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setMultivalued(true); + addFieldDescriptor(desc); - /** - * Method getValidator. - * - * @return a specific validator for the class described by this - * ClassDescriptor. - */ - public org.exolab.castor.xml.TypeValidator getValidator( - ) { - return this; + // -- validation code for: _treeList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { // -- local scope } + desc.setValidator(fieldValidator); + // -- _provenance + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + uk.ac.vamsas.objects.core.Provenance.class, "_provenance", + "Provenance", org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + DataSet target = (DataSet) object; + return target.getProvenance(); + } - /** - * Method getXMLName. - * - * @return the XML Name for the Class being described. - */ - public java.lang.String getXMLName( - ) { - return _xmlName; - } + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + DataSet target = (DataSet) object; + target.setProvenance((uk.ac.vamsas.objects.core.Provenance) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return new uk.ac.vamsas.objects.core.Provenance(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); - /** - * Method isElementDefinition. - * - * @return true if XML schema definition of this Class is that - * of a global - * element or element with anonymous type definition. - */ - public boolean isElementDefinition( - ) { - return _elementDefinition; + // -- validation code for: _provenance + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { // -- local scope } + desc.setValidator(fieldValidator); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * Method getAccessMode. + * + * @return the access mode specified for this class. + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() { + return null; + } + + /** + * Method getIdentity. + * + * @return the identity field, null if this class has no identity. + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() { + return super.getIdentity(); + } + + /** + * Method getJavaClass. + * + * @return the Java class represented by this descriptor. + */ + public java.lang.Class getJavaClass() { + return uk.ac.vamsas.objects.core.DataSet.class; + } + + /** + * Method getNameSpacePrefix. + * + * @return the namespace prefix to use when marshaling as XML. + */ + public java.lang.String getNameSpacePrefix() { + return _nsPrefix; + } + + /** + * Method getNameSpaceURI. + * + * @return the namespace URI used when marshaling and unmarshaling as XML. + */ + public java.lang.String getNameSpaceURI() { + return _nsURI; + } + + /** + * Method getValidator. + * + * @return a specific validator for the class described by this + * ClassDescriptor. + */ + public org.exolab.castor.xml.TypeValidator getValidator() { + return this; + } + + /** + * Method getXMLName. + * + * @return the XML Name for the Class being described. + */ + public java.lang.String getXMLName() { + return _xmlName; + } + + /** + * Method isElementDefinition. + * + * @return true if XML schema definition of this Class is that of a global + * element or element with anonymous type definition. + */ + public boolean isElementDefinition() { + return _elementDefinition; + } } diff --git a/src/uk/ac/vamsas/objects/core/descriptors/DbRefDescriptor.java b/src/uk/ac/vamsas/objects/core/descriptors/DbRefDescriptor.java index 9f13e4f..eee7f9a 100644 --- a/src/uk/ac/vamsas/objects/core/descriptors/DbRefDescriptor.java +++ b/src/uk/ac/vamsas/objects/core/descriptors/DbRefDescriptor.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core.descriptors; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import uk.ac.vamsas.objects.core.DbRef; @@ -18,422 +32,429 @@ import uk.ac.vamsas.objects.core.DbRef; * * @version $Revision$ $Date$ */ -public class DbRefDescriptor extends org.exolab.castor.xml.util.XMLClassDescriptorImpl { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _elementDefinition. - */ - private boolean _elementDefinition; - - /** - * Field _nsPrefix. - */ - private java.lang.String _nsPrefix; - - /** - * Field _nsURI. - */ - private java.lang.String _nsURI; - - /** - * Field _xmlName. - */ - private java.lang.String _xmlName; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public DbRefDescriptor() { - super(); - _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; - _xmlName = "dbRef"; - _elementDefinition = true; - - //-- set grouping compositor - setCompositorAsSequence(); - org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; - org.exolab.castor.mapping.FieldHandler handler = null; - org.exolab.castor.xml.FieldValidator fieldValidator = null; - //-- initialize attribute descriptors - - //-- _source - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_source", "source", 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 - { - DbRef target = (DbRef) object; - return target.getSource(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - DbRef target = (DbRef) object; - target.setSource( (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); - desc.setRequired(true); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _source - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); - { //-- local scope - org.exolab.castor.xml.validators.StringValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.StringValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setWhiteSpace("preserve"); - } - desc.setValidator(fieldValidator); - //-- _version - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_version", "version", 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 - { - DbRef target = (DbRef) object; - return target.getVersion(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - DbRef target = (DbRef) object; - target.setVersion( (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); - desc.setRequired(true); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _version - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); - { //-- local scope - org.exolab.castor.xml.validators.StringValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.StringValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setWhiteSpace("preserve"); +public class DbRefDescriptor extends + org.exolab.castor.xml.util.XMLClassDescriptorImpl { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _elementDefinition. + */ + private boolean _elementDefinition; + + /** + * Field _nsPrefix. + */ + private java.lang.String _nsPrefix; + + /** + * Field _nsURI. + */ + private java.lang.String _nsURI; + + /** + * Field _xmlName. + */ + private java.lang.String _xmlName; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public DbRefDescriptor() { + super(); + _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; + _xmlName = "dbRef"; + _elementDefinition = true; + + // -- set grouping compositor + setCompositorAsSequence(); + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + // -- initialize attribute descriptors + + // -- _source + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_source", "source", + 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 { + DbRef target = (DbRef) object; + return target.getSource(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + DbRef target = (DbRef) object; + target.setSource((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- _accessionId - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_accessionId", "accessionId", 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 - { - DbRef target = (DbRef) object; - return target.getAccessionId(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - DbRef target = (DbRef) object; - target.setAccessionId( (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); - desc.setRequired(true); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _accessionId - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); - { //-- local scope - org.exolab.castor.xml.validators.StringValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.StringValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setWhiteSpace("preserve"); + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return null; + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _source + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { // -- local scope + org.exolab.castor.xml.validators.StringValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.StringValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setWhiteSpace("preserve"); + } + desc.setValidator(fieldValidator); + // -- _version + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_version", "version", + 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 { + DbRef target = (DbRef) object; + return target.getVersion(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + DbRef target = (DbRef) object; + target.setVersion((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- _id - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_id", "id", org.exolab.castor.xml.NodeType.Attribute); - super.setIdentity(desc); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - DbRef target = (DbRef) object; - return target.getId(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - DbRef target = (DbRef) object; - target.setId( (java.lang.String) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new java.lang.String(); - } - }; - desc.setHandler(handler); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _id - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope - org.exolab.castor.xml.validators.IdValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.IdValidator(); - fieldValidator.setValidator(typeValidator); + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return null; + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _version + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { // -- local scope + org.exolab.castor.xml.validators.StringValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.StringValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setWhiteSpace("preserve"); + } + desc.setValidator(fieldValidator); + // -- _accessionId + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_accessionId", "accessionId", + 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 { + DbRef target = (DbRef) object; + return target.getAccessionId(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + DbRef target = (DbRef) object; + target.setAccessionId((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- initialize element descriptors - - //-- _mapList - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(uk.ac.vamsas.objects.core.Map.class, "_mapList", "map", org.exolab.castor.xml.NodeType.Element); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - DbRef target = (DbRef) object; - return target.getMap(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - DbRef target = (DbRef) object; - target.addMap( (uk.ac.vamsas.objects.core.Map) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public void resetValue(Object object) throws IllegalStateException, IllegalArgumentException { - try { - DbRef target = (DbRef) object; - target.removeAllMap(); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new uk.ac.vamsas.objects.core.Map(); - } - }; - desc.setHandler(handler); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setMultivalued(true); - addFieldDescriptor(desc); - - //-- validation code for: _mapList - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(0); - { //-- local scope + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return null; + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _accessionId + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { // -- local scope + org.exolab.castor.xml.validators.StringValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.StringValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setWhiteSpace("preserve"); + } + desc.setValidator(fieldValidator); + // -- _id + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_id", "id", + org.exolab.castor.xml.NodeType.Attribute); + super.setIdentity(desc); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + DbRef target = (DbRef) object; + return target.getId(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + DbRef target = (DbRef) object; + target.setId((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- _linkList - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(uk.ac.vamsas.objects.core.Link.class, "_linkList", "link", org.exolab.castor.xml.NodeType.Element); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - DbRef target = (DbRef) object; - return target.getLink(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - DbRef target = (DbRef) object; - target.addLink( (uk.ac.vamsas.objects.core.Link) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public void resetValue(Object object) throws IllegalStateException, IllegalArgumentException { - try { - DbRef target = (DbRef) object; - target.removeAllLink(); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new uk.ac.vamsas.objects.core.Link(); - } - }; - desc.setHandler(handler); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setMultivalued(true); - addFieldDescriptor(desc); - - //-- validation code for: _linkList - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(0); - { //-- local scope + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return new java.lang.String(); + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _id + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { // -- local scope + org.exolab.castor.xml.validators.IdValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.IdValidator(); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + // -- initialize element descriptors + + // -- _mapList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + uk.ac.vamsas.objects.core.Map.class, "_mapList", "map", + org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + DbRef target = (DbRef) object; + return target.getMap(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + DbRef target = (DbRef) object; + target.addMap((uk.ac.vamsas.objects.core.Map) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- _propertyList - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(uk.ac.vamsas.objects.core.Property.class, "_propertyList", "property", org.exolab.castor.xml.NodeType.Element); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - DbRef target = (DbRef) object; - return target.getProperty(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - DbRef target = (DbRef) object; - target.addProperty( (uk.ac.vamsas.objects.core.Property) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public void resetValue(Object object) throws IllegalStateException, IllegalArgumentException { - try { - DbRef target = (DbRef) object; - target.removeAllProperty(); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new uk.ac.vamsas.objects.core.Property(); - } - }; - desc.setHandler(handler); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setMultivalued(true); - addFieldDescriptor(desc); - - //-- validation code for: _propertyList - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(0); - { //-- local scope + } + + public void resetValue(Object object) throws IllegalStateException, + IllegalArgumentException { + try { + DbRef target = (DbRef) object; + target.removeAllMap(); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return new uk.ac.vamsas.objects.core.Map(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + // -- validation code for: _mapList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { // -- local scope } + desc.setValidator(fieldValidator); + // -- _linkList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + uk.ac.vamsas.objects.core.Link.class, "_linkList", "link", + org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + DbRef target = (DbRef) object; + return target.getLink(); + } + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + DbRef target = (DbRef) object; + target.addLink((uk.ac.vamsas.objects.core.Link) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - //-----------/ - //- Methods -/ - //-----------/ + public void resetValue(Object object) throws IllegalStateException, + IllegalArgumentException { + try { + DbRef target = (DbRef) object; + target.removeAllLink(); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getAccessMode. - * - * @return the access mode specified for this class. - */ - public org.exolab.castor.mapping.AccessMode getAccessMode( - ) { - return null; - } + public java.lang.Object newInstance(java.lang.Object parent) { + return new uk.ac.vamsas.objects.core.Link(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setMultivalued(true); + addFieldDescriptor(desc); - /** - * Method getIdentity. - * - * @return the identity field, null if this class has no - * identity. - */ - public org.exolab.castor.mapping.FieldDescriptor getIdentity( - ) { - return super.getIdentity(); + // -- validation code for: _linkList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { // -- local scope } + desc.setValidator(fieldValidator); + // -- _propertyList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + uk.ac.vamsas.objects.core.Property.class, "_propertyList", "property", + org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + DbRef target = (DbRef) object; + return target.getProperty(); + } - /** - * Method getJavaClass. - * - * @return the Java class represented by this descriptor. - */ - public java.lang.Class getJavaClass( - ) { - return uk.ac.vamsas.objects.core.DbRef.class; - } + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + DbRef target = (DbRef) object; + target.addProperty((uk.ac.vamsas.objects.core.Property) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getNameSpacePrefix. - * - * @return the namespace prefix to use when marshaling as XML. - */ - public java.lang.String getNameSpacePrefix( - ) { - return _nsPrefix; - } + public void resetValue(Object object) throws IllegalStateException, + IllegalArgumentException { + try { + DbRef target = (DbRef) object; + target.removeAllProperty(); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getNameSpaceURI. - * - * @return the namespace URI used when marshaling and - * unmarshaling as XML. - */ - public java.lang.String getNameSpaceURI( - ) { - return _nsURI; - } + public java.lang.Object newInstance(java.lang.Object parent) { + return new uk.ac.vamsas.objects.core.Property(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setMultivalued(true); + addFieldDescriptor(desc); - /** - * Method getValidator. - * - * @return a specific validator for the class described by this - * ClassDescriptor. - */ - public org.exolab.castor.xml.TypeValidator getValidator( - ) { - return this; + // -- validation code for: _propertyList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { // -- local scope } + desc.setValidator(fieldValidator); + } - /** - * Method getXMLName. - * - * @return the XML Name for the Class being described. - */ - public java.lang.String getXMLName( - ) { - return _xmlName; - } + // -----------/ + // - Methods -/ + // -----------/ - /** - * Method isElementDefinition. - * - * @return true if XML schema definition of this Class is that - * of a global - * element or element with anonymous type definition. - */ - public boolean isElementDefinition( - ) { - return _elementDefinition; - } + /** + * Method getAccessMode. + * + * @return the access mode specified for this class. + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() { + return null; + } + + /** + * Method getIdentity. + * + * @return the identity field, null if this class has no identity. + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() { + return super.getIdentity(); + } + + /** + * Method getJavaClass. + * + * @return the Java class represented by this descriptor. + */ + public java.lang.Class getJavaClass() { + return uk.ac.vamsas.objects.core.DbRef.class; + } + + /** + * Method getNameSpacePrefix. + * + * @return the namespace prefix to use when marshaling as XML. + */ + public java.lang.String getNameSpacePrefix() { + return _nsPrefix; + } + + /** + * Method getNameSpaceURI. + * + * @return the namespace URI used when marshaling and unmarshaling as XML. + */ + public java.lang.String getNameSpaceURI() { + return _nsURI; + } + + /** + * Method getValidator. + * + * @return a specific validator for the class described by this + * ClassDescriptor. + */ + public org.exolab.castor.xml.TypeValidator getValidator() { + return this; + } + + /** + * Method getXMLName. + * + * @return the XML Name for the Class being described. + */ + public java.lang.String getXMLName() { + return _xmlName; + } + + /** + * Method isElementDefinition. + * + * @return true if XML schema definition of this Class is that of a global + * element or element with anonymous type definition. + */ + public boolean isElementDefinition() { + return _elementDefinition; + } } diff --git a/src/uk/ac/vamsas/objects/core/descriptors/EntryDescriptor.java b/src/uk/ac/vamsas/objects/core/descriptors/EntryDescriptor.java index 6b3eb45..3041196 100644 --- a/src/uk/ac/vamsas/objects/core/descriptors/EntryDescriptor.java +++ b/src/uk/ac/vamsas/objects/core/descriptors/EntryDescriptor.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core.descriptors; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import uk.ac.vamsas.objects.core.Entry; @@ -18,465 +32,474 @@ import uk.ac.vamsas.objects.core.Entry; * * @version $Revision$ $Date$ */ -public class EntryDescriptor extends org.exolab.castor.xml.util.XMLClassDescriptorImpl { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _elementDefinition. - */ - private boolean _elementDefinition; - - /** - * Field _nsPrefix. - */ - private java.lang.String _nsPrefix; - - /** - * Field _nsURI. - */ - private java.lang.String _nsURI; - - /** - * Field _xmlName. - */ - private java.lang.String _xmlName; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public EntryDescriptor() { - super(); - _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; - _xmlName = "entry"; - _elementDefinition = true; - - //-- set grouping compositor - setCompositorAsSequence(); - org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; - org.exolab.castor.mapping.FieldHandler handler = null; - org.exolab.castor.xml.FieldValidator fieldValidator = null; - //-- initialize attribute descriptors - - //-- _id - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_id", "id", org.exolab.castor.xml.NodeType.Attribute); - super.setIdentity(desc); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - Entry target = (Entry) object; - return target.getId(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Entry target = (Entry) object; - target.setId( (java.lang.String) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new java.lang.String(); - } - }; - desc.setHandler(handler); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _id - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope - org.exolab.castor.xml.validators.IdValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.IdValidator(); - fieldValidator.setValidator(typeValidator); - } - desc.setValidator(fieldValidator); - //-- initialize element descriptors - - //-- _user - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_user", "User", org.exolab.castor.xml.NodeType.Element); - desc.setImmutable(true); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - Entry target = (Entry) object; - return target.getUser(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Entry target = (Entry) object; - target.setUser( (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); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setRequired(true); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _user - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); - { //-- local scope - org.exolab.castor.xml.validators.StringValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.StringValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setWhiteSpace("preserve"); - } - desc.setValidator(fieldValidator); - //-- _app - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_app", "App", org.exolab.castor.xml.NodeType.Element); - desc.setImmutable(true); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - Entry target = (Entry) object; - return target.getApp(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Entry target = (Entry) object; - target.setApp( (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); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setRequired(true); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _app - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); - { //-- local scope - org.exolab.castor.xml.validators.StringValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.StringValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setWhiteSpace("preserve"); - } - desc.setValidator(fieldValidator); - //-- _action - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_action", "Action", org.exolab.castor.xml.NodeType.Element); - desc.setImmutable(true); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - Entry target = (Entry) object; - return target.getAction(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Entry target = (Entry) object; - target.setAction( (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); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setRequired(true); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _action - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); - { //-- local scope - org.exolab.castor.xml.validators.StringValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.StringValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setWhiteSpace("preserve"); - } - desc.setValidator(fieldValidator); - //-- _date - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.util.Date.class, "_date", "Date", org.exolab.castor.xml.NodeType.Element); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - Entry target = (Entry) object; - return target.getDate(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Entry target = (Entry) object; - target.setDate( (java.util.Date) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new java.util.Date(); - } - }; - handler = new org.exolab.castor.xml.handlers.DateFieldHandler(handler); - desc.setImmutable(true); - desc.setHandler(handler); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setRequired(true); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _date - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); - { //-- local scope - org.exolab.castor.xml.validators.DateTimeValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.DateTimeValidator(); - fieldValidator.setValidator(typeValidator); - } - desc.setValidator(fieldValidator); - //-- _propertyList - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(uk.ac.vamsas.objects.core.Property.class, "_propertyList", "property", org.exolab.castor.xml.NodeType.Element); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - Entry target = (Entry) object; - return target.getProperty(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Entry target = (Entry) object; - target.addProperty( (uk.ac.vamsas.objects.core.Property) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public void resetValue(Object object) throws IllegalStateException, IllegalArgumentException { - try { - Entry target = (Entry) object; - target.removeAllProperty(); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new uk.ac.vamsas.objects.core.Property(); - } - }; - desc.setHandler(handler); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setMultivalued(true); - addFieldDescriptor(desc); - - //-- validation code for: _propertyList - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(0); - { //-- local scope - } - desc.setValidator(fieldValidator); - //-- _paramList - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(uk.ac.vamsas.objects.core.Param.class, "_paramList", "param", org.exolab.castor.xml.NodeType.Element); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - Entry target = (Entry) object; - return target.getParam(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Entry target = (Entry) object; - target.addParam( (uk.ac.vamsas.objects.core.Param) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public void resetValue(Object object) throws IllegalStateException, IllegalArgumentException { - try { - Entry target = (Entry) object; - target.removeAllParam(); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new uk.ac.vamsas.objects.core.Param(); - } - }; - desc.setHandler(handler); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setMultivalued(true); - addFieldDescriptor(desc); - - //-- validation code for: _paramList - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(0); - { //-- local scope - } - desc.setValidator(fieldValidator); - //-- _inputList - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(uk.ac.vamsas.objects.core.Input.class, "_inputList", "input", org.exolab.castor.xml.NodeType.Element); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - Entry target = (Entry) object; - return target.getInput(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Entry target = (Entry) object; - target.addInput( (uk.ac.vamsas.objects.core.Input) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public void resetValue(Object object) throws IllegalStateException, IllegalArgumentException { - try { - Entry target = (Entry) object; - target.removeAllInput(); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new uk.ac.vamsas.objects.core.Input(); - } - }; - desc.setHandler(handler); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setMultivalued(true); - addFieldDescriptor(desc); - - //-- validation code for: _inputList - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(0); - { //-- local scope +public class EntryDescriptor extends + org.exolab.castor.xml.util.XMLClassDescriptorImpl { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _elementDefinition. + */ + private boolean _elementDefinition; + + /** + * Field _nsPrefix. + */ + private java.lang.String _nsPrefix; + + /** + * Field _nsURI. + */ + private java.lang.String _nsURI; + + /** + * Field _xmlName. + */ + private java.lang.String _xmlName; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public EntryDescriptor() { + super(); + _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; + _xmlName = "entry"; + _elementDefinition = true; + + // -- set grouping compositor + setCompositorAsSequence(); + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + // -- initialize attribute descriptors + + // -- _id + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_id", "id", + org.exolab.castor.xml.NodeType.Attribute); + super.setIdentity(desc); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + Entry target = (Entry) object; + return target.getId(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Entry target = (Entry) object; + target.setId((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return new java.lang.String(); + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _id + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { // -- local scope + org.exolab.castor.xml.validators.IdValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.IdValidator(); + fieldValidator.setValidator(typeValidator); } + desc.setValidator(fieldValidator); + // -- initialize element descriptors + // -- _user + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_user", "User", + org.exolab.castor.xml.NodeType.Element); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + Entry target = (Entry) object; + return target.getUser(); + } - //-----------/ - //- Methods -/ - //-----------/ + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Entry target = (Entry) object; + target.setUser((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getAccessMode. - * - * @return the access mode specified for this class. - */ - public org.exolab.castor.mapping.AccessMode getAccessMode( - ) { + public java.lang.Object newInstance(java.lang.Object parent) { return null; - } + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); - /** - * Method getIdentity. - * - * @return the identity field, null if this class has no - * identity. - */ - public org.exolab.castor.mapping.FieldDescriptor getIdentity( - ) { - return super.getIdentity(); + // -- validation code for: _user + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { // -- local scope + org.exolab.castor.xml.validators.StringValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.StringValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setWhiteSpace("preserve"); } + desc.setValidator(fieldValidator); + // -- _app + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_app", "App", + org.exolab.castor.xml.NodeType.Element); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + Entry target = (Entry) object; + return target.getApp(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Entry target = (Entry) object; + target.setApp((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getJavaClass. - * - * @return the Java class represented by this descriptor. - */ - public java.lang.Class getJavaClass( - ) { - return uk.ac.vamsas.objects.core.Entry.class; + public java.lang.Object newInstance(java.lang.Object parent) { + return null; + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _app + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { // -- local scope + org.exolab.castor.xml.validators.StringValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.StringValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setWhiteSpace("preserve"); } + desc.setValidator(fieldValidator); + // -- _action + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_action", "Action", + org.exolab.castor.xml.NodeType.Element); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + Entry target = (Entry) object; + return target.getAction(); + } - /** - * Method getNameSpacePrefix. - * - * @return the namespace prefix to use when marshaling as XML. - */ - public java.lang.String getNameSpacePrefix( - ) { - return _nsPrefix; + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Entry target = (Entry) object; + target.setAction((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); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _action + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { // -- local scope + org.exolab.castor.xml.validators.StringValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.StringValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setWhiteSpace("preserve"); } + desc.setValidator(fieldValidator); + // -- _date + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.util.Date.class, "_date", "Date", + org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + Entry target = (Entry) object; + return target.getDate(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Entry target = (Entry) object; + target.setDate((java.util.Date) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return new java.util.Date(); + } + }; + handler = new org.exolab.castor.xml.handlers.DateFieldHandler(handler); + desc.setImmutable(true); + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); - /** - * Method getNameSpaceURI. - * - * @return the namespace URI used when marshaling and - * unmarshaling as XML. - */ - public java.lang.String getNameSpaceURI( - ) { - return _nsURI; + // -- validation code for: _date + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { // -- local scope + org.exolab.castor.xml.validators.DateTimeValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.DateTimeValidator(); + fieldValidator.setValidator(typeValidator); } + desc.setValidator(fieldValidator); + // -- _propertyList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + uk.ac.vamsas.objects.core.Property.class, "_propertyList", "property", + org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + Entry target = (Entry) object; + return target.getProperty(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Entry target = (Entry) object; + target.addProperty((uk.ac.vamsas.objects.core.Property) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getValidator. - * - * @return a specific validator for the class described by this - * ClassDescriptor. - */ - public org.exolab.castor.xml.TypeValidator getValidator( - ) { - return this; + public void resetValue(Object object) throws IllegalStateException, + IllegalArgumentException { + try { + Entry target = (Entry) object; + target.removeAllProperty(); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return new uk.ac.vamsas.objects.core.Property(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + // -- validation code for: _propertyList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { // -- local scope } + desc.setValidator(fieldValidator); + // -- _paramList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + uk.ac.vamsas.objects.core.Param.class, "_paramList", "param", + org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + Entry target = (Entry) object; + return target.getParam(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Entry target = (Entry) object; + target.addParam((uk.ac.vamsas.objects.core.Param) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + + public void resetValue(Object object) throws IllegalStateException, + IllegalArgumentException { + try { + Entry target = (Entry) object; + target.removeAllParam(); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getXMLName. - * - * @return the XML Name for the Class being described. - */ - public java.lang.String getXMLName( - ) { - return _xmlName; + public java.lang.Object newInstance(java.lang.Object parent) { + return new uk.ac.vamsas.objects.core.Param(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + // -- validation code for: _paramList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { // -- local scope } + desc.setValidator(fieldValidator); + // -- _inputList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + uk.ac.vamsas.objects.core.Input.class, "_inputList", "input", + org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + Entry target = (Entry) object; + return target.getInput(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Entry target = (Entry) object; + target.addInput((uk.ac.vamsas.objects.core.Input) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + + public void resetValue(Object object) throws IllegalStateException, + IllegalArgumentException { + try { + Entry target = (Entry) object; + target.removeAllInput(); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return new uk.ac.vamsas.objects.core.Input(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setMultivalued(true); + addFieldDescriptor(desc); - /** - * Method isElementDefinition. - * - * @return true if XML schema definition of this Class is that - * of a global - * element or element with anonymous type definition. - */ - public boolean isElementDefinition( - ) { - return _elementDefinition; + // -- validation code for: _inputList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { // -- local scope } + desc.setValidator(fieldValidator); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * Method getAccessMode. + * + * @return the access mode specified for this class. + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() { + return null; + } + + /** + * Method getIdentity. + * + * @return the identity field, null if this class has no identity. + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() { + return super.getIdentity(); + } + + /** + * Method getJavaClass. + * + * @return the Java class represented by this descriptor. + */ + public java.lang.Class getJavaClass() { + return uk.ac.vamsas.objects.core.Entry.class; + } + + /** + * Method getNameSpacePrefix. + * + * @return the namespace prefix to use when marshaling as XML. + */ + public java.lang.String getNameSpacePrefix() { + return _nsPrefix; + } + + /** + * Method getNameSpaceURI. + * + * @return the namespace URI used when marshaling and unmarshaling as XML. + */ + public java.lang.String getNameSpaceURI() { + return _nsURI; + } + + /** + * Method getValidator. + * + * @return a specific validator for the class described by this + * ClassDescriptor. + */ + public org.exolab.castor.xml.TypeValidator getValidator() { + return this; + } + + /** + * Method getXMLName. + * + * @return the XML Name for the Class being described. + */ + public java.lang.String getXMLName() { + return _xmlName; + } + + /** + * Method isElementDefinition. + * + * @return true if XML schema definition of this Class is that of a global + * element or element with anonymous type definition. + */ + public boolean isElementDefinition() { + return _elementDefinition; + } } diff --git a/src/uk/ac/vamsas/objects/core/descriptors/GlyphDescriptor.java b/src/uk/ac/vamsas/objects/core/descriptors/GlyphDescriptor.java index 0d694f0..c171da0 100644 --- a/src/uk/ac/vamsas/objects/core/descriptors/GlyphDescriptor.java +++ b/src/uk/ac/vamsas/objects/core/descriptors/GlyphDescriptor.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core.descriptors; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import uk.ac.vamsas.objects.core.Glyph; @@ -18,213 +32,204 @@ import uk.ac.vamsas.objects.core.Glyph; * * @version $Revision$ $Date$ */ -public class GlyphDescriptor extends org.exolab.castor.xml.util.XMLClassDescriptorImpl { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _elementDefinition. - */ - private boolean _elementDefinition; - - /** - * Field _nsPrefix. - */ - private java.lang.String _nsPrefix; - - /** - * Field _nsURI. - */ - private java.lang.String _nsURI; - - /** - * Field _xmlName. - */ - private java.lang.String _xmlName; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public GlyphDescriptor() { - super(); - _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; - _xmlName = "glyph"; - _elementDefinition = true; - org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; - org.exolab.castor.mapping.FieldHandler handler = null; - org.exolab.castor.xml.FieldValidator fieldValidator = null; - //-- _content - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_content", "PCDATA", org.exolab.castor.xml.NodeType.Text); - desc.setImmutable(true); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - Glyph target = (Glyph) object; - return target.getContent(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Glyph target = (Glyph) object; - target.setContent( (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: _content - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope - org.exolab.castor.xml.validators.StringValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.StringValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setWhiteSpace("preserve"); - } - desc.setValidator(fieldValidator); - //-- initialize attribute descriptors - - //-- _dict - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_dict", "dict", 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 - { - Glyph target = (Glyph) object; - return target.getDict(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Glyph target = (Glyph) object; - target.setDict( (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); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _dict - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope - org.exolab.castor.xml.validators.StringValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.StringValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setWhiteSpace("preserve"); +public class GlyphDescriptor extends + org.exolab.castor.xml.util.XMLClassDescriptorImpl { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _elementDefinition. + */ + private boolean _elementDefinition; + + /** + * Field _nsPrefix. + */ + private java.lang.String _nsPrefix; + + /** + * Field _nsURI. + */ + private java.lang.String _nsURI; + + /** + * Field _xmlName. + */ + private java.lang.String _xmlName; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public GlyphDescriptor() { + super(); + _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; + _xmlName = "glyph"; + _elementDefinition = true; + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + // -- _content + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_content", "PCDATA", + org.exolab.castor.xml.NodeType.Text); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + Glyph target = (Glyph) object; + return target.getContent(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Glyph target = (Glyph) object; + target.setContent((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- initialize element descriptors - - } - - - //-----------/ - //- Methods -/ - //-----------/ + } - /** - * Method getAccessMode. - * - * @return the access mode specified for this class. - */ - public org.exolab.castor.mapping.AccessMode getAccessMode( - ) { + public java.lang.Object newInstance(java.lang.Object parent) { return null; + } + }; + desc.setHandler(handler); + addFieldDescriptor(desc); + + // -- validation code for: _content + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { // -- local scope + org.exolab.castor.xml.validators.StringValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.StringValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setWhiteSpace("preserve"); } + desc.setValidator(fieldValidator); + // -- initialize attribute descriptors + + // -- _dict + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_dict", "dict", + 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 { + Glyph target = (Glyph) object; + return target.getDict(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Glyph target = (Glyph) object; + target.setDict((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getIdentity. - * - * @return the identity field, null if this class has no - * identity. - */ - public org.exolab.castor.mapping.FieldDescriptor getIdentity( - ) { - return super.getIdentity(); - } - - /** - * Method getJavaClass. - * - * @return the Java class represented by this descriptor. - */ - public java.lang.Class getJavaClass( - ) { - return uk.ac.vamsas.objects.core.Glyph.class; - } - - /** - * Method getNameSpacePrefix. - * - * @return the namespace prefix to use when marshaling as XML. - */ - public java.lang.String getNameSpacePrefix( - ) { - return _nsPrefix; - } - - /** - * Method getNameSpaceURI. - * - * @return the namespace URI used when marshaling and - * unmarshaling as XML. - */ - public java.lang.String getNameSpaceURI( - ) { - return _nsURI; - } - - /** - * Method getValidator. - * - * @return a specific validator for the class described by this - * ClassDescriptor. - */ - public org.exolab.castor.xml.TypeValidator getValidator( - ) { - return this; - } - - /** - * Method getXMLName. - * - * @return the XML Name for the Class being described. - */ - public java.lang.String getXMLName( - ) { - return _xmlName; - } - - /** - * Method isElementDefinition. - * - * @return true if XML schema definition of this Class is that - * of a global - * element or element with anonymous type definition. - */ - public boolean isElementDefinition( - ) { - return _elementDefinition; + public java.lang.Object newInstance(java.lang.Object parent) { + return null; + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _dict + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { // -- local scope + org.exolab.castor.xml.validators.StringValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.StringValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setWhiteSpace("preserve"); } + desc.setValidator(fieldValidator); + // -- initialize element descriptors + + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * Method getAccessMode. + * + * @return the access mode specified for this class. + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() { + return null; + } + + /** + * Method getIdentity. + * + * @return the identity field, null if this class has no identity. + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() { + return super.getIdentity(); + } + + /** + * Method getJavaClass. + * + * @return the Java class represented by this descriptor. + */ + public java.lang.Class getJavaClass() { + return uk.ac.vamsas.objects.core.Glyph.class; + } + + /** + * Method getNameSpacePrefix. + * + * @return the namespace prefix to use when marshaling as XML. + */ + public java.lang.String getNameSpacePrefix() { + return _nsPrefix; + } + + /** + * Method getNameSpaceURI. + * + * @return the namespace URI used when marshaling and unmarshaling as XML. + */ + public java.lang.String getNameSpaceURI() { + return _nsURI; + } + + /** + * Method getValidator. + * + * @return a specific validator for the class described by this + * ClassDescriptor. + */ + public org.exolab.castor.xml.TypeValidator getValidator() { + return this; + } + + /** + * Method getXMLName. + * + * @return the XML Name for the Class being described. + */ + public java.lang.String getXMLName() { + return _xmlName; + } + + /** + * Method isElementDefinition. + * + * @return true if XML schema definition of this Class is that of a global + * element or element with anonymous type definition. + */ + public boolean isElementDefinition() { + return _elementDefinition; + } } diff --git a/src/uk/ac/vamsas/objects/core/descriptors/InputDescriptor.java b/src/uk/ac/vamsas/objects/core/descriptors/InputDescriptor.java index 649ff90..17267bb 100644 --- a/src/uk/ac/vamsas/objects/core/descriptors/InputDescriptor.java +++ b/src/uk/ac/vamsas/objects/core/descriptors/InputDescriptor.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core.descriptors; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import uk.ac.vamsas.objects.core.Input; @@ -18,226 +32,219 @@ import uk.ac.vamsas.objects.core.Input; * * @version $Revision$ $Date$ */ -public class InputDescriptor extends uk.ac.vamsas.objects.core.descriptors.RangeTypeDescriptor { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _elementDefinition. - */ - private boolean _elementDefinition; - - /** - * Field _nsPrefix. - */ - private java.lang.String _nsPrefix; - - /** - * Field _nsURI. - */ - private java.lang.String _nsURI; - - /** - * Field _xmlName. - */ - private java.lang.String _xmlName; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public InputDescriptor() { - super(); - setExtendsWithoutFlatten(new uk.ac.vamsas.objects.core.descriptors.RangeTypeDescriptor()); - _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; - _xmlName = "input"; - _elementDefinition = true; - org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; - org.exolab.castor.mapping.FieldHandler handler = null; - org.exolab.castor.xml.FieldValidator fieldValidator = null; - //-- initialize attribute descriptors - - //-- _name - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_name", "name", 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 - { - Input target = (Input) object; - return target.getName(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Input target = (Input) object; - target.setName( (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); - desc.setRequired(true); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _name - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); - { //-- local scope - org.exolab.castor.xml.validators.StringValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.StringValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setWhiteSpace("preserve"); - } - desc.setValidator(fieldValidator); - //-- _objRef - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Object.class, "_objRef", "objRef", org.exolab.castor.xml.NodeType.Attribute); - desc.setReference(true); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - Input target = (Input) object; - return target.getObjRef(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Input target = (Input) object; - target.addObjRef( (java.lang.Object) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public void resetValue(Object object) throws IllegalStateException, IllegalArgumentException { - try { - Input target = (Input) object; - target.removeAllObjRef(); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new java.lang.Object(); - } - }; - desc.setMultivalued(true); - desc.setHandler(handler); - desc.setMultivalued(true); - addFieldDescriptor(desc); - - //-- validation code for: _objRef - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(0); - { //-- local scope - org.exolab.castor.xml.validators.IdRefsValidator typeValidator = new org.exolab.castor.xml.validators.IdRefsValidator(); - fieldValidator.setValidator(typeValidator); - desc.setValidator(fieldValidator); +public class InputDescriptor extends + uk.ac.vamsas.objects.core.descriptors.RangeTypeDescriptor { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _elementDefinition. + */ + private boolean _elementDefinition; + + /** + * Field _nsPrefix. + */ + private java.lang.String _nsPrefix; + + /** + * Field _nsURI. + */ + private java.lang.String _nsURI; + + /** + * Field _xmlName. + */ + private java.lang.String _xmlName; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public InputDescriptor() { + super(); + setExtendsWithoutFlatten(new uk.ac.vamsas.objects.core.descriptors.RangeTypeDescriptor()); + _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; + _xmlName = "input"; + _elementDefinition = true; + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + // -- initialize attribute descriptors + + // -- _name + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_name", "name", + 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 { + Input target = (Input) object; + return target.getName(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Input target = (Input) object; + target.setName((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- initialize element descriptors - - } - - - //-----------/ - //- Methods -/ - //-----------/ + } - /** - * Method getAccessMode. - * - * @return the access mode specified for this class. - */ - public org.exolab.castor.mapping.AccessMode getAccessMode( - ) { + public java.lang.Object newInstance(java.lang.Object parent) { return null; + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _name + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { // -- local scope + org.exolab.castor.xml.validators.StringValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.StringValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setWhiteSpace("preserve"); } - - /** - * Method getIdentity. - * - * @return the identity field, null if this class has no - * identity. - */ - public org.exolab.castor.mapping.FieldDescriptor getIdentity( - ) { - return super.getIdentity(); - } - - /** - * Method getJavaClass. - * - * @return the Java class represented by this descriptor. - */ - public java.lang.Class getJavaClass( - ) { - return uk.ac.vamsas.objects.core.Input.class; - } - - /** - * Method getNameSpacePrefix. - * - * @return the namespace prefix to use when marshaling as XML. - */ - public java.lang.String getNameSpacePrefix( - ) { - return _nsPrefix; - } - - /** - * Method getNameSpaceURI. - * - * @return the namespace URI used when marshaling and - * unmarshaling as XML. - */ - public java.lang.String getNameSpaceURI( - ) { - return _nsURI; - } - - /** - * Method getValidator. - * - * @return a specific validator for the class described by this - * ClassDescriptor. - */ - public org.exolab.castor.xml.TypeValidator getValidator( - ) { - return this; - } - - /** - * Method getXMLName. - * - * @return the XML Name for the Class being described. - */ - public java.lang.String getXMLName( - ) { - return _xmlName; - } - - /** - * Method isElementDefinition. - * - * @return true if XML schema definition of this Class is that - * of a global - * element or element with anonymous type definition. - */ - public boolean isElementDefinition( - ) { - return _elementDefinition; + desc.setValidator(fieldValidator); + // -- _objRef + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.Object.class, "_objRef", "objRef", + org.exolab.castor.xml.NodeType.Attribute); + desc.setReference(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + Input target = (Input) object; + return target.getObjRef(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Input target = (Input) object; + target.addObjRef((java.lang.Object) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + + public void resetValue(Object object) throws IllegalStateException, + IllegalArgumentException { + try { + Input target = (Input) object; + target.removeAllObjRef(); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return new java.lang.Object(); + } + }; + desc.setMultivalued(true); + desc.setHandler(handler); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + // -- validation code for: _objRef + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { // -- local scope + org.exolab.castor.xml.validators.IdRefsValidator typeValidator = new org.exolab.castor.xml.validators.IdRefsValidator(); + fieldValidator.setValidator(typeValidator); + desc.setValidator(fieldValidator); } + desc.setValidator(fieldValidator); + // -- initialize element descriptors + + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * Method getAccessMode. + * + * @return the access mode specified for this class. + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() { + return null; + } + + /** + * Method getIdentity. + * + * @return the identity field, null if this class has no identity. + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() { + return super.getIdentity(); + } + + /** + * Method getJavaClass. + * + * @return the Java class represented by this descriptor. + */ + public java.lang.Class getJavaClass() { + return uk.ac.vamsas.objects.core.Input.class; + } + + /** + * Method getNameSpacePrefix. + * + * @return the namespace prefix to use when marshaling as XML. + */ + public java.lang.String getNameSpacePrefix() { + return _nsPrefix; + } + + /** + * Method getNameSpaceURI. + * + * @return the namespace URI used when marshaling and unmarshaling as XML. + */ + public java.lang.String getNameSpaceURI() { + return _nsURI; + } + + /** + * Method getValidator. + * + * @return a specific validator for the class described by this + * ClassDescriptor. + */ + public org.exolab.castor.xml.TypeValidator getValidator() { + return this; + } + + /** + * Method getXMLName. + * + * @return the XML Name for the Class being described. + */ + public java.lang.String getXMLName() { + return _xmlName; + } + + /** + * Method isElementDefinition. + * + * @return true if XML schema definition of this Class is that of a global + * element or element with anonymous type definition. + */ + public boolean isElementDefinition() { + return _elementDefinition; + } } diff --git a/src/uk/ac/vamsas/objects/core/descriptors/InstanceDescriptor.java b/src/uk/ac/vamsas/objects/core/descriptors/InstanceDescriptor.java index d24131a..a9b62e3 100644 --- a/src/uk/ac/vamsas/objects/core/descriptors/InstanceDescriptor.java +++ b/src/uk/ac/vamsas/objects/core/descriptors/InstanceDescriptor.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core.descriptors; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import uk.ac.vamsas.objects.core.Instance; @@ -18,180 +32,169 @@ import uk.ac.vamsas.objects.core.Instance; * * @version $Revision$ $Date$ */ -public class InstanceDescriptor extends uk.ac.vamsas.objects.core.descriptors.AppDataDescriptor { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _elementDefinition. - */ - private boolean _elementDefinition; - - /** - * Field _nsPrefix. - */ - private java.lang.String _nsPrefix; - - /** - * Field _nsURI. - */ - private java.lang.String _nsURI; - - /** - * Field _xmlName. - */ - private java.lang.String _xmlName; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public InstanceDescriptor() { - super(); - setExtendsWithoutFlatten(new uk.ac.vamsas.objects.core.descriptors.AppDataDescriptor()); - _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; - _xmlName = "Instance"; - _elementDefinition = true; - org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; - org.exolab.castor.mapping.FieldHandler handler = null; - org.exolab.castor.xml.FieldValidator fieldValidator = null; - //-- initialize attribute descriptors - - //-- _urn - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_urn", "urn", 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 - { - Instance target = (Instance) object; - return target.getUrn(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Instance target = (Instance) object; - target.setUrn( (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); - desc.setRequired(true); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _urn - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); - { //-- local scope - org.exolab.castor.xml.validators.StringValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.StringValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setWhiteSpace("preserve"); +public class InstanceDescriptor extends + uk.ac.vamsas.objects.core.descriptors.AppDataDescriptor { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _elementDefinition. + */ + private boolean _elementDefinition; + + /** + * Field _nsPrefix. + */ + private java.lang.String _nsPrefix; + + /** + * Field _nsURI. + */ + private java.lang.String _nsURI; + + /** + * Field _xmlName. + */ + private java.lang.String _xmlName; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public InstanceDescriptor() { + super(); + setExtendsWithoutFlatten(new uk.ac.vamsas.objects.core.descriptors.AppDataDescriptor()); + _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; + _xmlName = "Instance"; + _elementDefinition = true; + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + // -- initialize attribute descriptors + + // -- _urn + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_urn", "urn", + 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 { + Instance target = (Instance) object; + return target.getUrn(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Instance target = (Instance) object; + target.setUrn((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- initialize element descriptors - - } + } - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Method getAccessMode. - * - * @return the access mode specified for this class. - */ - public org.exolab.castor.mapping.AccessMode getAccessMode( - ) { + public java.lang.Object newInstance(java.lang.Object parent) { return null; + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _urn + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { // -- local scope + org.exolab.castor.xml.validators.StringValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.StringValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setWhiteSpace("preserve"); } - - /** - * Method getIdentity. - * - * @return the identity field, null if this class has no - * identity. - */ - public org.exolab.castor.mapping.FieldDescriptor getIdentity( - ) { - return super.getIdentity(); - } - - /** - * Method getJavaClass. - * - * @return the Java class represented by this descriptor. - */ - public java.lang.Class getJavaClass( - ) { - return uk.ac.vamsas.objects.core.Instance.class; - } - - /** - * Method getNameSpacePrefix. - * - * @return the namespace prefix to use when marshaling as XML. - */ - public java.lang.String getNameSpacePrefix( - ) { - return _nsPrefix; - } - - /** - * Method getNameSpaceURI. - * - * @return the namespace URI used when marshaling and - * unmarshaling as XML. - */ - public java.lang.String getNameSpaceURI( - ) { - return _nsURI; - } - - /** - * Method getValidator. - * - * @return a specific validator for the class described by this - * ClassDescriptor. - */ - public org.exolab.castor.xml.TypeValidator getValidator( - ) { - return this; - } - - /** - * Method getXMLName. - * - * @return the XML Name for the Class being described. - */ - public java.lang.String getXMLName( - ) { - return _xmlName; - } - - /** - * Method isElementDefinition. - * - * @return true if XML schema definition of this Class is that - * of a global - * element or element with anonymous type definition. - */ - public boolean isElementDefinition( - ) { - return _elementDefinition; - } + desc.setValidator(fieldValidator); + // -- initialize element descriptors + + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * Method getAccessMode. + * + * @return the access mode specified for this class. + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() { + return null; + } + + /** + * Method getIdentity. + * + * @return the identity field, null if this class has no identity. + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() { + return super.getIdentity(); + } + + /** + * Method getJavaClass. + * + * @return the Java class represented by this descriptor. + */ + public java.lang.Class getJavaClass() { + return uk.ac.vamsas.objects.core.Instance.class; + } + + /** + * Method getNameSpacePrefix. + * + * @return the namespace prefix to use when marshaling as XML. + */ + public java.lang.String getNameSpacePrefix() { + return _nsPrefix; + } + + /** + * Method getNameSpaceURI. + * + * @return the namespace URI used when marshaling and unmarshaling as XML. + */ + public java.lang.String getNameSpaceURI() { + return _nsURI; + } + + /** + * Method getValidator. + * + * @return a specific validator for the class described by this + * ClassDescriptor. + */ + public org.exolab.castor.xml.TypeValidator getValidator() { + return this; + } + + /** + * Method getXMLName. + * + * @return the XML Name for the Class being described. + */ + public java.lang.String getXMLName() { + return _xmlName; + } + + /** + * Method isElementDefinition. + * + * @return true if XML schema definition of this Class is that of a global + * element or element with anonymous type definition. + */ + public boolean isElementDefinition() { + return _elementDefinition; + } } diff --git a/src/uk/ac/vamsas/objects/core/descriptors/LinkDescriptor.java b/src/uk/ac/vamsas/objects/core/descriptors/LinkDescriptor.java index e8c70a5..fde0663 100644 --- a/src/uk/ac/vamsas/objects/core/descriptors/LinkDescriptor.java +++ b/src/uk/ac/vamsas/objects/core/descriptors/LinkDescriptor.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core.descriptors; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import uk.ac.vamsas.objects.core.Link; @@ -18,208 +32,199 @@ import uk.ac.vamsas.objects.core.Link; * * @version $Revision$ $Date$ */ -public class LinkDescriptor extends org.exolab.castor.xml.util.XMLClassDescriptorImpl { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _elementDefinition. - */ - private boolean _elementDefinition; - - /** - * Field _nsPrefix. - */ - private java.lang.String _nsPrefix; - - /** - * Field _nsURI. - */ - private java.lang.String _nsURI; - - /** - * Field _xmlName. - */ - private java.lang.String _xmlName; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public LinkDescriptor() { - super(); - _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; - _xmlName = "link"; - _elementDefinition = true; - org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; - org.exolab.castor.mapping.FieldHandler handler = null; - org.exolab.castor.xml.FieldValidator fieldValidator = null; - //-- _content - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_content", "PCDATA", org.exolab.castor.xml.NodeType.Text); - desc.setImmutable(true); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - Link target = (Link) object; - return target.getContent(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Link target = (Link) object; - target.setContent( (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: _content - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope - org.exolab.castor.xml.validators.StringValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.StringValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setWhiteSpace("preserve"); - } - desc.setValidator(fieldValidator); - //-- initialize attribute descriptors - - //-- _href - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_href", "href", org.exolab.castor.xml.NodeType.Attribute); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - Link target = (Link) object; - return target.getHref(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Link target = (Link) object; - target.setHref( (java.lang.String) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new java.lang.String(); - } - }; - desc.setHandler(handler); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _href - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope +public class LinkDescriptor extends + org.exolab.castor.xml.util.XMLClassDescriptorImpl { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _elementDefinition. + */ + private boolean _elementDefinition; + + /** + * Field _nsPrefix. + */ + private java.lang.String _nsPrefix; + + /** + * Field _nsURI. + */ + private java.lang.String _nsURI; + + /** + * Field _xmlName. + */ + private java.lang.String _xmlName; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public LinkDescriptor() { + super(); + _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; + _xmlName = "link"; + _elementDefinition = true; + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + // -- _content + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_content", "PCDATA", + org.exolab.castor.xml.NodeType.Text); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + Link target = (Link) object; + return target.getContent(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Link target = (Link) object; + target.setContent((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- initialize element descriptors - - } - - - //-----------/ - //- Methods -/ - //-----------/ + } - /** - * Method getAccessMode. - * - * @return the access mode specified for this class. - */ - public org.exolab.castor.mapping.AccessMode getAccessMode( - ) { + public java.lang.Object newInstance(java.lang.Object parent) { return null; + } + }; + desc.setHandler(handler); + addFieldDescriptor(desc); + + // -- validation code for: _content + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { // -- local scope + org.exolab.castor.xml.validators.StringValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.StringValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setWhiteSpace("preserve"); } - - /** - * Method getIdentity. - * - * @return the identity field, null if this class has no - * identity. - */ - public org.exolab.castor.mapping.FieldDescriptor getIdentity( - ) { - return super.getIdentity(); - } - - /** - * Method getJavaClass. - * - * @return the Java class represented by this descriptor. - */ - public java.lang.Class getJavaClass( - ) { - return uk.ac.vamsas.objects.core.Link.class; - } - - /** - * Method getNameSpacePrefix. - * - * @return the namespace prefix to use when marshaling as XML. - */ - public java.lang.String getNameSpacePrefix( - ) { - return _nsPrefix; - } - - /** - * Method getNameSpaceURI. - * - * @return the namespace URI used when marshaling and - * unmarshaling as XML. - */ - public java.lang.String getNameSpaceURI( - ) { - return _nsURI; - } - - /** - * Method getValidator. - * - * @return a specific validator for the class described by this - * ClassDescriptor. - */ - public org.exolab.castor.xml.TypeValidator getValidator( - ) { - return this; - } - - /** - * Method getXMLName. - * - * @return the XML Name for the Class being described. - */ - public java.lang.String getXMLName( - ) { - return _xmlName; - } - - /** - * Method isElementDefinition. - * - * @return true if XML schema definition of this Class is that - * of a global - * element or element with anonymous type definition. - */ - public boolean isElementDefinition( - ) { - return _elementDefinition; + desc.setValidator(fieldValidator); + // -- initialize attribute descriptors + + // -- _href + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_href", "href", + org.exolab.castor.xml.NodeType.Attribute); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + Link target = (Link) object; + return target.getHref(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Link target = (Link) object; + target.setHref((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return new java.lang.String(); + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _href + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { // -- local scope } + desc.setValidator(fieldValidator); + // -- initialize element descriptors + + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * Method getAccessMode. + * + * @return the access mode specified for this class. + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() { + return null; + } + + /** + * Method getIdentity. + * + * @return the identity field, null if this class has no identity. + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() { + return super.getIdentity(); + } + + /** + * Method getJavaClass. + * + * @return the Java class represented by this descriptor. + */ + public java.lang.Class getJavaClass() { + return uk.ac.vamsas.objects.core.Link.class; + } + + /** + * Method getNameSpacePrefix. + * + * @return the namespace prefix to use when marshaling as XML. + */ + public java.lang.String getNameSpacePrefix() { + return _nsPrefix; + } + + /** + * Method getNameSpaceURI. + * + * @return the namespace URI used when marshaling and unmarshaling as XML. + */ + public java.lang.String getNameSpaceURI() { + return _nsURI; + } + + /** + * Method getValidator. + * + * @return a specific validator for the class described by this + * ClassDescriptor. + */ + public org.exolab.castor.xml.TypeValidator getValidator() { + return this; + } + + /** + * Method getXMLName. + * + * @return the XML Name for the Class being described. + */ + public java.lang.String getXMLName() { + return _xmlName; + } + + /** + * Method isElementDefinition. + * + * @return true if XML schema definition of this Class is that of a global + * element or element with anonymous type definition. + */ + public boolean isElementDefinition() { + return _elementDefinition; + } } diff --git a/src/uk/ac/vamsas/objects/core/descriptors/LocalDescriptor.java b/src/uk/ac/vamsas/objects/core/descriptors/LocalDescriptor.java index 409177c..d172d0b 100644 --- a/src/uk/ac/vamsas/objects/core/descriptors/LocalDescriptor.java +++ b/src/uk/ac/vamsas/objects/core/descriptors/LocalDescriptor.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core.descriptors; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import uk.ac.vamsas.objects.core.Local; @@ -18,134 +32,121 @@ import uk.ac.vamsas.objects.core.Local; * * @version $Revision$ $Date$ */ -public class LocalDescriptor extends uk.ac.vamsas.objects.core.descriptors.MapRangeTypeDescriptor { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _elementDefinition. - */ - private boolean _elementDefinition; - - /** - * Field _nsPrefix. - */ - private java.lang.String _nsPrefix; - - /** - * Field _nsURI. - */ - private java.lang.String _nsURI; - - /** - * Field _xmlName. - */ - private java.lang.String _xmlName; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public LocalDescriptor() { - super(); - setExtendsWithoutFlatten(new uk.ac.vamsas.objects.core.descriptors.MapRangeTypeDescriptor()); - _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; - _xmlName = "local"; - _elementDefinition = true; - } - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Method getAccessMode. - * - * @return the access mode specified for this class. - */ - public org.exolab.castor.mapping.AccessMode getAccessMode( - ) { - return null; - } - - /** - * Method getIdentity. - * - * @return the identity field, null if this class has no - * identity. - */ - public org.exolab.castor.mapping.FieldDescriptor getIdentity( - ) { - return super.getIdentity(); - } - - /** - * Method getJavaClass. - * - * @return the Java class represented by this descriptor. - */ - public java.lang.Class getJavaClass( - ) { - return uk.ac.vamsas.objects.core.Local.class; - } - - /** - * Method getNameSpacePrefix. - * - * @return the namespace prefix to use when marshaling as XML. - */ - public java.lang.String getNameSpacePrefix( - ) { - return _nsPrefix; - } - - /** - * Method getNameSpaceURI. - * - * @return the namespace URI used when marshaling and - * unmarshaling as XML. - */ - public java.lang.String getNameSpaceURI( - ) { - return _nsURI; - } - - /** - * Method getValidator. - * - * @return a specific validator for the class described by this - * ClassDescriptor. - */ - public org.exolab.castor.xml.TypeValidator getValidator( - ) { - return this; - } - - /** - * Method getXMLName. - * - * @return the XML Name for the Class being described. - */ - public java.lang.String getXMLName( - ) { - return _xmlName; - } - - /** - * Method isElementDefinition. - * - * @return true if XML schema definition of this Class is that - * of a global - * element or element with anonymous type definition. - */ - public boolean isElementDefinition( - ) { - return _elementDefinition; - } +public class LocalDescriptor extends + uk.ac.vamsas.objects.core.descriptors.MapRangeTypeDescriptor { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _elementDefinition. + */ + private boolean _elementDefinition; + + /** + * Field _nsPrefix. + */ + private java.lang.String _nsPrefix; + + /** + * Field _nsURI. + */ + private java.lang.String _nsURI; + + /** + * Field _xmlName. + */ + private java.lang.String _xmlName; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public LocalDescriptor() { + super(); + setExtendsWithoutFlatten(new uk.ac.vamsas.objects.core.descriptors.MapRangeTypeDescriptor()); + _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; + _xmlName = "local"; + _elementDefinition = true; + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * Method getAccessMode. + * + * @return the access mode specified for this class. + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() { + return null; + } + + /** + * Method getIdentity. + * + * @return the identity field, null if this class has no identity. + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() { + return super.getIdentity(); + } + + /** + * Method getJavaClass. + * + * @return the Java class represented by this descriptor. + */ + public java.lang.Class getJavaClass() { + return uk.ac.vamsas.objects.core.Local.class; + } + + /** + * Method getNameSpacePrefix. + * + * @return the namespace prefix to use when marshaling as XML. + */ + public java.lang.String getNameSpacePrefix() { + return _nsPrefix; + } + + /** + * Method getNameSpaceURI. + * + * @return the namespace URI used when marshaling and unmarshaling as XML. + */ + public java.lang.String getNameSpaceURI() { + return _nsURI; + } + + /** + * Method getValidator. + * + * @return a specific validator for the class described by this + * ClassDescriptor. + */ + public org.exolab.castor.xml.TypeValidator getValidator() { + return this; + } + + /** + * Method getXMLName. + * + * @return the XML Name for the Class being described. + */ + public java.lang.String getXMLName() { + return _xmlName; + } + + /** + * Method isElementDefinition. + * + * @return true if XML schema definition of this Class is that of a global + * element or element with anonymous type definition. + */ + public boolean isElementDefinition() { + return _elementDefinition; + } } diff --git a/src/uk/ac/vamsas/objects/core/descriptors/LockFileDescriptor.java b/src/uk/ac/vamsas/objects/core/descriptors/LockFileDescriptor.java index 26cd7cc..d073c6d 100644 --- a/src/uk/ac/vamsas/objects/core/descriptors/LockFileDescriptor.java +++ b/src/uk/ac/vamsas/objects/core/descriptors/LockFileDescriptor.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core.descriptors; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import uk.ac.vamsas.objects.core.LockFile; @@ -18,176 +32,165 @@ import uk.ac.vamsas.objects.core.LockFile; * * @version $Revision$ $Date$ */ -public class LockFileDescriptor extends org.exolab.castor.xml.util.XMLClassDescriptorImpl { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _elementDefinition. - */ - private boolean _elementDefinition; - - /** - * Field _nsPrefix. - */ - private java.lang.String _nsPrefix; - - /** - * Field _nsURI. - */ - private java.lang.String _nsURI; - - /** - * Field _xmlName. - */ - private java.lang.String _xmlName; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public LockFileDescriptor() { - super(); - _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasDocument"; - _xmlName = "LockFile"; - _elementDefinition = true; - org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; - org.exolab.castor.mapping.FieldHandler handler = null; - org.exolab.castor.xml.FieldValidator fieldValidator = null; - //-- _content - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_content", "PCDATA", org.exolab.castor.xml.NodeType.Text); - desc.setImmutable(true); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - LockFile target = (LockFile) object; - return target.getContent(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - LockFile target = (LockFile) object; - target.setContent( (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: _content - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope - org.exolab.castor.xml.validators.StringValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.StringValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setWhiteSpace("preserve"); +public class LockFileDescriptor extends + org.exolab.castor.xml.util.XMLClassDescriptorImpl { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _elementDefinition. + */ + private boolean _elementDefinition; + + /** + * Field _nsPrefix. + */ + private java.lang.String _nsPrefix; + + /** + * Field _nsURI. + */ + private java.lang.String _nsURI; + + /** + * Field _xmlName. + */ + private java.lang.String _xmlName; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public LockFileDescriptor() { + super(); + _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasDocument"; + _xmlName = "LockFile"; + _elementDefinition = true; + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + // -- _content + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_content", "PCDATA", + org.exolab.castor.xml.NodeType.Text); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + LockFile target = (LockFile) object; + return target.getContent(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + LockFile target = (LockFile) object; + target.setContent((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- initialize attribute descriptors - - //-- initialize element descriptors - - } + } - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Method getAccessMode. - * - * @return the access mode specified for this class. - */ - public org.exolab.castor.mapping.AccessMode getAccessMode( - ) { + public java.lang.Object newInstance(java.lang.Object parent) { return null; + } + }; + desc.setHandler(handler); + addFieldDescriptor(desc); + + // -- validation code for: _content + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { // -- local scope + org.exolab.castor.xml.validators.StringValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.StringValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setWhiteSpace("preserve"); } - - /** - * Method getIdentity. - * - * @return the identity field, null if this class has no - * identity. - */ - public org.exolab.castor.mapping.FieldDescriptor getIdentity( - ) { - return super.getIdentity(); - } - - /** - * Method getJavaClass. - * - * @return the Java class represented by this descriptor. - */ - public java.lang.Class getJavaClass( - ) { - return uk.ac.vamsas.objects.core.LockFile.class; - } - - /** - * Method getNameSpacePrefix. - * - * @return the namespace prefix to use when marshaling as XML. - */ - public java.lang.String getNameSpacePrefix( - ) { - return _nsPrefix; - } - - /** - * Method getNameSpaceURI. - * - * @return the namespace URI used when marshaling and - * unmarshaling as XML. - */ - public java.lang.String getNameSpaceURI( - ) { - return _nsURI; - } - - /** - * Method getValidator. - * - * @return a specific validator for the class described by this - * ClassDescriptor. - */ - public org.exolab.castor.xml.TypeValidator getValidator( - ) { - return this; - } - - /** - * Method getXMLName. - * - * @return the XML Name for the Class being described. - */ - public java.lang.String getXMLName( - ) { - return _xmlName; - } - - /** - * Method isElementDefinition. - * - * @return true if XML schema definition of this Class is that - * of a global - * element or element with anonymous type definition. - */ - public boolean isElementDefinition( - ) { - return _elementDefinition; - } + desc.setValidator(fieldValidator); + // -- initialize attribute descriptors + + // -- initialize element descriptors + + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * Method getAccessMode. + * + * @return the access mode specified for this class. + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() { + return null; + } + + /** + * Method getIdentity. + * + * @return the identity field, null if this class has no identity. + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() { + return super.getIdentity(); + } + + /** + * Method getJavaClass. + * + * @return the Java class represented by this descriptor. + */ + public java.lang.Class getJavaClass() { + return uk.ac.vamsas.objects.core.LockFile.class; + } + + /** + * Method getNameSpacePrefix. + * + * @return the namespace prefix to use when marshaling as XML. + */ + public java.lang.String getNameSpacePrefix() { + return _nsPrefix; + } + + /** + * Method getNameSpaceURI. + * + * @return the namespace URI used when marshaling and unmarshaling as XML. + */ + public java.lang.String getNameSpaceURI() { + return _nsURI; + } + + /** + * Method getValidator. + * + * @return a specific validator for the class described by this + * ClassDescriptor. + */ + public org.exolab.castor.xml.TypeValidator getValidator() { + return this; + } + + /** + * Method getXMLName. + * + * @return the XML Name for the Class being described. + */ + public java.lang.String getXMLName() { + return _xmlName; + } + + /** + * Method isElementDefinition. + * + * @return true if XML schema definition of this Class is that of a global + * element or element with anonymous type definition. + */ + public boolean isElementDefinition() { + return _elementDefinition; + } } diff --git a/src/uk/ac/vamsas/objects/core/descriptors/MapDescriptor.java b/src/uk/ac/vamsas/objects/core/descriptors/MapDescriptor.java index 14efb4b..6653ba6 100644 --- a/src/uk/ac/vamsas/objects/core/descriptors/MapDescriptor.java +++ b/src/uk/ac/vamsas/objects/core/descriptors/MapDescriptor.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core.descriptors; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import uk.ac.vamsas.objects.core.Map; @@ -18,177 +32,166 @@ import uk.ac.vamsas.objects.core.Map; * * @version $Revision$ $Date$ */ -public class MapDescriptor extends uk.ac.vamsas.objects.core.descriptors.MapTypeDescriptor { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _elementDefinition. - */ - private boolean _elementDefinition; - - /** - * Field _nsPrefix. - */ - private java.lang.String _nsPrefix; - - /** - * Field _nsURI. - */ - private java.lang.String _nsURI; - - /** - * Field _xmlName. - */ - private java.lang.String _xmlName; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public MapDescriptor() { - super(); - setExtendsWithoutFlatten(new uk.ac.vamsas.objects.core.descriptors.MapTypeDescriptor()); - _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; - _xmlName = "map"; - _elementDefinition = true; - org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; - org.exolab.castor.mapping.FieldHandler handler = null; - org.exolab.castor.xml.FieldValidator fieldValidator = null; - //-- initialize attribute descriptors - - //-- _id - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_id", "id", org.exolab.castor.xml.NodeType.Attribute); - super.setIdentity(desc); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - Map target = (Map) object; - return target.getId(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Map target = (Map) object; - target.setId( (java.lang.String) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new java.lang.String(); - } - }; - desc.setHandler(handler); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _id - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope - org.exolab.castor.xml.validators.IdValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.IdValidator(); - fieldValidator.setValidator(typeValidator); +public class MapDescriptor extends + uk.ac.vamsas.objects.core.descriptors.MapTypeDescriptor { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _elementDefinition. + */ + private boolean _elementDefinition; + + /** + * Field _nsPrefix. + */ + private java.lang.String _nsPrefix; + + /** + * Field _nsURI. + */ + private java.lang.String _nsURI; + + /** + * Field _xmlName. + */ + private java.lang.String _xmlName; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public MapDescriptor() { + super(); + setExtendsWithoutFlatten(new uk.ac.vamsas.objects.core.descriptors.MapTypeDescriptor()); + _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; + _xmlName = "map"; + _elementDefinition = true; + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + // -- initialize attribute descriptors + + // -- _id + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_id", "id", + org.exolab.castor.xml.NodeType.Attribute); + super.setIdentity(desc); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + Map target = (Map) object; + return target.getId(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Map target = (Map) object; + target.setId((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- initialize element descriptors - - } - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Method getAccessMode. - * - * @return the access mode specified for this class. - */ - public org.exolab.castor.mapping.AccessMode getAccessMode( - ) { - return null; - } - - /** - * Method getIdentity. - * - * @return the identity field, null if this class has no - * identity. - */ - public org.exolab.castor.mapping.FieldDescriptor getIdentity( - ) { - return super.getIdentity(); - } - - /** - * Method getJavaClass. - * - * @return the Java class represented by this descriptor. - */ - public java.lang.Class getJavaClass( - ) { - return uk.ac.vamsas.objects.core.Map.class; - } - - /** - * Method getNameSpacePrefix. - * - * @return the namespace prefix to use when marshaling as XML. - */ - public java.lang.String getNameSpacePrefix( - ) { - return _nsPrefix; - } - - /** - * Method getNameSpaceURI. - * - * @return the namespace URI used when marshaling and - * unmarshaling as XML. - */ - public java.lang.String getNameSpaceURI( - ) { - return _nsURI; - } - - /** - * Method getValidator. - * - * @return a specific validator for the class described by this - * ClassDescriptor. - */ - public org.exolab.castor.xml.TypeValidator getValidator( - ) { - return this; - } - - /** - * Method getXMLName. - * - * @return the XML Name for the Class being described. - */ - public java.lang.String getXMLName( - ) { - return _xmlName; - } - - /** - * Method isElementDefinition. - * - * @return true if XML schema definition of this Class is that - * of a global - * element or element with anonymous type definition. - */ - public boolean isElementDefinition( - ) { - return _elementDefinition; + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return new java.lang.String(); + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _id + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { // -- local scope + org.exolab.castor.xml.validators.IdValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.IdValidator(); + fieldValidator.setValidator(typeValidator); } + desc.setValidator(fieldValidator); + // -- initialize element descriptors + + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * Method getAccessMode. + * + * @return the access mode specified for this class. + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() { + return null; + } + + /** + * Method getIdentity. + * + * @return the identity field, null if this class has no identity. + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() { + return super.getIdentity(); + } + + /** + * Method getJavaClass. + * + * @return the Java class represented by this descriptor. + */ + public java.lang.Class getJavaClass() { + return uk.ac.vamsas.objects.core.Map.class; + } + + /** + * Method getNameSpacePrefix. + * + * @return the namespace prefix to use when marshaling as XML. + */ + public java.lang.String getNameSpacePrefix() { + return _nsPrefix; + } + + /** + * Method getNameSpaceURI. + * + * @return the namespace URI used when marshaling and unmarshaling as XML. + */ + public java.lang.String getNameSpaceURI() { + return _nsURI; + } + + /** + * Method getValidator. + * + * @return a specific validator for the class described by this + * ClassDescriptor. + */ + public org.exolab.castor.xml.TypeValidator getValidator() { + return this; + } + + /** + * Method getXMLName. + * + * @return the XML Name for the Class being described. + */ + public java.lang.String getXMLName() { + return _xmlName; + } + + /** + * Method isElementDefinition. + * + * @return true if XML schema definition of this Class is that of a global + * element or element with anonymous type definition. + */ + public boolean isElementDefinition() { + return _elementDefinition; + } } diff --git a/src/uk/ac/vamsas/objects/core/descriptors/MapListDescriptor.java b/src/uk/ac/vamsas/objects/core/descriptors/MapListDescriptor.java index 542a713..08b1b2f 100644 --- a/src/uk/ac/vamsas/objects/core/descriptors/MapListDescriptor.java +++ b/src/uk/ac/vamsas/objects/core/descriptors/MapListDescriptor.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core.descriptors; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import uk.ac.vamsas.objects.core.MapList; @@ -18,309 +32,316 @@ import uk.ac.vamsas.objects.core.MapList; * * @version $Revision$ $Date$ */ -public class MapListDescriptor extends org.exolab.castor.xml.util.XMLClassDescriptorImpl { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _elementDefinition. - */ - private boolean _elementDefinition; - - /** - * 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 MapListDescriptor() { - super(); - _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; - _xmlName = "mapList"; - _elementDefinition = false; - org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; - org.exolab.castor.mapping.FieldHandler handler = null; - org.exolab.castor.xml.FieldValidator fieldValidator = null; - //-- initialize attribute descriptors - - //-- _from - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Long.TYPE, "_from", "from", org.exolab.castor.xml.NodeType.Attribute); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - MapList target = (MapList) object; - if (!target.hasFrom()) { return null; } - return new java.lang.Long(target.getFrom()); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - MapList target = (MapList) object; - // if null, use delete method for optional primitives - if (value == null) { - target.deleteFrom(); - return; - } - target.setFrom( ((java.lang.Long) value).longValue()); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return null; - } - }; - desc.setHandler(handler); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _from - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope - org.exolab.castor.xml.validators.LongValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.LongValidator(); - fieldValidator.setValidator(typeValidator); +public class MapListDescriptor extends + org.exolab.castor.xml.util.XMLClassDescriptorImpl { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _elementDefinition. + */ + private boolean _elementDefinition; + + /** + * 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 MapListDescriptor() { + super(); + _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; + _xmlName = "mapList"; + _elementDefinition = false; + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + // -- initialize attribute descriptors + + // -- _from + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.Long.TYPE, "_from", "from", + org.exolab.castor.xml.NodeType.Attribute); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + MapList target = (MapList) object; + if (!target.hasFrom()) { + return null; } - desc.setValidator(fieldValidator); - //-- _to - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Long.TYPE, "_to", "to", org.exolab.castor.xml.NodeType.Attribute); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - MapList target = (MapList) object; - if (!target.hasTo()) { return null; } - return new java.lang.Long(target.getTo()); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - MapList target = (MapList) object; - // if null, use delete method for optional primitives - if (value == null) { - target.deleteTo(); - return; - } - target.setTo( ((java.lang.Long) value).longValue()); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return null; - } - }; - desc.setHandler(handler); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _to - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope - org.exolab.castor.xml.validators.LongValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.LongValidator(); - fieldValidator.setValidator(typeValidator); + return new java.lang.Long(target.getFrom()); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + MapList target = (MapList) object; + // if null, use delete method for optional primitives + if (value == null) { + target.deleteFrom(); + return; + } + target.setFrom(((java.lang.Long) value).longValue()); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- _start - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Long.TYPE, "_start", "start", org.exolab.castor.xml.NodeType.Attribute); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - MapList target = (MapList) object; - if (!target.hasStart()) { return null; } - return new java.lang.Long(target.getStart()); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - MapList target = (MapList) object; - // ignore null values for non optional primitives - if (value == null) { return; } - - target.setStart( ((java.lang.Long) value).longValue()); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return null; - } - }; - desc.setHandler(handler); - desc.setRequired(true); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _start - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); - { //-- local scope - org.exolab.castor.xml.validators.LongValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.LongValidator(); - fieldValidator.setValidator(typeValidator); + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return null; + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _from + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { // -- local scope + org.exolab.castor.xml.validators.LongValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.LongValidator(); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + // -- _to + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.Long.TYPE, "_to", "to", + org.exolab.castor.xml.NodeType.Attribute); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + MapList target = (MapList) object; + if (!target.hasTo()) { + return null; } - desc.setValidator(fieldValidator); - //-- _end - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Long.TYPE, "_end", "end", org.exolab.castor.xml.NodeType.Attribute); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - MapList target = (MapList) object; - if (!target.hasEnd()) { return null; } - return new java.lang.Long(target.getEnd()); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - MapList target = (MapList) object; - // ignore null values for non optional primitives - if (value == null) { return; } - - target.setEnd( ((java.lang.Long) value).longValue()); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return null; - } - }; - desc.setHandler(handler); - desc.setRequired(true); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _end - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); - { //-- local scope - org.exolab.castor.xml.validators.LongValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.LongValidator(); - fieldValidator.setValidator(typeValidator); + return new java.lang.Long(target.getTo()); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + MapList target = (MapList) object; + // if null, use delete method for optional primitives + if (value == null) { + target.deleteTo(); + return; + } + target.setTo(((java.lang.Long) value).longValue()); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- initialize element descriptors - + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return null; + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _to + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { // -- local scope + org.exolab.castor.xml.validators.LongValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.LongValidator(); + fieldValidator.setValidator(typeValidator); } + desc.setValidator(fieldValidator); + // -- _start + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.Long.TYPE, "_start", "start", + org.exolab.castor.xml.NodeType.Attribute); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + MapList target = (MapList) object; + if (!target.hasStart()) { + return null; + } + return new java.lang.Long(target.getStart()); + } + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + MapList target = (MapList) object; + // ignore null values for non optional primitives + if (value == null) { + return; + } - //-----------/ - //- Methods -/ - //-----------/ + target.setStart(((java.lang.Long) value).longValue()); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getAccessMode. - * - * @return the access mode specified for this class. - */ - public org.exolab.castor.mapping.AccessMode getAccessMode( - ) { + public java.lang.Object newInstance(java.lang.Object parent) { return null; - } + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); - /** - * Method getIdentity. - * - * @return the identity field, null if this class has no - * identity. - */ - public org.exolab.castor.mapping.FieldDescriptor getIdentity( - ) { - return _identity; + // -- validation code for: _start + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { // -- local scope + org.exolab.castor.xml.validators.LongValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.LongValidator(); + fieldValidator.setValidator(typeValidator); } + desc.setValidator(fieldValidator); + // -- _end + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.Long.TYPE, "_end", "end", + org.exolab.castor.xml.NodeType.Attribute); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + MapList target = (MapList) object; + if (!target.hasEnd()) { + return null; + } + return new java.lang.Long(target.getEnd()); + } - /** - * Method getJavaClass. - * - * @return the Java class represented by this descriptor. - */ - public java.lang.Class getJavaClass( - ) { - return uk.ac.vamsas.objects.core.MapList.class; - } + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + MapList target = (MapList) object; + // ignore null values for non optional primitives + if (value == null) { + return; + } - /** - * Method getNameSpacePrefix. - * - * @return the namespace prefix to use when marshaling as XML. - */ - public java.lang.String getNameSpacePrefix( - ) { - return _nsPrefix; - } + target.setEnd(((java.lang.Long) value).longValue()); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getNameSpaceURI. - * - * @return the namespace URI used when marshaling and - * unmarshaling as XML. - */ - public java.lang.String getNameSpaceURI( - ) { - return _nsURI; - } + public java.lang.Object newInstance(java.lang.Object parent) { + return null; + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); - /** - * Method getValidator. - * - * @return a specific validator for the class described by this - * ClassDescriptor. - */ - public org.exolab.castor.xml.TypeValidator getValidator( - ) { - return this; + // -- validation code for: _end + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { // -- local scope + org.exolab.castor.xml.validators.LongValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.LongValidator(); + fieldValidator.setValidator(typeValidator); } + desc.setValidator(fieldValidator); + // -- initialize element descriptors - /** - * Method getXMLName. - * - * @return the XML Name for the Class being described. - */ - public java.lang.String getXMLName( - ) { - return _xmlName; - } + } - /** - * Method isElementDefinition. - * - * @return true if XML schema definition of this Class is that - * of a global - * element or element with anonymous type definition. - */ - public boolean isElementDefinition( - ) { - return _elementDefinition; - } + // -----------/ + // - Methods -/ + // -----------/ + + /** + * Method getAccessMode. + * + * @return the access mode specified for this class. + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() { + return null; + } + + /** + * Method getIdentity. + * + * @return the identity field, null if this class has no identity. + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() { + return _identity; + } + + /** + * Method getJavaClass. + * + * @return the Java class represented by this descriptor. + */ + public java.lang.Class getJavaClass() { + return uk.ac.vamsas.objects.core.MapList.class; + } + + /** + * Method getNameSpacePrefix. + * + * @return the namespace prefix to use when marshaling as XML. + */ + public java.lang.String getNameSpacePrefix() { + return _nsPrefix; + } + + /** + * Method getNameSpaceURI. + * + * @return the namespace URI used when marshaling and unmarshaling as XML. + */ + public java.lang.String getNameSpaceURI() { + return _nsURI; + } + + /** + * Method getValidator. + * + * @return a specific validator for the class described by this + * ClassDescriptor. + */ + public org.exolab.castor.xml.TypeValidator getValidator() { + return this; + } + + /** + * Method getXMLName. + * + * @return the XML Name for the Class being described. + */ + public java.lang.String getXMLName() { + return _xmlName; + } + + /** + * Method isElementDefinition. + * + * @return true if XML schema definition of this Class is that of a global + * element or element with anonymous type definition. + */ + public boolean isElementDefinition() { + return _elementDefinition; + } } diff --git a/src/uk/ac/vamsas/objects/core/descriptors/MapRangeTypeDescriptor.java b/src/uk/ac/vamsas/objects/core/descriptors/MapRangeTypeDescriptor.java index 174449d..e7af789 100644 --- a/src/uk/ac/vamsas/objects/core/descriptors/MapRangeTypeDescriptor.java +++ b/src/uk/ac/vamsas/objects/core/descriptors/MapRangeTypeDescriptor.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core.descriptors; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import uk.ac.vamsas.objects.core.MapRangeType; @@ -18,183 +32,174 @@ import uk.ac.vamsas.objects.core.MapRangeType; * * @version $Revision$ $Date$ */ -public class MapRangeTypeDescriptor extends uk.ac.vamsas.objects.core.descriptors.RangeTypeDescriptor { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _elementDefinition. - */ - private boolean _elementDefinition; - - /** - * Field _nsPrefix. - */ - private java.lang.String _nsPrefix; - - /** - * Field _nsURI. - */ - private java.lang.String _nsURI; - - /** - * Field _xmlName. - */ - private java.lang.String _xmlName; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public MapRangeTypeDescriptor() { - super(); - setExtendsWithoutFlatten(new uk.ac.vamsas.objects.core.descriptors.RangeTypeDescriptor()); - _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; - _xmlName = "mapRangeType"; - _elementDefinition = false; - org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; - org.exolab.castor.mapping.FieldHandler handler = null; - org.exolab.castor.xml.FieldValidator fieldValidator = null; - //-- initialize attribute descriptors - - //-- _unit - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Long.TYPE, "_unit", "unit", org.exolab.castor.xml.NodeType.Attribute); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - MapRangeType target = (MapRangeType) object; - if (!target.hasUnit()) { return null; } - return new java.lang.Long(target.getUnit()); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - MapRangeType target = (MapRangeType) object; - // if null, use delete method for optional primitives - if (value == null) { - target.deleteUnit(); - return; - } - target.setUnit( ((java.lang.Long) value).longValue()); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return null; - } - }; - desc.setHandler(handler); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _unit - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope - org.exolab.castor.xml.validators.LongValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.LongValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setMinInclusive(1L); +public class MapRangeTypeDescriptor extends + uk.ac.vamsas.objects.core.descriptors.RangeTypeDescriptor { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _elementDefinition. + */ + private boolean _elementDefinition; + + /** + * Field _nsPrefix. + */ + private java.lang.String _nsPrefix; + + /** + * Field _nsURI. + */ + private java.lang.String _nsURI; + + /** + * Field _xmlName. + */ + private java.lang.String _xmlName; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public MapRangeTypeDescriptor() { + super(); + setExtendsWithoutFlatten(new uk.ac.vamsas.objects.core.descriptors.RangeTypeDescriptor()); + _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; + _xmlName = "mapRangeType"; + _elementDefinition = false; + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + // -- initialize attribute descriptors + + // -- _unit + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.Long.TYPE, "_unit", "unit", + org.exolab.castor.xml.NodeType.Attribute); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + MapRangeType target = (MapRangeType) object; + if (!target.hasUnit()) { + return null; } - desc.setValidator(fieldValidator); - //-- initialize element descriptors - - } - - - //-----------/ - //- Methods -/ - //-----------/ + return new java.lang.Long(target.getUnit()); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + MapRangeType target = (MapRangeType) object; + // if null, use delete method for optional primitives + if (value == null) { + target.deleteUnit(); + return; + } + target.setUnit(((java.lang.Long) value).longValue()); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getAccessMode. - * - * @return the access mode specified for this class. - */ - public org.exolab.castor.mapping.AccessMode getAccessMode( - ) { + public java.lang.Object newInstance(java.lang.Object parent) { return null; + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _unit + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { // -- local scope + org.exolab.castor.xml.validators.LongValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.LongValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setMinInclusive(1L); } - - /** - * Method getIdentity. - * - * @return the identity field, null if this class has no - * identity. - */ - public org.exolab.castor.mapping.FieldDescriptor getIdentity( - ) { - return super.getIdentity(); - } - - /** - * Method getJavaClass. - * - * @return the Java class represented by this descriptor. - */ - public java.lang.Class getJavaClass( - ) { - return uk.ac.vamsas.objects.core.MapRangeType.class; - } - - /** - * Method getNameSpacePrefix. - * - * @return the namespace prefix to use when marshaling as XML. - */ - public java.lang.String getNameSpacePrefix( - ) { - return _nsPrefix; - } - - /** - * Method getNameSpaceURI. - * - * @return the namespace URI used when marshaling and - * unmarshaling as XML. - */ - public java.lang.String getNameSpaceURI( - ) { - return _nsURI; - } - - /** - * Method getValidator. - * - * @return a specific validator for the class described by this - * ClassDescriptor. - */ - public org.exolab.castor.xml.TypeValidator getValidator( - ) { - return this; - } - - /** - * Method getXMLName. - * - * @return the XML Name for the Class being described. - */ - public java.lang.String getXMLName( - ) { - return _xmlName; - } - - /** - * Method isElementDefinition. - * - * @return true if XML schema definition of this Class is that - * of a global - * element or element with anonymous type definition. - */ - public boolean isElementDefinition( - ) { - return _elementDefinition; - } + desc.setValidator(fieldValidator); + // -- initialize element descriptors + + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * Method getAccessMode. + * + * @return the access mode specified for this class. + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() { + return null; + } + + /** + * Method getIdentity. + * + * @return the identity field, null if this class has no identity. + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() { + return super.getIdentity(); + } + + /** + * Method getJavaClass. + * + * @return the Java class represented by this descriptor. + */ + public java.lang.Class getJavaClass() { + return uk.ac.vamsas.objects.core.MapRangeType.class; + } + + /** + * Method getNameSpacePrefix. + * + * @return the namespace prefix to use when marshaling as XML. + */ + public java.lang.String getNameSpacePrefix() { + return _nsPrefix; + } + + /** + * Method getNameSpaceURI. + * + * @return the namespace URI used when marshaling and unmarshaling as XML. + */ + public java.lang.String getNameSpaceURI() { + return _nsURI; + } + + /** + * Method getValidator. + * + * @return a specific validator for the class described by this + * ClassDescriptor. + */ + public org.exolab.castor.xml.TypeValidator getValidator() { + return this; + } + + /** + * Method getXMLName. + * + * @return the XML Name for the Class being described. + */ + public java.lang.String getXMLName() { + return _xmlName; + } + + /** + * Method isElementDefinition. + * + * @return true if XML schema definition of this Class is that of a global + * element or element with anonymous type definition. + */ + public boolean isElementDefinition() { + return _elementDefinition; + } } diff --git a/src/uk/ac/vamsas/objects/core/descriptors/MapTypeDescriptor.java b/src/uk/ac/vamsas/objects/core/descriptors/MapTypeDescriptor.java index 39ee736..a6abd90 100644 --- a/src/uk/ac/vamsas/objects/core/descriptors/MapTypeDescriptor.java +++ b/src/uk/ac/vamsas/objects/core/descriptors/MapTypeDescriptor.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core.descriptors; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import uk.ac.vamsas.objects.core.MapType; @@ -18,213 +32,204 @@ import uk.ac.vamsas.objects.core.MapType; * * @version $Revision$ $Date$ */ -public class MapTypeDescriptor extends org.exolab.castor.xml.util.XMLClassDescriptorImpl { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _elementDefinition. - */ - private boolean _elementDefinition; - - /** - * Field _nsPrefix. - */ - private java.lang.String _nsPrefix; - - /** - * Field _nsURI. - */ - private java.lang.String _nsURI; - - /** - * Field _xmlName. - */ - private java.lang.String _xmlName; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public MapTypeDescriptor() { - super(); - _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; - _xmlName = "mapType"; - _elementDefinition = false; - - //-- set grouping compositor - setCompositorAsSequence(); - org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; - org.exolab.castor.mapping.FieldHandler handler = null; - org.exolab.castor.xml.FieldValidator fieldValidator = null; - //-- initialize attribute descriptors - - //-- initialize element descriptors - - //-- _local - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(uk.ac.vamsas.objects.core.Local.class, "_local", "local", org.exolab.castor.xml.NodeType.Element); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - MapType target = (MapType) object; - return target.getLocal(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - MapType target = (MapType) object; - target.setLocal( (uk.ac.vamsas.objects.core.Local) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new uk.ac.vamsas.objects.core.Local(); - } - }; - desc.setHandler(handler); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setRequired(true); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _local - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); - { //-- local scope - } - desc.setValidator(fieldValidator); - //-- _mapped - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(uk.ac.vamsas.objects.core.Mapped.class, "_mapped", "mapped", org.exolab.castor.xml.NodeType.Element); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - MapType target = (MapType) object; - return target.getMapped(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - MapType target = (MapType) object; - target.setMapped( (uk.ac.vamsas.objects.core.Mapped) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new uk.ac.vamsas.objects.core.Mapped(); - } - }; - desc.setHandler(handler); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setRequired(true); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _mapped - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); - { //-- local scope +public class MapTypeDescriptor extends + org.exolab.castor.xml.util.XMLClassDescriptorImpl { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _elementDefinition. + */ + private boolean _elementDefinition; + + /** + * Field _nsPrefix. + */ + private java.lang.String _nsPrefix; + + /** + * Field _nsURI. + */ + private java.lang.String _nsURI; + + /** + * Field _xmlName. + */ + private java.lang.String _xmlName; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public MapTypeDescriptor() { + super(); + _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; + _xmlName = "mapType"; + _elementDefinition = false; + + // -- set grouping compositor + setCompositorAsSequence(); + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + // -- initialize attribute descriptors + + // -- initialize element descriptors + + // -- _local + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + uk.ac.vamsas.objects.core.Local.class, "_local", "local", + org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + MapType target = (MapType) object; + return target.getLocal(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + MapType target = (MapType) object; + target.setLocal((uk.ac.vamsas.objects.core.Local) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - } - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Method getAccessMode. - * - * @return the access mode specified for this class. - */ - public org.exolab.castor.mapping.AccessMode getAccessMode( - ) { - return null; - } - - /** - * Method getIdentity. - * - * @return the identity field, null if this class has no - * identity. - */ - public org.exolab.castor.mapping.FieldDescriptor getIdentity( - ) { - return super.getIdentity(); + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return new uk.ac.vamsas.objects.core.Local(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _local + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { // -- local scope } - - /** - * Method getJavaClass. - * - * @return the Java class represented by this descriptor. - */ - public java.lang.Class getJavaClass( - ) { - return uk.ac.vamsas.objects.core.MapType.class; - } - - /** - * Method getNameSpacePrefix. - * - * @return the namespace prefix to use when marshaling as XML. - */ - public java.lang.String getNameSpacePrefix( - ) { - return _nsPrefix; - } - - /** - * Method getNameSpaceURI. - * - * @return the namespace URI used when marshaling and - * unmarshaling as XML. - */ - public java.lang.String getNameSpaceURI( - ) { - return _nsURI; - } - - /** - * Method getValidator. - * - * @return a specific validator for the class described by this - * ClassDescriptor. - */ - public org.exolab.castor.xml.TypeValidator getValidator( - ) { - return this; - } - - /** - * Method getXMLName. - * - * @return the XML Name for the Class being described. - */ - public java.lang.String getXMLName( - ) { - return _xmlName; - } - - /** - * Method isElementDefinition. - * - * @return true if XML schema definition of this Class is that - * of a global - * element or element with anonymous type definition. - */ - public boolean isElementDefinition( - ) { - return _elementDefinition; + desc.setValidator(fieldValidator); + // -- _mapped + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + uk.ac.vamsas.objects.core.Mapped.class, "_mapped", "mapped", + org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + MapType target = (MapType) object; + return target.getMapped(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + MapType target = (MapType) object; + target.setMapped((uk.ac.vamsas.objects.core.Mapped) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return new uk.ac.vamsas.objects.core.Mapped(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _mapped + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { // -- local scope } + desc.setValidator(fieldValidator); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * Method getAccessMode. + * + * @return the access mode specified for this class. + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() { + return null; + } + + /** + * Method getIdentity. + * + * @return the identity field, null if this class has no identity. + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() { + return super.getIdentity(); + } + + /** + * Method getJavaClass. + * + * @return the Java class represented by this descriptor. + */ + public java.lang.Class getJavaClass() { + return uk.ac.vamsas.objects.core.MapType.class; + } + + /** + * Method getNameSpacePrefix. + * + * @return the namespace prefix to use when marshaling as XML. + */ + public java.lang.String getNameSpacePrefix() { + return _nsPrefix; + } + + /** + * Method getNameSpaceURI. + * + * @return the namespace URI used when marshaling and unmarshaling as XML. + */ + public java.lang.String getNameSpaceURI() { + return _nsURI; + } + + /** + * Method getValidator. + * + * @return a specific validator for the class described by this + * ClassDescriptor. + */ + public org.exolab.castor.xml.TypeValidator getValidator() { + return this; + } + + /** + * Method getXMLName. + * + * @return the XML Name for the Class being described. + */ + public java.lang.String getXMLName() { + return _xmlName; + } + + /** + * Method isElementDefinition. + * + * @return true if XML schema definition of this Class is that of a global + * element or element with anonymous type definition. + */ + public boolean isElementDefinition() { + return _elementDefinition; + } } diff --git a/src/uk/ac/vamsas/objects/core/descriptors/MappedDescriptor.java b/src/uk/ac/vamsas/objects/core/descriptors/MappedDescriptor.java index 9162ab5..f5e7d8b 100644 --- a/src/uk/ac/vamsas/objects/core/descriptors/MappedDescriptor.java +++ b/src/uk/ac/vamsas/objects/core/descriptors/MappedDescriptor.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core.descriptors; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import uk.ac.vamsas.objects.core.Mapped; @@ -18,134 +32,121 @@ import uk.ac.vamsas.objects.core.Mapped; * * @version $Revision$ $Date$ */ -public class MappedDescriptor extends uk.ac.vamsas.objects.core.descriptors.MapRangeTypeDescriptor { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _elementDefinition. - */ - private boolean _elementDefinition; - - /** - * Field _nsPrefix. - */ - private java.lang.String _nsPrefix; - - /** - * Field _nsURI. - */ - private java.lang.String _nsURI; - - /** - * Field _xmlName. - */ - private java.lang.String _xmlName; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public MappedDescriptor() { - super(); - setExtendsWithoutFlatten(new uk.ac.vamsas.objects.core.descriptors.MapRangeTypeDescriptor()); - _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; - _xmlName = "mapped"; - _elementDefinition = true; - } - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Method getAccessMode. - * - * @return the access mode specified for this class. - */ - public org.exolab.castor.mapping.AccessMode getAccessMode( - ) { - return null; - } - - /** - * Method getIdentity. - * - * @return the identity field, null if this class has no - * identity. - */ - public org.exolab.castor.mapping.FieldDescriptor getIdentity( - ) { - return super.getIdentity(); - } - - /** - * Method getJavaClass. - * - * @return the Java class represented by this descriptor. - */ - public java.lang.Class getJavaClass( - ) { - return uk.ac.vamsas.objects.core.Mapped.class; - } - - /** - * Method getNameSpacePrefix. - * - * @return the namespace prefix to use when marshaling as XML. - */ - public java.lang.String getNameSpacePrefix( - ) { - return _nsPrefix; - } - - /** - * Method getNameSpaceURI. - * - * @return the namespace URI used when marshaling and - * unmarshaling as XML. - */ - public java.lang.String getNameSpaceURI( - ) { - return _nsURI; - } - - /** - * Method getValidator. - * - * @return a specific validator for the class described by this - * ClassDescriptor. - */ - public org.exolab.castor.xml.TypeValidator getValidator( - ) { - return this; - } - - /** - * Method getXMLName. - * - * @return the XML Name for the Class being described. - */ - public java.lang.String getXMLName( - ) { - return _xmlName; - } - - /** - * Method isElementDefinition. - * - * @return true if XML schema definition of this Class is that - * of a global - * element or element with anonymous type definition. - */ - public boolean isElementDefinition( - ) { - return _elementDefinition; - } +public class MappedDescriptor extends + uk.ac.vamsas.objects.core.descriptors.MapRangeTypeDescriptor { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _elementDefinition. + */ + private boolean _elementDefinition; + + /** + * Field _nsPrefix. + */ + private java.lang.String _nsPrefix; + + /** + * Field _nsURI. + */ + private java.lang.String _nsURI; + + /** + * Field _xmlName. + */ + private java.lang.String _xmlName; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public MappedDescriptor() { + super(); + setExtendsWithoutFlatten(new uk.ac.vamsas.objects.core.descriptors.MapRangeTypeDescriptor()); + _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; + _xmlName = "mapped"; + _elementDefinition = true; + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * Method getAccessMode. + * + * @return the access mode specified for this class. + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() { + return null; + } + + /** + * Method getIdentity. + * + * @return the identity field, null if this class has no identity. + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() { + return super.getIdentity(); + } + + /** + * Method getJavaClass. + * + * @return the Java class represented by this descriptor. + */ + public java.lang.Class getJavaClass() { + return uk.ac.vamsas.objects.core.Mapped.class; + } + + /** + * Method getNameSpacePrefix. + * + * @return the namespace prefix to use when marshaling as XML. + */ + public java.lang.String getNameSpacePrefix() { + return _nsPrefix; + } + + /** + * Method getNameSpaceURI. + * + * @return the namespace URI used when marshaling and unmarshaling as XML. + */ + public java.lang.String getNameSpaceURI() { + return _nsURI; + } + + /** + * Method getValidator. + * + * @return a specific validator for the class described by this + * ClassDescriptor. + */ + public org.exolab.castor.xml.TypeValidator getValidator() { + return this; + } + + /** + * Method getXMLName. + * + * @return the XML Name for the Class being described. + */ + public java.lang.String getXMLName() { + return _xmlName; + } + + /** + * Method isElementDefinition. + * + * @return true if XML schema definition of this Class is that of a global + * element or element with anonymous type definition. + */ + public boolean isElementDefinition() { + return _elementDefinition; + } } diff --git a/src/uk/ac/vamsas/objects/core/descriptors/MappingDescriptor.java b/src/uk/ac/vamsas/objects/core/descriptors/MappingDescriptor.java index a369678..5105668 100644 --- a/src/uk/ac/vamsas/objects/core/descriptors/MappingDescriptor.java +++ b/src/uk/ac/vamsas/objects/core/descriptors/MappingDescriptor.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core.descriptors; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import uk.ac.vamsas.objects.core.Mapping; @@ -18,187 +32,176 @@ import uk.ac.vamsas.objects.core.Mapping; * * @version $Revision$ $Date$ */ -public class MappingDescriptor extends uk.ac.vamsas.objects.core.descriptors.MapListDescriptor { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _elementDefinition. - */ - private boolean _elementDefinition; - - /** - * 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 MappingDescriptor() { - super(); - setExtendsWithoutFlatten(new uk.ac.vamsas.objects.core.descriptors.MapListDescriptor()); - _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; - _xmlName = "mapping"; - _elementDefinition = true; - org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; - org.exolab.castor.mapping.FieldHandler handler = null; - org.exolab.castor.xml.FieldValidator fieldValidator = null; - //-- initialize attribute descriptors - - //-- _onto - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Object.class, "_onto", "onto", org.exolab.castor.xml.NodeType.Attribute); - desc.setReference(true); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - Mapping target = (Mapping) object; - return target.getOnto(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Mapping target = (Mapping) object; - target.setOnto( (java.lang.Object) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new java.lang.Object(); - } - }; - desc.setHandler(handler); - desc.setRequired(true); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _onto - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); - { //-- local scope - org.exolab.castor.xml.validators.IdRefValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.IdRefValidator(); - fieldValidator.setValidator(typeValidator); - } - desc.setValidator(fieldValidator); - //-- initialize element descriptors - - } - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Method getAccessMode. - * - * @return the access mode specified for this class. - */ - public org.exolab.castor.mapping.AccessMode getAccessMode( - ) { - return null; - } - - /** - * Method getIdentity. - * - * @return the identity field, null if this class has no - * identity. - */ - public org.exolab.castor.mapping.FieldDescriptor getIdentity( - ) { - if (_identity == null) { - return super.getIdentity(); +public class MappingDescriptor extends + uk.ac.vamsas.objects.core.descriptors.MapListDescriptor { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _elementDefinition. + */ + private boolean _elementDefinition; + + /** + * 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 MappingDescriptor() { + super(); + setExtendsWithoutFlatten(new uk.ac.vamsas.objects.core.descriptors.MapListDescriptor()); + _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; + _xmlName = "mapping"; + _elementDefinition = true; + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + // -- initialize attribute descriptors + + // -- _onto + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.Object.class, "_onto", "onto", + org.exolab.castor.xml.NodeType.Attribute); + desc.setReference(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + Mapping target = (Mapping) object; + return target.getOnto(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Mapping target = (Mapping) object; + target.setOnto((java.lang.Object) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - return _identity; + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return new java.lang.Object(); + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _onto + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { // -- local scope + org.exolab.castor.xml.validators.IdRefValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.IdRefValidator(); + fieldValidator.setValidator(typeValidator); } - - /** - * Method getJavaClass. - * - * @return the Java class represented by this descriptor. - */ - public java.lang.Class getJavaClass( - ) { - return uk.ac.vamsas.objects.core.Mapping.class; - } - - /** - * Method getNameSpacePrefix. - * - * @return the namespace prefix to use when marshaling as XML. - */ - public java.lang.String getNameSpacePrefix( - ) { - return _nsPrefix; - } - - /** - * Method getNameSpaceURI. - * - * @return the namespace URI used when marshaling and - * unmarshaling as XML. - */ - public java.lang.String getNameSpaceURI( - ) { - return _nsURI; - } - - /** - * Method getValidator. - * - * @return a specific validator for the class described by this - * ClassDescriptor. - */ - public org.exolab.castor.xml.TypeValidator getValidator( - ) { - return this; - } - - /** - * Method getXMLName. - * - * @return the XML Name for the Class being described. - */ - public java.lang.String getXMLName( - ) { - return _xmlName; - } - - /** - * Method isElementDefinition. - * - * @return true if XML schema definition of this Class is that - * of a global - * element or element with anonymous type definition. - */ - public boolean isElementDefinition( - ) { - return _elementDefinition; + desc.setValidator(fieldValidator); + // -- initialize element descriptors + + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * Method getAccessMode. + * + * @return the access mode specified for this class. + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() { + return null; + } + + /** + * Method getIdentity. + * + * @return the identity field, null if this class has no identity. + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() { + if (_identity == null) { + return super.getIdentity(); } + return _identity; + } + + /** + * Method getJavaClass. + * + * @return the Java class represented by this descriptor. + */ + public java.lang.Class getJavaClass() { + return uk.ac.vamsas.objects.core.Mapping.class; + } + + /** + * Method getNameSpacePrefix. + * + * @return the namespace prefix to use when marshaling as XML. + */ + public java.lang.String getNameSpacePrefix() { + return _nsPrefix; + } + + /** + * Method getNameSpaceURI. + * + * @return the namespace URI used when marshaling and unmarshaling as XML. + */ + public java.lang.String getNameSpaceURI() { + return _nsURI; + } + + /** + * Method getValidator. + * + * @return a specific validator for the class described by this + * ClassDescriptor. + */ + public org.exolab.castor.xml.TypeValidator getValidator() { + return this; + } + + /** + * Method getXMLName. + * + * @return the XML Name for the Class being described. + */ + public java.lang.String getXMLName() { + return _xmlName; + } + + /** + * Method isElementDefinition. + * + * @return true if XML schema definition of this Class is that of a global + * element or element with anonymous type definition. + */ + public boolean isElementDefinition() { + return _elementDefinition; + } } diff --git a/src/uk/ac/vamsas/objects/core/descriptors/NewickDescriptor.java b/src/uk/ac/vamsas/objects/core/descriptors/NewickDescriptor.java index ba76c79..05a7425 100644 --- a/src/uk/ac/vamsas/objects/core/descriptors/NewickDescriptor.java +++ b/src/uk/ac/vamsas/objects/core/descriptors/NewickDescriptor.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core.descriptors; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import uk.ac.vamsas.objects.core.Newick; @@ -18,286 +32,281 @@ import uk.ac.vamsas.objects.core.Newick; * * @version $Revision$ $Date$ */ -public class NewickDescriptor extends org.exolab.castor.xml.util.XMLClassDescriptorImpl { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _elementDefinition. - */ - private boolean _elementDefinition; - - /** - * Field _nsPrefix. - */ - private java.lang.String _nsPrefix; - - /** - * Field _nsURI. - */ - private java.lang.String _nsURI; - - /** - * Field _xmlName. - */ - private java.lang.String _xmlName; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public NewickDescriptor() { - super(); - _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; - _xmlName = "newick"; - _elementDefinition = true; - org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; - org.exolab.castor.mapping.FieldHandler handler = null; - org.exolab.castor.xml.FieldValidator fieldValidator = null; - //-- _content - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_content", "PCDATA", org.exolab.castor.xml.NodeType.Text); - desc.setImmutable(true); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - Newick target = (Newick) object; - return target.getContent(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Newick target = (Newick) object; - target.setContent( (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: _content - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope - org.exolab.castor.xml.validators.StringValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.StringValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setWhiteSpace("preserve"); - } - desc.setValidator(fieldValidator); - //-- initialize attribute descriptors - - //-- _title - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_title", "title", 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 - { - Newick target = (Newick) object; - return target.getTitle(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Newick target = (Newick) object; - target.setTitle( (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); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _title - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope - org.exolab.castor.xml.validators.StringValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.StringValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setWhiteSpace("preserve"); - } - desc.setValidator(fieldValidator); - //-- _id - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_id", "id", org.exolab.castor.xml.NodeType.Attribute); - super.setIdentity(desc); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - Newick target = (Newick) object; - return target.getId(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Newick target = (Newick) object; - target.setId( (java.lang.String) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new java.lang.String(); - } - }; - desc.setHandler(handler); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _id - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope - org.exolab.castor.xml.validators.IdValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.IdValidator(); - fieldValidator.setValidator(typeValidator); - } - desc.setValidator(fieldValidator); - //-- _modifiable - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_modifiable", "modifiable", 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 - { - Newick target = (Newick) object; - return target.getModifiable(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Newick target = (Newick) object; - target.setModifiable( (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); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _modifiable - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope - org.exolab.castor.xml.validators.StringValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.StringValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setWhiteSpace("preserve"); +public class NewickDescriptor extends + org.exolab.castor.xml.util.XMLClassDescriptorImpl { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _elementDefinition. + */ + private boolean _elementDefinition; + + /** + * Field _nsPrefix. + */ + private java.lang.String _nsPrefix; + + /** + * Field _nsURI. + */ + private java.lang.String _nsURI; + + /** + * Field _xmlName. + */ + private java.lang.String _xmlName; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public NewickDescriptor() { + super(); + _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; + _xmlName = "newick"; + _elementDefinition = true; + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + // -- _content + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_content", "PCDATA", + org.exolab.castor.xml.NodeType.Text); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + Newick target = (Newick) object; + return target.getContent(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Newick target = (Newick) object; + target.setContent((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- initialize element descriptors - + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return null; + } + }; + desc.setHandler(handler); + addFieldDescriptor(desc); + + // -- validation code for: _content + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { // -- local scope + org.exolab.castor.xml.validators.StringValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.StringValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setWhiteSpace("preserve"); } + desc.setValidator(fieldValidator); + // -- initialize attribute descriptors + // -- _title + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_title", "title", + 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 { + Newick target = (Newick) object; + return target.getTitle(); + } - //-----------/ - //- Methods -/ - //-----------/ + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Newick target = (Newick) object; + target.setTitle((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getAccessMode. - * - * @return the access mode specified for this class. - */ - public org.exolab.castor.mapping.AccessMode getAccessMode( - ) { + public java.lang.Object newInstance(java.lang.Object parent) { return null; - } + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); - /** - * Method getIdentity. - * - * @return the identity field, null if this class has no - * identity. - */ - public org.exolab.castor.mapping.FieldDescriptor getIdentity( - ) { - return super.getIdentity(); + // -- validation code for: _title + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { // -- local scope + org.exolab.castor.xml.validators.StringValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.StringValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setWhiteSpace("preserve"); } + desc.setValidator(fieldValidator); + // -- _id + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_id", "id", + org.exolab.castor.xml.NodeType.Attribute); + super.setIdentity(desc); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + Newick target = (Newick) object; + return target.getId(); + } - /** - * Method getJavaClass. - * - * @return the Java class represented by this descriptor. - */ - public java.lang.Class getJavaClass( - ) { - return uk.ac.vamsas.objects.core.Newick.class; - } + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Newick target = (Newick) object; + target.setId((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getNameSpacePrefix. - * - * @return the namespace prefix to use when marshaling as XML. - */ - public java.lang.String getNameSpacePrefix( - ) { - return _nsPrefix; - } + public java.lang.Object newInstance(java.lang.Object parent) { + return new java.lang.String(); + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); - /** - * Method getNameSpaceURI. - * - * @return the namespace URI used when marshaling and - * unmarshaling as XML. - */ - public java.lang.String getNameSpaceURI( - ) { - return _nsURI; + // -- validation code for: _id + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { // -- local scope + org.exolab.castor.xml.validators.IdValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.IdValidator(); + fieldValidator.setValidator(typeValidator); } + desc.setValidator(fieldValidator); + // -- _modifiable + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_modifiable", "modifiable", + 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 { + Newick target = (Newick) object; + return target.getModifiable(); + } - /** - * Method getValidator. - * - * @return a specific validator for the class described by this - * ClassDescriptor. - */ - public org.exolab.castor.xml.TypeValidator getValidator( - ) { - return this; - } + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Newick target = (Newick) object; + target.setModifiable((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getXMLName. - * - * @return the XML Name for the Class being described. - */ - public java.lang.String getXMLName( - ) { - return _xmlName; - } + public java.lang.Object newInstance(java.lang.Object parent) { + return null; + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); - /** - * Method isElementDefinition. - * - * @return true if XML schema definition of this Class is that - * of a global - * element or element with anonymous type definition. - */ - public boolean isElementDefinition( - ) { - return _elementDefinition; + // -- validation code for: _modifiable + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { // -- local scope + org.exolab.castor.xml.validators.StringValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.StringValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setWhiteSpace("preserve"); } + desc.setValidator(fieldValidator); + // -- initialize element descriptors + + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * Method getAccessMode. + * + * @return the access mode specified for this class. + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() { + return null; + } + + /** + * Method getIdentity. + * + * @return the identity field, null if this class has no identity. + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() { + return super.getIdentity(); + } + + /** + * Method getJavaClass. + * + * @return the Java class represented by this descriptor. + */ + public java.lang.Class getJavaClass() { + return uk.ac.vamsas.objects.core.Newick.class; + } + + /** + * Method getNameSpacePrefix. + * + * @return the namespace prefix to use when marshaling as XML. + */ + public java.lang.String getNameSpacePrefix() { + return _nsPrefix; + } + + /** + * Method getNameSpaceURI. + * + * @return the namespace URI used when marshaling and unmarshaling as XML. + */ + public java.lang.String getNameSpaceURI() { + return _nsURI; + } + + /** + * Method getValidator. + * + * @return a specific validator for the class described by this + * ClassDescriptor. + */ + public org.exolab.castor.xml.TypeValidator getValidator() { + return this; + } + + /** + * Method getXMLName. + * + * @return the XML Name for the Class being described. + */ + public java.lang.String getXMLName() { + return _xmlName; + } + + /** + * Method isElementDefinition. + * + * @return true if XML schema definition of this Class is that of a global + * element or element with anonymous type definition. + */ + public boolean isElementDefinition() { + return _elementDefinition; + } } diff --git a/src/uk/ac/vamsas/objects/core/descriptors/NodeTypeDescriptor.java b/src/uk/ac/vamsas/objects/core/descriptors/NodeTypeDescriptor.java index 88f0791..69c0ae2 100644 --- a/src/uk/ac/vamsas/objects/core/descriptors/NodeTypeDescriptor.java +++ b/src/uk/ac/vamsas/objects/core/descriptors/NodeTypeDescriptor.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core.descriptors; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import uk.ac.vamsas.objects.core.NodeType; @@ -18,376 +32,379 @@ import uk.ac.vamsas.objects.core.NodeType; * * @version $Revision$ $Date$ */ -public class NodeTypeDescriptor extends org.exolab.castor.xml.util.XMLClassDescriptorImpl { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _elementDefinition. - */ - private boolean _elementDefinition; - - /** - * Field _nsPrefix. - */ - private java.lang.String _nsPrefix; - - /** - * Field _nsURI. - */ - private java.lang.String _nsURI; - - /** - * Field _xmlName. - */ - private java.lang.String _xmlName; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public NodeTypeDescriptor() { - super(); - _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; - _xmlName = "nodeType"; - _elementDefinition = false; - - //-- set grouping compositor - setCompositorAsSequence(); - org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; - org.exolab.castor.mapping.FieldHandler handler = null; - org.exolab.castor.xml.FieldValidator fieldValidator = null; - //-- initialize attribute descriptors - - //-- _id - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_id", "id", org.exolab.castor.xml.NodeType.Attribute); - super.setIdentity(desc); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - NodeType target = (NodeType) object; - return target.getId(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - NodeType target = (NodeType) object; - target.setId( (java.lang.String) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new java.lang.String(); - } - }; - desc.setHandler(handler); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _id - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope - org.exolab.castor.xml.validators.IdValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.IdValidator(); - fieldValidator.setValidator(typeValidator); - } - desc.setValidator(fieldValidator); - //-- _modifiable - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_modifiable", "modifiable", 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 - { - NodeType target = (NodeType) object; - return target.getModifiable(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - NodeType target = (NodeType) object; - target.setModifiable( (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); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _modifiable - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope - org.exolab.castor.xml.validators.StringValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.StringValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setWhiteSpace("preserve"); - } - desc.setValidator(fieldValidator); - //-- initialize element descriptors - - //-- _name - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_name", "name", org.exolab.castor.xml.NodeType.Element); - desc.setImmutable(true); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - NodeType target = (NodeType) object; - return target.getName(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - NodeType target = (NodeType) object; - target.setName( (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); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _name - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope - org.exolab.castor.xml.validators.StringValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.StringValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setWhiteSpace("preserve"); - } - desc.setValidator(fieldValidator); - //-- _description - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_description", "description", org.exolab.castor.xml.NodeType.Element); - desc.setImmutable(true); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - NodeType target = (NodeType) object; - return target.getDescription(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - NodeType target = (NodeType) object; - target.setDescription( (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); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _description - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope - org.exolab.castor.xml.validators.StringValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.StringValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setWhiteSpace("preserve"); - } - desc.setValidator(fieldValidator); - //-- _vrefList - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(uk.ac.vamsas.objects.core.Vref.class, "_vrefList", "vref", org.exolab.castor.xml.NodeType.Element); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - NodeType target = (NodeType) object; - return target.getVref(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - NodeType target = (NodeType) object; - target.addVref( (uk.ac.vamsas.objects.core.Vref) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public void resetValue(Object object) throws IllegalStateException, IllegalArgumentException { - try { - NodeType target = (NodeType) object; - target.removeAllVref(); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new uk.ac.vamsas.objects.core.Vref(); - } - }; - desc.setHandler(handler); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setMultivalued(true); - addFieldDescriptor(desc); - - //-- validation code for: _vrefList - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(0); - { //-- local scope +public class NodeTypeDescriptor extends + org.exolab.castor.xml.util.XMLClassDescriptorImpl { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _elementDefinition. + */ + private boolean _elementDefinition; + + /** + * Field _nsPrefix. + */ + private java.lang.String _nsPrefix; + + /** + * Field _nsURI. + */ + private java.lang.String _nsURI; + + /** + * Field _xmlName. + */ + private java.lang.String _xmlName; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public NodeTypeDescriptor() { + super(); + _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; + _xmlName = "nodeType"; + _elementDefinition = false; + + // -- set grouping compositor + setCompositorAsSequence(); + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + // -- initialize attribute descriptors + + // -- _id + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_id", "id", + org.exolab.castor.xml.NodeType.Attribute); + super.setIdentity(desc); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + NodeType target = (NodeType) object; + return target.getId(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + NodeType target = (NodeType) object; + target.setId((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- _propertyList - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(uk.ac.vamsas.objects.core.Property.class, "_propertyList", "property", org.exolab.castor.xml.NodeType.Element); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - NodeType target = (NodeType) object; - return target.getProperty(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - NodeType target = (NodeType) object; - target.addProperty( (uk.ac.vamsas.objects.core.Property) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public void resetValue(Object object) throws IllegalStateException, IllegalArgumentException { - try { - NodeType target = (NodeType) object; - target.removeAllProperty(); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new uk.ac.vamsas.objects.core.Property(); - } - }; - desc.setHandler(handler); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setMultivalued(true); - addFieldDescriptor(desc); - - //-- validation code for: _propertyList - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(0); - { //-- local scope + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return new java.lang.String(); + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _id + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { // -- local scope + org.exolab.castor.xml.validators.IdValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.IdValidator(); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + // -- _modifiable + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_modifiable", "modifiable", + 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 { + NodeType target = (NodeType) object; + return target.getModifiable(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + NodeType target = (NodeType) object; + target.setModifiable((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return null; + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _modifiable + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { // -- local scope + org.exolab.castor.xml.validators.StringValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.StringValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setWhiteSpace("preserve"); } + desc.setValidator(fieldValidator); + // -- initialize element descriptors + // -- _name + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_name", "name", + org.exolab.castor.xml.NodeType.Element); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + NodeType target = (NodeType) object; + return target.getName(); + } - //-----------/ - //- Methods -/ - //-----------/ + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + NodeType target = (NodeType) object; + target.setName((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getAccessMode. - * - * @return the access mode specified for this class. - */ - public org.exolab.castor.mapping.AccessMode getAccessMode( - ) { + public java.lang.Object newInstance(java.lang.Object parent) { return null; - } + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setMultivalued(false); + addFieldDescriptor(desc); - /** - * Method getIdentity. - * - * @return the identity field, null if this class has no - * identity. - */ - public org.exolab.castor.mapping.FieldDescriptor getIdentity( - ) { - return super.getIdentity(); + // -- validation code for: _name + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { // -- local scope + org.exolab.castor.xml.validators.StringValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.StringValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setWhiteSpace("preserve"); } + desc.setValidator(fieldValidator); + // -- _description + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_description", "description", + org.exolab.castor.xml.NodeType.Element); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + NodeType target = (NodeType) object; + return target.getDescription(); + } - /** - * Method getJavaClass. - * - * @return the Java class represented by this descriptor. - */ - public java.lang.Class getJavaClass( - ) { - return uk.ac.vamsas.objects.core.NodeType.class; - } + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + NodeType target = (NodeType) object; + target.setDescription((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getNameSpacePrefix. - * - * @return the namespace prefix to use when marshaling as XML. - */ - public java.lang.String getNameSpacePrefix( - ) { - return _nsPrefix; - } + public java.lang.Object newInstance(java.lang.Object parent) { + return null; + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setMultivalued(false); + addFieldDescriptor(desc); - /** - * Method getNameSpaceURI. - * - * @return the namespace URI used when marshaling and - * unmarshaling as XML. - */ - public java.lang.String getNameSpaceURI( - ) { - return _nsURI; + // -- validation code for: _description + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { // -- local scope + org.exolab.castor.xml.validators.StringValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.StringValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setWhiteSpace("preserve"); } + desc.setValidator(fieldValidator); + // -- _vrefList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + uk.ac.vamsas.objects.core.Vref.class, "_vrefList", "vref", + org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + NodeType target = (NodeType) object; + return target.getVref(); + } - /** - * Method getValidator. - * - * @return a specific validator for the class described by this - * ClassDescriptor. - */ - public org.exolab.castor.xml.TypeValidator getValidator( - ) { - return this; - } + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + NodeType target = (NodeType) object; + target.addVref((uk.ac.vamsas.objects.core.Vref) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + + public void resetValue(Object object) throws IllegalStateException, + IllegalArgumentException { + try { + NodeType target = (NodeType) object; + target.removeAllVref(); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getXMLName. - * - * @return the XML Name for the Class being described. - */ - public java.lang.String getXMLName( - ) { - return _xmlName; + public java.lang.Object newInstance(java.lang.Object parent) { + return new uk.ac.vamsas.objects.core.Vref(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + // -- validation code for: _vrefList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { // -- local scope } + desc.setValidator(fieldValidator); + // -- _propertyList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + uk.ac.vamsas.objects.core.Property.class, "_propertyList", "property", + org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + NodeType target = (NodeType) object; + return target.getProperty(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + NodeType target = (NodeType) object; + target.addProperty((uk.ac.vamsas.objects.core.Property) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method isElementDefinition. - * - * @return true if XML schema definition of this Class is that - * of a global - * element or element with anonymous type definition. - */ - public boolean isElementDefinition( - ) { - return _elementDefinition; + public void resetValue(Object object) throws IllegalStateException, + IllegalArgumentException { + try { + NodeType target = (NodeType) object; + target.removeAllProperty(); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return new uk.ac.vamsas.objects.core.Property(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + // -- validation code for: _propertyList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { // -- local scope } + desc.setValidator(fieldValidator); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * Method getAccessMode. + * + * @return the access mode specified for this class. + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() { + return null; + } + + /** + * Method getIdentity. + * + * @return the identity field, null if this class has no identity. + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() { + return super.getIdentity(); + } + + /** + * Method getJavaClass. + * + * @return the Java class represented by this descriptor. + */ + public java.lang.Class getJavaClass() { + return uk.ac.vamsas.objects.core.NodeType.class; + } + + /** + * Method getNameSpacePrefix. + * + * @return the namespace prefix to use when marshaling as XML. + */ + public java.lang.String getNameSpacePrefix() { + return _nsPrefix; + } + + /** + * Method getNameSpaceURI. + * + * @return the namespace URI used when marshaling and unmarshaling as XML. + */ + public java.lang.String getNameSpaceURI() { + return _nsURI; + } + + /** + * Method getValidator. + * + * @return a specific validator for the class described by this + * ClassDescriptor. + */ + public org.exolab.castor.xml.TypeValidator getValidator() { + return this; + } + + /** + * Method getXMLName. + * + * @return the XML Name for the Class being described. + */ + public java.lang.String getXMLName() { + return _xmlName; + } + + /** + * Method isElementDefinition. + * + * @return true if XML schema definition of this Class is that of a global + * element or element with anonymous type definition. + */ + public boolean isElementDefinition() { + return _elementDefinition; + } } diff --git a/src/uk/ac/vamsas/objects/core/descriptors/ParamDescriptor.java b/src/uk/ac/vamsas/objects/core/descriptors/ParamDescriptor.java index ce563d4..89211c6 100644 --- a/src/uk/ac/vamsas/objects/core/descriptors/ParamDescriptor.java +++ b/src/uk/ac/vamsas/objects/core/descriptors/ParamDescriptor.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core.descriptors; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import uk.ac.vamsas.objects.core.Param; @@ -18,254 +32,247 @@ import uk.ac.vamsas.objects.core.Param; * * @version $Revision$ $Date$ */ -public class ParamDescriptor extends org.exolab.castor.xml.util.XMLClassDescriptorImpl { - +public class ParamDescriptor extends + org.exolab.castor.xml.util.XMLClassDescriptorImpl { - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ - /** - * Field _elementDefinition. - */ - private boolean _elementDefinition; + /** + * Field _elementDefinition. + */ + private boolean _elementDefinition; - /** - * Field _nsPrefix. - */ - private java.lang.String _nsPrefix; + /** + * Field _nsPrefix. + */ + private java.lang.String _nsPrefix; - /** - * Field _nsURI. - */ - private java.lang.String _nsURI; + /** + * Field _nsURI. + */ + private java.lang.String _nsURI; - /** - * Field _xmlName. - */ - private java.lang.String _xmlName; + /** + * Field _xmlName. + */ + private java.lang.String _xmlName; + // ----------------/ + // - Constructors -/ + // ----------------/ - //----------------/ - //- Constructors -/ - //----------------/ + public ParamDescriptor() { + super(); + _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; + _xmlName = "param"; + _elementDefinition = true; + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + // -- _content + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_content", "PCDATA", + org.exolab.castor.xml.NodeType.Text); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + Param target = (Param) object; + return target.getContent(); + } - public ParamDescriptor() { - super(); - _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; - _xmlName = "param"; - _elementDefinition = true; - org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; - org.exolab.castor.mapping.FieldHandler handler = null; - org.exolab.castor.xml.FieldValidator fieldValidator = null; - //-- _content - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_content", "PCDATA", org.exolab.castor.xml.NodeType.Text); - desc.setImmutable(true); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - Param target = (Param) object; - return target.getContent(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Param target = (Param) object; - target.setContent( (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: _content - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope - org.exolab.castor.xml.validators.StringValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.StringValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setWhiteSpace("preserve"); - } - desc.setValidator(fieldValidator); - //-- initialize attribute descriptors - - //-- _name - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_name", "name", 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 - { - Param target = (Param) object; - return target.getName(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Param target = (Param) object; - target.setName( (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); - desc.setRequired(true); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _name - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); - { //-- local scope - org.exolab.castor.xml.validators.StringValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.StringValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setWhiteSpace("preserve"); + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Param target = (Param) object; + target.setContent((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- _type - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_type", "type", 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 - { - Param target = (Param) object; - return target.getType(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Param target = (Param) object; - target.setType( (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); - desc.setRequired(true); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _type - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); - { //-- local scope - org.exolab.castor.xml.validators.StringValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.StringValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setWhiteSpace("preserve"); - } - desc.setValidator(fieldValidator); - //-- initialize element descriptors - + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return null; + } + }; + desc.setHandler(handler); + addFieldDescriptor(desc); + + // -- validation code for: _content + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { // -- local scope + org.exolab.castor.xml.validators.StringValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.StringValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setWhiteSpace("preserve"); } + desc.setValidator(fieldValidator); + // -- initialize attribute descriptors + // -- _name + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_name", "name", + 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 { + Param target = (Param) object; + return target.getName(); + } - //-----------/ - //- Methods -/ - //-----------/ + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Param target = (Param) object; + target.setName((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getAccessMode. - * - * @return the access mode specified for this class. - */ - public org.exolab.castor.mapping.AccessMode getAccessMode( - ) { + public java.lang.Object newInstance(java.lang.Object parent) { return null; - } + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); - /** - * Method getIdentity. - * - * @return the identity field, null if this class has no - * identity. - */ - public org.exolab.castor.mapping.FieldDescriptor getIdentity( - ) { - return super.getIdentity(); + // -- validation code for: _name + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { // -- local scope + org.exolab.castor.xml.validators.StringValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.StringValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setWhiteSpace("preserve"); } + desc.setValidator(fieldValidator); + // -- _type + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_type", "type", + 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 { + Param target = (Param) object; + return target.getType(); + } - /** - * Method getJavaClass. - * - * @return the Java class represented by this descriptor. - */ - public java.lang.Class getJavaClass( - ) { - return uk.ac.vamsas.objects.core.Param.class; - } + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Param target = (Param) object; + target.setType((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getNameSpacePrefix. - * - * @return the namespace prefix to use when marshaling as XML. - */ - public java.lang.String getNameSpacePrefix( - ) { - return _nsPrefix; - } + public java.lang.Object newInstance(java.lang.Object parent) { + return null; + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); - /** - * Method getNameSpaceURI. - * - * @return the namespace URI used when marshaling and - * unmarshaling as XML. - */ - public java.lang.String getNameSpaceURI( - ) { - return _nsURI; + // -- validation code for: _type + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { // -- local scope + org.exolab.castor.xml.validators.StringValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.StringValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setWhiteSpace("preserve"); } + desc.setValidator(fieldValidator); + // -- initialize element descriptors - /** - * Method getValidator. - * - * @return a specific validator for the class described by this - * ClassDescriptor. - */ - public org.exolab.castor.xml.TypeValidator getValidator( - ) { - return this; - } + } - /** - * Method getXMLName. - * - * @return the XML Name for the Class being described. - */ - public java.lang.String getXMLName( - ) { - return _xmlName; - } + // -----------/ + // - Methods -/ + // -----------/ - /** - * Method isElementDefinition. - * - * @return true if XML schema definition of this Class is that - * of a global - * element or element with anonymous type definition. - */ - public boolean isElementDefinition( - ) { - return _elementDefinition; - } + /** + * Method getAccessMode. + * + * @return the access mode specified for this class. + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() { + return null; + } + + /** + * Method getIdentity. + * + * @return the identity field, null if this class has no identity. + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() { + return super.getIdentity(); + } + + /** + * Method getJavaClass. + * + * @return the Java class represented by this descriptor. + */ + public java.lang.Class getJavaClass() { + return uk.ac.vamsas.objects.core.Param.class; + } + + /** + * Method getNameSpacePrefix. + * + * @return the namespace prefix to use when marshaling as XML. + */ + public java.lang.String getNameSpacePrefix() { + return _nsPrefix; + } + + /** + * Method getNameSpaceURI. + * + * @return the namespace URI used when marshaling and unmarshaling as XML. + */ + public java.lang.String getNameSpaceURI() { + return _nsURI; + } + + /** + * Method getValidator. + * + * @return a specific validator for the class described by this + * ClassDescriptor. + */ + public org.exolab.castor.xml.TypeValidator getValidator() { + return this; + } + + /** + * Method getXMLName. + * + * @return the XML Name for the Class being described. + */ + public java.lang.String getXMLName() { + return _xmlName; + } + + /** + * Method isElementDefinition. + * + * @return true if XML schema definition of this Class is that of a global + * element or element with anonymous type definition. + */ + public boolean isElementDefinition() { + return _elementDefinition; + } } diff --git a/src/uk/ac/vamsas/objects/core/descriptors/PosDescriptor.java b/src/uk/ac/vamsas/objects/core/descriptors/PosDescriptor.java index 5c8c8d8..c7a3676 100644 --- a/src/uk/ac/vamsas/objects/core/descriptors/PosDescriptor.java +++ b/src/uk/ac/vamsas/objects/core/descriptors/PosDescriptor.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core.descriptors; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import uk.ac.vamsas.objects.core.Pos; @@ -18,183 +32,176 @@ import uk.ac.vamsas.objects.core.Pos; * * @version $Revision$ $Date$ */ -public class PosDescriptor extends org.exolab.castor.xml.util.XMLClassDescriptorImpl { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _elementDefinition. - */ - private boolean _elementDefinition; - - /** - * Field _nsPrefix. - */ - private java.lang.String _nsPrefix; - - /** - * Field _nsURI. - */ - private java.lang.String _nsURI; - - /** - * Field _xmlName. - */ - private java.lang.String _xmlName; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public PosDescriptor() { - super(); - _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; - _xmlName = "pos"; - _elementDefinition = true; - org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; - org.exolab.castor.mapping.FieldHandler handler = null; - org.exolab.castor.xml.FieldValidator fieldValidator = null; - //-- initialize attribute descriptors - - //-- _i - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Integer.TYPE, "_i", "i", org.exolab.castor.xml.NodeType.Attribute); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - Pos target = (Pos) object; - if (!target.hasI()) { return null; } - return new java.lang.Integer(target.getI()); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Pos target = (Pos) object; - // ignore null values for non optional primitives - if (value == null) { return; } - - target.setI( ((java.lang.Integer) value).intValue()); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return null; - } - }; - desc.setHandler(handler); - desc.setRequired(true); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _i - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); - { //-- local scope - org.exolab.castor.xml.validators.IntValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.IntValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setMinInclusive(-2147483648); - typeValidator.setMaxInclusive(2147483647); +public class PosDescriptor extends + org.exolab.castor.xml.util.XMLClassDescriptorImpl { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _elementDefinition. + */ + private boolean _elementDefinition; + + /** + * Field _nsPrefix. + */ + private java.lang.String _nsPrefix; + + /** + * Field _nsURI. + */ + private java.lang.String _nsURI; + + /** + * Field _xmlName. + */ + private java.lang.String _xmlName; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public PosDescriptor() { + super(); + _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; + _xmlName = "pos"; + _elementDefinition = true; + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + // -- initialize attribute descriptors + + // -- _i + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.Integer.TYPE, "_i", "i", + org.exolab.castor.xml.NodeType.Attribute); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + Pos target = (Pos) object; + if (!target.hasI()) { + return null; } - desc.setValidator(fieldValidator); - //-- initialize element descriptors - - } - - - //-----------/ - //- Methods -/ - //-----------/ + return new java.lang.Integer(target.getI()); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Pos target = (Pos) object; + // ignore null values for non optional primitives + if (value == null) { + return; + } + + target.setI(((java.lang.Integer) value).intValue()); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getAccessMode. - * - * @return the access mode specified for this class. - */ - public org.exolab.castor.mapping.AccessMode getAccessMode( - ) { + public java.lang.Object newInstance(java.lang.Object parent) { return null; + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _i + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { // -- local scope + org.exolab.castor.xml.validators.IntValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.IntValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setMinInclusive(-2147483648); + typeValidator.setMaxInclusive(2147483647); } - - /** - * Method getIdentity. - * - * @return the identity field, null if this class has no - * identity. - */ - public org.exolab.castor.mapping.FieldDescriptor getIdentity( - ) { - return super.getIdentity(); - } - - /** - * Method getJavaClass. - * - * @return the Java class represented by this descriptor. - */ - public java.lang.Class getJavaClass( - ) { - return uk.ac.vamsas.objects.core.Pos.class; - } - - /** - * Method getNameSpacePrefix. - * - * @return the namespace prefix to use when marshaling as XML. - */ - public java.lang.String getNameSpacePrefix( - ) { - return _nsPrefix; - } - - /** - * Method getNameSpaceURI. - * - * @return the namespace URI used when marshaling and - * unmarshaling as XML. - */ - public java.lang.String getNameSpaceURI( - ) { - return _nsURI; - } - - /** - * Method getValidator. - * - * @return a specific validator for the class described by this - * ClassDescriptor. - */ - public org.exolab.castor.xml.TypeValidator getValidator( - ) { - return this; - } - - /** - * Method getXMLName. - * - * @return the XML Name for the Class being described. - */ - public java.lang.String getXMLName( - ) { - return _xmlName; - } - - /** - * Method isElementDefinition. - * - * @return true if XML schema definition of this Class is that - * of a global - * element or element with anonymous type definition. - */ - public boolean isElementDefinition( - ) { - return _elementDefinition; - } + desc.setValidator(fieldValidator); + // -- initialize element descriptors + + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * Method getAccessMode. + * + * @return the access mode specified for this class. + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() { + return null; + } + + /** + * Method getIdentity. + * + * @return the identity field, null if this class has no identity. + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() { + return super.getIdentity(); + } + + /** + * Method getJavaClass. + * + * @return the Java class represented by this descriptor. + */ + public java.lang.Class getJavaClass() { + return uk.ac.vamsas.objects.core.Pos.class; + } + + /** + * Method getNameSpacePrefix. + * + * @return the namespace prefix to use when marshaling as XML. + */ + public java.lang.String getNameSpacePrefix() { + return _nsPrefix; + } + + /** + * Method getNameSpaceURI. + * + * @return the namespace URI used when marshaling and unmarshaling as XML. + */ + public java.lang.String getNameSpaceURI() { + return _nsURI; + } + + /** + * Method getValidator. + * + * @return a specific validator for the class described by this + * ClassDescriptor. + */ + public org.exolab.castor.xml.TypeValidator getValidator() { + return this; + } + + /** + * Method getXMLName. + * + * @return the XML Name for the Class being described. + */ + public java.lang.String getXMLName() { + return _xmlName; + } + + /** + * Method isElementDefinition. + * + * @return true if XML schema definition of this Class is that of a global + * element or element with anonymous type definition. + */ + public boolean isElementDefinition() { + return _elementDefinition; + } } diff --git a/src/uk/ac/vamsas/objects/core/descriptors/PropertyDescriptor.java b/src/uk/ac/vamsas/objects/core/descriptors/PropertyDescriptor.java index aaf5f97..8a92e0f 100644 --- a/src/uk/ac/vamsas/objects/core/descriptors/PropertyDescriptor.java +++ b/src/uk/ac/vamsas/objects/core/descriptors/PropertyDescriptor.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core.descriptors; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import uk.ac.vamsas.objects.core.Property; @@ -18,254 +32,247 @@ import uk.ac.vamsas.objects.core.Property; * * @version $Revision$ $Date$ */ -public class PropertyDescriptor extends org.exolab.castor.xml.util.XMLClassDescriptorImpl { - +public class PropertyDescriptor extends + org.exolab.castor.xml.util.XMLClassDescriptorImpl { - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ - /** - * Field _elementDefinition. - */ - private boolean _elementDefinition; + /** + * Field _elementDefinition. + */ + private boolean _elementDefinition; - /** - * Field _nsPrefix. - */ - private java.lang.String _nsPrefix; + /** + * Field _nsPrefix. + */ + private java.lang.String _nsPrefix; - /** - * Field _nsURI. - */ - private java.lang.String _nsURI; + /** + * Field _nsURI. + */ + private java.lang.String _nsURI; - /** - * Field _xmlName. - */ - private java.lang.String _xmlName; + /** + * Field _xmlName. + */ + private java.lang.String _xmlName; + // ----------------/ + // - Constructors -/ + // ----------------/ - //----------------/ - //- Constructors -/ - //----------------/ + public PropertyDescriptor() { + super(); + _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; + _xmlName = "property"; + _elementDefinition = true; + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + // -- _content + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_content", "PCDATA", + org.exolab.castor.xml.NodeType.Text); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + Property target = (Property) object; + return target.getContent(); + } - public PropertyDescriptor() { - super(); - _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; - _xmlName = "property"; - _elementDefinition = true; - org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; - org.exolab.castor.mapping.FieldHandler handler = null; - org.exolab.castor.xml.FieldValidator fieldValidator = null; - //-- _content - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_content", "PCDATA", org.exolab.castor.xml.NodeType.Text); - desc.setImmutable(true); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - Property target = (Property) object; - return target.getContent(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Property target = (Property) object; - target.setContent( (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: _content - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope - org.exolab.castor.xml.validators.StringValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.StringValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setWhiteSpace("preserve"); - } - desc.setValidator(fieldValidator); - //-- initialize attribute descriptors - - //-- _name - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_name", "name", 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 - { - Property target = (Property) object; - return target.getName(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Property target = (Property) object; - target.setName( (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); - desc.setRequired(true); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _name - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); - { //-- local scope - org.exolab.castor.xml.validators.StringValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.StringValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setWhiteSpace("preserve"); + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Property target = (Property) object; + target.setContent((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- _type - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_type", "type", 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 - { - Property target = (Property) object; - return target.getType(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Property target = (Property) object; - target.setType( (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); - desc.setRequired(true); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _type - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); - { //-- local scope - org.exolab.castor.xml.validators.StringValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.StringValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setWhiteSpace("preserve"); - } - desc.setValidator(fieldValidator); - //-- initialize element descriptors - + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return null; + } + }; + desc.setHandler(handler); + addFieldDescriptor(desc); + + // -- validation code for: _content + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { // -- local scope + org.exolab.castor.xml.validators.StringValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.StringValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setWhiteSpace("preserve"); } + desc.setValidator(fieldValidator); + // -- initialize attribute descriptors + // -- _name + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_name", "name", + 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 { + Property target = (Property) object; + return target.getName(); + } - //-----------/ - //- Methods -/ - //-----------/ + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Property target = (Property) object; + target.setName((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getAccessMode. - * - * @return the access mode specified for this class. - */ - public org.exolab.castor.mapping.AccessMode getAccessMode( - ) { + public java.lang.Object newInstance(java.lang.Object parent) { return null; - } + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); - /** - * Method getIdentity. - * - * @return the identity field, null if this class has no - * identity. - */ - public org.exolab.castor.mapping.FieldDescriptor getIdentity( - ) { - return super.getIdentity(); + // -- validation code for: _name + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { // -- local scope + org.exolab.castor.xml.validators.StringValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.StringValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setWhiteSpace("preserve"); } + desc.setValidator(fieldValidator); + // -- _type + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_type", "type", + 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 { + Property target = (Property) object; + return target.getType(); + } - /** - * Method getJavaClass. - * - * @return the Java class represented by this descriptor. - */ - public java.lang.Class getJavaClass( - ) { - return uk.ac.vamsas.objects.core.Property.class; - } + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Property target = (Property) object; + target.setType((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getNameSpacePrefix. - * - * @return the namespace prefix to use when marshaling as XML. - */ - public java.lang.String getNameSpacePrefix( - ) { - return _nsPrefix; - } + public java.lang.Object newInstance(java.lang.Object parent) { + return null; + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); - /** - * Method getNameSpaceURI. - * - * @return the namespace URI used when marshaling and - * unmarshaling as XML. - */ - public java.lang.String getNameSpaceURI( - ) { - return _nsURI; + // -- validation code for: _type + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { // -- local scope + org.exolab.castor.xml.validators.StringValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.StringValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setWhiteSpace("preserve"); } + desc.setValidator(fieldValidator); + // -- initialize element descriptors - /** - * Method getValidator. - * - * @return a specific validator for the class described by this - * ClassDescriptor. - */ - public org.exolab.castor.xml.TypeValidator getValidator( - ) { - return this; - } + } - /** - * Method getXMLName. - * - * @return the XML Name for the Class being described. - */ - public java.lang.String getXMLName( - ) { - return _xmlName; - } + // -----------/ + // - Methods -/ + // -----------/ - /** - * Method isElementDefinition. - * - * @return true if XML schema definition of this Class is that - * of a global - * element or element with anonymous type definition. - */ - public boolean isElementDefinition( - ) { - return _elementDefinition; - } + /** + * Method getAccessMode. + * + * @return the access mode specified for this class. + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() { + return null; + } + + /** + * Method getIdentity. + * + * @return the identity field, null if this class has no identity. + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() { + return super.getIdentity(); + } + + /** + * Method getJavaClass. + * + * @return the Java class represented by this descriptor. + */ + public java.lang.Class getJavaClass() { + return uk.ac.vamsas.objects.core.Property.class; + } + + /** + * Method getNameSpacePrefix. + * + * @return the namespace prefix to use when marshaling as XML. + */ + public java.lang.String getNameSpacePrefix() { + return _nsPrefix; + } + + /** + * Method getNameSpaceURI. + * + * @return the namespace URI used when marshaling and unmarshaling as XML. + */ + public java.lang.String getNameSpaceURI() { + return _nsURI; + } + + /** + * Method getValidator. + * + * @return a specific validator for the class described by this + * ClassDescriptor. + */ + public org.exolab.castor.xml.TypeValidator getValidator() { + return this; + } + + /** + * Method getXMLName. + * + * @return the XML Name for the Class being described. + */ + public java.lang.String getXMLName() { + return _xmlName; + } + + /** + * Method isElementDefinition. + * + * @return true if XML schema definition of this Class is that of a global + * element or element with anonymous type definition. + */ + public boolean isElementDefinition() { + return _elementDefinition; + } } diff --git a/src/uk/ac/vamsas/objects/core/descriptors/ProvenanceDescriptor.java b/src/uk/ac/vamsas/objects/core/descriptors/ProvenanceDescriptor.java index 3572880..91466d4 100644 --- a/src/uk/ac/vamsas/objects/core/descriptors/ProvenanceDescriptor.java +++ b/src/uk/ac/vamsas/objects/core/descriptors/ProvenanceDescriptor.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core.descriptors; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import uk.ac.vamsas.objects.core.Provenance; @@ -18,186 +32,177 @@ import uk.ac.vamsas.objects.core.Provenance; * * @version $Revision$ $Date$ */ -public class ProvenanceDescriptor extends org.exolab.castor.xml.util.XMLClassDescriptorImpl { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _elementDefinition. - */ - private boolean _elementDefinition; - - /** - * Field _nsPrefix. - */ - private java.lang.String _nsPrefix; - - /** - * Field _nsURI. - */ - private java.lang.String _nsURI; - - /** - * Field _xmlName. - */ - private java.lang.String _xmlName; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public ProvenanceDescriptor() { - super(); - _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; - _xmlName = "Provenance"; - _elementDefinition = true; - - //-- set grouping compositor - setCompositorAsSequence(); - org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; - org.exolab.castor.mapping.FieldHandler handler = null; - org.exolab.castor.xml.FieldValidator fieldValidator = null; - //-- initialize attribute descriptors - - //-- initialize element descriptors - - //-- _entryList - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(uk.ac.vamsas.objects.core.Entry.class, "_entryList", "entry", org.exolab.castor.xml.NodeType.Element); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - Provenance target = (Provenance) object; - return target.getEntry(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Provenance target = (Provenance) object; - target.addEntry( (uk.ac.vamsas.objects.core.Entry) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public void resetValue(Object object) throws IllegalStateException, IllegalArgumentException { - try { - Provenance target = (Provenance) object; - target.removeAllEntry(); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new uk.ac.vamsas.objects.core.Entry(); - } - }; - desc.setHandler(handler); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setRequired(true); - desc.setMultivalued(true); - addFieldDescriptor(desc); - - //-- validation code for: _entryList - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); - { //-- local scope +public class ProvenanceDescriptor extends + org.exolab.castor.xml.util.XMLClassDescriptorImpl { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _elementDefinition. + */ + private boolean _elementDefinition; + + /** + * Field _nsPrefix. + */ + private java.lang.String _nsPrefix; + + /** + * Field _nsURI. + */ + private java.lang.String _nsURI; + + /** + * Field _xmlName. + */ + private java.lang.String _xmlName; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public ProvenanceDescriptor() { + super(); + _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; + _xmlName = "Provenance"; + _elementDefinition = true; + + // -- set grouping compositor + setCompositorAsSequence(); + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + // -- initialize attribute descriptors + + // -- initialize element descriptors + + // -- _entryList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + uk.ac.vamsas.objects.core.Entry.class, "_entryList", "entry", + org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + Provenance target = (Provenance) object; + return target.getEntry(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Provenance target = (Provenance) object; + target.addEntry((uk.ac.vamsas.objects.core.Entry) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - } - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Method getAccessMode. - * - * @return the access mode specified for this class. - */ - public org.exolab.castor.mapping.AccessMode getAccessMode( - ) { - return null; - } - - /** - * Method getIdentity. - * - * @return the identity field, null if this class has no - * identity. - */ - public org.exolab.castor.mapping.FieldDescriptor getIdentity( - ) { - return super.getIdentity(); - } - - /** - * Method getJavaClass. - * - * @return the Java class represented by this descriptor. - */ - public java.lang.Class getJavaClass( - ) { - return uk.ac.vamsas.objects.core.Provenance.class; - } - - /** - * Method getNameSpacePrefix. - * - * @return the namespace prefix to use when marshaling as XML. - */ - public java.lang.String getNameSpacePrefix( - ) { - return _nsPrefix; - } - - /** - * Method getNameSpaceURI. - * - * @return the namespace URI used when marshaling and - * unmarshaling as XML. - */ - public java.lang.String getNameSpaceURI( - ) { - return _nsURI; - } - - /** - * Method getValidator. - * - * @return a specific validator for the class described by this - * ClassDescriptor. - */ - public org.exolab.castor.xml.TypeValidator getValidator( - ) { - return this; - } - - /** - * Method getXMLName. - * - * @return the XML Name for the Class being described. - */ - public java.lang.String getXMLName( - ) { - return _xmlName; - } - - /** - * Method isElementDefinition. - * - * @return true if XML schema definition of this Class is that - * of a global - * element or element with anonymous type definition. - */ - public boolean isElementDefinition( - ) { - return _elementDefinition; + } + + public void resetValue(Object object) throws IllegalStateException, + IllegalArgumentException { + try { + Provenance target = (Provenance) object; + target.removeAllEntry(); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return new uk.ac.vamsas.objects.core.Entry(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setRequired(true); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + // -- validation code for: _entryList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { // -- local scope } + desc.setValidator(fieldValidator); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * Method getAccessMode. + * + * @return the access mode specified for this class. + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() { + return null; + } + + /** + * Method getIdentity. + * + * @return the identity field, null if this class has no identity. + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() { + return super.getIdentity(); + } + + /** + * Method getJavaClass. + * + * @return the Java class represented by this descriptor. + */ + public java.lang.Class getJavaClass() { + return uk.ac.vamsas.objects.core.Provenance.class; + } + + /** + * Method getNameSpacePrefix. + * + * @return the namespace prefix to use when marshaling as XML. + */ + public java.lang.String getNameSpacePrefix() { + return _nsPrefix; + } + + /** + * Method getNameSpaceURI. + * + * @return the namespace URI used when marshaling and unmarshaling as XML. + */ + public java.lang.String getNameSpaceURI() { + return _nsURI; + } + + /** + * Method getValidator. + * + * @return a specific validator for the class described by this + * ClassDescriptor. + */ + public org.exolab.castor.xml.TypeValidator getValidator() { + return this; + } + + /** + * Method getXMLName. + * + * @return the XML Name for the Class being described. + */ + public java.lang.String getXMLName() { + return _xmlName; + } + + /** + * Method isElementDefinition. + * + * @return true if XML schema definition of this Class is that of a global + * element or element with anonymous type definition. + */ + public boolean isElementDefinition() { + return _elementDefinition; + } } diff --git a/src/uk/ac/vamsas/objects/core/descriptors/RangeAnnotationDescriptor.java b/src/uk/ac/vamsas/objects/core/descriptors/RangeAnnotationDescriptor.java index 6d3be6a..a70b904 100644 --- a/src/uk/ac/vamsas/objects/core/descriptors/RangeAnnotationDescriptor.java +++ b/src/uk/ac/vamsas/objects/core/descriptors/RangeAnnotationDescriptor.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core.descriptors; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import uk.ac.vamsas.objects.core.RangeAnnotation; @@ -18,575 +32,594 @@ import uk.ac.vamsas.objects.core.RangeAnnotation; * * @version $Revision$ $Date$ */ -public class RangeAnnotationDescriptor extends uk.ac.vamsas.objects.core.descriptors.RangeTypeDescriptor { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _elementDefinition. - */ - private boolean _elementDefinition; - - /** - * Field _nsPrefix. - */ - private java.lang.String _nsPrefix; - - /** - * Field _nsURI. - */ - private java.lang.String _nsURI; - - /** - * Field _xmlName. - */ - private java.lang.String _xmlName; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public RangeAnnotationDescriptor() { - super(); - setExtendsWithoutFlatten(new uk.ac.vamsas.objects.core.descriptors.RangeTypeDescriptor()); - _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; - _xmlName = "rangeAnnotation"; - _elementDefinition = false; - - //-- set grouping compositor - setCompositorAsSequence(); - org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; - org.exolab.castor.mapping.FieldHandler handler = null; - org.exolab.castor.xml.FieldValidator fieldValidator = null; - //-- initialize attribute descriptors - - //-- _id - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_id", "id", org.exolab.castor.xml.NodeType.Attribute); - super.setIdentity(desc); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - RangeAnnotation target = (RangeAnnotation) object; - return target.getId(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - RangeAnnotation target = (RangeAnnotation) object; - target.setId( (java.lang.String) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new java.lang.String(); - } - }; - desc.setHandler(handler); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _id - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope - org.exolab.castor.xml.validators.IdValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.IdValidator(); - fieldValidator.setValidator(typeValidator); +public class RangeAnnotationDescriptor extends + uk.ac.vamsas.objects.core.descriptors.RangeTypeDescriptor { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _elementDefinition. + */ + private boolean _elementDefinition; + + /** + * Field _nsPrefix. + */ + private java.lang.String _nsPrefix; + + /** + * Field _nsURI. + */ + private java.lang.String _nsURI; + + /** + * Field _xmlName. + */ + private java.lang.String _xmlName; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public RangeAnnotationDescriptor() { + super(); + setExtendsWithoutFlatten(new uk.ac.vamsas.objects.core.descriptors.RangeTypeDescriptor()); + _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; + _xmlName = "rangeAnnotation"; + _elementDefinition = false; + + // -- set grouping compositor + setCompositorAsSequence(); + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + // -- initialize attribute descriptors + + // -- _id + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_id", "id", + org.exolab.castor.xml.NodeType.Attribute); + super.setIdentity(desc); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + RangeAnnotation target = (RangeAnnotation) object; + return target.getId(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + RangeAnnotation target = (RangeAnnotation) object; + target.setId((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- _modifiable - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_modifiable", "modifiable", 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 - { - RangeAnnotation target = (RangeAnnotation) object; - return target.getModifiable(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - RangeAnnotation target = (RangeAnnotation) object; - target.setModifiable( (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); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _modifiable - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope - org.exolab.castor.xml.validators.StringValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.StringValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setWhiteSpace("preserve"); + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return new java.lang.String(); + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _id + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { // -- local scope + org.exolab.castor.xml.validators.IdValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.IdValidator(); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + // -- _modifiable + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_modifiable", "modifiable", + 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 { + RangeAnnotation target = (RangeAnnotation) object; + return target.getModifiable(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + RangeAnnotation target = (RangeAnnotation) object; + target.setModifiable((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- _group - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_group", "group", 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 - { - RangeAnnotation target = (RangeAnnotation) object; - return target.getGroup(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - RangeAnnotation target = (RangeAnnotation) object; - target.setGroup( (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); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _group - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope - org.exolab.castor.xml.validators.StringValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.StringValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setWhiteSpace("preserve"); + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return null; + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _modifiable + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { // -- local scope + org.exolab.castor.xml.validators.StringValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.StringValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setWhiteSpace("preserve"); + } + desc.setValidator(fieldValidator); + // -- _group + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_group", "group", + 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 { + RangeAnnotation target = (RangeAnnotation) object; + return target.getGroup(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + RangeAnnotation target = (RangeAnnotation) object; + target.setGroup((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- _type - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_type", "type", 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 - { - RangeAnnotation target = (RangeAnnotation) object; - return target.getType(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - RangeAnnotation target = (RangeAnnotation) object; - target.setType( (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); - desc.setRequired(true); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _type - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); - { //-- local scope - org.exolab.castor.xml.validators.StringValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.StringValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setWhiteSpace("preserve"); + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return null; + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _group + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { // -- local scope + org.exolab.castor.xml.validators.StringValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.StringValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setWhiteSpace("preserve"); + } + desc.setValidator(fieldValidator); + // -- _type + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_type", "type", + 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 { + RangeAnnotation target = (RangeAnnotation) object; + return target.getType(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + RangeAnnotation target = (RangeAnnotation) object; + target.setType((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- initialize element descriptors - - //-- _label - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_label", "label", org.exolab.castor.xml.NodeType.Element); - desc.setImmutable(true); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - RangeAnnotation target = (RangeAnnotation) object; - return target.getLabel(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - RangeAnnotation target = (RangeAnnotation) object; - target.setLabel( (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); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _label - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope - org.exolab.castor.xml.validators.StringValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.StringValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setWhiteSpace("preserve"); + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return null; + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _type + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { // -- local scope + org.exolab.castor.xml.validators.StringValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.StringValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setWhiteSpace("preserve"); + } + desc.setValidator(fieldValidator); + // -- initialize element descriptors + + // -- _label + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_label", "label", + org.exolab.castor.xml.NodeType.Element); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + RangeAnnotation target = (RangeAnnotation) object; + return target.getLabel(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + RangeAnnotation target = (RangeAnnotation) object; + target.setLabel((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- _description - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_description", "description", org.exolab.castor.xml.NodeType.Element); - desc.setImmutable(true); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - RangeAnnotation target = (RangeAnnotation) object; - return target.getDescription(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - RangeAnnotation target = (RangeAnnotation) object; - target.setDescription( (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); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _description - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope - org.exolab.castor.xml.validators.StringValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.StringValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setWhiteSpace("preserve"); + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return null; + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _label + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { // -- local scope + org.exolab.castor.xml.validators.StringValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.StringValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setWhiteSpace("preserve"); + } + desc.setValidator(fieldValidator); + // -- _description + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_description", "description", + org.exolab.castor.xml.NodeType.Element); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + RangeAnnotation target = (RangeAnnotation) object; + return target.getDescription(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + RangeAnnotation target = (RangeAnnotation) object; + target.setDescription((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- _status - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_status", "status", org.exolab.castor.xml.NodeType.Element); - desc.setImmutable(true); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - RangeAnnotation target = (RangeAnnotation) object; - return target.getStatus(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - RangeAnnotation target = (RangeAnnotation) object; - target.setStatus( (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); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _status - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope - org.exolab.castor.xml.validators.StringValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.StringValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setWhiteSpace("preserve"); + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return null; + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _description + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { // -- local scope + org.exolab.castor.xml.validators.StringValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.StringValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setWhiteSpace("preserve"); + } + desc.setValidator(fieldValidator); + // -- _status + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_status", "status", + org.exolab.castor.xml.NodeType.Element); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + RangeAnnotation target = (RangeAnnotation) object; + return target.getStatus(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + RangeAnnotation target = (RangeAnnotation) object; + target.setStatus((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- _annotationElementList - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(uk.ac.vamsas.objects.core.AnnotationElement.class, "_annotationElementList", "annotationElement", org.exolab.castor.xml.NodeType.Element); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - RangeAnnotation target = (RangeAnnotation) object; - return target.getAnnotationElement(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - RangeAnnotation target = (RangeAnnotation) object; - target.addAnnotationElement( (uk.ac.vamsas.objects.core.AnnotationElement) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public void resetValue(Object object) throws IllegalStateException, IllegalArgumentException { - try { - RangeAnnotation target = (RangeAnnotation) object; - target.removeAllAnnotationElement(); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new uk.ac.vamsas.objects.core.AnnotationElement(); - } - }; - desc.setHandler(handler); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setMultivalued(true); - addFieldDescriptor(desc); - - //-- validation code for: _annotationElementList - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(0); - { //-- local scope + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return null; + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _status + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { // -- local scope + org.exolab.castor.xml.validators.StringValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.StringValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setWhiteSpace("preserve"); + } + desc.setValidator(fieldValidator); + // -- _annotationElementList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + uk.ac.vamsas.objects.core.AnnotationElement.class, + "_annotationElementList", "annotationElement", + org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + RangeAnnotation target = (RangeAnnotation) object; + return target.getAnnotationElement(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + RangeAnnotation target = (RangeAnnotation) object; + target + .addAnnotationElement((uk.ac.vamsas.objects.core.AnnotationElement) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- _scoreList - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(uk.ac.vamsas.objects.core.Score.class, "_scoreList", "score", org.exolab.castor.xml.NodeType.Element); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - RangeAnnotation target = (RangeAnnotation) object; - return target.getScore(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - RangeAnnotation target = (RangeAnnotation) object; - target.addScore( (uk.ac.vamsas.objects.core.Score) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public void resetValue(Object object) throws IllegalStateException, IllegalArgumentException { - try { - RangeAnnotation target = (RangeAnnotation) object; - target.removeAllScore(); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new uk.ac.vamsas.objects.core.Score(); - } - }; - desc.setHandler(handler); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setMultivalued(true); - addFieldDescriptor(desc); - - //-- validation code for: _scoreList - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(0); - { //-- local scope + } + + public void resetValue(Object object) throws IllegalStateException, + IllegalArgumentException { + try { + RangeAnnotation target = (RangeAnnotation) object; + target.removeAllAnnotationElement(); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- _linkList - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(uk.ac.vamsas.objects.core.Link.class, "_linkList", "link", org.exolab.castor.xml.NodeType.Element); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - RangeAnnotation target = (RangeAnnotation) object; - return target.getLink(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - RangeAnnotation target = (RangeAnnotation) object; - target.addLink( (uk.ac.vamsas.objects.core.Link) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public void resetValue(Object object) throws IllegalStateException, IllegalArgumentException { - try { - RangeAnnotation target = (RangeAnnotation) object; - target.removeAllLink(); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new uk.ac.vamsas.objects.core.Link(); - } - }; - desc.setHandler(handler); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setMultivalued(true); - addFieldDescriptor(desc); - - //-- validation code for: _linkList - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(0); - { //-- local scope + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return new uk.ac.vamsas.objects.core.AnnotationElement(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + // -- validation code for: _annotationElementList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { // -- local scope + } + desc.setValidator(fieldValidator); + // -- _scoreList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + uk.ac.vamsas.objects.core.Score.class, "_scoreList", "score", + org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + RangeAnnotation target = (RangeAnnotation) object; + return target.getScore(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + RangeAnnotation target = (RangeAnnotation) object; + target.addScore((uk.ac.vamsas.objects.core.Score) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- _propertyList - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(uk.ac.vamsas.objects.core.Property.class, "_propertyList", "property", org.exolab.castor.xml.NodeType.Element); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - RangeAnnotation target = (RangeAnnotation) object; - return target.getProperty(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - RangeAnnotation target = (RangeAnnotation) object; - target.addProperty( (uk.ac.vamsas.objects.core.Property) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public void resetValue(Object object) throws IllegalStateException, IllegalArgumentException { - try { - RangeAnnotation target = (RangeAnnotation) object; - target.removeAllProperty(); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new uk.ac.vamsas.objects.core.Property(); - } - }; - desc.setHandler(handler); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setMultivalued(true); - addFieldDescriptor(desc); - - //-- validation code for: _propertyList - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(0); - { //-- local scope + } + + public void resetValue(Object object) throws IllegalStateException, + IllegalArgumentException { + try { + RangeAnnotation target = (RangeAnnotation) object; + target.removeAllScore(); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return new uk.ac.vamsas.objects.core.Score(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + // -- validation code for: _scoreList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { // -- local scope } + desc.setValidator(fieldValidator); + // -- _linkList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + uk.ac.vamsas.objects.core.Link.class, "_linkList", "link", + org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + RangeAnnotation target = (RangeAnnotation) object; + return target.getLink(); + } + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + RangeAnnotation target = (RangeAnnotation) object; + target.addLink((uk.ac.vamsas.objects.core.Link) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - //-----------/ - //- Methods -/ - //-----------/ + public void resetValue(Object object) throws IllegalStateException, + IllegalArgumentException { + try { + RangeAnnotation target = (RangeAnnotation) object; + target.removeAllLink(); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getAccessMode. - * - * @return the access mode specified for this class. - */ - public org.exolab.castor.mapping.AccessMode getAccessMode( - ) { - return null; - } + public java.lang.Object newInstance(java.lang.Object parent) { + return new uk.ac.vamsas.objects.core.Link(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setMultivalued(true); + addFieldDescriptor(desc); - /** - * Method getIdentity. - * - * @return the identity field, null if this class has no - * identity. - */ - public org.exolab.castor.mapping.FieldDescriptor getIdentity( - ) { - return super.getIdentity(); + // -- validation code for: _linkList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { // -- local scope } + desc.setValidator(fieldValidator); + // -- _propertyList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + uk.ac.vamsas.objects.core.Property.class, "_propertyList", "property", + org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + RangeAnnotation target = (RangeAnnotation) object; + return target.getProperty(); + } - /** - * Method getJavaClass. - * - * @return the Java class represented by this descriptor. - */ - public java.lang.Class getJavaClass( - ) { - return uk.ac.vamsas.objects.core.RangeAnnotation.class; - } + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + RangeAnnotation target = (RangeAnnotation) object; + target.addProperty((uk.ac.vamsas.objects.core.Property) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getNameSpacePrefix. - * - * @return the namespace prefix to use when marshaling as XML. - */ - public java.lang.String getNameSpacePrefix( - ) { - return _nsPrefix; - } + public void resetValue(Object object) throws IllegalStateException, + IllegalArgumentException { + try { + RangeAnnotation target = (RangeAnnotation) object; + target.removeAllProperty(); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getNameSpaceURI. - * - * @return the namespace URI used when marshaling and - * unmarshaling as XML. - */ - public java.lang.String getNameSpaceURI( - ) { - return _nsURI; - } + public java.lang.Object newInstance(java.lang.Object parent) { + return new uk.ac.vamsas.objects.core.Property(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setMultivalued(true); + addFieldDescriptor(desc); - /** - * Method getValidator. - * - * @return a specific validator for the class described by this - * ClassDescriptor. - */ - public org.exolab.castor.xml.TypeValidator getValidator( - ) { - return this; + // -- validation code for: _propertyList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { // -- local scope } + desc.setValidator(fieldValidator); + } - /** - * Method getXMLName. - * - * @return the XML Name for the Class being described. - */ - public java.lang.String getXMLName( - ) { - return _xmlName; - } + // -----------/ + // - Methods -/ + // -----------/ - /** - * Method isElementDefinition. - * - * @return true if XML schema definition of this Class is that - * of a global - * element or element with anonymous type definition. - */ - public boolean isElementDefinition( - ) { - return _elementDefinition; - } + /** + * Method getAccessMode. + * + * @return the access mode specified for this class. + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() { + return null; + } + + /** + * Method getIdentity. + * + * @return the identity field, null if this class has no identity. + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() { + return super.getIdentity(); + } + + /** + * Method getJavaClass. + * + * @return the Java class represented by this descriptor. + */ + public java.lang.Class getJavaClass() { + return uk.ac.vamsas.objects.core.RangeAnnotation.class; + } + + /** + * Method getNameSpacePrefix. + * + * @return the namespace prefix to use when marshaling as XML. + */ + public java.lang.String getNameSpacePrefix() { + return _nsPrefix; + } + + /** + * Method getNameSpaceURI. + * + * @return the namespace URI used when marshaling and unmarshaling as XML. + */ + public java.lang.String getNameSpaceURI() { + return _nsURI; + } + + /** + * Method getValidator. + * + * @return a specific validator for the class described by this + * ClassDescriptor. + */ + public org.exolab.castor.xml.TypeValidator getValidator() { + return this; + } + + /** + * Method getXMLName. + * + * @return the XML Name for the Class being described. + */ + public java.lang.String getXMLName() { + return _xmlName; + } + + /** + * Method isElementDefinition. + * + * @return true if XML schema definition of this Class is that of a global + * element or element with anonymous type definition. + */ + public boolean isElementDefinition() { + return _elementDefinition; + } } diff --git a/src/uk/ac/vamsas/objects/core/descriptors/RangeDescriptor.java b/src/uk/ac/vamsas/objects/core/descriptors/RangeDescriptor.java index 3053d50..f196666 100644 --- a/src/uk/ac/vamsas/objects/core/descriptors/RangeDescriptor.java +++ b/src/uk/ac/vamsas/objects/core/descriptors/RangeDescriptor.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core.descriptors; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import uk.ac.vamsas.objects.core.Range; @@ -18,317 +32,320 @@ import uk.ac.vamsas.objects.core.Range; * * @version $Revision$ $Date$ */ -public class RangeDescriptor extends org.exolab.castor.xml.util.XMLClassDescriptorImpl { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _elementDefinition. - */ - private boolean _elementDefinition; - - /** - * 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 RangeDescriptor() { - super(); - _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; - _xmlName = "range"; - _elementDefinition = true; - org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; - org.exolab.castor.mapping.FieldHandler handler = null; - org.exolab.castor.xml.FieldValidator fieldValidator = null; - //-- initialize attribute descriptors - - //-- _seqAStart - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Integer.TYPE, "_seqAStart", "seqAStart", org.exolab.castor.xml.NodeType.Attribute); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - Range target = (Range) object; - if (!target.hasSeqAStart()) { return null; } - return new java.lang.Integer(target.getSeqAStart()); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Range target = (Range) object; - // if null, use delete method for optional primitives - if (value == null) { - target.deleteSeqAStart(); - return; - } - target.setSeqAStart( ((java.lang.Integer) value).intValue()); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return null; - } - }; - desc.setHandler(handler); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _seqAStart - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope - org.exolab.castor.xml.validators.IntValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.IntValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setMinInclusive(-2147483648); - typeValidator.setMaxInclusive(2147483647); +public class RangeDescriptor extends + org.exolab.castor.xml.util.XMLClassDescriptorImpl { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _elementDefinition. + */ + private boolean _elementDefinition; + + /** + * 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 RangeDescriptor() { + super(); + _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; + _xmlName = "range"; + _elementDefinition = true; + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + // -- initialize attribute descriptors + + // -- _seqAStart + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.Integer.TYPE, "_seqAStart", "seqAStart", + org.exolab.castor.xml.NodeType.Attribute); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + Range target = (Range) object; + if (!target.hasSeqAStart()) { + return null; } - desc.setValidator(fieldValidator); - //-- _seqAEnd - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Integer.TYPE, "_seqAEnd", "seqAEnd", org.exolab.castor.xml.NodeType.Attribute); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - Range target = (Range) object; - if (!target.hasSeqAEnd()) { return null; } - return new java.lang.Integer(target.getSeqAEnd()); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Range target = (Range) object; - // if null, use delete method for optional primitives - if (value == null) { - target.deleteSeqAEnd(); - return; - } - target.setSeqAEnd( ((java.lang.Integer) value).intValue()); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return null; - } - }; - desc.setHandler(handler); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _seqAEnd - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope - org.exolab.castor.xml.validators.IntValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.IntValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setMinInclusive(-2147483648); - typeValidator.setMaxInclusive(2147483647); + return new java.lang.Integer(target.getSeqAStart()); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Range target = (Range) object; + // if null, use delete method for optional primitives + if (value == null) { + target.deleteSeqAStart(); + return; + } + target.setSeqAStart(((java.lang.Integer) value).intValue()); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- _seqBStart - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Integer.TYPE, "_seqBStart", "seqBStart", org.exolab.castor.xml.NodeType.Attribute); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - Range target = (Range) object; - if (!target.hasSeqBStart()) { return null; } - return new java.lang.Integer(target.getSeqBStart()); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Range target = (Range) object; - // if null, use delete method for optional primitives - if (value == null) { - target.deleteSeqBStart(); - return; - } - target.setSeqBStart( ((java.lang.Integer) value).intValue()); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return null; - } - }; - desc.setHandler(handler); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _seqBStart - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope - org.exolab.castor.xml.validators.IntValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.IntValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setMinInclusive(-2147483648); - typeValidator.setMaxInclusive(2147483647); + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return null; + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _seqAStart + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { // -- local scope + org.exolab.castor.xml.validators.IntValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.IntValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setMinInclusive(-2147483648); + typeValidator.setMaxInclusive(2147483647); + } + desc.setValidator(fieldValidator); + // -- _seqAEnd + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.Integer.TYPE, "_seqAEnd", "seqAEnd", + org.exolab.castor.xml.NodeType.Attribute); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + Range target = (Range) object; + if (!target.hasSeqAEnd()) { + return null; } - desc.setValidator(fieldValidator); - //-- _seqBEnd - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Integer.TYPE, "_seqBEnd", "seqBEnd", org.exolab.castor.xml.NodeType.Attribute); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - Range target = (Range) object; - if (!target.hasSeqBEnd()) { return null; } - return new java.lang.Integer(target.getSeqBEnd()); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Range target = (Range) object; - // if null, use delete method for optional primitives - if (value == null) { - target.deleteSeqBEnd(); - return; - } - target.setSeqBEnd( ((java.lang.Integer) value).intValue()); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return null; - } - }; - desc.setHandler(handler); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _seqBEnd - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope - org.exolab.castor.xml.validators.IntValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.IntValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setMinInclusive(-2147483648); - typeValidator.setMaxInclusive(2147483647); + return new java.lang.Integer(target.getSeqAEnd()); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Range target = (Range) object; + // if null, use delete method for optional primitives + if (value == null) { + target.deleteSeqAEnd(); + return; + } + target.setSeqAEnd(((java.lang.Integer) value).intValue()); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- initialize element descriptors - - } + } + public java.lang.Object newInstance(java.lang.Object parent) { + return null; + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _seqAEnd + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { // -- local scope + org.exolab.castor.xml.validators.IntValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.IntValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setMinInclusive(-2147483648); + typeValidator.setMaxInclusive(2147483647); + } + desc.setValidator(fieldValidator); + // -- _seqBStart + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.Integer.TYPE, "_seqBStart", "seqBStart", + org.exolab.castor.xml.NodeType.Attribute); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + Range target = (Range) object; + if (!target.hasSeqBStart()) { + return null; + } + return new java.lang.Integer(target.getSeqBStart()); + } - //-----------/ - //- Methods -/ - //-----------/ + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Range target = (Range) object; + // if null, use delete method for optional primitives + if (value == null) { + target.deleteSeqBStart(); + return; + } + target.setSeqBStart(((java.lang.Integer) value).intValue()); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getAccessMode. - * - * @return the access mode specified for this class. - */ - public org.exolab.castor.mapping.AccessMode getAccessMode( - ) { + public java.lang.Object newInstance(java.lang.Object parent) { return null; - } + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); - /** - * Method getIdentity. - * - * @return the identity field, null if this class has no - * identity. - */ - public org.exolab.castor.mapping.FieldDescriptor getIdentity( - ) { - return _identity; + // -- validation code for: _seqBStart + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { // -- local scope + org.exolab.castor.xml.validators.IntValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.IntValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setMinInclusive(-2147483648); + typeValidator.setMaxInclusive(2147483647); } + desc.setValidator(fieldValidator); + // -- _seqBEnd + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.Integer.TYPE, "_seqBEnd", "seqBEnd", + org.exolab.castor.xml.NodeType.Attribute); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + Range target = (Range) object; + if (!target.hasSeqBEnd()) { + return null; + } + return new java.lang.Integer(target.getSeqBEnd()); + } - /** - * Method getJavaClass. - * - * @return the Java class represented by this descriptor. - */ - public java.lang.Class getJavaClass( - ) { - return uk.ac.vamsas.objects.core.Range.class; - } + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Range target = (Range) object; + // if null, use delete method for optional primitives + if (value == null) { + target.deleteSeqBEnd(); + return; + } + target.setSeqBEnd(((java.lang.Integer) value).intValue()); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getNameSpacePrefix. - * - * @return the namespace prefix to use when marshaling as XML. - */ - public java.lang.String getNameSpacePrefix( - ) { - return _nsPrefix; - } + public java.lang.Object newInstance(java.lang.Object parent) { + return null; + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); - /** - * Method getNameSpaceURI. - * - * @return the namespace URI used when marshaling and - * unmarshaling as XML. - */ - public java.lang.String getNameSpaceURI( - ) { - return _nsURI; + // -- validation code for: _seqBEnd + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { // -- local scope + org.exolab.castor.xml.validators.IntValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.IntValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setMinInclusive(-2147483648); + typeValidator.setMaxInclusive(2147483647); } + desc.setValidator(fieldValidator); + // -- initialize element descriptors - /** - * Method getValidator. - * - * @return a specific validator for the class described by this - * ClassDescriptor. - */ - public org.exolab.castor.xml.TypeValidator getValidator( - ) { - return this; - } + } - /** - * Method getXMLName. - * - * @return the XML Name for the Class being described. - */ - public java.lang.String getXMLName( - ) { - return _xmlName; - } + // -----------/ + // - Methods -/ + // -----------/ - /** - * Method isElementDefinition. - * - * @return true if XML schema definition of this Class is that - * of a global - * element or element with anonymous type definition. - */ - public boolean isElementDefinition( - ) { - return _elementDefinition; - } + /** + * Method getAccessMode. + * + * @return the access mode specified for this class. + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() { + return null; + } + + /** + * Method getIdentity. + * + * @return the identity field, null if this class has no identity. + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() { + return _identity; + } + + /** + * Method getJavaClass. + * + * @return the Java class represented by this descriptor. + */ + public java.lang.Class getJavaClass() { + return uk.ac.vamsas.objects.core.Range.class; + } + + /** + * Method getNameSpacePrefix. + * + * @return the namespace prefix to use when marshaling as XML. + */ + public java.lang.String getNameSpacePrefix() { + return _nsPrefix; + } + + /** + * Method getNameSpaceURI. + * + * @return the namespace URI used when marshaling and unmarshaling as XML. + */ + public java.lang.String getNameSpaceURI() { + return _nsURI; + } + + /** + * Method getValidator. + * + * @return a specific validator for the class described by this + * ClassDescriptor. + */ + public org.exolab.castor.xml.TypeValidator getValidator() { + return this; + } + + /** + * Method getXMLName. + * + * @return the XML Name for the Class being described. + */ + public java.lang.String getXMLName() { + return _xmlName; + } + + /** + * Method isElementDefinition. + * + * @return true if XML schema definition of this Class is that of a global + * element or element with anonymous type definition. + */ + public boolean isElementDefinition() { + return _elementDefinition; + } } diff --git a/src/uk/ac/vamsas/objects/core/descriptors/RangeTypeDescriptor.java b/src/uk/ac/vamsas/objects/core/descriptors/RangeTypeDescriptor.java index 41f9da7..0fba2ca 100644 --- a/src/uk/ac/vamsas/objects/core/descriptors/RangeTypeDescriptor.java +++ b/src/uk/ac/vamsas/objects/core/descriptors/RangeTypeDescriptor.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core.descriptors; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import uk.ac.vamsas.objects.core.RangeType; @@ -18,229 +32,224 @@ import uk.ac.vamsas.objects.core.RangeType; * * @version $Revision$ $Date$ */ -public class RangeTypeDescriptor extends org.exolab.castor.xml.util.XMLClassDescriptorImpl { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _elementDefinition. - */ - private boolean _elementDefinition; - - /** - * Field _nsPrefix. - */ - private java.lang.String _nsPrefix; - - /** - * Field _nsURI. - */ - private java.lang.String _nsURI; - - /** - * Field _xmlName. - */ - private java.lang.String _xmlName; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public RangeTypeDescriptor() { - super(); - _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; - _xmlName = "rangeType"; - _elementDefinition = false; - - //-- set grouping compositor - setCompositorAsChoice(); - org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; - org.exolab.castor.mapping.FieldHandler handler = null; - org.exolab.castor.xml.FieldValidator fieldValidator = null; - //-- initialize attribute descriptors - - //-- initialize element descriptors - - //-- _posList - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(uk.ac.vamsas.objects.core.Pos.class, "_posList", "pos", org.exolab.castor.xml.NodeType.Element); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - RangeType target = (RangeType) object; - return target.getPos(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - RangeType target = (RangeType) object; - target.addPos( (uk.ac.vamsas.objects.core.Pos) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public void resetValue(Object object) throws IllegalStateException, IllegalArgumentException { - try { - RangeType target = (RangeType) object; - target.removeAllPos(); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new uk.ac.vamsas.objects.core.Pos(); - } - }; - desc.setHandler(handler); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setRequired(true); - desc.setMultivalued(true); - addFieldDescriptor(desc); - - //-- validation code for: _posList - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); - { //-- local scope +public class RangeTypeDescriptor extends + org.exolab.castor.xml.util.XMLClassDescriptorImpl { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _elementDefinition. + */ + private boolean _elementDefinition; + + /** + * Field _nsPrefix. + */ + private java.lang.String _nsPrefix; + + /** + * Field _nsURI. + */ + private java.lang.String _nsURI; + + /** + * Field _xmlName. + */ + private java.lang.String _xmlName; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public RangeTypeDescriptor() { + super(); + _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; + _xmlName = "rangeType"; + _elementDefinition = false; + + // -- set grouping compositor + setCompositorAsChoice(); + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + // -- initialize attribute descriptors + + // -- initialize element descriptors + + // -- _posList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + uk.ac.vamsas.objects.core.Pos.class, "_posList", "pos", + org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + RangeType target = (RangeType) object; + return target.getPos(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + RangeType target = (RangeType) object; + target.addPos((uk.ac.vamsas.objects.core.Pos) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- _segList - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(uk.ac.vamsas.objects.core.Seg.class, "_segList", "seg", org.exolab.castor.xml.NodeType.Element); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - RangeType target = (RangeType) object; - return target.getSeg(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - RangeType target = (RangeType) object; - target.addSeg( (uk.ac.vamsas.objects.core.Seg) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public void resetValue(Object object) throws IllegalStateException, IllegalArgumentException { - try { - RangeType target = (RangeType) object; - target.removeAllSeg(); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new uk.ac.vamsas.objects.core.Seg(); - } - }; - desc.setHandler(handler); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setRequired(true); - desc.setMultivalued(true); - addFieldDescriptor(desc); - - //-- validation code for: _segList - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); - { //-- local scope + } + + public void resetValue(Object object) throws IllegalStateException, + IllegalArgumentException { + try { + RangeType target = (RangeType) object; + target.removeAllPos(); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - } - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Method getAccessMode. - * - * @return the access mode specified for this class. - */ - public org.exolab.castor.mapping.AccessMode getAccessMode( - ) { - return null; - } - - /** - * Method getIdentity. - * - * @return the identity field, null if this class has no - * identity. - */ - public org.exolab.castor.mapping.FieldDescriptor getIdentity( - ) { - return super.getIdentity(); - } - - /** - * Method getJavaClass. - * - * @return the Java class represented by this descriptor. - */ - public java.lang.Class getJavaClass( - ) { - return uk.ac.vamsas.objects.core.RangeType.class; - } - - /** - * Method getNameSpacePrefix. - * - * @return the namespace prefix to use when marshaling as XML. - */ - public java.lang.String getNameSpacePrefix( - ) { - return _nsPrefix; - } - - /** - * Method getNameSpaceURI. - * - * @return the namespace URI used when marshaling and - * unmarshaling as XML. - */ - public java.lang.String getNameSpaceURI( - ) { - return _nsURI; - } - - /** - * Method getValidator. - * - * @return a specific validator for the class described by this - * ClassDescriptor. - */ - public org.exolab.castor.xml.TypeValidator getValidator( - ) { - return this; - } - - /** - * Method getXMLName. - * - * @return the XML Name for the Class being described. - */ - public java.lang.String getXMLName( - ) { - return _xmlName; + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return new uk.ac.vamsas.objects.core.Pos(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setRequired(true); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + // -- validation code for: _posList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { // -- local scope } - - /** - * Method isElementDefinition. - * - * @return true if XML schema definition of this Class is that - * of a global - * element or element with anonymous type definition. - */ - public boolean isElementDefinition( - ) { - return _elementDefinition; + desc.setValidator(fieldValidator); + // -- _segList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + uk.ac.vamsas.objects.core.Seg.class, "_segList", "seg", + org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + RangeType target = (RangeType) object; + return target.getSeg(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + RangeType target = (RangeType) object; + target.addSeg((uk.ac.vamsas.objects.core.Seg) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + + public void resetValue(Object object) throws IllegalStateException, + IllegalArgumentException { + try { + RangeType target = (RangeType) object; + target.removeAllSeg(); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return new uk.ac.vamsas.objects.core.Seg(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setRequired(true); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + // -- validation code for: _segList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { // -- local scope } + desc.setValidator(fieldValidator); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * Method getAccessMode. + * + * @return the access mode specified for this class. + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() { + return null; + } + + /** + * Method getIdentity. + * + * @return the identity field, null if this class has no identity. + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() { + return super.getIdentity(); + } + + /** + * Method getJavaClass. + * + * @return the Java class represented by this descriptor. + */ + public java.lang.Class getJavaClass() { + return uk.ac.vamsas.objects.core.RangeType.class; + } + + /** + * Method getNameSpacePrefix. + * + * @return the namespace prefix to use when marshaling as XML. + */ + public java.lang.String getNameSpacePrefix() { + return _nsPrefix; + } + + /** + * Method getNameSpaceURI. + * + * @return the namespace URI used when marshaling and unmarshaling as XML. + */ + public java.lang.String getNameSpaceURI() { + return _nsURI; + } + + /** + * Method getValidator. + * + * @return a specific validator for the class described by this + * ClassDescriptor. + */ + public org.exolab.castor.xml.TypeValidator getValidator() { + return this; + } + + /** + * Method getXMLName. + * + * @return the XML Name for the Class being described. + */ + public java.lang.String getXMLName() { + return _xmlName; + } + + /** + * Method isElementDefinition. + * + * @return true if XML schema definition of this Class is that of a global + * element or element with anonymous type definition. + */ + public boolean isElementDefinition() { + return _elementDefinition; + } } diff --git a/src/uk/ac/vamsas/objects/core/descriptors/ReferenceTypeDescriptor.java b/src/uk/ac/vamsas/objects/core/descriptors/ReferenceTypeDescriptor.java index 2a7a4b2..7c20d00 100644 --- a/src/uk/ac/vamsas/objects/core/descriptors/ReferenceTypeDescriptor.java +++ b/src/uk/ac/vamsas/objects/core/descriptors/ReferenceTypeDescriptor.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core.descriptors; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import uk.ac.vamsas.objects.core.ReferenceType; @@ -18,258 +32,253 @@ import uk.ac.vamsas.objects.core.ReferenceType; * * @version $Revision$ $Date$ */ -public class ReferenceTypeDescriptor extends org.exolab.castor.xml.util.XMLClassDescriptorImpl { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _elementDefinition. - */ - private boolean _elementDefinition; - - /** - * Field _nsPrefix. - */ - private java.lang.String _nsPrefix; - - /** - * Field _nsURI. - */ - private java.lang.String _nsURI; - - /** - * Field _xmlName. - */ - private java.lang.String _xmlName; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public ReferenceTypeDescriptor() { - super(); - _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; - _xmlName = "referenceType"; - _elementDefinition = false; - org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; - org.exolab.castor.mapping.FieldHandler handler = null; - org.exolab.castor.xml.FieldValidator fieldValidator = null; - //-- _content - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_content", "PCDATA", org.exolab.castor.xml.NodeType.Text); - desc.setImmutable(true); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - ReferenceType target = (ReferenceType) object; - return target.getContent(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - ReferenceType target = (ReferenceType) object; - target.setContent( (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: _content - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope - org.exolab.castor.xml.validators.StringValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.StringValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setWhiteSpace("preserve"); - } - desc.setValidator(fieldValidator); - //-- initialize attribute descriptors - - //-- _id - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_id", "id", org.exolab.castor.xml.NodeType.Attribute); - super.setIdentity(desc); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - ReferenceType target = (ReferenceType) object; - return target.getId(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - ReferenceType target = (ReferenceType) object; - target.setId( (java.lang.String) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new java.lang.String(); - } - }; - desc.setHandler(handler); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _id - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope - org.exolab.castor.xml.validators.IdValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.IdValidator(); - fieldValidator.setValidator(typeValidator); - } - desc.setValidator(fieldValidator); - //-- _refs - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Object.class, "_refs", "refs", org.exolab.castor.xml.NodeType.Attribute); - desc.setReference(true); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - ReferenceType target = (ReferenceType) object; - return target.getRefs(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - ReferenceType target = (ReferenceType) object; - target.addRefs( (java.lang.Object) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public void resetValue(Object object) throws IllegalStateException, IllegalArgumentException { - try { - ReferenceType target = (ReferenceType) object; - target.removeAllRefs(); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new java.lang.Object(); - } - }; - desc.setMultivalued(true); - desc.setHandler(handler); - desc.setMultivalued(true); - addFieldDescriptor(desc); - - //-- validation code for: _refs - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(0); - { //-- local scope - org.exolab.castor.xml.validators.IdRefsValidator typeValidator = new org.exolab.castor.xml.validators.IdRefsValidator(); - fieldValidator.setValidator(typeValidator); - desc.setValidator(fieldValidator); - } - desc.setValidator(fieldValidator); - //-- initialize element descriptors - - } +public class ReferenceTypeDescriptor extends + org.exolab.castor.xml.util.XMLClassDescriptorImpl { + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ - //-----------/ - //- Methods -/ - //-----------/ + /** + * Field _elementDefinition. + */ + private boolean _elementDefinition; - /** - * Method getAccessMode. - * - * @return the access mode specified for this class. - */ - public org.exolab.castor.mapping.AccessMode getAccessMode( - ) { + /** + * Field _nsPrefix. + */ + private java.lang.String _nsPrefix; + + /** + * Field _nsURI. + */ + private java.lang.String _nsURI; + + /** + * Field _xmlName. + */ + private java.lang.String _xmlName; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public ReferenceTypeDescriptor() { + super(); + _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; + _xmlName = "referenceType"; + _elementDefinition = false; + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + // -- _content + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_content", "PCDATA", + org.exolab.castor.xml.NodeType.Text); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + ReferenceType target = (ReferenceType) object; + return target.getContent(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + ReferenceType target = (ReferenceType) object; + target.setContent((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); - /** - * Method getIdentity. - * - * @return the identity field, null if this class has no - * identity. - */ - public org.exolab.castor.mapping.FieldDescriptor getIdentity( - ) { - return super.getIdentity(); + // -- validation code for: _content + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { // -- local scope + org.exolab.castor.xml.validators.StringValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.StringValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setWhiteSpace("preserve"); } + desc.setValidator(fieldValidator); + // -- initialize attribute descriptors - /** - * Method getJavaClass. - * - * @return the Java class represented by this descriptor. - */ - public java.lang.Class getJavaClass( - ) { - return uk.ac.vamsas.objects.core.ReferenceType.class; - } + // -- _id + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_id", "id", + org.exolab.castor.xml.NodeType.Attribute); + super.setIdentity(desc); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + ReferenceType target = (ReferenceType) object; + return target.getId(); + } - /** - * Method getNameSpacePrefix. - * - * @return the namespace prefix to use when marshaling as XML. - */ - public java.lang.String getNameSpacePrefix( - ) { - return _nsPrefix; - } + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + ReferenceType target = (ReferenceType) object; + target.setId((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getNameSpaceURI. - * - * @return the namespace URI used when marshaling and - * unmarshaling as XML. - */ - public java.lang.String getNameSpaceURI( - ) { - return _nsURI; - } + public java.lang.Object newInstance(java.lang.Object parent) { + return new java.lang.String(); + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); - /** - * Method getValidator. - * - * @return a specific validator for the class described by this - * ClassDescriptor. - */ - public org.exolab.castor.xml.TypeValidator getValidator( - ) { - return this; + // -- validation code for: _id + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { // -- local scope + org.exolab.castor.xml.validators.IdValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.IdValidator(); + fieldValidator.setValidator(typeValidator); } + desc.setValidator(fieldValidator); + // -- _refs + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.Object.class, "_refs", "refs", + org.exolab.castor.xml.NodeType.Attribute); + desc.setReference(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + ReferenceType target = (ReferenceType) object; + return target.getRefs(); + } - /** - * Method getXMLName. - * - * @return the XML Name for the Class being described. - */ - public java.lang.String getXMLName( - ) { - return _xmlName; - } + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + ReferenceType target = (ReferenceType) object; + target.addRefs((java.lang.Object) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method isElementDefinition. - * - * @return true if XML schema definition of this Class is that - * of a global - * element or element with anonymous type definition. - */ - public boolean isElementDefinition( - ) { - return _elementDefinition; + public void resetValue(Object object) throws IllegalStateException, + IllegalArgumentException { + try { + ReferenceType target = (ReferenceType) object; + target.removeAllRefs(); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return new java.lang.Object(); + } + }; + desc.setMultivalued(true); + desc.setHandler(handler); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + // -- validation code for: _refs + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { // -- local scope + org.exolab.castor.xml.validators.IdRefsValidator typeValidator = new org.exolab.castor.xml.validators.IdRefsValidator(); + fieldValidator.setValidator(typeValidator); + desc.setValidator(fieldValidator); } + desc.setValidator(fieldValidator); + // -- initialize element descriptors + + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * Method getAccessMode. + * + * @return the access mode specified for this class. + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() { + return null; + } + + /** + * Method getIdentity. + * + * @return the identity field, null if this class has no identity. + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() { + return super.getIdentity(); + } + + /** + * Method getJavaClass. + * + * @return the Java class represented by this descriptor. + */ + public java.lang.Class getJavaClass() { + return uk.ac.vamsas.objects.core.ReferenceType.class; + } + + /** + * Method getNameSpacePrefix. + * + * @return the namespace prefix to use when marshaling as XML. + */ + public java.lang.String getNameSpacePrefix() { + return _nsPrefix; + } + + /** + * Method getNameSpaceURI. + * + * @return the namespace URI used when marshaling and unmarshaling as XML. + */ + public java.lang.String getNameSpaceURI() { + return _nsURI; + } + + /** + * Method getValidator. + * + * @return a specific validator for the class described by this + * ClassDescriptor. + */ + public org.exolab.castor.xml.TypeValidator getValidator() { + return this; + } + + /** + * Method getXMLName. + * + * @return the XML Name for the Class being described. + */ + public java.lang.String getXMLName() { + return _xmlName; + } + + /** + * Method isElementDefinition. + * + * @return true if XML schema definition of this Class is that of a global + * element or element with anonymous type definition. + */ + public boolean isElementDefinition() { + return _elementDefinition; + } } diff --git a/src/uk/ac/vamsas/objects/core/descriptors/ScoreDescriptor.java b/src/uk/ac/vamsas/objects/core/descriptors/ScoreDescriptor.java index 06fac17..549384a 100644 --- a/src/uk/ac/vamsas/objects/core/descriptors/ScoreDescriptor.java +++ b/src/uk/ac/vamsas/objects/core/descriptors/ScoreDescriptor.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core.descriptors; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import uk.ac.vamsas.objects.core.Score; @@ -18,219 +32,212 @@ import uk.ac.vamsas.objects.core.Score; * * @version $Revision$ $Date$ */ -public class ScoreDescriptor extends org.exolab.castor.xml.util.XMLClassDescriptorImpl { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _elementDefinition. - */ - private boolean _elementDefinition; - - /** - * Field _nsPrefix. - */ - private java.lang.String _nsPrefix; - - /** - * Field _nsURI. - */ - private java.lang.String _nsURI; - - /** - * Field _xmlName. - */ - private java.lang.String _xmlName; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public ScoreDescriptor() { - super(); - _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; - _xmlName = "score"; - _elementDefinition = true; - org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; - org.exolab.castor.mapping.FieldHandler handler = null; - org.exolab.castor.xml.FieldValidator fieldValidator = null; - //-- _content - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Float.TYPE, "_content", "PCDATA", org.exolab.castor.xml.NodeType.Text); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - Score target = (Score) object; - if (!target.hasContent()) { return null; } - return new java.lang.Float(target.getContent()); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Score target = (Score) object; - // if null, use delete method for optional primitives - if (value == null) { - target.deleteContent(); - return; - } - target.setContent( ((java.lang.Float) value).floatValue()); - } 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: _content - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope - org.exolab.castor.xml.validators.FloatValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.FloatValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setMinInclusive((float) -3.4028235E38); - typeValidator.setMaxInclusive((float) 3.4028235E38); +public class ScoreDescriptor extends + org.exolab.castor.xml.util.XMLClassDescriptorImpl { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _elementDefinition. + */ + private boolean _elementDefinition; + + /** + * Field _nsPrefix. + */ + private java.lang.String _nsPrefix; + + /** + * Field _nsURI. + */ + private java.lang.String _nsURI; + + /** + * Field _xmlName. + */ + private java.lang.String _xmlName; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public ScoreDescriptor() { + super(); + _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; + _xmlName = "score"; + _elementDefinition = true; + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + // -- _content + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.Float.TYPE, "_content", "PCDATA", + org.exolab.castor.xml.NodeType.Text); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + Score target = (Score) object; + if (!target.hasContent()) { + return null; } - desc.setValidator(fieldValidator); - //-- initialize attribute descriptors - - //-- _name - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_name", "name", 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 - { - Score target = (Score) object; - return target.getName(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Score target = (Score) object; - target.setName( (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); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _name - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope - org.exolab.castor.xml.validators.StringValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.StringValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setWhiteSpace("preserve"); + return new java.lang.Float(target.getContent()); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Score target = (Score) object; + // if null, use delete method for optional primitives + if (value == null) { + target.deleteContent(); + return; + } + target.setContent(((java.lang.Float) value).floatValue()); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- initialize element descriptors - - } + } - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Method getAccessMode. - * - * @return the access mode specified for this class. - */ - public org.exolab.castor.mapping.AccessMode getAccessMode( - ) { + public java.lang.Object newInstance(java.lang.Object parent) { return null; + } + }; + desc.setHandler(handler); + addFieldDescriptor(desc); + + // -- validation code for: _content + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { // -- local scope + org.exolab.castor.xml.validators.FloatValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.FloatValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setMinInclusive((float) -3.4028235E38); + typeValidator.setMaxInclusive((float) 3.4028235E38); } + desc.setValidator(fieldValidator); + // -- initialize attribute descriptors + + // -- _name + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_name", "name", + 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 { + Score target = (Score) object; + return target.getName(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Score target = (Score) object; + target.setName((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getIdentity. - * - * @return the identity field, null if this class has no - * identity. - */ - public org.exolab.castor.mapping.FieldDescriptor getIdentity( - ) { - return super.getIdentity(); - } - - /** - * Method getJavaClass. - * - * @return the Java class represented by this descriptor. - */ - public java.lang.Class getJavaClass( - ) { - return uk.ac.vamsas.objects.core.Score.class; - } - - /** - * Method getNameSpacePrefix. - * - * @return the namespace prefix to use when marshaling as XML. - */ - public java.lang.String getNameSpacePrefix( - ) { - return _nsPrefix; - } - - /** - * Method getNameSpaceURI. - * - * @return the namespace URI used when marshaling and - * unmarshaling as XML. - */ - public java.lang.String getNameSpaceURI( - ) { - return _nsURI; - } - - /** - * Method getValidator. - * - * @return a specific validator for the class described by this - * ClassDescriptor. - */ - public org.exolab.castor.xml.TypeValidator getValidator( - ) { - return this; - } - - /** - * Method getXMLName. - * - * @return the XML Name for the Class being described. - */ - public java.lang.String getXMLName( - ) { - return _xmlName; - } - - /** - * Method isElementDefinition. - * - * @return true if XML schema definition of this Class is that - * of a global - * element or element with anonymous type definition. - */ - public boolean isElementDefinition( - ) { - return _elementDefinition; + public java.lang.Object newInstance(java.lang.Object parent) { + return null; + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _name + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { // -- local scope + org.exolab.castor.xml.validators.StringValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.StringValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setWhiteSpace("preserve"); } + desc.setValidator(fieldValidator); + // -- initialize element descriptors + + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * Method getAccessMode. + * + * @return the access mode specified for this class. + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() { + return null; + } + + /** + * Method getIdentity. + * + * @return the identity field, null if this class has no identity. + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() { + return super.getIdentity(); + } + + /** + * Method getJavaClass. + * + * @return the Java class represented by this descriptor. + */ + public java.lang.Class getJavaClass() { + return uk.ac.vamsas.objects.core.Score.class; + } + + /** + * Method getNameSpacePrefix. + * + * @return the namespace prefix to use when marshaling as XML. + */ + public java.lang.String getNameSpacePrefix() { + return _nsPrefix; + } + + /** + * Method getNameSpaceURI. + * + * @return the namespace URI used when marshaling and unmarshaling as XML. + */ + public java.lang.String getNameSpaceURI() { + return _nsURI; + } + + /** + * Method getValidator. + * + * @return a specific validator for the class described by this + * ClassDescriptor. + */ + public org.exolab.castor.xml.TypeValidator getValidator() { + return this; + } + + /** + * Method getXMLName. + * + * @return the XML Name for the Class being described. + */ + public java.lang.String getXMLName() { + return _xmlName; + } + + /** + * Method isElementDefinition. + * + * @return true if XML schema definition of this Class is that of a global + * element or element with anonymous type definition. + */ + public boolean isElementDefinition() { + return _elementDefinition; + } } diff --git a/src/uk/ac/vamsas/objects/core/descriptors/SegDescriptor.java b/src/uk/ac/vamsas/objects/core/descriptors/SegDescriptor.java index c489fff..6aa64fd 100644 --- a/src/uk/ac/vamsas/objects/core/descriptors/SegDescriptor.java +++ b/src/uk/ac/vamsas/objects/core/descriptors/SegDescriptor.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core.descriptors; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import uk.ac.vamsas.objects.core.Seg; @@ -18,267 +32,273 @@ import uk.ac.vamsas.objects.core.Seg; * * @version $Revision$ $Date$ */ -public class SegDescriptor extends org.exolab.castor.xml.util.XMLClassDescriptorImpl { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _elementDefinition. - */ - private boolean _elementDefinition; - - /** - * Field _nsPrefix. - */ - private java.lang.String _nsPrefix; - - /** - * Field _nsURI. - */ - private java.lang.String _nsURI; - - /** - * Field _xmlName. - */ - private java.lang.String _xmlName; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public SegDescriptor() { - super(); - _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; - _xmlName = "seg"; - _elementDefinition = true; - org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; - org.exolab.castor.mapping.FieldHandler handler = null; - org.exolab.castor.xml.FieldValidator fieldValidator = null; - //-- initialize attribute descriptors - - //-- _start - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Integer.TYPE, "_start", "start", org.exolab.castor.xml.NodeType.Attribute); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - Seg target = (Seg) object; - if (!target.hasStart()) { return null; } - return new java.lang.Integer(target.getStart()); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Seg target = (Seg) object; - // ignore null values for non optional primitives - if (value == null) { return; } - - target.setStart( ((java.lang.Integer) value).intValue()); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return null; - } - }; - desc.setHandler(handler); - desc.setRequired(true); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _start - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); - { //-- local scope - org.exolab.castor.xml.validators.IntValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.IntValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setMinInclusive(-2147483648); - typeValidator.setMaxInclusive(2147483647); - } - desc.setValidator(fieldValidator); - //-- _end - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Integer.TYPE, "_end", "end", org.exolab.castor.xml.NodeType.Attribute); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - Seg target = (Seg) object; - if (!target.hasEnd()) { return null; } - return new java.lang.Integer(target.getEnd()); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Seg target = (Seg) object; - // ignore null values for non optional primitives - if (value == null) { return; } - - target.setEnd( ((java.lang.Integer) value).intValue()); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return null; - } - }; - desc.setHandler(handler); - desc.setRequired(true); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _end - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); - { //-- local scope - org.exolab.castor.xml.validators.IntValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.IntValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setMinInclusive(-2147483648); - typeValidator.setMaxInclusive(2147483647); +public class SegDescriptor extends + org.exolab.castor.xml.util.XMLClassDescriptorImpl { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _elementDefinition. + */ + private boolean _elementDefinition; + + /** + * Field _nsPrefix. + */ + private java.lang.String _nsPrefix; + + /** + * Field _nsURI. + */ + private java.lang.String _nsURI; + + /** + * Field _xmlName. + */ + private java.lang.String _xmlName; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public SegDescriptor() { + super(); + _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; + _xmlName = "seg"; + _elementDefinition = true; + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + // -- initialize attribute descriptors + + // -- _start + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.Integer.TYPE, "_start", "start", + org.exolab.castor.xml.NodeType.Attribute); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + Seg target = (Seg) object; + if (!target.hasStart()) { + return null; } - desc.setValidator(fieldValidator); - //-- _inclusive - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Boolean.TYPE, "_inclusive", "inclusive", org.exolab.castor.xml.NodeType.Attribute); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - Seg target = (Seg) object; - if (!target.hasInclusive()) { return null; } - return (target.getInclusive() ? java.lang.Boolean.TRUE : java.lang.Boolean.FALSE); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Seg target = (Seg) object; - // ignore null values for non optional primitives - if (value == null) { return; } - - target.setInclusive( ((java.lang.Boolean) value).booleanValue()); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return null; - } - }; - desc.setHandler(handler); - desc.setRequired(true); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _inclusive - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); - { //-- local scope - org.exolab.castor.xml.validators.BooleanValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.BooleanValidator(); - fieldValidator.setValidator(typeValidator); + return new java.lang.Integer(target.getStart()); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Seg target = (Seg) object; + // ignore null values for non optional primitives + if (value == null) { + return; + } + + target.setStart(((java.lang.Integer) value).intValue()); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- initialize element descriptors - + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return null; + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _start + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { // -- local scope + org.exolab.castor.xml.validators.IntValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.IntValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setMinInclusive(-2147483648); + typeValidator.setMaxInclusive(2147483647); } + desc.setValidator(fieldValidator); + // -- _end + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.Integer.TYPE, "_end", "end", + org.exolab.castor.xml.NodeType.Attribute); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + Seg target = (Seg) object; + if (!target.hasEnd()) { + return null; + } + return new java.lang.Integer(target.getEnd()); + } + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Seg target = (Seg) object; + // ignore null values for non optional primitives + if (value == null) { + return; + } - //-----------/ - //- Methods -/ - //-----------/ + target.setEnd(((java.lang.Integer) value).intValue()); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getAccessMode. - * - * @return the access mode specified for this class. - */ - public org.exolab.castor.mapping.AccessMode getAccessMode( - ) { + public java.lang.Object newInstance(java.lang.Object parent) { return null; - } + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); - /** - * Method getIdentity. - * - * @return the identity field, null if this class has no - * identity. - */ - public org.exolab.castor.mapping.FieldDescriptor getIdentity( - ) { - return super.getIdentity(); + // -- validation code for: _end + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { // -- local scope + org.exolab.castor.xml.validators.IntValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.IntValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setMinInclusive(-2147483648); + typeValidator.setMaxInclusive(2147483647); } + desc.setValidator(fieldValidator); + // -- _inclusive + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.Boolean.TYPE, "_inclusive", "inclusive", + org.exolab.castor.xml.NodeType.Attribute); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + Seg target = (Seg) object; + if (!target.hasInclusive()) { + return null; + } + return (target.getInclusive() ? java.lang.Boolean.TRUE + : java.lang.Boolean.FALSE); + } - /** - * Method getJavaClass. - * - * @return the Java class represented by this descriptor. - */ - public java.lang.Class getJavaClass( - ) { - return uk.ac.vamsas.objects.core.Seg.class; - } + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Seg target = (Seg) object; + // ignore null values for non optional primitives + if (value == null) { + return; + } - /** - * Method getNameSpacePrefix. - * - * @return the namespace prefix to use when marshaling as XML. - */ - public java.lang.String getNameSpacePrefix( - ) { - return _nsPrefix; - } + target.setInclusive(((java.lang.Boolean) value).booleanValue()); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getNameSpaceURI. - * - * @return the namespace URI used when marshaling and - * unmarshaling as XML. - */ - public java.lang.String getNameSpaceURI( - ) { - return _nsURI; - } + public java.lang.Object newInstance(java.lang.Object parent) { + return null; + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); - /** - * Method getValidator. - * - * @return a specific validator for the class described by this - * ClassDescriptor. - */ - public org.exolab.castor.xml.TypeValidator getValidator( - ) { - return this; + // -- validation code for: _inclusive + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { // -- local scope + org.exolab.castor.xml.validators.BooleanValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.BooleanValidator(); + fieldValidator.setValidator(typeValidator); } + desc.setValidator(fieldValidator); + // -- initialize element descriptors - /** - * Method getXMLName. - * - * @return the XML Name for the Class being described. - */ - public java.lang.String getXMLName( - ) { - return _xmlName; - } + } - /** - * Method isElementDefinition. - * - * @return true if XML schema definition of this Class is that - * of a global - * element or element with anonymous type definition. - */ - public boolean isElementDefinition( - ) { - return _elementDefinition; - } + // -----------/ + // - Methods -/ + // -----------/ + + /** + * Method getAccessMode. + * + * @return the access mode specified for this class. + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() { + return null; + } + + /** + * Method getIdentity. + * + * @return the identity field, null if this class has no identity. + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() { + return super.getIdentity(); + } + + /** + * Method getJavaClass. + * + * @return the Java class represented by this descriptor. + */ + public java.lang.Class getJavaClass() { + return uk.ac.vamsas.objects.core.Seg.class; + } + + /** + * Method getNameSpacePrefix. + * + * @return the namespace prefix to use when marshaling as XML. + */ + public java.lang.String getNameSpacePrefix() { + return _nsPrefix; + } + + /** + * Method getNameSpaceURI. + * + * @return the namespace URI used when marshaling and unmarshaling as XML. + */ + public java.lang.String getNameSpaceURI() { + return _nsURI; + } + + /** + * Method getValidator. + * + * @return a specific validator for the class described by this + * ClassDescriptor. + */ + public org.exolab.castor.xml.TypeValidator getValidator() { + return this; + } + + /** + * Method getXMLName. + * + * @return the XML Name for the Class being described. + */ + public java.lang.String getXMLName() { + return _xmlName; + } + + /** + * Method isElementDefinition. + * + * @return true if XML schema definition of this Class is that of a global + * element or element with anonymous type definition. + */ + public boolean isElementDefinition() { + return _elementDefinition; + } } diff --git a/src/uk/ac/vamsas/objects/core/descriptors/SequenceDescriptor.java b/src/uk/ac/vamsas/objects/core/descriptors/SequenceDescriptor.java index d18b8c1..d67e4e8 100644 --- a/src/uk/ac/vamsas/objects/core/descriptors/SequenceDescriptor.java +++ b/src/uk/ac/vamsas/objects/core/descriptors/SequenceDescriptor.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core.descriptors; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import uk.ac.vamsas.objects.core.Sequence; @@ -18,303 +32,302 @@ import uk.ac.vamsas.objects.core.Sequence; * * @version $Revision$ $Date$ */ -public class SequenceDescriptor extends uk.ac.vamsas.objects.core.descriptors.SequenceTypeDescriptor { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _elementDefinition. - */ - private boolean _elementDefinition; - - /** - * Field _nsPrefix. - */ - private java.lang.String _nsPrefix; - - /** - * Field _nsURI. - */ - private java.lang.String _nsURI; - - /** - * Field _xmlName. - */ - private java.lang.String _xmlName; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public SequenceDescriptor() { - super(); - setExtendsWithoutFlatten(new uk.ac.vamsas.objects.core.descriptors.SequenceTypeDescriptor()); - _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; - _xmlName = "Sequence"; - _elementDefinition = true; - - //-- set grouping compositor - setCompositorAsSequence(); - org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; - org.exolab.castor.mapping.FieldHandler handler = null; - org.exolab.castor.xml.FieldValidator fieldValidator = null; - //-- initialize attribute descriptors - - //-- _id - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_id", "id", org.exolab.castor.xml.NodeType.Attribute); - super.setIdentity(desc); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - Sequence target = (Sequence) object; - return target.getId(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Sequence target = (Sequence) object; - target.setId( (java.lang.String) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new java.lang.String(); - } - }; - desc.setHandler(handler); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _id - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope - org.exolab.castor.xml.validators.IdValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.IdValidator(); - fieldValidator.setValidator(typeValidator); +public class SequenceDescriptor extends + uk.ac.vamsas.objects.core.descriptors.SequenceTypeDescriptor { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _elementDefinition. + */ + private boolean _elementDefinition; + + /** + * Field _nsPrefix. + */ + private java.lang.String _nsPrefix; + + /** + * Field _nsURI. + */ + private java.lang.String _nsURI; + + /** + * Field _xmlName. + */ + private java.lang.String _xmlName; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public SequenceDescriptor() { + super(); + setExtendsWithoutFlatten(new uk.ac.vamsas.objects.core.descriptors.SequenceTypeDescriptor()); + _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; + _xmlName = "Sequence"; + _elementDefinition = true; + + // -- set grouping compositor + setCompositorAsSequence(); + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + // -- initialize attribute descriptors + + // -- _id + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_id", "id", + org.exolab.castor.xml.NodeType.Attribute); + super.setIdentity(desc); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + Sequence target = (Sequence) object; + return target.getId(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Sequence target = (Sequence) object; + target.setId((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- _dictionary - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_dictionary", "dictionary", 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 - { - Sequence target = (Sequence) object; - return target.getDictionary(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Sequence target = (Sequence) object; - target.setDictionary( (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); - desc.setRequired(true); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _dictionary - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); - { //-- local scope - org.exolab.castor.xml.validators.StringValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.StringValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setWhiteSpace("preserve"); + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return new java.lang.String(); + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _id + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { // -- local scope + org.exolab.castor.xml.validators.IdValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.IdValidator(); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + // -- _dictionary + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_dictionary", "dictionary", + 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 { + Sequence target = (Sequence) object; + return target.getDictionary(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Sequence target = (Sequence) object; + target.setDictionary((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- initialize element descriptors - - //-- _dbRefList - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(uk.ac.vamsas.objects.core.DbRef.class, "_dbRefList", "dbRef", org.exolab.castor.xml.NodeType.Element); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - Sequence target = (Sequence) object; - return target.getDbRef(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Sequence target = (Sequence) object; - target.addDbRef( (uk.ac.vamsas.objects.core.DbRef) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public void resetValue(Object object) throws IllegalStateException, IllegalArgumentException { - try { - Sequence target = (Sequence) object; - target.removeAllDbRef(); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new uk.ac.vamsas.objects.core.DbRef(); - } - }; - desc.setHandler(handler); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setMultivalued(true); - addFieldDescriptor(desc); - - //-- validation code for: _dbRefList - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(0); - { //-- local scope + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return null; + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _dictionary + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { // -- local scope + org.exolab.castor.xml.validators.StringValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.StringValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setWhiteSpace("preserve"); + } + desc.setValidator(fieldValidator); + // -- initialize element descriptors + + // -- _dbRefList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + uk.ac.vamsas.objects.core.DbRef.class, "_dbRefList", "dbRef", + org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + Sequence target = (Sequence) object; + return target.getDbRef(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Sequence target = (Sequence) object; + target.addDbRef((uk.ac.vamsas.objects.core.DbRef) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- _vxrefList - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(uk.ac.vamsas.objects.core.Vxref.class, "_vxrefList", "vxref", org.exolab.castor.xml.NodeType.Element); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - Sequence target = (Sequence) object; - return target.getVxref(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Sequence target = (Sequence) object; - target.addVxref( (uk.ac.vamsas.objects.core.Vxref) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public void resetValue(Object object) throws IllegalStateException, IllegalArgumentException { - try { - Sequence target = (Sequence) object; - target.removeAllVxref(); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new uk.ac.vamsas.objects.core.Vxref(); - } - }; - desc.setHandler(handler); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setMultivalued(true); - addFieldDescriptor(desc); - - //-- validation code for: _vxrefList - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(0); - { //-- local scope + } + + public void resetValue(Object object) throws IllegalStateException, + IllegalArgumentException { + try { + Sequence target = (Sequence) object; + target.removeAllDbRef(); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return new uk.ac.vamsas.objects.core.DbRef(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + // -- validation code for: _dbRefList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { // -- local scope } + desc.setValidator(fieldValidator); + // -- _vxrefList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + uk.ac.vamsas.objects.core.Vxref.class, "_vxrefList", "vxref", + org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + Sequence target = (Sequence) object; + return target.getVxref(); + } + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Sequence target = (Sequence) object; + target.addVxref((uk.ac.vamsas.objects.core.Vxref) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - //-----------/ - //- Methods -/ - //-----------/ + public void resetValue(Object object) throws IllegalStateException, + IllegalArgumentException { + try { + Sequence target = (Sequence) object; + target.removeAllVxref(); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getAccessMode. - * - * @return the access mode specified for this class. - */ - public org.exolab.castor.mapping.AccessMode getAccessMode( - ) { - return null; - } + public java.lang.Object newInstance(java.lang.Object parent) { + return new uk.ac.vamsas.objects.core.Vxref(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setMultivalued(true); + addFieldDescriptor(desc); - /** - * Method getIdentity. - * - * @return the identity field, null if this class has no - * identity. - */ - public org.exolab.castor.mapping.FieldDescriptor getIdentity( - ) { - return super.getIdentity(); + // -- validation code for: _vxrefList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { // -- local scope } + desc.setValidator(fieldValidator); + } - /** - * Method getJavaClass. - * - * @return the Java class represented by this descriptor. - */ - public java.lang.Class getJavaClass( - ) { - return uk.ac.vamsas.objects.core.Sequence.class; - } + // -----------/ + // - Methods -/ + // -----------/ - /** - * Method getNameSpacePrefix. - * - * @return the namespace prefix to use when marshaling as XML. - */ - public java.lang.String getNameSpacePrefix( - ) { - return _nsPrefix; - } + /** + * Method getAccessMode. + * + * @return the access mode specified for this class. + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() { + return null; + } - /** - * Method getNameSpaceURI. - * - * @return the namespace URI used when marshaling and - * unmarshaling as XML. - */ - public java.lang.String getNameSpaceURI( - ) { - return _nsURI; - } + /** + * Method getIdentity. + * + * @return the identity field, null if this class has no identity. + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() { + return super.getIdentity(); + } - /** - * Method getValidator. - * - * @return a specific validator for the class described by this - * ClassDescriptor. - */ - public org.exolab.castor.xml.TypeValidator getValidator( - ) { - return this; - } + /** + * Method getJavaClass. + * + * @return the Java class represented by this descriptor. + */ + public java.lang.Class getJavaClass() { + return uk.ac.vamsas.objects.core.Sequence.class; + } - /** - * Method getXMLName. - * - * @return the XML Name for the Class being described. - */ - public java.lang.String getXMLName( - ) { - return _xmlName; - } + /** + * Method getNameSpacePrefix. + * + * @return the namespace prefix to use when marshaling as XML. + */ + public java.lang.String getNameSpacePrefix() { + return _nsPrefix; + } - /** - * Method isElementDefinition. - * - * @return true if XML schema definition of this Class is that - * of a global - * element or element with anonymous type definition. - */ - public boolean isElementDefinition( - ) { - return _elementDefinition; - } + /** + * Method getNameSpaceURI. + * + * @return the namespace URI used when marshaling and unmarshaling as XML. + */ + public java.lang.String getNameSpaceURI() { + return _nsURI; + } + + /** + * Method getValidator. + * + * @return a specific validator for the class described by this + * ClassDescriptor. + */ + public org.exolab.castor.xml.TypeValidator getValidator() { + return this; + } + + /** + * Method getXMLName. + * + * @return the XML Name for the Class being described. + */ + public java.lang.String getXMLName() { + return _xmlName; + } + + /** + * Method isElementDefinition. + * + * @return true if XML schema definition of this Class is that of a global + * element or element with anonymous type definition. + */ + public boolean isElementDefinition() { + return _elementDefinition; + } } diff --git a/src/uk/ac/vamsas/objects/core/descriptors/SequenceMappingDescriptor.java b/src/uk/ac/vamsas/objects/core/descriptors/SequenceMappingDescriptor.java index 396515e..e5faaad 100644 --- a/src/uk/ac/vamsas/objects/core/descriptors/SequenceMappingDescriptor.java +++ b/src/uk/ac/vamsas/objects/core/descriptors/SequenceMappingDescriptor.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core.descriptors; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import uk.ac.vamsas.objects.core.SequenceMapping; @@ -18,291 +32,286 @@ import uk.ac.vamsas.objects.core.SequenceMapping; * * @version $Revision$ $Date$ */ -public class SequenceMappingDescriptor extends uk.ac.vamsas.objects.core.descriptors.MapTypeDescriptor { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _elementDefinition. - */ - private boolean _elementDefinition; - - /** - * Field _nsPrefix. - */ - private java.lang.String _nsPrefix; - - /** - * Field _nsURI. - */ - private java.lang.String _nsURI; - - /** - * Field _xmlName. - */ - private java.lang.String _xmlName; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public SequenceMappingDescriptor() { - super(); - setExtendsWithoutFlatten(new uk.ac.vamsas.objects.core.descriptors.MapTypeDescriptor()); - _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; - _xmlName = "sequenceMapping"; - _elementDefinition = true; - - //-- set grouping compositor - setCompositorAsSequence(); - org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; - org.exolab.castor.mapping.FieldHandler handler = null; - org.exolab.castor.xml.FieldValidator fieldValidator = null; - //-- initialize attribute descriptors - - //-- _loc - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Object.class, "_loc", "loc", org.exolab.castor.xml.NodeType.Attribute); - desc.setReference(true); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - SequenceMapping target = (SequenceMapping) object; - return target.getLoc(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - SequenceMapping target = (SequenceMapping) object; - target.setLoc( (java.lang.Object) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new java.lang.Object(); - } - }; - desc.setHandler(handler); - desc.setRequired(true); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _loc - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); - { //-- local scope - org.exolab.castor.xml.validators.IdRefValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.IdRefValidator(); - fieldValidator.setValidator(typeValidator); - } - desc.setValidator(fieldValidator); - //-- _map - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Object.class, "_map", "map", org.exolab.castor.xml.NodeType.Attribute); - desc.setReference(true); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - SequenceMapping target = (SequenceMapping) object; - return target.getMap(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - SequenceMapping target = (SequenceMapping) object; - target.setMap( (java.lang.Object) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new java.lang.Object(); - } - }; - desc.setHandler(handler); - desc.setRequired(true); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _map - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); - { //-- local scope - org.exolab.castor.xml.validators.IdRefValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.IdRefValidator(); - fieldValidator.setValidator(typeValidator); - } - desc.setValidator(fieldValidator); - //-- _id - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_id", "id", org.exolab.castor.xml.NodeType.Attribute); - super.setIdentity(desc); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - SequenceMapping target = (SequenceMapping) object; - return target.getId(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - SequenceMapping target = (SequenceMapping) object; - target.setId( (java.lang.String) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new java.lang.String(); - } - }; - desc.setHandler(handler); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _id - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope - org.exolab.castor.xml.validators.IdValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.IdValidator(); - fieldValidator.setValidator(typeValidator); - } - desc.setValidator(fieldValidator); - //-- initialize element descriptors - - //-- _provenance - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(uk.ac.vamsas.objects.core.Provenance.class, "_provenance", "Provenance", org.exolab.castor.xml.NodeType.Element); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - SequenceMapping target = (SequenceMapping) object; - return target.getProvenance(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - SequenceMapping target = (SequenceMapping) object; - target.setProvenance( (uk.ac.vamsas.objects.core.Provenance) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new uk.ac.vamsas.objects.core.Provenance(); - } - }; - desc.setHandler(handler); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setRequired(true); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _provenance - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); - { //-- local scope +public class SequenceMappingDescriptor extends + uk.ac.vamsas.objects.core.descriptors.MapTypeDescriptor { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _elementDefinition. + */ + private boolean _elementDefinition; + + /** + * Field _nsPrefix. + */ + private java.lang.String _nsPrefix; + + /** + * Field _nsURI. + */ + private java.lang.String _nsURI; + + /** + * Field _xmlName. + */ + private java.lang.String _xmlName; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public SequenceMappingDescriptor() { + super(); + setExtendsWithoutFlatten(new uk.ac.vamsas.objects.core.descriptors.MapTypeDescriptor()); + _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; + _xmlName = "sequenceMapping"; + _elementDefinition = true; + + // -- set grouping compositor + setCompositorAsSequence(); + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + // -- initialize attribute descriptors + + // -- _loc + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.Object.class, "_loc", "loc", + org.exolab.castor.xml.NodeType.Attribute); + desc.setReference(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + SequenceMapping target = (SequenceMapping) object; + return target.getLoc(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + SequenceMapping target = (SequenceMapping) object; + target.setLoc((java.lang.Object) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return new java.lang.Object(); + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _loc + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { // -- local scope + org.exolab.castor.xml.validators.IdRefValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.IdRefValidator(); + fieldValidator.setValidator(typeValidator); } + desc.setValidator(fieldValidator); + // -- _map + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.Object.class, "_map", "map", + org.exolab.castor.xml.NodeType.Attribute); + desc.setReference(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + SequenceMapping target = (SequenceMapping) object; + return target.getMap(); + } + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + SequenceMapping target = (SequenceMapping) object; + target.setMap((java.lang.Object) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - //-----------/ - //- Methods -/ - //-----------/ + public java.lang.Object newInstance(java.lang.Object parent) { + return new java.lang.Object(); + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); - /** - * Method getAccessMode. - * - * @return the access mode specified for this class. - */ - public org.exolab.castor.mapping.AccessMode getAccessMode( - ) { - return null; + // -- validation code for: _map + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { // -- local scope + org.exolab.castor.xml.validators.IdRefValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.IdRefValidator(); + fieldValidator.setValidator(typeValidator); } + desc.setValidator(fieldValidator); + // -- _id + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_id", "id", + org.exolab.castor.xml.NodeType.Attribute); + super.setIdentity(desc); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + SequenceMapping target = (SequenceMapping) object; + return target.getId(); + } - /** - * Method getIdentity. - * - * @return the identity field, null if this class has no - * identity. - */ - public org.exolab.castor.mapping.FieldDescriptor getIdentity( - ) { - return super.getIdentity(); - } + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + SequenceMapping target = (SequenceMapping) object; + target.setId((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getJavaClass. - * - * @return the Java class represented by this descriptor. - */ - public java.lang.Class getJavaClass( - ) { - return uk.ac.vamsas.objects.core.SequenceMapping.class; - } + public java.lang.Object newInstance(java.lang.Object parent) { + return new java.lang.String(); + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); - /** - * Method getNameSpacePrefix. - * - * @return the namespace prefix to use when marshaling as XML. - */ - public java.lang.String getNameSpacePrefix( - ) { - return _nsPrefix; + // -- validation code for: _id + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { // -- local scope + org.exolab.castor.xml.validators.IdValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.IdValidator(); + fieldValidator.setValidator(typeValidator); } + desc.setValidator(fieldValidator); + // -- initialize element descriptors - /** - * Method getNameSpaceURI. - * - * @return the namespace URI used when marshaling and - * unmarshaling as XML. - */ - public java.lang.String getNameSpaceURI( - ) { - return _nsURI; - } + // -- _provenance + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + uk.ac.vamsas.objects.core.Provenance.class, "_provenance", + "Provenance", org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + SequenceMapping target = (SequenceMapping) object; + return target.getProvenance(); + } - /** - * Method getValidator. - * - * @return a specific validator for the class described by this - * ClassDescriptor. - */ - public org.exolab.castor.xml.TypeValidator getValidator( - ) { - return this; - } + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + SequenceMapping target = (SequenceMapping) object; + target.setProvenance((uk.ac.vamsas.objects.core.Provenance) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getXMLName. - * - * @return the XML Name for the Class being described. - */ - public java.lang.String getXMLName( - ) { - return _xmlName; - } + public java.lang.Object newInstance(java.lang.Object parent) { + return new uk.ac.vamsas.objects.core.Provenance(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); - /** - * Method isElementDefinition. - * - * @return true if XML schema definition of this Class is that - * of a global - * element or element with anonymous type definition. - */ - public boolean isElementDefinition( - ) { - return _elementDefinition; + // -- validation code for: _provenance + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { // -- local scope } + desc.setValidator(fieldValidator); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * Method getAccessMode. + * + * @return the access mode specified for this class. + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() { + return null; + } + + /** + * Method getIdentity. + * + * @return the identity field, null if this class has no identity. + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() { + return super.getIdentity(); + } + + /** + * Method getJavaClass. + * + * @return the Java class represented by this descriptor. + */ + public java.lang.Class getJavaClass() { + return uk.ac.vamsas.objects.core.SequenceMapping.class; + } + + /** + * Method getNameSpacePrefix. + * + * @return the namespace prefix to use when marshaling as XML. + */ + public java.lang.String getNameSpacePrefix() { + return _nsPrefix; + } + + /** + * Method getNameSpaceURI. + * + * @return the namespace URI used when marshaling and unmarshaling as XML. + */ + public java.lang.String getNameSpaceURI() { + return _nsURI; + } + + /** + * Method getValidator. + * + * @return a specific validator for the class described by this + * ClassDescriptor. + */ + public org.exolab.castor.xml.TypeValidator getValidator() { + return this; + } + + /** + * Method getXMLName. + * + * @return the XML Name for the Class being described. + */ + public java.lang.String getXMLName() { + return _xmlName; + } + + /** + * Method isElementDefinition. + * + * @return true if XML schema definition of this Class is that of a global + * element or element with anonymous type definition. + */ + public boolean isElementDefinition() { + return _elementDefinition; + } } diff --git a/src/uk/ac/vamsas/objects/core/descriptors/SequenceTypeDescriptor.java b/src/uk/ac/vamsas/objects/core/descriptors/SequenceTypeDescriptor.java index 7b059e6..607e999 100644 --- a/src/uk/ac/vamsas/objects/core/descriptors/SequenceTypeDescriptor.java +++ b/src/uk/ac/vamsas/objects/core/descriptors/SequenceTypeDescriptor.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core.descriptors; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import uk.ac.vamsas.objects.core.SequenceType; @@ -18,385 +32,394 @@ import uk.ac.vamsas.objects.core.SequenceType; * * @version $Revision$ $Date$ */ -public class SequenceTypeDescriptor extends org.exolab.castor.xml.util.XMLClassDescriptorImpl { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _elementDefinition. - */ - private boolean _elementDefinition; - - /** - * Field _nsPrefix. - */ - private java.lang.String _nsPrefix; - - /** - * Field _nsURI. - */ - private java.lang.String _nsURI; - - /** - * Field _xmlName. - */ - private java.lang.String _xmlName; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public SequenceTypeDescriptor() { - super(); - _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; - _xmlName = "SequenceType"; - _elementDefinition = false; - - //-- set grouping compositor - setCompositorAsSequence(); - org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; - org.exolab.castor.mapping.FieldHandler handler = null; - org.exolab.castor.xml.FieldValidator fieldValidator = null; - //-- initialize attribute descriptors - - //-- _start - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Long.TYPE, "_start", "start", org.exolab.castor.xml.NodeType.Attribute); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - SequenceType target = (SequenceType) object; - if (!target.hasStart()) { return null; } - return new java.lang.Long(target.getStart()); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - SequenceType target = (SequenceType) object; - // ignore null values for non optional primitives - if (value == null) { return; } - - target.setStart( ((java.lang.Long) value).longValue()); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return null; - } - }; - desc.setHandler(handler); - desc.setRequired(true); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _start - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); - { //-- local scope - org.exolab.castor.xml.validators.LongValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.LongValidator(); - fieldValidator.setValidator(typeValidator); - } - desc.setValidator(fieldValidator); - //-- _end - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Long.TYPE, "_end", "end", org.exolab.castor.xml.NodeType.Attribute); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - SequenceType target = (SequenceType) object; - if (!target.hasEnd()) { return null; } - return new java.lang.Long(target.getEnd()); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - SequenceType target = (SequenceType) object; - // ignore null values for non optional primitives - if (value == null) { return; } - - target.setEnd( ((java.lang.Long) value).longValue()); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return null; - } - }; - desc.setHandler(handler); - desc.setRequired(true); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _end - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); - { //-- local scope - org.exolab.castor.xml.validators.LongValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.LongValidator(); - fieldValidator.setValidator(typeValidator); - } - desc.setValidator(fieldValidator); - //-- initialize element descriptors - - //-- _sequence - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_sequence", "sequence", org.exolab.castor.xml.NodeType.Element); - desc.setImmutable(true); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - SequenceType target = (SequenceType) object; - return target.getSequence(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - SequenceType target = (SequenceType) object; - target.setSequence( (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); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setRequired(true); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _sequence - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); - { //-- local scope - org.exolab.castor.xml.validators.StringValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.StringValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setWhiteSpace("preserve"); +public class SequenceTypeDescriptor extends + org.exolab.castor.xml.util.XMLClassDescriptorImpl { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _elementDefinition. + */ + private boolean _elementDefinition; + + /** + * Field _nsPrefix. + */ + private java.lang.String _nsPrefix; + + /** + * Field _nsURI. + */ + private java.lang.String _nsURI; + + /** + * Field _xmlName. + */ + private java.lang.String _xmlName; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public SequenceTypeDescriptor() { + super(); + _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; + _xmlName = "SequenceType"; + _elementDefinition = false; + + // -- set grouping compositor + setCompositorAsSequence(); + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + // -- initialize attribute descriptors + + // -- _start + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.Long.TYPE, "_start", "start", + org.exolab.castor.xml.NodeType.Attribute); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + SequenceType target = (SequenceType) object; + if (!target.hasStart()) { + return null; } - desc.setValidator(fieldValidator); - //-- _name - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_name", "name", org.exolab.castor.xml.NodeType.Element); - desc.setImmutable(true); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - SequenceType target = (SequenceType) object; - return target.getName(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - SequenceType target = (SequenceType) object; - target.setName( (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); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setRequired(true); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _name - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); - { //-- local scope - org.exolab.castor.xml.validators.StringValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.StringValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setWhiteSpace("preserve"); + return new java.lang.Long(target.getStart()); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + SequenceType target = (SequenceType) object; + // ignore null values for non optional primitives + if (value == null) { + return; + } + + target.setStart(((java.lang.Long) value).longValue()); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- _description - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_description", "description", org.exolab.castor.xml.NodeType.Element); - desc.setImmutable(true); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - SequenceType target = (SequenceType) object; - return target.getDescription(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - SequenceType target = (SequenceType) object; - target.setDescription( (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); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _description - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope - org.exolab.castor.xml.validators.StringValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.StringValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setWhiteSpace("preserve"); + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return null; + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _start + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { // -- local scope + org.exolab.castor.xml.validators.LongValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.LongValidator(); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + // -- _end + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.Long.TYPE, "_end", "end", + org.exolab.castor.xml.NodeType.Attribute); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + SequenceType target = (SequenceType) object; + if (!target.hasEnd()) { + return null; } - desc.setValidator(fieldValidator); - //-- _propertyList - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(uk.ac.vamsas.objects.core.Property.class, "_propertyList", "property", org.exolab.castor.xml.NodeType.Element); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - SequenceType target = (SequenceType) object; - return target.getProperty(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - SequenceType target = (SequenceType) object; - target.addProperty( (uk.ac.vamsas.objects.core.Property) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public void resetValue(Object object) throws IllegalStateException, IllegalArgumentException { - try { - SequenceType target = (SequenceType) object; - target.removeAllProperty(); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new uk.ac.vamsas.objects.core.Property(); - } - }; - desc.setHandler(handler); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setMultivalued(true); - addFieldDescriptor(desc); - - //-- validation code for: _propertyList - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(0); - { //-- local scope + return new java.lang.Long(target.getEnd()); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + SequenceType target = (SequenceType) object; + // ignore null values for non optional primitives + if (value == null) { + return; + } + + target.setEnd(((java.lang.Long) value).longValue()); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return null; + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _end + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { // -- local scope + org.exolab.castor.xml.validators.LongValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.LongValidator(); + fieldValidator.setValidator(typeValidator); } + desc.setValidator(fieldValidator); + // -- initialize element descriptors + // -- _sequence + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_sequence", "sequence", + org.exolab.castor.xml.NodeType.Element); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + SequenceType target = (SequenceType) object; + return target.getSequence(); + } - //-----------/ - //- Methods -/ - //-----------/ + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + SequenceType target = (SequenceType) object; + target.setSequence((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getAccessMode. - * - * @return the access mode specified for this class. - */ - public org.exolab.castor.mapping.AccessMode getAccessMode( - ) { + public java.lang.Object newInstance(java.lang.Object parent) { return null; - } + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); - /** - * Method getIdentity. - * - * @return the identity field, null if this class has no - * identity. - */ - public org.exolab.castor.mapping.FieldDescriptor getIdentity( - ) { - return super.getIdentity(); + // -- validation code for: _sequence + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { // -- local scope + org.exolab.castor.xml.validators.StringValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.StringValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setWhiteSpace("preserve"); } + desc.setValidator(fieldValidator); + // -- _name + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_name", "name", + org.exolab.castor.xml.NodeType.Element); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + SequenceType target = (SequenceType) object; + return target.getName(); + } - /** - * Method getJavaClass. - * - * @return the Java class represented by this descriptor. - */ - public java.lang.Class getJavaClass( - ) { - return uk.ac.vamsas.objects.core.SequenceType.class; - } + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + SequenceType target = (SequenceType) object; + target.setName((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getNameSpacePrefix. - * - * @return the namespace prefix to use when marshaling as XML. - */ - public java.lang.String getNameSpacePrefix( - ) { - return _nsPrefix; - } + public java.lang.Object newInstance(java.lang.Object parent) { + return null; + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); - /** - * Method getNameSpaceURI. - * - * @return the namespace URI used when marshaling and - * unmarshaling as XML. - */ - public java.lang.String getNameSpaceURI( - ) { - return _nsURI; + // -- validation code for: _name + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { // -- local scope + org.exolab.castor.xml.validators.StringValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.StringValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setWhiteSpace("preserve"); } + desc.setValidator(fieldValidator); + // -- _description + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_description", "description", + org.exolab.castor.xml.NodeType.Element); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + SequenceType target = (SequenceType) object; + return target.getDescription(); + } - /** - * Method getValidator. - * - * @return a specific validator for the class described by this - * ClassDescriptor. - */ - public org.exolab.castor.xml.TypeValidator getValidator( - ) { - return this; - } + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + SequenceType target = (SequenceType) object; + target.setDescription((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); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setMultivalued(false); + addFieldDescriptor(desc); - /** - * Method getXMLName. - * - * @return the XML Name for the Class being described. - */ - public java.lang.String getXMLName( - ) { - return _xmlName; + // -- validation code for: _description + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { // -- local scope + org.exolab.castor.xml.validators.StringValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.StringValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setWhiteSpace("preserve"); } + desc.setValidator(fieldValidator); + // -- _propertyList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + uk.ac.vamsas.objects.core.Property.class, "_propertyList", "property", + org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + SequenceType target = (SequenceType) object; + return target.getProperty(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + SequenceType target = (SequenceType) object; + target.addProperty((uk.ac.vamsas.objects.core.Property) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method isElementDefinition. - * - * @return true if XML schema definition of this Class is that - * of a global - * element or element with anonymous type definition. - */ - public boolean isElementDefinition( - ) { - return _elementDefinition; + public void resetValue(Object object) throws IllegalStateException, + IllegalArgumentException { + try { + SequenceType target = (SequenceType) object; + target.removeAllProperty(); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return new uk.ac.vamsas.objects.core.Property(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + // -- validation code for: _propertyList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { // -- local scope } + desc.setValidator(fieldValidator); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * Method getAccessMode. + * + * @return the access mode specified for this class. + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() { + return null; + } + + /** + * Method getIdentity. + * + * @return the identity field, null if this class has no identity. + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() { + return super.getIdentity(); + } + + /** + * Method getJavaClass. + * + * @return the Java class represented by this descriptor. + */ + public java.lang.Class getJavaClass() { + return uk.ac.vamsas.objects.core.SequenceType.class; + } + + /** + * Method getNameSpacePrefix. + * + * @return the namespace prefix to use when marshaling as XML. + */ + public java.lang.String getNameSpacePrefix() { + return _nsPrefix; + } + + /** + * Method getNameSpaceURI. + * + * @return the namespace URI used when marshaling and unmarshaling as XML. + */ + public java.lang.String getNameSpaceURI() { + return _nsURI; + } + + /** + * Method getValidator. + * + * @return a specific validator for the class described by this + * ClassDescriptor. + */ + public org.exolab.castor.xml.TypeValidator getValidator() { + return this; + } + + /** + * Method getXMLName. + * + * @return the XML Name for the Class being described. + */ + public java.lang.String getXMLName() { + return _xmlName; + } + + /** + * Method isElementDefinition. + * + * @return true if XML schema definition of this Class is that of a global + * element or element with anonymous type definition. + */ + public boolean isElementDefinition() { + return _elementDefinition; + } } diff --git a/src/uk/ac/vamsas/objects/core/descriptors/TreeDescriptor.java b/src/uk/ac/vamsas/objects/core/descriptors/TreeDescriptor.java index 19f0b42..8a8907a 100644 --- a/src/uk/ac/vamsas/objects/core/descriptors/TreeDescriptor.java +++ b/src/uk/ac/vamsas/objects/core/descriptors/TreeDescriptor.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core.descriptors; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import uk.ac.vamsas.objects.core.Tree; @@ -18,416 +32,423 @@ import uk.ac.vamsas.objects.core.Tree; * * @version $Revision$ $Date$ */ -public class TreeDescriptor extends org.exolab.castor.xml.util.XMLClassDescriptorImpl { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _elementDefinition. - */ - private boolean _elementDefinition; - - /** - * Field _nsPrefix. - */ - private java.lang.String _nsPrefix; - - /** - * Field _nsURI. - */ - private java.lang.String _nsURI; - - /** - * Field _xmlName. - */ - private java.lang.String _xmlName; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public TreeDescriptor() { - super(); - _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; - _xmlName = "Tree"; - _elementDefinition = true; - - //-- set grouping compositor - setCompositorAsSequence(); - org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; - org.exolab.castor.mapping.FieldHandler handler = null; - org.exolab.castor.xml.FieldValidator fieldValidator = null; - //-- initialize attribute descriptors - - //-- _id - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_id", "id", org.exolab.castor.xml.NodeType.Attribute); - super.setIdentity(desc); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - Tree target = (Tree) object; - return target.getId(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Tree target = (Tree) object; - target.setId( (java.lang.String) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new java.lang.String(); - } - }; - desc.setHandler(handler); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _id - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope - org.exolab.castor.xml.validators.IdValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.IdValidator(); - fieldValidator.setValidator(typeValidator); +public class TreeDescriptor extends + org.exolab.castor.xml.util.XMLClassDescriptorImpl { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _elementDefinition. + */ + private boolean _elementDefinition; + + /** + * Field _nsPrefix. + */ + private java.lang.String _nsPrefix; + + /** + * Field _nsURI. + */ + private java.lang.String _nsURI; + + /** + * Field _xmlName. + */ + private java.lang.String _xmlName; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public TreeDescriptor() { + super(); + _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; + _xmlName = "Tree"; + _elementDefinition = true; + + // -- set grouping compositor + setCompositorAsSequence(); + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + // -- initialize attribute descriptors + + // -- _id + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_id", "id", + org.exolab.castor.xml.NodeType.Attribute); + super.setIdentity(desc); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + Tree target = (Tree) object; + return target.getId(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Tree target = (Tree) object; + target.setId((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- _modifiable - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_modifiable", "modifiable", 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 - { - Tree target = (Tree) object; - return target.getModifiable(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Tree target = (Tree) object; - target.setModifiable( (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); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _modifiable - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope - org.exolab.castor.xml.validators.StringValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.StringValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setWhiteSpace("preserve"); + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return new java.lang.String(); + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _id + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { // -- local scope + org.exolab.castor.xml.validators.IdValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.IdValidator(); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + // -- _modifiable + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_modifiable", "modifiable", + 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 { + Tree target = (Tree) object; + return target.getModifiable(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Tree target = (Tree) object; + target.setModifiable((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- initialize element descriptors - - //-- _title - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_title", "title", org.exolab.castor.xml.NodeType.Element); - desc.setImmutable(true); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - Tree target = (Tree) object; - return target.getTitle(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Tree target = (Tree) object; - target.setTitle( (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); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _title - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope - org.exolab.castor.xml.validators.StringValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.StringValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setWhiteSpace("preserve"); + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return null; + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _modifiable + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { // -- local scope + org.exolab.castor.xml.validators.StringValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.StringValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setWhiteSpace("preserve"); + } + desc.setValidator(fieldValidator); + // -- initialize element descriptors + + // -- _title + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_title", "title", + org.exolab.castor.xml.NodeType.Element); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + Tree target = (Tree) object; + return target.getTitle(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Tree target = (Tree) object; + target.setTitle((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- _newickList - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(uk.ac.vamsas.objects.core.Newick.class, "_newickList", "newick", org.exolab.castor.xml.NodeType.Element); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - Tree target = (Tree) object; - return target.getNewick(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Tree target = (Tree) object; - target.addNewick( (uk.ac.vamsas.objects.core.Newick) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public void resetValue(Object object) throws IllegalStateException, IllegalArgumentException { - try { - Tree target = (Tree) object; - target.removeAllNewick(); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new uk.ac.vamsas.objects.core.Newick(); - } - }; - desc.setHandler(handler); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setRequired(true); - desc.setMultivalued(true); - addFieldDescriptor(desc); - - //-- validation code for: _newickList - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); - { //-- local scope + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return null; + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _title + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { // -- local scope + org.exolab.castor.xml.validators.StringValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.StringValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setWhiteSpace("preserve"); + } + desc.setValidator(fieldValidator); + // -- _newickList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + uk.ac.vamsas.objects.core.Newick.class, "_newickList", "newick", + org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + Tree target = (Tree) object; + return target.getNewick(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Tree target = (Tree) object; + target.addNewick((uk.ac.vamsas.objects.core.Newick) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- _treenodeList - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(uk.ac.vamsas.objects.core.Treenode.class, "_treenodeList", "treenode", org.exolab.castor.xml.NodeType.Element); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - Tree target = (Tree) object; - return target.getTreenode(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Tree target = (Tree) object; - target.addTreenode( (uk.ac.vamsas.objects.core.Treenode) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public void resetValue(Object object) throws IllegalStateException, IllegalArgumentException { - try { - Tree target = (Tree) object; - target.removeAllTreenode(); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new uk.ac.vamsas.objects.core.Treenode(); - } - }; - desc.setHandler(handler); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setMultivalued(true); - addFieldDescriptor(desc); - - //-- validation code for: _treenodeList - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(0); - { //-- local scope + } + + public void resetValue(Object object) throws IllegalStateException, + IllegalArgumentException { + try { + Tree target = (Tree) object; + target.removeAllNewick(); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- _propertyList - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(uk.ac.vamsas.objects.core.Property.class, "_propertyList", "property", org.exolab.castor.xml.NodeType.Element); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - Tree target = (Tree) object; - return target.getProperty(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Tree target = (Tree) object; - target.addProperty( (uk.ac.vamsas.objects.core.Property) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public void resetValue(Object object) throws IllegalStateException, IllegalArgumentException { - try { - Tree target = (Tree) object; - target.removeAllProperty(); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new uk.ac.vamsas.objects.core.Property(); - } - }; - desc.setHandler(handler); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setMultivalued(true); - addFieldDescriptor(desc); - - //-- validation code for: _propertyList - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(0); - { //-- local scope + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return new uk.ac.vamsas.objects.core.Newick(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setRequired(true); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + // -- validation code for: _newickList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { // -- local scope + } + desc.setValidator(fieldValidator); + // -- _treenodeList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + uk.ac.vamsas.objects.core.Treenode.class, "_treenodeList", "treenode", + org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + Tree target = (Tree) object; + return target.getTreenode(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Tree target = (Tree) object; + target.addTreenode((uk.ac.vamsas.objects.core.Treenode) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- _provenance - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(uk.ac.vamsas.objects.core.Provenance.class, "_provenance", "Provenance", org.exolab.castor.xml.NodeType.Element); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - Tree target = (Tree) object; - return target.getProvenance(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Tree target = (Tree) object; - target.setProvenance( (uk.ac.vamsas.objects.core.Provenance) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new uk.ac.vamsas.objects.core.Provenance(); - } - }; - desc.setHandler(handler); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setRequired(true); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _provenance - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); - { //-- local scope + } + + public void resetValue(Object object) throws IllegalStateException, + IllegalArgumentException { + try { + Tree target = (Tree) object; + target.removeAllTreenode(); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return new uk.ac.vamsas.objects.core.Treenode(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + // -- validation code for: _treenodeList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { // -- local scope } + desc.setValidator(fieldValidator); + // -- _propertyList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + uk.ac.vamsas.objects.core.Property.class, "_propertyList", "property", + org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + Tree target = (Tree) object; + return target.getProperty(); + } + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Tree target = (Tree) object; + target.addProperty((uk.ac.vamsas.objects.core.Property) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - //-----------/ - //- Methods -/ - //-----------/ + public void resetValue(Object object) throws IllegalStateException, + IllegalArgumentException { + try { + Tree target = (Tree) object; + target.removeAllProperty(); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getAccessMode. - * - * @return the access mode specified for this class. - */ - public org.exolab.castor.mapping.AccessMode getAccessMode( - ) { - return null; - } + public java.lang.Object newInstance(java.lang.Object parent) { + return new uk.ac.vamsas.objects.core.Property(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setMultivalued(true); + addFieldDescriptor(desc); - /** - * Method getIdentity. - * - * @return the identity field, null if this class has no - * identity. - */ - public org.exolab.castor.mapping.FieldDescriptor getIdentity( - ) { - return super.getIdentity(); + // -- validation code for: _propertyList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { // -- local scope } + desc.setValidator(fieldValidator); + // -- _provenance + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + uk.ac.vamsas.objects.core.Provenance.class, "_provenance", + "Provenance", org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + Tree target = (Tree) object; + return target.getProvenance(); + } - /** - * Method getJavaClass. - * - * @return the Java class represented by this descriptor. - */ - public java.lang.Class getJavaClass( - ) { - return uk.ac.vamsas.objects.core.Tree.class; - } + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Tree target = (Tree) object; + target.setProvenance((uk.ac.vamsas.objects.core.Provenance) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getNameSpacePrefix. - * - * @return the namespace prefix to use when marshaling as XML. - */ - public java.lang.String getNameSpacePrefix( - ) { - return _nsPrefix; - } + public java.lang.Object newInstance(java.lang.Object parent) { + return new uk.ac.vamsas.objects.core.Provenance(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); - /** - * Method getNameSpaceURI. - * - * @return the namespace URI used when marshaling and - * unmarshaling as XML. - */ - public java.lang.String getNameSpaceURI( - ) { - return _nsURI; + // -- validation code for: _provenance + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { // -- local scope } + desc.setValidator(fieldValidator); + } - /** - * Method getValidator. - * - * @return a specific validator for the class described by this - * ClassDescriptor. - */ - public org.exolab.castor.xml.TypeValidator getValidator( - ) { - return this; - } + // -----------/ + // - Methods -/ + // -----------/ - /** - * Method getXMLName. - * - * @return the XML Name for the Class being described. - */ - public java.lang.String getXMLName( - ) { - return _xmlName; - } + /** + * Method getAccessMode. + * + * @return the access mode specified for this class. + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() { + return null; + } - /** - * Method isElementDefinition. - * - * @return true if XML schema definition of this Class is that - * of a global - * element or element with anonymous type definition. - */ - public boolean isElementDefinition( - ) { - return _elementDefinition; - } + /** + * Method getIdentity. + * + * @return the identity field, null if this class has no identity. + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() { + return super.getIdentity(); + } + + /** + * Method getJavaClass. + * + * @return the Java class represented by this descriptor. + */ + public java.lang.Class getJavaClass() { + return uk.ac.vamsas.objects.core.Tree.class; + } + + /** + * Method getNameSpacePrefix. + * + * @return the namespace prefix to use when marshaling as XML. + */ + public java.lang.String getNameSpacePrefix() { + return _nsPrefix; + } + + /** + * Method getNameSpaceURI. + * + * @return the namespace URI used when marshaling and unmarshaling as XML. + */ + public java.lang.String getNameSpaceURI() { + return _nsURI; + } + + /** + * Method getValidator. + * + * @return a specific validator for the class described by this + * ClassDescriptor. + */ + public org.exolab.castor.xml.TypeValidator getValidator() { + return this; + } + + /** + * Method getXMLName. + * + * @return the XML Name for the Class being described. + */ + public java.lang.String getXMLName() { + return _xmlName; + } + + /** + * Method isElementDefinition. + * + * @return true if XML schema definition of this Class is that of a global + * element or element with anonymous type definition. + */ + public boolean isElementDefinition() { + return _elementDefinition; + } } diff --git a/src/uk/ac/vamsas/objects/core/descriptors/TreenodeDescriptor.java b/src/uk/ac/vamsas/objects/core/descriptors/TreenodeDescriptor.java index 4108527..8e16388 100644 --- a/src/uk/ac/vamsas/objects/core/descriptors/TreenodeDescriptor.java +++ b/src/uk/ac/vamsas/objects/core/descriptors/TreenodeDescriptor.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core.descriptors; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import uk.ac.vamsas.objects.core.Treenode; @@ -18,224 +32,217 @@ import uk.ac.vamsas.objects.core.Treenode; * * @version $Revision$ $Date$ */ -public class TreenodeDescriptor extends uk.ac.vamsas.objects.core.descriptors.NodeTypeDescriptor { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _elementDefinition. - */ - private boolean _elementDefinition; - - /** - * Field _nsPrefix. - */ - private java.lang.String _nsPrefix; - - /** - * Field _nsURI. - */ - private java.lang.String _nsURI; - - /** - * Field _xmlName. - */ - private java.lang.String _xmlName; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public TreenodeDescriptor() { - super(); - setExtendsWithoutFlatten(new uk.ac.vamsas.objects.core.descriptors.NodeTypeDescriptor()); - _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; - _xmlName = "treenode"; - _elementDefinition = true; - org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; - org.exolab.castor.mapping.FieldHandler handler = null; - org.exolab.castor.xml.FieldValidator fieldValidator = null; - //-- initialize attribute descriptors - - //-- _treeId - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Object.class, "_treeId", "treeId", org.exolab.castor.xml.NodeType.Attribute); - desc.setReference(true); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - Treenode target = (Treenode) object; - return target.getTreeId(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Treenode target = (Treenode) object; - target.addTreeId( (java.lang.Object) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public void resetValue(Object object) throws IllegalStateException, IllegalArgumentException { - try { - Treenode target = (Treenode) object; - target.removeAllTreeId(); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new java.lang.Object(); - } - }; - desc.setMultivalued(true); - desc.setHandler(handler); - desc.setMultivalued(true); - addFieldDescriptor(desc); - - //-- validation code for: _treeId - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(0); - { //-- local scope - org.exolab.castor.xml.validators.IdRefsValidator typeValidator = new org.exolab.castor.xml.validators.IdRefsValidator(); - fieldValidator.setValidator(typeValidator); - desc.setValidator(fieldValidator); +public class TreenodeDescriptor extends + uk.ac.vamsas.objects.core.descriptors.NodeTypeDescriptor { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _elementDefinition. + */ + private boolean _elementDefinition; + + /** + * Field _nsPrefix. + */ + private java.lang.String _nsPrefix; + + /** + * Field _nsURI. + */ + private java.lang.String _nsURI; + + /** + * Field _xmlName. + */ + private java.lang.String _xmlName; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public TreenodeDescriptor() { + super(); + setExtendsWithoutFlatten(new uk.ac.vamsas.objects.core.descriptors.NodeTypeDescriptor()); + _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; + _xmlName = "treenode"; + _elementDefinition = true; + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + // -- initialize attribute descriptors + + // -- _treeId + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.Object.class, "_treeId", "treeId", + org.exolab.castor.xml.NodeType.Attribute); + desc.setReference(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + Treenode target = (Treenode) object; + return target.getTreeId(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Treenode target = (Treenode) object; + target.addTreeId((java.lang.Object) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- _nodespec - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_nodespec", "nodespec", 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 - { - Treenode target = (Treenode) object; - return target.getNodespec(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - Treenode target = (Treenode) object; - target.setNodespec( (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); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _nodespec - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope - org.exolab.castor.xml.validators.StringValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.StringValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setWhiteSpace("preserve"); + } + + public void resetValue(Object object) throws IllegalStateException, + IllegalArgumentException { + try { + Treenode target = (Treenode) object; + target.removeAllTreeId(); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- initialize element descriptors - + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return new java.lang.Object(); + } + }; + desc.setMultivalued(true); + desc.setHandler(handler); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + // -- validation code for: _treeId + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { // -- local scope + org.exolab.castor.xml.validators.IdRefsValidator typeValidator = new org.exolab.castor.xml.validators.IdRefsValidator(); + fieldValidator.setValidator(typeValidator); + desc.setValidator(fieldValidator); } + desc.setValidator(fieldValidator); + // -- _nodespec + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_nodespec", "nodespec", + 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 { + Treenode target = (Treenode) object; + return target.getNodespec(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + Treenode target = (Treenode) object; + target.setNodespec((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Method getAccessMode. - * - * @return the access mode specified for this class. - */ - public org.exolab.castor.mapping.AccessMode getAccessMode( - ) { + public java.lang.Object newInstance(java.lang.Object parent) { return null; + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _nodespec + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { // -- local scope + org.exolab.castor.xml.validators.StringValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.StringValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setWhiteSpace("preserve"); } - - /** - * Method getIdentity. - * - * @return the identity field, null if this class has no - * identity. - */ - public org.exolab.castor.mapping.FieldDescriptor getIdentity( - ) { - return super.getIdentity(); - } - - /** - * Method getJavaClass. - * - * @return the Java class represented by this descriptor. - */ - public java.lang.Class getJavaClass( - ) { - return uk.ac.vamsas.objects.core.Treenode.class; - } - - /** - * Method getNameSpacePrefix. - * - * @return the namespace prefix to use when marshaling as XML. - */ - public java.lang.String getNameSpacePrefix( - ) { - return _nsPrefix; - } - - /** - * Method getNameSpaceURI. - * - * @return the namespace URI used when marshaling and - * unmarshaling as XML. - */ - public java.lang.String getNameSpaceURI( - ) { - return _nsURI; - } - - /** - * Method getValidator. - * - * @return a specific validator for the class described by this - * ClassDescriptor. - */ - public org.exolab.castor.xml.TypeValidator getValidator( - ) { - return this; - } - - /** - * Method getXMLName. - * - * @return the XML Name for the Class being described. - */ - public java.lang.String getXMLName( - ) { - return _xmlName; - } - - /** - * Method isElementDefinition. - * - * @return true if XML schema definition of this Class is that - * of a global - * element or element with anonymous type definition. - */ - public boolean isElementDefinition( - ) { - return _elementDefinition; - } + desc.setValidator(fieldValidator); + // -- initialize element descriptors + + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * Method getAccessMode. + * + * @return the access mode specified for this class. + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() { + return null; + } + + /** + * Method getIdentity. + * + * @return the identity field, null if this class has no identity. + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() { + return super.getIdentity(); + } + + /** + * Method getJavaClass. + * + * @return the Java class represented by this descriptor. + */ + public java.lang.Class getJavaClass() { + return uk.ac.vamsas.objects.core.Treenode.class; + } + + /** + * Method getNameSpacePrefix. + * + * @return the namespace prefix to use when marshaling as XML. + */ + public java.lang.String getNameSpacePrefix() { + return _nsPrefix; + } + + /** + * Method getNameSpaceURI. + * + * @return the namespace URI used when marshaling and unmarshaling as XML. + */ + public java.lang.String getNameSpaceURI() { + return _nsURI; + } + + /** + * Method getValidator. + * + * @return a specific validator for the class described by this + * ClassDescriptor. + */ + public org.exolab.castor.xml.TypeValidator getValidator() { + return this; + } + + /** + * Method getXMLName. + * + * @return the XML Name for the Class being described. + */ + public java.lang.String getXMLName() { + return _xmlName; + } + + /** + * Method isElementDefinition. + * + * @return true if XML schema definition of this Class is that of a global + * element or element with anonymous type definition. + */ + public boolean isElementDefinition() { + return _elementDefinition; + } } diff --git a/src/uk/ac/vamsas/objects/core/descriptors/UserDescriptor.java b/src/uk/ac/vamsas/objects/core/descriptors/UserDescriptor.java index 8a6e724..4d5a95d 100644 --- a/src/uk/ac/vamsas/objects/core/descriptors/UserDescriptor.java +++ b/src/uk/ac/vamsas/objects/core/descriptors/UserDescriptor.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core.descriptors; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import uk.ac.vamsas.objects.core.User; @@ -18,219 +32,210 @@ import uk.ac.vamsas.objects.core.User; * * @version $Revision$ $Date$ */ -public class UserDescriptor extends uk.ac.vamsas.objects.core.descriptors.AppDataDescriptor { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _elementDefinition. - */ - private boolean _elementDefinition; - - /** - * Field _nsPrefix. - */ - private java.lang.String _nsPrefix; - - /** - * Field _nsURI. - */ - private java.lang.String _nsURI; - - /** - * Field _xmlName. - */ - private java.lang.String _xmlName; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public UserDescriptor() { - super(); - setExtendsWithoutFlatten(new uk.ac.vamsas.objects.core.descriptors.AppDataDescriptor()); - _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; - _xmlName = "User"; - _elementDefinition = true; - org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; - org.exolab.castor.mapping.FieldHandler handler = null; - org.exolab.castor.xml.FieldValidator fieldValidator = null; - //-- initialize attribute descriptors - - //-- _fullname - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_fullname", "fullname", 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 - { - User target = (User) object; - return target.getFullname(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - User target = (User) object; - target.setFullname( (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); - desc.setRequired(true); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _fullname - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); - { //-- local scope - org.exolab.castor.xml.validators.StringValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.StringValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setWhiteSpace("preserve"); - } - desc.setValidator(fieldValidator); - //-- _organization - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_organization", "organization", 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 - { - User target = (User) object; - return target.getOrganization(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - User target = (User) object; - target.setOrganization( (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); - desc.setRequired(true); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _organization - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); - { //-- local scope - org.exolab.castor.xml.validators.StringValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.StringValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setWhiteSpace("preserve"); +public class UserDescriptor extends + uk.ac.vamsas.objects.core.descriptors.AppDataDescriptor { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _elementDefinition. + */ + private boolean _elementDefinition; + + /** + * Field _nsPrefix. + */ + private java.lang.String _nsPrefix; + + /** + * Field _nsURI. + */ + private java.lang.String _nsURI; + + /** + * Field _xmlName. + */ + private java.lang.String _xmlName; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public UserDescriptor() { + super(); + setExtendsWithoutFlatten(new uk.ac.vamsas.objects.core.descriptors.AppDataDescriptor()); + _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; + _xmlName = "User"; + _elementDefinition = true; + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + // -- initialize attribute descriptors + + // -- _fullname + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_fullname", "fullname", + 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 { + User target = (User) object; + return target.getFullname(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + User target = (User) object; + target.setFullname((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- initialize element descriptors - - } - - - //-----------/ - //- Methods -/ - //-----------/ + } - /** - * Method getAccessMode. - * - * @return the access mode specified for this class. - */ - public org.exolab.castor.mapping.AccessMode getAccessMode( - ) { + public java.lang.Object newInstance(java.lang.Object parent) { return null; + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _fullname + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { // -- local scope + org.exolab.castor.xml.validators.StringValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.StringValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setWhiteSpace("preserve"); } + desc.setValidator(fieldValidator); + // -- _organization + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_organization", "organization", + 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 { + User target = (User) object; + return target.getOrganization(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + User target = (User) object; + target.setOrganization((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getIdentity. - * - * @return the identity field, null if this class has no - * identity. - */ - public org.exolab.castor.mapping.FieldDescriptor getIdentity( - ) { - return super.getIdentity(); - } - - /** - * Method getJavaClass. - * - * @return the Java class represented by this descriptor. - */ - public java.lang.Class getJavaClass( - ) { - return uk.ac.vamsas.objects.core.User.class; - } - - /** - * Method getNameSpacePrefix. - * - * @return the namespace prefix to use when marshaling as XML. - */ - public java.lang.String getNameSpacePrefix( - ) { - return _nsPrefix; - } - - /** - * Method getNameSpaceURI. - * - * @return the namespace URI used when marshaling and - * unmarshaling as XML. - */ - public java.lang.String getNameSpaceURI( - ) { - return _nsURI; - } - - /** - * Method getValidator. - * - * @return a specific validator for the class described by this - * ClassDescriptor. - */ - public org.exolab.castor.xml.TypeValidator getValidator( - ) { - return this; - } - - /** - * Method getXMLName. - * - * @return the XML Name for the Class being described. - */ - public java.lang.String getXMLName( - ) { - return _xmlName; - } - - /** - * Method isElementDefinition. - * - * @return true if XML schema definition of this Class is that - * of a global - * element or element with anonymous type definition. - */ - public boolean isElementDefinition( - ) { - return _elementDefinition; + public java.lang.Object newInstance(java.lang.Object parent) { + return null; + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _organization + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { // -- local scope + org.exolab.castor.xml.validators.StringValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.StringValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setWhiteSpace("preserve"); } + desc.setValidator(fieldValidator); + // -- initialize element descriptors + + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * Method getAccessMode. + * + * @return the access mode specified for this class. + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() { + return null; + } + + /** + * Method getIdentity. + * + * @return the identity field, null if this class has no identity. + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() { + return super.getIdentity(); + } + + /** + * Method getJavaClass. + * + * @return the Java class represented by this descriptor. + */ + public java.lang.Class getJavaClass() { + return uk.ac.vamsas.objects.core.User.class; + } + + /** + * Method getNameSpacePrefix. + * + * @return the namespace prefix to use when marshaling as XML. + */ + public java.lang.String getNameSpacePrefix() { + return _nsPrefix; + } + + /** + * Method getNameSpaceURI. + * + * @return the namespace URI used when marshaling and unmarshaling as XML. + */ + public java.lang.String getNameSpaceURI() { + return _nsURI; + } + + /** + * Method getValidator. + * + * @return a specific validator for the class described by this + * ClassDescriptor. + */ + public org.exolab.castor.xml.TypeValidator getValidator() { + return this; + } + + /** + * Method getXMLName. + * + * @return the XML Name for the Class being described. + */ + public java.lang.String getXMLName() { + return _xmlName; + } + + /** + * Method isElementDefinition. + * + * @return true if XML schema definition of this Class is that of a global + * element or element with anonymous type definition. + */ + public boolean isElementDefinition() { + return _elementDefinition; + } } diff --git a/src/uk/ac/vamsas/objects/core/descriptors/VAMSASDescriptor.java b/src/uk/ac/vamsas/objects/core/descriptors/VAMSASDescriptor.java index b999ff4..3402057 100644 --- a/src/uk/ac/vamsas/objects/core/descriptors/VAMSASDescriptor.java +++ b/src/uk/ac/vamsas/objects/core/descriptors/VAMSASDescriptor.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core.descriptors; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import uk.ac.vamsas.objects.core.VAMSAS; @@ -18,300 +32,299 @@ import uk.ac.vamsas.objects.core.VAMSAS; * * @version $Revision$ $Date$ */ -public class VAMSASDescriptor extends org.exolab.castor.xml.util.XMLClassDescriptorImpl { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _elementDefinition. - */ - private boolean _elementDefinition; - - /** - * Field _nsPrefix. - */ - private java.lang.String _nsPrefix; - - /** - * Field _nsURI. - */ - private java.lang.String _nsURI; - - /** - * Field _xmlName. - */ - private java.lang.String _xmlName; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public VAMSASDescriptor() { - super(); - _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; - _xmlName = "VAMSAS"; - _elementDefinition = true; - - //-- set grouping compositor - setCompositorAsSequence(); - org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; - org.exolab.castor.mapping.FieldHandler handler = null; - org.exolab.castor.xml.FieldValidator fieldValidator = null; - //-- initialize attribute descriptors - - //-- _id - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_id", "id", org.exolab.castor.xml.NodeType.Attribute); - super.setIdentity(desc); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - VAMSAS target = (VAMSAS) object; - return target.getId(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - VAMSAS target = (VAMSAS) object; - target.setId( (java.lang.String) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new java.lang.String(); - } - }; - desc.setHandler(handler); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _id - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope - org.exolab.castor.xml.validators.IdValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.IdValidator(); - fieldValidator.setValidator(typeValidator); +public class VAMSASDescriptor extends + org.exolab.castor.xml.util.XMLClassDescriptorImpl { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _elementDefinition. + */ + private boolean _elementDefinition; + + /** + * Field _nsPrefix. + */ + private java.lang.String _nsPrefix; + + /** + * Field _nsURI. + */ + private java.lang.String _nsURI; + + /** + * Field _xmlName. + */ + private java.lang.String _xmlName; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public VAMSASDescriptor() { + super(); + _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; + _xmlName = "VAMSAS"; + _elementDefinition = true; + + // -- set grouping compositor + setCompositorAsSequence(); + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + // -- initialize attribute descriptors + + // -- _id + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_id", "id", + org.exolab.castor.xml.NodeType.Attribute); + super.setIdentity(desc); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + VAMSAS target = (VAMSAS) object; + return target.getId(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + VAMSAS target = (VAMSAS) object; + target.setId((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- _modifiable - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_modifiable", "modifiable", 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 - { - VAMSAS target = (VAMSAS) object; - return target.getModifiable(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - VAMSAS target = (VAMSAS) object; - target.setModifiable( (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); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _modifiable - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope - org.exolab.castor.xml.validators.StringValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.StringValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setWhiteSpace("preserve"); + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return new java.lang.String(); + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _id + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { // -- local scope + org.exolab.castor.xml.validators.IdValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.IdValidator(); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + // -- _modifiable + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_modifiable", "modifiable", + 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 { + VAMSAS target = (VAMSAS) object; + return target.getModifiable(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + VAMSAS target = (VAMSAS) object; + target.setModifiable((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- initialize element descriptors - - //-- _treeList - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(uk.ac.vamsas.objects.core.Tree.class, "_treeList", "Tree", org.exolab.castor.xml.NodeType.Element); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - VAMSAS target = (VAMSAS) object; - return target.getTree(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - VAMSAS target = (VAMSAS) object; - target.addTree( (uk.ac.vamsas.objects.core.Tree) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public void resetValue(Object object) throws IllegalStateException, IllegalArgumentException { - try { - VAMSAS target = (VAMSAS) object; - target.removeAllTree(); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new uk.ac.vamsas.objects.core.Tree(); - } - }; - desc.setHandler(handler); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setMultivalued(true); - addFieldDescriptor(desc); - - //-- validation code for: _treeList - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(0); - { //-- local scope + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return null; + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _modifiable + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { // -- local scope + org.exolab.castor.xml.validators.StringValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.StringValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setWhiteSpace("preserve"); + } + desc.setValidator(fieldValidator); + // -- initialize element descriptors + + // -- _treeList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + uk.ac.vamsas.objects.core.Tree.class, "_treeList", "Tree", + org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + VAMSAS target = (VAMSAS) object; + return target.getTree(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + VAMSAS target = (VAMSAS) object; + target.addTree((uk.ac.vamsas.objects.core.Tree) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- _dataSetList - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(uk.ac.vamsas.objects.core.DataSet.class, "_dataSetList", "DataSet", org.exolab.castor.xml.NodeType.Element); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - VAMSAS target = (VAMSAS) object; - return target.getDataSet(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - VAMSAS target = (VAMSAS) object; - target.addDataSet( (uk.ac.vamsas.objects.core.DataSet) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public void resetValue(Object object) throws IllegalStateException, IllegalArgumentException { - try { - VAMSAS target = (VAMSAS) object; - target.removeAllDataSet(); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new uk.ac.vamsas.objects.core.DataSet(); - } - }; - desc.setHandler(handler); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setMultivalued(true); - addFieldDescriptor(desc); - - //-- validation code for: _dataSetList - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(0); - { //-- local scope + } + + public void resetValue(Object object) throws IllegalStateException, + IllegalArgumentException { + try { + VAMSAS target = (VAMSAS) object; + target.removeAllTree(); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return new uk.ac.vamsas.objects.core.Tree(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + // -- validation code for: _treeList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { // -- local scope } + desc.setValidator(fieldValidator); + // -- _dataSetList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + uk.ac.vamsas.objects.core.DataSet.class, "_dataSetList", "DataSet", + org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + VAMSAS target = (VAMSAS) object; + return target.getDataSet(); + } + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + VAMSAS target = (VAMSAS) object; + target.addDataSet((uk.ac.vamsas.objects.core.DataSet) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - //-----------/ - //- Methods -/ - //-----------/ + public void resetValue(Object object) throws IllegalStateException, + IllegalArgumentException { + try { + VAMSAS target = (VAMSAS) object; + target.removeAllDataSet(); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getAccessMode. - * - * @return the access mode specified for this class. - */ - public org.exolab.castor.mapping.AccessMode getAccessMode( - ) { - return null; - } + public java.lang.Object newInstance(java.lang.Object parent) { + return new uk.ac.vamsas.objects.core.DataSet(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setMultivalued(true); + addFieldDescriptor(desc); - /** - * Method getIdentity. - * - * @return the identity field, null if this class has no - * identity. - */ - public org.exolab.castor.mapping.FieldDescriptor getIdentity( - ) { - return super.getIdentity(); + // -- validation code for: _dataSetList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { // -- local scope } + desc.setValidator(fieldValidator); + } - /** - * Method getJavaClass. - * - * @return the Java class represented by this descriptor. - */ - public java.lang.Class getJavaClass( - ) { - return uk.ac.vamsas.objects.core.VAMSAS.class; - } + // -----------/ + // - Methods -/ + // -----------/ - /** - * Method getNameSpacePrefix. - * - * @return the namespace prefix to use when marshaling as XML. - */ - public java.lang.String getNameSpacePrefix( - ) { - return _nsPrefix; - } + /** + * Method getAccessMode. + * + * @return the access mode specified for this class. + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() { + return null; + } - /** - * Method getNameSpaceURI. - * - * @return the namespace URI used when marshaling and - * unmarshaling as XML. - */ - public java.lang.String getNameSpaceURI( - ) { - return _nsURI; - } + /** + * Method getIdentity. + * + * @return the identity field, null if this class has no identity. + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() { + return super.getIdentity(); + } - /** - * Method getValidator. - * - * @return a specific validator for the class described by this - * ClassDescriptor. - */ - public org.exolab.castor.xml.TypeValidator getValidator( - ) { - return this; - } + /** + * Method getJavaClass. + * + * @return the Java class represented by this descriptor. + */ + public java.lang.Class getJavaClass() { + return uk.ac.vamsas.objects.core.VAMSAS.class; + } - /** - * Method getXMLName. - * - * @return the XML Name for the Class being described. - */ - public java.lang.String getXMLName( - ) { - return _xmlName; - } + /** + * Method getNameSpacePrefix. + * + * @return the namespace prefix to use when marshaling as XML. + */ + public java.lang.String getNameSpacePrefix() { + return _nsPrefix; + } - /** - * Method isElementDefinition. - * - * @return true if XML schema definition of this Class is that - * of a global - * element or element with anonymous type definition. - */ - public boolean isElementDefinition( - ) { - return _elementDefinition; - } + /** + * Method getNameSpaceURI. + * + * @return the namespace URI used when marshaling and unmarshaling as XML. + */ + public java.lang.String getNameSpaceURI() { + return _nsURI; + } + + /** + * Method getValidator. + * + * @return a specific validator for the class described by this + * ClassDescriptor. + */ + public org.exolab.castor.xml.TypeValidator getValidator() { + return this; + } + + /** + * Method getXMLName. + * + * @return the XML Name for the Class being described. + */ + public java.lang.String getXMLName() { + return _xmlName; + } + + /** + * Method isElementDefinition. + * + * @return true if XML schema definition of this Class is that of a global + * element or element with anonymous type definition. + */ + public boolean isElementDefinition() { + return _elementDefinition; + } } diff --git a/src/uk/ac/vamsas/objects/core/descriptors/VamsasDocumentDescriptor.java b/src/uk/ac/vamsas/objects/core/descriptors/VamsasDocumentDescriptor.java index 9c7a594..a7bf199 100644 --- a/src/uk/ac/vamsas/objects/core/descriptors/VamsasDocumentDescriptor.java +++ b/src/uk/ac/vamsas/objects/core/descriptors/VamsasDocumentDescriptor.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core.descriptors; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import uk.ac.vamsas.objects.core.VamsasDocument; @@ -18,376 +32,383 @@ import uk.ac.vamsas.objects.core.VamsasDocument; * * @version $Revision$ $Date$ */ -public class VamsasDocumentDescriptor extends org.exolab.castor.xml.util.XMLClassDescriptorImpl { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _elementDefinition. - */ - private boolean _elementDefinition; - - /** - * Field _nsPrefix. - */ - private java.lang.String _nsPrefix; - - /** - * Field _nsURI. - */ - private java.lang.String _nsURI; - - /** - * Field _xmlName. - */ - private java.lang.String _xmlName; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public VamsasDocumentDescriptor() { - super(); - _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasDocument"; - _xmlName = "VamsasDocument"; - _elementDefinition = true; - - //-- set grouping compositor - setCompositorAsSequence(); - org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; - org.exolab.castor.mapping.FieldHandler handler = null; - org.exolab.castor.xml.FieldValidator fieldValidator = null; - //-- initialize attribute descriptors - - //-- initialize element descriptors - - //-- _version - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_version", "Version", org.exolab.castor.xml.NodeType.Element); - desc.setImmutable(true); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - VamsasDocument target = (VamsasDocument) object; - return target.getVersion(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - VamsasDocument target = (VamsasDocument) object; - target.setVersion( (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); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasDocument"); - desc.setRequired(true); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _version - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); - { //-- local scope - org.exolab.castor.xml.validators.StringValidator typeValidator; - typeValidator = new org.exolab.castor.xml.validators.StringValidator(); - fieldValidator.setValidator(typeValidator); - typeValidator.setWhiteSpace("preserve"); - } - desc.setValidator(fieldValidator); - //-- _lockFile - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(uk.ac.vamsas.objects.core.LockFile.class, "_lockFile", "LockFile", org.exolab.castor.xml.NodeType.Element); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - VamsasDocument target = (VamsasDocument) object; - return target.getLockFile(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - VamsasDocument target = (VamsasDocument) object; - target.setLockFile( (uk.ac.vamsas.objects.core.LockFile) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new uk.ac.vamsas.objects.core.LockFile(); - } - }; - desc.setHandler(handler); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasDocument"); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _lockFile - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope +public class VamsasDocumentDescriptor extends + org.exolab.castor.xml.util.XMLClassDescriptorImpl { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _elementDefinition. + */ + private boolean _elementDefinition; + + /** + * Field _nsPrefix. + */ + private java.lang.String _nsPrefix; + + /** + * Field _nsURI. + */ + private java.lang.String _nsURI; + + /** + * Field _xmlName. + */ + private java.lang.String _xmlName; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public VamsasDocumentDescriptor() { + super(); + _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasDocument"; + _xmlName = "VamsasDocument"; + _elementDefinition = true; + + // -- set grouping compositor + setCompositorAsSequence(); + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + // -- initialize attribute descriptors + + // -- initialize element descriptors + + // -- _version + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + java.lang.String.class, "_version", "Version", + org.exolab.castor.xml.NodeType.Element); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + VamsasDocument target = (VamsasDocument) object; + return target.getVersion(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + VamsasDocument target = (VamsasDocument) object; + target.setVersion((java.lang.String) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- _provenance - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(uk.ac.vamsas.objects.core.Provenance.class, "_provenance", "Provenance", org.exolab.castor.xml.NodeType.Element); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - VamsasDocument target = (VamsasDocument) object; - return target.getProvenance(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - VamsasDocument target = (VamsasDocument) object; - target.setProvenance( (uk.ac.vamsas.objects.core.Provenance) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new uk.ac.vamsas.objects.core.Provenance(); - } - }; - desc.setHandler(handler); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setMultivalued(false); - addFieldDescriptor(desc); - - //-- validation code for: _provenance - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return null; + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasDocument"); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _version + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { // -- local scope + org.exolab.castor.xml.validators.StringValidator typeValidator; + typeValidator = new org.exolab.castor.xml.validators.StringValidator(); + fieldValidator.setValidator(typeValidator); + typeValidator.setWhiteSpace("preserve"); + } + desc.setValidator(fieldValidator); + // -- _lockFile + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + uk.ac.vamsas.objects.core.LockFile.class, "_lockFile", "LockFile", + org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + VamsasDocument target = (VamsasDocument) object; + return target.getLockFile(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + VamsasDocument target = (VamsasDocument) object; + target.setLockFile((uk.ac.vamsas.objects.core.LockFile) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- _VAMSASList - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(uk.ac.vamsas.objects.core.VAMSAS.class, "_VAMSASList", "VAMSAS", org.exolab.castor.xml.NodeType.Element); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - VamsasDocument target = (VamsasDocument) object; - return target.getVAMSAS(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - VamsasDocument target = (VamsasDocument) object; - target.addVAMSAS( (uk.ac.vamsas.objects.core.VAMSAS) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public void resetValue(Object object) throws IllegalStateException, IllegalArgumentException { - try { - VamsasDocument target = (VamsasDocument) object; - target.removeAllVAMSAS(); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new uk.ac.vamsas.objects.core.VAMSAS(); - } - }; - desc.setHandler(handler); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setRequired(true); - desc.setMultivalued(true); - addFieldDescriptor(desc); - - //-- validation code for: _VAMSASList - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(1); - { //-- local scope + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return new uk.ac.vamsas.objects.core.LockFile(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasDocument"); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _lockFile + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { // -- local scope + } + desc.setValidator(fieldValidator); + // -- _provenance + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + uk.ac.vamsas.objects.core.Provenance.class, "_provenance", + "Provenance", org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + VamsasDocument target = (VamsasDocument) object; + return target.getProvenance(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + VamsasDocument target = (VamsasDocument) object; + target.setProvenance((uk.ac.vamsas.objects.core.Provenance) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- _applicationDataList - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(uk.ac.vamsas.objects.core.ApplicationData.class, "_applicationDataList", "ApplicationData", org.exolab.castor.xml.NodeType.Element); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - VamsasDocument target = (VamsasDocument) object; - return target.getApplicationData(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - VamsasDocument target = (VamsasDocument) object; - target.addApplicationData( (uk.ac.vamsas.objects.core.ApplicationData) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public void resetValue(Object object) throws IllegalStateException, IllegalArgumentException { - try { - VamsasDocument target = (VamsasDocument) object; - target.removeAllApplicationData(); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new uk.ac.vamsas.objects.core.ApplicationData(); - } - }; - desc.setHandler(handler); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setMultivalued(true); - addFieldDescriptor(desc); - - //-- validation code for: _applicationDataList - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(0); - { //-- local scope + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return new uk.ac.vamsas.objects.core.Provenance(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + // -- validation code for: _provenance + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { // -- local scope + } + desc.setValidator(fieldValidator); + // -- _VAMSASList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + uk.ac.vamsas.objects.core.VAMSAS.class, "_VAMSASList", "VAMSAS", + org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + VamsasDocument target = (VamsasDocument) object; + return target.getVAMSAS(); + } + + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + VamsasDocument target = (VamsasDocument) object; + target.addVAMSAS((uk.ac.vamsas.objects.core.VAMSAS) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); - //-- _attachmentList - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(uk.ac.vamsas.objects.core.Attachment.class, "_attachmentList", "Attachment", org.exolab.castor.xml.NodeType.Element); - handler = new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - VamsasDocument target = (VamsasDocument) object; - return target.getAttachment(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - VamsasDocument target = (VamsasDocument) object; - target.addAttachment( (uk.ac.vamsas.objects.core.Attachment) value); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public void resetValue(Object object) throws IllegalStateException, IllegalArgumentException { - try { - VamsasDocument target = (VamsasDocument) object; - target.removeAllAttachment(); - } catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance(java.lang.Object parent) { - return new uk.ac.vamsas.objects.core.Attachment(); - } - }; - desc.setHandler(handler); - desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); - desc.setMultivalued(true); - addFieldDescriptor(desc); - - //-- validation code for: _attachmentList - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - fieldValidator.setMinOccurs(0); - { //-- local scope + } + + public void resetValue(Object object) throws IllegalStateException, + IllegalArgumentException { + try { + VamsasDocument target = (VamsasDocument) object; + target.removeAllVAMSAS(); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); } - desc.setValidator(fieldValidator); + } + + public java.lang.Object newInstance(java.lang.Object parent) { + return new uk.ac.vamsas.objects.core.VAMSAS(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setRequired(true); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + // -- validation code for: _VAMSASList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { // -- local scope } + desc.setValidator(fieldValidator); + // -- _applicationDataList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + uk.ac.vamsas.objects.core.ApplicationData.class, + "_applicationDataList", "ApplicationData", + org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + VamsasDocument target = (VamsasDocument) object; + return target.getApplicationData(); + } + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + VamsasDocument target = (VamsasDocument) object; + target + .addApplicationData((uk.ac.vamsas.objects.core.ApplicationData) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - //-----------/ - //- Methods -/ - //-----------/ + public void resetValue(Object object) throws IllegalStateException, + IllegalArgumentException { + try { + VamsasDocument target = (VamsasDocument) object; + target.removeAllApplicationData(); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getAccessMode. - * - * @return the access mode specified for this class. - */ - public org.exolab.castor.mapping.AccessMode getAccessMode( - ) { - return null; - } + public java.lang.Object newInstance(java.lang.Object parent) { + return new uk.ac.vamsas.objects.core.ApplicationData(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setMultivalued(true); + addFieldDescriptor(desc); - /** - * Method getIdentity. - * - * @return the identity field, null if this class has no - * identity. - */ - public org.exolab.castor.mapping.FieldDescriptor getIdentity( - ) { - return super.getIdentity(); + // -- validation code for: _applicationDataList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { // -- local scope } + desc.setValidator(fieldValidator); + // -- _attachmentList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl( + uk.ac.vamsas.objects.core.Attachment.class, "_attachmentList", + "Attachment", org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue(java.lang.Object object) + throws IllegalStateException { + VamsasDocument target = (VamsasDocument) object; + return target.getAttachment(); + } - /** - * Method getJavaClass. - * - * @return the Java class represented by this descriptor. - */ - public java.lang.Class getJavaClass( - ) { - return uk.ac.vamsas.objects.core.VamsasDocument.class; - } + public void setValue(java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException { + try { + VamsasDocument target = (VamsasDocument) object; + target.addAttachment((uk.ac.vamsas.objects.core.Attachment) value); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getNameSpacePrefix. - * - * @return the namespace prefix to use when marshaling as XML. - */ - public java.lang.String getNameSpacePrefix( - ) { - return _nsPrefix; - } + public void resetValue(Object object) throws IllegalStateException, + IllegalArgumentException { + try { + VamsasDocument target = (VamsasDocument) object; + target.removeAllAttachment(); + } catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } - /** - * Method getNameSpaceURI. - * - * @return the namespace URI used when marshaling and - * unmarshaling as XML. - */ - public java.lang.String getNameSpaceURI( - ) { - return _nsURI; - } + public java.lang.Object newInstance(java.lang.Object parent) { + return new uk.ac.vamsas.objects.core.Attachment(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"); + desc.setMultivalued(true); + addFieldDescriptor(desc); - /** - * Method getValidator. - * - * @return a specific validator for the class described by this - * ClassDescriptor. - */ - public org.exolab.castor.xml.TypeValidator getValidator( - ) { - return this; + // -- validation code for: _attachmentList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { // -- local scope } + desc.setValidator(fieldValidator); + } - /** - * Method getXMLName. - * - * @return the XML Name for the Class being described. - */ - public java.lang.String getXMLName( - ) { - return _xmlName; - } + // -----------/ + // - Methods -/ + // -----------/ - /** - * Method isElementDefinition. - * - * @return true if XML schema definition of this Class is that - * of a global - * element or element with anonymous type definition. - */ - public boolean isElementDefinition( - ) { - return _elementDefinition; - } + /** + * Method getAccessMode. + * + * @return the access mode specified for this class. + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() { + return null; + } + + /** + * Method getIdentity. + * + * @return the identity field, null if this class has no identity. + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() { + return super.getIdentity(); + } + + /** + * Method getJavaClass. + * + * @return the Java class represented by this descriptor. + */ + public java.lang.Class getJavaClass() { + return uk.ac.vamsas.objects.core.VamsasDocument.class; + } + + /** + * Method getNameSpacePrefix. + * + * @return the namespace prefix to use when marshaling as XML. + */ + public java.lang.String getNameSpacePrefix() { + return _nsPrefix; + } + + /** + * Method getNameSpaceURI. + * + * @return the namespace URI used when marshaling and unmarshaling as XML. + */ + public java.lang.String getNameSpaceURI() { + return _nsURI; + } + + /** + * Method getValidator. + * + * @return a specific validator for the class described by this + * ClassDescriptor. + */ + public org.exolab.castor.xml.TypeValidator getValidator() { + return this; + } + + /** + * Method getXMLName. + * + * @return the XML Name for the Class being described. + */ + public java.lang.String getXMLName() { + return _xmlName; + } + + /** + * Method isElementDefinition. + * + * @return true if XML schema definition of this Class is that of a global + * element or element with anonymous type definition. + */ + public boolean isElementDefinition() { + return _elementDefinition; + } } diff --git a/src/uk/ac/vamsas/objects/core/descriptors/VrefDescriptor.java b/src/uk/ac/vamsas/objects/core/descriptors/VrefDescriptor.java index aaf2f6d..cd06385 100644 --- a/src/uk/ac/vamsas/objects/core/descriptors/VrefDescriptor.java +++ b/src/uk/ac/vamsas/objects/core/descriptors/VrefDescriptor.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core.descriptors; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import uk.ac.vamsas.objects.core.Vref; @@ -18,134 +32,121 @@ import uk.ac.vamsas.objects.core.Vref; * * @version $Revision$ $Date$ */ -public class VrefDescriptor extends uk.ac.vamsas.objects.core.descriptors.ReferenceTypeDescriptor { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _elementDefinition. - */ - private boolean _elementDefinition; - - /** - * Field _nsPrefix. - */ - private java.lang.String _nsPrefix; - - /** - * Field _nsURI. - */ - private java.lang.String _nsURI; - - /** - * Field _xmlName. - */ - private java.lang.String _xmlName; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public VrefDescriptor() { - super(); - setExtendsWithoutFlatten(new uk.ac.vamsas.objects.core.descriptors.ReferenceTypeDescriptor()); - _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; - _xmlName = "vref"; - _elementDefinition = true; - } - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Method getAccessMode. - * - * @return the access mode specified for this class. - */ - public org.exolab.castor.mapping.AccessMode getAccessMode( - ) { - return null; - } - - /** - * Method getIdentity. - * - * @return the identity field, null if this class has no - * identity. - */ - public org.exolab.castor.mapping.FieldDescriptor getIdentity( - ) { - return super.getIdentity(); - } - - /** - * Method getJavaClass. - * - * @return the Java class represented by this descriptor. - */ - public java.lang.Class getJavaClass( - ) { - return uk.ac.vamsas.objects.core.Vref.class; - } - - /** - * Method getNameSpacePrefix. - * - * @return the namespace prefix to use when marshaling as XML. - */ - public java.lang.String getNameSpacePrefix( - ) { - return _nsPrefix; - } - - /** - * Method getNameSpaceURI. - * - * @return the namespace URI used when marshaling and - * unmarshaling as XML. - */ - public java.lang.String getNameSpaceURI( - ) { - return _nsURI; - } - - /** - * Method getValidator. - * - * @return a specific validator for the class described by this - * ClassDescriptor. - */ - public org.exolab.castor.xml.TypeValidator getValidator( - ) { - return this; - } - - /** - * Method getXMLName. - * - * @return the XML Name for the Class being described. - */ - public java.lang.String getXMLName( - ) { - return _xmlName; - } - - /** - * Method isElementDefinition. - * - * @return true if XML schema definition of this Class is that - * of a global - * element or element with anonymous type definition. - */ - public boolean isElementDefinition( - ) { - return _elementDefinition; - } +public class VrefDescriptor extends + uk.ac.vamsas.objects.core.descriptors.ReferenceTypeDescriptor { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _elementDefinition. + */ + private boolean _elementDefinition; + + /** + * Field _nsPrefix. + */ + private java.lang.String _nsPrefix; + + /** + * Field _nsURI. + */ + private java.lang.String _nsURI; + + /** + * Field _xmlName. + */ + private java.lang.String _xmlName; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public VrefDescriptor() { + super(); + setExtendsWithoutFlatten(new uk.ac.vamsas.objects.core.descriptors.ReferenceTypeDescriptor()); + _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; + _xmlName = "vref"; + _elementDefinition = true; + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * Method getAccessMode. + * + * @return the access mode specified for this class. + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() { + return null; + } + + /** + * Method getIdentity. + * + * @return the identity field, null if this class has no identity. + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() { + return super.getIdentity(); + } + + /** + * Method getJavaClass. + * + * @return the Java class represented by this descriptor. + */ + public java.lang.Class getJavaClass() { + return uk.ac.vamsas.objects.core.Vref.class; + } + + /** + * Method getNameSpacePrefix. + * + * @return the namespace prefix to use when marshaling as XML. + */ + public java.lang.String getNameSpacePrefix() { + return _nsPrefix; + } + + /** + * Method getNameSpaceURI. + * + * @return the namespace URI used when marshaling and unmarshaling as XML. + */ + public java.lang.String getNameSpaceURI() { + return _nsURI; + } + + /** + * Method getValidator. + * + * @return a specific validator for the class described by this + * ClassDescriptor. + */ + public org.exolab.castor.xml.TypeValidator getValidator() { + return this; + } + + /** + * Method getXMLName. + * + * @return the XML Name for the Class being described. + */ + public java.lang.String getXMLName() { + return _xmlName; + } + + /** + * Method isElementDefinition. + * + * @return true if XML schema definition of this Class is that of a global + * element or element with anonymous type definition. + */ + public boolean isElementDefinition() { + return _elementDefinition; + } } diff --git a/src/uk/ac/vamsas/objects/core/descriptors/VxrefDescriptor.java b/src/uk/ac/vamsas/objects/core/descriptors/VxrefDescriptor.java index 86ddb3e..78fa9c1 100644 --- a/src/uk/ac/vamsas/objects/core/descriptors/VxrefDescriptor.java +++ b/src/uk/ac/vamsas/objects/core/descriptors/VxrefDescriptor.java @@ -1,14 +1,28 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.objects.core.descriptors; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ import uk.ac.vamsas.objects.core.Vxref; @@ -18,134 +32,121 @@ import uk.ac.vamsas.objects.core.Vxref; * * @version $Revision$ $Date$ */ -public class VxrefDescriptor extends uk.ac.vamsas.objects.core.descriptors.ReferenceTypeDescriptor { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _elementDefinition. - */ - private boolean _elementDefinition; - - /** - * Field _nsPrefix. - */ - private java.lang.String _nsPrefix; - - /** - * Field _nsURI. - */ - private java.lang.String _nsURI; - - /** - * Field _xmlName. - */ - private java.lang.String _xmlName; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public VxrefDescriptor() { - super(); - setExtendsWithoutFlatten(new uk.ac.vamsas.objects.core.descriptors.ReferenceTypeDescriptor()); - _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; - _xmlName = "vxref"; - _elementDefinition = true; - } - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Method getAccessMode. - * - * @return the access mode specified for this class. - */ - public org.exolab.castor.mapping.AccessMode getAccessMode( - ) { - return null; - } - - /** - * Method getIdentity. - * - * @return the identity field, null if this class has no - * identity. - */ - public org.exolab.castor.mapping.FieldDescriptor getIdentity( - ) { - return super.getIdentity(); - } - - /** - * Method getJavaClass. - * - * @return the Java class represented by this descriptor. - */ - public java.lang.Class getJavaClass( - ) { - return uk.ac.vamsas.objects.core.Vxref.class; - } - - /** - * Method getNameSpacePrefix. - * - * @return the namespace prefix to use when marshaling as XML. - */ - public java.lang.String getNameSpacePrefix( - ) { - return _nsPrefix; - } - - /** - * Method getNameSpaceURI. - * - * @return the namespace URI used when marshaling and - * unmarshaling as XML. - */ - public java.lang.String getNameSpaceURI( - ) { - return _nsURI; - } - - /** - * Method getValidator. - * - * @return a specific validator for the class described by this - * ClassDescriptor. - */ - public org.exolab.castor.xml.TypeValidator getValidator( - ) { - return this; - } - - /** - * Method getXMLName. - * - * @return the XML Name for the Class being described. - */ - public java.lang.String getXMLName( - ) { - return _xmlName; - } - - /** - * Method isElementDefinition. - * - * @return true if XML schema definition of this Class is that - * of a global - * element or element with anonymous type definition. - */ - public boolean isElementDefinition( - ) { - return _elementDefinition; - } +public class VxrefDescriptor extends + uk.ac.vamsas.objects.core.descriptors.ReferenceTypeDescriptor { + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _elementDefinition. + */ + private boolean _elementDefinition; + + /** + * Field _nsPrefix. + */ + private java.lang.String _nsPrefix; + + /** + * Field _nsURI. + */ + private java.lang.String _nsURI; + + /** + * Field _xmlName. + */ + private java.lang.String _xmlName; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public VxrefDescriptor() { + super(); + setExtendsWithoutFlatten(new uk.ac.vamsas.objects.core.descriptors.ReferenceTypeDescriptor()); + _nsURI = "http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes"; + _xmlName = "vxref"; + _elementDefinition = true; + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * Method getAccessMode. + * + * @return the access mode specified for this class. + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() { + return null; + } + + /** + * Method getIdentity. + * + * @return the identity field, null if this class has no identity. + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() { + return super.getIdentity(); + } + + /** + * Method getJavaClass. + * + * @return the Java class represented by this descriptor. + */ + public java.lang.Class getJavaClass() { + return uk.ac.vamsas.objects.core.Vxref.class; + } + + /** + * Method getNameSpacePrefix. + * + * @return the namespace prefix to use when marshaling as XML. + */ + public java.lang.String getNameSpacePrefix() { + return _nsPrefix; + } + + /** + * Method getNameSpaceURI. + * + * @return the namespace URI used when marshaling and unmarshaling as XML. + */ + public java.lang.String getNameSpaceURI() { + return _nsURI; + } + + /** + * Method getValidator. + * + * @return a specific validator for the class described by this + * ClassDescriptor. + */ + public org.exolab.castor.xml.TypeValidator getValidator() { + return this; + } + + /** + * Method getXMLName. + * + * @return the XML Name for the Class being described. + */ + public java.lang.String getXMLName() { + return _xmlName; + } + + /** + * Method isElementDefinition. + * + * @return true if XML schema definition of this Class is that of a global + * element or element with anonymous type definition. + */ + public boolean isElementDefinition() { + return _elementDefinition; + } } diff --git a/src/uk/ac/vamsas/objects/utils/AppDataReference.java b/src/uk/ac/vamsas/objects/utils/AppDataReference.java index 058f9e6..efdf0c4 100644 --- a/src/uk/ac/vamsas/objects/utils/AppDataReference.java +++ b/src/uk/ac/vamsas/objects/utils/AppDataReference.java @@ -1,160 +1,208 @@ -/** - * - */ -package uk.ac.vamsas.objects.utils; -import java.util.Vector; - - -import uk.ac.vamsas.client.ClientHandle; -import uk.ac.vamsas.client.UserHandle; -import uk.ac.vamsas.client.simpleclient.VamsasArchive; -import uk.ac.vamsas.client.simpleclient.VamsasArchiveReader; -import uk.ac.vamsas.objects.core.*; -/** - * Form, accessors and validation for ApplicationData references in - * vamsas document. - * TODO: LATER:extend XML Schema to properly validate against the same forms required by this class - * TODO: VAMSAS: URNS for appDatas are supposed to be unique, aren't they ? - */ -public class AppDataReference { - /** - * search interface for collecting particular types of AppDatas in a vamsas document - * @author jimp - * - */ - interface IAppDSearch { - /** - * process the appData Vobject d - * @param d - * @return true if appData should be collected - */ - public boolean process(AppData d); - } - /** - * collect all appData reference strings in a vamsas document - * @param doc - * @return vector of String objects - */ - static public Vector getAppDataReferences(VamsasDocument doc) { - if ((doc!=null) && (doc.getApplicationDataCount()>0)) { - Vector apdrefs = new Vector(); - ApplicationData[] appdatas = doc.getApplicationData(); - for (int q=0; q0) - return apdrefs; - } - return null; - } - /** - * General search through the set of AppData objects for a particular profile of Client and User handle. - * @param doc - * @param test interface implemented by the filter selecting particular AppDatas. - * @param cascade if true only User objects for ApplicationData objects that test.process returned true will be tested. - * @return set of uk.ac.vamsas.objects.core.AppData objects for which test.process returned true - */ - static public Vector searchAppDatas(VamsasDocument doc, IAppDSearch test, boolean cascade) { - if ((doc!=null) && (doc.getApplicationDataCount()>0)) { - Vector apdrefs = new Vector(); - ApplicationData[] appdatas = doc.getApplicationData(); - for (int q=0; q0) - return apdrefs; - } - return null; - } - static public boolean equals(User p, UserHandle u) { - if (p.getFullname().equals(u.getFullName()) - && p.getOrganization().equals(u.getOrganization())) - return true; - return false; - } - /** - * returns true if Name matches in c and p, and Urn's match (or c.getUrn()==null) and Version's match (or c.getVersion()==null) - * @param p - * @param c - * @return match of p on template c. - */ - static public boolean equals(ApplicationData p, ClientHandle c) { - if ( - //((c.getClientUrn()==null) || p.getUrn().equals(c.getClientUrn())) - //&& - (p.getName().equals(c.getClientName())) - && - ((c.getVersion()==null) || (p.getVersion().equals(c.getVersion()))) - ) - return true; - return false; - } - /** - * Searches document appData structure for particular combinations of client and user data - * @param doc the data - * @param user template user data to match against - * @see AppDataReference.equals(uk.ac.vamsas.objects.core.User, uk.ac.vamsas.client.UserHandle) - * @param app - * @see AppDataReference.equals(uk.ac.vamsas.objects.core.ApplicationData, uk.ac.vamsas.client.ClientHandle) - * @return set of matching client app datas for this client and user combination - */ - static public Vector getUserandApplicationsData(VamsasDocument doc, UserHandle user, ClientHandle app) { - if (doc==null) { - return null; - } - final UserHandle u = user; - final ClientHandle c = app; - - IAppDSearch match = new IAppDSearch() { - public boolean process(AppData p) { - if (p instanceof User) { - if (AppDataReference.equals((User) p, u)) - return true; - } else - if (p instanceof ApplicationData) { - if (AppDataReference.equals((ApplicationData) p, c)) - return true; - } - return false; - } - }; - - return searchAppDatas(doc, match, true); // only return AppDatas belonging to appdata app. - } - /** - * safely creates a new appData reference - * @param dest destination document Vobject - * @param entry base application reference to make unique - */ - public static String uniqueAppDataReference(VamsasDocument dest,String base) { - String urn = base.replace('/','_').replace('\\','_').replace(':', '_').replace('.', '_'); - int v = 1; - for (int i=0, j=dest.getApplicationDataCount(); i. + */ +package uk.ac.vamsas.objects.utils; + +import java.util.Vector; + +import uk.ac.vamsas.client.ClientHandle; +import uk.ac.vamsas.client.UserHandle; +import uk.ac.vamsas.client.simpleclient.VamsasArchive; +import uk.ac.vamsas.client.simpleclient.VamsasArchiveReader; +import uk.ac.vamsas.objects.core.*; + +/** + * Form, accessors and validation for ApplicationData references in vamsas + * document. TODO: LATER:extend XML Schema to properly validate against the same + * forms required by this class TODO: VAMSAS: URNS for appDatas are supposed to + * be unique, aren't they ? + */ +public class AppDataReference { + /** + * search interface for collecting particular types of AppDatas in a vamsas + * document + * + * @author jimp + * + */ + interface IAppDSearch { + /** + * process the appData Vobject d + * + * @param d + * @return true if appData should be collected + */ + public boolean process(AppData d); + } + + /** + * collect all appData reference strings in a vamsas document + * + * @param doc + * @return vector of String objects + */ + static public Vector getAppDataReferences(VamsasDocument doc) { + if ((doc != null) && (doc.getApplicationDataCount() > 0)) { + Vector apdrefs = new Vector(); + ApplicationData[] appdatas = doc.getApplicationData(); + for (int q = 0; q < appdatas.length; q++) { + String refstring = appdatas[q].getDataReference(); + if (refstring != null) + apdrefs.add(refstring); + User users[] = appdatas[q].getUser(); + + if (users != null) + for (int u = 0; u < users.length; u++) { + refstring = users[u].getDataReference(); + if (refstring != null) + apdrefs.add(new String(refstring)); // avoid referencing. + } + } + if (apdrefs.size() > 0) + return apdrefs; + } + return null; + } + + /** + * General search through the set of AppData objects for a particular profile + * of Client and User handle. + * + * @param doc + * @param test + * interface implemented by the filter selecting particular AppDatas. + * @param cascade + * if true only User objects for ApplicationData objects that + * test.process returned true will be tested. + * @return set of uk.ac.vamsas.objects.core.AppData objects for which + * test.process returned true + */ + static public Vector searchAppDatas(VamsasDocument doc, IAppDSearch test, + boolean cascade) { + if ((doc != null) && (doc.getApplicationDataCount() > 0)) { + Vector apdrefs = new Vector(); + ApplicationData[] appdatas = doc.getApplicationData(); + for (int q = 0; q < appdatas.length; q++) { + boolean t; + if (t = test.process(appdatas[q])) + apdrefs.add(appdatas[q]); + if (t || cascade) { + User users[] = appdatas[q].getUser(); + if (users != null) + for (int u = 0; u < users.length; u++) + if (test.process(users[u])) + apdrefs.add(users[u]); + } + } + if (apdrefs.size() > 0) + return apdrefs; + } + return null; + } + + static public boolean equals(User p, UserHandle u) { + if (p.getFullname().equals(u.getFullName()) + && p.getOrganization().equals(u.getOrganization())) + return true; + return false; + } + + /** + * returns true if Name matches in c and p, and Urn's match (or + * c.getUrn()==null) and Version's match (or c.getVersion()==null) + * + * @param p + * @param c + * @return match of p on template c. + */ + static public boolean equals(ApplicationData p, ClientHandle c) { + if ( + // ((c.getClientUrn()==null) || p.getUrn().equals(c.getClientUrn())) + // && + (p.getName().equals(c.getClientName())) + && ((c.getVersion() == null) || (p.getVersion().equals(c.getVersion())))) + return true; + return false; + } + + /** + * Searches document appData structure for particular combinations of client + * and user data + * + * @param doc + * the data + * @param user + * template user data to match against + * @see AppDataReference.equals(uk.ac.vamsas.objects.core.User, + * uk.ac.vamsas.client.UserHandle) + * @param app + * @see AppDataReference.equals(uk.ac.vamsas.objects.core.ApplicationData, + * uk.ac.vamsas.client.ClientHandle) + * @return set of matching client app datas for this client and user + * combination + */ + static public Vector getUserandApplicationsData(VamsasDocument doc, + UserHandle user, ClientHandle app) { + if (doc == null) { + return null; + } + final UserHandle u = user; + final ClientHandle c = app; + + IAppDSearch match = new IAppDSearch() { + public boolean process(AppData p) { + if (p instanceof User) { + if (AppDataReference.equals((User) p, u)) + return true; + } else if (p instanceof ApplicationData) { + if (AppDataReference.equals((ApplicationData) p, c)) + return true; + } + return false; + } + }; + + return searchAppDatas(doc, match, true); // only return AppDatas belonging + // to appdata app. + } + + /** + * safely creates a new appData reference + * + * @param dest + * destination document Vobject + * @param entry + * base application reference to make unique + */ + public static String uniqueAppDataReference(VamsasDocument dest, String base) { + String urn = base.replace('/', '_').replace('\\', '_').replace(':', '_') + .replace('.', '_'); + int v = 1; + for (int i = 0, j = dest.getApplicationDataCount(); i < j; i++) { + ApplicationData o = dest.getApplicationData()[i]; + // ensure new urn is really unique + while (o.getDataReference() != null && o.getDataReference().equals(urn)) { + urn = base + "_" + v++; + } + } + return urn; + } +} diff --git a/src/uk/ac/vamsas/objects/utils/DocumentStuff.java b/src/uk/ac/vamsas/objects/utils/DocumentStuff.java index 01df061..14d764d 100644 --- a/src/uk/ac/vamsas/objects/utils/DocumentStuff.java +++ b/src/uk/ac/vamsas/objects/utils/DocumentStuff.java @@ -1,35 +1,57 @@ -package uk.ac.vamsas.objects.utils; - - -import uk.ac.vamsas.objects.core.*; -import uk.ac.vamsas.objects.utils.document.VersionEntries; - -/** - * various vamsas-client independent helpers - * for creating and manipulating the vamsasDocument Vobject - * @author jimp - * - */ -public class DocumentStuff { - public static VamsasDocument newVamsasDocument(VAMSAS root[], String version) { - return newVamsasDocument(root, ProvenanceStuff.newProvenance( - "AUTO:org.vamsas.DocumentStuff.newVamsasDocument", - "Vamsas Document created"), - version); - } - public static VamsasDocument newVamsasDocument(VAMSAS root[]) { - return newVamsasDocument(root, ProvenanceStuff.newProvenance( - "AUTO:org.vamsas.DocumentStuff.newVamsasDocument", - "Vamsas Document created"), - VersionEntries.latestVersion()); - } - public static VamsasDocument newVamsasDocument(VAMSAS root[], Provenance p, String version) { - VamsasDocument doc = new VamsasDocument(); - for (int r=0; r. + */ +package uk.ac.vamsas.objects.utils; + +import uk.ac.vamsas.objects.core.*; +import uk.ac.vamsas.objects.utils.document.VersionEntries; + +/** + * various vamsas-client independent helpers for creating and manipulating the + * vamsasDocument Vobject + * + * @author jimp + * + */ +public class DocumentStuff { + public static VamsasDocument newVamsasDocument(VAMSAS root[], String version) { + return newVamsasDocument(root, ProvenanceStuff.newProvenance( + "AUTO:org.vamsas.DocumentStuff.newVamsasDocument", + "Vamsas Document created"), version); + } + + public static VamsasDocument newVamsasDocument(VAMSAS root[]) { + return newVamsasDocument(root, ProvenanceStuff.newProvenance( + "AUTO:org.vamsas.DocumentStuff.newVamsasDocument", + "Vamsas Document created"), VersionEntries.latestVersion()); + } + + public static VamsasDocument newVamsasDocument(VAMSAS root[], Provenance p, + String version) { + VamsasDocument doc = new VamsasDocument(); + for (int r = 0; r < root.length; r++) { + doc.addVAMSAS(root[r]); + } + doc.setProvenance(p); + doc.setVersion(version); + return doc; + } +} diff --git a/src/uk/ac/vamsas/objects/utils/Format.java b/src/uk/ac/vamsas/objects/utils/Format.java index b4bd722..f67f698 100644 --- a/src/uk/ac/vamsas/objects/utils/Format.java +++ b/src/uk/ac/vamsas/objects/utils/Format.java @@ -1,24 +1,24 @@ /* - * Cay S. Horstmann & Gary Cornell, Core Java - * Published By Sun Microsystems Press/Prentice-Hall - * Copyright (C) 1997 Sun Microsystems Inc. - * All Rights Reserved. - * - * Permission to use, copy, modify, and distribute this - * software and its documentation for NON-COMMERCIAL purposes - * and without fee is hereby granted provided that this - * copyright notice appears in all copies. + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. * - * THE AUTHORS AND PUBLISHER MAKE NO REPRESENTATIONS OR - * WARRANTIES ABOUT THE SUITABILITY OF THE SOFTWARE, EITHER - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE - * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. THE AUTHORS - * AND PUBLISHER SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED - * BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING - * THIS SOFTWARE OR ITS DERIVATIVES. + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - /** * A class for formatting numbers that follows printf conventions. * Also implements C-like atoi and atof functions @@ -30,7 +30,8 @@ package uk.ac.vamsas.objects.utils; import java.io.*; -public class Format { /** +public class Format { +/** * Formats the number following printf conventions. * Main limitation: Can only handle one format parameter at a time * Use multiple Format objects to format more than one number @@ -154,62 +155,81 @@ public class Format { /** } /** - * prints a formatted number following printf conventions - * @param s a PrintStream - * @param fmt the format string - * @param x the double to print - */ + * prints a formatted number following printf conventions + * + * @param s + * a PrintStream + * @param fmt + * the format string + * @param x + * the double to print + */ public static void print(java.io.PrintStream s, String fmt, double x) { s.print(new Format(fmt).form(x)); } /** - * prints a formatted number following printf conventions - * @param s a PrintStream - * @param fmt the format string - * @param x the long to print - */ + * prints a formatted number following printf conventions + * + * @param s + * a PrintStream + * @param fmt + * the format string + * @param x + * the long to print + */ public static void print(java.io.PrintStream s, String fmt, long x) { s.print(new Format(fmt).form(x)); } /** - * prints a formatted number following printf conventions - * @param s a PrintStream - * @param fmt the format string - * @param x the character to - */ + * prints a formatted number following printf conventions + * + * @param s + * a PrintStream + * @param fmt + * the format string + * @param x + * the character to + */ public static void print(java.io.PrintStream s, String fmt, char x) { s.print(new Format(fmt).form(x)); } /** - * prints a formatted number following printf conventions - * @param s a PrintStream, fmt the format string - * @param x a string that represents the digits to print - */ + * prints a formatted number following printf conventions + * + * @param s + * a PrintStream, fmt the format string + * @param x + * a string that represents the digits to print + */ public static void print(java.io.PrintStream s, String fmt, String x) { s.print(new Format(fmt).form(x)); } /** - * Converts a string of digits (decimal, octal or hex) to an integer - * @param s a string - * @return the numeric value of the prefix of s representing a base 10 integer - */ + * Converts a string of digits (decimal, octal or hex) to an integer + * + * @param s + * a string + * @return the numeric value of the prefix of s representing a base 10 integer + */ public static int atoi(String s) { - return (int)atol(s); + return (int) atol(s); } /** - * Converts a string of digits (decimal, octal or hex) to a long integer - * @param s a string - * @return the numeric value of the prefix of s representing a base 10 integer - */ + * Converts a string of digits (decimal, octal or hex) to a long integer + * + * @param s + * a string + * @return the numeric value of the prefix of s representing a base 10 integer + */ public static long atol(String s) { int i = 0; @@ -217,7 +237,8 @@ public class Format { /** while (i < s.length() && Character.isWhitespace(s.charAt(i))) i++; if (i < s.length() && s.charAt(i) == '0') { - if (i + 1 < s.length() && (s.charAt(i + 1) == 'x' || s.charAt(i + 1) == 'X')) + if (i + 1 < s.length() + && (s.charAt(i + 1) == 'x' || s.charAt(i + 1) == 'X')) return parseLong(s.substring(i + 2), 16); else return parseLong(s, 8); @@ -243,9 +264,9 @@ public class Format { /** if ('0' <= ch && ch < '0' + base) r = r * base + ch - '0'; else if ('A' <= ch && ch < 'A' + base - 10) - r = r * base + ch - 'A' + 10 ; + r = r * base + ch - 'A' + 10; else if ('a' <= ch && ch < 'a' + base - 10) - r = r * base + ch - 'a' + 10 ; + r = r * base + ch - 'a' + 10; else return r * sign; i++; @@ -254,9 +275,11 @@ public class Format { /** } /** - * Converts a string of digits to an double - * @param s a string - */ + * Converts a string of digits to an double + * + * @param s + * a string + */ public static double atof(String s) { int i = 0; @@ -289,7 +312,7 @@ public class Format { /** else return sign * r; } else if (ch == 'e' || ch == 'E') { - long e = (int)parseLong(s.substring(i + 1), 10); + long e = (int) parseLong(s.substring(i + 1), 10); return sign * r * Math.pow(10, e); } else return sign * r; @@ -299,11 +322,14 @@ public class Format { /** } /** - * Formats a double into a string (like sprintf in C) - * @param x the number to format - * @return the formatted string - * @exception IllegalArgumentException if bad argument - */ + * Formats a double into a string (like sprintf in C) + * + * @param x + * the number to format + * @return the formatted string + * @exception IllegalArgumentException + * if bad argument + */ public String form(double x) { String r; @@ -325,10 +351,12 @@ public class Format { /** } /** - * Formats a long integer into a string (like sprintf in C) - * @param x the number to format - * @return the formatted string - */ + * Formats a long integer into a string (like sprintf in C) + * + * @param x + * the number to format + * @return the formatted string + */ public String form(long x) { String r; @@ -354,10 +382,12 @@ public class Format { /** } /** - * Formats a character into a string (like sprintf in C) - * @param x the value to format - * @return the formatted string - */ + * Formats a character into a string (like sprintf in C) + * + * @param x + * the value to format + * @return the formatted string + */ public String form(char c) { if (fmt != 'c') @@ -368,10 +398,12 @@ public class Format { /** } /** - * Formats a string into a larger string (like sprintf in C) - * @param x the value to format - * @return the formatted string - */ + * Formats a string into a larger string (like sprintf in C) + * + * @param x + * the value to format + * @return the formatted string + */ public String form(String s) { if (fmt != 's') @@ -381,10 +413,9 @@ public class Format { /** return pad(s); } - /** - * a test stub for the format class - */ + * a test stub for the format class + */ public static void main(String[] a) { double x = 1.23456789012; @@ -471,7 +502,7 @@ public class Format { /** return "0"; String r = ""; while (x != 0) { - r = d.charAt((int)(x & m)) + r; + r = d.charAt((int) (x & m)) + r; x = x >>> n; } return r; @@ -506,23 +537,22 @@ public class Format { /** if (leading_zeroes) w = width; else if ((fmt == 'd' || fmt == 'i' || fmt == 'x' || fmt == 'X' || fmt == 'o') - && precision > 0) + && precision > 0) w = precision; return p + repeat('0', w - p.length() - r.length()) + r; } private String fixed_format(double d) { - boolean removeTrailing - = (fmt == 'G' || fmt == 'g') && !alternate; + boolean removeTrailing = (fmt == 'G' || fmt == 'g') && !alternate; // remove trailing zeroes and decimal point if (d > 0x7FFFFFFFFFFFFFFFL) return exp_format(d); if (precision == 0) - return (long)(d + 0.5) + (removeTrailing ? "" : "."); + return (long) (d + 0.5) + (removeTrailing ? "" : "."); - long whole = (long)d; + long whole = (long) d; double fr = d - whole; // fractional part if (fr >= 1 || fr < 0) return exp_format(d); @@ -595,18 +625,22 @@ public class Format { /** } private int width; + private int precision; + private String pre; + private String post; + private boolean leading_zeroes; + private boolean show_plus; + private boolean alternate; + private boolean show_space; + private boolean left_align; + private char fmt; // one of cdeEfgGiosxXos } - - - - - diff --git a/src/uk/ac/vamsas/objects/utils/GlyphDictionary.java b/src/uk/ac/vamsas/objects/utils/GlyphDictionary.java index a49f4be..02a128e 100644 --- a/src/uk/ac/vamsas/objects/utils/GlyphDictionary.java +++ b/src/uk/ac/vamsas/objects/utils/GlyphDictionary.java @@ -1,23 +1,47 @@ +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ package uk.ac.vamsas.objects.utils; /** - * dict attribute values for glyph symbol sets found in uk.ac.vamsas.objects.core.AnnotationElement - * TODO: add validators and multilength symbols. + * dict attribute values for glyph symbol sets found in + * uk.ac.vamsas.objects.core.AnnotationElement TODO: add validators and + * multilength symbols. + * * @author JimP - * + * */ public class GlyphDictionary { /** * standard H, E, or C three state secondary structure assignment. */ - static final public String PROTEIN_SS_3STATE="aasecstr_3"; // HE, blank or C + static final public String PROTEIN_SS_3STATE = "aasecstr_3"; // HE, blank or C + /** * default glyph type attribute indicates a UTF8 character */ - static final public String DEFAULT="utf8"; + static final public String DEFAULT = "utf8"; + /** - * kyte and doolittle hydrophobicity - * TODO: specify this glyph set. + * kyte and doolittle hydrophobicity TODO: specify this glyph set. */ - static final public String PROTEIN_HD_HYDRO="kd_hydrophobicity"; + static final public String PROTEIN_HD_HYDRO = "kd_hydrophobicity"; } diff --git a/src/uk/ac/vamsas/objects/utils/MapList.java b/src/uk/ac/vamsas/objects/utils/MapList.java index 5052c94..30970e7 100644 --- a/src/uk/ac/vamsas/objects/utils/MapList.java +++ b/src/uk/ac/vamsas/objects/utils/MapList.java @@ -1,810 +1,743 @@ -/* - * This code was originated from - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ -package uk.ac.vamsas.objects.utils; - -import java.util.*; - -/** - * MapList - * Simple way of bijectively mapping a non-contiguous linear range to another non-contiguous linear range - * Use at your own risk! - * TODO: efficient implementation of private posMap method - * TODO: test/ensure that sense of from and to ratio start position is conserved (codon start position recovery) - * TODO: optimize to use int[][] arrays rather than vectors. - */ -public class MapList -{ - /* (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ - public boolean equals(MapList obj) { - if (obj==this) - return true; - if (obj!=null && obj.fromRatio==fromRatio && obj.toRatio==toRatio - && obj.fromShifts!=null && obj.toShifts!=null) { - int i,iSize=fromShifts.size(),j,jSize=obj.fromShifts.size(); - if (iSize!=jSize) - return false; - for (i=0,iSize=fromShifts.size(),j=0, jSize=obj.fromShifts.size(); ipos) - limits[0]=pos; - if (limits[1]=ivSize) - { - return null; - } - int[] intv=(int[]) intVals.elementAt(iv++); - int from=intv[0],to=intv[1]; - if (from > to) - { - from = intv[1]; - to=intv[0]; - } - while (ivto) - { - to=intv[0]; - } - if (intv[1]>to) - { - to=intv[1]; - } - } - int tF=0,tT=0; - int mp[][] = new int[to-from+2][]; - for (int i = 0; i < mp.length; i++) - { - int[] m = shift(i+from,intVals,ratio,toIntVals, toRatio); - if (m != null) - { - if (i == 0) - { - tF=tT=m[0]; - } - else - { - if (m[0] < tF) - { - tF=m[0]; - } - if (m[0] > tT) - { - tT=m[0]; - } - } - } - mp[i] = m; - } - int[][] map = new int[][] - { - new int[] - { - from, to, tF, tT}, new int[to - from + 2]}; - - map[0][2] = tF; - map[0][3] = tT; - - for (int i = 0; i < mp.length; i++) - { - if (mp[i] != null) - { - map[1][i] = mp[i][0]-tF; - } - else - { - map[1][i] = -1; // indicates an out of range mapping - } - } - return map; - } - /** - * addShift - * @param pos start position for shift (in original reference frame) - * @param shift length of shift - * - public void addShift(int pos, int shift) - { - int sidx = 0; - int[] rshift=null; - while (sidx= intv[0] && pos <= intv[1]) - { - return new int[] - { - count + pos - intv[0] + 1, +1}; - } - else - { - count+=intv[1]-intv[0]+1; - } - } - else - { - if (pos >= intv[1] && pos <= intv[0]) - { - return new int[] - { - count + intv[0] - pos + 1, -1}; - } - else - { - count+=intv[0]-intv[1]+1; - } - } - } - return null; - } - /** - * count out pos positions into a series of intervals and return the position - * @param intVals - * @param pos - * @return position pos in interval set - */ - private int[] countToPos(Vector intVals, int pos) - { - int count = 0, diff = 0, iv=0,ivSize=intVals.size(), intv[] = - { - 0, 0}; - while (iv= 0) - { - if (pos <= count + 1 + diff) - { - return new int[] - { - pos - count - 1 + intv[0], +1}; - } - else - { - count+=1+diff; - } - } - else - { - if (pos <= count + 1 - diff) - { - return new int[] - { - intv[0] - (pos - count - 1), -1}; - } - else - { - count+=1-diff; - } - } - } - return null;//(diff<0) ? (intv[1]-1) : (intv[0]+1); - } - /** - * find series of intervals mapping from start-end in the From map. - * @param start position in to map - * @param end position in to map - * @return series of ranges in from map - */ - public int[] locateInFrom(int start, int end) { - // inefficient implementation - int fromStart[] = shiftTo(start); - int fromEnd[] = shiftTo(end); // needs to be inclusive of end of symbol position - if (fromStart==null || fromEnd==null) - return null; - int iv[] = getIntervals(fromShifts, fromStart, fromEnd,fromRatio); - return iv; - } - - /** - * find series of intervals mapping from start-end in the to map. - * @param start position in from map - * @param end position in from map - * @return series of ranges in to map - */ - public int[] locateInTo(int start, int end) { - // inefficient implementation - int toStart[] = shiftFrom(start); - int toEnd[] = shiftFrom(end); - if (toStart==null || toEnd==null) - return null; - int iv[] = getIntervals(toShifts, toStart, toEnd, toRatio); - return iv; - } - /** - * like shift - except returns the intervals in the given vector of shifts which were spanned - * in traversing fromStart to fromEnd - * @param fromShifts2 - * @param fromStart - * @param fromEnd - * @param fromRatio2 - * @return series of from,to intervals from from first position of starting region to final position of ending region inclusive - */ - private int[] getIntervals(Vector fromShifts2, int[] fromStart, int[] fromEnd, int fromRatio2) - { - int startpos,endpos; - startpos = fromStart[0]; // first position in fromStart - endpos = fromEnd[0]+fromEnd[2]*(fromRatio2-1); // last position in fromEnd - int intv=0,intvSize= fromShifts2.size(); - int iv[],i=0,fs=-1,fe=-1; // containing intervals - while (intv=iv[0] && startpos<=iv[1]) { - fs = i; - } - if (fe==-1 && endpos>=iv[0] && endpos<=iv[1]) { - fe = i; - } - } else { - if (fs==-1 && startpos<=iv[0] && startpos>=iv[1]) { - fs = i; - } - if (fe==-1 && endpos<=iv[0] && endpos>=iv[1]) { - fe = i; - } - } - i++; - } - if (fs==fe && fe==-1) - return null; - Vector ranges=new Vector(); - if (fs<=fe) { - intv = fs; - i=fs; - // truncate initial interval - iv = (int[]) fromShifts2.elementAt(intv++); - iv = new int[] { iv[0], iv[1]};// clone - if (i==fs) - iv[0] = startpos; - while (i!=fe) { - ranges.addElement(iv); // add initial range - iv = (int[]) fromShifts2.elementAt(intv++); // get next interval - iv = new int[] { iv[0], iv[1]};// clone - i++; - } - if (i==fe) - iv[1] = endpos; - ranges.addElement(iv); // add only - or final range - } else { - // walk from end of interval. - i=fromShifts2.size()-1; - while (i>fs) { - i--; - } - iv = (int[]) fromShifts2.elementAt(i); - iv = new int[] { iv[1], iv[0]};// reverse and clone - // truncate initial interval - if (i==fs) - { - iv[0] = startpos; - } - while (--i!=fe) { // fix apparent logic bug when fe==-1 - ranges.addElement(iv); // add (truncated) reversed interval - iv = (int[]) fromShifts2.elementAt(i); - iv = new int[] { iv[1], iv[0] }; // reverse and clone - } - if (i==fe) { - // interval is already reversed - iv[1] = endpos; - } - ranges.addElement(iv); // add only - or final range - } - // create array of start end intervals. - int[] range = null; - if (ranges!=null && ranges.size()>0) - { - range = new int[ranges.size()*2]; - intv = 0; - intvSize=ranges.size(); - i=0; - while (intv" + toofrom[0]); - } - System.out.println("ShiftTo(" + too[0] + ")==" + toofrom[0] + " % " + - toofrom[1]+" ("+toofrom[2]+")"); - } - else - { - System.out.println("ShiftTo(" + too[0] + ")==" + - "NaN! - not Bijective Mapping!"); - } - } - } - int mmap[][] = ml.makeFromMap(); - System.out.println("FromMap : (" + mmap[0][0] + " " + mmap[0][1] + " " + - mmap[0][2] + " " + mmap[0][3] + " "); - for (int i = 1; i <= mmap[1].length; i++) - { - if (mmap[1][i - 1] == -1) - { - System.out.print(i+"=XXX"); - - } - else - { - System.out.print(i+"="+(mmap[0][2]+mmap[1][i-1])); - } - if (i % 20==0) - { - System.out.print("\n"); - } - else - { - System.out.print(","); - } - } - //test range function - System.out.print("\nTest locateInFrom\n"); - { - int f=mmap[0][2],t=mmap[0][3]; - while (f<=t) { - System.out.println("Range "+f+" to "+t); - int rng[] = ml.locateInFrom(f,t); - if (rng!=null) - { - for (int i=0; i. + */ +package uk.ac.vamsas.objects.utils; + +import java.util.*; + +/** + * MapList Simple way of bijectively mapping a non-contiguous linear range to + * another non-contiguous linear range Use at your own risk! TODO: efficient + * implementation of private posMap method TODO: test/ensure that sense of from + * and to ratio start position is conserved (codon start position recovery) + * TODO: optimize to use int[][] arrays rather than vectors. + */ +public class MapList { + /* + * (non-Javadoc) + * + * @see java.lang.Object#equals(java.lang.Object) + */ + public boolean equals(MapList obj) { + if (obj == this) + return true; + if (obj != null && obj.fromRatio == fromRatio && obj.toRatio == toRatio + && obj.fromShifts != null && obj.toShifts != null) { + int i, iSize = fromShifts.size(), j, jSize = obj.fromShifts.size(); + if (iSize != jSize) + return false; + for (i = 0, iSize = fromShifts.size(), j = 0, jSize = obj.fromShifts + .size(); i < iSize;) { + int[] mi = (int[]) fromShifts.elementAt(i++); + int[] mj = (int[]) obj.fromShifts.elementAt(j++); + if (mi[0] != mj[0] || mi[1] != mj[1]) + return false; + } + iSize = toShifts.size(); + jSize = obj.toShifts.size(); + if (iSize != jSize) + return false; + for (i = 0, j = 0; i < iSize;) { + int[] mi = (int[]) toShifts.elementAt(i++); + int[] mj = (int[]) obj.toShifts.elementAt(j++); + if (mi[0] != mj[0] || mi[1] != mj[1]) + return false; + } + return true; + } + return false; + } + + public Vector fromShifts; + + public Vector toShifts; + + int fromRatio; // number of steps in fromShifts to one toRatio unit + + int toRatio; // number of steps in toShifts to one fromRatio + + /** + * + * @return series of intervals mapped in from + */ + public int[] getFromRanges() { + return getRanges(fromShifts); + } + + public int[] getToRanges() { + return getRanges(toShifts); + } + + private int[] getRanges(Vector shifts) { + int[] rnges = new int[2 * shifts.size()]; + Enumeration e = shifts.elements(); + int i = 0; + while (e.hasMoreElements()) { + int r[] = (int[]) e.nextElement(); + rnges[i++] = r[0]; + rnges[i++] = r[1]; + } + return rnges; + } + + /** + * lowest and highest value in the from Map + */ + int[] fromRange = null; + + /** + * lowest and highest value in the to Map + */ + int[] toRange = null; + + /** + * + * @return length of mapped phrase in from + */ + public int getFromRatio() { + return fromRatio; + } + + /** + * + * @return length of mapped phrase in to + */ + public int getToRatio() { + return toRatio; + } + + public int getFromLowest() { + return fromRange[0]; + } + + public int getFromHighest() { + return fromRange[1]; + } + + public int getToLowest() { + return toRange[0]; + } + + public int getToHighest() { + return toRange[1]; + } + + private void ensureRange(int[] limits, int pos) { + if (limits[0] > pos) + limits[0] = pos; + if (limits[1] < pos) + limits[1] = pos; + } + + public MapList(int from[], int to[], int fromRatio, int toRatio) { + fromRange = new int[] { from[0], from[1] }; + toRange = new int[] { to[0], to[1] }; + + fromShifts = new Vector(); + for (int i = 0; i < from.length; i += 2) { + ensureRange(fromRange, from[i]); + ensureRange(fromRange, from[i + 1]); + + fromShifts.addElement(new int[] { from[i], from[i + 1] }); + } + toShifts = new Vector(); + for (int i = 0; i < to.length; i += 2) { + ensureRange(toRange, to[i]); + ensureRange(toRange, to[i + 1]); + toShifts.addElement(new int[] { to[i], to[i + 1] }); + } + this.fromRatio = fromRatio; + this.toRatio = toRatio; + } + + public MapList(MapList map) { + this.fromRange = new int[] { map.fromRange[0], map.fromRange[1] }; + this.toRange = new int[] { map.toRange[0], map.toRange[1] }; + this.fromRatio = map.fromRatio; + this.toRatio = map.toRatio; + if (map.fromShifts != null) { + this.fromShifts = new Vector(); + Enumeration e = map.fromShifts.elements(); + while (e.hasMoreElements()) { + int[] el = (int[]) e.nextElement(); + fromShifts.addElement(new int[] { el[0], el[1] }); + } + } + if (map.toShifts != null) { + this.toShifts = new Vector(); + Enumeration e = map.toShifts.elements(); + while (e.hasMoreElements()) { + int[] el = (int[]) e.nextElement(); + toShifts.addElement(new int[] { el[0], el[1] }); + } + } + } + + /** + * get all mapped positions from 'from' to 'to' + * + * @return int[][] { int[] { fromStart, fromFinish, toStart, toFinish }, int + * [fromFinish-fromStart+2] { toStart..toFinish mappings}} + */ + public int[][] makeFromMap() { + return posMap(fromShifts, fromRatio, toShifts, toRatio); + } + + /** + * get all mapped positions from 'to' to 'from' + * + * @return int[to position]=position mapped in from + */ + public int[][] makeToMap() { + return posMap(toShifts, toRatio, fromShifts, fromRatio); + } + + /** + * construct an int map for intervals in intVals + * + * @param intVals + * @return int[] { from, to pos in range }, int[range.to-range.from+1] + * returning mapped position + */ + private int[][] posMap(Vector intVals, int ratio, Vector toIntVals, + int toRatio) { + int iv = 0, ivSize = intVals.size(); + if (iv >= ivSize) { + return null; + } + int[] intv = (int[]) intVals.elementAt(iv++); + int from = intv[0], to = intv[1]; + if (from > to) { + from = intv[1]; + to = intv[0]; + } + while (iv < ivSize) { + intv = (int[]) intVals.elementAt(iv++); + if (intv[0] < from) { + from = intv[0]; + } + if (intv[1] < from) { + from = intv[1]; + } + if (intv[0] > to) { + to = intv[0]; + } + if (intv[1] > to) { + to = intv[1]; + } + } + int tF = 0, tT = 0; + int mp[][] = new int[to - from + 2][]; + for (int i = 0; i < mp.length; i++) { + int[] m = shift(i + from, intVals, ratio, toIntVals, toRatio); + if (m != null) { + if (i == 0) { + tF = tT = m[0]; + } else { + if (m[0] < tF) { + tF = m[0]; + } + if (m[0] > tT) { + tT = m[0]; + } + } + } + mp[i] = m; + } + int[][] map = new int[][] { new int[] { from, to, tF, tT }, + new int[to - from + 2] }; + + map[0][2] = tF; + map[0][3] = tT; + + for (int i = 0; i < mp.length; i++) { + if (mp[i] != null) { + map[1][i] = mp[i][0] - tF; + } else { + map[1][i] = -1; // indicates an out of range mapping + } + } + return map; + } + + /** + * addShift + * + * @param pos + * start position for shift (in original reference frame) + * @param shift + * length of shift + * + * public void addShift(int pos, int shift) { int sidx = 0; int[] + * rshift=null; while (sidx= intv[0] && pos <= intv[1]) { + return new int[] { count + pos - intv[0] + 1, +1 }; + } else { + count += intv[1] - intv[0] + 1; + } + } else { + if (pos >= intv[1] && pos <= intv[0]) { + return new int[] { count + intv[0] - pos + 1, -1 }; + } else { + count += intv[0] - intv[1] + 1; + } + } + } + return null; + } + + /** + * count out pos positions into a series of intervals and return the position + * + * @param intVals + * @param pos + * @return position pos in interval set + */ + private int[] countToPos(Vector intVals, int pos) { + int count = 0, diff = 0, iv = 0, ivSize = intVals.size(), intv[] = { 0, 0 }; + while (iv < ivSize) { + intv = (int[]) intVals.elementAt(iv++); + diff = intv[1] - intv[0]; + if (diff >= 0) { + if (pos <= count + 1 + diff) { + return new int[] { pos - count - 1 + intv[0], +1 }; + } else { + count += 1 + diff; + } + } else { + if (pos <= count + 1 - diff) { + return new int[] { intv[0] - (pos - count - 1), -1 }; + } else { + count += 1 - diff; + } + } + } + return null;// (diff<0) ? (intv[1]-1) : (intv[0]+1); + } + + /** + * find series of intervals mapping from start-end in the From map. + * + * @param start + * position in to map + * @param end + * position in to map + * @return series of ranges in from map + */ + public int[] locateInFrom(int start, int end) { + // inefficient implementation + int fromStart[] = shiftTo(start); + int fromEnd[] = shiftTo(end); // needs to be inclusive of end of symbol + // position + if (fromStart == null || fromEnd == null) + return null; + int iv[] = getIntervals(fromShifts, fromStart, fromEnd, fromRatio); + return iv; + } + + /** + * find series of intervals mapping from start-end in the to map. + * + * @param start + * position in from map + * @param end + * position in from map + * @return series of ranges in to map + */ + public int[] locateInTo(int start, int end) { + // inefficient implementation + int toStart[] = shiftFrom(start); + int toEnd[] = shiftFrom(end); + if (toStart == null || toEnd == null) + return null; + int iv[] = getIntervals(toShifts, toStart, toEnd, toRatio); + return iv; + } + + /** + * like shift - except returns the intervals in the given vector of shifts + * which were spanned in traversing fromStart to fromEnd + * + * @param fromShifts2 + * @param fromStart + * @param fromEnd + * @param fromRatio2 + * @return series of from,to intervals from from first position of starting + * region to final position of ending region inclusive + */ + private int[] getIntervals(Vector fromShifts2, int[] fromStart, + int[] fromEnd, int fromRatio2) { + int startpos, endpos; + startpos = fromStart[0]; // first position in fromStart + endpos = fromEnd[0] + fromEnd[2] * (fromRatio2 - 1); // last position in + // fromEnd + int intv = 0, intvSize = fromShifts2.size(); + int iv[], i = 0, fs = -1, fe = -1; // containing intervals + while (intv < intvSize && (fs == -1 || fe == -1)) { + iv = (int[]) fromShifts2.elementAt(intv++); + if (iv[0] <= iv[1]) { + if (fs == -1 && startpos >= iv[0] && startpos <= iv[1]) { + fs = i; + } + if (fe == -1 && endpos >= iv[0] && endpos <= iv[1]) { + fe = i; + } + } else { + if (fs == -1 && startpos <= iv[0] && startpos >= iv[1]) { + fs = i; + } + if (fe == -1 && endpos <= iv[0] && endpos >= iv[1]) { + fe = i; + } + } + i++; + } + if (fs == fe && fe == -1) + return null; + Vector ranges = new Vector(); + if (fs <= fe) { + intv = fs; + i = fs; + // truncate initial interval + iv = (int[]) fromShifts2.elementAt(intv++); + iv = new int[] { iv[0], iv[1] };// clone + if (i == fs) + iv[0] = startpos; + while (i != fe) { + ranges.addElement(iv); // add initial range + iv = (int[]) fromShifts2.elementAt(intv++); // get next interval + iv = new int[] { iv[0], iv[1] };// clone + i++; + } + if (i == fe) + iv[1] = endpos; + ranges.addElement(iv); // add only - or final range + } else { + // walk from end of interval. + i = fromShifts2.size() - 1; + while (i > fs) { + i--; + } + iv = (int[]) fromShifts2.elementAt(i); + iv = new int[] { iv[1], iv[0] };// reverse and clone + // truncate initial interval + if (i == fs) { + iv[0] = startpos; + } + while (--i != fe) { // fix apparent logic bug when fe==-1 + ranges.addElement(iv); // add (truncated) reversed interval + iv = (int[]) fromShifts2.elementAt(i); + iv = new int[] { iv[1], iv[0] }; // reverse and clone + } + if (i == fe) { + // interval is already reversed + iv[1] = endpos; + } + ranges.addElement(iv); // add only - or final range + } + // create array of start end intervals. + int[] range = null; + if (ranges != null && ranges.size() > 0) { + range = new int[ranges.size() * 2]; + intv = 0; + intvSize = ranges.size(); + i = 0; + while (intv < intvSize) { + iv = (int[]) ranges.elementAt(intv); + range[i++] = iv[0]; + range[i++] = iv[1]; + ranges.setElementAt(null, intv++); // remove + } + } + return range; + } + + /** + * get the 'initial' position of mpos in To + * + * @param mpos + * position in from + * @return position of first word in to reference frame + */ + public int getToPosition(int mpos) { + int[] mp = shiftTo(mpos); + if (mp != null) { + return mp[0]; + } + return mpos; + } + + /** + * get range of positions in To frame for the mpos word in From + * + * @param mpos + * position in From + * @return null or int[] first position in To for mpos, last position in to + * for Mpos + */ + public int[] getToWord(int mpos) { + int[] mp = shiftTo(mpos); + if (mp != null) { + return new int[] { mp[0], mp[0] + mp[2] * (getFromRatio() - 1) }; + } + return null; + } + + /** + * get From position in the associated reference frame for position pos in the + * associated sequence. + * + * @param pos + * @return + */ + public int getMappedPosition(int pos) { + int[] mp = shiftFrom(pos); + if (mp != null) { + return mp[0]; + } + return pos; + } + + public int[] getMappedWord(int pos) { + int[] mp = shiftFrom(pos); + if (mp != null) { + return new int[] { mp[0], mp[0] + mp[2] * (getToRatio() - 1) }; + } + return null; + } + + /** + * test routine. not incremental. + * + * @param ml + * @param fromS + * @param fromE + */ + public static void testMap(MapList ml, int fromS, int fromE) { + for (int from = 1; from <= 25; from++) { + int[] too = ml.shiftFrom(from); + System.out.print("ShiftFrom(" + from + ")=="); + if (too == null) { + System.out.print("NaN\n"); + } else { + System.out.print(too[0] + " % " + too[1] + " (" + too[2] + ")"); + System.out.print("\t+--+\t"); + int[] toofrom = ml.shiftTo(too[0]); + if (toofrom != null) { + if (toofrom[0] != from) { + System.err.println("Mapping not reflexive:" + from + " " + too[0] + + "->" + toofrom[0]); + } + System.out.println("ShiftTo(" + too[0] + ")==" + toofrom[0] + " % " + + toofrom[1] + " (" + toofrom[2] + ")"); + } else { + System.out.println("ShiftTo(" + too[0] + ")==" + + "NaN! - not Bijective Mapping!"); + } + } + } + int mmap[][] = ml.makeFromMap(); + System.out.println("FromMap : (" + mmap[0][0] + " " + mmap[0][1] + " " + + mmap[0][2] + " " + mmap[0][3] + " "); + for (int i = 1; i <= mmap[1].length; i++) { + if (mmap[1][i - 1] == -1) { + System.out.print(i + "=XXX"); + + } else { + System.out.print(i + "=" + (mmap[0][2] + mmap[1][i - 1])); + } + if (i % 20 == 0) { + System.out.print("\n"); + } else { + System.out.print(","); + } + } + // test range function + System.out.print("\nTest locateInFrom\n"); + { + int f = mmap[0][2], t = mmap[0][3]; + while (f <= t) { + System.out.println("Range " + f + " to " + t); + int rng[] = ml.locateInFrom(f, t); + if (rng != null) { + for (int i = 0; i < rng.length; i++) { + System.out.print(rng[i] + ((i % 2 == 0) ? "," : ";")); + } + } else { + System.out.println("No range!"); + } + System.out.print("\nReversed\n"); + rng = ml.locateInFrom(t, f); + if (rng != null) { + for (int i = 0; i < rng.length; i++) { + System.out.print(rng[i] + ((i % 2 == 0) ? "," : ";")); + } + } else { + System.out.println("No range!"); + } + System.out.print("\n"); + f++; + t--; + } + } + System.out.print("\n"); + mmap = ml.makeToMap(); + System.out.println("ToMap : (" + mmap[0][0] + " " + mmap[0][1] + " " + + mmap[0][2] + " " + mmap[0][3] + " "); + for (int i = 1; i <= mmap[1].length; i++) { + if (mmap[1][i - 1] == -1) { + System.out.print(i + "=XXX"); + + } else { + System.out.print(i + "=" + (mmap[0][2] + mmap[1][i - 1])); + } + if (i % 20 == 0) { + System.out.print("\n"); + } else { + System.out.print(","); + } + } + System.out.print("\n"); + // test range function + System.out.print("\nTest locateInTo\n"); + { + int f = mmap[0][2], t = mmap[0][3]; + while (f <= t) { + System.out.println("Range " + f + " to " + t); + int rng[] = ml.locateInTo(f, t); + if (rng != null) { + for (int i = 0; i < rng.length; i++) { + System.out.print(rng[i] + ((i % 2 == 0) ? "," : ";")); + } + } else { + System.out.println("No range!"); + } + System.out.print("\nReversed\n"); + rng = ml.locateInTo(t, f); + if (rng != null) { + for (int i = 0; i < rng.length; i++) { + System.out.print(rng[i] + ((i % 2 == 0) ? "," : ";")); + } + } else { + System.out.println("No range!"); + } + f++; + t--; + System.out.print("\n"); + } + } + + } + + public static void main(String argv[]) { + MapList ml = new MapList(new int[] { 1, 5, 10, 15, 25, 20 }, new int[] { + 51, 1 }, 1, 3); + MapList ml1 = new MapList(new int[] { 1, 3, 17, 4 }, new int[] { 51, 1 }, + 1, 3); + MapList ml2 = new MapList(new int[] { 1, 60 }, new int[] { 1, 20 }, 3, 1); + // test internal consistency + int to[] = new int[51]; + MapList.testMap(ml, 1, 60); + /* + * for (int from=1; from<=51; from++) { int[] too=ml.shiftTo(from); int[] + * toofrom=ml.shiftFrom(too[0]); + * System.out.println("ShiftFrom("+from+")=="+too + * [0]+" % "+too[1]+"\t+-+\tShiftTo(" + * +too[0]+")=="+toofrom[0]+" % "+toofrom[1]); } + */ + System.out.print("Success?\n"); // if we get here - something must be + // working! + } + + /** + * + * @return a MapList whose From range is this maplist's To Range, and vice + * versa + */ + public MapList getInverse() { + return new MapList(getToRanges(), getFromRanges(), getToRatio(), + getFromRatio()); + } +} diff --git a/src/uk/ac/vamsas/objects/utils/Mapping.java b/src/uk/ac/vamsas/objects/utils/Mapping.java index b592c8c..5f987ae 100644 --- a/src/uk/ac/vamsas/objects/utils/Mapping.java +++ b/src/uk/ac/vamsas/objects/utils/Mapping.java @@ -1,386 +1,360 @@ -package uk.ac.vamsas.objects.utils; -/* - * This code was originated from - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -import java.util.Vector; - -public class Mapping -{ - /** - * Contains the start-end pairs mapping from the associated sequence to the - * sequence in the database coordinate system it also takes care of step - * difference between coordinate systems - */ - MapList map = null; - - /** - * The seuqence that map maps the associated seuqence to (if any). - SequenceI to = null; - */ - public Mapping(MapList map) - { - super(); - this.map = map; - } - -/* public Mapping(SequenceI to, MapList map) - { - this(map); - this.to = to; - } -*/ - /** - * create a new mapping from - * - * (in Jalview) param to was - * the destination sequence being mapped - * @param local - * int[] {start,end,start,end} series on associated sequence - * @param mapped - * int[] {start,end,...} ranges on the reference frame being mapped - * to - * @param i - * step size on associated sequence - * @param j - * step size on mapped frame - */ - public Mapping(//SequenceI to, - int[] local, int[] mapped, int i, int j) - { - this(new MapList(local, mapped, i, j)); - } - - /** - * create a duplicate (and independent) mapping object with the same reference - * to any SequenceI being mapped to. - * - * @param map2 - */ - public Mapping(Mapping map2) - { - if (map2 != this && map2 != null) - { - if (map2.map != null) - { - map = new MapList(map2.map); - } - } - } - - /** - * @return the map - */ - public MapList getMap() - { - return map; - } - - /** - * @param map - * the map to set - */ - public void setMap(MapList map) - { - this.map = map; - } - - /** - * Equals that compares both the to references and MapList mappings. - * - * @param other - * @return - */ - public boolean equals(Mapping other) - { - if (other == null) - return false; - if (other == this) - return true; - if ((map != null && other.map == null) - || (map == null && other.map != null)) - return false; - if (map.equals(other.map)) - return true; - return false; - } - - /** - * get the 'initial' position in the associated sequence for a position in the - * mapped reference frame - * - * @param mpos - * @return - */ - public int getPosition(int mpos) - { - if (map != null) - { - int[] mp = map.shiftTo(mpos); - if (mp != null) - { - return mp[0]; - } - } - return mpos; - } - - /** - * gets boundary in direction of mapping - * - * @param position - * in mapped reference frame - * @return int{start, end} positions in associated sequence (in direction of - * mapped word) - */ - public int[] getWord(int mpos) - { - if (map != null) - { - return map.getToWord(mpos); - } - return null; - } - - /** - * width of mapped unit in associated sequence - * - */ - public int getWidth() - { - if (map != null) - { - return map.getFromRatio(); - } - return 1; - } - - /** - * width of unit in mapped reference frame - * - * @return - */ - public int getMappedWidth() - { - if (map != null) - { - return map.getToRatio(); - } - return 1; - } - - /** - * get mapped position in the associated reference frame for position pos in - * the associated sequence. - * - * @param pos - * @return - */ - public int getMappedPosition(int pos) - { - if (map != null) - { - int[] mp = map.shiftFrom(pos); - if (mp != null) - { - return mp[0]; - } - } - return pos; - } - - public int[] getMappedWord(int pos) - { - if (map != null) - { - int[] mp = map.shiftFrom(pos); - if (mp != null) - { - return new int[] - { mp[0], mp[0] + mp[2] * (map.getToRatio() - 1) }; - } - } - return null; - } - - /** - * locates the region of feature f in the associated (local) sequence's reference - * frame - * - * @param f - * @return int[] { start1, end1, ... starti, endi } for the corresponding interval in local reference frame - */ - public int[] locateFeature(int begin, int end) - { - if (true) - { // f.getBegin()!=f.getEnd()) { - if (map != null) - { - int[] frange = map.locateInFrom(begin, end); //f.getBegin(), f.getEnd()); - /* left in as an example as to how this is used in Jalview - * SequenceFeature[] vf = new SequenceFeature[frange.length / 2]; - for (int i = 0, v = 0; i < frange.length; i += 2, v++) - { - vf[v] = new SequenceFeature(f); - vf[v].setBegin(frange[i]); - vf[v].setEnd(frange[i + 1]); - if (frange.length > 2) - vf[v].setDescription(f.getDescription() + "\nPart " + v); - } - */ - return frange; - } - } - // give up and just return the interval unchanged - this might not be the correct behaviour - return new int[] { begin, end }; - } - - /** - * return a series of contigs on the associated sequence corresponding to the - * from,to interval on the mapped reference frame - * - * @param from - * @param to - * @return int[] { from_i, to_i for i=1 to n contiguous regions in the - * associated sequence} - */ - public int[] locateRange(int from, int to) - { - if (map != null) - { - if (from <= to) - { - from = (map.getToLowest() < from) ? from : map.getToLowest(); - to = (map.getToHighest() > to) ? to : map.getToHighest(); - if (from > to) - return null; - } - else - { - from = (map.getToHighest() > from) ? from : map.getToHighest(); - to = (map.getToLowest() < to) ? to : map.getToLowest(); - if (from < to) - return null; - } - return map.locateInFrom(from, to); - } - return new int[] - { from, to }; - } - - /** - * return a series of mapped contigs mapped from a range on the associated - * sequence - * - * @param from - * @param to - * @return - */ - public int[] locateMappedRange(int from, int to) - { - if (map != null) - { - - if (from <= to) - { - from = (map.getFromLowest() < from) ? from : map.getFromLowest(); - to = (map.getFromHighest() > to) ? to : map.getFromHighest(); - if (from > to) - return null; - } - else - { - from = (map.getFromHighest() > from) ? from : map.getFromHighest(); - to = (map.getFromLowest() < to) ? to : map.getFromLowest(); - if (from < to) - return null; - } - return map.locateInTo(from, to); - } - return new int[] - { from, to }; - } - - /** - * return a new mapping object with a maplist modifed to only map the visible - * regions defined by viscontigs. - * - * @param viscontigs - * @return - */ - public Mapping intersectVisContigs(int[] viscontigs) - { - Mapping copy = new Mapping(this); - if (map != null) - { - Vector toRange = new Vector(); - Vector fromRange = new Vector(); - for (int vc = 0; vc < viscontigs.length; vc += 2) - { - // find a mapped range in this visible region - int[] mpr = locateMappedRange(1+viscontigs[vc], viscontigs[vc + 1]-1); - if (mpr != null) - { - for (int m = 0; m < mpr.length; m += 2) - { - toRange.addElement(new int[] - { mpr[m], mpr[m + 1] }); - int[] xpos = locateRange(mpr[m], mpr[m + 1]); - for (int x = 0; x < xpos.length; x += 2) - { - fromRange.addElement(new int[] - { xpos[x], xpos[x + 1] }); - } - } - } - } - int[] from = new int[fromRange.size()*2]; - int[] to = new int[toRange.size()*2]; - int[] r; - for (int f=0,fSize=fromRange.size(); f Protein exon map and a range of visContigs - */ - MapList fk = new MapList(new int[] { 1,6,8,13,15,23}, new int[] { 1,7}, 3, 1); - Mapping m = new Mapping(fk); - Mapping m_1 = m.intersectVisContigs(new int[] {fk.getFromLowest(), fk.getFromHighest()}); - Mapping m_2 = m.intersectVisContigs(new int[] {1,7,11,20}); - System.out.println(""+m_1.map.getFromRanges()); - // this test was for debugging purposes only - it should run without exceptions, but the - // integrity of the mapping was checked using an interactive debugger rather than programmatically. - } -} +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ +package uk.ac.vamsas.objects.utils; + +/* + * This code was originated from + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +import java.util.Vector; + +public class Mapping { + /** + * Contains the start-end pairs mapping from the associated sequence to the + * sequence in the database coordinate system it also takes care of step + * difference between coordinate systems + */ + MapList map = null; + + /** + * The seuqence that map maps the associated seuqence to (if any). SequenceI + * to = null; + */ + public Mapping(MapList map) { + super(); + this.map = map; + } + + /* + * public Mapping(SequenceI to, MapList map) { this(map); this.to = to; } + */ + /** + * create a new mapping from + * + * (in Jalview) param to was the destination sequence being mapped + * + * @param local + * int[] {start,end,start,end} series on associated sequence + * @param mapped + * int[] {start,end,...} ranges on the reference frame being mapped + * to + * @param i + * step size on associated sequence + * @param j + * step size on mapped frame + */ + public Mapping(// SequenceI to, + int[] local, int[] mapped, int i, int j) { + this(new MapList(local, mapped, i, j)); + } + + /** + * create a duplicate (and independent) mapping object with the same reference + * to any SequenceI being mapped to. + * + * @param map2 + */ + public Mapping(Mapping map2) { + if (map2 != this && map2 != null) { + if (map2.map != null) { + map = new MapList(map2.map); + } + } + } + + /** + * @return the map + */ + public MapList getMap() { + return map; + } + + /** + * @param map + * the map to set + */ + public void setMap(MapList map) { + this.map = map; + } + + /** + * Equals that compares both the to references and MapList mappings. + * + * @param other + * @return + */ + public boolean equals(Mapping other) { + if (other == null) + return false; + if (other == this) + return true; + if ((map != null && other.map == null) + || (map == null && other.map != null)) + return false; + if (map.equals(other.map)) + return true; + return false; + } + + /** + * get the 'initial' position in the associated sequence for a position in the + * mapped reference frame + * + * @param mpos + * @return + */ + public int getPosition(int mpos) { + if (map != null) { + int[] mp = map.shiftTo(mpos); + if (mp != null) { + return mp[0]; + } + } + return mpos; + } + + /** + * gets boundary in direction of mapping + * + * @param position + * in mapped reference frame + * @return int{start, end} positions in associated sequence (in direction of + * mapped word) + */ + public int[] getWord(int mpos) { + if (map != null) { + return map.getToWord(mpos); + } + return null; + } + + /** + * width of mapped unit in associated sequence + * + */ + public int getWidth() { + if (map != null) { + return map.getFromRatio(); + } + return 1; + } + + /** + * width of unit in mapped reference frame + * + * @return + */ + public int getMappedWidth() { + if (map != null) { + return map.getToRatio(); + } + return 1; + } + + /** + * get mapped position in the associated reference frame for position pos in + * the associated sequence. + * + * @param pos + * @return + */ + public int getMappedPosition(int pos) { + if (map != null) { + int[] mp = map.shiftFrom(pos); + if (mp != null) { + return mp[0]; + } + } + return pos; + } + + public int[] getMappedWord(int pos) { + if (map != null) { + int[] mp = map.shiftFrom(pos); + if (mp != null) { + return new int[] { mp[0], mp[0] + mp[2] * (map.getToRatio() - 1) }; + } + } + return null; + } + + /** + * locates the region of feature f in the associated (local) sequence's + * reference frame + * + * @param f + * @return int[] { start1, end1, ... starti, endi } for the corresponding + * interval in local reference frame + */ + public int[] locateFeature(int begin, int end) { + if (true) { // f.getBegin()!=f.getEnd()) { + if (map != null) { + int[] frange = map.locateInFrom(begin, end); // f.getBegin(), + // f.getEnd()); + /* + * left in as an example as to how this is used in Jalview + * SequenceFeature[] vf = new SequenceFeature[frange.length / 2]; for + * (int i = 0, v = 0; i < frange.length; i += 2, v++) { vf[v] = new + * SequenceFeature(f); vf[v].setBegin(frange[i]); vf[v].setEnd(frange[i + * + 1]); if (frange.length > 2) vf[v].setDescription(f.getDescription() + * + "\nPart " + v); } + */ + return frange; + } + } + // give up and just return the interval unchanged - this might not be the + // correct behaviour + return new int[] { begin, end }; + } + + /** + * return a series of contigs on the associated sequence corresponding to the + * from,to interval on the mapped reference frame + * + * @param from + * @param to + * @return int[] { from_i, to_i for i=1 to n contiguous regions in the + * associated sequence} + */ + public int[] locateRange(int from, int to) { + if (map != null) { + if (from <= to) { + from = (map.getToLowest() < from) ? from : map.getToLowest(); + to = (map.getToHighest() > to) ? to : map.getToHighest(); + if (from > to) + return null; + } else { + from = (map.getToHighest() > from) ? from : map.getToHighest(); + to = (map.getToLowest() < to) ? to : map.getToLowest(); + if (from < to) + return null; + } + return map.locateInFrom(from, to); + } + return new int[] { from, to }; + } + + /** + * return a series of mapped contigs mapped from a range on the associated + * sequence + * + * @param from + * @param to + * @return + */ + public int[] locateMappedRange(int from, int to) { + if (map != null) { + + if (from <= to) { + from = (map.getFromLowest() < from) ? from : map.getFromLowest(); + to = (map.getFromHighest() > to) ? to : map.getFromHighest(); + if (from > to) + return null; + } else { + from = (map.getFromHighest() > from) ? from : map.getFromHighest(); + to = (map.getFromLowest() < to) ? to : map.getFromLowest(); + if (from < to) + return null; + } + return map.locateInTo(from, to); + } + return new int[] { from, to }; + } + + /** + * return a new mapping object with a maplist modifed to only map the visible + * regions defined by viscontigs. + * + * @param viscontigs + * @return + */ + public Mapping intersectVisContigs(int[] viscontigs) { + Mapping copy = new Mapping(this); + if (map != null) { + Vector toRange = new Vector(); + Vector fromRange = new Vector(); + for (int vc = 0; vc < viscontigs.length; vc += 2) { + // find a mapped range in this visible region + int[] mpr = locateMappedRange(1 + viscontigs[vc], + viscontigs[vc + 1] - 1); + if (mpr != null) { + for (int m = 0; m < mpr.length; m += 2) { + toRange.addElement(new int[] { mpr[m], mpr[m + 1] }); + int[] xpos = locateRange(mpr[m], mpr[m + 1]); + for (int x = 0; x < xpos.length; x += 2) { + fromRange.addElement(new int[] { xpos[x], xpos[x + 1] }); + } + } + } + } + int[] from = new int[fromRange.size() * 2]; + int[] to = new int[toRange.size() * 2]; + int[] r; + for (int f = 0, fSize = fromRange.size(); f < fSize; f++) { + r = (int[]) fromRange.elementAt(f); + from[f * 2] = r[0]; + from[f * 2 + 1] = r[1]; + } + for (int f = 0, fSize = toRange.size(); f < fSize; f++) { + r = (int[]) toRange.elementAt(f); + to[f * 2] = r[0]; + to[f * 2 + 1] = r[1]; + } + copy.setMap(new MapList(from, to, map.getFromRatio(), map.getToRatio())); + } + return copy; + } + + public static void main(String[] args) { + /** + * trite test of the intersectVisContigs method for a simple DNA -> Protein + * exon map and a range of visContigs + */ + MapList fk = new MapList(new int[] { 1, 6, 8, 13, 15, 23 }, new int[] { 1, + 7 }, 3, 1); + Mapping m = new Mapping(fk); + Mapping m_1 = m.intersectVisContigs(new int[] { fk.getFromLowest(), + fk.getFromHighest() }); + Mapping m_2 = m.intersectVisContigs(new int[] { 1, 7, 11, 20 }); + System.out.println("" + m_1.map.getFromRanges()); + // this test was for debugging purposes only - it should run without + // exceptions, but the + // integrity of the mapping was checked using an interactive debugger rather + // than programmatically. + } +} diff --git a/src/uk/ac/vamsas/objects/utils/Properties.java b/src/uk/ac/vamsas/objects/utils/Properties.java index 4d5c874..039096e 100644 --- a/src/uk/ac/vamsas/objects/utils/Properties.java +++ b/src/uk/ac/vamsas/objects/utils/Properties.java @@ -1,3 +1,24 @@ +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ package uk.ac.vamsas.objects.utils; import java.util.Enumeration; @@ -6,152 +27,150 @@ import java.util.Vector; import uk.ac.vamsas.objects.core.Property; public class Properties { - public static Property newProperty(String name, String type, String content) - { + public static Property newProperty(String name, String type, String content) { Property vProperty = new Property(); vProperty.setName(name); - if (type != null) - { + if (type != null) { vProperty.setType(type); - } - else - { + } else { vProperty.setType(STRINGTYPE); } vProperty.setContent(content); return vProperty; } - final public static String STRINGTYPE="string"; - final public static String FLOATTYPE="float"; - final public static String INTEGERTYPE="integer"; - final public static String BOOLEANTYPE="boolean"; + + final public static String STRINGTYPE = "string"; + + final public static String FLOATTYPE = "float"; + + final public static String INTEGERTYPE = "integer"; + + final public static String BOOLEANTYPE = "boolean"; + /** - * add newprop to properties, or update the value of an existing property with the same exact name and type. - * Note - this routine will stop after encounting the first occurance of a Property with the same name and type, no others will be affected. + * add newprop to properties, or update the value of an existing property with + * the same exact name and type. Note - this routine will stop after + * encounting the first occurance of a Property with the same name and type, + * no others will be affected. + * * @param properties - * @param newprop - * @return true if property was added or its value updated. false if no change was made. + * @param newprop + * @return true if property was added or its value updated. false if no change + * was made. */ - public static boolean addOrReplace(Vector properties, Property newprop) - { - if (properties.size()>0) - { + public static boolean addOrReplace(Vector properties, Property newprop) { + if (properties.size() > 0) { Enumeration en = properties.elements(); - while (en.hasMoreElements()) - { + while (en.hasMoreElements()) { Object el = en.nextElement(); - if (el instanceof Property) - { + if (el instanceof Property) { Property prop = (Property) el; - if (prop.getName().equals(newprop.getName()) && - prop.getType().equals(newprop.getType())) - { - if (prop.getContent().equals(newprop.getContent())) - { + if (prop.getName().equals(newprop.getName()) + && prop.getType().equals(newprop.getType())) { + if (prop.getContent().equals(newprop.getContent())) { return false; - } else { + } else { prop.setContent(newprop.getContent()); return true; } } } else { - throw new Error("Implementation Error: properties must be a Vector of uk.ac.vamsas.objects.core.Property objects only."); + throw new Error( + "Implementation Error: properties must be a Vector of uk.ac.vamsas.objects.core.Property objects only."); } } - } + } properties.addElement(newprop); return true; } + /** - * validate property p against the known type strings and try to parse the content string accordingly + * validate property p against the known type strings and try to parse the + * content string accordingly + * * @param p - * @return true if the content parses as the given type (if it is known) - * TODO: decide if an isValidType method is also necessary. + * @return true if the content parses as the given type (if it is known) TODO: + * decide if an isValidType method is also necessary. */ - public static boolean isValid(Property p) - { - if (p.getType().equalsIgnoreCase(STRINGTYPE)) - { + public static boolean isValid(Property p) { + if (p.getType().equalsIgnoreCase(STRINGTYPE)) { return true; - } else - if (p.getType().equalsIgnoreCase(BOOLEANTYPE)) - { - try { - Boolean bool = new Boolean(p.getContent()); - return true; - } catch (Exception e) - { - return false; - } - } else - if (p.getType().equalsIgnoreCase(FLOATTYPE)) - { - try { - Float fv = new Float(p.getContent()); - return true; - } catch (Exception e) - { - return false; - } + } else if (p.getType().equalsIgnoreCase(BOOLEANTYPE)) { + try { + Boolean bool = new Boolean(p.getContent()); + return true; + } catch (Exception e) { + return false; } - else - if( p.getType().equalsIgnoreCase(INTEGERTYPE)) - { - - try { - Integer fv = new Integer(p.getContent()); - return true; - } catch (Exception e) - { - return false; - } - } + } else if (p.getType().equalsIgnoreCase(FLOATTYPE)) { + try { + Float fv = new Float(p.getContent()); + return true; + } catch (Exception e) { + return false; + } + } else if (p.getType().equalsIgnoreCase(INTEGERTYPE)) { + + try { + Integer fv = new Integer(p.getContent()); + return true; + } catch (Exception e) { + return false; + } + } return false; } + /** - * String content test + * String content test + * * @param p - * @return true if the property is a string + * @return true if the property is a string */ - public static boolean isString(Property p) - { + public static boolean isString(Property p) { return isType(p, STRINGTYPE); } + /** - * Float content test + * Float content test + * * @param p - * @return true if the property is a string + * @return true if the property is a string */ - public static boolean isFloat(Property p) - { + public static boolean isFloat(Property p) { return isType(p, FLOATTYPE); } + /** - * Integer content test + * Integer content test + * * @param p - * @return true if the property is a string + * @return true if the property is a string */ - public static boolean isInteger(Property p) - { + public static boolean isInteger(Property p) { return isType(p, INTEGERTYPE); } + /** - * Boolean content test + * Boolean content test + * * @param p - * @return true if the property is a string + * @return true if the property is a string */ - public static boolean isBoolean(Property p) - { + public static boolean isBoolean(Property p) { return isType(p, BOOLEANTYPE); } + /** * - * @param p the property to test for type - * @param typeString one of the string constants in this class + * @param p + * the property to test for type + * @param typeString + * one of the string constants in this class * @return true if p is of type 'typeString' */ public static boolean isType(Property p, String typeString) { - return (p==null) ? false : (p.getType().toLowerCase().equals(typeString)); + return (p == null) ? false : (p.getType().toLowerCase().equals(typeString)); } - + } diff --git a/src/uk/ac/vamsas/objects/utils/ProvenanceStuff.java b/src/uk/ac/vamsas/objects/utils/ProvenanceStuff.java index 3c675dc..d6a7d6d 100644 --- a/src/uk/ac/vamsas/objects/utils/ProvenanceStuff.java +++ b/src/uk/ac/vamsas/objects/utils/ProvenanceStuff.java @@ -1,46 +1,72 @@ -package uk.ac.vamsas.objects.utils; - -import java.util.Date; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import uk.ac.vamsas.objects.core.Entry; -import uk.ac.vamsas.objects.core.Provenance; - -public class ProvenanceStuff { - - /** - * stuff for making and doing things with provenance objects. - */ - static Log log = LogFactory.getLog(ProvenanceStuff.class); - - /** - * @param app TODO - * @param action - * text for action entry - * @return new Provenance entry for ArchiveWriter created docs. - * TODO: Verify and move to SimpleClient class for provenance handling - */ - public static Entry newProvenanceEntry(String app, String user, String action) { - log.debug("Adding ProvenanceEntry("+user+","+action+")"); - Entry e = new Entry(); - e.setApp(app); - e.setAction(action); - e.setUser(user); - e.setDate(new Date()); - return e; - } - public static Provenance newProvenance(Entry entry) { - Provenance list = new Provenance(); - list.addEntry(entry); - return list; - } - public static Provenance newProvenance(String user, String action) { - return newProvenance(ProvenanceStuff.newProvenanceEntry("vamsasApp:ExampleVamsasClient/alpha", user, action)); - } - public static Provenance newProvenance(String app, String user, String action) { - return newProvenance(ProvenanceStuff.newProvenanceEntry(app, user, action)); - } - -} +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ +package uk.ac.vamsas.objects.utils; + +import java.util.Date; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import uk.ac.vamsas.objects.core.Entry; +import uk.ac.vamsas.objects.core.Provenance; + +public class ProvenanceStuff { + + /** + * stuff for making and doing things with provenance objects. + */ + static Log log = LogFactory.getLog(ProvenanceStuff.class); + + /** + * @param app + * TODO + * @param action + * text for action entry + * @return new Provenance entry for ArchiveWriter created docs. TODO: Verify + * and move to SimpleClient class for provenance handling + */ + public static Entry newProvenanceEntry(String app, String user, String action) { + log.debug("Adding ProvenanceEntry(" + user + "," + action + ")"); + Entry e = new Entry(); + e.setApp(app); + e.setAction(action); + e.setUser(user); + e.setDate(new Date()); + return e; + } + + public static Provenance newProvenance(Entry entry) { + Provenance list = new Provenance(); + list.addEntry(entry); + return list; + } + + public static Provenance newProvenance(String user, String action) { + return newProvenance(ProvenanceStuff.newProvenanceEntry( + "vamsasApp:ExampleVamsasClient/alpha", user, action)); + } + + public static Provenance newProvenance(String app, String user, String action) { + return newProvenance(ProvenanceStuff.newProvenanceEntry(app, user, action)); + } + +} diff --git a/src/uk/ac/vamsas/objects/utils/Range.java b/src/uk/ac/vamsas/objects/utils/Range.java index 74ace8e..8e4c314 100644 --- a/src/uk/ac/vamsas/objects/utils/Range.java +++ b/src/uk/ac/vamsas/objects/utils/Range.java @@ -1,3 +1,24 @@ +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ package uk.ac.vamsas.objects.utils; import java.util.Vector; @@ -9,90 +30,80 @@ import uk.ac.vamsas.objects.core.RangeType; import uk.ac.vamsas.objects.core.Seg; /** - * Utilities for working with RangeType and MapType objects. - * Derived from bitter experience. + * Utilities for working with RangeType and MapType objects. Derived from bitter + * experience. + * * @author JimP - * + * */ public class Range { - static org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getFactory().getLog(Range.class); + static org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory + .getFactory().getLog(Range.class); /** * get start 0 && dseta.getPosCount() > 0) - { - throw new Error("Invalid vamsas RangeType - cannot resolve both lists of Pos and Seg from choice!"); + if (dseta.getSegCount() > 0 && dseta.getPosCount() > 0) { + throw new Error( + "Invalid vamsas RangeType - cannot resolve both lists of Pos and Seg from choice!"); } - if (dseta.getSegCount() > 0) - { + if (dseta.getSegCount() > 0) { se = getSegRange(dseta.getSeg(0), true); - for (int s = 1, sSize = dseta.getSegCount(); s < sSize; s++) - { + for (int s = 1, sSize = dseta.getSegCount(); s < sSize; s++) { int nse[] = getSegRange(dseta.getSeg(s), true); - if (se[0] > nse[0]) - { + if (se[0] > nse[0]) { se[0] = nse[0]; } - if (se[1] < nse[1]) - { + if (se[1] < nse[1]) { se[1] = nse[1]; } } } - if (dseta.getPosCount() > 0) - { - // could do a polarity for pos range too. and pass back indication of discontinuities. + if (dseta.getPosCount() > 0) { + // could do a polarity for pos range too. and pass back indication of + // discontinuities. int pos = dseta.getPos(0).getI(); - se = new int[] - { - pos, pos}; - for (int p = 0, pSize = dseta.getPosCount(); p < pSize; p++) - { + se = new int[] { pos, pos }; + for (int p = 0, pSize = dseta.getPosCount(); p < pSize; p++) { pos = dseta.getPos(p).getI(); - if (se[0] > pos) - { + if (se[0] > pos) { se[0] = pos; } - if (se[1] < pos) - { + if (se[1] < pos) { se[1] = pos; } } @@ -103,49 +114,41 @@ public class Range { } /** - * map from a rangeType's internal frame to the referenced object's coordinate frame. + * map from a rangeType's internal frame to the referenced object's coordinate + * frame. + * * @param dseta * @return int [] { ref(pos)...} for all pos in rangeType's frame. */ - public static int[] getMapping(RangeType dseta) - { + public static int[] getMapping(RangeType dseta) { Vector posList = new Vector(); - if (dseta != null) - { + if (dseta != null) { int[] se = null; - if (dseta.getSegCount() > 0 && dseta.getPosCount() > 0) - { - throw new Error("Invalid vamsas RangeType - cannot resolve both lists of Pos and Seg from choice!"); + if (dseta.getSegCount() > 0 && dseta.getPosCount() > 0) { + throw new Error( + "Invalid vamsas RangeType - cannot resolve both lists of Pos and Seg from choice!"); } - if (dseta.getSegCount() > 0) - { - for (int s = 0, sSize = dseta.getSegCount(); s < sSize; s++) - { + if (dseta.getSegCount() > 0) { + for (int s = 0, sSize = dseta.getSegCount(); s < sSize; s++) { se = getSegRange(dseta.getSeg(s), false); int se_end = se[1 - se[2]] + (se[2] == 0 ? 1 : -1); - for (int p = se[se[2]]; p != se_end; p += se[2] == 0 ? 1 : -1) - { + for (int p = se[se[2]]; p != se_end; p += se[2] == 0 ? 1 : -1) { posList.add(new Integer(p)); } } - } - else if (dseta.getPosCount() > 0) - { + } else if (dseta.getPosCount() > 0) { int pos = dseta.getPos(0).getI(); - for (int p = 0, pSize = dseta.getPosCount(); p < pSize; p++) - { + for (int p = 0, pSize = dseta.getPosCount(); p < pSize; p++) { pos = dseta.getPos(p).getI(); posList.add(new Integer(pos)); } } } - if (posList != null && posList.size() > 0) - { + if (posList != null && posList.size() > 0) { int[] range = new int[posList.size()]; - for (int i = 0; i < range.length; i++) - { - range[i] = ( (Integer) posList.elementAt(i)).intValue(); + for (int i = 0; i < range.length; i++) { + range[i] = ((Integer) posList.elementAt(i)).intValue(); } posList.clear(); return range; @@ -153,61 +156,52 @@ public class Range { return null; } - public static int[] getIntervals(RangeType range) - { - int[] intervals=null; + public static int[] getIntervals(RangeType range) { + int[] intervals = null; Vector posList = new Vector(); - if (range != null) - { + if (range != null) { int[] se = null; - if (range.getSegCount() > 0 && range.getPosCount() > 0) - { - throw new Error("Invalid vamsas RangeType - cannot resolve both lists of Pos and Seg from choice!"); -} - if (range.getSegCount() > 0) - { - for (int s = 0, sSize = range.getSegCount(); s < sSize; s++) - { + if (range.getSegCount() > 0 && range.getPosCount() > 0) { + throw new Error( + "Invalid vamsas RangeType - cannot resolve both lists of Pos and Seg from choice!"); + } + if (range.getSegCount() > 0) { + for (int s = 0, sSize = range.getSegCount(); s < sSize; s++) { se = getSegRange(range.getSeg(s), false); posList.addElement(new Integer(se[0])); posList.addElement(new Integer(se[1])); } - } - else if (range.getPosCount() > 0) - { + } else if (range.getPosCount() > 0) { int pos = range.getPos(0).getI(); - for (int p = 0, pSize = range.getPosCount(); p < pSize; p++) - { + for (int p = 0, pSize = range.getPosCount(); p < pSize; p++) { pos = range.getPos(p).getI(); posList.add(new Integer(pos)); posList.add(new Integer(pos)); } } } - if (posList != null && posList.size() > 0) - { - intervals=new int[posList.size()]; + if (posList != null && posList.size() > 0) { + intervals = new int[posList.size()]; java.util.Enumeration e = posList.elements(); - int i=0; - while (e.hasMoreElements()) - { - intervals[i++] = ((Integer)e.nextElement()).intValue(); + int i = 0; + while (e.hasMoreElements()) { + intervals[i++] = ((Integer) e.nextElement()).intValue(); } } return intervals; } + /** * initialise a range type object from a set of start/end inclusive intervals + * * @param mrt * @param range */ - public static void initRangeType(RangeType mrt, int[] range) - { - for (int i=0; i "+map.toString()))); + public static MapList parsemapType(MapType map) { + if (!map.getLocal().hasUnit() || !map.getMapped().hasUnit()) { + if (log.isDebugEnabled()) { + log.debug("using default mapping length of 1:1 for map " + + (map.isRegistered() ? map.getVorbaId().toString() + : (" " + map.toString()))); } } - return parsemapType(map, 1, 1); + return parsemapType(map, 1, 1); } /** * initialise a MapType object from a MapList object. + * * @param maprange * @param ml * @param setUnits */ - public static void initMapType(MapType maprange, MapList ml, boolean setUnits) - { + public static void initMapType(MapType maprange, MapList ml, boolean setUnits) { initMapType(maprange, ml, setUnits, false); } + /** * * @param maprange * @param ml * @param setUnits - * @param reverse - reverse MapList mapping for Local and Mapped ranges and units + * @param reverse + * - reverse MapList mapping for Local and Mapped ranges and units */ - public static void initMapType(MapType maprange, MapList ml, boolean setUnits, boolean reverse) - { + public static void initMapType(MapType maprange, MapList ml, + boolean setUnits, boolean reverse) { maprange.setLocal(new Local()); maprange.setMapped(new Mapped()); - if (!reverse) - { + if (!reverse) { initRangeType(maprange.getLocal(), ml.getFromRanges()); initRangeType(maprange.getMapped(), ml.getToRanges()); - } else { - initRangeType(maprange.getLocal(), ml.getToRanges()); - initRangeType(maprange.getMapped(), ml.getFromRanges()); - } - if (setUnits) - { - if (!reverse) - { + } else { + initRangeType(maprange.getLocal(), ml.getToRanges()); + initRangeType(maprange.getMapped(), ml.getFromRanges()); + } + if (setUnits) { + if (!reverse) { maprange.getLocal().setUnit(ml.getFromRatio()); maprange.getMapped().setUnit(ml.getToRatio()); } else { @@ -291,4 +286,4 @@ public class Range { } } -} \ No newline at end of file +} diff --git a/src/uk/ac/vamsas/objects/utils/Seq.java b/src/uk/ac/vamsas/objects/utils/Seq.java index 7c82d82..538d658 100644 --- a/src/uk/ac/vamsas/objects/utils/Seq.java +++ b/src/uk/ac/vamsas/objects/utils/Seq.java @@ -1,131 +1,162 @@ -/* - * Created on 17-May-2005 - * - * TODO To change the template for this generated file go to - * Window - Preferences - Java - Code Style - Code Templates - */ -package uk.ac.vamsas.objects.utils; - -import java.io.BufferedWriter; -import java.io.IOException; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.util.regex.Pattern; - -import uk.ac.vamsas.objects.core.AlignmentSequence; -import uk.ac.vamsas.objects.core.Sequence; -import uk.ac.vamsas.objects.core.SequenceType; - -/** - * @author jimp - * - * TODO To change the template for this generated type comment go to - * Window - Preferences - Java - Code Style - Code Templates - */ -public class Seq { - - public static void write_PirSeq(OutputStream os, SequenceType seq, int wid) throws IOException { - BufferedWriter pir_out = new BufferedWriter(new OutputStreamWriter(os)); - pir_out.write(">P1;"+seq.getName()+"\n"); - int width = (wid<1) ? 80 : wid; - for (int j=0,k=seq.getSequence().length(); j"+seq.getName()+"\n"); - fasta_out.write(seq.getSequence()+"\n"); - fasta_out.flush(); - } - - public static void write_FastaSeq(OutputStream os, SequenceType seq, int wid) throws IOException { - BufferedWriter fasta_out = new BufferedWriter(new OutputStreamWriter(os)); - fasta_out.write(">"+seq.getName()+"\n"); - int width = (wid<1) ? 80 : wid; - for (int j=0,k=seq.getSequence().length(); jend on Sequence Vobject - if ((start-end)!=Sequence.length()) - seq.setEnd(end+Sequence.length()); - } - return seq; - } - public static AlignmentSequence newAlignmentSequence(String name, String alSequence, Sequence refseq, long start, long end) { - if (refseq!=null) { - AlignmentSequence asq = new AlignmentSequence(); - asq.setName(name); - asq.setSequence(alSequence); - asq.setRefid(refseq); - if (end>refseq.getEnd() || end0 - || !q.getDictionary().equals(SymbolDictionary.STANDARD_AA)) - return false; - return valid_aadictionary_string(q.getSequence(), SymbolDictionary.STANDARD_AA); - } - - // follow references - if (s instanceof AlignmentSequence) { - Object w = (((AlignmentSequence) s).getRefid()); - if (w!=null && w!=s && w instanceof SequenceType) - return is_valid_aa_seq((SequenceType) w) - && valid_aadictionary_string(((AlignmentSequence) s).getSequence(), SymbolDictionary.STANDARD_AA); - } - - return false; - } -} +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ +package uk.ac.vamsas.objects.utils; + +import java.io.BufferedWriter; +import java.io.IOException; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.util.regex.Pattern; + +import uk.ac.vamsas.objects.core.AlignmentSequence; +import uk.ac.vamsas.objects.core.Sequence; +import uk.ac.vamsas.objects.core.SequenceType; + +/** + * @author jimp + * + * TODO To change the template for this generated type comment go to + * Window - Preferences - Java - Code Style - Code Templates + */ +public class Seq { + + public static void write_PirSeq(OutputStream os, SequenceType seq, int wid) + throws IOException { + BufferedWriter pir_out = new BufferedWriter(new OutputStreamWriter(os)); + pir_out.write(">P1;" + seq.getName() + "\n"); + int width = (wid < 1) ? 80 : wid; + for (int j = 0, k = seq.getSequence().length(); j < k; j += width) + if (j + width < k) + pir_out.write(seq.getSequence().substring(j, j + width) + "\n"); + else + pir_out.write(seq.getSequence().substring(j) + "\n"); + pir_out.flush(); + } + + public static void write_FastaSeq(OutputStream os, SequenceType seq) + throws IOException { + BufferedWriter fasta_out = new BufferedWriter(new OutputStreamWriter(os)); + fasta_out.write(">" + seq.getName() + "\n"); + fasta_out.write(seq.getSequence() + "\n"); + fasta_out.flush(); + } + + public static void write_FastaSeq(OutputStream os, SequenceType seq, int wid) + throws IOException { + BufferedWriter fasta_out = new BufferedWriter(new OutputStreamWriter(os)); + fasta_out.write(">" + seq.getName() + "\n"); + int width = (wid < 1) ? 80 : wid; + for (int j = 0, k = seq.getSequence().length(); j < k; j += width) + if (j + width < k) + fasta_out.write(seq.getSequence().substring(j, j + width) + "\n"); + else + fasta_out.write(seq.getSequence().substring(j) + "\n"); + fasta_out.flush(); + } + + /** + *validate a SequenceType Vobject as an info:iubmb.org/aminoacid SequenceType + * This version resolves references to Sequence objects from AlignmentSequence + * TODO: Define info: urn for dictionary string (could also be regex of valid + * characters!) + * + * @param s + * @param dict + * TODO + * @return true if a valid amino acid sequence Vobject + */ + private static boolean valid_aadictionary_string(String s, String dict) { + if (s == null) + return false; + // validate against dictionary + // TODO generalise to resolve dictionary against info: urn for dictionary + // type + Pattern aa_repl = Pattern.compile("[ARNDCQEGHILKMFPSTWYVUX]+", + Pattern.CASE_INSENSITIVE); + String remnants = aa_repl.matcher(s).replaceAll(""); + return !remnants.matches("//S+"); + } + + public static Sequence newSequence(String Name, String Sequence, + String Dictionary, int start, int end) { + // TODO: make hierarchy reflecting the SeqType Vobject. + Sequence seq = new Sequence(); + seq.setDictionary(Dictionary); + seq.setName(Name); + seq.setSequence(Sequence); + seq.setStart(start); + if (start <= end) { + if ((end - start) != Sequence.length()) + seq.setEnd(start + Sequence.length()); + } else { + // reverse topology mapping. TODO: VAMSAS: decide if allowed to do + // start>end on Sequence Vobject + if ((start - end) != Sequence.length()) + seq.setEnd(end + Sequence.length()); + } + return seq; + } + + public static AlignmentSequence newAlignmentSequence(String name, + String alSequence, Sequence refseq, long start, long end) { + if (refseq != null) { + AlignmentSequence asq = new AlignmentSequence(); + asq.setName(name); + asq.setSequence(alSequence); + asq.setRefid(refseq); + if (end > refseq.getEnd() || end < start || end == -1) + end = refseq.getEnd(); + asq.setEnd(end); + if (start < refseq.getStart()) + start = refseq.getStart(); + asq.setStart(start); + return asq; + } + return null; + } + + public static boolean is_valid_aa_seq(SequenceType s) { + Sequence q; + boolean validref = false; + if (s instanceof Sequence) { + q = (Sequence) s; + if (q.getDictionary() != null + + && q.getDictionary().length() > 0 + || !q.getDictionary().equals(SymbolDictionary.STANDARD_AA)) + return false; + return valid_aadictionary_string(q.getSequence(), + SymbolDictionary.STANDARD_AA); + } + + // follow references + if (s instanceof AlignmentSequence) { + Object w = (((AlignmentSequence) s).getRefid()); + if (w != null && w != s && w instanceof SequenceType) + return is_valid_aa_seq((SequenceType) w) + && valid_aadictionary_string(((AlignmentSequence) s).getSequence(), + SymbolDictionary.STANDARD_AA); + } + + return false; + } +} diff --git a/src/uk/ac/vamsas/objects/utils/SeqAln.java b/src/uk/ac/vamsas/objects/utils/SeqAln.java index e9f49bd..92e8068 100644 --- a/src/uk/ac/vamsas/objects/utils/SeqAln.java +++ b/src/uk/ac/vamsas/objects/utils/SeqAln.java @@ -1,238 +1,261 @@ -/* - * Created on 17-May-2005 - * - * TODO To change the template for this generated file go to - * Window - Preferences - Java - Code Style - Code Templates - */ -package uk.ac.vamsas.objects.utils; - -import java.io.BufferedOutputStream; -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.util.Hashtable; -import java.util.StringTokenizer; -import java.util.Vector; -import java.util.regex.Pattern; - -import uk.ac.vamsas.objects.core.*; - -/** - * @author jimp - * - * TODO To change the template for this generated type comment go to Window - - * Preferences - Java - Code Style - Code Templates - */ -public class SeqAln extends uk.ac.vamsas.objects.core.Alignment { - - public static Sequence[] ReadClustalFile(InputStream os) throws Exception { - System.err.println("NOT FULLY IMPLEMENTED!"); // TODO: Finish adapting this method - Pattern nonGap = Pattern.compile("[A-Z*0-9]", Pattern.CASE_INSENSITIVE); - String gapchars = ""; - char gapchar = '-'; - - int i = 0; - boolean flag = false; - - Vector headers = new Vector(); - Hashtable seqhash = new Hashtable(); - Sequence[] seqs = null; - int noSeqs = 0; - String line; - - try { - BufferedReader ins = new BufferedReader(new InputStreamReader(os)); - while ((line = ins.readLine()) != null) { - if (line.indexOf(" ") != 0) { - java.util.StringTokenizer str = new StringTokenizer(line, " "); - String id = ""; - - if (str.hasMoreTokens()) { - id = str.nextToken(); - if (id.equals("CLUSTAL")) { - flag = true; - } else { - if (flag) { - StringBuffer tempseq; - if (seqhash.containsKey(id)) { - tempseq = (StringBuffer) seqhash.get(id); - } else { - tempseq = new StringBuffer(); - seqhash.put(id, tempseq); - } - - if (!(headers.contains(id))) { - headers.addElement(id); - } - - tempseq.append(str.nextToken()); - } - } - } - } - } - - } catch (IOException e) { - throw (new Exception("Exception parsing clustal file ", e)); - } - - if (flag) { - noSeqs = headers.size(); - - // Add sequences to the hash - seqs = new Sequence[headers.size()]; - for (i = 0; i < headers.size(); i++) { - if (seqhash.get(headers.elementAt(i)) != null) { - // TODO: develop automatic dictionary typing for sequences - Sequence newSeq = Seq.newSequence(headers.elementAt(i).toString(), - seqhash.get(headers.elementAt(i).toString()).toString(), - SymbolDictionary.STANDARD_AA,0,0); - - seqs[i] = newSeq; - - } else { - throw (new Exception("Bizarreness! Can't find sequence for " - + headers.elementAt(i))); - } - } - } - return seqs; - } - - public static void WriteClustalWAlignment(java.io.OutputStream os, - Alignment seqAl) throws IOException { - System.err.println("NOT FULLY IMPLEMENTED!"); // TODO: Finish adapting this method - AlignmentSequence[] s = seqAl.getAlignmentSequence(); - - java.io.BufferedWriter out = new BufferedWriter( - new java.io.OutputStreamWriter(os)); - - out.write("CLUSTAL\n\n"); - - int max = 0; - int maxid = 0; - - int i = 0; - - while (i < s.length && s[i] != null) { - String tmp = s[i].getId(); - - if (s[i].getSequence().length() > max) { - max = s[i].getSequence().length(); - } - if (tmp.length() > maxid) { - maxid = tmp.length(); - } - i++; - } - - if (maxid < 15) { - maxid = 15; - } - maxid++; - int len = 60; - int nochunks = max / len + 1; - - for (i = 0; i < nochunks; i++) { - int j = 0; - while (j < s.length && s[j] != null) { - out.write(new Format("%-" + maxid + "s").form(s[j].getId() + " ")); - int start = i * len; - int end = start + len; - - if (end < s[j].getSequence().length() && start < s[j].getSequence().length()) { - out.write(s[j].getSequence().substring(start, end) + "\n"); - } else { - if (start < s[j].getSequence().length()) { - out.write(s[j].getSequence().substring(start) + "\n"); - } - } - j++; - } - out.write("\n"); - - } - } - /** - * manufacture an alignment/dataset from an array of sequences - * @param origin - * @param seqs - * @return - * @throws Exception - */ - public static Alignment make_Alignment(Entry origin, - Sequence[] seqs) throws Exception { - System.err.println("NOT FULLY IMPLEMENTED!"); // TODO: Finish adapting this method - Alignment al = new Alignment(); - al.setProvenance(ProvenanceStuff.newProvenance(origin)); - - Pattern nonGap = Pattern.compile("[A-Z*0-9]", Pattern.CASE_INSENSITIVE); - boolean gapsset = false; - char gapchar = '-'; - int seqLength = 0; - - for (int i = 0, nseq = seqs.length; i < nseq; i++) { - String seq = seqs[i].getSequence(); - String gaps = nonGap.matcher(seq).replaceAll(""); - if (seqLength == 0) { - seqLength = seq.length(); - } else if (seqLength != seq.length()) - throw (new Exception(i + "th Sequence (>" + seqs[i].getId() - + ") is not aligned.\n"));// TODO: move this to assertions part of - // Alignment - - // common check for any sequence... - if (gaps != null && gaps.length() > 0) { - if (!gapsset) - gapchar = gaps.charAt(0); - for (int c = 0, gc = gaps.length(); c < gc; c++) { - if (gapchar != gaps.charAt(c)) { - throw (new IOException("Inconsistent gap characters in sequence " - + i + ": '" + seq + "'")); - } - } - } - AlignmentSequence sq = new AlignmentSequence(); - // TODO: use as basis of default AlignSequence(Sequence) constructor. - sq.setSequence(seq); - sq.setName(seqs[i].getId()); - sq.setRefid(seqs[i].getVorbaId()); - sq.setStart(seqs[i].getStart()); - sq.setEnd(seqs[i].getEnd()); - al.addAlignmentSequence(sq); - } - al.setGapChar(String.valueOf(gapchar)); - return al; - } - - public static Alignment read_FastaAlignment(InputStream os, Entry entry) - throws Exception { - Sequence[] seqs; - System.err.println("NOT FULLY IMPLEMENTED!"); // TODO: Finish adapting this method - try { - seqs = SeqSet.read_SeqFasta(os); - if (seqs == null) - throw (new Exception("Empty alignment stream!\n")); - } catch (Exception e) { - throw new Exception("Invalid fasta alignment\n", e); - } - - return make_Alignment(entry, seqs); - } - - public static Alignment read_ClustalAlignment(InputStream os, Entry entry) - throws Exception { - Sequence[] seqs; - try { - seqs = SeqAln.ReadClustalFile(os); - if (seqs == null) - throw (new Exception("Empty alignment stream!\n")); - } catch (Exception e) { - throw new Exception("Invalid fasta alignment\n", e); - } - System.err.println("NOT FULLY IMPLEMENTED!"); // TODO: Finish adapting this method - return make_Alignment(entry, seqs); - } -} +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ +package uk.ac.vamsas.objects.utils; + +import java.io.BufferedOutputStream; +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.Hashtable; +import java.util.StringTokenizer; +import java.util.Vector; +import java.util.regex.Pattern; + +import uk.ac.vamsas.objects.core.*; + +/** + * @author jimp + * + * TODO To change the template for this generated type comment go to + * Window - Preferences - Java - Code Style - Code Templates + */ +public class SeqAln extends uk.ac.vamsas.objects.core.Alignment { + + public static Sequence[] ReadClustalFile(InputStream os) throws Exception { + System.err.println("NOT FULLY IMPLEMENTED!"); // TODO: Finish adapting this + // method + Pattern nonGap = Pattern.compile("[A-Z*0-9]", Pattern.CASE_INSENSITIVE); + String gapchars = ""; + char gapchar = '-'; + + int i = 0; + boolean flag = false; + + Vector headers = new Vector(); + Hashtable seqhash = new Hashtable(); + Sequence[] seqs = null; + int noSeqs = 0; + String line; + + try { + BufferedReader ins = new BufferedReader(new InputStreamReader(os)); + while ((line = ins.readLine()) != null) { + if (line.indexOf(" ") != 0) { + java.util.StringTokenizer str = new StringTokenizer(line, " "); + String id = ""; + + if (str.hasMoreTokens()) { + id = str.nextToken(); + if (id.equals("CLUSTAL")) { + flag = true; + } else { + if (flag) { + StringBuffer tempseq; + if (seqhash.containsKey(id)) { + tempseq = (StringBuffer) seqhash.get(id); + } else { + tempseq = new StringBuffer(); + seqhash.put(id, tempseq); + } + + if (!(headers.contains(id))) { + headers.addElement(id); + } + + tempseq.append(str.nextToken()); + } + } + } + } + } + + } catch (IOException e) { + throw (new Exception("Exception parsing clustal file ", e)); + } + + if (flag) { + noSeqs = headers.size(); + + // Add sequences to the hash + seqs = new Sequence[headers.size()]; + for (i = 0; i < headers.size(); i++) { + if (seqhash.get(headers.elementAt(i)) != null) { + // TODO: develop automatic dictionary typing for sequences + Sequence newSeq = Seq.newSequence(headers.elementAt(i).toString(), + seqhash.get(headers.elementAt(i).toString()).toString(), + SymbolDictionary.STANDARD_AA, 0, 0); + + seqs[i] = newSeq; + + } else { + throw (new Exception("Bizarreness! Can't find sequence for " + + headers.elementAt(i))); + } + } + } + return seqs; + } + + public static void WriteClustalWAlignment(java.io.OutputStream os, + Alignment seqAl) throws IOException { + System.err.println("NOT FULLY IMPLEMENTED!"); // TODO: Finish adapting this + // method + AlignmentSequence[] s = seqAl.getAlignmentSequence(); + + java.io.BufferedWriter out = new BufferedWriter( + new java.io.OutputStreamWriter(os)); + + out.write("CLUSTAL\n\n"); + + int max = 0; + int maxid = 0; + + int i = 0; + + while (i < s.length && s[i] != null) { + String tmp = s[i].getId(); + + if (s[i].getSequence().length() > max) { + max = s[i].getSequence().length(); + } + if (tmp.length() > maxid) { + maxid = tmp.length(); + } + i++; + } + + if (maxid < 15) { + maxid = 15; + } + maxid++; + int len = 60; + int nochunks = max / len + 1; + + for (i = 0; i < nochunks; i++) { + int j = 0; + while (j < s.length && s[j] != null) { + out.write(new Format("%-" + maxid + "s").form(s[j].getId() + " ")); + int start = i * len; + int end = start + len; + + if (end < s[j].getSequence().length() + && start < s[j].getSequence().length()) { + out.write(s[j].getSequence().substring(start, end) + "\n"); + } else { + if (start < s[j].getSequence().length()) { + out.write(s[j].getSequence().substring(start) + "\n"); + } + } + j++; + } + out.write("\n"); + + } + } + + /** + * manufacture an alignment/dataset from an array of sequences + * + * @param origin + * @param seqs + * @return + * @throws Exception + */ + public static Alignment make_Alignment(Entry origin, Sequence[] seqs) + throws Exception { + System.err.println("NOT FULLY IMPLEMENTED!"); // TODO: Finish adapting this + // method + Alignment al = new Alignment(); + al.setProvenance(ProvenanceStuff.newProvenance(origin)); + + Pattern nonGap = Pattern.compile("[A-Z*0-9]", Pattern.CASE_INSENSITIVE); + boolean gapsset = false; + char gapchar = '-'; + int seqLength = 0; + + for (int i = 0, nseq = seqs.length; i < nseq; i++) { + String seq = seqs[i].getSequence(); + String gaps = nonGap.matcher(seq).replaceAll(""); + if (seqLength == 0) { + seqLength = seq.length(); + } else if (seqLength != seq.length()) + throw (new Exception(i + "th Sequence (>" + seqs[i].getId() + + ") is not aligned.\n"));// TODO: move this to assertions part of + // Alignment + + // common check for any sequence... + if (gaps != null && gaps.length() > 0) { + if (!gapsset) + gapchar = gaps.charAt(0); + for (int c = 0, gc = gaps.length(); c < gc; c++) { + if (gapchar != gaps.charAt(c)) { + throw (new IOException("Inconsistent gap characters in sequence " + + i + ": '" + seq + "'")); + } + } + } + AlignmentSequence sq = new AlignmentSequence(); + // TODO: use as basis of default AlignSequence(Sequence) constructor. + sq.setSequence(seq); + sq.setName(seqs[i].getId()); + sq.setRefid(seqs[i].getVorbaId()); + sq.setStart(seqs[i].getStart()); + sq.setEnd(seqs[i].getEnd()); + al.addAlignmentSequence(sq); + } + al.setGapChar(String.valueOf(gapchar)); + return al; + } + + public static Alignment read_FastaAlignment(InputStream os, Entry entry) + throws Exception { + Sequence[] seqs; + System.err.println("NOT FULLY IMPLEMENTED!"); // TODO: Finish adapting this + // method + try { + seqs = SeqSet.read_SeqFasta(os); + if (seqs == null) + throw (new Exception("Empty alignment stream!\n")); + } catch (Exception e) { + throw new Exception("Invalid fasta alignment\n", e); + } + + return make_Alignment(entry, seqs); + } + + public static Alignment read_ClustalAlignment(InputStream os, Entry entry) + throws Exception { + Sequence[] seqs; + try { + seqs = SeqAln.ReadClustalFile(os); + if (seqs == null) + throw (new Exception("Empty alignment stream!\n")); + } catch (Exception e) { + throw new Exception("Invalid fasta alignment\n", e); + } + System.err.println("NOT FULLY IMPLEMENTED!"); // TODO: Finish adapting this + // method + return make_Alignment(entry, seqs); + } +} diff --git a/src/uk/ac/vamsas/objects/utils/SeqSet.java b/src/uk/ac/vamsas/objects/utils/SeqSet.java index e75bd54..b6f48ad 100644 --- a/src/uk/ac/vamsas/objects/utils/SeqSet.java +++ b/src/uk/ac/vamsas/objects/utils/SeqSet.java @@ -1,138 +1,166 @@ -/* - * Created on 17-May-2005 - * Slurped into VamsasClient object set on 12th Jan 2006 - * - * TODO To change the template for this generated file go to - * Window - Preferences - Java - Code Style - Code Templates - */ -package uk.ac.vamsas.objects.utils; - -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.util.Hashtable; -import java.util.Vector; -import java.util.regex.Pattern; - -import uk.ac.vamsas.objects.core.*; - -/** - * @author jimp - * - * TODO To change the template for this generated type comment go to - * Window - Preferences - Java - Code Style - Code Templates - */ -public class SeqSet { - - public static void write_Fasta(OutputStream os, SequenceType[] seqs) throws IOException { - write_Fasta(os, seqs, 80); - } - - public static void write_Fasta(OutputStream os, SequenceType[] seqs, boolean width80) throws IOException { - write_Fasta(os, seqs, (width80) ? 80 : 0); - } - - public static void write_Fasta(OutputStream os, SequenceType[] seqs, int width) throws IOException { - int i, nseq = seqs.length; - BufferedWriter fasta_out = new BufferedWriter(new OutputStreamWriter(os)); - System.err.println("NOT FULLY IMPLEMENTED!"); // TODO: Finish adapting this method - for (i=0; i"+seqs[i].getName()+"\n"); - if (width<=0) { - fasta_out.write(seqs[i].getSequence()+"\n"); - } else { - // TODO: adapt to SymbolDictionary labelwidths - String tempseq = seqs[i].getSequence(); - int j=0, k=tempseq.length(); - while (j=width) { - fasta_out.write(tempseq, j, width); - } else { - fasta_out.write(tempseq, j, d); - } - fasta_out.write("\n"); - j+=width; - } - } - } - fasta_out.flush(); - } - /** - * TODO: introduce a dictionary parameter for qualified sequence symbols - * Reads a sequence set from a stream - will only read prescribed amino acid - * symbols. - * @param os - * @return - * @throws IOException - */ - public static Sequence[] read_SeqFasta(InputStream os) throws IOException { - Vector seqs = new Vector(); - int nseq = 0; - BufferedReader infasta = new BufferedReader(new InputStreamReader(os)); - System.err.println("NOT FULLY IMPLEMENTED!"); // TODO: Finish adapting this method - // TODO: decide on return type - SequenceType is a partly complete vamsas Vobject - either for a dataset or alignment sequence - // so could go in either! - String line; - Sequence seq = null; - Pattern aaMatch = Pattern.compile("[ARNDCQEGHILKMFPSTUWYV]", Pattern.CASE_INSENSITIVE); - String sname = "", seqstr=null; - do { - line = infasta.readLine(); - if (line==null || line.startsWith(">")) { - if (seqstr!=null) - seqs.add((Object) Seq.newSequence(sname.substring(1), seqstr, SymbolDictionary.STANDARD_AA, 0,0)); - sname = line; // remove > - seqstr=""; - } else { - String subseq = Pattern.compile("//s+").matcher(line).replaceAll(""); - seqstr += subseq; - } - } while (line!=null); - nseq = seqs.size(); - if (nseq>0) { - // TODO:POSS: should really return a sequence if there's only one in the file. - Sequence[] seqset = new Sequence[nseq]; - for (int i=0; i. + */ +package uk.ac.vamsas.objects.utils; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.util.Hashtable; +import java.util.Vector; +import java.util.regex.Pattern; + +import uk.ac.vamsas.objects.core.*; + +/** + * @author jimp + * + * TODO To change the template for this generated type comment go to + * Window - Preferences - Java - Code Style - Code Templates + */ +public class SeqSet { + + public static void write_Fasta(OutputStream os, SequenceType[] seqs) + throws IOException { + write_Fasta(os, seqs, 80); + } + + public static void write_Fasta(OutputStream os, SequenceType[] seqs, + boolean width80) throws IOException { + write_Fasta(os, seqs, (width80) ? 80 : 0); + } + + public static void write_Fasta(OutputStream os, SequenceType[] seqs, int width) + throws IOException { + int i, nseq = seqs.length; + BufferedWriter fasta_out = new BufferedWriter(new OutputStreamWriter(os)); + System.err.println("NOT FULLY IMPLEMENTED!"); // TODO: Finish adapting this + // method + for (i = 0; i < nseq; i++) { + fasta_out.write(">" + seqs[i].getName() + "\n"); + if (width <= 0) { + fasta_out.write(seqs[i].getSequence() + "\n"); + } else { + // TODO: adapt to SymbolDictionary labelwidths + String tempseq = seqs[i].getSequence(); + int j = 0, k = tempseq.length(); + while (j < k) { + int d = k - j; + if (d >= width) { + fasta_out.write(tempseq, j, width); + } else { + fasta_out.write(tempseq, j, d); + } + fasta_out.write("\n"); + j += width; + } + } + } + fasta_out.flush(); + } + + /** + * TODO: introduce a dictionary parameter for qualified sequence symbols Reads + * a sequence set from a stream - will only read prescribed amino acid + * symbols. + * + * @param os + * @return + * @throws IOException + */ + public static Sequence[] read_SeqFasta(InputStream os) throws IOException { + Vector seqs = new Vector(); + int nseq = 0; + BufferedReader infasta = new BufferedReader(new InputStreamReader(os)); + System.err.println("NOT FULLY IMPLEMENTED!"); // TODO: Finish adapting this + // method + // TODO: decide on return type - SequenceType is a partly complete vamsas + // Vobject - either for a dataset or alignment sequence + // so could go in either! + String line; + Sequence seq = null; + Pattern aaMatch = Pattern.compile("[ARNDCQEGHILKMFPSTUWYV]", + Pattern.CASE_INSENSITIVE); + String sname = "", seqstr = null; + do { + line = infasta.readLine(); + if (line == null || line.startsWith(">")) { + if (seqstr != null) + seqs.add((Object) Seq.newSequence(sname.substring(1), seqstr, + SymbolDictionary.STANDARD_AA, 0, 0)); + sname = line; // remove > + seqstr = ""; + } else { + String subseq = Pattern.compile("//s+").matcher(line).replaceAll(""); + seqstr += subseq; + } + } while (line != null); + nseq = seqs.size(); + if (nseq > 0) { + // TODO:POSS: should really return a sequence if there's only one in the + // file. + Sequence[] seqset = new Sequence[nseq]; + for (int i = 0; i < nseq; i++) { + seqset[i] = (Sequence) seqs.elementAt(i); + } + return seqset; + } + + return null; + } + + public static Hashtable uniquify(SequenceType[] sequences) { + System.err.println("NOT FULLY IMPLEMENTED!"); // TODO: Finish adapting this + // method + // TODO: do we need this with vamsas sequences ? + // Generate a safely named sequence set and a hash to recover the sequence + // names + Hashtable map = new Hashtable(); + for (int i = 0; i < sequences.length; i++) { + String safename = new String("Sequence" + i); + map.put(safename, sequences[i].getName()); + sequences[i].setName(safename); + } + return map; + } + + public static boolean deuniquify(Hashtable map, SequenceType[] sequences) { + System.err.println("NOT FULLY IMPLEMENTED!"); // TODO: Finish adapting this + // method + // TODO: do we need this with vamsas sequences ? + // recover unsafe sequence names for a sequence set + boolean allfound = true; + for (int i = 0; i < sequences.length; i++) { + if (map.containsKey(sequences[i].getName())) { + String unsafename = (String) map.get(sequences[i].getName()); + sequences[i].setName(unsafename); + } else { + allfound = false; + } + } + return allfound; + } + +} diff --git a/src/uk/ac/vamsas/objects/utils/SymbolDictionary.java b/src/uk/ac/vamsas/objects/utils/SymbolDictionary.java index b8ac66f..6cd81a8 100644 --- a/src/uk/ac/vamsas/objects/utils/SymbolDictionary.java +++ b/src/uk/ac/vamsas/objects/utils/SymbolDictionary.java @@ -1,19 +1,50 @@ -package uk.ac.vamsas.objects.utils; - -public class SymbolDictionary { - /** - * defines standard names and properties for vamsas sequence dictionaries - */ - static final public String STANDARD_AA="info:iubmb.org/aminoacids"; // strict 1 letter code - static final public String STANDARD_NA="info:iubmb.org/nucleosides";// strict 1 letter code (do not allow arbitrary rare nucleosides) - /** - * TODO: Vamsas Dictionary properties interface - * an interface for dictionary provides : - * validation for a string - * symbolwidth (or symbol next/previous) - * mappings to certain other dictionaries (one2three, etc) - * gap-character test - * - */ - -} +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ +package uk.ac.vamsas.objects.utils; + +public class SymbolDictionary { + /** + * defines standard names and properties for vamsas sequence dictionaries + */ + static final public String STANDARD_AA = "info:iubmb.org/aminoacids"; // strict + // 1 + // letter + // code + + static final public String STANDARD_NA = "info:iubmb.org/nucleosides";// strict + // 1 + // letter + // code + // (do + // not + // allow + // arbitrary + // rare + // nucleosides) + /** + * TODO: Vamsas Dictionary properties interface an interface for dictionary + * provides : validation for a string symbolwidth (or symbol next/previous) + * mappings to certain other dictionaries (one2three, etc) gap-character test + * + */ + +} diff --git a/src/uk/ac/vamsas/objects/utils/Trees.java b/src/uk/ac/vamsas/objects/utils/Trees.java index 718d8fa..dbea136 100644 --- a/src/uk/ac/vamsas/objects/utils/Trees.java +++ b/src/uk/ac/vamsas/objects/utils/Trees.java @@ -1,3 +1,24 @@ +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ package uk.ac.vamsas.objects.utils; import java.io.IOException; @@ -8,12 +29,13 @@ import uk.ac.vamsas.objects.utils.trees.NewickFile; public class Trees { /** - * TODO: implement - * helper functions based on NewickFile tree parser + * TODO: implement helper functions based on NewickFile tree parser * - * 1. create a newickfile object from a newick string. - * 2. let user map a vamsas object to each node by setting that node's ((SequenceNode)node).setElement(VorbaId) - * 3. generate Tree object with newickString as a newick string, and added treenodes to record mapping to vorba ids + * 1. create a newickfile object from a newick string. 2. let user map a + * vamsas object to each node by setting that node's + * ((SequenceNode)node).setElement(VorbaId) 3. generate Tree object with + * newickString as a newick string, and added treenodes to record mapping to + * vorba ids */ - + } diff --git a/src/uk/ac/vamsas/objects/utils/document/VersionEntries.java b/src/uk/ac/vamsas/objects/utils/document/VersionEntries.java index 7972347..b8bd785 100644 --- a/src/uk/ac/vamsas/objects/utils/document/VersionEntries.java +++ b/src/uk/ac/vamsas/objects/utils/document/VersionEntries.java @@ -1,49 +1,73 @@ -/** - * - */ -package uk.ac.vamsas.objects.utils.document; - -import java.util.Hashtable; - -/** - * enumerates versions for the VamsasDocument.Version string - * provides version comparison methods - * TODO: LATER: associate schema versions with these strings - */ -public class VersionEntries { - public static final String ALPHA_VERSION="alpha"; - public static final String BETA_VERSION="beta"; - protected static Hashtable versions; - static { - versions = new Hashtable(); - // integers represent version hierarchy - 0 precedes 1 - versions.put(ALPHA_VERSION, new Integer(0)); - versions.put(BETA_VERSION, new Integer(1)); - } - // TODO: LATER: decide on best pattern for enumeration classes (ie - need an ordered list of versions, and validator, plus explicit enum-strings) - public static boolean isVersion(String vstring) { - return versions.containsKey(vstring); - } - /** - * returns 0 if levels are equivalent, - * 1 if higher is valid and higher, - * 2 if lower is valid and higher - * -1 if both levels are invalid - * @param higher - * @param lower - * @return - */ - public static int compare(String higher, String lower) { - int v_1 = versions.containsKey(higher) ? ((Integer) versions.get(higher)).intValue() : -1; - int v_2 = versions.containsKey(lower) ? ((Integer) versions.get(lower)).intValue() : -1; - int comp = v_1. + */ +package uk.ac.vamsas.objects.utils.document; + +import java.util.Hashtable; + +/** + * enumerates versions for the VamsasDocument.Version string provides version + * comparison methods TODO: LATER: associate schema versions with these strings + */ +public class VersionEntries { + public static final String ALPHA_VERSION = "alpha"; + + public static final String BETA_VERSION = "beta"; + + protected static Hashtable versions; + static { + versions = new Hashtable(); + // integers represent version hierarchy - 0 precedes 1 + versions.put(ALPHA_VERSION, new Integer(0)); + versions.put(BETA_VERSION, new Integer(1)); + } + + // TODO: LATER: decide on best pattern for enumeration classes (ie - need an + // ordered list of versions, and validator, plus explicit enum-strings) + public static boolean isVersion(String vstring) { + return versions.containsKey(vstring); + } + + /** + * returns 0 if levels are equivalent, 1 if higher is valid and higher, 2 if + * lower is valid and higher -1 if both levels are invalid + * + * @param higher + * @param lower + * @return + */ + public static int compare(String higher, String lower) { + int v_1 = versions.containsKey(higher) ? ((Integer) versions.get(higher)) + .intValue() : -1; + int v_2 = versions.containsKey(lower) ? ((Integer) versions.get(lower)) + .intValue() : -1; + int comp = v_1 < v_2 ? 2 : v_1 == v_2 ? 0 : 1; + return (comp == 0) ? (v_1 != -1 ? 0 : -1) : comp; + } + + /** + * @return the latest version that this vamsas library supports + */ + public static String latestVersion() { + return BETA_VERSION; + } + +} diff --git a/src/uk/ac/vamsas/objects/utils/trees/BinaryNode.java b/src/uk/ac/vamsas/objects/utils/trees/BinaryNode.java index bc41783..5cf8664 100644 --- a/src/uk/ac/vamsas/objects/utils/trees/BinaryNode.java +++ b/src/uk/ac/vamsas/objects/utils/trees/BinaryNode.java @@ -1,5 +1,23 @@ -/** +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ package uk.ac.vamsas.objects.utils.trees; @@ -18,7 +36,7 @@ public class BinaryNode { BinaryNode parent; /** bootstrap is non-negative integer */ - public int bootstrap=-1; + public int bootstrap = -1; /** * Creates a new BinaryNode object. @@ -140,10 +158,10 @@ public class BinaryNode { } /** - * attaches FIRST and SECOND node arguments as the LEFT and RIGHT children - * of this node (removing any old references) a null parameter DOES NOT mean - * that the pointer to the corresponding child node is set to NULL - you - * should use setChild(null), or detach() for this. + * attaches FIRST and SECOND node arguments as the LEFT and RIGHT children of + * this node (removing any old references) a null parameter DOES NOT mean that + * the pointer to the corresponding child node is set to NULL - you should use + * setChild(null), or detach() for this. * */ public void SetChildren(BinaryNode leftchild, BinaryNode rightchild) { @@ -253,26 +271,20 @@ public class BinaryNode { } /** * - * @return unquoted string of form VorbaId|v|node name string - public String getNewickNodeName() { - if (element!=null || name!=null) - { - return ((element!=null) ? element.getVorbaId().getId()+"|v|" : "") - + ((name == null) ? "" : name); - } - return ""; - } - - * note we probably don't need this now - - * public boolean parseNodeNameString(uk.ac.vamsas.client.ClientDocument binder) - { - - if (element==null && name!=null && name.indexOf("|v|")>-1) - { - element = binder.getObject(null).getVorbaId(); // TODO: fix THIS ! name.substring(0, name.indexOf("|v"))); - - } - return false; - }*/ -} \ No newline at end of file + * @return unquoted string of form VorbaId|v|node name string public String + * getNewickNodeName() { if (element!=null || name!=null) { return + * ((element!=null) ? element.getVorbaId().getId()+"|v|" : "") + + * ((name == null) ? "" : name); } return ""; } + * + * note we probably don't need this now + * + * public boolean + * parseNodeNameString(uk.ac.vamsas.client.ClientDocument binder) { + * + * if (element==null && name!=null && name.indexOf("|v|")>-1) { + * element = binder.getObject(null).getVorbaId(); // TODO: fix THIS ! + * name.substring(0, name.indexOf("|v"))); + * + * } return false; } + */ +} diff --git a/src/uk/ac/vamsas/objects/utils/trees/NewickFile.java b/src/uk/ac/vamsas/objects/utils/trees/NewickFile.java index d6f5f57..d38c99a 100644 --- a/src/uk/ac/vamsas/objects/utils/trees/NewickFile.java +++ b/src/uk/ac/vamsas/objects/utils/trees/NewickFile.java @@ -1,24 +1,24 @@ /* - * originally from + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. * - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - // NewickFile.java // Tree I/O // http://evolution.genetics.washington.edu/phylip/newick_doc.html @@ -222,9 +222,9 @@ public class NewickFile { } /** - * call this to convert the newick string into a binary node linked tree - * Note: this is automatically called by the constructors, so you normally - * wouldn't need to use this. + * call this to convert the newick string into a binary node linked tree Note: + * this is automatically called by the constructors, so you normally wouldn't + * need to use this. * * @throws IOException * if the newick string cannot be parsed. @@ -271,9 +271,9 @@ public class NewickFile { Matcher mjsyms = majorsyms.matcher(nf); char schar; - int nextcp=0; + int nextcp = 0; int ncp = cp; - while (mjsyms.find(cp) && (Error == null)) { + while (mjsyms.find(cp) && (Error == null)) { int fcp = mjsyms.start(); switch (schar = nf.charAt(fcp)) { @@ -339,29 +339,32 @@ public class NewickFile { "Wayward semicolon (depth=" + d + ")", 7, fcp, nf); } - // Skip Comment or structured/extended NH format info + // Skip Comment or structured/extended NH format info if (schar == '[') { - if ((nextcp=nf.indexOf(']', fcp)) > -1) { + if ((nextcp = nf.indexOf(']', fcp)) > -1) { // verified that comment is properly terminated. // now skip the comment field nextcp++; - break; // go and search for the next node separator, leaving ncp at beginning of node info + break; // go and search for the next node separator, leaving ncp at + // beginning of node info } else { Error = ErrorStringrange(Error, "Unterminated comment", 3, fcp, nf); nextcp = 0; break; } } - - // Parse simpler field strings from substring between ncp and node separator + + // Parse simpler field strings from substring between ncp and node + // separator String fstring = nf.substring(ncp, fcp); // extract any comments from the nodeinfo. - while (fstring.indexOf(']')>-1) - { - int cstart=fstring.indexOf('['); - int cend=fstring.indexOf(']'); - String comment = fstring.substring(cstart+1,cend); // TODO: put this somewhere ? - fstring = fstring.substring(0, cstart)+fstring.substring(cend+1); + while (fstring.indexOf(']') > -1) { + int cstart = fstring.indexOf('['); + int cend = fstring.indexOf(']'); + String comment = fstring.substring(cstart + 1, cend); // TODO: put + // this + // somewhere ? + fstring = fstring.substring(0, cstart) + fstring.substring(cend + 1); } Matcher uqnodename = Pattern.compile("^([^' :;\\](),]+).*").matcher( fstring); @@ -384,14 +387,12 @@ public class NewickFile { Matcher nbootstrap = Pattern.compile("\\s*([+0-9]+)\\s*:.*").matcher( fstring); - if (nbootstrap.matches()) - { - if (nodename!=null && nbootstrap.group(1).equals(nodename)) - { - nodename=null; // empty nodename - only bootstrap value + if (nbootstrap.matches()) { + if (nodename != null && nbootstrap.group(1).equals(nodename)) { + nodename = null; // empty nodename - only bootstrap value } - if ((nodename==null || nodename.length()==0) || nbootstrap.start(1)>=uqnodename.end(1)) - { + if ((nodename == null || nodename.length() == 0) + || nbootstrap.start(1) >= uqnodename.end(1)) { try { bootstrap = (new Integer(nbootstrap.group(1))).intValue(); HasBootstrap = true; @@ -401,7 +402,7 @@ public class NewickFile { } } } - + Matcher ndist = Pattern.compile(".*:([-0-9Ee.+]+)").matcher(fstring); boolean nodehasdistance = false; @@ -515,7 +516,8 @@ public class NewickFile { public uk.ac.vamsas.objects.core.Treenode[] matchTreeNodeNames( String[] names, Vobject[] boundObjects) { // todo! - // also - need to reconstruct a names object id mapping (or BInaryNode) mapping for the parsed tree file + // also - need to reconstruct a names object id mapping (or BInaryNode) + // mapping for the parsed tree file return null; } @@ -641,7 +643,7 @@ public class NewickFile { private String nodeName(String name) { if (NodeSafeName[0].matcher(name).find()) { return QuoteChar + NodeSafeName[1].matcher(name).replaceAll("''") - + QuoteChar; // quite + + QuoteChar; // quite } else { return NodeSafeName[2].matcher(name).replaceAll("_"); // whitespace } @@ -656,10 +658,12 @@ public class NewickFile { * @return DOCUMENT ME! */ private String printNodeField(SequenceNode c) { - return //c.getNewickNodeName() + return // c.getNewickNodeName() ((c.getName() == null) ? "" : nodeName(c.getName())) - + ((HasBootstrap) ? ((c.getBootstrap() > -1) ? (((c.getName()==null) ? " " : "") + c.getBootstrap()) - : "") : "") + ((HasDistances) ? (":" + c.dist) : ""); + + ((HasBootstrap) ? ((c.getBootstrap() > -1) ? (((c.getName() == null) ? " " + : "") + c.getBootstrap()) + : "") + : "") + ((HasDistances) ? (":" + c.dist) : ""); } /** @@ -673,9 +677,10 @@ public class NewickFile { private String printRootField(SequenceNode root) { return (printRootInfo) ? (((root.getName() == null) ? "" : nodeName(root .getName())) - + ((HasBootstrap) ? ((root.getBootstrap() > -1) ? ((root.getName()!=null ? " " : "") + root - .getBootstrap()) : "") : "") + ((RootHasDistance) ? (":" + root.dist) - : "")) + + ((HasBootstrap) ? ((root.getBootstrap() > -1) ? ((root.getName() != null ? " " + : "") + root.getBootstrap()) + : "") + : "") + ((RootHasDistance) ? (":" + root.dist) : "")) : ""; } @@ -790,10 +795,12 @@ public class NewickFile { /** * Search for leaf nodes. - * - * @param node root node to search from - * @param leaves Vector of leaves to add leaf node objects too. - * + * + * @param node + * root node to search from + * @param leaves + * Vector of leaves to add leaf node objects too. + * * @return Vector of leaf nodes on binary tree */ public Vector findLeaves(SequenceNode node, Vector leaves) { @@ -801,16 +808,17 @@ public class NewickFile { return leaves; } - if ((node.left() == null) && (node.right() == null)) // Interior node detection + if ((node.left() == null) && (node.right() == null)) // Interior node + // detection { leaves.addElement(node); return leaves; } else { - /* TODO: Identify internal nodes... if (node.isSequenceLabel()) - { - leaves.addElement(node); - }*/ + /* + * TODO: Identify internal nodes... if (node.isSequenceLabel()) { + * leaves.addElement(node); } + */ findLeaves((SequenceNode) node.left(), leaves); findLeaves((SequenceNode) node.right(), leaves); } @@ -819,7 +827,9 @@ public class NewickFile { } /** - * make tree node vector from a newick tree structure with associated vamsas objects + * make tree node vector from a newick tree structure with associated vamsas + * objects + * * @param ntree * @return Treenode definitions for nodes with associated objects */ @@ -828,8 +838,10 @@ public class NewickFile { } /** - * make treenode vector for a parsed tree with/out leaf node associations - * @param ignoreplaceholders if true means only associated nodes are returned + * make treenode vector for a parsed tree with/out leaf node associations + * + * @param ignoreplaceholders + * if true means only associated nodes are returned * @return treenode vector for associated or all leaves */ public Treenode[] makeTreeNodes(boolean ignoreplaceholders) { @@ -915,11 +927,14 @@ public class NewickFile { } /** - * - * re-decorate the newick node representation with the VorbaId of an object mapped by its corresponding TreeNode. - * Note: this only takes the first object in the first set of references. + * + * re-decorate the newick node representation with the VorbaId of an object + * mapped by its corresponding TreeNode. Note: this only takes the first + * object in the first set of references. + * * @param tn - * @return vector of mappings { treenode, SequenceNode, Vobject for VorbaId on sequence node } + * @return vector of mappings { treenode, SequenceNode, Vobject for VorbaId on + * sequence node } */ public Vector attachTreeMap(Treenode[] tn) { if (root != null || tn == null) diff --git a/src/uk/ac/vamsas/objects/utils/trees/SequenceNode.java b/src/uk/ac/vamsas/objects/utils/trees/SequenceNode.java index 9f2a05d..88cf944 100644 --- a/src/uk/ac/vamsas/objects/utils/trees/SequenceNode.java +++ b/src/uk/ac/vamsas/objects/utils/trees/SequenceNode.java @@ -1,5 +1,23 @@ -/** +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ package uk.ac.vamsas.objects.utils.trees; @@ -65,8 +83,7 @@ public class SequenceNode extends BinaryNode { /** * @param dummy - * true if node is created for the representation of polytomous - * trees + * true if node is created for the representation of polytomous trees */ public boolean isDummy() { return dummy; @@ -120,4 +137,4 @@ public class SequenceNode extends BinaryNode { return c; } -} \ No newline at end of file +} diff --git a/src/uk/ac/vamsas/test/ExampleApplication.java b/src/uk/ac/vamsas/test/ExampleApplication.java index 2fb20a3..6ebfcec 100644 --- a/src/uk/ac/vamsas/test/ExampleApplication.java +++ b/src/uk/ac/vamsas/test/ExampleApplication.java @@ -1,3 +1,24 @@ +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ package uk.ac.vamsas.test; import uk.ac.vamsas.client.*; @@ -378,16 +399,19 @@ public class ExampleApplication { } public String Usage = "ExampleApplication :/n [-arena ][-session ] [+]\n" - + " is one of :\n\tsave,new,watch\n"+ - "-arena and -session are not yet supported"; // TODO for release + + " is one of :\n\tsave,new,watch\n" + + "-arena and -session are not yet supported"; // TODO for release String sess = null; String importFile = null; String outputFile = null; - boolean newSession=false; - boolean imported=false; + + boolean newSession = false; + + boolean imported = false; + private boolean parseArgs(String args[]) { if (args.length == 0) { return false; @@ -396,14 +420,15 @@ public class ExampleApplication { boolean parsed = false; while (!parsed && cpos < args.length) { // TODO: note importDocument not yet supported. - //if (args[cpos].toLowerCase().equals("load") && cpos + 1 < args.length) { - // importFile = args[cpos + 1]; - // cpos += 2; - // continue; - //} + // if (args[cpos].toLowerCase().equals("load") && cpos + 1 < args.length) + // { + // importFile = args[cpos + 1]; + // cpos += 2; + // continue; + // } if (args[cpos].toLowerCase().equals("new") && cpos + 1 < args.length) { importFile = args[cpos + 1]; - newSession=true; + newSession = true; cpos += 2; continue; } @@ -465,9 +490,9 @@ public class ExampleApplication { // get an Iclient with session data app = new ClientHandle("uk.ac.vamsas.test.ExampleApplication", "0.1"); user = new UserHandle("arnolduser", "deathsdoor"); - if (sess!=null && importFile!=null) - { - System.err.println("Import of an existing document into an existing session is not fully supported yet."); + if (sess != null && importFile != null) { + System.err + .println("Import of an existing document into an existing session is not fully supported yet."); System.exit(3); } try { @@ -475,32 +500,32 @@ public class ExampleApplication { System.out.println("Connecting to " + sess); vorbaclient = clientfactory.getIClient(app, user, sess); } else { - if (newSession) - { - if (importFile==null) - { + if (newSession) { + if (importFile == null) { System.out.println("Connecting to a new VAMSAS Session."); vorbaclient = clientfactory.getNewSessionIClient(app, user); } else { - System.out.println("Connecting to a new VAMSAS Session to share data in existing document:"+importFile); + System.out + .println("Connecting to a new VAMSAS Session to share data in existing document:" + + importFile); File vfile = new File(importFile); - vorbaclient = clientfactory.openAsNewSessionIClient(app, user, vfile); - System.out.println("Succesfully imported document into new session."); + vorbaclient = clientfactory.openAsNewSessionIClient(app, user, + vfile); + System.out + .println("Succesfully imported document into new session."); imported = true; - importFile=null; + importFile = null; } } else { - vorbaclient = clientfactory.getIClient(app, user); + vorbaclient = clientfactory.getIClient(app, user); } } - } - catch (InvalidSessionDocumentException e) { - System.err.println("Failed to create a session to share "+importFile); + } catch (InvalidSessionDocumentException e) { + System.err.println("Failed to create a session to share " + importFile); System.err.println("Sorry it didn't work out. This is what went wrong:"); e.printStackTrace(System.err); System.exit(3); - } - catch (NoDefaultSessionException e) { + } catch (NoDefaultSessionException e) { System.err .println("There appear to be several sessions to choose from :"); String[] sessions = clientfactory.getCurrentSessions(); @@ -522,7 +547,7 @@ public class ExampleApplication { File vfile = new File(importFile); try { vorbaclient.importDocument(vfile); - imported=true; + imported = true; } catch (Exception e) { System.err.println("Failed to import file " + importFile); System.err.println("Exception received was " + e); @@ -544,11 +569,11 @@ public class ExampleApplication { // get document data try { IClientDocument cdoc = vorbaclient.getClientDocument(); - if (imported) - { - if (cdoc.getVamsasRoots()==null || cdoc.getVamsasRoots()[0].getDataSetCount()<1) - { - System.err.println("Imported an Empty vamsas document. Is this correct ?"); + if (imported) { + if (cdoc.getVamsasRoots() == null + || cdoc.getVamsasRoots()[0].getDataSetCount() < 1) { + System.err + .println("Imported an Empty vamsas document. Is this correct ?"); } } processVamsasDocument(cdoc); @@ -598,7 +623,8 @@ public class ExampleApplication { } try { Thread.sleep(200); - } catch (Exception e){} + } catch (Exception e) { + } } } else { if (System.currentTimeMillis() > shutdown) { diff --git a/src/uk/ac/vamsas/test/objects/Core.java b/src/uk/ac/vamsas/test/objects/Core.java index 58eccea..6dce168 100644 --- a/src/uk/ac/vamsas/test/objects/Core.java +++ b/src/uk/ac/vamsas/test/objects/Core.java @@ -1,82 +1,121 @@ -/** - * - */ -package uk.ac.vamsas.test.objects; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import uk.ac.vamsas.objects.core.*; -import uk.ac.vamsas.objects.utils.*; -import uk.ac.vamsas.objects.utils.document.*; -import uk.ac.vamsas.test.simpleclient.ArchiveReports; - -/** - * @author jim - * test XSD-Java binding classes in uk.ac.vamsas.objects.core - */ -public class Core { - static Log log = LogFactory.getLog(Core.class); - - /** - * - * complete any automatically completable entries in the dataset - * @param ds - */ - public static String user = "uk.ac.vamsas.test.objects.Core"; - - public static void complete(DataSet ds) { - Sequence[] q = ds.getSequence(); - for (int i=0,j=q.length; i. + */ +package uk.ac.vamsas.test.objects; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import uk.ac.vamsas.objects.core.*; +import uk.ac.vamsas.objects.utils.*; +import uk.ac.vamsas.objects.utils.document.*; +import uk.ac.vamsas.test.simpleclient.ArchiveReports; + +/** + * @author jim test XSD-Java binding classes in uk.ac.vamsas.objects.core + */ +public class Core { + static Log log = LogFactory.getLog(Core.class); + + /** + * + * complete any automatically completable entries in the dataset + * + * @param ds + */ + public static String user = "uk.ac.vamsas.test.objects.Core"; + + public static void complete(DataSet ds) { + Sequence[] q = ds.getSequence(); + for (int i = 0, j = q.length; i < j; i++) { + q[i].setStart(i + 1); + q[i].setEnd(q[i].getSequence().length() + i + 1); + } + } + + public static VAMSAS getDemoVamsas() { + VAMSAS v = new VAMSAS(); + DataSet ds = new DataSet(); + ds.addSequence(Seq.newSequence("Dummy1", "ASDFLEQ", + SymbolDictionary.STANDARD_AA, 5, 11)); + ds.addSequence(Seq.newSequence("Dummy2", "ASFLEQ", + SymbolDictionary.STANDARD_AA, 5, 10)); + ds.addSequence(Seq.newSequence("Dummy3", "ADFEQ", + SymbolDictionary.STANDARD_AA, 3, 7)); + ds.setProvenance(ProvenanceStuff.newProvenance(user, + "constructed some dummy sequences")); + complete(ds); + v.addDataSet(ds); + Alignment al = new Alignment(); + al.setProvenance(ProvenanceStuff.newProvenance(user, + "Created dummy alignment")); + // rely on newAlignmentSequence to set start/end correctly + al.addAlignmentSequence(Seq.newAlignmentSequence("Aligned1", "ASDFLEQ", ds + .getSequence(0), -1, -1)); + al.addAlignmentSequence(Seq.newAlignmentSequence("Aligned2", "AS-FLEQ", ds + .getSequence(1), -1, -1)); + al.addAlignmentSequence(Seq.newAlignmentSequence("Aligned3", "A-DF-EQ", ds + .getSequence(2), -1, -1)); + al.setGapChar("-"); + ds.addAlignment(al); + // TODO: create annotations + // TODO: create tree + return v; + } + + /** + * @param args + */ + public static void main(String[] args) { + + /** + * test constants and controlled vocab utils + */ + System.out.println("VersionEntries.compare(invalid, ALPHA) returned " + + VersionEntries.compare("invalid", VersionEntries.ALPHA_VERSION)); + System.out.println("VersionEntries.compare(ALPHA, invalid) returned " + + VersionEntries.compare(VersionEntries.ALPHA_VERSION, "invalid")); + System.out.println("VersionEntries.compare(BETA, ALPHA) returned " + + VersionEntries.compare(VersionEntries.BETA_VERSION, + VersionEntries.ALPHA_VERSION)); + System.out.println("VersionEntries.compare(ALPHA, BETA) returned " + + VersionEntries.compare(VersionEntries.ALPHA_VERSION, + VersionEntries.BETA_VERSION)); + System.out.println("VersionEntries.compare(ALPHA, ALPHA) returned " + + VersionEntries.compare(VersionEntries.ALPHA_VERSION, + VersionEntries.ALPHA_VERSION)); + System.out.println("VersionEntries.compare(invalid, invalid) returned " + + VersionEntries.compare("invalid", "invalid")); + System.out.println("VersionEntries.latestVersion()=" + + VersionEntries.latestVersion() + ", dict_aa=" + + SymbolDictionary.STANDARD_AA + ", dict_na=" + + SymbolDictionary.STANDARD_NA); + /** + * Test utils and autogenerated Vobject interfaces + */ + + VamsasDocument doc = DocumentStuff.newVamsasDocument( + new VAMSAS[] { getDemoVamsas() }, ProvenanceStuff.newProvenance( + "org.vamsas.objects.test.Core", "Created demo vamsasDocument"), + VersionEntries.latestVersion()); + ArchiveReports.reportDocument(doc, null, true, System.out); + } +} diff --git a/src/uk/ac/vamsas/test/simpleclient/ArchiveClient.java b/src/uk/ac/vamsas/test/simpleclient/ArchiveClient.java index 9044e0d..fa3c700 100644 --- a/src/uk/ac/vamsas/test/simpleclient/ArchiveClient.java +++ b/src/uk/ac/vamsas/test/simpleclient/ArchiveClient.java @@ -1,294 +1,367 @@ -/** - * - */ -package uk.ac.vamsas.test.simpleclient; - -import java.io.File; -import java.io.IOException; -import java.util.Date; -import java.util.Hashtable; -import java.util.Vector; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.exolab.castor.xml.MarshalException; -import org.exolab.castor.xml.ValidationException; - -import uk.ac.vamsas.client.AppDataOutputStream; -import uk.ac.vamsas.client.ClientHandle; -import uk.ac.vamsas.client.IVorbaIdFactory; -import uk.ac.vamsas.client.SessionHandle; -import uk.ac.vamsas.client.UserHandle; -import uk.ac.vamsas.client.Vobject; -import uk.ac.vamsas.client.VorbaId; -import uk.ac.vamsas.client.simpleclient.FileWatcher; -import uk.ac.vamsas.client.simpleclient.IdFactory; -import uk.ac.vamsas.client.simpleclient.SessionFile; -import uk.ac.vamsas.client.simpleclient.SimpleDocBinding; -import uk.ac.vamsas.client.simpleclient.SimpleDocument; -import uk.ac.vamsas.client.simpleclient.VamsasArchive; -import uk.ac.vamsas.client.simpleclient.VamsasArchiveReader; -import uk.ac.vamsas.client.simpleclient.VamsasFile; -import uk.ac.vamsas.objects.core.AppData; -import uk.ac.vamsas.objects.core.ApplicationData; -import uk.ac.vamsas.objects.core.User; -import uk.ac.vamsas.objects.core.VamsasDocument; -import uk.ac.vamsas.objects.utils.AppDataReference; -import uk.ac.vamsas.objects.utils.DocumentStuff; -import uk.ac.vamsas.objects.utils.ProvenanceStuff; -import uk.ac.vamsas.objects.utils.SeqSet; -import uk.ac.vamsas.objects.utils.document.VersionEntries; -import uk.ac.vamsas.test.objects.Core; - -/** - * @author jimp - * test the VamsasFile routines for watching, reading and updating a vamsas document jar file. - * simple document access base class. - */ -public class ArchiveClient extends IdFactory { - - private Log log = LogFactory.getLog(ArchiveClient.class); - // protected UserHandle user=null; - // protected ClientHandle me = new ClientHandle("ArchiveClient","0.01"); - VamsasFile vsess; - - /** - * @param user - * @param vsess - */ - public ArchiveClient(UserHandle user, VamsasFile vsess) { - super(new SessionHandle("vamsasfile://"+vsess.getVamsasFile()), new ClientHandle("ArchiveClient","0.01"), user); - this.vsess = vsess; - valid(); - } - private void _openVsess(File vsess) { - try { - this.vsess = new VamsasFile(vsess); - } - catch (Exception e) { - log.error("Couldn't open session for file "+vsess,e); - this.vsess = null; - } - } - public ArchiveClient(String username, String organization, File vsess) { - super(new SessionHandle("vamsasfile://"+vsess), new ClientHandle("ArchiveClient","0.01"), new UserHandle(username, organization)); - _openVsess(vsess); - valid(); - } - public ArchiveClient(String username, String organization, String clientName, String clientVersion, File vsess) { - super(new SessionHandle("vamsasfile://"+vsess), new ClientHandle(clientName, clientVersion), new UserHandle(username, organization)); - _openVsess(vsess); - valid(); - } - public void valid() { - if (vsess==null) - throw new Error("ArchiveClient instance is invalid!."); - } - /** - * set this to false if watch loop should end immediately - */ - protected boolean watchForChange=true; - public static int WATCH_SLEEP=300; - /** - * watch the document file for updates. - * @param time - length of time to watch for. - * @return read only IO interface for session document. - */ - public ClientDoc watch(long time) { - valid(); - vsess.unLock(); // doh. - FileWatcher watcher = new FileWatcher(vsess.getVamsasFile()); - // watcher.setState(); - watchForChange=true; - long endtime=System.currentTimeMillis()+time; - try { - uk.ac.vamsas.client.simpleclient.Lock doclock; - do { - doclock=watcher.getChangedState(); - if (doclock==null) - Thread.sleep(WATCH_SLEEP); - } while (watchForChange && doclock==null && (time==0 || endtime>System.currentTimeMillis())); // tuning. - if (doclock==null) - return null; - else { - return getUpdateable(vsess.getLock(doclock)); - /*VamsasArchiveReader varc = new VamsasArchiveReader(vsess.getVamsasFile()); - return _getReadonly(varc);*/ - } - } catch (Exception e) { - log.error("Whilst watching file "+vsess.getVamsasFile(), e); - } - return null; - } - - // from ClientDocument.getClientAppdata - private AppData[] getAppData(VamsasDocument doc) { - // TODO: codefest - not yet tested or merged in to SimpleClient - if (doc==null) { - log.debug("extractAppData called for null document object"); - return null; - } - AppData appsGlobal=null, usersData=null; - Vector apldataset = AppDataReference.getUserandApplicationsData( - doc, this.getUserHandle(), this.getClientHandle()); - if (apldataset!=null) { - if (apldataset.size()>0) { - AppData clientdat = (AppData) apldataset.get(0); - if (clientdat instanceof ApplicationData) { - appsGlobal = (ApplicationData) clientdat; - if (apldataset.size()>1) { - clientdat = (AppData) apldataset.get(1); - if (clientdat instanceof User) { - usersData = (User) clientdat; - } - if (apldataset.size()>2) - log.info("Ignoring additional ("+(apldataset.size()-2)+") AppDatas returned by document appdata query."); - } - } else { - log.warn("Unexpected entry in AppDataReference query: id="+clientdat.getVorbaId()+" type="+clientdat.getClass().getName()); - } - apldataset.removeAllElements(); // destroy references. - } - } - return new AppData[] { appsGlobal, usersData}; - } - - protected ClientDoc _getReadonly(VamsasArchiveReader vreader) throws IOException, ValidationException, MarshalException { - valid(); - if (vreader!=null) { - SimpleDocBinding docb = new SimpleDocBinding(); - docb.setVorba(this); - VamsasDocument d; - d = docb.getVamsasDocument(vreader); - - if (d!=null) { - ClientDoc creader = new ClientDoc(d, null, vreader, getClientHandle().getClientUrn(), getProvenanceUser(), getVorbaIdHash()); - return creader; - } - } - return null; - } - /** - * from SimpleClient - * @return user field for a provenance entry - */ - protected String getProvenanceUser() { - return new String(getUserHandle().getFullName()+" ["+getClientHandle().getClientUrn()+"]"); - } - - public ClientDoc getUpdateable() { - return getUpdateable(null); - } - public ClientDoc getUpdateable(uk.ac.vamsas.client.simpleclient.Lock lock) { - getVorbaIdHash().clear(); - valid(); - try { - // patiently wait for a lock on the document. - long tries=5000; - while (lock==null && ((lock=vsess.getLock())==null || !lock.isLocked()) && --tries>0) { -// Thread.sleep(1); - log.debug("Trying to get a document lock for the "+tries+"'th time."); - } - VamsasArchive varc = new VamsasArchive(vsess, true, false); // read archive, write as vamsasDocument, don't erase original contents. - varc.setVorba(this); - VamsasDocument d = varc.getVamsasDocument(getProvenanceUser(), "Created new document.", VersionEntries.latestVersion()); // VAMSAS: provenance user and client combined - - if (d==null) { - log.warn("Backing out from opening a VamsasArchive writable IO session"); - varc.cancelArchive(); - return null; - } - ClientDoc cdoc = new ClientDoc(d, varc, varc.getOriginalArchiveReader(), getClientHandle().getClientUrn(), getProvenanceUser(), getVorbaIdHash()); - return cdoc; - // do appHandle? - } catch (Exception e) { - log.error("Failed to get Updateable version of "+vsess.getVamsasFile(), e); - } - return null; - } - /** - * trust client to not do anything stupid to the document roots which will now be written to the archive. - * @param cdoc - * @return true if write was a success. - */ - public boolean doUpdate(ClientDoc cdoc) { - valid(); - if (cdoc==null) { - log.warn("Invalid ClientDoc passed to uk.ac.vamsas.test.simpleclient.doUpdate()"); - return false; - } - if (cdoc.iohandler==null) { - log.warn("Read only ClientDoc object passed to uk.ac.vamsas.test.simpleclient.doUpdate()"); - return false; - } - if (cdoc.iohandler.getVorba()!=this) { - log.error("Mismatch between ClientDoc instances and ArchiveClient instances!"); - return false; - } - try { - // do any appDatas first. - if (cdoc.iohandler.transferRemainingAppDatas()) - log.debug("Remaining appdatas were transfered."); - cdoc.updateDocumentRoots(); - cdoc.iohandler.putVamsasDocument(cdoc.doc); - cdoc.iohandler.closeArchive(); - this.extantids.clear();// we forget our ids after we close the document. - cdoc.iohandler=null; - cdoc = null; - vsess.unLock(); - } catch (Exception e) { - log.warn("While updating archive in "+vsess.getVamsasFile(),e); - return false; - } - return true; - } - /** - * @param args - */ - public static void usage() { - throw new Error("Usage: Username Organization VamsasFile [command,args]*"); - } - public static void main(String[] args) { - // really simple. - if (args.length<3) - usage(); - - ArchiveClient client = new ArchiveClient(args[0],args[1], new File(args[2])); - ClientDoc cdoc=null; - // sanity test. - try { - cdoc = client.getUpdateable(); - // ArchiveReports.reportDocument(cdoc.doc, cdoc.getReader(), true, System.out); - System.out.println("Report Roots :"); - ArchiveReports.rootReport(cdoc.getVamsasRoots(), true, System.out); - cdoc.addVamsasRoot(Core.getDemoVamsas()); - System.out.println("Doing update."); - client.doUpdate(cdoc); - cdoc.closeDoc(); - cdoc = null; - int u=5; - while (--u>0) { - System.out.println("Watch for more... ("+u+" left)"); - ClientDoc ucdoc = client.watch(0000); - if (ucdoc!=null) { - System.out.println("****\nUpdate detected at "+new Date()); - ArchiveReports.reportDocument(ucdoc.doc, ucdoc.getReader(), true, System.out); - ucdoc.closeDoc(); - ucdoc=null; - } else { - System.out.println("!!!! Null document update detected at "+new Date()); - } - } - } - catch (Exception e) { - client.log.error("Broken!", e); - } - System.out.println("Finished at "+new Date()); - } - public uk.ac.vamsas.client.Vobject getObject(VorbaId id) { - Hashtable idhash = this.getVorbaIdHash(); - if (idhash!=null && idhash.containsKey(id)) - return (Vobject) idhash.get(id); - return null; - } -} +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ +package uk.ac.vamsas.test.simpleclient; + +import java.io.File; +import java.io.IOException; +import java.util.Date; +import java.util.Hashtable; +import java.util.Vector; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.exolab.castor.xml.MarshalException; +import org.exolab.castor.xml.ValidationException; + +import uk.ac.vamsas.client.AppDataOutputStream; +import uk.ac.vamsas.client.ClientHandle; +import uk.ac.vamsas.client.IVorbaIdFactory; +import uk.ac.vamsas.client.SessionHandle; +import uk.ac.vamsas.client.UserHandle; +import uk.ac.vamsas.client.Vobject; +import uk.ac.vamsas.client.VorbaId; +import uk.ac.vamsas.client.simpleclient.FileWatcher; +import uk.ac.vamsas.client.simpleclient.IdFactory; +import uk.ac.vamsas.client.simpleclient.SessionFile; +import uk.ac.vamsas.client.simpleclient.SimpleDocBinding; +import uk.ac.vamsas.client.simpleclient.SimpleDocument; +import uk.ac.vamsas.client.simpleclient.VamsasArchive; +import uk.ac.vamsas.client.simpleclient.VamsasArchiveReader; +import uk.ac.vamsas.client.simpleclient.VamsasFile; +import uk.ac.vamsas.objects.core.AppData; +import uk.ac.vamsas.objects.core.ApplicationData; +import uk.ac.vamsas.objects.core.User; +import uk.ac.vamsas.objects.core.VamsasDocument; +import uk.ac.vamsas.objects.utils.AppDataReference; +import uk.ac.vamsas.objects.utils.DocumentStuff; +import uk.ac.vamsas.objects.utils.ProvenanceStuff; +import uk.ac.vamsas.objects.utils.SeqSet; +import uk.ac.vamsas.objects.utils.document.VersionEntries; +import uk.ac.vamsas.test.objects.Core; + +/** + * @author jimp test the VamsasFile routines for watching, reading and updating + * a vamsas document jar file. simple document access base class. + */ +public class ArchiveClient extends IdFactory { + + private Log log = LogFactory.getLog(ArchiveClient.class); + + // protected UserHandle user=null; + // protected ClientHandle me = new ClientHandle("ArchiveClient","0.01"); + VamsasFile vsess; + + /** + * @param user + * @param vsess + */ + public ArchiveClient(UserHandle user, VamsasFile vsess) { + super(new SessionHandle("vamsasfile://" + vsess.getVamsasFile()), + new ClientHandle("ArchiveClient", "0.01"), user); + this.vsess = vsess; + valid(); + } + + private void _openVsess(File vsess) { + try { + this.vsess = new VamsasFile(vsess); + } catch (Exception e) { + log.error("Couldn't open session for file " + vsess, e); + this.vsess = null; + } + } + + public ArchiveClient(String username, String organization, File vsess) { + super(new SessionHandle("vamsasfile://" + vsess), new ClientHandle( + "ArchiveClient", "0.01"), new UserHandle(username, organization)); + _openVsess(vsess); + valid(); + } + + public ArchiveClient(String username, String organization, String clientName, + String clientVersion, File vsess) { + super(new SessionHandle("vamsasfile://" + vsess), new ClientHandle( + clientName, clientVersion), new UserHandle(username, organization)); + _openVsess(vsess); + valid(); + } + + public void valid() { + if (vsess == null) + throw new Error("ArchiveClient instance is invalid!."); + } + + /** + * set this to false if watch loop should end immediately + */ + protected boolean watchForChange = true; + + public static int WATCH_SLEEP = 300; + + /** + * watch the document file for updates. + * + * @param time + * - length of time to watch for. + * @return read only IO interface for session document. + */ + public ClientDoc watch(long time) { + valid(); + vsess.unLock(); // doh. + FileWatcher watcher = new FileWatcher(vsess.getVamsasFile()); + // watcher.setState(); + watchForChange = true; + long endtime = System.currentTimeMillis() + time; + try { + uk.ac.vamsas.client.simpleclient.Lock doclock; + do { + doclock = watcher.getChangedState(); + if (doclock == null) + Thread.sleep(WATCH_SLEEP); + } while (watchForChange && doclock == null + && (time == 0 || endtime > System.currentTimeMillis())); // tuning. + if (doclock == null) + return null; + else { + return getUpdateable(vsess.getLock(doclock)); + /* + * VamsasArchiveReader varc = new + * VamsasArchiveReader(vsess.getVamsasFile()); return + * _getReadonly(varc); + */ + } + } catch (Exception e) { + log.error("Whilst watching file " + vsess.getVamsasFile(), e); + } + return null; + } + + // from ClientDocument.getClientAppdata + private AppData[] getAppData(VamsasDocument doc) { + // TODO: codefest - not yet tested or merged in to SimpleClient + if (doc == null) { + log.debug("extractAppData called for null document object"); + return null; + } + AppData appsGlobal = null, usersData = null; + Vector apldataset = AppDataReference.getUserandApplicationsData(doc, this + .getUserHandle(), this.getClientHandle()); + if (apldataset != null) { + if (apldataset.size() > 0) { + AppData clientdat = (AppData) apldataset.get(0); + if (clientdat instanceof ApplicationData) { + appsGlobal = (ApplicationData) clientdat; + if (apldataset.size() > 1) { + clientdat = (AppData) apldataset.get(1); + if (clientdat instanceof User) { + usersData = (User) clientdat; + } + if (apldataset.size() > 2) + log.info("Ignoring additional (" + (apldataset.size() - 2) + + ") AppDatas returned by document appdata query."); + } + } else { + log.warn("Unexpected entry in AppDataReference query: id=" + + clientdat.getVorbaId() + " type=" + + clientdat.getClass().getName()); + } + apldataset.removeAllElements(); // destroy references. + } + } + return new AppData[] { appsGlobal, usersData }; + } + + protected ClientDoc _getReadonly(VamsasArchiveReader vreader) + throws IOException, ValidationException, MarshalException { + valid(); + if (vreader != null) { + SimpleDocBinding docb = new SimpleDocBinding(); + docb.setVorba(this); + VamsasDocument d; + d = docb.getVamsasDocument(vreader); + + if (d != null) { + ClientDoc creader = new ClientDoc(d, null, vreader, getClientHandle() + .getClientUrn(), getProvenanceUser(), getVorbaIdHash()); + return creader; + } + } + return null; + } + + /** + * from SimpleClient + * + * @return user field for a provenance entry + */ + protected String getProvenanceUser() { + return new String(getUserHandle().getFullName() + " [" + + getClientHandle().getClientUrn() + "]"); + } + + public ClientDoc getUpdateable() { + return getUpdateable(null); + } + + public ClientDoc getUpdateable(uk.ac.vamsas.client.simpleclient.Lock lock) { + getVorbaIdHash().clear(); + valid(); + try { + // patiently wait for a lock on the document. + long tries = 5000; + while (lock == null + && ((lock = vsess.getLock()) == null || !lock.isLocked()) + && --tries > 0) { + // Thread.sleep(1); + log.debug("Trying to get a document lock for the " + tries + + "'th time."); + } + VamsasArchive varc = new VamsasArchive(vsess, true, false); // read + // archive, + // write as + // vamsasDocument, + // don't erase + // original + // contents. + varc.setVorba(this); + VamsasDocument d = varc.getVamsasDocument(getProvenanceUser(), + "Created new document.", VersionEntries.latestVersion()); // VAMSAS: + // provenance + // user and + // client + // combined + + if (d == null) { + log + .warn("Backing out from opening a VamsasArchive writable IO session"); + varc.cancelArchive(); + return null; + } + ClientDoc cdoc = new ClientDoc(d, varc, varc.getOriginalArchiveReader(), + getClientHandle().getClientUrn(), getProvenanceUser(), + getVorbaIdHash()); + return cdoc; + // do appHandle? + } catch (Exception e) { + log.error("Failed to get Updateable version of " + vsess.getVamsasFile(), + e); + } + return null; + } + + /** + * trust client to not do anything stupid to the document roots which will now + * be written to the archive. + * + * @param cdoc + * @return true if write was a success. + */ + public boolean doUpdate(ClientDoc cdoc) { + valid(); + if (cdoc == null) { + log + .warn("Invalid ClientDoc passed to uk.ac.vamsas.test.simpleclient.doUpdate()"); + return false; + } + if (cdoc.iohandler == null) { + log + .warn("Read only ClientDoc object passed to uk.ac.vamsas.test.simpleclient.doUpdate()"); + return false; + } + if (cdoc.iohandler.getVorba() != this) { + log + .error("Mismatch between ClientDoc instances and ArchiveClient instances!"); + return false; + } + try { + // do any appDatas first. + if (cdoc.iohandler.transferRemainingAppDatas()) + log.debug("Remaining appdatas were transfered."); + cdoc.updateDocumentRoots(); + cdoc.iohandler.putVamsasDocument(cdoc.doc); + cdoc.iohandler.closeArchive(); + this.extantids.clear();// we forget our ids after we close the document. + cdoc.iohandler = null; + cdoc = null; + vsess.unLock(); + } catch (Exception e) { + log.warn("While updating archive in " + vsess.getVamsasFile(), e); + return false; + } + return true; + } + + /** + * @param args + */ + public static void usage() { + throw new Error("Usage: Username Organization VamsasFile [command,args]*"); + } + + public static void main(String[] args) { + // really simple. + if (args.length < 3) + usage(); + + ArchiveClient client = new ArchiveClient(args[0], args[1], + new File(args[2])); + ClientDoc cdoc = null; + // sanity test. + try { + cdoc = client.getUpdateable(); + // ArchiveReports.reportDocument(cdoc.doc, cdoc.getReader(), true, + // System.out); + System.out.println("Report Roots :"); + ArchiveReports.rootReport(cdoc.getVamsasRoots(), true, System.out); + cdoc.addVamsasRoot(Core.getDemoVamsas()); + System.out.println("Doing update."); + client.doUpdate(cdoc); + cdoc.closeDoc(); + cdoc = null; + int u = 5; + while (--u > 0) { + System.out.println("Watch for more... (" + u + " left)"); + ClientDoc ucdoc = client.watch(0000); + if (ucdoc != null) { + System.out.println("****\nUpdate detected at " + new Date()); + ArchiveReports.reportDocument(ucdoc.doc, ucdoc.getReader(), true, + System.out); + ucdoc.closeDoc(); + ucdoc = null; + } else { + System.out.println("!!!! Null document update detected at " + + new Date()); + } + } + } catch (Exception e) { + client.log.error("Broken!", e); + } + System.out.println("Finished at " + new Date()); + } + + public uk.ac.vamsas.client.Vobject getObject(VorbaId id) { + Hashtable idhash = this.getVorbaIdHash(); + if (idhash != null && idhash.containsKey(id)) + return (Vobject) idhash.get(id); + return null; + } +} diff --git a/src/uk/ac/vamsas/test/simpleclient/ArchiveReader.java b/src/uk/ac/vamsas/test/simpleclient/ArchiveReader.java index 68e6ff4..a00be72 100644 --- a/src/uk/ac/vamsas/test/simpleclient/ArchiveReader.java +++ b/src/uk/ac/vamsas/test/simpleclient/ArchiveReader.java @@ -1,51 +1,74 @@ -package uk.ac.vamsas.test.simpleclient; - -import java.io.BufferedInputStream; -import java.io.File; -import java.io.InputStream; -import java.io.InputStreamReader; - - -import uk.ac.vamsas.client.simpleclient.VamsasArchiveReader; -import uk.ac.vamsas.objects.core.VAMSAS; -import uk.ac.vamsas.objects.core.VamsasDocument; - -public class ArchiveReader { - /** - * tests VamsasArchiveReader archive reader on a vamsas jar file - * @param args - */ - public static void main(String args[]) { - - try { - File av = new File(args[0]); - VamsasArchiveReader var = new VamsasArchiveReader(av); - VAMSAS roots[]=null; - if (var.isValid()) { - InputStreamReader vdoc = new InputStreamReader(var.getVamsasDocumentStream()); - VamsasDocument doc = VamsasDocument.unmarshal(vdoc); - if (ArchiveReports.reportDocument(doc, var, true, System.out)) { - roots = doc.getVAMSAS(); - } - } else { - InputStream vxmlis = var.getVamsasXmlStream(); - - if (vxmlis!=null) { // Might be an old vamsas file. - BufferedInputStream ixml = new BufferedInputStream(var.getVamsasXmlStream()); - InputStreamReader vxml = new InputStreamReader(ixml); - VAMSAS root; - // unmarshal seems to always close the stream (should check this) - if ((root = VAMSAS.unmarshal(vxml))!=null) { - System.out.println("Read a root."); - roots = new VAMSAS[1]; - roots[0] = root; - } - } - } - if (!ArchiveReports.rootReport(roots, true, System.out)) - System.err.print(args[0]+" is not a valid vamsas archive."); - } catch (Exception e) { - e.printStackTrace(System.err); - } - } -} +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ +package uk.ac.vamsas.test.simpleclient; + +import java.io.BufferedInputStream; +import java.io.File; +import java.io.InputStream; +import java.io.InputStreamReader; + +import uk.ac.vamsas.client.simpleclient.VamsasArchiveReader; +import uk.ac.vamsas.objects.core.VAMSAS; +import uk.ac.vamsas.objects.core.VamsasDocument; + +public class ArchiveReader { + /** + * tests VamsasArchiveReader archive reader on a vamsas jar file + * + * @param args + */ + public static void main(String args[]) { + + try { + File av = new File(args[0]); + VamsasArchiveReader var = new VamsasArchiveReader(av); + VAMSAS roots[] = null; + if (var.isValid()) { + InputStreamReader vdoc = new InputStreamReader(var + .getVamsasDocumentStream()); + VamsasDocument doc = VamsasDocument.unmarshal(vdoc); + if (ArchiveReports.reportDocument(doc, var, true, System.out)) { + roots = doc.getVAMSAS(); + } + } else { + InputStream vxmlis = var.getVamsasXmlStream(); + + if (vxmlis != null) { // Might be an old vamsas file. + BufferedInputStream ixml = new BufferedInputStream(var + .getVamsasXmlStream()); + InputStreamReader vxml = new InputStreamReader(ixml); + VAMSAS root; + // unmarshal seems to always close the stream (should check this) + if ((root = VAMSAS.unmarshal(vxml)) != null) { + System.out.println("Read a root."); + roots = new VAMSAS[1]; + roots[0] = root; + } + } + } + if (!ArchiveReports.rootReport(roots, true, System.out)) + System.err.print(args[0] + " is not a valid vamsas archive."); + } catch (Exception e) { + e.printStackTrace(System.err); + } + } +} diff --git a/src/uk/ac/vamsas/test/simpleclient/ArchiveReports.java b/src/uk/ac/vamsas/test/simpleclient/ArchiveReports.java index 766d6a2..83989af 100644 --- a/src/uk/ac/vamsas/test/simpleclient/ArchiveReports.java +++ b/src/uk/ac/vamsas/test/simpleclient/ArchiveReports.java @@ -1,214 +1,268 @@ -package uk.ac.vamsas.test.simpleclient; - -import java.io.InputStream; -import java.io.PrintStream; -import java.io.PrintWriter; - - -import uk.ac.vamsas.client.ClientDocument; -import uk.ac.vamsas.client.Vobject; -import uk.ac.vamsas.client.simpleclient.VamsasArchiveReader; -import uk.ac.vamsas.objects.core.Alignment; -import uk.ac.vamsas.objects.core.AppData; -import uk.ac.vamsas.objects.core.ApplicationData; -import uk.ac.vamsas.objects.core.DataSet; -import uk.ac.vamsas.objects.core.Entry; -import uk.ac.vamsas.objects.core.Instance; -import uk.ac.vamsas.objects.core.Provenance; -import uk.ac.vamsas.objects.core.Tree; -import uk.ac.vamsas.objects.core.User; -import uk.ac.vamsas.objects.core.VAMSAS; -import uk.ac.vamsas.objects.core.VamsasDocument; -/** - * this class contains static methods for writing info to stdout about a vamsas document - * Methods have a 'cascade' switch to indicate if sub-objects should have info printed on them. - * Methods return true or false - indicating if the Vobject was valid or not - * TODO: LATER: propagate true/false return so that an invalid vamsas Vobject invalidates the whole document - * @author jimp - * - */ -public class ArchiveReports { - /** - * print an informative summary on a VamsasDocument - * @param outstr TODO - * @param document - the document itself - * @param archive - document source archive for resolving any appData refs - * @return - */ - public static boolean reportProvenance(Provenance p, PrintStream outstr) { - if (p==null) { - outstr.println("No Provenance"); - return false; - } - Entry[] pe = p.getEntry(); - for (int i=0; i1) { - outstr.print("a reference ("+appData+")"); - InputStream jstrm; - if ((jstrm=archive.getAppdataStream(appData))!=null) - outstr.println(" which resolves to a JarEntry."); - else { - outstr.println(" which does not resolve to a JarEntry."); - outstr.println("Unresolved appdata reference '"+appData+"'"); - } - } else { - nulldata=true; - } - } else { - if (appD.getData()==null) - nulldata &= true; - else - outstr.println("an embedded chunk of "+appD.getData().length+" bytes."); - } - if (nulldata) - outstr.println("Null AppData reference/data chunk."); - } - return true; - } - - public static boolean appDataReport(ApplicationData appD, VamsasArchiveReader archive, boolean cascade, PrintStream outstr) { - if (appD!=null) { - // Report on root appData - appDataEntryReport(appD, archive, cascade, outstr); - if (appD.getInstanceCount()>0) { - Instance inst[] = appD.getInstance(); - for (int i=0,j=inst.hashCode(); i0) { - User users[] = appD.getUser(); - for (int i=0,j=users.length; i0 && cascade) - rootReport(document.getVAMSAS(), true, outstr); - if (document.getApplicationDataCount()>0) { - outstr.print("There are "+document.getApplicationDataCount()+" ApplicationData references.\n"); - ApplicationData appd[] = document.getApplicationData(); - for (int i=0,j=appd.length; i") - +") contains "+(ds=r.getDataSetCount())+" DataSets, " - + (tr=r.getTreeCount())+" Global trees\n"); - outputVobjectState(r, outstr); - if (cascade) { - for (int j=0; j0) { - for (int i=0; i. + */ +package uk.ac.vamsas.test.simpleclient; + +import java.io.InputStream; +import java.io.PrintStream; +import java.io.PrintWriter; + +import uk.ac.vamsas.client.ClientDocument; +import uk.ac.vamsas.client.Vobject; +import uk.ac.vamsas.client.simpleclient.VamsasArchiveReader; +import uk.ac.vamsas.objects.core.Alignment; +import uk.ac.vamsas.objects.core.AppData; +import uk.ac.vamsas.objects.core.ApplicationData; +import uk.ac.vamsas.objects.core.DataSet; +import uk.ac.vamsas.objects.core.Entry; +import uk.ac.vamsas.objects.core.Instance; +import uk.ac.vamsas.objects.core.Provenance; +import uk.ac.vamsas.objects.core.Tree; +import uk.ac.vamsas.objects.core.User; +import uk.ac.vamsas.objects.core.VAMSAS; +import uk.ac.vamsas.objects.core.VamsasDocument; + +/** + * this class contains static methods for writing info to stdout about a vamsas + * document Methods have a 'cascade' switch to indicate if sub-objects should + * have info printed on them. Methods return true or false - indicating if the + * Vobject was valid or not TODO: LATER: propagate true/false return so that an + * invalid vamsas Vobject invalidates the whole document + * + * @author jimp + * + */ +public class ArchiveReports { + /** + * print an informative summary on a VamsasDocument + * + * @param outstr + * TODO + * @param document + * - the document itself + * @param archive + * - document source archive for resolving any appData refs + * @return + */ + public static boolean reportProvenance(Provenance p, PrintStream outstr) { + if (p == null) { + outstr.println("No Provenance"); + return false; + } + Entry[] pe = p.getEntry(); + for (int i = 0; i < pe.length; i++) { + outstr.print(pe[i].getDate() + "\t'" + pe[i].getUser() + "'\t" + + pe[i].getApp() + "\t'" + pe[i].getAction() + "' "); + outputVobjectState(pe[i], outstr); + } + return true; + } + + public static boolean appDataEntryReport(AppData appD, + VamsasArchiveReader archive, boolean cascade, PrintStream outstr) { + if (appD != null) { + boolean nulldata = false; + if (appD.getDataReference() != null) { + String appData = appD.getDataReference(); + if (appData == null) { + outstr.println("Empty DataReference - not valid ?"); + } else if (appData.length() > 1) { + outstr.print("a reference (" + appData + ")"); + InputStream jstrm; + if ((jstrm = archive.getAppdataStream(appData)) != null) + outstr.println(" which resolves to a JarEntry."); + else { + outstr.println(" which does not resolve to a JarEntry."); + outstr.println("Unresolved appdata reference '" + appData + "'"); + } + } else { + nulldata = true; + } + } else { + if (appD.getData() == null) + nulldata &= true; + else + outstr.println("an embedded chunk of " + appD.getData().length + + " bytes."); + } + if (nulldata) + outstr.println("Null AppData reference/data chunk."); + } + return true; + } + + public static boolean appDataReport(ApplicationData appD, + VamsasArchiveReader archive, boolean cascade, PrintStream outstr) { + if (appD != null) { + // Report on root appData + appDataEntryReport(appD, archive, cascade, outstr); + if (appD.getInstanceCount() > 0) { + Instance inst[] = appD.getInstance(); + for (int i = 0, j = inst.hashCode(); i < j; i++) { + outstr.println("Data for App Instance URN: '" + inst[i].getUrn()); + appDataEntryReport(inst[i], archive, cascade, outstr); + } + } + if (appD.getUserCount() > 0) { + User users[] = appD.getUser(); + for (int i = 0, j = users.length; i < j; i++) { + outstr.println("Data for User '" + users[i].getFullname() + "' of '" + + users[i].getOrganization() + "'"); + appDataEntryReport(users[i], archive, cascade, outstr); + } + } + } + + return true; + } + + public static boolean reportDocument(VamsasDocument document, + VamsasArchiveReader archive, boolean cascade, PrintStream outstr) { + if (document != null) { + outstr.println("Vamsas Document version '" + document.getVersion() + "'"); + reportProvenance(document.getProvenance(), outstr); + outstr.print("Document contains " + document.getVAMSASCount() + + " VAMSAS Elements and " + document.getApplicationDataCount() + + " Application data elements.\n"); + if (document.getVAMSASCount() > 0 && cascade) + rootReport(document.getVAMSAS(), true, outstr); + if (document.getApplicationDataCount() > 0) { + outstr.print("There are " + document.getApplicationDataCount() + + " ApplicationData references.\n"); + ApplicationData appd[] = document.getApplicationData(); + for (int i = 0, j = appd.length; i < j; i++) { + outstr.print("Application " + i + ": '" + appd[i].getName() + + "'\nVersion '" + appd[i].getVersion() + "'\n"); + outstr.print("AppData is :"); + appDataReport(appd[i], archive, cascade, outstr); + } + + } + return true; + } else { + outstr.println("Document Object is null"); + } + return false; + } + + /** + * summarises all the datasets in a vamsas document. + * + * @param roots + * @param cascade + * TODO + * @param outstr + * TODO + * @return + */ + public static boolean rootReport(VAMSAS[] roots, boolean cascade, + PrintStream outstr) { + if (roots != null) { + for (int i = 0; i < roots.length; i++) { + VAMSAS r = roots[i]; + int ds, tr; + outstr.print("Vamsas Root " + i + " (id=" + + ((r.getId() != null) ? r.getId() : "") + ") contains " + + (ds = r.getDataSetCount()) + " DataSets, " + + (tr = r.getTreeCount()) + " Global trees\n"); + outputVobjectState(r, outstr); + if (cascade) { + for (int j = 0; j < ds; j++) { + outstr.println("Dataset " + j); + cascade = datasetReport(r.getDataSet(j), true, outstr) && cascade; + } + for (int j = 0; j < tr; j++) { + outstr.println("Global tree " + j); + cascade = treeReport(r.getTree(j), true, outstr) && cascade; + } + } + } + return true; + } + return false; + } + + public static void outputVobjectState(Vobject v, PrintStream outstr) { + outstr.print(" (Object is: "); + boolean comma = false; + if (v.is__stored_in_document()) { + outstr.print(" stored"); + comma = true; + } + if (v.isNewInDocument()) { + if (comma) + outstr.print(","); + comma = true; + outstr.print(" new in document"); + } + if (v.isUpdated()) { + if (comma) + outstr.print(","); + comma = true; + outstr.print(" updated since last read"); + } + outstr.println(")"); + } + + public static boolean datasetReport(DataSet ds, boolean cascade, + PrintStream outstr) { + if (cascade) + reportProvenance(ds.getProvenance(), outstr); + outputVobjectState(ds, outstr); + outstr.println("Dataset contains : " + ds.getSequenceCount() + + " sequences, " + ds.getAlignmentCount() + " alignments and " + + ds.getTreeCount() + " trees."); + if (cascade) + alignmentReport(ds.getAlignment(), true, outstr); + return true; + } + + public static boolean alignmentReport(Alignment[] al, boolean cascade, + PrintStream outstr) { + boolean val = true; + if (al != null && al.length > 0) { + for (int i = 0; i < al.length; i++) { + outstr.println("Alignment " + + i + + (al[i].isRegistered() ? " (" + al[i].getVorbaId() + ")" + : " (unregistered)")); + outputVobjectState(al[i], outstr); + if (cascade) + reportProvenance(al[i].getProvenance(), outstr); + outstr.println("Involves " + al[i].getAlignmentSequenceCount() + + " sequences, has " + al[i].getAlignmentAnnotationCount() + + " annotations and " + al[i].getTreeCount() + " trees."); + if (cascade) { + for (int t = 0; t < al[i].getTreeCount(); t++) + treeReport(al[i].getTree(t), true, outstr); + } + } + } + return val; + } + + public static boolean treeReport(Tree t, boolean cascade, PrintStream outstr) { + outstr.print("Tree: '" + t.getTitle() + "' "); + outputVobjectState(t, outstr); + return !cascade || reportProvenance(t.getProvenance(), outstr); + } + +} diff --git a/src/uk/ac/vamsas/test/simpleclient/ArchiveStreamReader.java b/src/uk/ac/vamsas/test/simpleclient/ArchiveStreamReader.java index d3fe14f..ff96afc 100644 --- a/src/uk/ac/vamsas/test/simpleclient/ArchiveStreamReader.java +++ b/src/uk/ac/vamsas/test/simpleclient/ArchiveStreamReader.java @@ -1,53 +1,77 @@ -package uk.ac.vamsas.test.simpleclient; - -import java.io.BufferedInputStream; -import java.io.File; -import java.io.InputStream; -import java.io.InputStreamReader; - - -import uk.ac.vamsas.client.simpleclient.SessionFile; -import uk.ac.vamsas.client.simpleclient.VamsasArchiveReader; -import uk.ac.vamsas.client.simpleclient.VamsasFile; -import uk.ac.vamsas.objects.core.VAMSAS; -import uk.ac.vamsas.objects.core.VamsasDocument; - -public class ArchiveStreamReader { - /** - * tests VamsasArchiveReader archive reader on a vamsas jar file opened as a stream - * @param args - */ - public static void main(String args[]) { - - try { - VamsasFile av = new VamsasFile(new File(args[0])); - VamsasArchiveReader var = new VamsasArchiveReader(av.getLock()); - VAMSAS roots[]=null; - if (var.isValid()) { - InputStreamReader vdoc = new InputStreamReader(var.getVamsasDocumentStream()); - VamsasDocument doc = VamsasDocument.unmarshal(vdoc); - if (ArchiveReports.reportDocument(doc, var, true, System.out)) { - roots = doc.getVAMSAS(); - } - } else { - InputStream vxmlis = var.getVamsasXmlStream(); - - if (vxmlis!=null) { // Might be an old vamsas file. - BufferedInputStream ixml = new BufferedInputStream(var.getVamsasXmlStream()); - InputStreamReader vxml = new InputStreamReader(ixml); - VAMSAS root; - // unmarshal seems to always close the stream (should check this) - if ((root = VAMSAS.unmarshal(vxml))!=null) { - System.out.println("Read a root."); - roots = new VAMSAS[1]; - roots[0] = root; - } - } - } - if (!ArchiveReports.rootReport(roots, true, System.out)) - System.err.print(args[0]+" is not a valid vamsas archive."); - } catch (Exception e) { - e.printStackTrace(System.err); - } - } -} +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ +package uk.ac.vamsas.test.simpleclient; + +import java.io.BufferedInputStream; +import java.io.File; +import java.io.InputStream; +import java.io.InputStreamReader; + +import uk.ac.vamsas.client.simpleclient.SessionFile; +import uk.ac.vamsas.client.simpleclient.VamsasArchiveReader; +import uk.ac.vamsas.client.simpleclient.VamsasFile; +import uk.ac.vamsas.objects.core.VAMSAS; +import uk.ac.vamsas.objects.core.VamsasDocument; + +public class ArchiveStreamReader { + /** + * tests VamsasArchiveReader archive reader on a vamsas jar file opened as a + * stream + * + * @param args + */ + public static void main(String args[]) { + + try { + VamsasFile av = new VamsasFile(new File(args[0])); + VamsasArchiveReader var = new VamsasArchiveReader(av.getLock()); + VAMSAS roots[] = null; + if (var.isValid()) { + InputStreamReader vdoc = new InputStreamReader(var + .getVamsasDocumentStream()); + VamsasDocument doc = VamsasDocument.unmarshal(vdoc); + if (ArchiveReports.reportDocument(doc, var, true, System.out)) { + roots = doc.getVAMSAS(); + } + } else { + InputStream vxmlis = var.getVamsasXmlStream(); + + if (vxmlis != null) { // Might be an old vamsas file. + BufferedInputStream ixml = new BufferedInputStream(var + .getVamsasXmlStream()); + InputStreamReader vxml = new InputStreamReader(ixml); + VAMSAS root; + // unmarshal seems to always close the stream (should check this) + if ((root = VAMSAS.unmarshal(vxml)) != null) { + System.out.println("Read a root."); + roots = new VAMSAS[1]; + roots[0] = root; + } + } + } + if (!ArchiveReports.rootReport(roots, true, System.out)) + System.err.print(args[0] + " is not a valid vamsas archive."); + } catch (Exception e) { + e.printStackTrace(System.err); + } + } +} diff --git a/src/uk/ac/vamsas/test/simpleclient/ArchiveWatcher.java b/src/uk/ac/vamsas/test/simpleclient/ArchiveWatcher.java index d784a8e..e0d2f9f 100644 --- a/src/uk/ac/vamsas/test/simpleclient/ArchiveWatcher.java +++ b/src/uk/ac/vamsas/test/simpleclient/ArchiveWatcher.java @@ -1,106 +1,140 @@ -package uk.ac.vamsas.test.simpleclient; - -import java.io.File; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import uk.ac.vamsas.client.ClientHandle; -import uk.ac.vamsas.client.simpleclient.FileWatcher; -import uk.ac.vamsas.client.simpleclient.Lock; -import uk.ac.vamsas.client.simpleclient.SimpleDocument; -import uk.ac.vamsas.client.simpleclient.VamsasArchiveReader; -import uk.ac.vamsas.client.simpleclient.VamsasFile; -import uk.ac.vamsas.objects.core.VamsasDocument; -/** - * demo of archive watching process - should mimic the clientsfileTest watcher/monitor process. - * @author jimp - * - */ -public class ArchiveWatcher { - private static Log log = LogFactory.getLog(ArchiveWatcher.class); - private static CommandProcessor cproc=new CommandProcessor(); - static { - cproc.addCommand("new", 0, "no args"); - cproc.addCommand("delete", 0, "no args"); - cproc.addCommand("watch", 0, "no args"); - cproc.addCommand("file", 1, "Need vamsas archive as argument."); - } - - public static void main(String[] args) { - try { - - if (args!=null && args.length>0) { - File archive = new File(args[0]); - log.info("Watching file "+args[0]); - int argc=1; - while (argc < args.length) { - // vars needed for operations - ClientHandle ch; - int com = cproc.getCommand(args, argc); - argc++; - switch (com) { - case 0: - // new - log.info("Doing locked deletion and new-file creation."); - { - if (!archive.exists()) - archive.createNewFile(); - VamsasFile sf = new VamsasFile(archive); - Lock l = sf.getLock(); - archive.delete(); - archive.createNewFile(); - sf.unLock(); - } - break; - case 1: - // delete - log.info("Deleting "+archive+" without locking it first."); - archive.delete(); - break; - case 2: - // watch - log.info("Endlessly Watching file "+archive); - /* if (!archive.exists()) - archive.createNewFile(); - */ // watch the new file... - taken straight from ClientsFileTest - FileWatcher w = new FileWatcher(archive); - while (true) { - // get watcher's lock to ensure state change is fixed for retrieval - Lock chlock = w.getChangedState(); - if (chlock != null) { - log.info("Got lock on "+archive+(archive.exists() ? " exists l="+archive.length() : "(non existant)")); - if (archive.length()>0) { - VamsasArchiveReader vreader = new VamsasArchiveReader(archive); - SimpleDocument sdoc = new SimpleDocument("testing vamsas watcher"); - try { - VamsasDocument d = sdoc.getVamsasDocument(vreader); - if (d!=null) { - ArchiveReports.reportDocument(d, vreader, false, System.out); - } - System.out.println("Update at "+System.currentTimeMillis()+"\n\n********************************************************\n"); - } catch (Exception e) { - log.error("Unmarshalling failed.",e); - } - vreader.close(); - w.setState(); - } - } - } - // break; - case 3: // set file - archive = new File(args[argc++]); - break; - case 4: - break; - default: - log.warn("Unknown command + "+args[argc++]); - } - } - } - } catch (Exception e) { - log.error(e); - } - - } -} +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ +package uk.ac.vamsas.test.simpleclient; + +import java.io.File; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import uk.ac.vamsas.client.ClientHandle; +import uk.ac.vamsas.client.simpleclient.FileWatcher; +import uk.ac.vamsas.client.simpleclient.Lock; +import uk.ac.vamsas.client.simpleclient.SimpleDocument; +import uk.ac.vamsas.client.simpleclient.VamsasArchiveReader; +import uk.ac.vamsas.client.simpleclient.VamsasFile; +import uk.ac.vamsas.objects.core.VamsasDocument; + +/** + * demo of archive watching process - should mimic the clientsfileTest + * watcher/monitor process. + * + * @author jimp + * + */ +public class ArchiveWatcher { + private static Log log = LogFactory.getLog(ArchiveWatcher.class); + + private static CommandProcessor cproc = new CommandProcessor(); + static { + cproc.addCommand("new", 0, "no args"); + cproc.addCommand("delete", 0, "no args"); + cproc.addCommand("watch", 0, "no args"); + cproc.addCommand("file", 1, "Need vamsas archive as argument."); + } + + public static void main(String[] args) { + try { + + if (args != null && args.length > 0) { + File archive = new File(args[0]); + log.info("Watching file " + args[0]); + int argc = 1; + while (argc < args.length) { + // vars needed for operations + ClientHandle ch; + int com = cproc.getCommand(args, argc); + argc++; + switch (com) { + case 0: + // new + log.info("Doing locked deletion and new-file creation."); + { + if (!archive.exists()) + archive.createNewFile(); + VamsasFile sf = new VamsasFile(archive); + Lock l = sf.getLock(); + archive.delete(); + archive.createNewFile(); + sf.unLock(); + } + break; + case 1: + // delete + log.info("Deleting " + archive + " without locking it first."); + archive.delete(); + break; + case 2: + // watch + log.info("Endlessly Watching file " + archive); + /* + * if (!archive.exists()) archive.createNewFile(); + */// watch the new file... - taken straight from ClientsFileTest + FileWatcher w = new FileWatcher(archive); + while (true) { + // get watcher's lock to ensure state change is fixed for + // retrieval + Lock chlock = w.getChangedState(); + if (chlock != null) { + log.info("Got lock on " + + archive + + (archive.exists() ? " exists l=" + archive.length() + : "(non existant)")); + if (archive.length() > 0) { + VamsasArchiveReader vreader = new VamsasArchiveReader(archive); + SimpleDocument sdoc = new SimpleDocument( + "testing vamsas watcher"); + try { + VamsasDocument d = sdoc.getVamsasDocument(vreader); + if (d != null) { + ArchiveReports.reportDocument(d, vreader, false, + System.out); + } + System.out + .println("Update at " + + System.currentTimeMillis() + + "\n\n********************************************************\n"); + } catch (Exception e) { + log.error("Unmarshalling failed.", e); + } + vreader.close(); + w.setState(); + } + } + } + // break; + case 3: // set file + archive = new File(args[argc++]); + break; + case 4: + break; + default: + log.warn("Unknown command + " + args[argc++]); + } + } + } + } catch (Exception e) { + log.error(e); + } + + } +} diff --git a/src/uk/ac/vamsas/test/simpleclient/ArchiveWriter.java b/src/uk/ac/vamsas/test/simpleclient/ArchiveWriter.java index f156b74..de56816 100644 --- a/src/uk/ac/vamsas/test/simpleclient/ArchiveWriter.java +++ b/src/uk/ac/vamsas/test/simpleclient/ArchiveWriter.java @@ -1,180 +1,234 @@ -package uk.ac.vamsas.test.simpleclient; - -import java.io.File; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.PrintWriter; -import java.text.DateFormat; -import java.util.Date; -import java.util.Hashtable; -import java.util.Vector; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import uk.ac.vamsas.objects.core.Alignment; -import uk.ac.vamsas.objects.core.ApplicationData; -import uk.ac.vamsas.objects.core.Entry; -import uk.ac.vamsas.objects.core.Instance; -import uk.ac.vamsas.objects.core.Provenance; -import uk.ac.vamsas.objects.core.VAMSAS; -import uk.ac.vamsas.objects.core.VamsasDocument; -import uk.ac.vamsas.objects.utils.ProvenanceStuff; -import uk.ac.vamsas.client.simpleclient.VamsasArchive; -import uk.ac.vamsas.client.simpleclient.VamsasArchiveReader; - -public class ArchiveWriter { - - /** - * Test program for writing archive files. - * form is ArchiveWriter new/modified argive command list - */ - - static Log log = LogFactory.getLog(ArchiveWriter.class); - - private static void mergeVecs(Object[] destvec, Object[] svec1, Object[] svec2) { - int i; - for (i=0; i0) { - ApplicationData[] newdat = new ApplicationData[source.getApplicationDataCount()+dest.getApplicationDataCount()]; - ApplicationData[] sappd = source.getApplicationData(); - // check refs and update/modify if necessary - for (int i=0; i [(commands)]"); - return; - } - File newarch = new File(argv[0]); - int argpos = 0; - try { - // test fully fledged doc construction - VamsasArchive varc = new VamsasArchive(newarch, true); - VamsasDocument docroot; - docroot = new VamsasDocument(); - docroot.setProvenance(ProvenanceStuff.newProvenance("ArchiveWriter", "user", "Created new Vamsas Document")); - while (++argpos. + */ +package uk.ac.vamsas.test.simpleclient; + +import java.io.File; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.text.DateFormat; +import java.util.Date; +import java.util.Hashtable; +import java.util.Vector; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import uk.ac.vamsas.objects.core.Alignment; +import uk.ac.vamsas.objects.core.ApplicationData; +import uk.ac.vamsas.objects.core.Entry; +import uk.ac.vamsas.objects.core.Instance; +import uk.ac.vamsas.objects.core.Provenance; +import uk.ac.vamsas.objects.core.VAMSAS; +import uk.ac.vamsas.objects.core.VamsasDocument; +import uk.ac.vamsas.objects.utils.ProvenanceStuff; +import uk.ac.vamsas.client.simpleclient.VamsasArchive; +import uk.ac.vamsas.client.simpleclient.VamsasArchiveReader; + +public class ArchiveWriter { + + /** + * Test program for writing archive files. form is ArchiveWriter new/modified + * argive command list + */ + + static Log log = LogFactory.getLog(ArchiveWriter.class); + + private static void mergeVecs(Object[] destvec, Object[] svec1, Object[] svec2) { + int i; + for (i = 0; i < svec1.length; i++) + destvec[i] = svec1[i]; + for (int j = 0; j < svec2.length; i++, j++) + destvec[i] = svec2[j]; + } + + // Merge appDataReferences require transfer of jar entries, perhaps with a + // renaming of the entry. + // Merge appDatas require eventually unique URNS + // TODO: merging global appdata from different documents where same app has + // written them causes conflict + + public static Hashtable hashOfAppDatas(Hashtable ht, Instance[] appdatas) { + if (ht == null) + ht = new Hashtable(); + for (int i = 0, j = appdatas.length; i < j; i++) { + if (!ht.containsKey(appdatas[i].getUrn())) { + Hashtable aphash = new Hashtable(); + ht.put(appdatas[i].getUrn(), aphash); + aphash.put(appdatas[i], appdatas[i].getDataReference()); + } else { + // ensure urns and references are unique + + } + + } + return ht; + } + + /** + * safely copies an appData from one archive to another. + * + * @param darc + * destination archive + * @param dest + * destination document Vobject + * @param sarc + * source archive reader + * @param entry + * application data to be copied from source archive + */ + public static void addAppDataEntry(VamsasArchive darc, VamsasDocument dest, + VamsasArchiveReader sarc, ApplicationData entry) { + // TODO: fix instances + // check uniqueness of instance's[] entry.urn amongst + // dest.ApplicationData[].getInstances[].urn + // check uniqueness of entry.user[].urn amongst + // dest.ApplicationData[].user[].urn + // check uniqueness of entry.user + // entry.getAppDataChoice().getData() or getDataReference is unique + ApplicationData newo = new ApplicationData(); + for (int i = 0, j = dest.getApplicationDataCount(); i < j; i++) { + ApplicationData o = dest.getApplicationData()[i]; + // ensure new urn is really unique + // String urn = entry.getUrn(); + int v = 1; + // while (o.getUrn().equals(urn)) { + // urn = entry.getUrn()+v++; + // } + // uniqueness of urn + // check each user ApplicationData + // uniqueness (again) + // copy over valid objects + // + } + } + + /** + * Copy new datasets and appdatas from one vamsas document to another. + * + * @param darc + * @param dest + * @param sarc + * @param source + * @return true if merge was successful. + */ + public static boolean mergeDocs(VamsasArchive darc, VamsasDocument dest, + VamsasArchiveReader sarc, VamsasDocument source) { + log.debug("mergeDocs entered."); + // search for appDatas in cdoc + VAMSAS[] newr = new VAMSAS[dest.getVAMSASCount() + source.getVAMSASCount()]; + mergeVecs(newr, dest.getVAMSAS(), source.getVAMSAS()); + dest.setVAMSAS(newr); + /** + * TODO: LATER: should verify that all ids really are unique in newly merged + * document. If not then what ? investigate possibility of having an id + * translation between appDatas and the core document - the mapping is + * stored when an external application performs a merge, but when the owning + * Application accesses the Vobject, the vorba_id is updated to the new one + * when it writes its references in to its appdata again + */ + if (source.getApplicationDataCount() > 0) { + ApplicationData[] newdat = new ApplicationData[source + .getApplicationDataCount() + + dest.getApplicationDataCount()]; + ApplicationData[] sappd = source.getApplicationData(); + // check refs and update/modify if necessary + for (int i = 0; i < sappd.length; i++) { + addAppDataEntry(darc, dest, sarc, sappd[i]); + } + + } + + return true; // success + } + + private static CommandProcessor cproc; + static { + cproc.addCommand("new", 0, "no args"); + cproc.addCommand("add", 1, + "Need another vamsas document archive filename as argument."); + cproc.addCommand("repair", 0, "no args"); + cproc.addCommand("list", 0, "no args"); + cproc.addCommand("monitor", 0, "no args"); + } + + public static void main(String argv[]) { + /** + * TODO: switches for setting user identities for writing to vamsas document + */ + if (argv.length < 1) { + log.fatal("Usage : [(commands)]"); + return; + } + File newarch = new File(argv[0]); + int argpos = 0; + try { + // test fully fledged doc construction + VamsasArchive varc = new VamsasArchive(newarch, true); + VamsasDocument docroot; + docroot = new VamsasDocument(); + docroot.setProvenance(ProvenanceStuff.newProvenance("ArchiveWriter", + "user", "Created new Vamsas Document")); + while (++argpos < argv.length) { + File archive = new File(argv[argpos]); + InputStream istream; + if (archive.exists()) { + VamsasArchiveReader vdoc = new VamsasArchiveReader(archive); + if (vdoc.isValid()) { + istream = vdoc.getVamsasDocumentStream(); + if (istream != null) { + VamsasDocument cdocroot = VamsasDocument + .unmarshal(new InputStreamReader(istream)); + if (cdocroot != null) + mergeDocs(varc, docroot, vdoc, cdocroot); + } else + log + .warn("Unexpectedly null document stream from existing document " + + archive); + } else { + // updating an oldformat stream ? + if ((istream = vdoc.getVamsasXmlStream()) != null) { + // make a new vamsas document from the vamsas.xml entry + VAMSAS root = VAMSAS.unmarshal(new InputStreamReader(istream)); // TODO: + // verify + // only + // one + // VAMSAS + // element + // per + // vamsas.xml + // entry. + docroot.getProvenance().addEntry( + ProvenanceStuff.newProvenanceEntry("ArchiveWriter", "user", + "added vamsas.xml from " + argv[argpos - 1])); + docroot.addVAMSAS(root); + } + } + } else { + // Begin a new vamsas document + PrintWriter docwriter = varc.getDocumentOutputStream(); + } + } + } catch (Exception e) { + log.error("Whilst manipulating " + argv[0], e); + } + } +} diff --git a/src/uk/ac/vamsas/test/simpleclient/ClientDoc.java b/src/uk/ac/vamsas/test/simpleclient/ClientDoc.java index 990d58a..0772cb3 100644 --- a/src/uk/ac/vamsas/test/simpleclient/ClientDoc.java +++ b/src/uk/ac/vamsas/test/simpleclient/ClientDoc.java @@ -1,356 +1,434 @@ -package uk.ac.vamsas.test.simpleclient; - -import java.util.Hashtable; -import java.util.Vector; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import uk.ac.vamsas.client.IClientAppdata; -import uk.ac.vamsas.client.Vobject; -import uk.ac.vamsas.client.VorbaId; -import uk.ac.vamsas.client.simpleclient.ClientDocument; -import uk.ac.vamsas.client.simpleclient.VamsasArchive; -import uk.ac.vamsas.client.simpleclient.VamsasArchiveReader; -import uk.ac.vamsas.objects.core.Entry; -import uk.ac.vamsas.objects.core.VAMSAS; -import uk.ac.vamsas.objects.core.VamsasDocument; -import uk.ac.vamsas.objects.utils.ProvenanceStuff; - -// simple holder to pass to client. -public class ClientDoc extends uk.ac.vamsas.client.ClientDocument { - /* (non-Javadoc) - * @see uk.ac.vamsas.client.IClientDocument#getClientAppdata() - */ - public IClientAppdata getClientAppdata() { - throw new Error("Appdata access is not implemented in the test.simpleclient.ClientDoc instance."); // TODO Auto-generated method stub - } - protected boolean isModified=false; - private Log log = LogFactory.getLog(ClientDoc.class); - protected VamsasDocument doc; - public uk.ac.vamsas.objects.core.VAMSAS[] _VamsasRoots; - protected VamsasArchive iohandler=null; - protected VamsasArchiveReader reader=null; - private String user=null; - private String app=null; - - /** - * @param doc - * @param iohandler - * @param reader - * @param app - * @param user - */ - public ClientDoc(VamsasDocument doc, VamsasArchive iohandler, VamsasArchiveReader reader, String app, String user, Hashtable objrefs) { - super(objrefs, (iohandler!=null) ? iohandler.getVorba() : null); - this.doc = doc; - this.iohandler = iohandler; - this.reader = reader; - this.app = app; - this.user = user; - this.objrefs = objrefs; - _VamsasRoots = doc.getVAMSAS(); - } - // AppDataOutputStream appd; - //AppDataOutputStream userd; - /* (non-Javadoc) - * @see java.lang.Object#finalize() - */ - protected Entry getProvenanceEntry(String action) { - // VAMSAS: modify schema to allow referencing of user field (plus other issues, ClientUrn field, machine readable action, input parameters, additional data generated notes - Entry prov = ProvenanceStuff.newProvenanceEntry(app, user, action); - return prov; - } - public VAMSAS[] getVamsasRoots() { - if (doc==null) { - log.debug("Null document for getVamsasRoots(), returning null"); - return null; - } - if (iohandler==null) { - // LATER: decide on read-only status of ClientDocument object - log.warn("getVamsasRoots() called on possibly read-only document."); - } - if (_VamsasRoots!=null) - return _VamsasRoots; - VAMSAS[] roots = doc.getVAMSAS(); - if (roots == null) { - // Make a new one to return to client to get filled. - _VamsasRoots = new VAMSAS[] { new VAMSAS() }; - // Do provenance now. just in case. - doc.getProvenance().addEntry(getProvenanceEntry("Created new document root [id="+_VamsasRoots[0].getId()+"]")); - doc.addVAMSAS(_VamsasRoots[0]); - } else { - _VamsasRoots = new VAMSAS[roots.length]; - for (int r=0;r-1) { - if (isValidUpdate(newr[k], original[i])) { - modified=true; - rts.add(newr[k]); - newr[k]=null; - } else { - // LATER: try harder to merge ducument roots. - log.warn("Couldn't merge new VAMSAS root "+newr[k].getId()); - newr[k] = null; // LATER: this means we ignore mangled roots. NOT GOOD - } - } else { - // add in order. - rts.add(original[i]); - } - } - // add remaining (new) roots - for (int i=0,j=newr.length; i. + */ +package uk.ac.vamsas.test.simpleclient; + +import java.util.Hashtable; +import java.util.Vector; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import uk.ac.vamsas.client.IClientAppdata; +import uk.ac.vamsas.client.Vobject; +import uk.ac.vamsas.client.VorbaId; +import uk.ac.vamsas.client.simpleclient.ClientDocument; +import uk.ac.vamsas.client.simpleclient.VamsasArchive; +import uk.ac.vamsas.client.simpleclient.VamsasArchiveReader; +import uk.ac.vamsas.objects.core.Entry; +import uk.ac.vamsas.objects.core.VAMSAS; +import uk.ac.vamsas.objects.core.VamsasDocument; +import uk.ac.vamsas.objects.utils.ProvenanceStuff; + +// simple holder to pass to client. +public class ClientDoc extends uk.ac.vamsas.client.ClientDocument { + /* + * (non-Javadoc) + * + * @see uk.ac.vamsas.client.IClientDocument#getClientAppdata() + */ + public IClientAppdata getClientAppdata() { + throw new Error( + "Appdata access is not implemented in the test.simpleclient.ClientDoc instance."); // TODO + // Auto-generated + // method + // stub + } + + protected boolean isModified = false; + + private Log log = LogFactory.getLog(ClientDoc.class); + + protected VamsasDocument doc; + + public uk.ac.vamsas.objects.core.VAMSAS[] _VamsasRoots; + + protected VamsasArchive iohandler = null; + + protected VamsasArchiveReader reader = null; + + private String user = null; + + private String app = null; + + /** + * @param doc + * @param iohandler + * @param reader + * @param app + * @param user + */ + public ClientDoc(VamsasDocument doc, VamsasArchive iohandler, + VamsasArchiveReader reader, String app, String user, Hashtable objrefs) { + super(objrefs, (iohandler != null) ? iohandler.getVorba() : null); + this.doc = doc; + this.iohandler = iohandler; + this.reader = reader; + this.app = app; + this.user = user; + this.objrefs = objrefs; + _VamsasRoots = doc.getVAMSAS(); + } + + // AppDataOutputStream appd; + // AppDataOutputStream userd; + /* + * (non-Javadoc) + * + * @see java.lang.Object#finalize() + */ + protected Entry getProvenanceEntry(String action) { + // VAMSAS: modify schema to allow referencing of user field (plus other + // issues, ClientUrn field, machine readable action, input parameters, + // additional data generated notes + Entry prov = ProvenanceStuff.newProvenanceEntry(app, user, action); + return prov; + } + + public VAMSAS[] getVamsasRoots() { + if (doc == null) { + log.debug("Null document for getVamsasRoots(), returning null"); + return null; + } + if (iohandler == null) { + // LATER: decide on read-only status of ClientDocument object + log.warn("getVamsasRoots() called on possibly read-only document."); + } + if (_VamsasRoots != null) + return _VamsasRoots; + VAMSAS[] roots = doc.getVAMSAS(); + if (roots == null) { + // Make a new one to return to client to get filled. + _VamsasRoots = new VAMSAS[] { new VAMSAS() }; + // Do provenance now. just in case. + doc.getProvenance().addEntry( + getProvenanceEntry("Created new document root [id=" + + _VamsasRoots[0].getId() + "]")); + doc.addVAMSAS(_VamsasRoots[0]); + } else { + _VamsasRoots = new VAMSAS[roots.length]; + for (int r = 0; r < roots.length; r++) + _VamsasRoots[r] = roots[r]; + } + return _VamsasRoots; + } + + private int _contains(VAMSAS root, VAMSAS[] docRoots) { + if (root == null) + return -1; + if (docRoots == null || docRoots.length == 0) + return -1; + VorbaId r_id = root.getVorbaId(); + for (int i = 0, j = docRoots.length; i < j; i++) { + VorbaId n_id = null; + if (docRoots[i] == root + || (docRoots[i] != null && (n_id = docRoots[i].getVorbaId()) != null && n_id + .equals(r_id))) + return i; + } + return -1; + } + + /** + * verify that newr version is really an intact version of the + * + * @param newVersion + * (may be modified) + * @param oldVersion + * @return true if newVersion is a valid root that preserves original + * references + */ + private boolean isValidUpdate(VAMSAS newVersion, final VAMSAS oldVersion) { + // ideal - this cascades down the two structures, ensuring that all ID'd + // objects in one are present in the other. + if (oldVersion == newVersion) { + // may be a virgin root element. + if (!newVersion.isRegistered()) + iohandler.getVorba().makeVorbaId(newVersion); + // Should retrieve original version and compare - unless local hashes can + // be used to determine if resultSet has been truncated. + // just do internal validation for moment. + if (newVersion.isValid()) + return true; + return false; + } else { + // redundant ? if (oldVersion.is__stored_in_document()) + if (!newVersion.isRegistered()) + iohandler.getVorba().makeVorbaId(newVersion); + if (newVersion.isValid()) + return true; + } + return false; + } + + /** + * /** merge old and new root vectors + * + * @param newr + * This array may be written to + * @param original + * @param the + * client document (usually this) which this root set belongs to. + * @return merged vector of vamsas roots + */ + private VAMSAS[] _combineRoots(VAMSAS[] newr, final VAMSAS[] original, + ClientDoc modflag) { + Vector rts = new Vector(); + boolean modified = false; + for (int i = 0, j = original.length; i < j; i++) { + int k = _contains(original[i], newr); + if (k > -1) { + if (isValidUpdate(newr[k], original[i])) { + modified = true; + rts.add(newr[k]); + newr[k] = null; + } else { + // LATER: try harder to merge ducument roots. + log.warn("Couldn't merge new VAMSAS root " + newr[k].getId()); + newr[k] = null; // LATER: this means we ignore mangled roots. NOT GOOD + } + } else { + // add in order. + rts.add(original[i]); + } + } + // add remaining (new) roots + for (int i = 0, j = newr.length; i < j; i++) { + if (newr[i] != null) { + rts.add(newr[i]); + modified = true; + } + } + newr = new VAMSAS[rts.size()]; + for (int i = 0, j = rts.size(); i < j; i++) + newr[i] = (VAMSAS) rts.get(i); + if (modflag != null) + modflag.isModified = modified; + return newr; + } + + /** + * update the document with new roots. LATER: decide: this affects the next + * call to getVamsasRoots() + * + * @see org.vamsas.IClientDocument.setVamsasRoots + */ + public void setVamsasRoots(VAMSAS[] newroots) { + if (doc == null) { + log.debug("setVamsasRoots called on null document."); + return; + } + VAMSAS[] newr; + if (newroots == null) { + log.debug("setVamsasRoots(null) - do nothing."); + return; + } + // are we dealing with same array ? + if (_VamsasRoots != newroots) { + // merge roots into local version. + newr = new VAMSAS[newroots.length]; + for (int i = 0; i < newr.length; i++) + newr[i] = newroots[i]; + newr = _combineRoots(newr, _VamsasRoots, this); + } else { + newr = new VAMSAS[_VamsasRoots.length]; + for (int i = 0; i < newr.length; i++) + newr[i] = _VamsasRoots[i]; + } + // actually compare with document root set for final combination (to ensure + // nothing is lost) + _VamsasRoots = _combineRoots(newr, doc.getVAMSAS(), this); + } + + /* + * (non-Javadoc) LATER: decide: this affects the next call to getVamsasRoots() + * + * @see + * uk.ac.vamsas.client.IClientDocument#addVamsasRoot(uk.ac.vamsas.objects. + * core.VAMSAS) + */ + public void addVamsasRoot(VAMSAS newroot) { + if (doc == null) { + log.debug("addVamsasRoots called on null document."); + return; + } + VAMSAS[] newroots = _combineRoots(new VAMSAS[] { newroot }, _VamsasRoots, + this); + _VamsasRoots = newroots; + } + + public VamsasArchiveReader getReader() { + return reader; + } + + private void _finalize() { + log.debug("finalizing clientDoc"); + if (doc != null) { + doc = null; + } + if (_VamsasRoots != null) { + for (int i = 0; i < _VamsasRoots.length; i++) + _VamsasRoots[i] = null; + _VamsasRoots = null; + + } + + if (reader != null) { + log.debug("Closing and removing reader reference"); + reader.close(); + reader = null; + } + if (iohandler != null) { + log.debug("Removing ioHandler reference."); + iohandler.cancelArchive(); + iohandler = null; + } + } + + protected void finalize() throws Throwable { + _finalize(); + super.finalize(); + } + + private java.util.Hashtable objrefs = null; + + public VorbaId[] registerObjects(Vobject[] unregistered) { + if (doc == null) { + log.warn("registerObjects[] called on null document."); + return null; + } + if (objrefs == null) { + log.warn("registerObjects[] called for null objrefs hasharray."); + return null; + } + if (unregistered != null) { + VorbaId ids[] = new VorbaId[unregistered.length]; + for (int i = 0, k = unregistered.length; i < k; i++) + if (unregistered[i] != null) { + log.warn("Null Vobject passed to registerObject[] at position " + i); + return null; + } else { + ids[i] = registerObject(unregistered[i]); + } + log.debug("Registered " + unregistered.length + " objects - total of " + + objrefs.size() + " ids."); + return ids; + } + return null; + } + + /* + * (non-Javadoc) + * + * @see + * uk.ac.vamsas.client.IClientDocument#registerObject(uk.ac.vamsas.client. + * Vobject) + */ + public VorbaId registerObject(Vobject unregistered) { + if (doc == null) { + log.warn("registerObjects called on null document."); + return null; + } + if (objrefs == null) { + log.warn("registerObjects called for null objrefs hasharray."); + return null; + } + if (iohandler == null) { + log.warn("registerObjects called for read only document."); + return null; + } + + if (unregistered != null) { + VorbaId id = this._registerObject(unregistered); + log.debug("Registered object - total of " + objrefs.size() + " ids."); + return id; + } + log.warn("Null Vobject passed to registerObject."); + return null; + } + + /* + * (non-Javadoc) + * + * @see + * uk.ac.vamsas.client.IClientDocument#getObject(uk.ac.vamsas.client.VorbaId) + */ + public Vobject getObject(VorbaId id) { + if (objrefs == null) { + log.debug("getObject called on null objrefs list."); + return null; + } + if (objrefs.containsKey(id.getId())) + return (Vobject) objrefs.get(id.getId()); + log.debug("Returning null Vobject reference for id " + id.getId()); + return null; + } + + /* + * (non-Javadoc) + * + * @see + * uk.ac.vamsas.client.IClientDocument#getObjects(uk.ac.vamsas.client.VorbaId + * []) + */ + public Vobject[] getObjects(VorbaId[] ids) { + if (objrefs == null) { + log.debug("getObject[] called on null objrefs list."); + return null; + } + Vobject[] vo = new Vobject[ids.length]; + for (int i = 0, j = ids.length; i < j; i++) + if (objrefs.containsKey(ids[i])) + vo[i] = (Vobject) objrefs.get(ids[i]); + else + log.debug("Returning null Vobject reference for id " + ids[i].getId()); + return vo; + } + + protected void updateDocumentRoots() { + if (doc == null) { + log + .error("updateDocumentRoots called on null document. Probably an implementation error."); + return; + } + if (isModified) { + if (_VamsasRoots != null) { + doc.setVAMSAS(_VamsasRoots); + _VamsasRoots = null; + } + } + } + + /** + * tell vamsas client to close the document and reset the object. Once closed, + * nothing can be done with the object. + * + */ + public void closeDoc() { + if (doc != null) { + log.debug("Closing open document."); + _finalize(); + } else { + log.warn("Ignoring closeDoc on invalid document."); + } + } + +} diff --git a/src/uk/ac/vamsas/test/simpleclient/ClientsFileTest.java b/src/uk/ac/vamsas/test/simpleclient/ClientsFileTest.java index 9d76bfb..edbd855 100644 --- a/src/uk/ac/vamsas/test/simpleclient/ClientsFileTest.java +++ b/src/uk/ac/vamsas/test/simpleclient/ClientsFileTest.java @@ -1,311 +1,268 @@ -package uk.ac.vamsas.test.simpleclient; - -import java.io.File; -import java.util.Iterator; -import java.util.Vector; - - -import uk.ac.vamsas.client.ClientHandle; -import uk.ac.vamsas.client.simpleclient.ClientsFile; -import uk.ac.vamsas.client.simpleclient.FileWatcher; -import uk.ac.vamsas.client.simpleclient.Lock; - -public class ClientsFileTest { - private static CommandProcessor cproc; - - private static Vector commands; - static { - cproc = new CommandProcessor(); - ClientsFileTest.commands = new Vector(); - ClientsFileTest.commands.add(new String("add")); - cproc.addCommand("add", 2, "for the Client's 'Name' and 'Version'"); - ClientsFileTest.commands.add(new String("remove")); - cproc.addCommand("remove", 3, "for the Client's 'Name', Version and URN"); - ClientsFileTest.commands.add(new String("list")); - cproc.addCommand("list", 0, "no args needed"); - ClientsFileTest.commands.add(new String("clear")); - cproc.addCommand("clear", 0, "no args needed"); - ClientsFileTest.commands.add(new String("watch")); - cproc.addCommand("watch", 0, "no args needed"); - ClientsFileTest.commands.add(new String("monitor")); - cproc.addCommand("monitor", 2, "for the Client's 'Name' and 'Version'"); - } - - private static void complainArgs(int argl, int argpos, String cmd, - int argneed, String msg) { - if (argl - argpos < argneed) - throw new Error(cmd + " needs " + argneed + " arguments : " + msg); - } - - public static void main(String[] args) { - java.io.File cf = new java.io.File(args[0]); - System.out.println("Connecting to clientFile " + args[0]); - ClientsFile cfhand; - try { - cfhand = new ClientsFile(cf); - } catch (Exception e) { - e.printStackTrace(System.err); - return; - } - int argc = 1; - while (argc < args.length) { - // vars needed for operations - ClientHandle ch; - int com = cproc.getCommand(args, argc); - argc++; - switch (com) { - case 0: - // Add - int pos = cfhand.addClient(ch = new ClientHandle(args[argc], - args[argc + 1])); - argc += 2; - if (pos != 0) - System.out.println("Client added at " + pos + " as urn:" - + ch.getClientUrn()); - else - System.out.println("Client was not added."); - break; - case 1: - // remove - ch = new ClientHandle(args[argc], args[argc + 1]); - ch.setClientUrn(args[argc + 2]); - argc += 3; - cfhand.removeClient(ch, null); - System.out.println("Client removed (apparently)"); - break; - case 2: - // list - ClientHandle[] chlist = cfhand.retrieveClientList(); - if (chlist != null) { - for (int chi = 0, che = chlist.length; chi < che; chi++) { - System.out.println("Client " + chi + " (" - + chlist[chi].getClientName() + " " + chlist[chi].getVersion() - + " " + chlist[chi].getClientUrn() + ")"); - } - } else { - System.out.println("Client list is empty."); - } - break; - case 3: - // clear - //cfhand.get = null; - //cf.delete(); - try { - - cfhand.clearList(); - - } catch (Exception e) { - System.err.println("Failed on new empty clientfile creation!"); - e.printStackTrace(System.err); - } - break; - case 4: - // watch - FileWatcher w = new FileWatcher(cf); - while (cf.exists()) { - // get watcher's lock to ensure state change is fixed for retrieval - Lock chlock = w.getChangedState(); - if (chlock != null) { - ClientHandle[] cl = cfhand.retrieveClientList(chlock); - System.out.println("-- Watching " + cf.getName()); - //while (w.hasChanged()) - // ; - if (cl != null) { - for (int chi = 0, che = cl.length; chi < che; chi++) { - System.out.println("Client " + chi + " (" - + cl[chi].getClientName() + " " + cl[chi].getVersion() - + " " + cl[chi].getClientUrn() + ")"); - } - } else { - System.out.println("Client list is empty."); - } - } - - } - break; - case 5: - // monitor - int clpos = cfhand.addClient(ch = new ClientHandle(args[argc], - args[argc + 1])); - argc += 2; - if (clpos != 0) - System.out.println("Monitor Client added at " + clpos + " as urn:" - + ch.getClientUrn()); - else { - System.err.println("Monitor Client was not added."); - break; - } - FileWatcher mon = new FileWatcher(cf); - while (cf.exists()) { - // get watcher's lock to ensure state change is fixed for retrieval - Lock chlock = mon.getChangedState(); - if (chlock != null) { - ClientHandle[] cl = cfhand.retrieveClientList(chlock); - System.out.println("-- Monitor " + cf.getName()); - //while (w.hasChanged()) - // ; - int newpos = -1; - if (cl != null) { - for (int chi = 0, che = cl.length; chi < che; chi++) { - if (ch.equals(cl[chi])) - newpos = chi + 1; - } - } - if (newpos == -1) { - // add self again to cleared list. - newpos = cfhand.addClient(ch); - mon.setState(); - if (newpos == 0) { - System.err - .println("Monitor client could not be re-added to list."); - break; - } - } - if (newpos != clpos) { - System.out.println("Monitor client moved from " + clpos + " to " - + newpos); - clpos = newpos; - } - } - } - break; - default: - if (com == -1) { - System.err - .println("Unknown command : " + args[argc++] + "*Ignored!*"); - } else - System.err.println("Command " + args[argc++] - + " *Ignored!* - its not implemented."); - } - - for (int j = 0; j < 900000; j++) { - Integer i = Integer.getInteger("1"); - Integer q = i; - } - } - - } - - /* Iterator coms = commands.iterator(); - int com=-1; - while ((coms!=null) && coms.hasNext()) { - com++; - if (args[argc].toLowerCase().equals((String) coms.next())) { - System.out.println("Doing "+args[argc]); - ClientHandle ch; - argc++; - switch (com) { - case 0: - // Add - ClientsFileTest.complainArgs(args.length, argc, "add", 2, "for the Client's 'Name' and 'Version'"); - int pos = cfhand.addClient(ch=new ClientHandle(args[argc],args[argc+1])); - argc+=2; - if (pos!=0) - System.out.println("Client added at "+pos+" as urn:"+ch.getClientUrn()); - else - System.out.println("Client was not added."); - break; - case 1: - // remove - ClientsFileTest.complainArgs(args.length, argc, "remove", 3, "for the Client's 'Name', Version and URN"); - ch=new ClientHandle(args[argc], args[argc+1]); - ch.setClientUrn(args[argc+2]); - argc+=3; - cfhand.removeClient(ch, null); - System.out.println("Client removed (apparently)"); - break; - case 2: - // list - ClientHandle[] chlist = cfhand.retrieveClientList(); - if (chlist!=null) { - for (int chi=0,che=chlist.length; chi. + */ +package uk.ac.vamsas.test.simpleclient; + +import java.io.File; +import java.util.Iterator; +import java.util.Vector; + +import uk.ac.vamsas.client.ClientHandle; +import uk.ac.vamsas.client.simpleclient.ClientsFile; +import uk.ac.vamsas.client.simpleclient.FileWatcher; +import uk.ac.vamsas.client.simpleclient.Lock; + +public class ClientsFileTest { + private static CommandProcessor cproc; + + private static Vector commands; + static { + cproc = new CommandProcessor(); + ClientsFileTest.commands = new Vector(); + ClientsFileTest.commands.add(new String("add")); + cproc.addCommand("add", 2, "for the Client's 'Name' and 'Version'"); + ClientsFileTest.commands.add(new String("remove")); + cproc.addCommand("remove", 3, "for the Client's 'Name', Version and URN"); + ClientsFileTest.commands.add(new String("list")); + cproc.addCommand("list", 0, "no args needed"); + ClientsFileTest.commands.add(new String("clear")); + cproc.addCommand("clear", 0, "no args needed"); + ClientsFileTest.commands.add(new String("watch")); + cproc.addCommand("watch", 0, "no args needed"); + ClientsFileTest.commands.add(new String("monitor")); + cproc.addCommand("monitor", 2, "for the Client's 'Name' and 'Version'"); + } + + private static void complainArgs(int argl, int argpos, String cmd, + int argneed, String msg) { + if (argl - argpos < argneed) + throw new Error(cmd + " needs " + argneed + " arguments : " + msg); + } + + public static void main(String[] args) { + java.io.File cf = new java.io.File(args[0]); + System.out.println("Connecting to clientFile " + args[0]); + ClientsFile cfhand; + try { + cfhand = new ClientsFile(cf); + } catch (Exception e) { + e.printStackTrace(System.err); + return; + } + int argc = 1; + while (argc < args.length) { + // vars needed for operations + ClientHandle ch; + int com = cproc.getCommand(args, argc); + argc++; + switch (com) { + case 0: + // Add + int pos = cfhand.addClient(ch = new ClientHandle(args[argc], + args[argc + 1])); + argc += 2; + if (pos != 0) + System.out.println("Client added at " + pos + " as urn:" + + ch.getClientUrn()); + else + System.out.println("Client was not added."); + break; + case 1: + // remove + ch = new ClientHandle(args[argc], args[argc + 1]); + ch.setClientUrn(args[argc + 2]); + argc += 3; + cfhand.removeClient(ch, null); + System.out.println("Client removed (apparently)"); + break; + case 2: + // list + ClientHandle[] chlist = cfhand.retrieveClientList(); + if (chlist != null) { + for (int chi = 0, che = chlist.length; chi < che; chi++) { + System.out.println("Client " + chi + " (" + + chlist[chi].getClientName() + " " + chlist[chi].getVersion() + + " " + chlist[chi].getClientUrn() + ")"); + } + } else { + System.out.println("Client list is empty."); + } + break; + case 3: + // clear + // cfhand.get = null; + // cf.delete(); + try { + + cfhand.clearList(); + + } catch (Exception e) { + System.err.println("Failed on new empty clientfile creation!"); + e.printStackTrace(System.err); + } + break; + case 4: + // watch + FileWatcher w = new FileWatcher(cf); + while (cf.exists()) { + // get watcher's lock to ensure state change is fixed for retrieval + Lock chlock = w.getChangedState(); + if (chlock != null) { + ClientHandle[] cl = cfhand.retrieveClientList(chlock); + System.out.println("-- Watching " + cf.getName()); + // while (w.hasChanged()) + // ; + if (cl != null) { + for (int chi = 0, che = cl.length; chi < che; chi++) { + System.out.println("Client " + chi + " (" + + cl[chi].getClientName() + " " + cl[chi].getVersion() + + " " + cl[chi].getClientUrn() + ")"); + } + } else { + System.out.println("Client list is empty."); + } + } + + } + break; + case 5: + // monitor + int clpos = cfhand.addClient(ch = new ClientHandle(args[argc], + args[argc + 1])); + argc += 2; + if (clpos != 0) + System.out.println("Monitor Client added at " + clpos + " as urn:" + + ch.getClientUrn()); + else { + System.err.println("Monitor Client was not added."); + break; + } + FileWatcher mon = new FileWatcher(cf); + while (cf.exists()) { + // get watcher's lock to ensure state change is fixed for retrieval + Lock chlock = mon.getChangedState(); + if (chlock != null) { + ClientHandle[] cl = cfhand.retrieveClientList(chlock); + System.out.println("-- Monitor " + cf.getName()); + // while (w.hasChanged()) + // ; + int newpos = -1; + if (cl != null) { + for (int chi = 0, che = cl.length; chi < che; chi++) { + if (ch.equals(cl[chi])) + newpos = chi + 1; + } + } + if (newpos == -1) { + // add self again to cleared list. + newpos = cfhand.addClient(ch); + mon.setState(); + if (newpos == 0) { + System.err + .println("Monitor client could not be re-added to list."); + break; + } + } + if (newpos != clpos) { + System.out.println("Monitor client moved from " + clpos + " to " + + newpos); + clpos = newpos; + } + } + } + break; + default: + if (com == -1) { + System.err + .println("Unknown command : " + args[argc++] + "*Ignored!*"); + } else + System.err.println("Command " + args[argc++] + + " *Ignored!* - its not implemented."); + } + + for (int j = 0; j < 900000; j++) { + Integer i = Integer.getInteger("1"); + Integer q = i; + } + } + + } + + /* + * Iterator coms = commands.iterator(); int com=-1; while ((coms!=null) && + * coms.hasNext()) { com++; if (args[argc].toLowerCase().equals((String) + * coms.next())) { System.out.println("Doing "+args[argc]); ClientHandle ch; + * argc++; switch (com) { case 0: // Add + * ClientsFileTest.complainArgs(args.length, argc, "add", 2, + * "for the Client's 'Name' and 'Version'"); int pos = cfhand.addClient(ch=new + * ClientHandle(args[argc],args[argc+1])); argc+=2; if (pos!=0) + * System.out.println("Client added at "+pos+" as urn:"+ch.getClientUrn()); + * else System.out.println("Client was not added."); break; case 1: // remove + * ClientsFileTest.complainArgs(args.length, argc, "remove", 3, + * "for the Client's 'Name', Version and URN"); ch=new + * ClientHandle(args[argc], args[argc+1]); ch.setClientUrn(args[argc+2]); + * argc+=3; cfhand.removeClient(ch, null); + * System.out.println("Client removed (apparently)"); break; case 2: // list + * ClientHandle[] chlist = cfhand.retrieveClientList(); if (chlist!=null) { + * for (int chi=0,che=chlist.length; chi2) - complainArgs(args.length, argc+1, comnext); - return com; - } - } - return -1; - - } -} +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ +package uk.ac.vamsas.test.simpleclient; + +import java.util.Iterator; +import java.util.Vector; + +public class CommandProcessor { + /** + * this is not getOPT!!!! - processes a *series* of space separated commands - + * some of which take arguments. + */ + private Vector commands; + + /* + * static { ClientsFileTest.commands=new Vector(); + * ClientsFileTest.commands.add(new String("add")); + * ClientsFileTest.commands.add(new String("remove")); + * ClientsFileTest.commands.add(new String("list")); + * ClientsFileTest.commands.add(new String("clear")); + * ClientsFileTest.commands.add(new String("watch")); + * ClientsFileTest.commands.add(new String("monitor")); } + */ + + public int addCommand(String cmd, int argneed, String complainString) { + int cnum = 0; + if (commands == null) + commands = new Vector(); + else + cnum = commands.size(); + Vector cv = new Vector(); + cv.add(new String(cmd)); + cv.add(new Integer(argneed)); + cv.add(new String(complainString)); + commands.add(cv); + return cnum; + } + + /** + * Integer argl, Integer argpos, String cmd, Integer argneed, String msg in + * vector + */ + public void complainArgs(int argl, int argpos, Vector ca) { + int argneed = ((Integer) ca.get(1)).intValue(); + if (argl - argpos < argneed) + throw new Error(((String) ca.get(0)) + " at position " + argpos + + " needs " + argneed + " arguments : " + (String) ca.get(2)); + } + + /** + * find and verify a command + * + * @param args + * argstring + * @param argpos + * position to check for command + * @return matching command or -1 + */ + public int getCommand(String[] args, int argpos) { + Iterator coms = commands.iterator(); + int com = -1, argc; + argc = argpos; + while ((coms != null) && coms.hasNext()) { + com++; + Vector comnext = (Vector) coms.next(); + if (args[argc].toLowerCase().equals((String) comnext.get(0))) { + if (comnext.size() > 2) + complainArgs(args.length, argc + 1, comnext); + return com; + } + } + return -1; + + } +} diff --git a/src/uk/ac/vamsas/test/simpleclient/TestSessionURN.java b/src/uk/ac/vamsas/test/simpleclient/TestSessionURN.java index e0759e2..b7434d3 100644 --- a/src/uk/ac/vamsas/test/simpleclient/TestSessionURN.java +++ b/src/uk/ac/vamsas/test/simpleclient/TestSessionURN.java @@ -1,29 +1,49 @@ -package uk.ac.vamsas.test.simpleclient; - -import java.io.File; - -import uk.ac.vamsas.client.simpleclient.SessionUrn; - -/** - * Tests simple client sessionURN creation - * - * - */ -public class TestSessionURN { - - public static void main (String [] arg) throws Exception - { - String file = null; - if (arg == null || arg.length ==0) - file = "."; - else - file = arg[0]; - - File f = new File (file); - SessionUrn urn = new SessionUrn(f); - System.out.println("urn "+urn.getSessionUrn()); - System.out.println("urn file "+ urn.asFile().getAbsolutePath()); - System.out.println("urn file exists?"+ urn.asFile().exists()); - } - -} +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ +package uk.ac.vamsas.test.simpleclient; + +import java.io.File; + +import uk.ac.vamsas.client.simpleclient.SessionUrn; + +/** + * Tests simple client sessionURN creation + * + * + */ +public class TestSessionURN { + + public static void main(String[] arg) throws Exception { + String file = null; + if (arg == null || arg.length == 0) + file = "."; + else + file = arg[0]; + + File f = new File(file); + SessionUrn urn = new SessionUrn(f); + System.out.println("urn " + urn.getSessionUrn()); + System.out.println("urn file " + urn.asFile().getAbsolutePath()); + System.out.println("urn file exists?" + urn.asFile().exists()); + } + +} diff --git a/src/uk/ac/vamsas/test/simpleclient/VamsasArchive.java b/src/uk/ac/vamsas/test/simpleclient/VamsasArchive.java index 175c2bc..fe83f66 100644 --- a/src/uk/ac/vamsas/test/simpleclient/VamsasArchive.java +++ b/src/uk/ac/vamsas/test/simpleclient/VamsasArchive.java @@ -1,239 +1,273 @@ -package uk.ac.vamsas.test.simpleclient; - -import java.io.File; -import java.io.ObjectOutputStream; -import java.io.RandomAccessFile; -import java.util.jar.JarFile; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import uk.ac.vamsas.client.simpleclient.Lock; -import uk.ac.vamsas.client.simpleclient.SessionFile; -import uk.ac.vamsas.client.simpleclient.SimpleDocument; -import uk.ac.vamsas.client.simpleclient.VamsasArchiveReader; -import uk.ac.vamsas.client.simpleclient.VamsasFile; -import uk.ac.vamsas.objects.core.ApplicationData; -import uk.ac.vamsas.objects.core.User; -import uk.ac.vamsas.objects.core.VAMSAS; -import uk.ac.vamsas.objects.core.VamsasDocument; -import uk.ac.vamsas.test.objects.Core; - -public class VamsasArchive { - /** - * test the org.vamsas.simpleclient.vamsasArchive class - */ - static Log log = LogFactory.getLog(VamsasArchive.class); - public static ApplicationData makeDemoAppdata(uk.ac.vamsas.client.simpleclient.VamsasArchive va, String apname, String userName, String userOrg) { - if (va==null) - return null; - VamsasArchiveReader vread=null; - try { - vread = va.getOriginalArchiveReader(); - } - catch (Exception e) { - log.error("Failed to get original archive reader!",e); - return null; - } - ApplicationData appdata = new ApplicationData(); - appdata.setName("uk.ac.vamsas.test.simpleclient.VamsasArchive"); - appdata.setData(new String("this is some test data.").getBytes()); - User apuser = new User(); - apuser.setFullname(userName); - apuser.setOrganization(userOrg); - String appdata_ref = "vamsas:"+apname+"/"+apuser.getOrganization()+"/"+apuser.getFullname(); - SimpleDocument sdoc = new SimpleDocument("test.simpleclient.VamsasArchive"); - if (vread!=null) { - VamsasDocument orignalnew; - try { - orignalnew = sdoc.getVamsasDocument(vread); - log.info("*** Dump follows ***"); - - ArchiveReports.reportDocument(orignalnew, vread, false, System.out); - log.info("*** Dump precedes ***"); - } catch (Exception e) { - log.info("makeDemoAppdata: Problems accessing original document"); - } - - log.info("Reading (and avoiding references to) original data"); - if (vread.getAppdataStream(appdata_ref)!=null) { - // transfer over - try { - va.transferAppDataEntry(appdata_ref); - } catch (Exception e) { - log.warn("Exception when transferring appdata reference : "+appdata_ref, e); - } - int i=0; - while (vread.getAppdataStream(appdata_ref+"/"+Integer.toString(++i))!=null) { - try { - // copy over another duplicate. - va.transferAppDataEntry(appdata_ref+"/"+Integer.toString(i)); - } catch (Exception e) { - log.warn("Exception when transferring appdata reference : "+appdata_ref, e); - } - } - // this one must be unique! - appdata_ref+="/"+Integer.toString(i); - } - } - - log.info("Adding new data stuff."); - log.info("Writing an apdata reference using AppDataStream interface."); - apuser.setDataReference(appdata_ref); - appdata.addUser(apuser); - appdata.setVersion("noggin"); - //TODO: write instance appdata appdata.setUrn("program:/the.nog/"); - try { - ObjectOutputStream ost = new ObjectOutputStream(va.getAppDataStream(appdata_ref)); - ost.writeObject(appdata); - ost.close(); - } catch (Exception e) { - log.warn("Couldn't write appdata reference "+appdata_ref); - } - return appdata; - } - public static void main(String args[]) { - - try { - File av; - if (args.length>0) - av = new File(args[0]); - else - av = new File("test/vamsas.zip"); - try { - RandomAccessFile raf = new RandomAccessFile(av, "r"); - raf.readByte(); - raf.close(); - } catch (Exception f) - { - log.info("Couldn't random access file archive "+av, f); - } - try { - JarFile jf = new JarFile(av, true, JarFile.OPEN_READ); - if (jf.getEntry("vamsasDocument.xml")!=null) - { - log.info("Valid archive (sun) "+av); - } - jf.close(); - } catch (Exception f) - { - log.warn("Couldn't access jar archive with sun jartools: "+av, f); - } - try { - org.apache.tools.zip.ZipFile jf = new org.apache.tools.zip.ZipFile(av); - if (jf.getEntry("vamsasDocument.xml")!=null) - { - log.info("Valid archive (apache) "+av); - } - jf.close(); - } catch (Exception f) - { - log.warn("Couldn't access jar archive with apache ziptool: "+av,f); - } - - log.info("Opening archive "+av); - uk.ac.vamsas.client.simpleclient.VamsasArchive varchive = new uk.ac.vamsas.client.simpleclient.VamsasArchive(av, true); - - VAMSAS[] roots = (VAMSAS[]) varchive.getOriginalRoots(); - - if (roots!=null) { - log.info("Report on Original roots in archive:"); - ArchiveReports.rootReport(roots, true, System.out); - } - log.info("Getting current vamsas document."); - VamsasDocument doc = varchive.getVamsasDocument(); - ArchiveReports.reportDocument(doc, varchive.getOriginalArchiveReader(), true, System.out); // not modified document so references will still be valid - // do some stuff - log.info("Retrieving backup"); - File backup = varchive.backupFile(); - if (backup==null) - log.info(av+" is a New Archive."); - else - log.info(av+" has been backed up as "+backup); - File newf=new File(av.getAbsolutePath()+"_new.zip"); - VamsasFile sfile = new VamsasFile(newf); - /* if (newf.exists()) { - int q=1; - do { - newf=new File(av.getAbsolutePath()+"_"+q+++"_new.zip"); - } - while (newf.exists()); - } */ - if (newf.exists()) { - log.info("Removing existing "+newf); - newf.delete(); - } - - log.info("Now writing new Archive into "+newf.getAbsolutePath()); - uk.ac.vamsas.client.simpleclient.VamsasArchive va=null; - { // hold lock over deletion and write of new archive. - //Lock wlock = sfile.getLock(); - //newf.delete(); // clear out old file. - sfile.getLock(); - va = new uk.ac.vamsas.client.simpleclient.VamsasArchive(newf, true, true, sfile); - // open another and... - ApplicationData appdata = makeDemoAppdata(va, - "uk.ac.vamsas.test.simpleclient.VamsasArchive", "arnold Bugger esq", "disOrganised"); - log.info("Preparing to write new document."); - doc.addApplicationData(appdata); - doc.addVAMSAS(Core.getDemoVamsas()); - va.putVamsasDocument(doc); // gets stream and puts it. - va.closeArchive(); - sfile.unLock(); - } - log.info("Dump of new vamsas document :"); - log.info("Testing update: "); - { - Lock lock=sfile.getLock(); - if (lock==null) - while ((lock=sfile.getLock())==null) { - log.info("Waiting for lock."); - Thread.sleep(100); - } - VamsasArchiveReader vreader = new VamsasArchiveReader(sfile.getVamsasFile());// lock); // cannot do new JarFile on a locked file. // newf); - SimpleDocument sdoc = new SimpleDocument("testing new vamsas write"); - ArchiveReports.reportDocument(sdoc.getVamsasDocument(vreader), vreader, true, System.out); - sfile.unLock(); - } - // backup.delete(); // tidy up - - log.info("Now Cancelling write to original archive "+av); - if (varchive.cancelArchive()) - log.info("Successfully cancelled."); - else - log.info("Didn't cancel."); - long t=System.currentTimeMillis()+200; while (t>System.currentTimeMillis()); - log.info("Now testing archive update."); - va = new uk.ac.vamsas.client.simpleclient.VamsasArchive(newf, false, true, sfile); - doc = va.getVamsasDocument(); - doc.addVAMSAS(Core.getDemoVamsas()); - doc.addApplicationData(makeDemoAppdata(va, - "uk.ac.vamsas.test.simpleclient.VamsasArchive", "another old Bugger esq", "rescinded")); - if (va.transferRemainingAppDatas()) - log.info("Remain appdatas were transferred."); - else - log.warn("No appdatas were transferred. This is wrong."); - va.putVamsasDocument(doc); - va.closeArchive(); - sfile.unLock(); - log.info("Testing update: "); - { - Lock lock=sfile.getLock(); - if (lock==null) - while ((lock=sfile.getLock())==null) - log.info("Waiting for lock."); - // VamsasArchiveReader vreader = new VamsasArchiveReader(lock); - VamsasArchiveReader vreader = new VamsasArchiveReader(newf); - - SimpleDocument sdoc = new SimpleDocument("testing vamsas update"); - VamsasDocument finaldoc = sdoc.getVamsasDocument(vreader); - if (finaldoc!=null) - ArchiveReports.reportDocument(finaldoc, vreader, true, System.out); - else - log.error("Null Document Read from "+newf); - } - } catch (Exception e) { - e.printStackTrace(System.err); - } - } -} +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ +package uk.ac.vamsas.test.simpleclient; + +import java.io.File; +import java.io.ObjectOutputStream; +import java.io.RandomAccessFile; +import java.util.jar.JarFile; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import uk.ac.vamsas.client.simpleclient.Lock; +import uk.ac.vamsas.client.simpleclient.SessionFile; +import uk.ac.vamsas.client.simpleclient.SimpleDocument; +import uk.ac.vamsas.client.simpleclient.VamsasArchiveReader; +import uk.ac.vamsas.client.simpleclient.VamsasFile; +import uk.ac.vamsas.objects.core.ApplicationData; +import uk.ac.vamsas.objects.core.User; +import uk.ac.vamsas.objects.core.VAMSAS; +import uk.ac.vamsas.objects.core.VamsasDocument; +import uk.ac.vamsas.test.objects.Core; + +public class VamsasArchive { + /** + * test the org.vamsas.simpleclient.vamsasArchive class + */ + static Log log = LogFactory.getLog(VamsasArchive.class); + + public static ApplicationData makeDemoAppdata( + uk.ac.vamsas.client.simpleclient.VamsasArchive va, String apname, + String userName, String userOrg) { + if (va == null) + return null; + VamsasArchiveReader vread = null; + try { + vread = va.getOriginalArchiveReader(); + } catch (Exception e) { + log.error("Failed to get original archive reader!", e); + return null; + } + ApplicationData appdata = new ApplicationData(); + appdata.setName("uk.ac.vamsas.test.simpleclient.VamsasArchive"); + appdata.setData(new String("this is some test data.").getBytes()); + User apuser = new User(); + apuser.setFullname(userName); + apuser.setOrganization(userOrg); + String appdata_ref = "vamsas:" + apname + "/" + apuser.getOrganization() + + "/" + apuser.getFullname(); + SimpleDocument sdoc = new SimpleDocument("test.simpleclient.VamsasArchive"); + if (vread != null) { + VamsasDocument orignalnew; + try { + orignalnew = sdoc.getVamsasDocument(vread); + log.info("*** Dump follows ***"); + + ArchiveReports.reportDocument(orignalnew, vread, false, System.out); + log.info("*** Dump precedes ***"); + } catch (Exception e) { + log.info("makeDemoAppdata: Problems accessing original document"); + } + + log.info("Reading (and avoiding references to) original data"); + if (vread.getAppdataStream(appdata_ref) != null) { + // transfer over + try { + va.transferAppDataEntry(appdata_ref); + } catch (Exception e) { + log.warn("Exception when transferring appdata reference : " + + appdata_ref, e); + } + int i = 0; + while (vread + .getAppdataStream(appdata_ref + "/" + Integer.toString(++i)) != null) { + try { + // copy over another duplicate. + va.transferAppDataEntry(appdata_ref + "/" + Integer.toString(i)); + } catch (Exception e) { + log.warn("Exception when transferring appdata reference : " + + appdata_ref, e); + } + } + // this one must be unique! + appdata_ref += "/" + Integer.toString(i); + } + } + + log.info("Adding new data stuff."); + log.info("Writing an apdata reference using AppDataStream interface."); + apuser.setDataReference(appdata_ref); + appdata.addUser(apuser); + appdata.setVersion("noggin"); + // TODO: write instance appdata appdata.setUrn("program:/the.nog/"); + try { + ObjectOutputStream ost = new ObjectOutputStream(va + .getAppDataStream(appdata_ref)); + ost.writeObject(appdata); + ost.close(); + } catch (Exception e) { + log.warn("Couldn't write appdata reference " + appdata_ref); + } + return appdata; + } + + public static void main(String args[]) { + + try { + File av; + if (args.length > 0) + av = new File(args[0]); + else + av = new File("test/vamsas.zip"); + try { + RandomAccessFile raf = new RandomAccessFile(av, "r"); + raf.readByte(); + raf.close(); + } catch (Exception f) { + log.info("Couldn't random access file archive " + av, f); + } + try { + JarFile jf = new JarFile(av, true, JarFile.OPEN_READ); + if (jf.getEntry("vamsasDocument.xml") != null) { + log.info("Valid archive (sun) " + av); + } + jf.close(); + } catch (Exception f) { + log.warn("Couldn't access jar archive with sun jartools: " + av, f); + } + try { + org.apache.tools.zip.ZipFile jf = new org.apache.tools.zip.ZipFile(av); + if (jf.getEntry("vamsasDocument.xml") != null) { + log.info("Valid archive (apache) " + av); + } + jf.close(); + } catch (Exception f) { + log.warn("Couldn't access jar archive with apache ziptool: " + av, f); + } + + log.info("Opening archive " + av); + uk.ac.vamsas.client.simpleclient.VamsasArchive varchive = new uk.ac.vamsas.client.simpleclient.VamsasArchive( + av, true); + + VAMSAS[] roots = (VAMSAS[]) varchive.getOriginalRoots(); + + if (roots != null) { + log.info("Report on Original roots in archive:"); + ArchiveReports.rootReport(roots, true, System.out); + } + log.info("Getting current vamsas document."); + VamsasDocument doc = varchive.getVamsasDocument(); + ArchiveReports.reportDocument(doc, varchive.getOriginalArchiveReader(), + true, System.out); // not modified document so references will still + // be valid + // do some stuff + log.info("Retrieving backup"); + File backup = varchive.backupFile(); + if (backup == null) + log.info(av + " is a New Archive."); + else + log.info(av + " has been backed up as " + backup); + File newf = new File(av.getAbsolutePath() + "_new.zip"); + VamsasFile sfile = new VamsasFile(newf); + /* + * if (newf.exists()) { int q=1; do { newf=new + * File(av.getAbsolutePath()+"_"+q+++"_new.zip"); } while (newf.exists()); + * } + */ + if (newf.exists()) { + log.info("Removing existing " + newf); + newf.delete(); + } + + log.info("Now writing new Archive into " + newf.getAbsolutePath()); + uk.ac.vamsas.client.simpleclient.VamsasArchive va = null; + { // hold lock over deletion and write of new archive. + // Lock wlock = sfile.getLock(); + // newf.delete(); // clear out old file. + sfile.getLock(); + va = new uk.ac.vamsas.client.simpleclient.VamsasArchive(newf, true, + true, sfile); + // open another and... + ApplicationData appdata = makeDemoAppdata(va, + "uk.ac.vamsas.test.simpleclient.VamsasArchive", + "arnold Bugger esq", "disOrganised"); + log.info("Preparing to write new document."); + doc.addApplicationData(appdata); + doc.addVAMSAS(Core.getDemoVamsas()); + va.putVamsasDocument(doc); // gets stream and puts it. + va.closeArchive(); + sfile.unLock(); + } + log.info("Dump of new vamsas document :"); + log.info("Testing update: "); + { + Lock lock = sfile.getLock(); + if (lock == null) + while ((lock = sfile.getLock()) == null) { + log.info("Waiting for lock."); + Thread.sleep(100); + } + VamsasArchiveReader vreader = new VamsasArchiveReader(sfile + .getVamsasFile());// lock); // cannot do new JarFile on a locked + // file. // newf); + SimpleDocument sdoc = new SimpleDocument("testing new vamsas write"); + ArchiveReports.reportDocument(sdoc.getVamsasDocument(vreader), vreader, + true, System.out); + sfile.unLock(); + } + // backup.delete(); // tidy up + + log.info("Now Cancelling write to original archive " + av); + if (varchive.cancelArchive()) + log.info("Successfully cancelled."); + else + log.info("Didn't cancel."); + long t = System.currentTimeMillis() + 200; + while (t > System.currentTimeMillis()) + ; + log.info("Now testing archive update."); + va = new uk.ac.vamsas.client.simpleclient.VamsasArchive(newf, false, + true, sfile); + doc = va.getVamsasDocument(); + doc.addVAMSAS(Core.getDemoVamsas()); + doc.addApplicationData(makeDemoAppdata(va, + "uk.ac.vamsas.test.simpleclient.VamsasArchive", + "another old Bugger esq", "rescinded")); + if (va.transferRemainingAppDatas()) + log.info("Remain appdatas were transferred."); + else + log.warn("No appdatas were transferred. This is wrong."); + va.putVamsasDocument(doc); + va.closeArchive(); + sfile.unLock(); + log.info("Testing update: "); + { + Lock lock = sfile.getLock(); + if (lock == null) + while ((lock = sfile.getLock()) == null) + log.info("Waiting for lock."); + // VamsasArchiveReader vreader = new VamsasArchiveReader(lock); + VamsasArchiveReader vreader = new VamsasArchiveReader(newf); + + SimpleDocument sdoc = new SimpleDocument("testing vamsas update"); + VamsasDocument finaldoc = sdoc.getVamsasDocument(vreader); + if (finaldoc != null) + ArchiveReports.reportDocument(finaldoc, vreader, true, System.out); + else + log.error("Null Document Read from " + newf); + } + } catch (Exception e) { + e.printStackTrace(System.err); + } + } +} diff --git a/src/uk/ac/vamsas/test/simpleclient/ZipTest.java b/src/uk/ac/vamsas/test/simpleclient/ZipTest.java index a860e0e..847d8fb 100644 --- a/src/uk/ac/vamsas/test/simpleclient/ZipTest.java +++ b/src/uk/ac/vamsas/test/simpleclient/ZipTest.java @@ -1,48 +1,68 @@ +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ package uk.ac.vamsas.test.simpleclient; import java.io.File; import java.util.jar.JarFile; + /** - * really simple test to see if we can open an archive and test for the existence of - * an entry called vamssDocument.xml. + * really simple test to see if we can open an archive and test for the + * existence of an entry called vamssDocument.xml. * - * 'Pathological' archives fail this test (due to things like funny characters or lots of '.' in the entry name. + * 'Pathological' archives fail this test (due to things like funny characters + * or lots of '.' in the entry name. * * @author JimP - * + * */ public class ZipTest { /** - * @param args single filename as an argument to open as a Jar file. + * @param args + * single filename as an argument to open as a Jar file. */ public static void main(String[] args) { File av = new File(args[0]); - boolean jfailed=false; + boolean jfailed = false; try { JarFile jf = new JarFile(av, false, JarFile.OPEN_READ); - if (jf.getEntry("vamsasDocument.xml")!=null) - { - System.out.println("Valid archive "+av); + if (jf.getEntry("vamsasDocument.xml") != null) { + System.out.println("Valid archive " + av); } jf.close(); return; - } catch (Exception f) - { - System.out.println("Couldn't access jar archive "+av); + } catch (Exception f) { + System.out.println("Couldn't access jar archive " + av); f.printStackTrace(System.out); } try { System.out.println("Trying the Apache Zip Package:"); org.apache.tools.zip.ZipFile jf = new org.apache.tools.zip.ZipFile(av); - if (jf.getEntry("vamsasDocument.xml")!=null) - { - System.out.println("Valid archive "+av); + if (jf.getEntry("vamsasDocument.xml") != null) { + System.out.println("Valid archive " + av); } jf.close(); - } catch (Exception f) - { - System.out.println("Couldn't access jar archive "+av); + } catch (Exception f) { + System.out.println("Couldn't access jar archive " + av); f.printStackTrace(System.out); } } diff --git a/src/uk/ac/vamsas/test/simpleclient/simpleapp/VamsasClient.java b/src/uk/ac/vamsas/test/simpleclient/simpleapp/VamsasClient.java index d4b9ec0..67db315 100644 --- a/src/uk/ac/vamsas/test/simpleclient/simpleapp/VamsasClient.java +++ b/src/uk/ac/vamsas/test/simpleclient/simpleapp/VamsasClient.java @@ -1,187 +1,243 @@ -/** - * - */ -package uk.ac.vamsas.test.simpleclient.simpleapp; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.OutputStreamWriter; -import java.io.PrintWriter; -import java.util.Hashtable; -import java.util.IdentityHashMap; -import java.util.Vector; -import java.util.jar.JarOutputStream; - -import javax.swing.JInternalFrame; - - -import uk.ac.vamsas.client.UserHandle; -import uk.ac.vamsas.client.simpleclient.FileWatcher; -import uk.ac.vamsas.client.simpleclient.VamsasArchive; -import uk.ac.vamsas.client.simpleclient.VamsasFile; -import uk.ac.vamsas.objects.core.Entry; -import uk.ac.vamsas.objects.core.VamsasDocument; -import uk.ac.vamsas.test.simpleclient.ArchiveClient; -import uk.ac.vamsas.test.simpleclient.ClientDoc; - -/** - * @author jimp - * - */ -public class VamsasClient extends ArchiveClient { - org.apache.commons.logging.Log log=org.apache.commons.logging.LogFactory.getLog(VamsasClient.class); - /** - * create a new vamsas client session from the archive at sessionPath. - * @param sessionPath - */ - public VamsasClient(File sessionPath) { - super(System.getProperty("user.name"),System.getProperty("host.name"), "SimpleVamsasClientApp","0.1", - sessionPath); - } - /** - * Called by gui to read anything from the vamsas session into the apps datamodel - * after it has started up. - * - */ - public void initial_update() { - log.info("Jalview loading the Vamsas Session."); - // load in the vamsas archive for the first time - ClientDoc cdoc = this.getUpdateable(); - updateJalview(cdoc); - // TODO: flush any new VorbaIds to the document : updateVamsasClient may actually generate new Vamsas Document data in the form of vamsas element ids - these should be written back to the document. - //doUpdate(cdoc); // JBPNote: this should flush new VorbaIds but I've not tested it yet. - cdoc.closeDoc(); - // then tell app to update its display based on the datamodel changes. - } - VamsasClientWatcher watcher=null; - /** - * Called by app when internal datamodel should exported (syncrhonised outwards) to vamsas document - * - */ - public void push_update() { - - watchForChange=false; // this makes any watch(long) loops return. - // we should also wait arount for this.WATCH_SLEEP to really make sure the watcher thread has stopped. - try { - Thread.sleep(WATCH_SLEEP); - } catch (Exception e) { - - }; - - ClientDoc cdoc = getUpdateable(); - updateVamsasDocument(cdoc); - doUpdate(cdoc); - cdoc.closeDoc(); - cdoc=null; - watchForChange=true; - startWatcher(); - } - public void end_session() { - watchForChange=false; // this makes any watch(long) loops return. - // we should also wait arount for this.WATCH_SLEEP to really make sure the watcher thread has stopped. - try { - Thread.sleep(WATCH_SLEEP); - } catch (Exception e) { - - }; - - // stop any update/watcher thread. - log.info("VamsasClientApplication disconnecting from the Vamsas Session."); - } - public void updateJalview(ClientDoc cdoc) { - ensureVamsasBindings(); - VamsasDatastore vds = new VamsasDatastore(cdoc, vobj2jv, jv2vobj, baseProvEntry()); - vds.updateToJalview(); - } - private void ensureVamsasBindings() { - if (jv2vobj==null) { - jv2vobj = new IdentityHashMap(); - vobj2jv = new Hashtable(); - } - } - /** - * App's object binding to VorbaIds - */ - IdentityHashMap jv2vobj = null; - Hashtable vobj2jv = null; - /** - * called with a vamsas document which will be updated with new data from the app - * @param doc - */ - public void updateVamsasDocument(ClientDoc doc) { - ensureVamsasBindings(); - VamsasDatastore vds = new VamsasDatastore(doc, vobj2jv, jv2vobj, baseProvEntry()); - // wander through frames - vds.storeVAMSAS(new Object()); // Object is the apps datamodel ;) - } - /** - * - * @return a base provenance entry used by the VamsasDatastore object to get attributes from. this isn't particularly elegant either. - */ - private Entry baseProvEntry() { - uk.ac.vamsas.objects.core.Entry pentry = new uk.ac.vamsas.objects.core.Entry(); - pentry.setUser(this.getProvenanceUser()); - pentry.setApp(this.getClientHandle().getClientName()); - pentry.setDate(new java.util.Date()); - pentry.setAction("created"); - return pentry; - } - protected class VamsasClientWatcher extends Thread implements Runnable { - /* (non-Javadoc) - * @see java.lang.Thread#run() - */ - VamsasClient client=null; - VamsasClientWatcher(VamsasClient client) { - this.client = client; - } - boolean running=false; - public void run() { - running=true; - while (client.watchForChange) { - ClientDoc docio = client.watch(0); - if (docio!=null) { - // VamsasClient GUI bits should be disabled whilst an update is in progress so the user doesn't screw anything up. - client.disableGui(true); - log.debug("Updating VamsasClient app from changed vamsas document."); - client.updateJalview(docio); - log.debug("Finished updating from document change."); - docio.closeDoc(); - docio=null; - client.disableGui(false); - } - } - running=false; - - } - - } - /** - * @param args - */ - public static void main(String[] args) { - // TODO Auto-generated method stub - - } - /** - * disable (if b is true) or enable (if b is true) the VamsasClient's vamsas session gui bits whilst a document change is being updated to the app. - * @param b - */ - public void disableGui(boolean b) { - // in jalview, we turn off the VAMSAS Session menu : Desktop.instance.setVamsasUpdate(b); - } - /** - * spawn a new thread to start the VamsasClientWatcher. - * - */ - public void startWatcher() { - if (watcher==null) - watcher=new VamsasClientWatcher(this); - Thread thr = new Thread() { - public void run() { - watcher.start(); - } - }; - thr.start(); - } - -} +/* + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . + */ +package uk.ac.vamsas.test.simpleclient.simpleapp; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.OutputStreamWriter; +import java.io.PrintWriter; +import java.util.Hashtable; +import java.util.IdentityHashMap; +import java.util.Vector; +import java.util.jar.JarOutputStream; + +import javax.swing.JInternalFrame; + +import uk.ac.vamsas.client.UserHandle; +import uk.ac.vamsas.client.simpleclient.FileWatcher; +import uk.ac.vamsas.client.simpleclient.VamsasArchive; +import uk.ac.vamsas.client.simpleclient.VamsasFile; +import uk.ac.vamsas.objects.core.Entry; +import uk.ac.vamsas.objects.core.VamsasDocument; +import uk.ac.vamsas.test.simpleclient.ArchiveClient; +import uk.ac.vamsas.test.simpleclient.ClientDoc; + +/** + * @author jimp + * + */ +public class VamsasClient extends ArchiveClient { + org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory + .getLog(VamsasClient.class); + + /** + * create a new vamsas client session from the archive at sessionPath. + * + * @param sessionPath + */ + public VamsasClient(File sessionPath) { + super(System.getProperty("user.name"), System.getProperty("host.name"), + "SimpleVamsasClientApp", "0.1", sessionPath); + } + + /** + * Called by gui to read anything from the vamsas session into the apps + * datamodel after it has started up. + * + */ + public void initial_update() { + log.info("Jalview loading the Vamsas Session."); + // load in the vamsas archive for the first time + ClientDoc cdoc = this.getUpdateable(); + updateJalview(cdoc); + // TODO: flush any new VorbaIds to the document : updateVamsasClient may + // actually generate new Vamsas Document data in the form of vamsas element + // ids - these should be written back to the document. + // doUpdate(cdoc); // JBPNote: this should flush new VorbaIds but I've not + // tested it yet. + cdoc.closeDoc(); + // then tell app to update its display based on the datamodel changes. + } + + VamsasClientWatcher watcher = null; + + /** + * Called by app when internal datamodel should exported (syncrhonised + * outwards) to vamsas document + * + */ + public void push_update() { + + watchForChange = false; // this makes any watch(long) loops return. + // we should also wait arount for this.WATCH_SLEEP to really make sure the + // watcher thread has stopped. + try { + Thread.sleep(WATCH_SLEEP); + } catch (Exception e) { + + } + ; + + ClientDoc cdoc = getUpdateable(); + updateVamsasDocument(cdoc); + doUpdate(cdoc); + cdoc.closeDoc(); + cdoc = null; + watchForChange = true; + startWatcher(); + } + + public void end_session() { + watchForChange = false; // this makes any watch(long) loops return. + // we should also wait arount for this.WATCH_SLEEP to really make sure the + // watcher thread has stopped. + try { + Thread.sleep(WATCH_SLEEP); + } catch (Exception e) { + + } + ; + + // stop any update/watcher thread. + log.info("VamsasClientApplication disconnecting from the Vamsas Session."); + } + + public void updateJalview(ClientDoc cdoc) { + ensureVamsasBindings(); + VamsasDatastore vds = new VamsasDatastore(cdoc, vobj2jv, jv2vobj, + baseProvEntry()); + vds.updateToJalview(); + } + + private void ensureVamsasBindings() { + if (jv2vobj == null) { + jv2vobj = new IdentityHashMap(); + vobj2jv = new Hashtable(); + } + } + + /** + * App's object binding to VorbaIds + */ + IdentityHashMap jv2vobj = null; + + Hashtable vobj2jv = null; + + /** + * called with a vamsas document which will be updated with new data from the + * app + * + * @param doc + */ + public void updateVamsasDocument(ClientDoc doc) { + ensureVamsasBindings(); + VamsasDatastore vds = new VamsasDatastore(doc, vobj2jv, jv2vobj, + baseProvEntry()); + // wander through frames + vds.storeVAMSAS(new Object()); // Object is the apps datamodel ;) + } + + /** + * + * @return a base provenance entry used by the VamsasDatastore object to get + * attributes from. this isn't particularly elegant either. + */ + private Entry baseProvEntry() { + uk.ac.vamsas.objects.core.Entry pentry = new uk.ac.vamsas.objects.core.Entry(); + pentry.setUser(this.getProvenanceUser()); + pentry.setApp(this.getClientHandle().getClientName()); + pentry.setDate(new java.util.Date()); + pentry.setAction("created"); + return pentry; + } + + protected class VamsasClientWatcher extends Thread implements Runnable { + /* + * (non-Javadoc) + * + * @see java.lang.Thread#run() + */ + VamsasClient client = null; + + VamsasClientWatcher(VamsasClient client) { + this.client = client; + } + + boolean running = false; + + public void run() { + running = true; + while (client.watchForChange) { + ClientDoc docio = client.watch(0); + if (docio != null) { + // VamsasClient GUI bits should be disabled whilst an update is in + // progress so the user doesn't screw anything up. + client.disableGui(true); + log.debug("Updating VamsasClient app from changed vamsas document."); + client.updateJalview(docio); + log.debug("Finished updating from document change."); + docio.closeDoc(); + docio = null; + client.disableGui(false); + } + } + running = false; + + } + + } + + /** + * @param args + */ + public static void main(String[] args) { + // TODO Auto-generated method stub + + } + + /** + * disable (if b is true) or enable (if b is true) the VamsasClient's vamsas + * session gui bits whilst a document change is being updated to the app. + * + * @param b + */ + public void disableGui(boolean b) { + // in jalview, we turn off the VAMSAS Session menu : + // Desktop.instance.setVamsasUpdate(b); + } + + /** + * spawn a new thread to start the VamsasClientWatcher. + * + */ + public void startWatcher() { + if (watcher == null) + watcher = new VamsasClientWatcher(this); + Thread thr = new Thread() { + public void run() { + watcher.start(); + } + }; + thr.start(); + } + +} diff --git a/src/uk/ac/vamsas/test/simpleclient/simpleapp/VamsasDatastore.java b/src/uk/ac/vamsas/test/simpleclient/simpleapp/VamsasDatastore.java index aecf14f..c14598c 100644 --- a/src/uk/ac/vamsas/test/simpleclient/simpleapp/VamsasDatastore.java +++ b/src/uk/ac/vamsas/test/simpleclient/simpleapp/VamsasDatastore.java @@ -1,26 +1,26 @@ /* - * VamsasClientSimpleApp - A framework for interoparable Sequence analysis - * Copyright (C) 2006 VAMSAS - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, + * This file is part of the Vamsas Client version 0.1. + * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ - package uk.ac.vamsas.test.simpleclient.simpleapp; - - import java.io.*; import java.util.HashMap; import java.util.HashSet; @@ -46,9 +46,10 @@ import uk.ac.vamsas.test.simpleclient.ClientDoc; */ public class VamsasDatastore { - org.apache.commons.logging.Log log=org.apache.commons.logging.LogFactory.getLog(VamsasDatastore.class); - Entry provEntry = null; + org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory + .getLog(VamsasDatastore.class); + Entry provEntry = null; org.exolab.castor.types.Date date = new org.exolab.castor.types.Date( new java.util.Date()); @@ -61,7 +62,7 @@ public class VamsasDatastore { public VamsasDatastore(ClientDoc cdoc, Hashtable vobj2jv, IdentityHashMap jv2vobj, Entry provEntry) { - this.cdoc = cdoc; + this.cdoc = cdoc; this.vobj2jv = vobj2jv; this.jv2vobj = jv2vobj; this.provEntry = provEntry; @@ -80,8 +81,6 @@ public class VamsasDatastore { * * marshaller.setMapping(map); marshaller.marshal(af); } catch (Exception e) { * e.printStackTrace(); } } - * - * */ /** * @return the Vobject bound to Jalview datamodel object @@ -99,11 +98,9 @@ public class VamsasDatastore { */ protected Object getvObj2jv(uk.ac.vamsas.client.Vobject vobj) { VorbaId id = vobj.getVorbaId(); - if (id == null) - { + if (id == null) { id = cdoc.registerObject(vobj); - log - .debug("Registering new object and returning null for getvObj2jv"); + log.debug("Registering new object and returning null for getvObj2jv"); return null; } if (vobj2jv.containsKey(vobj.getVorbaId())) @@ -113,18 +110,17 @@ public class VamsasDatastore { protected void bindjvvobj(Object jvobj, uk.ac.vamsas.client.Vobject vobj) { VorbaId id = vobj.getVorbaId(); - if (id == null) - { + if (id == null) { id = cdoc.registerObject(vobj); - if (id==null || vobj.getVorbaId()==null) - log.error("Failed to get id for "+(vobj.isRegisterable() ? "registerable" : "unregisterable") +" object "+vobj); + if (id == null || vobj.getVorbaId() == null) + log.error("Failed to get id for " + + (vobj.isRegisterable() ? "registerable" : "unregisterable") + + " object " + vobj); } - if (vobj2jv.containsKey(vobj.getVorbaId()) || jv2vobj.containsKey(jvobj)) - { - log.error("Duplicate object binding! "+vobj+" id " +vobj.getVorbaId().getId()+" to "+jvobj); - } - else - { + if (vobj2jv.containsKey(vobj.getVorbaId()) || jv2vobj.containsKey(jvobj)) { + log.error("Duplicate object binding! " + vobj + " id " + + vobj.getVorbaId().getId() + " to " + jvobj); + } else { vobj2jv.put(vobj.getVorbaId(), jvobj);// JBPNote - better implementing a // hybrid invertible hash. jv2vobj.put(jvobj, vobj.getVorbaId()); @@ -140,8 +136,7 @@ public class VamsasDatastore { boolean nw = false; VAMSAS root = null; // will be resolved based on Dataset Parent. DataSet dataset = (DataSet) getjv2vObj(fromAppsDatamodel); - if (dataset == null) - { + if (dataset == null) { root = cdoc.getVamsasRoots()[0]; // default vamsas root for modifying. dataset = new DataSet(); root.addDataSet(dataset); @@ -156,9 +151,9 @@ public class VamsasDatastore { } private Property newProperty(String name, String type, String content) { - Property vProperty=new Property(); + Property vProperty = new Property(); vProperty.setName(name); - if (type!=null) + if (type != null) vProperty.setType(type); vProperty.setContent(content); return vProperty; @@ -167,10 +162,12 @@ public class VamsasDatastore { /** * get start0 && dseta.getPosCount()>0) - throw new Error("Invalid vamsas RangeType - cannot resolve both lists of Pos and Seg from choice!"); - if (dseta.getSegCount() > 0) - { - se = getSegRange(dseta.getSeg(0),true); - for (int s = 1, sSize = dseta.getSegCount(); s < sSize; s++) - { + if (dseta.getSegCount() > 0 && dseta.getPosCount() > 0) + throw new Error( + "Invalid vamsas RangeType - cannot resolve both lists of Pos and Seg from choice!"); + if (dseta.getSegCount() > 0) { + se = getSegRange(dseta.getSeg(0), true); + for (int s = 1, sSize = dseta.getSegCount(); s < sSize; s++) { int nse[] = getSegRange(dseta.getSeg(s), true); if (se[0] > nse[0]) se[0] = nse[0]; @@ -239,13 +235,12 @@ public class VamsasDatastore { se[1] = nse[1]; } } - if (dseta.getPosCount() > 0) - { - // could do a polarity for pos range too. and pass back indication of discontinuities. + if (dseta.getPosCount() > 0) { + // could do a polarity for pos range too. and pass back indication of + // discontinuities. int pos = dseta.getPos(0).getI(); se = new int[] { pos, pos }; - for (int p = 0, pSize = dseta.getPosCount(); p < pSize; p++) - { + for (int p = 0, pSize = dseta.getPosCount(); p < pSize; p++) { pos = dseta.getPos(p).getI(); if (se[0] > pos) se[0] = pos; @@ -257,53 +252,52 @@ public class VamsasDatastore { } return null; } + /** - * map from a rangeType's internal frame to the referenced object's coordinate frame. + * map from a rangeType's internal frame to the referenced object's coordinate + * frame. + * * @param dseta * @return int [] { ref(pos)...} for all pos in rangeType's frame. */ private int[] getMapping(RangeType dseta) { - Vector posList=new Vector(); - if (dseta != null) - { + Vector posList = new Vector(); + if (dseta != null) { int[] se = null; - if (dseta.getSegCount()>0 && dseta.getPosCount()>0) - throw new Error("Invalid vamsas RangeType - cannot resolve both lists of Pos and Seg from choice!"); - if (dseta.getSegCount() > 0) - { - for (int s = 0, sSize = dseta.getSegCount(); s < sSize; s++) - { + if (dseta.getSegCount() > 0 && dseta.getPosCount() > 0) + throw new Error( + "Invalid vamsas RangeType - cannot resolve both lists of Pos and Seg from choice!"); + if (dseta.getSegCount() > 0) { + for (int s = 0, sSize = dseta.getSegCount(); s < sSize; s++) { se = getSegRange(dseta.getSeg(s), false); - int se_end=se[1-se[2]]+(se[2]==0 ? 1 : -1); - for (int p=se[se[2]]; p!=se_end; p+=se[2]==0 ? 1 : -1 ) { + int se_end = se[1 - se[2]] + (se[2] == 0 ? 1 : -1); + for (int p = se[se[2]]; p != se_end; p += se[2] == 0 ? 1 : -1) { posList.add(new Integer(p)); } } - } - else if (dseta.getPosCount() > 0) - { + } else if (dseta.getPosCount() > 0) { int pos = dseta.getPos(0).getI(); - for (int p = 0, pSize = dseta.getPosCount(); p < pSize; p++) - { + for (int p = 0, pSize = dseta.getPosCount(); p < pSize; p++) { pos = dseta.getPos(p).getI(); posList.add(new Integer(pos)); } } } - if (posList!=null && posList.size()>0) { - int[] range=new int[posList.size()]; - for (int i=0; i 0) { + int[] range = new int[posList.size()]; + for (int i = 0; i < range.length; i++) + range[i] = ((Integer) posList.elementAt(i)).intValue(); posList.clear(); return range; } return null; } + /** * - * @return default initial provenance list for a VamsasDatastore created vamsas - * object. + * @return default initial provenance list for a VamsasDatastore created + * vamsas object. */ Provenance dummyProvenance() { return dummyProvenance(null);