de.lmu.ifi.dbs.elki.utilities.optionhandling.constraints
Class StringLengthConstraint

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.utilities.optionhandling.constraints.StringLengthConstraint
All Implemented Interfaces:
ParameterConstraint<String>

public class StringLengthConstraint
extends Object
implements ParameterConstraint<String>

Length constraint for a StringParameter .


Field Summary
(package private)  int maxlength
          Maximum length
(package private)  int minlength
          Minimum length
 
Constructor Summary
StringLengthConstraint(int minlength, int maxlength)
          Constructor with minimum and maximum length.
 
Method Summary
 String getDescription(String parameterName)
          Returns a description of this constraint.
 void test(String t)
          Checks if the given string value of the string parameter is within the length restrictions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

minlength

int minlength
Minimum length


maxlength

int maxlength
Maximum length

Constructor Detail

StringLengthConstraint

public StringLengthConstraint(int minlength,
                              int maxlength)
Constructor with minimum and maximum length.

Parameters:
minlength - Minimum length, may be 0 for no limit
maxlength - Maximum length, may be -1 for no limit
Method Detail

test

public void test(String t)
          throws ParameterException
Checks if the given string value of the string parameter is within the length restrictions. If not, a parameter exception is thrown.

Specified by:
test in interface ParameterConstraint<String>
Parameters:
t - Value to be checked whether or not it fulfills the underlying parameter constraint.
Throws:
ParameterException - if the parameter to be tested does not fulfill the parameter constraint

getDescription

public String getDescription(String parameterName)
Description copied from interface: ParameterConstraint
Returns a description of this constraint.

Specified by:
getDescription in interface ParameterConstraint<String>
Parameters:
parameterName - the name of the parameter this constraint is used for
Returns:
a description of this constraint

Release 0.4.0 (2011-09-20_1324)