public final class StreamingValidatorImpl extends java.lang.Object implements DatatypeStreamingValidator
DatatypeStreamingValidator
.
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); } .... }
Modifier and Type | Field and Description |
---|---|
private Datatype |
baseType
Datatype obejct that creates this streaming validator.
|
private java.lang.StringBuffer |
buffer
This buffer accumulates characters.
|
private ValidationContext |
context
The current context.
|
Constructor and Description |
---|
StreamingValidatorImpl(Datatype baseType,
ValidationContext context) |
Modifier and Type | Method and Description |
---|---|
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.
|
private final java.lang.StringBuffer buffer
private final Datatype baseType
private final ValidationContext context
public StreamingValidatorImpl(Datatype baseType, ValidationContext context)
public void addCharacters(char[] buf, int start, int len)
DatatypeStreamingValidator
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.
addCharacters
in interface DatatypeStreamingValidator
public boolean isValid()
DatatypeStreamingValidator
isValid
in interface DatatypeStreamingValidator
public void checkValid() throws DatatypeException
DatatypeStreamingValidator
checkValid
in interface DatatypeStreamingValidator
DatatypeException
- If the callee supports the diagnosis and the accumulated
literal is invalid, then this exception that possibly
contains diagnosis information is thrown.