[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
In directory dev.open-bio.org:/tmp/cvs-serv29629/src/main/org/biomoby/shared
Modified Files:
MobySecondaryData.java
Log Message:
Updates to secondary article handling
moby-live/Java/src/main/org/biomoby/shared MobySecondaryData.java,1.9,1.10
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobySecondaryData.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobySecondaryData.java 2006/11/11 23:04:34 1.9
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobySecondaryData.java 2006/12/07 16:37:36 1.10
@@ -23,8 +23,13 @@
public class MobySecondaryData
extends MobyData {
+ public static final String INTEGER_TYPE = "Integer";
+ public static final String FLOAT_TYPE = "Float";
+ public static final String STRING_TYPE = "String";
+ public static final String DATETIME_TYPE = "DateTime";
+ public static final String BOOLEAN_TYPE = "Boolean";
- protected String dataType = "String";
+ protected String dataType = STRING_TYPE;
protected String defaultValue = "";
protected String minimumValue = "";
protected String maximumValue = "";
@@ -54,14 +59,18 @@
* </Parameter>
*
*************************************************************************/
- public MobySecondaryData (Element elem) {
+ public MobySecondaryData (Element elem){
super (elem.getAttribute ("articleName"));
NodeList children = elem.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
String childName = children.item (i).getNodeName();
if (childName.equals ("datatype")) {
if (children.item (i).getFirstChild() != null)
- setDataType (children.item (i).getFirstChild().getNodeValue());
+ try{
+ setDataType (children.item (i).getFirstChild().getNodeValue());
+ } catch(Exception e){
+ e.printStackTrace();
+ }
} else if (childName.equals ("description")) {
if (children.item (i).getFirstChild() != null)
setDescription (children.item (i).getFirstChild().getNodeValue());
@@ -84,8 +93,29 @@
public String getDataType() {
return dataType;
}
- public void setDataType (String value) {
- dataType = (value == null ? "" : value);
+
+ public void setDataType (String value) throws Exception{
+ if(value.equalsIgnoreCase(INTEGER_TYPE)){
+ dataType = INTEGER_TYPE;
+ }
+ else if(value.equalsIgnoreCase(FLOAT_TYPE)){
+ dataType = FLOAT_TYPE;
+ }
+ else if(value.equalsIgnoreCase(STRING_TYPE)){
+ dataType = STRING_TYPE;
+ }
+ else if(value.equalsIgnoreCase(DATETIME_TYPE)){
+ dataType = DATETIME_TYPE;
+ }
+ else if(value.equalsIgnoreCase(BOOLEAN_TYPE)){
+ dataType = BOOLEAN_TYPE;
+ }
+ else{
+ throw new Exception("Data type for secondary parameter '" + getName() +
+ "' was not valid (\"" + value + "\"), must be one of " +
+ INTEGER_TYPE + ", " + FLOAT_TYPE + ", " + STRING_TYPE + ", " +
+ DATETIME_TYPE + ", " + BOOLEAN_TYPE);
+ }
}
public String getDefaultValue() {
More information about the MOBY-guts
mailing list