Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.mortbay.util
Class StringMap

    java.lang.Object
      java.util.AbstractMap
          org.mortbay.util.StringMap

All Implemented Interfaces:
  java.io.Externalizable, java.io.Serializable, java.util.Map

    public class StringMap

extends java.util.AbstractMap
implements java.io.Externalizable

Map implementation Optimized for Strings keys.. 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.

Author:
  Greg Wilkins (gregw)
See Also:
  Serialized Form

Nested Class Summary

Nested classes/interfaces inherited from class java.util.AbstractMap
`java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V>`

Nested classes/interfaces inherited from interface java.util.Map
`java.util.Map.Entry<K,V>`

Field Summary
`protected static int` | `__HASH_WIDTH`
`protected java.util.HashSet` | `_entrySet`
`protected boolean` | `_ignoreCase`
`protected org.mortbay.util.StringMap.NullEntry` | `_nullEntry`
`protected java.lang.Object` | `_nullValue`
`protected org.mortbay.util.StringMap.Node` | `_root`
`protected java.util.Set` | `_umEntrySet`
`protected int` | `_width`
`static boolean` | `CASE_INSENSTIVE`

Constructor Summary
`StringMap()` Constructor.
`StringMap(boolean ignoreCase)` Constructor.
`StringMap(boolean ignoreCase, int width)` Constructor.

Method Summary
`void` | `clear()`
`boolean` | `containsKey(java.lang.Object key)`
`java.util.Set` | `entrySet()`
`java.lang.Object` | `get(java.lang.Object key)`
`java.lang.Object` | `get(java.lang.String key)`
`java.util.Map.Entry` | `getBestEntry(byte[] key, int offset, int maxLength)` Get a map entry by byte array key, using as much of the passed key as needed for a match.
`java.util.Map.Entry` | `getEntry(char[] key, int offset, int length)` Get a map entry by char array key.
`java.util.Map.Entry` | `getEntry(java.lang.String key, int offset, int length)` Get a map entry by substring key.
`int` | `getWidth()`
`boolean` | `isEmpty()`
`boolean` | `isIgnoreCase()`
`java.lang.Object` | `put(java.lang.Object key, java.lang.Object value)`
`java.lang.Object` | `put(java.lang.String key, java.lang.Object value)`
`void` | `readExternal(java.io.ObjectInput in)`
`java.lang.Object` | `remove(java.lang.Object key)`
`java.lang.Object` | `remove(java.lang.String key)`
`void` | `setIgnoreCase(boolean ic)` Set the ignoreCase attribute.
`void` | `setWidth(int width)` Set the hash width.
`int` | `size()`
`void` | `writeExternal(java.io.ObjectOutput out)`

Methods inherited from class java.util.AbstractMap
`clone, containsValue, equals, hashCode, keySet, putAll, toString, values`

Methods inherited from class java.lang.Object
`finalize, getClass, notify, notifyAll, wait, wait, wait`

Field Detail

### CASE_INSENSTIVE

    public static final boolean CASE_INSENSTIVE

See Also:
  Constant Field Values

### __HASH_WIDTH

    protected static final int __HASH_WIDTH

See Also:
  Constant Field Values

### _width

    protected int _width

### _root

    protected org.mortbay.util.StringMap.Node _root

### _ignoreCase

    protected boolean _ignoreCase

### _nullEntry

    protected org.mortbay.util.StringMap.NullEntry _nullEntry

### _nullValue

    protected java.lang.Object _nullValue

### _entrySet

    protected java.util.HashSet _entrySet

### _umEntrySet

    protected java.util.Set _umEntrySet

Constructor Detail

### StringMap

    public StringMap()

  Constructor.

### StringMap

    public StringMap(boolean ignoreCase)

  Constructor.

  Parameters:
    `ignoreCase` -

### StringMap

    public StringMap(boolean ignoreCase,
                     int width)

  Constructor.

  Parameters:
    `ignoreCase` -
    `width` - Width of hash tables, larger values are faster but use more memory.

