org.opensha.commons.param.constraint.impl
Class StringListConstraint

java.lang.Object
  extended by org.opensha.commons.param.constraint.AbstractParameterConstraint<java.util.List<java.lang.String>>
      extended by org.opensha.commons.param.constraint.impl.StringListConstraint
All Implemented Interfaces:
java.io.Serializable, Named, DiscreteParameterConstraint<java.util.List<java.lang.String>>, ParameterConstraint<java.util.List<java.lang.String>>

public class StringListConstraint
extends AbstractParameterConstraint<java.util.List<java.lang.String>>
implements DiscreteParameterConstraint<java.util.List<java.lang.String>>

Title: StringListConstraint.java

Description: This constraint is used for allowing multiple String selections by the user. It is typically presented in GUI as a JList where multiple item selection is allowed.

Copyright: Copyright (c) 2002

Company:

Version:
1.0
Author:
not attributable
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.opensha.commons.param.constraint.AbstractParameterConstraint
C, D, editable, name, nullAllowed
 
Constructor Summary
StringListConstraint()
          No-Arg constructor for the StringConstraint object.
StringListConstraint(java.util.List<java.lang.String> strings)
          Accepts a list of strings to be displayed in the list.
 
Method Summary
 void addString(java.lang.String str)
          Adds a String to the list of allowed values, if this constraint is editable.
 java.lang.Object clone()
          Returns a copy so you can't edit or damage the origial.
 java.util.ArrayList getAllowedValues()
          Returns cloned vector of allowed values, unable to modify original values.
 boolean isAllowed(java.util.List<java.lang.String> valsList)
          Determines whether Strings in the ArrayList are allowed.
 java.util.ListIterator listIterator()
          Returns Iterator over allowed values, able to modify original.
 int size()
          Returns the number of allowed values in the list
 
Methods inherited from class org.opensha.commons.param.constraint.AbstractParameterConstraint
checkEditable, getName, isEditable, isNullAllowed, setName, setNonEditable, setNullAllowed
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.opensha.commons.param.constraint.ParameterConstraint
getName, isEditable, isNullAllowed, setName, setNonEditable, setNullAllowed
 

Constructor Detail

StringListConstraint

public StringListConstraint()
No-Arg constructor for the StringConstraint object. Calls the super() constructor.


StringListConstraint

public StringListConstraint(java.util.List<java.lang.String> strings)
                     throws ConstraintException
Accepts a list of strings to be displayed in the list. User can choose one or more items from this list

Parameters:
strings -
Throws:
ConstraintException
Method Detail

isAllowed

public boolean isAllowed(java.util.List<java.lang.String> valsList)
Determines whether Strings in the ArrayList are allowed. It first checks that all the elements in arraylist should be String objects. Then it checks that all String objects in ArrayList are included in the list of allowed Strings

Specified by:
isAllowed in interface ParameterConstraint<java.util.List<java.lang.String>>
Parameters:
valsList -
Returns:

clone

public java.lang.Object clone()
Returns a copy so you can't edit or damage the origial.

Specified by:
clone in interface ParameterConstraint<java.util.List<java.lang.String>>
Specified by:
clone in class AbstractParameterConstraint<java.util.List<java.lang.String>>
Returns:
Exact copy of this object's state.

addString

public void addString(java.lang.String str)
               throws EditableException
Adds a String to the list of allowed values, if this constraint is editable.

Throws:
EditableException

getAllowedValues

public java.util.ArrayList getAllowedValues()
Description copied from interface: DiscreteParameterConstraint
Returns cloned vector of allowed values, unable to modify original values.

Specified by:
getAllowedValues in interface DiscreteParameterConstraint<java.util.List<java.lang.String>>

listIterator

public java.util.ListIterator listIterator()
Description copied from interface: DiscreteParameterConstraint
Returns Iterator over allowed values, able to modify original.

Specified by:
listIterator in interface DiscreteParameterConstraint<java.util.List<java.lang.String>>

size

public int size()
Description copied from interface: DiscreteParameterConstraint
Returns the number of allowed values in the list

Specified by:
size in interface DiscreteParameterConstraint<java.util.List<java.lang.String>>