org.mortbay.util
Class StringMap

java.lang.Object
  |
  +--java.util.AbstractMap
        |
        +--org.mortbay.util.StringMap
All Implemented Interfaces:
java.util.Map

public class StringMap
extends java.util.AbstractMap

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.

Version:
1.0 Thu Aug 16 2001
Author:
Greg Wilkins (gregw)

Inner classes inherited from class java.util.Map
java.util.Map.Entry
 
Constructor Summary
StringMap()
          Constructor.
StringMap(boolean ignoreCase)
          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 getEntry(byte[] key, int offset, int length)
          Get a map entry by byte array key.
 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.
 boolean isEmpty()
           
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
           
 java.lang.Object put(java.lang.String key, java.lang.Object value)
           
 java.lang.Object remove(java.lang.Object key)
           
 java.lang.Object remove(java.lang.String key)
           
 void setIgnoreCase(boolean ic)
          Set the ignoreCase attribute.
 int size()
           
 
Methods inherited from class java.util.AbstractMap
containsValue, equals, hashCode, keySet, putAll, toString, values
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StringMap

public StringMap()
Constructor.

StringMap

public StringMap(boolean ignoreCase)
Constructor.
Parameters:
ignoreCase -  
Method Detail

setIgnoreCase

public void setIgnoreCase(boolean ic)
Set the ignoreCase attribute.
Parameters:
ic - If true, the map is case insensitive for keys.

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
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)
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.

getEntry

public java.util.Map.Entry getEntry(byte[] key,
                                    int offset,
                                    int length)
Get a map entry by byte array key.
Parameters:
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
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)
Overrides:
remove in class java.util.AbstractMap

remove

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

entrySet

public java.util.Set entrySet()
Overrides:
entrySet in class java.util.AbstractMap

size

public int size()
Overrides:
size in class java.util.AbstractMap

isEmpty

public boolean isEmpty()
Overrides:
isEmpty in class java.util.AbstractMap

containsKey

public boolean containsKey(java.lang.Object key)
Overrides:
containsKey in class java.util.AbstractMap

clear

public void clear()
Overrides:
clear in class java.util.AbstractMap


Copyright © 2000 Mortbay Consulting Pty. Ltd. All Rights Reserved.