|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsimple.util.parse.Parser
simple.util.parse.MapParser
public abstract class MapParser
The MapParser
object represents a parser for name
value pairs. Any parser extending this will typically be parsing
name=value tokens or the like, and inserting these pairs into
the internal map. This type of parser is useful as it exposes all
pairs extracted using the java.util.Map
interface
and as such can be used with the Java collections framework. The
internal map used by this is a Hashtable
, however
subclasses are free to assign a different type to the map used.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface java.util.Map |
---|
java.util.Map.Entry<K,V> |
Field Summary | |
---|---|
protected java.util.Hashtable |
map
This is the internal map that provides storage for tokens. |
Fields inherited from class simple.util.parse.Parser |
---|
buf, count, off |
Constructor Summary | |
---|---|
protected |
MapParser()
Constructor for the MapParser object. |
Method Summary | |
---|---|
void |
clear()
The clear method is used to wipe out all the
currently existing tokens from the collection. |
boolean |
containsKey(java.lang.Object name)
This is used to determine whether a token representing the name of a pair has been inserted into the internal map. |
boolean |
containsValue(java.lang.Object value)
This method is used to determine whether any pair that has been inserted into the internal map had the presented value. |
java.util.Set |
entrySet()
This method is used to acquire the name and value pairs that have currently been collected by this parser. |
java.lang.Object |
get(java.lang.Object name)
The get method is used to acquire the value for
a named pair. |
boolean |
isEmpty()
Thsi method is used to determine whether the parser has any tokens available. |
java.util.Set |
keySet()
This is used to acquire the names for all the tokens that have currently been collected by this parser. |
java.lang.Object |
put(java.lang.Object name,
java.lang.Object value)
The put method is used to insert the name and
value provided into the collection of tokens. |
void |
putAll(java.util.Map data)
This method is used to insert a collection of tokens into the parsers map. |
java.lang.Object |
remove(java.lang.Object name)
The remove method is used to remove the named
token pair from the collection of tokens. |
int |
size()
This obviously enough provides the number of tokens that have been inserted into the internal map. |
java.lang.String |
token(java.lang.Object name)
The token method is used to acquire the value
as a string. |
java.util.Collection |
values()
This method is used to acquire the value for all tokens that have currently been collected by this parser. |
Methods inherited from class simple.util.parse.Parser |
---|
digit, ensureCapacity, init, parse, parse, skip, space, toLower |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.util.Map |
---|
equals, hashCode |
Field Detail |
---|
protected java.util.Hashtable map
Constructor Detail |
---|
protected MapParser()
MapParser
object. This is
used to create a new parser that makes use of a thread safe
map implementation. The Hashtable
is used so
that the resulting parser can be accessed in a concurrent
environment with the fear of data corruption.
Method Detail |
---|
public int size()
size
.
size
in interface java.util.Map
public boolean isEmpty()
size
is zero then the
parser is empty and this returns true. The is acts as a
proxy the the isEmpty
of the internal map.
isEmpty
in interface java.util.Map
public boolean containsKey(java.lang.Object name)
containsKey
in interface java.util.Map
name
- this is the name of a pair within the map
public boolean containsValue(java.lang.Object value)
containsValue
in interface java.util.Map
value
- this is the value that is to be searched for
public java.lang.Object get(java.lang.Object name)
get
method is used to acquire the value for
a named pair. So if a pair of name=value has been parsed and
inserted into the collection of tokens this will return the
value given the name. The value returned will be a string.
get
in interface java.util.Map
name
- this is a string used to search for the value
public java.lang.String token(java.lang.Object name)
token
method is used to acquire the value
as a string. So if a pair of name=value has been parsed and
inserted into the collection of tokens this will return the
value given the name. The value returned will be a string.
name
- this is a string used to search for the value
public java.lang.Object put(java.lang.Object name, java.lang.Object value)
put
method is used to insert the name and
value provided into the collection of tokens. Although it is
up to the parser to decide what values will be inserted it
is generally the case that the inserted tokens will be text.
put
in interface java.util.Map
name
- this is the name token from a name=value pairvalue
- this is the value token from a name=value pair
public java.lang.Object remove(java.lang.Object name)
remove
method is used to remove the named
token pair from the collection of tokens. This acts like a
take, in that it will get the token value and remove if
from the collection of tokens the parser has stored.
remove
in interface java.util.Map
name
- this is a string used to search for the value
public void putAll(java.util.Map data)
putAll
in interface java.util.Map
data
- this is the collection of tokens to be addedpublic java.util.Set keySet()
keySet
in interface java.util.Map
public java.util.Collection values()
values
in interface java.util.Map
public java.util.Set entrySet()
entrySet
in interface java.util.Map
public void clear()
clear
method is used to wipe out all the
currently existing tokens from the collection. This is used
to recycle the parser so that it can be used to parse some
other source of tokens without any lingering state.
clear
in interface java.util.Map
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |