public abstract class BC_MIFValueSetter
extends java.lang.Object
Utility class for setting object values from strings and vice-versa.
The main use of this class is building a schema-dependent array of "parsers" which speed up the process of reading text lines and converting them into features.
Modifier and Type | Field and Description |
---|---|
protected java.lang.Object |
objValue |
protected java.lang.String |
strValue |
Constructor and Description |
---|
BC_MIFValueSetter(java.lang.String defa)
The constructor accepts a default value for the ValueSetter.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getError()
Gets and resets the current error message.
|
java.lang.String |
getString()
Returns the string value.
|
java.lang.Object |
getValue()
Gets the object value.
|
boolean |
setString(java.lang.String value)
Sets the value as a String.
|
void |
setValue(java.lang.Object value)
Sets the object value, and calculates the String value.
|
protected abstract void |
stringToValue()
This method must be overridden by descendants in order to implement the
correct conversion between strings and object values.
|
protected void |
valueToString()
Converts an object value to string - the default implementation uses
toString for non-null values.
|
protected java.lang.String strValue
protected java.lang.Object objValue
public BC_MIFValueSetter(java.lang.String defa)
The constructor accepts a default value for the ValueSetter.
defa
- String representation of the default valuepublic final boolean setString(java.lang.String value)
Sets the value as a String. After a setString call, getValue() can be used to access the converted value.
value
- String representation of the object valuepublic final java.lang.String getString()
Returns the string value.
public final void setValue(java.lang.Object value)
Sets the object value, and calculates the String value.
value
- The Object valuepublic final java.lang.Object getValue()
Gets the object value.
public final java.lang.String getError()
Gets and resets the current error message.
protected void valueToString()
Converts an object value to string - the default implementation uses toString for non-null values.
protected abstract void stringToValue() throws java.lang.Exception
This method must be overridden by descendants in order to implement the
correct conversion between strings and object values.
Must throw an exception if conversion failed
java.lang.Exception
- if value conversion failed