|
Expresso 5-6 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.jcorporate.expresso.core.dataobjects.DefaultDataField
Default implementation of the DataField interface. This class provides some basic conversion capabilities between different Java types as well as provides all use change logging capabilities.
| Field Summary | |
static String |
ATTRIBUTE_ERROR
Attribute String for if there's an error with the field. |
static String |
ATTRIBUTE_ERROR_MESSAGE
Attribute String for what message to display if there's an error with thie field. |
protected Map |
attributes
A generic map of attribute keys to attribute values |
protected Object |
currentValue
The Current Value |
protected boolean |
isChanged
Flag to signify if the field is changed |
protected boolean |
isValueSet
Flag to signify if the field value has been set - the retrieved value may be null |
protected DataFieldMetaData |
myMetaData
A link to my metadata. |
protected Object |
originalValue
The original value, used in comparison tests for 'isChanged' calculation; set by first retrieve(); reset after add() or update() |
protected DataObject |
owner
A link to the DataObject that contains me. |
| Constructor Summary | |
protected |
DefaultDataField(DataFieldMetaData metaData,
DataObject parentObject)
Creates a new DefaultDataField object. |
| Method Summary | |
BigDecimal |
asBigDecimal()
Retrieve the wrapped object as a BigDecimal object or zero if we're unable
to convert it. |
Boolean |
asBoolean()
Retrieve the boolean object value. |
Date |
asDate()
Retrieve the wrapped object as a Date object or possibly null if we
can't convert it or the object is null. |
Double |
asDouble()
Retrieve the wrapped object as a Double object or zero if we
can't convert i |
Integer |
asInteger()
Retrieves the wrapped object as an Integer or zero if it's an invalid format. |
InputStream |
asStream()
Retrieve the field as a InputStream. |
String |
asString()
Retrieves the wrapped object as a String |
void |
cacheIsChangedComparison()
reset 'original' value and isChanged flags; call when add(), retrieve() or update() has occurred, and currentValue of data fields should be considered 'original value' for purposes of determining 'isChanged' |
void |
checkValue()
Make sure the value of the field is valid. |
Map |
getAllAttributes()
Returns a Read Only Map of all attributes in name-value pairs. |
Object |
getAttribute(String attributeName)
Retrieves any user defined attributes for this field. |
protected String |
getBooleanFieldValue(Boolean theFieldValue)
Internal refactoring for getting what a boolean field should be set to. |
DataFieldMetaData |
getFieldMetaData()
Returns a handle to the Field MetaData object. |
static DefaultDataField |
getInstance(DataFieldMetaData metaData,
DataObject parentObject)
create new object for this field |
Object |
getOriginalValue()
Retrieve the last original value if the data has changed. |
DataObject |
getOwner()
Returns a handle to the DataObject that is the container for this Data Field |
protected org.apache.oro.text.regex.PatternMatcher |
getPatternMatcher()
Retrieve a thread local instance of the Perl5 pattern matcher. |
Object |
getSerializedForm()
Returns the form in a way suitable for storage in a database or other data source. |
protected SimpleDateFormat |
getSimpleDateFormat(String pattern)
Get a SimpleDateFormat object that is cached. |
Object |
getValue()
retrieve value object for this field |
boolean |
isChanged()
Used for change logging and updating only changed fields. |
boolean |
isNull()
Returns true if the object is null. |
boolean |
isValueSet()
Used for change logging. |
void |
release()
set all internal data members to null; |
void |
removeAttribute(String attribute)
Removes an attribute |
void |
resetChanged()
Resets the isChanged and isValueSet flags and sets the original value field to null |
void |
setAttribute(String attributeName,
Object value)
Sets an attribute for this particular instance of the Data field |
void |
setFieldMetaData(DataFieldMetaData newMetadata)
Sets the metadata object for this field. |
void |
setOwner(DataObject newOwner)
Sets the owner of a given DataObject |
void |
setSerializedForm(Object o)
Used for setting raw data from a JDBC connection. |
void |
setValue(Object newValue)
Sets the wrapped object for the data field; also updates values for isValueSet and isChanged flags |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final String ATTRIBUTE_ERROR
public static final String ATTRIBUTE_ERROR_MESSAGE
protected transient DataFieldMetaData myMetaData
protected transient DataObject owner
protected Map attributes
protected Object currentValue
protected Object originalValue
protected boolean isChanged
protected boolean isValueSet
| Constructor Detail |
protected DefaultDataField(DataFieldMetaData metaData,
DataObject parentObject)
metaData - parentObject - | Method Detail |
public static DefaultDataField getInstance(DataFieldMetaData metaData,
DataObject parentObject)
metaData - parentObject -
public void release()
public void setSerializedForm(Object o)
o - the object to set.
public Object getSerializedForm()
throws DataException
DataException - upon errorpublic Object getValue()
getValue in interface DataFieldpublic String asString()
asString in interface DataFieldpublic InputStream asStream()
asStream in interface DataFieldpublic Integer asInteger()
Integer or zero if it's an invalid format.
asInteger in interface DataFieldpublic Date asDate()
Date object or possibly null if we
can't convert it or the object is null.
asDate in interface DataFieldDate Object if we're able to convert it.protected SimpleDateFormat getSimpleDateFormat(String pattern)
pattern - the format pattern to look up
public BigDecimal asBigDecimal()
BigDecimal object or zero if we're unable
to convert it.
asBigDecimal in interface DataFieldBigDecimal Object if we're able to convert it.public Double asDouble()
Double object or zero if we
can't convert i
asDouble in interface DataFieldDouble Object if we're able to convert it.public Boolean asBoolean()
asBoolean in interface DataFieldpublic Object getOriginalValue()
getOriginalValue in interface DataFieldpublic boolean isChanged()
isChanged in interface DataFieldpublic boolean isValueSet()
isValueSet in interface DataField
public void checkValue()
throws DataException
checkValue in interface DataFieldDataException - if the field value is not validpublic void resetChanged()
resetChanged in interface DataFieldpublic void setValue(Object newValue)
setValue in interface DataFieldnewValue - a new Object to set the value topublic boolean isNull()
isNull in interface DataField
public void setAttribute(String attributeName,
Object value)
setAttribute in interface DataFieldattributeName - the name of the attribute to setvalue - the value to set it topublic void removeAttribute(String attribute)
attribute - The attribute key to removepublic Object getAttribute(String attributeName)
getAttribute in interface DataFieldattributeName - the name of the attribute to retrieve
public Map getAllAttributes()
Map of all attributes in name-value pairs. If there are no
attributes then getAllAttributes will return a null map.
getAllAttributes in interface DataFieldpublic DataObject getOwner()
getOwner in interface DataFieldpublic void setOwner(DataObject newOwner)
setOwner in interface DataFieldnewOwner - The new parent object.public DataFieldMetaData getFieldMetaData()
getFieldMetaData in interface DataFieldpublic void setFieldMetaData(DataFieldMetaData newMetadata)
setFieldMetaData in interface DataFieldnewMetadata - the new Field Meta data object... for example DBFieldprotected String getBooleanFieldValue(Boolean theFieldValue)
theFieldValue - The target value
IllegalArgumentException - If we can't get the data contextprotected org.apache.oro.text.regex.PatternMatcher getPatternMatcher()
public void cacheIsChangedComparison()
cacheIsChangedComparison in interface DataField
|
Expresso 5-6 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||