org.jtheque.core.utils.ui.constraints
Class MaxLenghtConstraint

java.lang.Object
  extended by org.jtheque.core.utils.ui.constraints.MaxLenghtConstraint
All Implemented Interfaces:
Constraint

public final class MaxLenghtConstraint
extends java.lang.Object
implements Constraint

A constraint to set a max length.

Author:
Baptiste Wicht

Constructor Summary
MaxLenghtConstraint(int maxLength, java.lang.String fieldName, boolean canBenNull, boolean numerical)
          Construct a new MaxLenghtConstraint.
 
Method Summary
 boolean canBeNullOrEmpty()
          Indicate if the value can be null or not.
 int maxLength()
          Return the max length of the value.
 boolean mustBeNumerical()
          Indicate if the value must be numerical or not.
 boolean mustControlLength()
          Indicate if we must control length or not.
 void validate(java.lang.Object field, java.util.Collection<JThequeError> errors)
          Validate the field.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MaxLenghtConstraint

public MaxLenghtConstraint(int maxLength,
                           java.lang.String fieldName,
                           boolean canBenNull,
                           boolean numerical)
Construct a new MaxLenghtConstraint.

Parameters:
maxLength - The maximum length of the field.
fieldName - The field name.
canBenNull - Can the field be null ?
numerical - Must the field be numerical ?
Method Detail

maxLength

public int maxLength()
Description copied from interface: Constraint
Return the max length of the value.

Specified by:
maxLength in interface Constraint
Returns:
The max length of the value.

mustBeNumerical

public boolean mustBeNumerical()
Description copied from interface: Constraint
Indicate if the value must be numerical or not.

Specified by:
mustBeNumerical in interface Constraint
Returns:
true if teh value must be numerical else false.

canBeNullOrEmpty

public boolean canBeNullOrEmpty()
Description copied from interface: Constraint
Indicate if the value can be null or not.

Specified by:
canBeNullOrEmpty in interface Constraint
Returns:
true if the value can be null else false.

mustControlLength

public boolean mustControlLength()
Description copied from interface: Constraint
Indicate if we must control length or not.

Specified by:
mustControlLength in interface Constraint
Returns:
true if we must control length else false.

validate

public void validate(java.lang.Object field,
                     java.util.Collection<JThequeError> errors)
Description copied from interface: Constraint
Validate the field.

Specified by:
validate in interface Constraint
Parameters:
field - The field to validate.
errors - The errors list.


Copyright © 2009 JTheque. All Rights Reserved.