|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.text.Format com.pcauto.util.QuantityFormat com.pcauto.util.WeightFormat
WeightFormat
provides several mechanisms to use Weight
objects:
Weight
objects
Locale based constructors use a default scale of 2. The parse and format
methods are used to generate and format Weight
objects respectively.
Nested Class Summary |
Nested classes inherited from class java.text.Format |
java.text.Format.Field |
Field Summary |
Fields inherited from class com.pcauto.util.QuantityFormat |
groupingUsed, scale, units |
Constructor Summary | |
WeightFormat()
Constructs new WeightFormat instance based on default
Locale . |
|
WeightFormat(java.util.Locale loc)
Constructs new WeightFormat instance based on supplied
Locale . |
|
WeightFormat(WeightUnits units,
int scale)
Constructs new WeightFormat with units set to
WeightUnits units and scale set to int scale. |
Method Summary | |
java.lang.Object |
clone()
Creates new WeightFormat object based on this
WeightFormat . |
java.lang.StringBuffer |
format(java.lang.Object obj,
java.lang.StringBuffer toAppendTo,
java.text.FieldPosition pos)
Returns StringBuffer with supplied Weight
quantity formatted in units. |
java.lang.String |
formatWeight(Weight wt)
Returns String with supplied Weight
quantity formatted in units. |
WeightUnits |
getUnits()
Gets value for measurement units. |
java.lang.Object |
parseObject(java.lang.String source,
java.text.ParsePosition pos)
Parses String based on units to return a
Weight object. |
Weight |
parseWeight(java.lang.String value)
Parses String based on units to return a
Weight object. |
void |
setUnits(WeightUnits units)
Sets value for measurement units. |
Methods inherited from class com.pcauto.util.QuantityFormat |
getScale, isGroupingUsed, setGroupingUsed, setScale |
Methods inherited from class java.text.Format |
format, formatToCharacterIterator, parseObject |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public WeightFormat()
WeightFormat
instance based on default
Locale
.
public WeightFormat(java.util.Locale loc)
WeightFormat
instance based on supplied
Locale
.
loc
- Locale
to set correct measurement unitspublic WeightFormat(WeightUnits units, int scale)
WeightFormat
with units set to
WeightUnits
units and scale set to int
scale.
units
- WeightUnits
to set unitsscale
- int
to set scaleMethod Detail |
public java.lang.String formatWeight(Weight wt)
String
with supplied Weight
quantity formatted in units.
wt
- Weight
object from which to format value
String
weight in current unitspublic java.lang.StringBuffer format(java.lang.Object obj, java.lang.StringBuffer toAppendTo, java.text.FieldPosition pos)
StringBuffer
with supplied Weight
quantity formatted in units.
obj
- Object
object from which to format valuetoAppendTo
- StringBuffer
string buffer to append topos
- FieldPosition
ignored but can't be null
StringBuffer
weight in current units
IllegalArguementException
- if obj is not a
Weight
.public Weight parseWeight(java.lang.String value)
String
based on units to return a
Weight
object.
public java.lang.Object parseObject(java.lang.String source, java.text.ParsePosition pos)
String
based on units to return a
Weight
object.
source
- String
to be converted
to Weight
objectpos
- ParsePosition
(can't be null)
Object
a Weight
holding a value specified
in input String
NumberFormatException
- on
non-numeric String
inputpublic java.lang.Object clone()
WeightFormat
object based on this
WeightFormat
.
public void setUnits(WeightUnits units)
public WeightUnits getUnits()
WeightUnits
value of current measurement units
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |