org.mortbay.util
Class StringMap
AbstractMap
org.mortbay.util.StringMap
- Externalizable
public class StringMap
extends AbstractMap
implements Externalizable
Map like class of Strings to Objects.
This String Map has been optimized for mapping small sets of
Strings where the most frequently accessed Strings have been put to
the map first.
It also has the benefit that it can look up entries by substring or
sections of char and byte arrays. This can prevent many String
objects from being created just to look up in the map.
This map is NOT synchronized.
$Id: StringMap.java,v 1.13 2004/10/23 09:03:22 gregwilkins Exp $
_entrySet
protected HashSet _entrySet
_ignoreCase
protected boolean _ignoreCase
_nullEntry
protected org.mortbay.util.StringMap.NullEntry _nullEntry
_nullValue
protected Object _nullValue
_root
protected org.mortbay.util.StringMap.Node _root
_umEntrySet
protected Set _umEntrySet
_width
protected int _width
StringMap
public StringMap()
Constructor.
StringMap
public StringMap(boolean ignoreCase)
Constructor.
StringMap
public StringMap(boolean ignoreCase,
int width)
Constructor.
ignoreCase
- width
- Width of hash tables, larger values are faster but
use more memory.
containsKey
public boolean containsKey(Object key)
entrySet
public Set entrySet()
get
public Object get(Object key)
get
public Object get(String key)
getEntry
public Map.Entry getEntry(String key,
int offset,
int length)
Get a map entry by substring key.
key
- String containing the keyoffset
- Offset of the key within the String.length
- The length of the key
- The Map.Entry for the key or null if the key is not in
the map.
getEntry
public Map.Entry getEntry(byte[] key,
int offset,
int length)
Get a map entry by byte array key.
key
- byte array containing the key. A simple ASCII byte
to char mapping is used.offset
- Offset of the key within the array.length
- The length of the key
- The Map.Entry for the key or null if the key is not in
the map.
getEntry
public Map.Entry getEntry(char[] key,
int offset,
int length)
Get a map entry by char array key.
key
- char array containing the keyoffset
- Offset of the key within the array.length
- The length of the key
- The Map.Entry for the key or null if the key is not in
the map.
getWidth
public int getWidth()
isEmpty
public boolean isEmpty()
isIgnoreCase
public boolean isIgnoreCase()
put
public Object put(Object key,
Object value)
put
public Object put(String key,
Object value)
readExternal
public void readExternal(java.io.ObjectInput in)
throws java.io.IOException,
ClassNotFoundException
remove
public Object remove(Object key)
remove
public Object remove(String key)
setIgnoreCase
public void setIgnoreCase(boolean ic)
Set the ignoreCase attribute.
ic
- If true, the map is case insensitive for keys.
setWidth
public void setWidth(int width)
Set the hash width.
width
- Width of hash tables, larger values are faster but
use more memory.
writeExternal
public void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException
Copyright © 2004 Mortbay Consulting Pty. Ltd. All Rights Reserved.