| java.lang.Object org.apache.tomcat.util.collections.MultiMap
All known Subclasses: org.apache.tomcat.util.http.Parameters,
MultiMap | public class MultiMap (Code) | | An efficient representation for certain type of map. The keys
can have a single or multi values, but most of the time there are
single values.
The data is of "MessageBytes" type, meaning bytes[] that can be
converted to Strings ( if needed, and encoding is lazy-binded ).
This is a base class for MimeHeaders, Parameters and Cookies.
Data structures: each field is a single-valued key/value.
The fields are allocated when needed, and are recycled.
The current implementation does linear search, in future we'll
also use the hashkey.
author: dac@eng.sun.com author: James Todd [gonzo@eng.sun.com] author: Costin Manolache |
Inner Class :final class Field | |
Constructor Summary | |
public | MultiMap(int initial_size) |
Method Summary | |
public int | addField() Create a new, unitialized entry. | public int | find(String name, int starting) Find the index of a field with the given name. | public int | findFirst(String name) | public int | findIgnoreCase(String name, int starting) Find the index of a field with the given name. | public int | findNext(int startPos) | public MessageBytes | get(String name) | public MessageBytes | getName(int n) Returns the Nth header name
This may be used to iterate through all header fields. | public MessageBytes | getValue(int n) Returns the Nth header value
This may be used to iterate through all header fields. | public void | recycle() Clears all header fields. | public void | remove(int i) Removes the field at the specified position. | public int | size() Returns the current number of header fields. |
LAST | final static int LAST(Code) | | |
NEED_NEXT | final static int NEED_NEXT(Code) | | |
count | protected int count(Code) | | |
fields | protected Field[] fields(Code) | | |
MultiMap | public MultiMap(int initial_size)(Code) | | |
addField | public int addField()(Code) | | Create a new, unitialized entry.
|
find | public int find(String name, int starting)(Code) | | Find the index of a field with the given name.
|
findIgnoreCase | public int findIgnoreCase(String name, int starting)(Code) | | Find the index of a field with the given name.
|
findNext | public int findNext(int startPos)(Code) | | |
getName | public MessageBytes getName(int n)(Code) | | Returns the Nth header name
This may be used to iterate through all header fields.
An exception is thrown if the index is not valid ( <0 or >size )
|
getValue | public MessageBytes getValue(int n)(Code) | | Returns the Nth header value
This may be used to iterate through all header fields.
|
recycle | public void recycle()(Code) | | Clears all header fields.
|
remove | public void remove(int i)(Code) | | Removes the field at the specified position.
MultiMap will preserve the order of field add unless remove()
is called. This is not thread-safe, and will invalidate all
iterators.
This is not a frequent operation for Headers and Parameters -
there are better ways ( like adding a "isValid" field )
|
size | public int size()(Code) | | Returns the current number of header fields.
|
|
|