public class IndexMap extends Object implements Serializable, Cloneable
Modifier and Type | Class and Description |
---|---|
static class |
IndexMap.ListIndexMap
Provide access to the index map via list interface.
|
static class |
IndexMap.MapIndexMap
Provide access to the index map via map interface.
|
Constructor and Description |
---|
IndexMap()
Create a new index map.
|
IndexMap(List list,
Map map)
Create a new index map using the specified collections as backup.
|
Modifier and Type | Method and Description |
---|---|
void |
add(int index,
Object element)
Unsupported method, due to missing key parameter.
|
void |
add(int index,
Object key,
Object o)
Add an object to the collection.
|
boolean |
add(Object o)
Unsupported method, due to missing key parameter.
|
void |
add(Object key,
Object o)
Add a new object with key and value.
|
boolean |
addAll(Collection c)
Unsupported method, due to missing key parameter.
|
boolean |
addAll(int index,
Collection c)
Unsupported method, due to missing key parameter.
|
void |
clear()
Removes all mappings from this map.
|
Object |
clone()
Clone an index map.
|
boolean |
contains(Object o)
Returns true if this list contains the specified element.
|
boolean |
containsAll(Collection c)
Returns true if this list contains all of the elements of the
specified collection.
|
boolean |
containsKey(Object key)
Returns true if this map contains a mapping for the specified
key.
|
boolean |
containsValue(Object value)
Returns true if this map maps one or more keys to the
specified value.
|
Set |
entrySet()
Returns a set view of the mappings contained in this map.
|
boolean |
equals(Object o)
Compares the specified object with this map for equality.
|
Object |
get(int index)
Returns the element at the specified position in this list.
|
Object |
get(Object key)
Returns the value to which this map maps the specified key.
|
List |
getAsList()
Return an instance of this index map accessible via list interface.
|
Map |
getAsMap()
Return an instance of this index map accessible via map interface.
|
Object |
getKey(int index)
Get an indexed key.
|
Object[] |
getKeys()
Get the keys as array.
|
Object[] |
getKeys(Class type)
Get the keys as array.
|
Object[] |
getObjects()
Get the values as array.
|
Object[] |
getObjects(Class type)
Get the values as array.
|
int |
hashCode()
Returns the hash code value for this map.
|
int |
indexOf(Object o)
Returns the index in this list of the first occurrence of the specified
element, or -1 if this list does not contain this element.
|
boolean |
isEmpty()
Returns true if this map contains no key-value mappings.
|
Iterator |
iterator()
Returns an iterator over the elements in this list in proper sequence.
|
Set |
keySet()
Returns a set view of the keys contained in this map.
|
int |
lastIndexOf(Object o)
Returns the index in this list of the last occurrence of the specified
element, or -1 if this list does not contain this element.
|
ListIterator |
listIterator()
Returns a list iterator of the elements in this list (in proper
sequence).
|
ListIterator |
listIterator(int index)
Returns a list iterator of the elements in this list (in proper
sequence), starting at the specified position in this list.
|
Object |
put(Object key,
Object value)
Associates the specified value with the specified key in this map
(optional operation).
|
void |
putAll(Map t)
Copies all of the mappings from the specified map to this map
(optional operation).
|
Object |
remove(int index)
Removes the element at the specified position in this list.
|
boolean |
removeAll(Collection c)
Removes from this list all the elements that are contained in the
specified collection.
|
Object |
removeKey(Object key)
Removes the mapping for this key from this map if it is present.
|
boolean |
removeValue(Object o)
Removes the first occurrence in this list of the specified element.
|
Object |
replace(Object key,
Object o)
Replace an object for the given key.
|
boolean |
retainAll(Collection c)
Retains only the elements in this list that are contained in the
specified collection.
|
Object |
set(int index,
Object element)
Replaces the element at the specified position in this list with the
specified element.
|
int |
size()
Returns the number of key-value mappings in this map.
|
List |
subList(int fromIndex,
int toIndex)
Unsupported method.
|
Object[] |
toArray()
Returns an array containing all of the elements in this list in proper
sequence.
|
Object[] |
toArray(Object[] array)
Returns an array containing all of the elements in this list in proper
sequence; the runtime type of the returned array is that of the
specified array.
|
String |
toString()
Create a string representation of this map.
|
Collection |
values()
Returns a collection view of the values contained in this map.
|
public int size()
public boolean isEmpty()
public boolean containsKey(Object key)
key
- key whose presence in this map is to be tested.ClassCastException
- if the key is of an inappropriate type for
this map (optional).NullPointerException
- if the key is null and this map
does not not permit null keys (optional).public boolean containsValue(Object value)
value
- value whose presence in this map is to be tested.ClassCastException
- if the value is of an inappropriate type for
this map (optional).NullPointerException
- if the value is null and this map
does not not permit null values (optional).public Object get(Object key)
More formally, if this map contains a mapping from a key k to a value v such that (key==null ? k==null : key.equals(k)), then this method returns v; otherwise it returns null. (There can be at most one such mapping.)
key
- key whose associated value is to be returned.ClassCastException
- if the key is of an inappropriate type for
this map (optional).NullPointerException
- key is null and this map does not
not permit null keys (optional).containsKey(Object)
public Object put(Object key, Object value)
m.containsKey(k)
would return
true.))key
- key with which the specified value is to be associated.value
- value to be associated with the specified key.UnsupportedOperationException
- if the put operation is
not supported by this map.ClassCastException
- if the class of the specified key or value
prevents it from being stored in this map.IllegalArgumentException
- if some aspect of this key or value
prevents it from being stored in this map.NullPointerException
- this map does not permit null
keys or values, and the specified key or value is
null.public void putAll(Map t)
put(k, v)
on this map once
for each mapping from key k to value v in the
specified map. The behavior of this operation is unspecified if the
specified map is modified while the operation is in progress.t
- Mappings to be stored in this map.UnsupportedOperationException
- if the putAll method is
not supported by this map.ClassCastException
- if the class of a key or value in the
specified map prevents it from being stored in this map.IllegalArgumentException
- some aspect of a key or value in the
specified map prevents it from being stored in this map.NullPointerException
- the specified map is null, or if
this map does not permit null keys or values, and the
specified map contains null keys or values.public void clear()
public Set keySet()
public Collection values()
public Set entrySet()
public boolean equals(Object o)
public int hashCode()
hashCode
in class Object
Object.hashCode()
,
Object.equals(Object)
,
equals(Object)
public String toString()
public boolean contains(Object o)
o
- element whose presence in this list is to be tested.ClassCastException
- if the type of the specified element
is incompatible with this list (optional).NullPointerException
- if the specified element is null and this
list does not support null elements (optional).public Iterator iterator()
public Object[] toArray()
Arrays.asList(Object[])
public Object[] toArray(Object[] array)
array
- the array into which the elements of this list are to
be stored, if it is big enough; otherwise, a new array of the
same runtime type is allocated for this purpose.ArrayStoreException
- if the runtime type of the specified array
is not a supertype of the runtime type of every element in
this list.NullPointerException
- if the specified array is null.public boolean containsAll(Collection c)
c
- collection to be checked for containment in this list.ClassCastException
- if the types of one or more elements
in the specified collection are incompatible with this
list (optional).NullPointerException
- if the specified collection contains one
or more null elements and this list does not support null
elements (optional).NullPointerException
- if the specified collection is
null.contains(Object)
public boolean removeAll(Collection c)
c
- collection that defines which elements will be removed from
this list.ClassCastException
- if the types of one or more elements
in this list are incompatible with the specified
collection (optional).NullPointerException
- if this list contains one or more
null elements and the specified collection does not support
null elements (optional).NullPointerException
- if the specified collection is
null.removeValue(Object)
,
contains(Object)
public boolean retainAll(Collection c)
c
- collection that defines which elements this set will retain.ClassCastException
- if the types of one or more elements
in this list are incompatible with the specified
collection (optional).NullPointerException
- if this list contains one or more
null elements and the specified collection does not support
null elements (optional).NullPointerException
- if the specified collection is
null.removeValue(Object)
,
contains(Object)
public Object get(int index)
index
- index of element to return.IndexOutOfBoundsException
- if the index is out of range (index
< 0 || index >= size()).public Object set(int index, Object element)
index
- index of element to replace.element
- element to be stored at the specified position.ClassCastException
- if the class of the specified element
prevents it from being added to this list.NullPointerException
- if the specified element is null and
this list does not support null elements.IllegalArgumentException
- if some aspect of the specified
element prevents it from being added to this list.IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index >= size()).public Object remove(int index)
index
- the index of the element to removed.IndexOutOfBoundsException
- if the index is out of range (index
< 0 || index >= size()).public int indexOf(Object o)
o
- element to search for.ClassCastException
- if the type of the specified element
is incompatible with this list (optional).NullPointerException
- if the specified element is null and this
list does not support null elements (optional).public int lastIndexOf(Object o)
o
- element to search for.ClassCastException
- if the type of the specified element
is incompatible with this list (optional).NullPointerException
- if the specified element is null and this
list does not support null elements (optional).public ListIterator listIterator()
public ListIterator listIterator(int index)
index
- index of first element to be returned from the
list iterator (by a call to the next method).IndexOutOfBoundsException
- if the index is out of range (index
< 0 || index > size()).public List subList(int fromIndex, int toIndex)
UnsupportedOperationException
public boolean add(Object o)
UnsupportedOperationException
public boolean addAll(Collection c)
UnsupportedOperationException
public boolean addAll(int index, Collection c)
UnsupportedOperationException
public void add(int index, Object element)
UnsupportedOperationException
public Object removeKey(Object key)
(key==null ? k==null : key.equals(k))
, that mapping
is removed. (The map can contain at most one such mapping.)
Returns the value to which the map previously associated the key, or null if the map contained no mapping for this key. (A null return can also indicate that the map previously associated null with the specified key if the implementation supports null values.) The map will not contain a mapping for the specified key once the call returns.
key
- key whose mapping is to be removed from the map.ClassCastException
- if the key is of an inappropriate type for
this map (optional).NullPointerException
- if the key is null and this map
does not not permit null keys (optional).public boolean removeValue(Object o)
o
- element to be removed from this list, if present.ClassCastException
- if the type of the specified element
is incompatible with this list (optional).NullPointerException
- if the specified element is null and this
list does not support null elements (optional).public void add(Object key, Object o)
key
- The key.o
- The object.public Object replace(Object key, Object o)
key
- The key.o
- The object.public Object getKey(int index)
index
- The index.public void add(int index, Object key, Object o)
index
- The index.key
- The key.o
- The object.public Map getAsMap()
public List getAsList()
public Object[] getObjects()
public Object[] getObjects(Class type)
type
- The component type of the array.public Object[] getKeys()
Copyright © 2012. All Rights Reserved.