| java.lang.Object com.mockrunner.util.common.CaseAwareMap
CaseAwareMap | public class CaseAwareMap implements Map(Code) | | Implementation of a Map that recognizes the case of the
keys, if the keys are strings. If isCaseSensitive is
true it behaves exactly like a HashMap .
If isCaseSensitive is false (which is the
default), it considers same strings with different case as equal.
I.e. if you do
put("test", "1");
put("TEST", "2");
the second put overwrites the value of the first one,
because the keys are considered to be equal. With
get("TesT");
you'll get the result "2" .
If you iterate through the keys (using either keySet or
entrySet ), you'll get the first added version of the key,
in the above case, you'll get "test" .
It is allowed to use non-strings as keys. In this case the Map
behaves like a usual HashMap .
Note: This class is similar to a TreeMap(String.CASE_INSENSITIVE_ORDER)
except that non-strings do not throw a ClassCastException
and that keys are not sorted.
|
CaseAwareMap | public CaseAwareMap()(Code) | | |
CaseAwareMap | public CaseAwareMap(boolean isCaseSensitive)(Code) | | |
clear | public void clear()(Code) | | |
containsValue | public boolean containsValue(Object value)(Code) | | |
isCaseSensitive | public boolean isCaseSensitive()(Code) | | Returns if keys are case sensitive. Defaults to false .
are keys case sensitive |
isEmpty | public boolean isEmpty()(Code) | | |
setCaseSensitive | public void setCaseSensitive(boolean isCaseSensitive)(Code) | | Sets if keys are case sensitive.
If set to true this implementation behaves like
a HashMap . Please note, that all entries are cleared
when switching case sensitivity. It's not possible to switch
and keep the entries.
Parameters: isCaseSensitive - are keys case sensitive |
|
|