com.inigoserrano.isvalidator.data
Class SimpleData

java.lang.Object
  |
  +--com.inigoserrano.isvalidator.data.SimpleData
All Implemented Interfaces:
Check, Data, DataInternal
Direct Known Subclasses:
CommandLineArgumentData, ServletParameterData

public class SimpleData
extends java.lang.Object
implements DataInternal

This class is the base of all the Data, it isn´t specialized in any domain. The rest of the Data usually overrides the methods that need and uses this class´s

Version:
@version@
Author:
@author@

Field Summary
protected  java.util.Vector almacen
          the store of all the Checks
protected  ErrorDo constraintListener
          One errorDo that listen the parameters
protected  ErrorDoGroup constraintListenerContainer
          the group of errorDo that listen the parameters
protected  boolean hasBeenChecked
          if the data has been checked
protected  boolean match
          if the data match all the constraints
protected  boolean throwException
          if we must throw an exception, this flag is at container level
protected  OkDo validConstraintProcesor
          The OkDo to process this data
protected  java.lang.String valueToCheck
          the data to check
protected  java.lang.String valueToCheckName
          the name of the data (parameterName, argumentName,...)
 
Constructor Summary
SimpleData(java.lang.String valueToCheck)
          This is the most simple constructor, only with the data to check
SimpleData(java.lang.String valueToCheck, boolean throwException)
          Constructor that indicates the dat to check and explicity if throw exception if dosen´t match
SimpleData(java.lang.String valueToCheck, java.lang.String valueToCheckName)
          Constructor, with the data and its name
SimpleData(java.lang.String valueToCheck, java.lang.String valueToCheckName, boolean throwException)
          Constructor, with the data, its name and if throw an exception
 
Method Summary
 void addCheck(SimpleCheck constraint)
          Add one constraint to the store, it also notifies to the constraint that this object is its container.
 void addDataParameters(ErrorDo listener)
          This method add the constraintContainer´s parameters when the data is invalid.
 boolean check()
          This method gets all the constraints and check if the data match all this constraints.
 java.lang.String executeOkDo(OkDo constraintListener)
          This method set the ValidConstrinatProcessor and executes it.
 ErrorDoGroup getErrorDoGroup()
          This method returns a container with instances of invalidConstraintProcessors, one for each constraint that dosen´t match.
 OkDo getOkDo()
          Returns the ValidConstraintProcessor
 java.lang.String getValueToCheck()
          Return the data to check

[Spanish] Devuelve el valor a comprobar, este método es llamado por la restricción para saber que valor debe comprobar.
 java.lang.String getValueToCheckName()
          Return the name of the data to check

[Spanish] Devuelve el nombre del valor a comprobar, por ejemplo el nombre del parametro del servlet.
 boolean isChecked()
          Return if this data has been checked
 boolean isTrownException()
          Return if throw an Exception if this constraintContainer dose´nt match some constraint
 boolean match()
          Return if this data match or not (the value return by checkConstraints)
 boolean needExecutedCheck(java.lang.String constraintName)
          This method is used by the consstraint to indicate to the container that needs one diferent constraint executed, if the container hasn´t then return false else returns true.
 void setErrorDo(ErrorDo constraintListener, ErrorDoGroup constraintListenerContainer)
          This method puts the InValidConstraintProcesor and InValidConstraintProcesorContainer
 void setOkDo(OkDo constraintListener)
          This method puts the OkDo
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

almacen

protected java.util.Vector almacen
the store of all the Checks


valueToCheck

protected java.lang.String valueToCheck
the data to check


throwException

protected boolean throwException
if we must throw an exception, this flag is at container level


constraintListenerContainer

protected ErrorDoGroup constraintListenerContainer
the group of errorDo that listen the parameters


constraintListener

protected ErrorDo constraintListener
One errorDo that listen the parameters


validConstraintProcesor

protected OkDo validConstraintProcesor
The OkDo to process this data


match

protected boolean match
if the data match all the constraints


hasBeenChecked

protected boolean hasBeenChecked
if the data has been checked


valueToCheckName

protected java.lang.String valueToCheckName
the name of the data (parameterName, argumentName,...)

Constructor Detail

SimpleData

public SimpleData(java.lang.String valueToCheck)
This is the most simple constructor, only with the data to check

Parameters:
valueToCheck - the data that has to be checked

SimpleData

public SimpleData(java.lang.String valueToCheck,
                  java.lang.String valueToCheckName)
Constructor, with the data and its name

Parameters:
valueToCheck - the data to check
valueToCheckName - the name of the data (for example the name of the parameter of the servlet or the argument of the commandLine)

SimpleData

public SimpleData(java.lang.String valueToCheck,
                  java.lang.String valueToCheckName,
                  boolean throwException)
Constructor, with the data, its name and if throw an exception

Parameters:
valueToCheck - the data to check
valueToCheckName - the name of the data (for example the name of the parameter of the servlet or the argument of the commandLine)
throwException - true if must throw an exception when the data dosn´t fit the constraints

