|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectjava.text.Format
com.davisor.data.Type
com.davisor.data.LocaleType
com.davisor.data.FormatType
com.davisor.data.SimpleNumberType
SimpleNumberType provides an abstract base class for all data types that manipulate simple numerical value. As with all the other types, the main function of SimpleNumberType is to convert number strings to number objects and back.
BetterDecimalFormat and
other subclasses of java.text.NumberFormat to parse
and format number strings. The formatter is selected and controlled
by the current number pattern, locale, and sample values. Please
see FormatType and LocaleType superclasses for more
information about how to set these attributes. Please see BetterDecimalFormat for more information about the exact number
pattern syntax.
A short, inaccurate and only informal simple number format syntax summary would be:
format := [prefix] mantissa [fraction] [exponent] [suffix]
mantissa := [ {"0"} {"#"} "," ] {"0"} {"#"}
fraction := "." {"0"} {"#"}
exponent := "E"|"e" [ {"0"} {"#"} | siPrefix ]
BetterDecimalFormat,
SimpleNumberValue,
Serialized Form| Nested Class Summary |
| Nested classes inherited from class java.text.Format |
java.text.Format.Field |
| Field Summary |
| Fields inherited from class com.davisor.data.FormatType |
M_pattern, M_sample |
| Fields inherited from class com.davisor.data.LocaleType |
DEFAULT_LOCALE, M_locale |
| Fields inherited from class com.davisor.data.Type |
METADATA_GROUP, METADATA_NAME, METADATA_PARENT, METADATA_SUBCHANNELS, TYPENAME |
| Constructor Summary | |
protected |
SimpleNumberType(SimpleNumberType snt)
Copy constructor. |
protected |
SimpleNumberType(java.lang.String typeName,
java.lang.String dataName,
java.lang.String id,
java.util.Map metaData,
java.util.Locale locale,
java.lang.String pattern,
java.lang.Object sample)
Creates a new simple number type. |
| Method Summary | |
byte |
byteValue(byte value)
Converts a byte value to an another byte value. |
byte |
byteValue(java.lang.String value,
java.text.ParsePosition status)
Converts a string to a byte value. |
protected java.text.Format |
createFormatter()
Creates a new format instance suitable for the purposes of this class. |
double |
doubleValue(double value)
Converts a double value to an another double value. |
double |
doubleValue(java.lang.String value,
java.text.ParsePosition status)
Converts a string to a double value. |
float |
floatValue(float value)
Converts a float value to an another float value. |
float |
floatValue(java.lang.String value,
java.text.ParsePosition status)
Converts a string to a float value. |
int |
intValue(int value)
Converts a integer value to an another int value. |
int |
intValue(java.lang.String value,
java.text.ParsePosition status)
Converts a string to an integer value. |
long |
longValue(long value)
Converts a long value to an another long value. |
long |
longValue(java.lang.String value,
java.text.ParsePosition status)
Converts a string to a long value. |
java.lang.Number |
numberValue(java.lang.String stringValue,
java.text.ParsePosition status)
Converts a string to a number value. |
short |
shortValue(short value)
Converts a short value to an another short value. |
short |
shortValue(java.lang.String value,
java.text.ParsePosition status)
Converts a string to a short value. |
java.lang.String |
stringValue(byte value)
Converts a byte value to a string. |
java.lang.String |
stringValue(double value)
Converts a double value to a string. |
java.lang.String |
stringValue(float value)
Converts a float value to a string. |
java.lang.String |
stringValue(int value)
Converts an integer value to a string. |
java.lang.String |
stringValue(long value)
Converts a long value to a string. |
java.lang.String |
stringValue(java.lang.Number value)
Converts a Number value to a string. |
java.lang.String |
stringValue(short value)
Converts a short value to a string. |
DataValue |
zero()
Gets the zero data value for this type. |
| Methods inherited from class com.davisor.data.FormatType |
clearFormatter, equals, getFormat, getFormatter, getPattern, getSample, getValueClass, hashCode, setFormat, setFormat, setLocale, setPattern, setSample |
| Methods inherited from class com.davisor.data.LocaleType |
getLocale, setLocale |
| Methods inherited from class com.davisor.data.Type |
ceil, check, check, compare, create, create, create, create, create, dup, dup, floor, format, getCompatibility, getDataName, getId, getID, getMetaData, getMetaData, getSpecs, getSQLCode, getSQLName, getSQLName, getTypeName, isNull, parseObject, register, register, setDataName, setId, setID, setMetaData, setMetaData, setSpecs, toData, toData, toData, toData, toString, toXML, xmlEnd, xmlStart |
| Methods inherited from class java.text.Format |
clone, format, formatToCharacterIterator, parseObject |
| Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface com.davisor.core.Dupable |
dup |
| Constructor Detail |
protected SimpleNumberType(SimpleNumberType snt)
protected SimpleNumberType(java.lang.String typeName,
java.lang.String dataName,
java.lang.String id,
java.util.Map metaData,
java.util.Locale locale,
java.lang.String pattern,
java.lang.Object sample)
typeName - type namedataName - data nameid - type identitymetaData - type meta data map (may be null)locale - type locale (may be null)pattern - format pattern (may be null)sample - format sample (may be null)FormatType.setLocale(java.util.Locale),
FormatType.setPattern(java.lang.String),
FormatType.setSample(java.lang.Object)| Method Detail |
protected java.text.Format createFormatter()
If current pattern is not empty, an instance of BetterDecimalFormat is configured with the current locale and
pattern. If current locale is null, US locale is
used instead (please note, that in this case US locale is used
as the default locale, regardless of system own default
locale). If current sample value is an instance of
java.lang.Number, the magnitude of that sample is
resolved, and the decimal format exponent hint is set with BetterDecimalFormat.setExponentHint(int).
If current pattern is
In any other case, no format can be created, and
null or empty, but current
locale is defined, a locale spesific number format is created
with java.text.NumberFormat.getInstance(Locale) and
returned.
null is returned.
createFormatter in class FormatType
LocaleType.getLocale(),
FormatType.getPattern(),
FormatType.getSample(),
BetterDecimalFormat
public byte byteValue(java.lang.String value,
java.text.ParsePosition status)
throws InvalidDataException
byteValue in interface NumberTypevalue - the string to be convertedstatus - parse status (may be null)
InvalidDataException - if the value cannot
be converted
public double doubleValue(java.lang.String value,
java.text.ParsePosition status)
throws InvalidDataException
doubleValue in interface NumberTypevalue - the string to be convertedstatus - parse status (may be null)
InvalidDataException - if the value cannot
be converted
public float floatValue(java.lang.String value,
java.text.ParsePosition status)
throws InvalidDataException
floatValue in interface NumberTypevalue - the string to be convertedstatus - parse status (may be null)
InvalidDataException - if the value cannot
be converted
public int intValue(java.lang.String value,
java.text.ParsePosition status)
throws InvalidDataException
intValue in interface NumberTypevalue - the string to be convertedstatus - parse status (may be null)
InvalidDataException - if the value cannot
be converted
public long longValue(java.lang.String value,
java.text.ParsePosition status)
throws InvalidDataException
longValue in interface NumberTypevalue - the string to be convertedstatus - parse status (may be null)
InvalidDataException - if the value cannot
be converted
public java.lang.Number numberValue(java.lang.String stringValue,
java.text.ParsePosition status)
throws InvalidDataException
LocaleType default locale
format. null or empty string value will evaluate to
null boolean value.
If the given string value contains trailing characters that can not be interpreted as a number value, a warning message will be printed to system error channel. This warning is neccessary since number string miss-interpretation is one of the most common and difficult practical data interpretation problems. In particular, different number formatting rules in different locales cause a lot of confusion, and the warning messages will significantly help to track these problems down.
numberValue in interface NumberTypestringValue - the string to be converted (may be null)status - parse status (may be null)
InvalidDataExeption - if value cannot be decoded
InvalidDataException - if the value cannot
be converted to a long value.FormatType.getFormatter()
public short shortValue(java.lang.String value,
java.text.ParsePosition status)
throws InvalidDataException
shortValue in interface NumberTypevalue - the string to be convertedstatus - parse status (may be null)
InvalidDataException - if the value cannot
be converted
public java.lang.String stringValue(byte value)
throws InvalidDataException
stringValue in interface NumberTypevalue - the value to be converted
InvalidDataException - if the value cannot
be convertedFormatType.getFormatter()
public java.lang.String stringValue(double value)
throws InvalidDataException
stringValue in interface NumberTypevalue - the value to be converted
InvalidDataException - if the value cannot
be convertedFormatType.getFormatter()
public java.lang.String stringValue(float value)
throws InvalidDataException
stringValue in interface NumberTypevalue - the value to be converted
InvalidDataException - if the value cannot
be convertedFormatType.getFormatter()
public java.lang.String stringValue(int value)
throws InvalidDataException
stringValue in interface NumberTypevalue - the value to be converted
InvalidDataException - if the value cannot
be convertedFormatType.getFormatter()
public java.lang.String stringValue(long value)
throws InvalidDataException
stringValue in interface NumberTypevalue - the value to be converted
InvalidDataException - if the value cannot
be convertedFormatType.getFormatter()
public java.lang.String stringValue(short value)
throws InvalidDataException
stringValue in interface NumberTypevalue - the value to be converted
InvalidDataException - if the value cannot
be convertedFormatType.getFormatter()
public java.lang.String stringValue(java.lang.Number value)
throws InvalidDataException
stringValue in interface NumberTypevalue - the value to be converted
InvalidDataException - if the value cannot
be convertedFormatType.getFormatter()public byte byteValue(byte value)
byteValue in interface NumberTypevalue - the value to be convertedpublic double doubleValue(double value)
doubleValue in interface NumberTypevalue - the value to be convertedpublic float floatValue(float value)
floatValue in interface NumberTypevalue - the value to be convertedpublic int intValue(int value)
intValue in interface NumberTypevalue - the value to be convertedpublic long longValue(long value)
longValue in interface NumberTypevalue - the value to be convertedpublic short shortValue(short value)
shortValue in interface NumberTypevalue - the value to be convertedpublic DataValue zero()
zero in class TypeDoubleData object sharing this typeDataValue.deinterpolate(com.davisor.data.DataValue, com.davisor.data.DataValue),
DataValue.interpolate(double, com.davisor.data.DataValue)
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||