[MOBY-guts] biomoby commit
Paul Gordon
gordonp at pub.open-bio.org
Wed Feb 9 17:20:38 UTC 2005
gordonp
Wed Feb 9 12:20:38 EST 2005
Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared
In directory pub.open-bio.org:/tmp/cvs-serv30837/org/biomoby/shared
Modified Files:
MobyDataFloat.java MobyDataInt.java
MobyDataSimpleInstance.java MobyDataString.java
Log Message:
Updates to correct javadoc errors, plus addition of underlying object accessibility for MOBY Data Instances
moby-live/Java/src/main/org/biomoby/shared MobyDataFloat.java,1.1,1.2 MobyDataInt.java,1.1,1.2 MobyDataSimpleInstance.java,1.3,1.4 MobyDataString.java,1.1,1.2
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyDataFloat.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyDataFloat.java 2004/09/03 20:28:16 1.1
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyDataFloat.java 2005/02/09 17:20:38 1.2
@@ -61,6 +61,13 @@
return copy;
}
+ /**
+ * @return a BigDecimal
+ */
+ public Object getObject(){
+ return value;
+ }
+
public String getValue(){
return ""+value;
}
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyDataInt.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyDataInt.java 2004/09/03 20:28:16 1.1
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyDataInt.java 2005/02/09 17:20:38 1.2
@@ -3,10 +3,10 @@
import java.math.*;
/**
- * A class representing a MOBY Float primitive. Note that the
- * Float notion in MOBY does not define a specific bit precision.
- * All values in this class are stored as Java BigDecimal, which is
- * arbitary precision to avoid loss of data integrity.
+ * A class representing a MOBY Integer primitive. Note that the
+ * Integer notion in MOBY does not define a specific bit precision.
+ * All values in this class are stored as Java BigInteger, which has no
+ * minmum or maximum value, to avoid loss of data integrity.
*/
public class MobyDataInt extends MobyDataSimpleInstance{
@@ -15,7 +15,8 @@
/**
* Constructor to use if the incoming value is a number object such as
- * Float, Double, Integer, BigDecimal, etc.
+ * Float, Double, Integer, BigInteger, BigDecimal, etc.
+ * Real numbers will be converted to their integer equivalents.
*/
public MobyDataInt(String articleName, Number n){
super(articleName);
@@ -33,7 +34,7 @@
/**
* Constructor to use if the incoming value is a primitive.
- * If you want to pass in a float or int, cast it to a double.
+ * If you want to pass in a float or double, cast it to an int.
*/
public MobyDataInt(String articleName, int i){
super(articleName);
@@ -42,10 +43,10 @@
}
/**
- * Constructor to use if the incoming value is a string representing a number
- * (including mantissa/exponent format).
+ * Constructor to use if the incoming value is a string representing an integer number.
+ *
*
- * @throws NumberFormatException if the string does not represent a number
+ * @throws NumberFormatException if the string does not represent an integer number
*/
public MobyDataInt(String articleName, String stringNumber) throws NumberFormatException{
super(articleName);
@@ -61,6 +62,13 @@
return copy;
}
+ /**
+ * @return a BigInteger
+ */
+ public Object getObject(){
+ return value;
+ }
+
public String getValue(){
return ""+value;
}
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyDataSimpleInstance.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyDataSimpleInstance.java 2004/09/23 10:20:29 1.3
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyDataSimpleInstance.java 2005/02/09 17:20:38 1.4
@@ -132,6 +132,16 @@
}
/**
+ * Gives access to the Java object instance underlying the MobyData instance.
+ * For example, to increment a MOBY integer object, call ((BigInteger) (data.getObject()).add(BigInteger.ONE)
+ *
+ * Not yet fully implemented for base objects whose setValue() method has been called.
+ */
+ public Object getObject(){
+ return dataValue;
+ }
+
+ /**
* Convenience method to get the basic XML representation
* @return the raw XML representation of the object
*/
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyDataString.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyDataString.java 2004/09/03 20:28:16 1.1
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyDataString.java 2005/02/09 17:20:38 1.2
@@ -3,10 +3,7 @@
import java.math.*;
/**
- * A class representing a MOBY Float primitive. Note that the
- * Float notion in MOBY does not define a specific bit precision.
- * All values in this class are stored as Java BigDecimal, which is
- * arbitary precision to avoid loss of data integrity.
+ * A class representing a MOBY String primitive.
*/
public class MobyDataString extends MobyDataSimpleInstance{
@@ -44,17 +41,33 @@
return copy;
}
+ /**
+ * @return a String
+ */
+ public Object getObject(){
+ return value;
+ }
+
public String getValue(){
return value;
}
+ /**
+ * This class sanitizes strings of XML escape characters such as the ampersand (&) and the
+ * less-than sign (<). WARNING: this method will not escape ampersand in the string "&amp;",
+ * or '&#x26;' style character references. We will assume that is this case you've probably
+ * already written the string as XML.
+ *
+ * WARNING: As of yet, we do not deal with the false escaping of strings containg already-escaped
+ * CDATA sections!
+ */
public String toXML(){
MobyNamespace[] ns = getNamespaces();
if(xmlMode == SERVICE_XML_MODE){
String tmpValue = value;
if(tmpValue != null){
tmpValue = tmpValue.replaceAll("<", "<");
- tmpValue = tmpValue.replaceAll("&", "&");
+ tmpValue = tmpValue.replaceAll("&(?!(amp|#x\\d+);)", "&");
}
return "<moby:String moby:namespace=\""+
More information about the MOBY-guts
mailing list