FreeHEP API
Version current

org.freehep.util.parameterdatabase.selector
Class Selector

java.lang.Object
  extended byorg.freehep.util.parameterdatabase.selector.Selector
Direct Known Subclasses:
LineSizeSelector, MarkerSelector, MarkerSizeSelector, OnOffSelector, StdColorSelector

public abstract class Selector
extends Object

This provides a class which allows the user to choose between a small number of different choices. Instances of this class and subclasses should be immutable. This is intended to work within a table context. For everything to work correctly, the subclasses must provide a constructor which takes an Object as an argument and one which takes a String as an argument. The String constructor must work with the Strings produced from the getTag() method. For some of the utility routines to work, the iterator over all of the possible selector values must be provided. The initialization of the underlying data structure and the filling with possible values should be done in a static context.

Source Code:
Selector.java

Constructor Summary
  Selector(Object value)
          This constructor will create a Selector with the given value.
  Selector(String tag)
          This constructor will create a Selector from the given tag.
protected Selector(String tag, Object value)
          This protected constructor unconditionally creates a Selector with the given value.
 
Method Summary
 boolean equals(Object obj)
          For equality, the two objects must have the same class and the same underlying value (compared with equals()).
 boolean getBooleanValue()
          This returns the value associated with this Selector as a boolean.
 double getDoubleValue()
          This returns the value associated with this Selector as a double.
 int getIntValue()
          This returns the value associated with this Selector as an int.
protected  Selector getSelectorFromTag(String tag)
          Return a Selector object which corresponds to the given tag.
protected  Selector getSelectorFromValue(Object value)
          Return a Selector object which corresponds to the given value.
 String getTag()
          This returns the associated tag for this Selector.
 Object getValue()
          This returns the value associated with this Selector as an Object.
 int hashCode()
          The hashcode for this object is the one from the underlying value.
 void initialize(JComboBox comboBox)
          Initialize a JComboBox with all of the possible values.
abstract  Iterator iterator()
          This returns an iterator over all of the possible Selector objects of this class.
 String toString()
          Return the tag associated with this selector's value.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Selector

protected Selector(String tag,
                   Object value)
This protected constructor unconditionally creates a Selector with the given value. This is necessary for subclasses which wish to create statically a list of all possible Selectors of a particular class.


Selector

public Selector(Object value)
This constructor will create a Selector with the given value. Subclasses must provide a constructor with this signature.


Selector

public Selector(String tag)
This constructor will create a Selector from the given tag. Subclasses must provide a constructor with this signature.

Method Detail

getSelectorFromValue

protected Selector getSelectorFromValue(Object value)
Return a Selector object which corresponds to the given value.


getSelectorFromTag

protected Selector getSelectorFromTag(String tag)
Return a Selector object which corresponds to the given tag.


iterator

public abstract Iterator iterator()
This returns an iterator over all of the possible Selector objects of this class.


getTag

public String getTag()
This returns the associated tag for this Selector.


getValue

public Object getValue()
This returns the value associated with this Selector as an Object.


getIntValue

public int getIntValue()
This returns the value associated with this Selector as an int. This will throw a ClassCastException if the underlying value is not an Integer.


getDoubleValue

public double getDoubleValue()
This returns the value associated with this Selector as a double. This will throw a ClassCastException if the underlying value is not an Double.


getBooleanValue

public boolean getBooleanValue()
This returns the value associated with this Selector as a boolean. This will throw a ClassCastException if the underlying value is not a Boolean.


toString

public String toString()
Return the tag associated with this selector's value.


initialize

public void initialize(JComboBox comboBox)
Initialize a JComboBox with all of the possible values.


equals

public boolean equals(Object obj)
For equality, the two objects must have the same class and the same underlying value (compared with equals()).


hashCode

public int hashCode()
The hashcode for this object is the one from the underlying value.


FreeHEP API
Version current

Copyright © 2000-2004 FreeHEP, All Rights Reserved.