com.tensegrity.generic.constraint
Class EnumConstraint

java.lang.Object
  extended bycom.tensegrity.generic.constraint.AbstractConstraint
      extended bycom.tensegrity.generic.constraint.EnumConstraint
All Implemented Interfaces:
Constraint
Direct Known Subclasses:
OpenEnumConstraint

public class EnumConstraint
extends com.tensegrity.generic.constraint.AbstractConstraint

Used to check whether the value that is subject to validation is equal to one of the entries of the list of values on the right-hand-side of the operator. The entries of the list of values can be quoted strings or numbers. Interleaving both elements is allowed. The EnumConstraint validates its value by means of the potentially overridden equals() method of the value object.

Version:
$Id: EnumConstraint.java,v 1.23 2005/04/01 15:40:21 MichaelKegel Exp $
Author:
MichaelKegel
See Also:
Constraint, ConstraintParser

Field Summary
protected  java.lang.String lastError
          string used to trace for the last error
 
Method Summary
 java.lang.Object[] getAlternatives()
          Returns the legal alternatives of this enum constraint.
 Constraint intern()
          Pools this constraint analogous to the java.lang.String.intern() method.
 java.lang.String toString()
          Returns a string representation of this constraint.
 void trace(java.lang.StringBuffer sb)
          Default implementation appending the last error occured to the given StringBuffer.
 boolean validate(java.lang.Object value)
          Validates this contraint against a given value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

lastError

protected java.lang.String lastError
string used to trace for the last error

Method Detail

validate

public boolean validate(java.lang.Object value)
Description copied from interface: Constraint
Validates this contraint against a given value.
Notice:The given argument may not be null.

Parameters:
value - the object to validate. It is not allowed to pass in null as an argument.
Returns:
true if this value confirms to this constraints and false if it doesn't.

getAlternatives

public java.lang.Object[] getAlternatives()
Returns the legal alternatives of this enum constraint.

Returns:
legal alternatives of the constraint.

toString

public java.lang.String toString()
Returns a string representation of this constraint.

Returns:
a string representation of this constraint.

intern

public Constraint intern()
Pools this constraint analogous to the java.lang.String.intern() method. This method is not threadsafe.

Specified by:
intern in interface Constraint
Returns:
the pooled instance of this constraint. The returned object reference is the same as the this-reference if this object has not been pooled before.

trace

public void trace(java.lang.StringBuffer sb)
Default implementation appending the last error occured to the given StringBuffer.

Specified by:
trace in interface Constraint
Parameters:
sb - the stringbuffer to append the last error to.


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.