com.bea.wsrp.ext.holders
Class NamedStringArray

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<NamedStringArray.NamedString>
          extended by com.bea.wsrp.ext.holders.NamedStringArray
All Implemented Interfaces
Serializable, Iterable<NamedStringArray.NamedString>, Collection<NamedStringArray.NamedString>, List<NamedStringArray.NamedString>

public class NamedStringArray
extends AbstractList<NamedStringArray.NamedString>
implements Serializable

This class holds an ordered set of string name/value pairs and corresponds to the WSRP 2.0 type "NamedStringArray"; when used as an event payload over WSRP 2.0, it will be bound to this standard WSRP 2.0 type which may allow for better interoperability with third-party producers or consumers that support WSRP 2.0 eventing. When used as an event payload over WSRP 1.0, it will get serialized as a Java object. NamedStringArray cannot contain null name/value pairs (NamedString) and the name portion of each NamedString cannot be null, but the value may be null.

See Also
Serialized Form

Nested Class Summary
static class NamedStringArray.NamedString
          This class represents a single name/value pair in a NamedStringArray, where the name is a non-null string and value is a nullable string.
 
Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
NamedStringArray()
          Constructs a new, empty NamedStringArray.
NamedStringArray(Element root)
          Constructs a new NamedStringArray from the specified DOM element, which should be the root "NamedStringArray" element.
NamedStringArray(int size)
          Constructs a new, empty NamedStringArray of the specified initial size.
 
Method Summary
 void add(int index, NamedStringArray.NamedString element)
          Inserts the specified NamedString at the specified position in this NamedStringArray.
 void add(int index, String name, String value)
          Inserts the specified name/value pair at the specified position in this NamedStringArray.
 void add(String name, String value)
          Appends the specified name/value pair to the end of this NamedStringArray.
 void clear()
          Removes all entries from this NamedStringArray.
 boolean equals(Object o)
           
 NamedStringArray.NamedString get(int index)
          Gets the NamedString at the specified index.
 String getName(int index)
          Gets the name of the NamedString at the specified index.
 String getValue(int index)
          Gets the value of the NamedString at the specified index.
 List<String> getValues(String name)
          Returns all values associated with the specified name, in the same order they appear in the NamedStringArray.
 int hashCode()
           
 NamedStringArray.NamedString remove(int index)
          Removes the name/value pair at the specified index, shifting any entries beyond that position to the right (removing one from their indicies).
 void remove(String name)
          Removes all name/value pairs in this NamedStringArray with the specified name.
 NamedStringArray.NamedString set(int index, NamedStringArray.NamedString element)
          Replaces the NamedString at the specified position in this NamedStringArray with the specified NamedString.
 void set(int index, String name, String value)
          Replaces the name/value pair at the specified index with the specified name and value.
 int size()
          Returns the number of entries in this NamedStringArray.
 String toString()
           
 void writeTo(Element root)
          Writes this NamedStringArray to the specified DOM element, which is the root element of the NamedStringArray.
 
Methods inherited from class java.util.AbstractList
add, addAll, indexOf, iterator, lastIndexOf, listIterator, listIterator, removeRange, subList
 
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
 

Constructor Detail

NamedStringArray

public NamedStringArray()
Constructs a new, empty NamedStringArray.


NamedStringArray

public NamedStringArray(int size)
Constructs a new, empty NamedStringArray of the specified initial size.

Parameters
size - the initial capacity for this NamedStringArray.

NamedStringArray

public NamedStringArray(Element root)
Constructs a new NamedStringArray from the specified DOM element, which should be the root "NamedStringArray" element. All sub-elements of the root element not named "namedString" are ignored.

Parameters
root - the root DOM element of the NamedStringArray, whose child elements consist of "NamedString" elements.
Throws
IllegalArgumentException - if the argument is null.
Method Detail

size

public int size()
Returns the number of entries in this NamedStringArray.

Specified by:
size in interface Collection<NamedStringArray.NamedString>
Specified by:
size in interface List<NamedStringArray.NamedString>
Specified by:
size in class AbstractCollection<NamedStringArray.NamedString>
Returns
the number of name/value pairs in this NamedStringArray.

get

public NamedStringArray.NamedString get(int index)
Gets the NamedString at the specified index.

Specified by:
get in interface List<NamedStringArray.NamedString>
Specified by:
get in class AbstractList<NamedStringArray.NamedString>
Parameters
index - the index of the NamedString in the NamedStringArray to get.
Returns
the NamedString in the NamedStringArray at the specified index.
Throws
IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size())

getName

public String getName(int index)
Gets the name of the NamedString at the specified index.

Parameters
index - the index of the NamedString in the NamedStringArray to get the name of.
Returns
the name of the NamedString in the NamedStringArray at the specified index.
Throws
IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size())

