Top Description Fields Constructors Methods
com.sun.tools.rngdatatype.helpers

public final Class StreamingValidatorImpl

extends Object
implements DatatypeStreamingValidator
Class Inheritance
All Implemented Interfaces
com.sun.tools.rngdatatype.DatatypeStreamingValidator
Imports
com.sun.tools.rngdatatype.Datatype, .DatatypeException, .DatatypeStreamingValidator, .ValidationContext

Dummy implementation of 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);
    }
    ....
}
Author
Kohsuke KAWAGUCHI

Field Summary

Modifier and TypeField and Description
private final Datatype
baseType

Datatype obejct that creates this streaming validator.

private final StringBuffer
buffer

This buffer accumulates characters.

private final ValidationContext
context

The current context.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
addCharacters(char[] buf, int start, int len)

Implements com.sun.tools.rngdatatype.DatatypeStreamingValidator.addCharacters.

Passes an additional fragment of the literal.

public void
checkValid()

Implements com.sun.tools.rngdatatype.DatatypeStreamingValidator.checkValid.

Similar to the isValid method, but this method throws Exception (with possibly diagnostic information), instead of returning false.

public boolean
isValid()

Implements com.sun.tools.rngdatatype.DatatypeStreamingValidator.isValid.

Tells if the accumulated literal is valid with respect to the underlying Datatype.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

baseTypeback to summary
private final Datatype baseType

Datatype obejct that creates this streaming validator.

bufferback to summary
private final StringBuffer buffer

This buffer accumulates characters.

contextback to summary
private final ValidationContext context

The current context.

Constructor Detail

StreamingValidatorImplback to summary
public StreamingValidatorImpl(Datatype baseType, ValidationContext context)

Method Detail

addCharactersback to summary
public void addCharacters(char[] buf, int start, int len)

Implements com.sun.tools.rngdatatype.DatatypeStreamingValidator.addCharacters.

Doc from com.sun.tools.rngdatatype.DatatypeStreamingValidator.addCharacters.

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.

checkValidback to summary
public void checkValid() throws DatatypeException

Implements com.sun.tools.rngdatatype.DatatypeStreamingValidator.checkValid.

Doc from com.sun.tools.rngdatatype.DatatypeStreamingValidator.checkValid.

Similar to the isValid method, but this method throws Exception (with possibly diagnostic information), instead of returning false.

Exceptions
DatatypeException:
If the callee supports the diagnosis and the accumulated literal is invalid, then this exception that possibly contains diagnosis information is thrown.
isValidback to summary
public boolean isValid()

Implements com.sun.tools.rngdatatype.DatatypeStreamingValidator.isValid.

Doc from com.sun.tools.rngdatatype.DatatypeStreamingValidator.isValid.

Tells if the accumulated literal is valid with respect to the underlying Datatype.