org.pf.util
Class NamedTextList

java.lang.Object
  extended by org.pf.util.AssociationList
      extended by org.pf.util.NamedValueList
          extended by org.pf.util.NamedTextList

public class NamedTextList
extends NamedValueList

A container that holds a collection of NamedText objects.

Version:
1.4
Author:
Manfred Duchrow

Field Summary
static NamedText[] EMPTY_NAMED_TEXT_ARRAY
           
 
Fields inherited from class org.pf.util.NamedValueList
EMPTY_NAMED_VALUE_ARRAY
 
Fields inherited from class org.pf.util.AssociationList
EMPTY_ASSOCIATION_ARRAY
 
Constructor Summary
NamedTextList()
          Initialize the new instance with default values.
NamedTextList(java.util.Map map)
          Initialize the new instance with values from the given map.
 
Method Summary
 void add(Association association)
          Adds the specified association only if it is an instance of NamedText.
 void add(NamedText namedText)
          Adds the specified named text.
 void add(java.lang.Object key, java.lang.Object value)
          Adds the specified key and value as new association if both of them are an instance of String.
 void add(java.lang.String name, java.lang.Object value)
          Adds the specified name and value as new NamedText if value is an instance of String.
 void add(java.lang.String name, java.lang.String text)
          Adds the specified name and text as new NamedText.
 void addAll(NamedText[] namedTexts)
          Adds all named text elements of the given array to the list.
 java.util.Properties asProperties()
          Returns all name/text pairs transformed to a Properties object.
 NamedText findNamedText(java.lang.String name)
          Returns the first named text with the specified name or null if none can be found.
 NamedText[] namedTextArray()
          Returns all named text pairs as an array
 NamedText[] namedTextArray(IObjectFilter filter)
          Returns an array of all those elements contained in this list that match the given filter.
 NamedText namedTextAt(int index)
          Returns the named text at the specified index.
 void setNamedTextAt(int index, NamedText namedText)
          Puts the given named text at the specified index.
 java.lang.String textAt(int index)
          Returns the text (value) at the specified index.
 java.lang.String textAt(java.lang.String name)
          Returns the value associated with the specified name or null if the name cannot be found.
 
Methods inherited from class org.pf.util.NamedValueList
add, addAll, containsName, findNamedValue, nameAt, namedValueArray, namedValueArray, namedValueAt, names, remove, setNamedValueAt, sort, sort, valueAt
 
Methods inherited from class org.pf.util.AssociationList
addAll, addAll, addAllToMap, asHashMap, asHashtable, asList, associationArray, associationArray, associationAt, clear, containsKey, findAssociation, indexOf, isEmpty, keyAt, keys, processEach, put, put, putAll, putAll, remove, remove, removeAll, removeKey, setAssociationAt, size, valueAt, valueAt, values
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_NAMED_TEXT_ARRAY

public static final NamedText[] EMPTY_NAMED_TEXT_ARRAY
Constructor Detail

NamedTextList

public NamedTextList()
Initialize the new instance with default values.


NamedTextList

public NamedTextList(java.util.Map map)
Initialize the new instance with values from the given map. Only key/value pairs from the given map are added to the newly created object where both key and value are of type string. Other entries in the map will be skipped silently.

Parameters:
map - A containing key/value pairs to be added to the new object
Method Detail

add

public void add(NamedText namedText)
Adds the specified named text.

Parameters:
namedText - The named text to add (must not be null!)

add

public void add(Association association)
Adds the specified association only if it is an instance of NamedText.

Overrides:
add in class NamedValueList
Parameters:
association - The association to add (must not be null!)

add

public void add(java.lang.Object key,
                java.lang.Object value)
Adds the specified key and value as new association if both of them are an instance of String.

Overrides:
add in class NamedValueList
Parameters:
key - The key of the association to add
value - The value of the association to add

add

public void add(java.lang.String name,
                java.lang.Object value)
Adds the specified name and value as new NamedText if value is an instance of String.

Overrides:
add in class NamedValueList
Parameters:
name - The name of the named value to add
value - The value of the named value to add

add

public void add(java.lang.String name,
                java.lang.String text)
Adds the specified name and text as new NamedText.

Parameters:
name - The name of the named text to add
text - The text of the named text to add

addAll

public void addAll(NamedText[] namedTexts)
Adds all named text elements of the given array to the list.

Parameters:
namedTexts - The named text objects to add

namedTextArray

public NamedText[] namedTextArray()
Returns all named text pairs as an array


namedTextArray

public NamedText[] namedTextArray(IObjectFilter filter)
Returns an array of all those elements contained in this list that match the given filter. Each NamedText element of this list gets passed to the matches() method of the filter. If the filter is null, all elements will be returned.

Parameters:
filter - The filter that determines which elements to return in the result array
Returns:
Always an array, never null

asProperties

public java.util.Properties asProperties()
Returns all name/text pairs transformed to a Properties object.


namedTextAt

public NamedText namedTextAt(int index)
Returns the named text at the specified index.

Parameters:
index - The index of the NamedText

setNamedTextAt

public void setNamedTextAt(int index,
                           NamedText namedText)
Puts the given named text at the specified index.

Parameters:
index - The index where to put the namedText
namedText - The named text object to be put at the given index
Throws:
java.lang.IndexOutOfBoundsException - if the index is out of range

textAt

public java.lang.String textAt(int index)
Returns the text (value) at the specified index.

Parameters:
index - The index of the NamedText

findNamedText

public NamedText findNamedText(java.lang.String name)
Returns the first named text with the specified name or null if none can be found.

Parameters:
name - The name of the named text to look for

textAt

public java.lang.String textAt(java.lang.String name)
Returns the value associated with the specified name or null if the name cannot be found.

Parameters:
name - The identifier for the desired value