Package org.simpleframework.common.parse
Class MapParser<T>
- java.lang.Object
-
- org.simpleframework.common.parse.Parser
-
- org.simpleframework.common.parse.MapParser<T>
-
- All Implemented Interfaces:
java.util.Map<T,T>
- Direct Known Subclasses:
QueryParser
public abstract class MapParser<T> extends Parser implements java.util.Map<T,T>
TheMapParserobject 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 thejava.util.Mapinterface and as such can be used with the Java collections framework. The internal map used by this is aHashtable, however subclasses are free to assign a different type to the map used.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedMapParser()Constructor for theMapParserobject.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Theclearmethod is used to wipe out all the currently existing tokens from the collection.booleancontainsKey(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.booleancontainsValue(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<java.util.Map.Entry<T,T>>entrySet()This method is used to acquire the name and value pairs that have currently been collected by this parser.Tget(java.lang.Object name)Thegetmethod is used to acquire the value for a named pair.java.util.List<T>getAll(java.lang.Object key)This method is used to acquire aListfor all of the values that have been put in to the map.booleanisEmpty()This method is used to determine whether the parser has any tokens available.java.util.Set<T>keySet()This is used to acquire the names for all the tokens that have currently been collected by this parser.Tput(T name, T value)Theputmethod is used to insert the name and value provided into the collection of tokens.voidputAll(java.util.Map<? extends T,? extends T> data)This method is used to insert a collection of tokens into the parsers map.Tremove(java.lang.Object name)Theremovemethod is used to remove the named token pair from the collection of tokens.intsize()This obviously enough provides the number of tokens that have been inserted into the internal map.java.util.Collection<T>values()This method is used to acquire the value for all tokens that have currently been collected by this parser.-
Methods inherited from class org.simpleframework.common.parse.Parser
digit, ensureCapacity, init, parse, parse, skip, space, toLower
-
-
-
-
Constructor Detail
-
MapParser
protected MapParser()
Constructor for theMapParserobject. This is used to create a new parser that makes use of a thread safe map implementation. TheHashMapis used so that the resulting parser can be accessed in a concurrent environment with the fear of data corruption.
-
-
Method Detail
-
containsKey
public 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. The object passed into this method should be a string, as all tokens stored within the map will be stored as strings.
-
containsValue
public 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. If one or more pairs within the collected tokens contains the value provided then this method will return true.
-
entrySet
public java.util.Set<java.util.Map.Entry<T,T>> entrySet()
This method is used to acquire the name and value pairs that have currently been collected by this parser. This is used to determine which tokens have been extracted from the source. It is useful when the tokens have to be gathered.
-
get
public T get(java.lang.Object name)
Thegetmethod 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.
-
getAll
public java.util.List<T> getAll(java.lang.Object key)
This method is used to acquire aListfor all of the values that have been put in to the map. The list allows all values associated with the specified key. This enables a parser to collect a number of associated tokens.- Parameters:
key- this is the key used to search for the value- Returns:
- this is the list of values associated with the key
-
isEmpty
public boolean isEmpty()
This method is used to determine whether the parser has any tokens available. If thesizeis zero then the parser is empty and this returns true. The is acts as a proxy the theisEmptyof the internal map.
-
keySet
public java.util.Set<T> keySet()
This is used to acquire the names for all the tokens that have currently been collected by this parser. This is used to determine which tokens have been extracted from the source. It is useful when the tokens have to be gathered.
-
put
public T put(T name, T value)
Theputmethod 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.
-
putAll
public void putAll(java.util.Map<? extends T,? extends T> data)
This method is used to insert a collection of tokens into the parsers map. This is used when another source of tokens is required to populate the connection currently maintained within this parsers internal map. Any tokens that currently exist with similar names will be overwritten by this.
-
remove
public T remove(java.lang.Object name)
Theremovemethod 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.
-
size
public int size()
This obviously enough provides the number of tokens that have been inserted into the internal map. This acts as a proxy method for the internal mapsize.
-
values
public java.util.Collection<T> values()
This method is used to acquire the value for all tokens that have currently been collected by this parser. This is used to determine which tokens have been extracted from the source. It is useful when the tokens have to be gathered.
-
-