Package org.relaxng.datatype.helpers
Class StreamingValidatorImpl
- java.lang.Object
-
- org.relaxng.datatype.helpers.StreamingValidatorImpl
-
- All Implemented Interfaces:
DatatypeStreamingValidator
public final class StreamingValidatorImpl extends java.lang.Object implements DatatypeStreamingValidator
Dummy implementation ofDatatypeStreamingValidator.This implementation can be used as a quick hack when the performance of streaming validation is not important. And this implementation also shows you how to implement the DatatypeStreamingValidator interface.
Typical usage would be:
class MyDatatype implements Datatype { .... public DatatypeStreamingValidator createStreamingValidator( ValidationContext context ) { return new StreamingValidatorImpl(this,context); } .... }
-
-
Field Summary
Fields Modifier and Type Field Description private DatatypebaseTypeDatatype obejct that creates this streaming validator.private java.lang.StringBufferbufferThis buffer accumulates characters.private ValidationContextcontextThe current context.
-
Constructor Summary
Constructors Constructor Description StreamingValidatorImpl(Datatype baseType, ValidationContext context)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddCharacters(char[] buf, int start, int len)Passes an additional fragment of the literal.voidcheckValid()Similar to the isValid method, but this method throws Exception (with possibly diagnostic information), instead of returning false.booleanisValid()Tells if the accumulated literal is valid with respect to the underlying Datatype.
-
-
-
Field Detail
-
buffer
private final java.lang.StringBuffer buffer
This buffer accumulates characters.
-
baseType
private final Datatype baseType
Datatype obejct that creates this streaming validator.
-
context
private final ValidationContext context
The current context.
-
-
Constructor Detail
-
StreamingValidatorImpl
public StreamingValidatorImpl(Datatype baseType, ValidationContext context)
-
-
Method Detail
-
addCharacters
public void addCharacters(char[] buf, int start, int len)Description copied from interface:DatatypeStreamingValidatorPasses 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:
addCharactersin interfaceDatatypeStreamingValidator
-
isValid
public boolean isValid()
Description copied from interface:DatatypeStreamingValidatorTells if the accumulated literal is valid with respect to the underlying Datatype.- Specified by:
isValidin interfaceDatatypeStreamingValidator- Returns:
- True if it is valid. False if otherwise.
-
checkValid
public void checkValid() throws DatatypeExceptionDescription copied from interface:DatatypeStreamingValidatorSimilar to the isValid method, but this method throws Exception (with possibly diagnostic information), instead of returning false.- Specified by:
checkValidin interfaceDatatypeStreamingValidator- Throws:
DatatypeException- If the callee supports the diagnosis and the accumulated literal is invalid, then this exception that possibly contains diagnosis information is thrown.
-
-