SimpleData

public SimpleData(java.lang.String valueToCheck,
                  boolean throwException)
Constructor that indicates the dat to check and explicity if throw exception if dosen´t match

Parameters:
valueToCheck - the data to check
throwException - true if throw an exception when the data dosen´t match the constraints
Method Detail

addCheck

public void addCheck(SimpleCheck constraint)
              throws InternalCheckException
Add one constraint to the store, it also notifies to the constraint that this object is its container.

Specified by:
addCheck in interface Data
Parameters:
constraint - the constraint to add
Throws:
InternalCheckException - for internal errors

addDataParameters

public void addDataParameters(ErrorDo listener)
This method add the constraintContainer´s parameters when the data is invalid. It adds the valueToCheckName if it exist

Specified by:
addDataParameters in interface DataInternal
Parameters:
listener - the object that receives the parameters

check

public boolean check()
              throws CheckException,
                     InternalCheckException
This method gets all the constraints and check if the data match all this constraints. If all match the return true, else return false

Specified by:
check in interface Check
Returns:
true if the data match all the constraints, else false
Throws:
CheckException - Throws if the data dosn´t match and the flag is on
InternalCheckException - for internal error only

executeOkDo

public java.lang.String executeOkDo(OkDo constraintListener)
                             throws OkDoInternalException
This method set the ValidConstrinatProcessor and executes it.

Specified by:
executeOkDo in interface Data
Parameters:
constraintListener - the validConstraintProcesor object to handle the process
Returns:
the String with the result of the execution
Throws:
OkDoInternalException - for internal error only

getErrorDoGroup

public ErrorDoGroup getErrorDoGroup()
This method returns a container with instances of invalidConstraintProcessors, one for each constraint that dosen´t match. It also adds the constainer´s parameters

[Spanish] El funcionamiento es obtener todas las restricciones y comprobar si se han cumplido o no (se supone que todas están ejecutadas) Si no se han cumplido, entonces debemos crear un objeto para contener los parametros y pedir a la restricción que nos los proporcione Se añaden los parametros propios del contenedor de restricciones y se introducen en el contenedor de objetos de parametros.

Specified by:
getErrorDoGroup in interface Data
Returns:
One instance of the InValidConstraintProcesorContainer indicated in the set method with all the errorDo

getOkDo

public OkDo getOkDo()
Returns the ValidConstraintProcessor

Specified by:
getOkDo in interface Data
Returns:
the OkDo

getValueToCheck

public java.lang.String getValueToCheck()
Return the data to check

[Spanish] Devuelve el valor a comprobar, este método es llamado por la restricción para saber que valor debe comprobar.

Specified by:
getValueToCheck in interface Data
Returns:
the data to check

getValueToCheckName

public java.lang.String getValueToCheckName()
Return the name of the data to check

[Spanish] Devuelve el nombre del valor a comprobar, por ejemplo el nombre del parametro del servlet.

Specified by:
getValueToCheckName in interface Data
Returns:
the name of the data to check

isChecked

public boolean isChecked()
Return if this data has been checked

Specified by:
isChecked in interface Check
Returns:
true if this ConstraintCOntainer has been checked

isTrownException

public boolean isTrownException()
Return if throw an Exception if this constraintContainer dose´nt match some constraint

Specified by:
isTrownException in interface DataInternal
Returns:
true if throw or false if not

match

public boolean match()
Return if this data match or not (the value return by checkConstraints)

Specified by:
match in interface Check
Returns:
the value of checkConstraint()

needExecutedCheck

public boolean needExecutedCheck(java.lang.String constraintName)
                          throws CheckException,
                                 InternalCheckException
This method is used by the consstraint to indicate to the container that needs one diferent constraint executed, if the container hasn´t then return false else returns true. If the constraint isn´t executed then the container executes it.

[Spanish] Compruebo todas las restricciones que tengo a ver si alguna coincide con la que me piden. Si la tengo y no está ejecutada, la ejecuto. Si no la tengo, devuelvo false

Specified by:
needExecutedCheck in interface DataInternal
Parameters:
constraintName - the class name of the constraint that needs (com.inigoserrano.isvalidator.checks.NotBlankCheck, for example)
Returns:
true if have execute else false
Throws:
CheckException - Throw if the data dosn´t match and the flag is on
InternalCheckException - For internal error only

setErrorDo

public void setErrorDo(ErrorDo constraintListener,
                       ErrorDoGroup constraintListenerContainer)
This method puts the InValidConstraintProcesor and InValidConstraintProcesorContainer

Specified by:
setErrorDo in interface Data
Parameters:
constraintListener - One instance of an InValidConstraintProcesor
constraintListenerContainer - One instance of an InValidConstraintProcesorContainer

setOkDo

public void setOkDo(OkDo constraintListener)
This method puts the OkDo

Specified by:
setOkDo in interface Data
Parameters:
constraintListener - The OkDo


Copyright © 2002-2002 Iñigo Serrano Llona. All Rights Reserved.