Package com.im.df.api.support
Class DefaultValue
- java.lang.Object
-
- com.im.df.api.support.DefaultValue
-
public final class DefaultValue extends java.lang.ObjectRepresents a default value for a field. Essentially this is a wrapper around the actual value, as in some special cases the database can define "magical" values such as "sysdate" which are not parseable as valid values.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static DefaultValuecreate(java.lang.Object value)This method is the simplest way for creating new DefaultValue instance.static DefaultValuecreate(java.lang.String[] stringValues, java.lang.Object convertedValue)Create a non-null default value.static DefaultValuecreate(java.lang.String stringValue, java.lang.Object convertedValue)Create a non-null default value for single-column field.static DefaultValuecreateForString(java.lang.String str)Create an instance of DefaultValue for String.static DefaultValuecreateNull(int columnsCount)Create DefaultValue instance forNULL.booleanequals(java.lang.Object obj)java.lang.ObjectgetConvertedValue()java.lang.String[]getStringValues()The JDBC derived defaults for each column used by the field.inthashCode()booleanisNull()static DefaultValueparse(java.lang.String stringValue, DFDataConvertor convertor)Try to parse from string representation (created e.g.java.lang.StringtoString()
-
-
-
Method Detail
-
getConvertedValue
public java.lang.Object getConvertedValue()
- Returns:
- The converted value, if there is one. Can return null if it's either special value
or if its
DEFAULT_NULL.
-
getStringValues
public java.lang.String[] getStringValues()
The JDBC derived defaults for each column used by the field. Typically a field represents a single column so then the array contains only a single String. Can return null if this isDEFAULT_NULLinstance.- Returns:
- The String values of the column defaults
-
createNull
public static DefaultValue createNull(int columnsCount)
Create DefaultValue instance forNULL. It's necessary to specify number of columns, becausegetStringValues()of this new instance will return array of this length (all values in the array will be null).- Parameters:
columnsCount-- Returns:
- The default value instance
-
createForString
public static DefaultValue createForString(java.lang.String str)
Create an instance of DefaultValue for String. If the parameter is null or it's string with length 0 then it's delegated tocreateNull(int).- Parameters:
str-- Returns:
- The default value instance
-
create
public static DefaultValue create(java.lang.Object value)
This method is the simplest way for creating new DefaultValue instance. If you have an original value e.g. Integer(100), Date instance, etc. you can create DefaultValue from this object directly.This method can be used only for single-column fields.
getStringValues()method of returned instance will return String[1] where the only element will be created usingvalue.toString()- Parameters:
value- The original object in Field's own specific format. Null is allowed.- Returns:
- The new DefaultValue instance
-
create
public static DefaultValue create(java.lang.String stringValue, java.lang.Object convertedValue)
Create a non-null default value for single-column field. If you want to create default value for NULL plesase usecreateNull(int)instead.- Parameters:
stringValue- This is the original default value from the database. Null is not allowed.convertedValue- Converted value can be specified, but it's not required. You can pass null here. Then the special DefaultValue is created - for example if default value is SYSDATE on Oracle, etc.- Returns:
- The new instance of DefaultValue
-
create
public static DefaultValue create(java.lang.String[] stringValues, java.lang.Object convertedValue)
Create a non-null default value. If you want to create default value for NULL plesase usecreateNull(int)instead.- Parameters:
stringValues- This is array of original default values from the database. Each value of the array corresponds to default value for one column. The array's length must be > 0.convertedValue- Converted value can be specified, but it's not required. You can pass null here. Then the special DefaultValue is created - for example if default value is SYSDATE on Oracle, etc.- Returns:
- The new instance of DefaultValue
-
parse
public static DefaultValue parse(java.lang.String stringValue, DFDataConvertor convertor)
Try to parse from string representation (created e.g. usingtoString().- Parameters:
stringValue- String representation e.g. "123" or "a,b" or "null"convertor- Convertor used for preparation of value as correct object (e.g. Integer(123))- Returns:
- The parsed value
-
isNull
public boolean isNull()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-