|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.mmbase.util.StringTagger
public class StringTagger
StringTagger, Creates a object with tags and fields from a String. Its ideal for name-value pairs and name-value pairs with multivalues. It also provides support for quoted values, and recognizes values that are 'function' calls with their own parameter list (allowing to ignore any tokens within these lists when parsing).
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface java.util.Map |
|---|
Map.Entry<K,V> |
| Constructor Summary | |
|---|---|
StringTagger(String line)
Creates a StringTag for the given line. |
|
StringTagger(String line,
char tagStart,
char tagSeparator,
char fieldSeparator,
char quote)
Creates a StringTag for the given line. |
|
StringTagger(String line,
char tagStart,
char tagSeparator,
char fieldSeparator,
char quote,
char functionOpen,
char functionClose)
Creates a StringTag for the given line. |
|
| Method Summary | |
|---|---|
void |
clear()
Clears all data |
boolean |
containsKey(Object ob)
Checks whether a key exits. |
boolean |
containsValue(Object ob)
Checks whether a value exits. |
protected void |
createTagger(String line)
Parses the given line, and stores all value-pairs found in the tokens and multitokens fields. |
Enumeration |
elements()
Returns a Enumeration of the values as String. |
Set |
entrySet()
returns all values |
boolean |
equals(Object ob)
Returns whether two objects are the same |
Object |
get(Object ob)
Returns the value of a key as an Object. |
int |
hashCode()
Hashcode for sorting and comparing |
boolean |
isEmpty()
Checks whether the tagger is empty |
Enumeration |
keys()
Returns a Enumeration of the name keys. |
Set |
keySet()
Returns a Set of the name keys. |
static void |
main(String[] args)
For testing |
Enumeration |
multiElements(String token)
Returns a Enumeration of the values as Vectors that contain the seperated values. |
Object |
put(Object key,
Object value)
sets a value (for the Map interface). |
void |
putAll(Map map)
Manually sets a set of values (for the Map interface). |
Object |
remove(Object key)
remove a value (for the Map interface). |
void |
setValue(String token,
String val)
Manually sets a single value. |
void |
setValues(String token,
Vector values)
Manually sets a multi-value value. |
int |
size()
sets a value (for the Map interface). |
protected void |
splitTag(String tag)
Handles and splits a tag in its component parts, and store the elemements in the tokens and multitokens fields. |
String |
toString()
toString |
String |
Value(String token)
Returns the first value as a String. |
Collection |
values()
returns all values |
Vector |
Values(String token)
Returns the values as a Vector that contains the separated values. |
String |
ValuesString(String token)
Returns the original parsed line |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public StringTagger(String line,
char tagStart,
char tagSeparator,
char fieldSeparator,
char quote,
char functionOpen,
char functionClose)
line - : to be tagged linetagStart - : Seperator for the TagstagSeparator - : Seperator inside the Tag (between name and value)fieldSeparator - : Seperator inside the valuequote - : Char used if a quoted valuefunctionOpen - char used to open a function parameter listfunctionClose - char used to close a function parameter list
public StringTagger(String line,
char tagStart,
char tagSeparator,
char fieldSeparator,
char quote)
line - : to be tagged linetagStart - : Seperator for the TagstagSeparator - : Seperator inside the Tag (between name and value)fieldSeparator - : Seperator inside the valuequote - : Char used if a quoted valuepublic StringTagger(String line)
line - : to be tagged line| Method Detail |
|---|
protected void createTagger(String line)
line - : to be tagged line (why is this a parameter when it can eb retrieved from startline?)protected void splitTag(String tag)
tag - the string containing the tagpublic void clear()
clear in interface Mappublic boolean containsKey(Object ob)
containsKey in interface Mappublic boolean containsValue(Object ob)
containsValue in interface Mappublic Set entrySet()
entrySet in interface Mappublic boolean equals(Object ob)
equals in interface Mapequals in class Objectob - the key of the value to retrievepublic Object get(Object ob)
Values(java.lang.String) to get a list of multi-values as a Vector.Value(java.lang.String) to get the first value as a String
get in interface Mapob - the key of the value to retrievepublic int hashCode()
hashCode in interface MaphashCode in class Objectpublic boolean isEmpty()
isEmpty in interface Mappublic Set keySet()
keySet in interface Map
public Object put(Object key,
Object value)
put in interface Mappublic void putAll(Map map)
putAll in interface Mappublic Object remove(Object key)
remove in interface Mappublic int size()
size in interface Mappublic Collection values()
values in interface Mappublic Enumeration keys()
public String toString()
toString in class Objectpublic Enumeration elements()
multiElements(java.lang.String) to get a list of multi-values.
public Enumeration multiElements(String token)
elements() to get a list of single, unseparated, values.
public Vector Values(String token)
get(java.lang.Object) to get the list of values as a StringValue(java.lang.String) to get the first value as a String
token - the key of the value to retrievepublic String ValuesString(String token)
token - unusedpublic String Value(String token)
String.
In case of a single value, it returns that value. In case of multiple values,
it returns the
Use get(java.lang.Object) to get the list of values as a StringValues(java.lang.String) to get a list of multi-values as a Vector.
token - the key of the value to retrieve
public void setValue(String token,
String val)
public void setValues(String token,
Vector values)
public static void main(String[] args)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||