getValue

public String getValue(int index)
Gets the value of the NamedString at the specified index.

Parameters
index - the index of the NamedString in the NamedStringArray to get the value of.
Returns
the value of the NamedString in the NamedStringArray at the specified index.
Throws
IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size())

getValues

public List<String> getValues(String name)
Returns all values associated with the specified name, in the same order they appear in the NamedStringArray.

Parameters
name - the name to get all the values for.
Returns
a List of all values associated with that name, in the same order in which they appear in the NamedStringArray.

add

public void add(String name,
                String value)
Appends the specified name/value pair to the end of this NamedStringArray.

Parameters
name - the name of the NamedString to add to the end of the NamedStringArray
value - the value of the NamedString to add to the end of the NamedStringArray.
Throws
IllegalArgumentException - if name is null.
NullPointerException - if the name argument is null.

add

public void add(int index,
                NamedStringArray.NamedString element)
Inserts the specified NamedString at the specified position in this NamedStringArray. Shifts the NamedString currently at that position (if any) and any subsequent elements to the right (adds one to their indices).

Specified by:
add in interface List<NamedStringArray.NamedString>
Overrides:
add in class AbstractList<NamedStringArray.NamedString>
Parameters
index - the index at which the specified element is to be inserted.
element - the NamedString to be inserted.
Throws
NullPointerException - if element is null
IndexOutOfBoundsExcepion - if the index is out of range (index < 0 || index >= size())

add

public void add(int index,
                String name,
                String value)
Inserts the specified name/value pair at the specified position in this NamedStringArray. Shifts the entries currently at that position (if any) and any subsequent entries to the right (adds one to their indices).

Parameters
index - the index at which the specified name/value pair is to be inserted.
name - the name to insert
value - the value to insert
Throws
IllegalArgumentException - if name is null.
IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size())
NullPointerException - if the name argument is null.

set

public void set(int index,
                String name,
                String value)
Replaces the name/value pair at the specified index with the specified name and value.

Parameters
index - the index to replace with the specified name/value pair.
name - the name to replace with
value - the value to replace with
Throws
IllegalArgumentException - if name is null.
IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size())
NullPointerException - if the specified name is null.

set

public NamedStringArray.NamedString set(int index,
                                        NamedStringArray.NamedString element)
Replaces the NamedString at the specified position in this NamedStringArray with the specified NamedString.

Specified by:
set in interface List<NamedStringArray.NamedString>
Overrides:
set in class AbstractList<NamedStringArray.NamedString>
Parameters
index - the index of the element to replace.
element - the NamedString to be stored at the specified position.
Returns
the NamedString previously at the specified position.
Throws
IndexOutOfBoundsExcepion - if the index is out of range (index < 0 || index >= size())
NullPointerException - if the element argument is null.

remove

public NamedStringArray.NamedString remove(int index)
Removes the name/value pair at the specified index, shifting any entries beyond that position to the right (removing one from their indicies).

Specified by:
remove in interface List<NamedStringArray.NamedString>
Overrides:
remove in class AbstractList<NamedStringArray.NamedString>
Parameters
index - the index of the name/value pair to remove.
Returns
the NamedString removed from this NamedStringArray
Throws
IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size())

remove

public void remove(String name)
Removes all name/value pairs in this NamedStringArray with the specified name.

Parameters
name - the name of all name/value pairs to remove.

clear

public void clear()
Removes all entries from this NamedStringArray.

Specified by:
clear in interface Collection<NamedStringArray.NamedString>
Specified by:
clear in interface List<NamedStringArray.NamedString>
Overrides:
clear in class AbstractList<NamedStringArray.NamedString>

writeTo

public void writeTo(Element root)
Writes this NamedStringArray to the specified DOM element, which is the root element of the NamedStringArray. This method essentially adds "NamedString" elements as children of the specified root element, inheriting the namespace used for the specified root element. This allows the NamedStringArray to be used with either the WSRP V1 or WSRP V2 namespaces. The caller is responsible for setting the appropriate namespace and element name on the root DOM element.

Parameters
root - the root DOM element to write the NamedString elements to.

toString

public String toString()
Overrides:
toString in class AbstractCollection<NamedStringArray.NamedString>

equals

public boolean equals(Object o)
Specified by:
equals in interface Collection<NamedStringArray.NamedString>
Specified by:
equals in interface List<NamedStringArray.NamedString>
Overrides:
equals in class AbstractList<NamedStringArray.NamedString>

hashCode

public int hashCode()
Specified by:
hashCode in interface Collection<NamedStringArray.NamedString>
Specified by:
hashCode in interface List<NamedStringArray.NamedString>
Overrides:
hashCode in class AbstractList<NamedStringArray.NamedString>


Copyright © 2011, Oracle. All rights reserved.