public class Data
extends java.lang.Object
It contains the following access get/set methods. Each set method returns "this", so you can chain them.
String.format(Locale, String, Object...)
.Data.Type
.Modifier and Type | Class and Description |
---|---|
static class |
Data.State
Enumerates the States that are available, standard.
|
static class |
Data.Type
Defines the Type the Value is
|
Constructor and Description |
---|
Data(Data data)
Copy Constructor.
|
Data(java.lang.String name) |
Data(java.lang.String name,
java.lang.Object value) |
Data(java.lang.String name,
java.lang.Object value,
java.lang.String UOM) |
Data(java.lang.String name,
java.lang.Object value,
java.lang.String UOM,
java.lang.String state)
Constructor(s).
|
Modifier and Type | Method and Description |
---|---|
void |
add(Data d)
Adds all the named values from another Data instance.
|
void |
add(java.lang.String name) |
void |
add(java.lang.String name,
java.lang.Object value) |
void |
add(java.lang.String name,
java.lang.Object value,
java.lang.String UOM)
Adds a new named value to this container Each argument is optional, except name which is required.
|
Data |
addConversion(Data data)
Add all the units from another data object.
|
Data |
addConversion(java.lang.String fromUOM,
java.lang.String toUOM,
double factor)
Add a unit of measure conversion directly to this object.
|
int |
compare(Data data) |
int |
compare(Data data,
java.lang.String name)
Compares this instance to another Data instance.
|
Data |
convertUOM(java.lang.String UOM) |
Data |
convertUOM(java.lang.String name,
java.lang.String UOM) |
boolean |
equals(boolean b) |
boolean |
equals(Data pData) |
boolean |
equals(double d) |
boolean |
equals(float f) |
boolean |
equals(int i) |
boolean |
equals(long l) |
boolean |
equals(java.lang.String s) |
boolean |
equals(java.lang.String name,
boolean b) |
boolean |
equals(java.lang.String name,
double d) |
boolean |
equals(java.lang.String name,
float f) |
boolean |
equals(java.lang.String name,
int i) |
boolean |
equals(java.lang.String name,
long l) |
boolean |
equals(java.lang.String name,
java.lang.String s) |
boolean |
equalsIgnoreCase(java.lang.String s) |
boolean |
equalsIgnoreCase(java.lang.String name,
java.lang.String s) |
boolean |
getBoolean() |
boolean |
getBoolean(java.lang.String name)
Returns the value as a boolean.
|
java.util.ArrayList<java.lang.Boolean> |
getBooleanArray() |
java.util.ArrayList<java.lang.Boolean> |
getBooleanArray(java.lang.String name)
Returns the value as an array of boolean.
|
double |
getDouble() |
double |
getDouble(java.lang.String name)
Returns the value as a double.
|
java.util.ArrayList<java.lang.Double> |
getDoubleArray() |
java.util.ArrayList<java.lang.Double> |
getDoubleArray(java.lang.String name)
Returns the value as an array of doubles.
|
float |
getFloat() |
java.lang.Float |
getFloat(java.lang.String name)
Returns the value as a float.
|
java.lang.String |
getFormat() |
java.lang.String |
getFormat(java.lang.String name)
Returns the format string.
|
java.lang.String |
getId()
Returns the Id of this instance.
|
int |
getInteger() |
int |
getInteger(java.lang.String name)
Returns the value as an integer.
|
long |
getInterval() |
long |
getInterval(java.lang.String name)
Returns the interval in milliseconds used by
isDataStale(String) . |
java.lang.String |
getLang() |
java.lang.String |
getLang(java.lang.String name)
Returns the language that this container will use for translations and formatting.
|
long |
getLong() |
java.lang.Long |
getLong(java.lang.String name)
Returns the value as a long.
|
java.lang.String |
getName()
Returns the default name.
|
java.lang.String[] |
getNames()
Returns an array of all of the names for the named values that are in this container.
|
java.lang.String |
getRequestedUOM() |
java.lang.String |
getRequestedUOM(java.lang.String name)
Returns the Requested Unit of Measure.
|
java.lang.String |
getState() |
java.lang.String |
getState(java.lang.String name)
Returns the current State as defined by
Data.State . |
double |
getStatePercent() |
double |
getStatePercent(java.lang.String name)
Returns the percentage of where the current value lies within the range of the State.
|
java.lang.String |
getString() |
java.lang.String |
getString(java.lang.String name)
Returns the value as a string.
|
java.lang.String |
getStringFormatted(java.lang.String format) |
java.lang.String |
getStringFormatted(java.lang.String name,
java.lang.String format)
Returns the value formatted using the passed in format instead of the internal one.
|
java.lang.String |
getStringTranslated() |
java.lang.String |
getStringTranslated(java.lang.String name)
Returns the value as a String, translated.
|
long |
getTimeStamp() |
long |
getTimeStamp(java.lang.String name)
Returns the time stamp that was set by
updateTimeStamp(String) . |
Data.Type |
getType() |
Data.Type |
getType(java.lang.String name)
Returns the Type as defined by
Data.Type . |
java.lang.String |
getUOM() |
java.lang.String |
getUOM(java.lang.String name)
Returns the unit of measure.
|
java.lang.String |
getUOMAbbr() |
java.lang.String |
getUOMAbbr(java.lang.String name)
Returns a translated abbreviation of the unit of measure.
|
java.lang.String |
getUOMAbbrTranslated() |
java.lang.String |
getUOMAbbrTranslated(java.lang.String name)
Returns the unit of measure abbreviation as a String, translated.
|
java.lang.String |
getUOMDesc() |
java.lang.String |
getUOMDesc(java.lang.String name)
Returns a translated long description of the unit of measure.
|
java.lang.String |
getUOMDescTranslated() |
java.lang.String |
getUOMDescTranslated(java.lang.String name)
Returns the unit of measure long description as a String, translated.
|
java.lang.Object |
getValue() |
java.lang.Object |
getValue(java.lang.String name)
Returns the value as an Object.
|
java.lang.String |
getValueFormatted() |
java.lang.String |
getValueFormatted(java.lang.String name)
Returns the value formatted using the format string and translated.
|
boolean |
isDataStale() |
boolean |
isDataStale(java.lang.String name)
Returns true if the value is older than the specified interval.
|
boolean |
isDirty()
Returns true if the Data has changed.
|
boolean |
isEmpty() |
boolean |
isEmpty(java.lang.String name)
Returns true if the value is considered empty.
|
void |
remove(java.lang.String name)
Removes a named value from the container.
|
void |
set(Data d)
Copies all the named values from another Data instance as if it was cloning it.
|
Data |
setDirty(java.lang.Boolean dirty)
Sets the dirty flag.
|
Data |
setFormat(java.lang.String format) |
Data |
setFormat(java.lang.String name,
java.lang.String format)
Sets the format using the same syntax as
String.format(Locale, String, Object...) . |
Data |
setId(java.lang.String id)
Sets the Id for this instance.
|
Data |
setInterval(java.lang.Long value) |
Data |
setInterval(java.lang.String name,
java.lang.Long interval)
Sets the interval in milliseconds used by
isDataStale(String) . |
Data |
setLang(java.lang.String lang) |
Data |
setLang(java.lang.String name,
java.lang.String lang)
Sets the language to be used for translations and formatting of this value.
|
Data |
setName(java.lang.String name)
Sets or updates the default name.
|
Data |
setRequestedUOM(java.lang.String UOM) |
Data |
setRequestedUOM(java.lang.String name,
java.lang.String UOM)
Sets the Requested Unit of Measure.
|
Data |
setState(java.lang.String state) |
Data |
setState(java.lang.String name,
java.lang.String state)
Sets the State.
|
Data |
setStatePercent(java.lang.Double statepercent) |
Data |
setStatePercent(java.lang.String name,
java.lang.Double statepercent)
Sets the State Percentage.
|
Data |
setUOM(java.lang.String UOM) |
Data |
setUOM(java.lang.String name,
java.lang.String UOM)
Sets the unit of measure.
|
Data |
setValue(java.lang.Object value) |
Data |
setValue(java.lang.Object value,
java.lang.String UOM) |
Data |
setValue(java.lang.Object value,
java.lang.String UOM,
java.lang.String state) |
Data |
setValue(java.lang.Object value,
java.lang.String UOM,
java.lang.String state,
java.lang.Double pct)
As well as the standard
setValue(String, Object) ,
I have overloaded it to take value and UOM together as well as optionally,
State and Percentage when setting for the default name. |
Data |
setValue(java.lang.String name,
java.lang.Object value)
Sets the value for the object.
|
java.lang.String |
toString()
Returns the contents of all the named values of this instance as a JSON formatted string.
|
java.lang.String |
toString(java.lang.String name)
Returns the contents of this instances' named value as a JSON formatted string.
|
Data |
updateTimeStamp() |
Data |
updateTimeStamp(java.lang.String name)
Updates the time stamp to the current time in milliseconds
|
public Data(java.lang.String name, java.lang.Object value, java.lang.String UOM, java.lang.String state)
name
- The name of the value. Becomes the default name.value
- (Optional), the value. Default is "".UOM
- (Optional), the Unit of Measure of the value. Default is "".state
- (Optional), the initial State of the value. Default is "OFF".public Data(java.lang.String name, java.lang.Object value, java.lang.String UOM)
public Data(java.lang.String name, java.lang.Object value)
public Data(java.lang.String name)
public Data(Data data)
data
- The Data instance to copy.public void add(java.lang.String name, java.lang.Object value, java.lang.String UOM)
name
- The name of the value. Becomes the default name.value
- (Optional), the value. Default is "".UOM
- (Optional), the Unit of Measure of the value. Default is "".public void add(java.lang.String name, java.lang.Object value)
public void add(java.lang.String name)
public void add(Data d)
d
- The Data instance to copy from.public void set(Data d)
d
- The Data instance to copy from.public void remove(java.lang.String name)
name
- The name of the value.public Data addConversion(java.lang.String fromUOM, java.lang.String toUOM, double factor)
fromUOM
- The from unit of measuretoUOM
- The to unit of measurefactor
- The conversion factor to convert from to to.public Data addConversion(Data data)
data
- The data object to copy conversions frompublic boolean isDirty()
public Data setDirty(java.lang.Boolean dirty)
dirty
- The dirty flag.public boolean isDataStale(java.lang.String name)
name
- (Optional), the name of the value.public boolean isDataStale()
public boolean isEmpty(java.lang.String name)
name
- (Optional), the name of the value.public boolean isEmpty()
public java.lang.String getId()
public Data setId(java.lang.String id)
id
- The Id.public java.lang.String[] getNames()
public java.lang.String getName()
public Data setName(java.lang.String name)
name
- The new namepublic java.lang.Object getValue(java.lang.String name)
name
- (Optional), the name of the value.public java.lang.Object getValue()
public Data setValue(java.lang.String name, java.lang.Object value)
name
- (Optional), The name of the value.value
- The valuepublic Data setValue(java.lang.Object value)
public Data setValue(java.lang.Object value, java.lang.String UOM, java.lang.String state, java.lang.Double pct)
setValue(String, Object)
,
I have overloaded it to take value and UOM together as well as optionally,
State and Percentage when setting for the default name.value
- The value.UOM
- The unit of measure.state
- (Optionally), The State.pct
- (Optionally), The state percentagepublic Data setValue(java.lang.Object value, java.lang.String UOM, java.lang.String state)
public Data setValue(java.lang.Object value, java.lang.String UOM)
public java.lang.String getUOM(java.lang.String name)
name
- (Optional), the name of the value.public java.lang.String getUOM()
public Data setUOM(java.lang.String name, java.lang.String UOM)
name
- The name of the valueUOM
- The unit of measurepublic Data setUOM(java.lang.String UOM)
public java.lang.String getRequestedUOM(java.lang.String name)
name
- (Optional), The name of the value.public java.lang.String getRequestedUOM()
public Data setRequestedUOM(java.lang.String name, java.lang.String UOM)
name
- (Optional), The name of the value.UOM
- The unit of measure.public Data setRequestedUOM(java.lang.String UOM)
public java.lang.String getUOMAbbr(java.lang.String name)
name
- (Optional), The name of the value.public java.lang.String getUOMAbbr()
public java.lang.String getUOMDesc(java.lang.String name)
name
- (Optional), The name of the value.public java.lang.String getUOMDesc()
public Data.Type getType(java.lang.String name)
Data.Type
.name
- (Optional), The name of the value.public Data.Type getType()
public java.lang.String getFormat(java.lang.String name)
name
- (Optional), The name of the value.public java.lang.String getFormat()
public Data setFormat(java.lang.String name, java.lang.String format)
String.format(Locale, String, Object...)
.name
- (Optionally), The name of the value.format
- The format string.public Data setFormat(java.lang.String format)
public java.lang.String getState(java.lang.String name)
Data.State
.
Note: Other states can be added, it is just a string.name
- (Optional), The name of the value.public java.lang.String getState()
public Data setState(java.lang.String name, java.lang.String state)
name
- (Optionally), The name of the value.state
- The Statepublic Data setState(java.lang.String state)
public double getStatePercent(java.lang.String name)
name
- (Optional), The name of the value.public double getStatePercent()
public Data setStatePercent(java.lang.String name, java.lang.Double statepercent)
name
- (Optionally), The name of the value.statepercent
- The State Percentagepublic Data setStatePercent(java.lang.Double statepercent)
public java.lang.String getLang(java.lang.String name)
name
- (Optional), The name of the value.public java.lang.String getLang()
public Data setLang(java.lang.String name, java.lang.String lang)
name
- (Optional), The name of the value.lang
- The language formatted as {language}_{country}.public Data setLang(java.lang.String lang)
public long getInterval(java.lang.String name)
isDataStale(String)
.name
- (Optional), The name of the value.public long getInterval()
public Data setInterval(java.lang.String name, java.lang.Long interval)
isDataStale(String)
.name
- (Optional), The name of the value.interval
- millisecondspublic Data setInterval(java.lang.Long value)
public long getTimeStamp(java.lang.String name)
updateTimeStamp(String)
.name
- (Optional), The name of the value.public long getTimeStamp()
public Data updateTimeStamp(java.lang.String name)
name
- (Optional), The name of the value.public Data updateTimeStamp()
public java.lang.String getValueFormatted(java.lang.String name)
name
- The name of the value.public java.lang.String getValueFormatted()
public java.lang.String getString(java.lang.String name)
name
- (Optional), The name of the value.public java.lang.String getString()
public java.lang.String getStringTranslated(java.lang.String name)
name
- The name of the value.public java.lang.String getStringTranslated()
public java.lang.String getUOMAbbrTranslated(java.lang.String name)
name
- The name of the value.public java.lang.String getUOMAbbrTranslated()
public java.lang.String getUOMDescTranslated(java.lang.String name)
name
- The name of the value.public java.lang.String getUOMDescTranslated()
public java.lang.String getStringFormatted(java.lang.String name, java.lang.String format)
String.format(Locale, String, Object...)
.
If there is an error with the format syntax, that error is returned instead of the formatted value.name
- (Optional), The name of the value.format
- The format string. If blank, a default appropriate for the Type is used.public java.lang.String getStringFormatted(java.lang.String format)
public java.util.ArrayList<java.lang.Boolean> getBooleanArray(java.lang.String name)
name
- (Optional), The name of the value.public java.util.ArrayList<java.lang.Boolean> getBooleanArray()
public java.util.ArrayList<java.lang.Double> getDoubleArray(java.lang.String name)
name
- (Optional), The name of the value.public java.util.ArrayList<java.lang.Double> getDoubleArray()
public boolean getBoolean(java.lang.String name)
name
- (Optional), The name of the value.public boolean getBoolean()
public double getDouble(java.lang.String name)
name
- (Optional), The name of the value.public double getDouble()
public java.lang.Float getFloat(java.lang.String name)
name
- (Optional), The name of the value.public float getFloat()
public int getInteger(java.lang.String name)
name
- (Optional), The name of the value.public int getInteger()
public java.lang.Long getLong(java.lang.String name)
name
- (Optional), The name of the value.public long getLong()
public Data convertUOM(java.lang.String name, java.lang.String UOM)
public Data convertUOM(java.lang.String UOM)
public int compare(Data data, java.lang.String name)
data
- The Data instance to compare to.name
- (Optional) The specific named value to compare.public int compare(Data data)
public boolean equals(Data pData)
public boolean equals(java.lang.String name, double d)
public boolean equals(double d)
public boolean equals(java.lang.String name, boolean b)
public boolean equals(boolean b)
public boolean equals(java.lang.String name, float f)
public boolean equals(float f)
public boolean equals(java.lang.String name, int i)
public boolean equals(int i)
public boolean equals(java.lang.String name, long l)
public boolean equals(long l)
public boolean equals(java.lang.String name, java.lang.String s)
public boolean equals(java.lang.String s)
public boolean equalsIgnoreCase(java.lang.String name, java.lang.String s)
public boolean equalsIgnoreCase(java.lang.String s)
public java.lang.String toString(java.lang.String name)
{ "Name": "{Name}", "Type": "{Type}", "Value": "{Value}", "Format": "{Format}", "UOM": "{UOM}", "UOMAbbr": "{UOMAbbr}", "UOMDescr": "{UOMDescr}", "Lang": "{Lang}", "State": "{State}", "StatePercent": "{StatePercent}", "ValueFormatted": "{ValueFormatted}" }
name
- The name of the value.public java.lang.String toString()
{ "__Id": "{m_id}", "__DefaultName": "{m_defaultname}", "{Name1}": { "Name": "{Name1.Name}", "Type": "{Name1.Type}", "Value": "{Name1.Value}", "Format": "{Name1.Format}", "UOM": "{Name1.UOM}", "UOMAbbr": "{Name1.UOMAbbr}", "UOMDescr": "{Name1.UOMDescr}", "Lang": "{Name1.Lang}", "State": "{Name1.State}", "StatePercent": "{Name1.StatePercent}", "ValueFormatted": "{Name1.ValueFormatted}" } , "{NameX}": { "Name": "{NameX.Name}", ... } }
toString
in class java.lang.Object