removed type preservation code in setStringValue() - if the property was
of a different type previously, it is set to STRING instead of trying to get a boolean, number, date etc. out of the string value.
This commit is contained in:
parent
3009a40358
commit
fdced7ceed
2 changed files with 3 additions and 56 deletions
|
@ -67,33 +67,10 @@ public final class Property implements IProperty, Serializable, Cloneable {
|
|||
public void setStringValue (String value) throws ParseException {
|
||||
if (type == NODE)
|
||||
unregisterNode ();
|
||||
// IServer.getLogger().log ("setting string value of property "+propname + " to "+value);
|
||||
if (type == DATE) {
|
||||
SimpleDateFormat dateformat = new SimpleDateFormat ();
|
||||
dateformat.setLenient (true);
|
||||
Date date = dateformat.parse (value);
|
||||
this.lvalue = date.getTime ();
|
||||
return;
|
||||
}
|
||||
if (type == BOOLEAN) {
|
||||
if ("true".equalsIgnoreCase (value))
|
||||
this.bvalue = true;
|
||||
else if ("false".equalsIgnoreCase (value))
|
||||
this.bvalue = false;
|
||||
return;
|
||||
}
|
||||
if (type == INTEGER) {
|
||||
this.lvalue = Long.parseLong (value);
|
||||
return;
|
||||
}
|
||||
if (type == FLOAT) {
|
||||
this.dvalue = new Double (value).doubleValue ();
|
||||
return;
|
||||
}
|
||||
if (type == JAVAOBJECT)
|
||||
this.jvalue = null;
|
||||
this.svalue = value;
|
||||
type = STRING;
|
||||
this.svalue = value;
|
||||
}
|
||||
|
||||
public void setIntegerValue (long value) {
|
||||
|
|
|
@ -140,41 +140,11 @@ public final class Property implements IProperty, Serializable, Cloneable {
|
|||
public void setStringValue (String value) {
|
||||
if (type == NODE)
|
||||
unregisterNode ();
|
||||
// IServer.getLogger().log ("setting string value of property "+propname + " to "+value);
|
||||
// mark property as dirty
|
||||
dirty = true;
|
||||
// if this is not a string property, try to parse a value out of it
|
||||
if (type == DATE) {
|
||||
SimpleDateFormat dateformat = new SimpleDateFormat ();
|
||||
try {
|
||||
dateformat.setLenient (true);
|
||||
Date date = dateformat.parse (value);
|
||||
this.lvalue = date.getTime ();
|
||||
return;
|
||||
} catch (ParseException nodate) {
|
||||
node.nmgr.logEvent ("Couldn't parse date: was expecting something like "+dateformat.format (new Date()));
|
||||
// store as plain string
|
||||
}
|
||||
}
|
||||
if (type == BOOLEAN) {
|
||||
if ("true".equalsIgnoreCase (value))
|
||||
this.bvalue = true;
|
||||
else if ("false".equalsIgnoreCase (value))
|
||||
this.bvalue = false;
|
||||
return;
|
||||
}
|
||||
if (type == INTEGER) {
|
||||
this.lvalue = Long.parseLong (value);
|
||||
return;
|
||||
}
|
||||
if (type == FLOAT) {
|
||||
this.dvalue = new Double (value).doubleValue ();
|
||||
return;
|
||||
}
|
||||
if (type == JAVAOBJECT)
|
||||
this.jvalue = null;
|
||||
this.svalue = value;
|
||||
type = STRING;
|
||||
this.svalue = value;
|
||||
dirty = true;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue