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 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. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | addCharacters(char[] buf, int start, int len)
Implements com. Passes an additional fragment of the literal. |
| public void | checkValid()
Implements com. Similar to the isValid method, but this method throws Exception (with possibly diagnostic information), instead of returning false. |
| public boolean | isValid()
Implements com. Tells if the accumulated literal is valid with respect to the underlying Datatype. |
| baseType | back to summary |
|---|---|
| private final Datatype baseType Datatype obejct that creates this streaming validator. | |
| buffer | back to summary |
|---|---|
| private final StringBuffer buffer This buffer accumulates characters. | |
| context | back to summary |
|---|---|
| private final ValidationContext context The current context. | |
| StreamingValidatorImpl | back to summary |
|---|---|
| public StreamingValidatorImpl(Datatype baseType, ValidationContext context) | |
| addCharacters | back to summary |
|---|---|
| public void addCharacters(char[] buf, int start, int len) Implements com. Doc from com. 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. | |
| checkValid | back to summary |
|---|---|
| public void checkValid() throws DatatypeException Implements com. Doc from com. Similar to the isValid method, but this method throws Exception (with possibly diagnostic information), instead of returning false.
| |
| isValid | back to summary |
|---|---|
| public boolean isValid() Implements com. Doc from com. Tells if the accumulated literal is valid with respect to the underlying Datatype. | |