|
| Components |
|
| |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||||
com.sas.util.transforms.StringToDictionaryInterfaceTransform
public class StringToDictionaryInterfaceTransform
A transform for converting a String to a DictionaryInterface.
This works by tokenizing the input. Data that looks like an int
is converted to a ; long ints are converted
to IntegerLong objects;
floating point values are converted to objects,
true/false are converted
to Double,
character literals are converted to a Boolean object,
and pretty much everything else is converted to a Character.
String values may be quoted if they contain leading or trailing spaces,
quotes, or commas.
String
Each item should be of the form key=value. For example, the String
a=5,b=9,c=4.5,d="a string","a string, no?"=d,100=maxwill create a
Dictionary with 6 items:
| Key | Key type | Value | Value type | |
| "a" | java.lang.String | 5 | java.lang.Integer | |
| "b" | java.lang.String | 9 | java.lang.Integer | |
| "c" | java.lang.String | 4.5 | java.lang.Double | |
| "d" | java.lang.String | "a string" | java.lang.String | |
| "a string, no?" | java.lang.String | "d" | java.lang.String | |
| 100 | java.lang.Integer | "max" | java.lang.String |
DictionaryInterfaceToStringTransform,
Serialized Form| Field Summary | |
|---|---|
static StringToDictionaryInterfaceTransform |
defaultInstance
A default instance which can perform the transformation. |
java.lang.Class |
dictionaryClass
Which class to use to make DictionaryInterface instances. |
| Constructor Summary | |
|---|---|
StringToDictionaryInterfaceTransform()
Default constructor which uses a ',' delimiter. |
|
StringToDictionaryInterfaceTransform(char delimiter)
Construct a transform which uses a specific delimiter. |
|
StringToDictionaryInterfaceTransform(char delimiter,
char separator)
Construct a transform which uses a specific delimiter. |
|
| Method Summary | |
|---|---|
protected static char |
defaultDelimiterChar()
|
java.lang.Class |
getInputClass()
|
java.lang.Class |
getOutputClass()
|
protected DictionaryInterface |
newDictionary()
Factory method to create a DictionaryInterface instance
when transforming an object. |
DictionaryInterface |
transform(DictionaryInterface dictionary,
java.lang.String text)
Transform a text string into a Dictionary |
java.lang.Object |
transform(java.lang.Object object)
Transform a String to a DictionaryInterface |
| Field Detail |
|---|
public static final StringToDictionaryInterfaceTransform defaultInstance
public java.lang.Class dictionaryClass
DictionaryInterface instances.
Defaults to com.sas.collection.Dictionary.class, but
subclasses may prefer another class that implements
DictionaryInterface. The class must have a public no-arg constructor.
| Constructor Detail |
|---|
public StringToDictionaryInterfaceTransform()
',' delimiter.
public StringToDictionaryInterfaceTransform(char delimiter)
delimiter - the item delimiter.
public StringToDictionaryInterfaceTransform(char delimiter,
char separator)
delimiter - the item delimiter.| Method Detail |
|---|
protected static char defaultDelimiterChar()
public java.lang.Object transform(java.lang.Object object)
throws com.sas.util.transforms.TransformException
String to a DictionaryInterface
transform in interface com.sas.util.transforms.TransformInterfaceobject - null or a String; it contains a comma separated list of items.
Individual items need not be quoted, but quotes are required to preserve
leading and/or trailing space, or of the item contains special characters,
such as escaped characters, a comma, or a '"' double quote.
com.sas.util.transforms.TransformException - if
the transform(dictionary, Object) method throws an exception
java.lang.ClassCastException - if object
is not a Stringprotected DictionaryInterface newDictionary()
DictionaryInterface instance
when transforming an object. Creates an instance of the
class referenced in dictionaryClass, or Dictionary if that is null.
public DictionaryInterface transform(DictionaryInterface dictionary,
java.lang.String text)
throws com.sas.util.transforms.TransformException
Dictionary
dictionary - items parsed from the text are put into this dictionary,text - a comma separated list of items.delimiter - the delimiter which separates the items.
com.sas.util.transforms.TransformException - if
the there is an error parsing the textpublic java.lang.Class getInputClass()
getInputClass in interface com.sas.util.transforms.TransformInputOutputInterfacepublic java.lang.Class getOutputClass()
getOutputClass in interface com.sas.util.transforms.TransformInputOutputInterface
|
| Components |
|
| |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||||