|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.solr.common.util.NamedList<T>
public class NamedList<T>
A simple container class for modeling an ordered list of name/value pairs.
Unlike Maps:
A NamedList provides fast access by element number, but not by name.
When a NamedList is serialized, order is considered more important than access
by key, so ResponseWriters that output to a format such as JSON will normally
choose a data structure that allows order to be easily preserved in various
clients (i.e. not a straight map).
If access by key is more important, see SimpleOrderedMap
,
or simply use a regular Map
Nested Class Summary | |
---|---|
static class |
NamedList.NamedListEntry<T>
Helper class implementing Map.Entry |
Field Summary | |
---|---|
protected List |
nvPairs
|
Constructor Summary | |
---|---|
NamedList()
Creates an empty instance |
|
NamedList(List nameValuePairs)
Deprecated. Use NamedList(java.util.Map.Entry[]) for the NamedList instantiation |
|
NamedList(Map.Entry<String,? extends T>[] nameValuePairs)
Creates a NamedList instance containing the "name,value" pairs contained in the Entry[]. |
Method Summary | |
---|---|
void |
add(String name,
T val)
Adds a name/value pair to the end of the list. |
boolean |
addAll(Map<String,T> args)
Iterates over the Map and sequentially adds it's key/value pairs |
boolean |
addAll(NamedList<T> nl)
Appends the elements of the given NamedList to this one. |
NamedList<T> |
clone()
Makes a shallow copy of the named list. |
boolean |
equals(Object obj)
|
T |
get(String name)
Gets the value for the first instance of the specified name found. |
T |
get(String name,
int start)
Gets the value for the first instance of the specified name found starting at the specified index. |
List<T> |
getAll(String name)
Gets the values for the the specified name |
String |
getName(int idx)
The name of the pair at the specified List index |
T |
getVal(int idx)
The value of the pair at the specified List index |
int |
hashCode()
|
int |
indexOf(String name,
int start)
Scans the list sequentially beginning at the specified index and returns the index of the first pair with the specified name. |
Iterator<Map.Entry<String,T>> |
iterator()
Support the Iterable interface |
T |
remove(int idx)
Removes the name/value pair at the specified index. |
T |
remove(String name)
|
void |
setName(int idx,
String name)
Modifies the name of the pair at the specified index. |
T |
setVal(int idx,
T val)
Modifies the value of the pair at the specified index. |
int |
size()
The total number of name/value pairs |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected final List nvPairs
Constructor Detail |
---|
public NamedList()
public NamedList(Map.Entry<String,? extends T>[] nameValuePairs)
Modifying the contents of the Entry[] after calling this constructor may change
the NamedList (in future versions of Solr), but this is not garunteed and should
not be relied upon. To modify the NamedList, refer to add(String, Object)
or remove(String)
.
nameValuePairs
- the name value pairs@Deprecated public NamedList(List nameValuePairs)
NamedList(java.util.Map.Entry[])
for the NamedList instantiation
When using this constructor, runtime typesafety is only garunteed if the all even numbered elements of the input list are of type "T".
nameValuePairs
- underlying List which should be used to implement a NamedListMethod Detail |
---|
public int size()
public String getName(int idx)
public T getVal(int idx)
public void add(String name, T val)
public void setName(int idx, String name)
public T setVal(int idx, T val)
public T remove(int idx)
public int indexOf(String name, int start)
name
- name to look for, may be nullstart
- index to begin searching from
public T get(String name)
indexOf(java.lang.String, int)
,
get(String,int)
public T get(String name, int start)
indexOf(java.lang.String, int)
public List<T> getAll(String name)
name
- Name
public String toString()
toString
in class Object
public boolean addAll(Map<String,T> args)
public boolean addAll(NamedList<T> nl)
public NamedList<T> clone()
clone
in class Object
public Iterator<Map.Entry<String,T>> iterator()
iterator
in interface Iterable<Map.Entry<String,T>>
public T remove(String name)
public int hashCode()
hashCode
in class Object
public boolean equals(Object obj)
equals
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |