[MOBY-guts] biomoby commit
Paul Gordon
gordonp at dev.open-bio.org
Thu Dec 7 16:37:36 UTC 2006
gordonp
Thu Dec 7 11:37:36 EST 2006
Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data
In directory dev.open-bio.org:/tmp/cvs-serv29629/src/main/org/biomoby/shared/data
Modified Files:
MobyDataSecondaryInstance.java
Log Message:
Updates to secondary article handling
moby-live/Java/src/main/org/biomoby/shared/data MobyDataSecondaryInstance.java,1.6,1.7
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataSecondaryInstance.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/data/MobyDataSecondaryInstance.java 2006/07/07 04:12:40 1.6
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataSecondaryInstance.java 2006/12/07 16:37:36 1.7
@@ -4,6 +4,8 @@
import org.biomoby.shared.*;
import org.biomoby.shared.parser.MobyTags;
import org.w3c.dom.*;
+import java.math.*;
+import java.util.GregorianCalendar; // with apologies to the Julians among us...
/**
* A class that holds and displays secondary input data to a service.
@@ -26,7 +28,11 @@
public MobyDataSecondaryInstance(MobySecondaryData type){
super(type.getName());
setId(type.getId());
- setDataType(type.getDataType());
+ try{
+ setDataType(type.getDataType());
+ }catch(Exception e){
+ e.printStackTrace();
+ }
setAllowedValues(type.getAllowedValues());
setDefaultValue(type.getDefaultValue());
setMinimumValue(type.getMinimumValue());
@@ -49,7 +55,11 @@
if(getName().length() == 0){
throw new MobyException("Secondary parameters with blank articleNames are not allowed, input was: " + objectTag);
}
- setDataType("String");
+ try{
+ setDataType(MobySecondaryData.STRING_TYPE);
+ } catch(Exception e){
+ e.printStackTrace();
+ }
if(objectTag == null){
return;
@@ -75,6 +85,38 @@
setValue(MobyDataObject.getTextContents((Element) values.item(0)));
}
+ public boolean asBoolean(){
+ return dataValue.equalsIgnoreCase("true") || dataValue.equals("1") || dataValue.equalsIgnoreCase("T");
+ }
+
+ public BigDecimal asFloat(){
+ try{
+ return new BigDecimal(dataValue);
+ } catch(Exception e){
+ return null;
+ }
+ }
+
+ public BigInteger asInteger(){
+ try{
+ return new BigInteger(dataValue);
+ } catch(Exception e){
+ return null;
+ }
+ }
+
+ public String asString(){
+ return dataValue;
+ }
+
+ public GregorianCalendar asDateTime(){
+ try{
+ return MobyDataDateTime.parseISO8601(dataValue);
+ } catch(Exception e){
+ return null;
+ }
+ }
+
/**
* For now, all secondary parameters are treated as strings.
*/
More information about the MOBY-guts
mailing list