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 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

Constructor Summary
StreamingValidatorImpl(Datatype baseType, ValidationContext context)
           
 
Method Summary
 void characters(char[] buf, int start, int len)
          let a streaming validator process additional literal fragment.
 void check()
          similar to the finish method, but this method throws Exception (with possibly diagnostic information), instad of returning false.
 boolean finish()
          gets if the accumulated literal is valid with respect to the underlying Datatype.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StreamingValidatorImpl

public StreamingValidatorImpl(Datatype baseType,
                              ValidationContext context)
Method Detail

characters

public void characters(char[] buf,
                       int start,
                       int len)
Description copied from interface: DatatypeStreamingValidator
let a streaming validator process additional literal fragment.

The application can call this method several times, then call the isValid method to check the validity.

Specified by:
characters in interface DatatypeStreamingValidator

finish

public boolean finish()
Description copied from interface: DatatypeStreamingValidator
gets if the accumulated literal is valid with respect to the underlying Datatype. The application should call it when there is no more characters.

This method can be called only once, and this object should be discarded after that.

Specified by:
finish in interface DatatypeStreamingValidator
Following copied from interface: org.relaxng.datatype.DatatypeStreamingValidator
Returns:
True if it is valid. False if otherwise.

check

public void check()
           throws DatatypeException
Description copied from interface: DatatypeStreamingValidator
similar to the finish method, but this method throws Exception (with possibly diagnostic information), instad of returning false.

If this method returns without any exception thrown, that means the accumulated string is valid.

Specified by:
check in interface DatatypeStreamingValidator
Following copied from interface: org.relaxng.datatype.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.