|
Components |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
com.sas.util.transforms.ParseTransform
public class ParseTransform
Transform from String to numeric data using a Format
.
This transform converts between a String
to a number using the parseObject() method of the format object.
The Format can be a NumberFormat
,
any Format instance returned from SASFormat
(if you
wish to format using SAS formats), or any other class that extends from Format
.
Note that in the current release of the class libraries, parsing using the SASFormat classes in the com.sas.text package is not implemented.
You can create property links between two components
such that one object's property is set to the parsed
value of another property.
For example, if component A has a property X of type double,
and component B has a property Y of type String and you
want A.X to display the parsed numeric value of B.Y using
the DecimalFormat
#,###.##
,
you could use:
com.sas.PropertyLinkAdaptor(B, "Y", A, "X", new ParseTransform(new java.text.DecimalFormat("#,###.##")));
FormatTransform
,
Serialized FormField Summary | |
---|---|
static ParseTransform |
defaultInstance
A default instance which converts Strings to numbers using the Locale's default number format. |
protected java.text.ParsePosition |
pp
Parameter passed to parseObject; it is reset to position 0 before each call. |
Fields inherited from class com.sas.util.transforms.BaseFormatTransform |
---|
format, SASpattern |
Constructor Summary | |
---|---|
ParseTransform()
Construct a default FormatTransform which uses default rules to convert Strings to numeric values. |
|
ParseTransform(java.text.Format format)
Construct a FormatTransform which uses the parseObject method of the format object to convert Strings to numeric values. |
Method Summary | |
---|---|
void |
setSASFormat(java.lang.String pattern)
Set the SAS format pattern to use for parsing. |
java.lang.Object |
transform(java.lang.Object object)
Transform an object (a String) into another object by invoking the parseObject() method of the
format property available via getFormat()
If no format exists, the string is assumed to represent
a number and is parsed using DoubleData.valueOf(String) . |
Methods inherited from class com.sas.util.transforms.BaseFormatTransform |
---|
getDateFormat, getDecimalFormat, getFormat, getSASFormat, setDateFormat, setDecimalFormat, setFormat |
Field Detail |
---|
public static final ParseTransform defaultInstance
protected java.text.ParsePosition pp
Constructor Detail |
---|
public ParseTransform()
public ParseTransform(java.text.Format format)
Method Detail |
---|
public java.lang.Object transform(java.lang.Object object) throws com.sas.util.transforms.TransformException
parseObject()
method of the
format
property available via getFormat()
If no format exists, the string is assumed to represent
a number and is parsed using DoubleData.valueOf(String)
.
transform
in interface com.sas.util.transforms.TransformInterface
transform
in class BaseFormatTransform
object
- an object, normally a String, from which another object (normally a number)
is parsed. If the object is not a String, it's toString()
method
is invoked and the result is parsed.
Number
, but
it can be whatever is returned by getFormat().parseObject(object)
.
com.sas.util.transforms.TransformException
- if the
value cannot be parsed (i.e. parseObject() throws an exception).public void setSASFormat(java.lang.String pattern)
setSASFormat
in class BaseFormatTransform
java.lang.IllegalStateException
- in all cases, as SAS formats are not yet implemented.
|
Components |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |