[MOBY-guts] biomoby commit
Martin Senger
senger at pub.open-bio.org
Sun Nov 6 16:23:50 UTC 2005
senger
Sun Nov 6 11:23:50 EST 2005
Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared
In directory pub.open-bio.org:/tmp/cvs-serv13600/src/main/org/biomoby/shared
Modified Files:
MobyPrimaryDataSet.java MobyPrimaryDataSimple.java
MobySecondaryData.java
Added Files:
MobyPrimaryData.java
Log Message:
moby-live/Java/src/main/org/biomoby/shared MobyPrimaryData.java,NONE,1.1 MobyPrimaryDataSet.java,1.5,1.6 MobyPrimaryDataSimple.java,1.6,1.7 MobySecondaryData.java,1.4,1.5
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyPrimaryDataSet.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyPrimaryDataSet.java 2005/11/05 17:51:04 1.5
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyPrimaryDataSet.java 2005/11/06 16:23:50 1.6
@@ -24,7 +24,7 @@
*/
public class MobyPrimaryDataSet
- extends MobyData {
+ extends MobyPrimaryData {
protected Vector elements = new Vector(); // elemenst are of type MobyPrimaryDataSimple
@@ -74,10 +74,11 @@
elements.addElement (value);
}
- public boolean isPrimary() {
- return true;
- }
-
+ /**************************************************************************
+ * Return a data type of the first element of this collection
+ * (according the Biomoby API, however, all elements should have
+ * the same data type).
+ *************************************************************************/
public MobyDataType getDataType() {
synchronized (elements) {
if (elements.size() > 0)
@@ -87,6 +88,11 @@
}
}
+ /**************************************************************************
+ * Set given data type to all elements of this collection
+ * (according the Biomoby API all elements should have the same
+ * data type).
+ *************************************************************************/
public void setDataType (MobyDataType dataType) {
synchronized (elements) {
for (Enumeration en = elements.elements(); en.hasMoreElements(); )
@@ -95,6 +101,59 @@
}
/**************************************************************************
+ * Return namespaces of the first element of this collection.
+ *************************************************************************/
+ public MobyNamespace[] getNamespaces() {
+ synchronized (elements) {
+ if (elements.size() > 0)
+ return ((MobyPrimaryDataSimple)elements.firstElement()).getNamespaces();
+ else
+ return new MobyNamespace[] {};
+ }
+ }
+
+ /**************************************************************************
+ * Set given namespaces of all elements of this collection.
+ *************************************************************************/
+ public void setNamespaces (MobyNamespace[] value) {
+ synchronized (elements) {
+ for (Enumeration en = elements.elements(); en.hasMoreElements(); )
+ ((MobyPrimaryDataSimple)en.nextElement()).setNamespaces (value);
+ }
+ }
+
+ /**************************************************************************
+ * Add given namespace of all elements of this collection.
+ *************************************************************************/
+ public void addNamespace (MobyNamespace value) {
+ synchronized (elements) {
+ for (Enumeration en = elements.elements(); en.hasMoreElements(); )
+ ((MobyPrimaryDataSimple)en.nextElement()).addNamespace (value);
+ }
+ }
+
+ /**************************************************************************
+ * Remove given namespace (defined by its name) from all elements
+ * of this collection.
+ *************************************************************************/
+ public void removeNamespace (String namespaceName) {
+ synchronized (elements) {
+ for (Enumeration en = elements.elements(); en.hasMoreElements(); )
+ ((MobyPrimaryDataSimple)en.nextElement()).removeNamespace (namespaceName);
+ }
+ }
+
+ /**************************************************************************
+ * Remove given namespace from all elements of this collection.
+ *************************************************************************/
+ public void removeNamespace (MobyNamespace value) {
+ synchronized (elements) {
+ for (Enumeration en = elements.elements(); en.hasMoreElements(); )
+ ((MobyPrimaryDataSimple)en.nextElement()).removeNamespace (value);
+ }
+ }
+
+ /**************************************************************************
* Convert this instance to the XML.
* The XML will look like this:
*
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyPrimaryDataSimple.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyPrimaryDataSimple.java 2005/11/06 05:31:35 1.6
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyPrimaryDataSimple.java 2005/11/06 16:23:50 1.7
@@ -26,7 +26,7 @@
*/
public class MobyPrimaryDataSimple
- extends MobyData {
+ extends MobyPrimaryData {
protected Vector namespaces = new Vector(); // elements are of type MobyNamespace
protected MobyDataType dataType;
@@ -72,48 +72,71 @@
}
}
+ /**************************************************************************
+ *
+ *************************************************************************/
public MobyDataType getDataType() {
return dataType;
}
+
+ /**************************************************************************
+ *
+ *************************************************************************/
public void setDataType (MobyDataType value) {
dataType = value;
}
+ /**************************************************************************
+ * Return all namespaces defined in this data container.
+ *************************************************************************/
public MobyNamespace[] getNamespaces() {
MobyNamespace[] result = new MobyNamespace [namespaces.size()];
namespaces.copyInto (result);
return result;
}
+
+ /**************************************************************************
+ * Replace all existing namespaces (if any) by a new array of
+ * namespaces. Do not accept duplicates (same names).
+ *************************************************************************/
public void setNamespaces (MobyNamespace[] value) {
if (value == null) {
namespaces.clear();
} else {
for (int i = 0; i < value.length; i++)
- namespaces.addElement (value[i]);
+ addNamespace (value[i]);
}
}
- public void addNamespace (MobyNamespace value) {
- namespaces.addElement (value);
- }
- public boolean isPrimary() {
- return true;
+ /**************************************************************************
+ * Add one namespace to already existing ones (but only if a
+ * namespace of the same name does not exist yet).
+ *************************************************************************/
+ public void addNamespace (MobyNamespace value) {
+ synchronized (namespaces) {
+ if (! namespaces.contains (value))
+ namespaces.addElement (value);
+ }
}
+ /**************************************************************************
+ * Remove namespace given by its name.
+ *************************************************************************/
public void removeNamespace (String namespaceName) {
removeNamespace (new MobyNamespace (namespaceName));
}
+ /**************************************************************************
+ * Remove given namespace.
+ *************************************************************************/
public void removeNamespace (MobyNamespace value) {
- for (Enumeration en = namespaces.elements(); en.hasMoreElements(); ) {
- if (en.nextElement().equals (value)) {
- namespaces.removeElement (value);
- return;
- }
+ synchronized (namespaces) {
+ int index = namespaces.indexOf (value);
+ if (index > -1)
+ namespaces.remove (index);
}
}
-
/**************************************************************************
* Convert this instance into XML.
* The XML will look like this:
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobySecondaryData.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobySecondaryData.java 2005/09/22 16:07:09 1.4
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobySecondaryData.java 2005/11/06 16:23:50 1.5
@@ -26,7 +26,7 @@
public class MobySecondaryData
extends MobyData {
- protected String dataType = "STRING";
+ protected String dataType = "String";
protected String defaultValue = "";
protected int minimumValue = Integer.MIN_VALUE;
protected int maximumValue = Integer.MAX_VALUE;
More information about the MOBY-guts
mailing list