|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.ca.commons.datamodel.DataModelValue
public final class DataModelValue
Serves double purpose representing both type and value information.
| Nested Class Summary | |
|---|---|
static class |
DataModelValue.ConversionSettings
Struct whose fields can be used to modulate conversions of all sorts of values to and from strings. |
| Field Summary | |
|---|---|
static int |
ANY_TYPE
Deprecated. |
static int |
BINARY_TYPE
Deprecated. |
static int |
BOOL_TYPE
Deprecated. |
static int |
DATE_TIME_TYPE
Deprecated. |
static int |
DATE_TYPE
Deprecated. |
static int |
DBL_TYPE
Deprecated. |
static int |
DURATION_TYPE
Deprecated. |
static int |
ENUM_TYPE
Deprecated. |
static int |
FLEXI_STR_TYPE
Deprecated. |
static int |
FLOAT_TYPE
Deprecated. |
static int |
INT_TYPE
Deprecated. |
static Logger |
logger
|
static int |
LONG_TYPE
Deprecated. |
static int |
MAP_TYPE
Deprecated. |
static int |
SEQ_TYPE
Deprecated. |
static int |
SET_TYPE
Deprecated. |
static int |
STR_TYPE
Deprecated. |
static int |
TIME_TYPE
Deprecated. |
static int |
UNDEF_TYPE
Deprecated. |
static TimeZone |
UTC_TIMEZONE
|
| Constructor Summary | |
|---|---|
DataModelValue(DataModelType type)
For internal use where a typed, but empty, value is required. |
|
DataModelValue(DataModelType type,
Object value)
|
|
DataModelValue(DataModelType type,
Object value,
boolean isDefault)
|
|
| Method Summary | ||
|---|---|---|
DataModelValue |
changeValue(Object newValue)
|
|
DataModelValue |
copy()
|
|
boolean |
equals(Object o)
|
|
static com.ca.commons.functional.Pred<DataModelValue> |
fnIsType(DataModelType dmType)
|
|
static
|
fnValue(Class<? extends T> type)
|
|
static Object |
fromString(DataModelType type,
String str)
Calls fromString(DataModelType, String, ConversionSettings) with null last argument. |
|
static Object |
fromString(DataModelType type,
String value,
DataModelValue.ConversionSettings convSettings)
Parses a string to find a data model value of a specified type. |
|
static Object |
fromString(int type,
String str)
Deprecated. Use version taking a DataModelType instead of legacy int. |
|
static Object |
fromString(int legacyType,
String value,
DataModelValue.ConversionSettings convSettings)
Deprecated. Use version taking DataModelType instead of legacy int. |
|
Object |
getAny()
|
|
String |
getBaseTypeString()
Null if type for this value is not compound, otherwise return base type string, eg returns "FLEXI_STR" when "FLEXI_STR:DN" is passed in. |
|
DataModelBinaryValue |
getBinary()
|
|
boolean |
getBool()
|
|
static String |
getClassRefClass(ClassReference ref)
|
|
DataModelCollectionValue |
getCollection()
|
|
ClassReference |
getCompoundValueClassRef()
|
|
String |
getCompoundValueClassRefClass()
|
|
String |
getCompoundValueClassRefStr()
Return fully qualified name referencing compound value class. |
|
Date |
getDate()
|
|
Date |
getDateTime()
|
|
double |
getDbl()
|
|
Duration |
getDuration()
|
|
DataModelEnumValue |
getEnum()
|
|
DataModelFlexiStrValue |
getFlexiStr()
|
|
float |
getFloat()
|
|
int |
getInt()
|
|
long |
getLong()
|
|
DataModelMapValue |
getMap()
|
|
DataModelValue |
getNestedValue()
Return "this" for simple (non-collection) values, otherwise return the basetype for the collection. |
|
Collection<DataModelValue> |
getSeq()
|
|
Collection<DataModelValue> |
getSet()
|
|
String |
getStr()
|
|
Date |
getTime()
|
|
DataModelType |
getType()
|
|
String |
getTypeString()
Return full qualified stype for this value, eg "BOOL" or "FLEXI_STR:DN". |
|
Object |
getValue()
|
|
static Object |
getValue(DataModelType type,
String value)
Deprecated. Use fromString instead. |
|
static Object |
getValue(int legacyType,
String value)
Deprecated. Use fromString instead. |
|
String |
getValueAsString()
Calls getValueAsString(com.ca.commons.datamodel.DataModelValue.ConversionSettings) with null argument. |
|
String |
getValueAsString(DataModelValue.ConversionSettings convSettings)
Return string representation of contained value, or null for collections, where convSettings will default to DEFAULT_CONVERSION_SETTINGS if null. |
|
int |
hashCode()
|
|
void |
initTypeString()
String signifying logical type for value contained, eg for validation purposes. |
|
boolean |
isDefault()
Does the contained value (for primitives) act as a default? |
|
boolean |
isType(DataModelType type)
|
|
static DataModelValue |
newBooleanValue(boolean b)
|
|
static DataModelValue |
newIntValue(int i)
|
|
static DataModelValue |
newStringValue(String s)
|
|
static DateFormat |
newXsdDateFormat()
|
|
static DateFormat |
newXsdDateTimeFormat()
|
|
static DateFormat |
newXsdDateTimeMillisFormat()
|
|
static DateFormat |
newXsdTimeFormat()
|
|
static DateFormat |
newXsdTimeMillisFormat()
|
|
String |
stringValue(String defaultValue)
|
|
String |
toString()
|
|
static String |
toString(DataModelType type,
Object obj,
DataModelValue.ConversionSettings convSettings)
Return string representation of obj based on chosen type allowing for simple conversions between numeric types as required, such as converting an Integer obj to DBL_TYPE and the reverse. |
|
static String |
toString(int type,
Object obj)
Return result of calling toString(int, Object, com.ca.commons.datamodel.DataModelValue.ConversionSettings) with a null last argument. |
|
static String |
toString(int legacyType,
Object obj,
DataModelValue.ConversionSettings convSettings)
Deprecated. This method takes legacy int values for the type and throws a runtime exception for unparsable strings, which is bad. Use the getValue(DataModelType, String) or toString(DataModelType, Object, ConversionSettings) methods instead. |
|
String |
toTypeString()
Deprecated. Use getTypeString() instead. |
|
|
value(Class<? extends T> type)
|
|
|
value(T defaultValue)
|
|
|
value(T defaultValue,
Class<? extends T> type)
|
|
static com.ca.commons.functional.Fn<Object,DataModelValue> |
valueMaker(DataModelType dataModelType)
|
|
|
valueOpt(Class<? extends T> type)
|
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final Logger logger
public static final TimeZone UTC_TIMEZONE
@Deprecated public static final int UNDEF_TYPE
@Deprecated public static final int BOOL_TYPE
@Deprecated public static final int INT_TYPE
@Deprecated public static final int DBL_TYPE
@Deprecated public static final int STR_TYPE
@Deprecated public static final int DATE_TYPE
@Deprecated public static final int TIME_TYPE
@Deprecated public static final int ENUM_TYPE
@Deprecated public static final int FLEXI_STR_TYPE
@Deprecated public static final int SEQ_TYPE
@Deprecated public static final int SET_TYPE
@Deprecated public static final int LONG_TYPE
@Deprecated public static final int DATE_TIME_TYPE
@Deprecated public static final int FLOAT_TYPE
@Deprecated public static final int DURATION_TYPE
@Deprecated public static final int BINARY_TYPE
@Deprecated public static final int ANY_TYPE
@Deprecated public static final int MAP_TYPE
| Constructor Detail |
|---|
public DataModelValue(@NotNull
DataModelType type,
@NotNull
Object value,
boolean isDefault)
public DataModelValue(@NotNull
DataModelType type,
@NotNull
Object value)
public DataModelValue(@NotNull
DataModelType type)
| Method Detail |
|---|
public static DateFormat newXsdDateFormat()
public static DateFormat newXsdDateTimeFormat()
public static DateFormat newXsdDateTimeMillisFormat()
public static DateFormat newXsdTimeFormat()
public static DateFormat newXsdTimeMillisFormat()
@NotNull
public static DataModelValue newStringValue(@NotNull
String s)
@NotNull public static DataModelValue newIntValue(int i)
@NotNull public static DataModelValue newBooleanValue(boolean b)
@NotNull
public static <T> com.ca.commons.functional.Fn<DataModelValue,com.ca.commons.functional.Option<T>> fnValue(@NotNull
Class<? extends T> type)
@NotNull
public static com.ca.commons.functional.Fn<Object,DataModelValue> valueMaker(@NotNull
DataModelType dataModelType)
public static com.ca.commons.functional.Pred<DataModelValue> fnIsType(DataModelType dmType)
public DataModelValue copy()
@NotNull
public DataModelValue changeValue(@NotNull
Object newValue)
@NotNull public final DataModelType getType()
public final boolean isType(@Nullable
DataModelType type)
@Nullable public final Object getValue()
@Nullable public String getValueAsString(DataModelValue.ConversionSettings convSettings)
DEFAULT_CONVERSION_SETTINGS if null.
@Nullable public String getValueAsString()
getValueAsString(com.ca.commons.datamodel.DataModelValue.ConversionSettings) with null argument.
public boolean isDefault()
public DataModelValue getNestedValue()
public ClassReference getCompoundValueClassRef()
public String getCompoundValueClassRefClass()
public static String getClassRefClass(ClassReference ref)
public String getCompoundValueClassRefStr()
public boolean getBool()
public int getInt()
public double getDbl()
public String getStr()
public Date getDate()
public Date getDateTime()
public long getLong()
public Date getTime()
public float getFloat()
public DataModelEnumValue getEnum()
public DataModelFlexiStrValue getFlexiStr()
public DataModelCollectionValue getCollection()
public Collection<DataModelValue> getSeq()
public Collection<DataModelValue> getSet()
public DataModelMapValue getMap()
public DataModelBinaryValue getBinary()
public Duration getDuration()
public Object getAny()
public boolean equals(Object o)
equals in class Objectpublic int hashCode()
hashCode in class Objectpublic String toString()
toString in class Objectpublic void initTypeString()
public String getTypeString()
@Deprecated public String toTypeString()
getTypeString() instead.
public String getBaseTypeString()
public static String toString(DataModelType type,
Object obj,
DataModelValue.ConversionSettings convSettings)
throws ParseException
type - Chosen from *_TYPE constants defined in this class.obj - Object to be converted to a string.convSettings - Settings to modulate conversion behaviour, if null then DEFAULT_CONVERSION_SETTINGS will be used.
IllegalArgumentException - if the provided value could not
be parsed according to the specified data model type.
ParseException
@Deprecated
public static String toString(int legacyType,
Object obj,
DataModelValue.ConversionSettings convSettings)
getValue(DataModelType, String) or toString(DataModelType, Object, ConversionSettings) methods instead.
legacyType - The data type to parse the string for.obj - The string to parse.convSettings - Settings to modulate conversion behaviour, if null then DEFAULT_CONVERSION_SETTINGS will be used.
IllegalArgumentException - if the provided value could not
be parsed according to the specified data model type.
public static String toString(int type,
Object obj)
toString(int, Object, com.ca.commons.datamodel.DataModelValue.ConversionSettings) with a null last argument.
public static Object fromString(DataModelType type,
String value,
DataModelValue.ConversionSettings convSettings)
throws ParseException
type - The data type to parse the string for.value - The string to parse.convSettings - Settings offering fine-grain control of conversion behaviour, if null then DEFAULT_CONVERSION_SETTINGS will be used.
ParseException - if the string value provided could not be parsed
according to the specified data model type.
@Nullable
public String stringValue(@Nullable
String defaultValue)
@NotNull
public <T> T value(@NotNull
T defaultValue)
@Nullable
public <T> T value(@Nullable
T defaultValue,
@NotNull
Class<? extends T> type)
@Nullable
public <T> T value(@NotNull
Class<? extends T> type)
@NotNull
public <T> com.ca.commons.functional.Option<T> valueOpt(@NotNull
Class<? extends T> type)
public static Object fromString(DataModelType type,
String str)
throws ParseException
fromString(DataModelType, String, ConversionSettings) with null last argument.
ParseException
@Deprecated
public static Object fromString(int type,
String str)
fromString(int, String, ConversionSettings) with null last argument.
@Deprecated
public static Object fromString(int legacyType,
String value,
DataModelValue.ConversionSettings convSettings)
@Deprecated
public static Object getValue(int legacyType,
String value)
fromString(int, String).
@Deprecated
public static Object getValue(DataModelType type,
String value)
fromString(DataModelType, String).
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||