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:
Serializable, Cloneable, Iterable<OptionEntry>, Collection<OptionEntry>, Set<OptionEntry>

public class Options
extends AbstractSet<OptionEntry>
implements Cloneable, Serializable

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.

See Also:
Serialized Form

Nested Class Summary
static class Options.InsertPos
           
 
Constructor Summary
Options()
           
Options(OptionEntry[] entries)
           
Options(Options other)
           
 
Method Summary
 void add(Object value, 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(Element element, long flags)
          Adds all these options to the xml element
 void clear()
           
 Options clone()
           
 boolean contains(Object object)
           
protected  OptionEntry createOptionEntry(Object value, String text)
           
 String get(Object value)
           
 OptionEntry getEntry(Object value)
           
protected  int getIndex(Object value)
           
 String getTextAt(int i)
          Gets the text of the entry at index i
 Object getValueAt(int i)
          Gets the value of the entry at index i
 Set<Object> getValues()
           
 boolean isEmpty()
           
 Iterator<OptionEntry> iterator()
           
 boolean remove(Object object)
           
 void set(Object value, String text)
          Sets or adds Adds an option at the bottom
 void set(Object value, String text, Options.InsertPos pos)
          Sets or Adds an option at a certain position
 int size()
           
 Object[] toArray()
           
 String toString()
           
 
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
 
Methods inherited from class java.util.AbstractCollection
addAll, containsAll, retainAll, toArray
 
Methods inherited from class java.lang.Object
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

clone

public Options clone()
Overrides:
clone in class Object

getIndex

protected int getIndex(Object value)

createOptionEntry

protected OptionEntry createOptionEntry(Object value,
                                        String text)

getEntry

public OptionEntry getEntry(Object value)

get

public String get(Object value)

getValueAt

public 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 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 Set<Object> getValues()

set

public void set(Object value,
                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(Object value,
                String text)
Sets or adds Adds an option at the bottom

Parameters:
value - the value object
text - the text

add

public void add(Object value,
                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 Collection<OptionEntry>
Specified by:
add in interface Set<OptionEntry>
Overrides:
add in class AbstractCollection<OptionEntry>

clear

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

contains

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

isEmpty

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

iterator

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

remove

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

size

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

toArray

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

toString

public String toString()
Overrides:
toString in class AbstractCollection<OptionEntry>

addXml

public void addXml(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–2014 Apache Software Foundation. All rights reserved.