org.springframework.rules.constraint
Class StringLengthConstraint

java.lang.Object
  extended by org.springframework.core.closure.support.AlgorithmsAccessor
      extended by org.springframework.rules.constraint.ConstraintsAccessor
          extended by org.springframework.rules.constraint.AbstractConstraint
              extended by org.springframework.rules.constraint.StringLengthConstraint
All Implemented Interfaces:
Serializable, Constraint, TypeResolvable

public class StringLengthConstraint
extends AbstractConstraint
implements TypeResolvable

Constraint to validate an object's string length.

Author:
Keith Donald
See Also:
Serialized Form

Constructor Summary
StringLengthConstraint(int length)
          Constructs a maxlength constraint of the specified length.
StringLengthConstraint(int min, int max)
          Constructs a string length range constraint.
StringLengthConstraint(int min, int max, String type)
          Constructs a string length range constraint.
StringLengthConstraint(int length, String type)
          Constructs a maxlength constraint of the specified length.
StringLengthConstraint(RelationalOperator operator, int length)
          Constructs a string length constraint with the specified operator and length constraint.
StringLengthConstraint(RelationalOperator operator, int length, String type)
          Constructs a string length constraint with the specified operator and length constraint.
 
Method Summary
 Constraint getPredicate()
           
 String getType()
          Returns this object's logical type identifier.
 boolean test(Object argument)
          Tests that the string form of this argument falls within the length constraint.
 String toString()
           
 
Methods inherited from class org.springframework.rules.constraint.AbstractConstraint
allTrue, allTrue, anyTrue, anyTrue, findAll, findAll, findFirst, findFirst
 
Methods inherited from class org.springframework.rules.constraint.ConstraintsAccessor
all, all, and, any, any, bind, bind, bind, bind, bind, conjunction, disjunction, eq, eq, eq, eq, eq, eqProperty, eqProperty, getConstraints, gt, gt, gt, gt, gt, gt, gt, gte, gte, gte, gte, gte, gte, gte, gteProperty, gteProperty, gtProperty, gtProperty, ifTrue, ifTrueElse, inGroup, inGroup, inGroup, inRange, inRange, inRangeProperties, inRangeProperties, like, like, lt, lt, lt, lt, lt, lt, lt, lte, lte, lte, lte, lte, lte, lte, lteProperty, lteProperty, ltProperty, ltProperty, maxLength, method, minLength, not, not, or, present, present, range, range, range, range, range, range, range, regexp, regexp, required, required, testResultOf, unique, value
 
Methods inherited from class org.springframework.core.closure.support.AlgorithmsAccessor
allTrue, allTrue, anyTrue, anyTrue, findAll, findAll, findFirst, findFirst, forEach, forEach, getAlgorithms
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StringLengthConstraint

public StringLengthConstraint(int length)
Constructs a maxlength constraint of the specified length.

Parameters:
length - the max string length

StringLengthConstraint

public StringLengthConstraint(int length,
                              String type)
Constructs a maxlength constraint of the specified length.

Parameters:
length - the max string length

StringLengthConstraint

public StringLengthConstraint(RelationalOperator operator,
                              int length)
Constructs a string length constraint with the specified operator and length constraint.

Parameters:
operator - the operator (one of ==, >, >=, <, <=)
length - the length constraint

StringLengthConstraint

public StringLengthConstraint(RelationalOperator operator,
                              int length,
                              String type)
Constructs a string length constraint with the specified operator and length constraint.

Parameters:
operator - the operator (one of ==, >, >=, <, <=)
length - the length constraint
type - Type used to resolve messages.

StringLengthConstraint

public StringLengthConstraint(int min,
                              int max)
Constructs a string length range constraint.

Parameters:
min - The minimum edge of the range
max - the maximum edge of the range

StringLengthConstraint

public StringLengthConstraint(int min,
                              int max,
                              String type)
Constructs a string length range constraint.

Parameters:
min - The minimum edge of the range
max - the maximum edge of the range
Method Detail

test

public boolean test(Object argument)
Tests that the string form of this argument falls within the length constraint.

Specified by:
test in interface Constraint
Parameters:
argument - the argument value
Returns:
true if the condition was satisfied, false otherwise
See Also:
Constraint.test(java.lang.Object)

getPredicate

public Constraint getPredicate()

toString

public String toString()
Overrides:
toString in class Object

getType

public String getType()
Description copied from interface: TypeResolvable
Returns this object's logical type identifier.

Specified by:
getType in interface TypeResolvable
Returns:
The type identifier


Copyright © 2004-2008 The Spring Framework. All Rights Reserved.