Method Detail

### setIgnoreCase

    public void setIgnoreCase(boolean ic)

  Set the ignoreCase attribute.

  Parameters:
    `ic` - If true, the map is case insensitive for keys.

### isIgnoreCase

    public boolean isIgnoreCase()

### setWidth

    public void setWidth(int width)

  Set the hash width.

  Parameters:
    `width` - Width of hash tables, larger values are faster but use more memory.

### getWidth

    public int getWidth()

### put

    public java.lang.Object put(java.lang.Object key,
                                java.lang.Object value)

  Specified by:
    `put` in interface `java.util.Map`
  Overrides:
    `put` in class `java.util.AbstractMap`

### put

    public java.lang.Object put(java.lang.String key,
                                java.lang.Object value)

### get

    public java.lang.Object get(java.lang.Object key)

  Specified by:
    `get` in interface `java.util.Map`
  Overrides:
    `get` in class `java.util.AbstractMap`

### get

    public java.lang.Object get(java.lang.String key)

### getEntry

    public java.util.Map.Entry getEntry(java.lang.String key,
                                        int offset,
                                        int length)

  Get a map entry by substring key.

  Parameters:
    `key` - String containing the key
    `offset` - Offset of the key within the String.
    `length` - The length of the key
  Returns:
    The Map.Entry for the key or null if the key is not in the map.

### getEntry

    public java.util.Map.Entry getEntry(char[] key,
                                        int offset,
                                        int length)

  Get a map entry by char array key.

  Parameters:
    `key` - char array containing the key
    `offset` - Offset of the key within the array.
    `length` - The length of the key
  Returns:
    The Map.Entry for the key or null if the key is not in the map.

### getBestEntry

    public java.util.Map.Entry getBestEntry(byte[] key,
                                            int offset,
                                            int maxLength)

  Get a map entry by byte array key, using as much of the passed key as needed for a match. A simple 8859-1 byte to char mapping is assumed.

  Parameters:
    `key` - char array containing the key
    `offset` - Offset of the key within the array.
    `maxLength` - The length of the key
  Returns:
    The Map.Entry for the key or null if the key is not in the map.

### remove

    public java.lang.Object remove(java.lang.Object key)

  Specified by:
    `remove` in interface `java.util.Map`
  Overrides:
    `remove` in class `java.util.AbstractMap`

### remove

    public java.lang.Object remove(java.lang.String key)

### entrySet

    public java.util.Set entrySet()

  Specified by:
    `entrySet` in interface `java.util.Map`
  Specified by:
    `entrySet` in class `java.util.AbstractMap`

### size

    public int size()

  Specified by:
    `size` in interface `java.util.Map`
  Overrides:
    `size` in class `java.util.AbstractMap`

### isEmpty

    public boolean isEmpty()

  Specified by:
    `isEmpty` in interface `java.util.Map`
  Overrides:
    `isEmpty` in class `java.util.AbstractMap`

### containsKey

    public boolean containsKey(java.lang.Object key)

  Specified by:
    `containsKey` in interface `java.util.Map`
  Overrides:
    `containsKey` in class `java.util.AbstractMap`

### clear

    public void clear()

  Specified by:
    `clear` in interface `java.util.Map`
  Overrides:
    `clear` in class `java.util.AbstractMap`

### writeExternal

    public void writeExternal(java.io.ObjectOutput out)
                       throws java.io.IOException

  Specified by:
    `writeExternal` in interface `java.io.Externalizable`
  Throws:
    `java.io.IOException`

### readExternal

    public void readExternal(java.io.ObjectInput in)
                      throws java.io.IOException,
                             java.lang.ClassNotFoundException

  Specified by:
    `readExternal` in interface `java.io.Externalizable`
  Throws:
    `java.io.IOException`
    `java.lang.ClassNotFoundException`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 1995-2010 Mort Bay Consulting. All Rights Reserved.