org.apache.empire.commons
Class Options

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractSet<OptionEntry>
          extended by org.apache.empire.commons.Options
All Implemented Interfaces:
java.lang.Iterable<OptionEntry>, java.util.Collection<OptionEntry>, java.util.Set<OptionEntry>

public class Options
extends java.util.AbstractSet<OptionEntry>

This class represents a list of possible values that are valid for a particular field.
Additionally the class provides a text string describing the value for display purposes.
The class is implemented as a set of OptionEntry objects where the entry value is used as the key for the set and thus must be unique.


Nested Class Summary
static class Options.InsertPos
           
 
Constructor Summary
Options()
           
Options(OptionEntry[] entries)
           
Options(Options other)
           
 
Method Summary
 void add(java.lang.Object value, java.lang.String text, boolean noCheck)
          Adds an object, the check for an existing can be skipped for performance issues (not recommended!)
 boolean add(OptionEntry option)
           
 void addXml(org.w3c.dom.Element element, long flags)
          Adds all these options to the xml element
 void clear()
           
 boolean contains(java.lang.Object object)
           
protected  OptionEntry createOptionEntry(java.lang.Object value, java.lang.String text)
           
 java.lang.String get(java.lang.Object value)
           
 OptionEntry getEntry(java.lang.Object value)
           
protected  int getIndex(java.lang.Object value)
           
 java.lang.String getTextAt(int i)
          Gets the text of the entry at index i
 java.lang.Object getValueAt(int i)
          Gets the value of the entry at index i
 java.util.Set<java.lang.Object> getValues()
           
 boolean isEmpty()
           
 java.util.Iterator<OptionEntry> iterator()
           
 boolean remove(java.lang.Object object)
           
 void set(java.lang.Object value, java.lang.String text)
          Sets or adds Adds an option at the bottom
 void set(java.lang.Object value, java.lang.String text, Options.InsertPos pos)
          Sets or Adds an option at a certain position
 int size()
           
 java.lang.Object[] toArray()
           
 
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
 
Methods inherited from class java.util.AbstractCollection
addAll, containsAll, retainAll, toArray, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Set
addAll, containsAll, retainAll, toArray
 

Constructor Detail

Options

public Options()

Options

public Options(Options other)

Options

public Options(OptionEntry[] entries)
Method Detail

getIndex

protected int getIndex(java.lang.Object value)

createOptionEntry

protected OptionEntry createOptionEntry(java.lang.Object value,
                                        java.lang.String text)

getEntry

public OptionEntry getEntry(java.lang.Object value)

get

public java.lang.String get(java.lang.Object value)

getValueAt

public java.lang.Object getValueAt(int i)
Gets the value of the entry at index i

Parameters:
i - the index
Returns:
the value or null if not found

getTextAt

public java.lang.String getTextAt(int i)
Gets the text of the entry at index i

Parameters:
i - the index
Returns:
the text or an empty String if not found

getValues

public java.util.Set<java.lang.Object> getValues()

set

public void set(java.lang.Object value,
                java.lang.String text,
                Options.InsertPos pos)
Sets or Adds an option at a certain position

Parameters:
value - the value object
text - the text
pos - the position, see Options.InsertPos

set

public void set(java.lang.Object value,
                java.lang.String text)
Sets or adds Adds an option at the bottom

Parameters:
value - the value object
text - the text

add

public void add(java.lang.Object value,
                java.lang.String text,
                boolean noCheck)
Adds an object, the check for an existing can be skipped for performance issues (not recommended!)

Parameters:
value - the value
text - the text
noCheck - set to true to skip testing for an existing key (handle with care!)

add

public boolean add(OptionEntry option)
Specified by:
add in interface java.util.Collection<OptionEntry>
Specified by:
add in interface java.util.Set<OptionEntry>
Overrides:
add in class java.util.AbstractCollection<OptionEntry>

clear

public void clear()
Specified by:
clear in interface java.util.Collection<OptionEntry>
Specified by:
clear in interface java.util.Set<OptionEntry>
Overrides:
clear in class java.util.AbstractCollection<OptionEntry>

contains

public boolean contains(java.lang.Object object)
Specified by:
contains in interface java.util.Collection<OptionEntry>
Specified by:
contains in interface java.util.Set<OptionEntry>
Overrides:
contains in class java.util.AbstractCollection<OptionEntry>

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface java.util.Collection<OptionEntry>
Specified by:
isEmpty in interface java.util.Set<OptionEntry>
Overrides:
isEmpty in class java.util.AbstractCollection<OptionEntry>

iterator

public java.util.Iterator<OptionEntry> iterator()
Specified by:
iterator in interface java.lang.Iterable<OptionEntry>
Specified by:
iterator in interface java.util.Collection<OptionEntry>
Specified by:
iterator in interface java.util.Set<OptionEntry>
Specified by:
iterator in class java.util.AbstractCollection<OptionEntry>

remove

public boolean remove(java.lang.Object object)
Specified by:
remove in interface java.util.Collection<OptionEntry>
Specified by:
remove in interface java.util.Set<OptionEntry>
Overrides:
remove in class java.util.AbstractCollection<OptionEntry>

size

public int size()
Specified by:
size in interface java.util.Collection<OptionEntry>
Specified by:
size in interface java.util.Set<OptionEntry>
Specified by:
size in class java.util.AbstractCollection<OptionEntry>

toArray

public java.lang.Object[] toArray()
Specified by:
toArray in interface java.util.Collection<OptionEntry>
Specified by:
toArray in interface java.util.Set<OptionEntry>
Overrides:
toArray in class java.util.AbstractCollection<OptionEntry>

addXml

public void addXml(org.w3c.dom.Element element,
                   long flags)
Adds all these options to the xml element

Parameters:
element - the element to add the option tags to
flags - not used for now


Copyright © 2008-2011 Apache Software Foundation. All Rights Reserved.