org.whattf.datatype
Class DatatypeStreamingValidatorImpl

java.lang.Object
  extended by org.whattf.datatype.DatatypeStreamingValidatorImpl
All Implemented Interfaces:
DatatypeStreamingValidator

public final class DatatypeStreamingValidatorImpl
extends Object
implements DatatypeStreamingValidator


Field Summary
private  StringBuilder buffer
           
private  AbstractDatatype datatype
           
 
Constructor Summary
DatatypeStreamingValidatorImpl(AbstractDatatype datatype)
           
 
Method Summary
 void addCharacters(char[] buf, int start, int len)
          Passes an additional fragment of the literal.
 void checkValid()
          Similar to the isValid method, but this method throws Exception (with possibly diagnostic information), instead of returning false.
 boolean isValid()
          Tells if the accumulated literal is valid with respect to the underlying Datatype.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

datatype

private final AbstractDatatype datatype

buffer

private final StringBuilder buffer
Constructor Detail

DatatypeStreamingValidatorImpl

public DatatypeStreamingValidatorImpl(AbstractDatatype datatype)
Method Detail

addCharacters

public void addCharacters(char[] buf,
                          int start,
                          int len)
Description copied from interface: DatatypeStreamingValidator
Passes an additional fragment of the literal.

The application can call this method several times, then call the isValid method (or the checkValid method) to check the validity of the accumulated characters.

Specified by:
addCharacters in interface DatatypeStreamingValidator

isValid

public boolean isValid()
Description copied from interface: DatatypeStreamingValidator
Tells if the accumulated literal is valid with respect to the underlying Datatype.

Specified by:
isValid in interface DatatypeStreamingValidator
Returns:
True if it is valid. False if otherwise.

checkValid

public void checkValid()
                throws DatatypeException
Description copied from interface: DatatypeStreamingValidator
Similar to the isValid method, but this method throws Exception (with possibly diagnostic information), instead of returning false.

Specified by:
checkValid in interface DatatypeStreamingValidator
Throws:
DatatypeException - If the callee supports the diagnosis and the accumulated literal is invalid, then this exception that possibly contains diagnosis information is thrown.