|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.cocoon.components.validation.impl.AbstractValidator
public abstract class AbstractValidator
The AbstractValidator provides a generic implementation of the methods
specified by the Validator interface.
Final implementations must implement three component management methods
lookupParserByGrammar(String), lookupParserByName(String) and
releaseParser(SchemaParser).
In addition to this, they might also override the default implementation of
the getSchema(SchemaParser, Source, String) method, for example when
caching Schema instances.
This implementation provides a simple grammar identification mechanism, which
can be overridden by reimplementing the detectGrammar(Source) method
provided by this class.
| Field Summary | |
|---|---|
protected Logger |
logger
The configured Logger instance. |
protected ServiceManager |
manager
The configured ServiceManager instance. |
protected SourceResolver |
resolver
The configured SourceResolver instance. |
| Fields inherited from interface org.apache.cocoon.components.validation.Validator |
|---|
GRAMMAR_ISO_SCHEMATRON, GRAMMAR_RELAX_CORE, GRAMMAR_RELAX_NG, GRAMMAR_RELAX_NS, GRAMMAR_SCHEMATRON, GRAMMAR_TREX, GRAMMAR_XML_DTD, GRAMMAR_XML_SCHEMA, ROLE |
| Constructor Summary | |
|---|---|
AbstractValidator()
Create a new AbstractValidator instance. |
|
| Method Summary | |
|---|---|
protected String |
detectGrammar(Source source)
Attempt to detect the grammar language used by the schema identified by the specified Source. |
void |
dispose()
Dispose of this component instance. |
void |
enableLogging(Logger logger)
Enable logging. |
protected Schema |
getSchema(SchemaParser parser,
Source source,
String grammar)
Return a Schema instance from the specified SchemaParser
associated with the given Source and grammar language. |
ValidationHandler |
getValidationHandler(Source source)
Return a ValidationHandler validating an XML document according to
the schema found at the specified location. |
ValidationHandler |
getValidationHandler(Source source,
ErrorHandler errorHandler)
Return a ValidationHandler validating an XML document according to
the schema found at the specified location. |
ValidationHandler |
getValidationHandler(Source source,
String grammar)
Return a ValidationHandler validating an XML document according to
the schema found at the specified location. |
ValidationHandler |
getValidationHandler(Source source,
String grammar,
ErrorHandler errorHandler)
Return a ValidationHandler validating an XML document according to
the schema found at the specified location. |
ValidationHandler |
getValidationHandler(String uri)
Return a ValidationHandler validating an XML document according to
the schema found at the specified location. |
ValidationHandler |
getValidationHandler(String uri,
ErrorHandler errorHandler)
Return a ValidationHandler validating an XML document according to
the schema found at the specified location. |
ValidationHandler |
getValidationHandler(String uri,
String grammar)
Return a ValidationHandler validating an XML document according to
the schema found at the specified location. |
ValidationHandler |
getValidationHandler(String uri,
String grammar,
ErrorHandler errorHandler)
Return a ValidationHandler validating an XML document according to
the schema found at the specified location. |
protected abstract SchemaParser |
lookupParserByGrammar(String grammar)
Attempt to acquire a SchemaParser interface able to understand
the grammar language specified. |
protected abstract SchemaParser |
lookupParserByName(String name)
Attempt to acquire a SchemaParser interface associated with the
specified instance name. |
protected abstract void |
releaseParser(SchemaParser parser)
Release a previously acquired SchemaParser instance back to its
original component manager. |
void |
service(ServiceManager manager)
Specify the ServiceManager available to this instance. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected ServiceManager manager
The configured ServiceManager instance.
protected SourceResolver resolver
The configured SourceResolver instance.
protected Logger logger
The configured Logger instance.
| Constructor Detail |
|---|
public AbstractValidator()
Create a new AbstractValidator instance.
| Method Detail |
|---|
public void enableLogging(Logger logger)
Enable logging.
enableLogging in interface LogEnabled
public void service(ServiceManager manager)
throws ServiceException
Specify the ServiceManager available to this instance.
service in interface ServiceableServiceExceptionpublic void dispose()
Dispose of this component instance.
dispose in interface Disposable
public ValidationHandler getValidationHandler(String uri)
throws IOException,
SAXException,
ValidatorException
Return a ValidationHandler validating an XML document according to
the schema found at the specified location.
The Validator will attempt to automatically detect the grammar
language of the specified schema, and each error or warning occurring while
validating the document will trigger a SAXException to be thrown back
to the caller.
getValidationHandler in interface Validatoruri - the location of the schema to use to validate the document.
ValidationHandler able to SAX events from
the original XML document to validate.
IOException - if an I/O error occurred parsing the schema.
SAXException - if a grammar error occurred parsing the schema.
ValidatorException - if the grammar language of the specified schema
could not be detected or was not supported.SchemaParser.parseSchema(Source, String),
Schema.createValidator(ErrorHandler)
public ValidationHandler getValidationHandler(String uri,
String grammar)
throws IOException,
SAXException,
ValidatorException
Return a ValidationHandler validating an XML document according to
the schema found at the specified location.
Each error or warning occurring while validating the document will trigger
a SAXException to be thrown back to the caller.
getValidationHandler in interface Validatoruri - the location of the schema to use to validate the document.grammar - the grammar language of the schema to parse.
ValidationHandler able to SAX events from
the original XML document to validate.
IOException - if an I/O error occurred parsing the schema.
SAXException - if a grammar error occurred parsing the schema.
ValidatorException - if the specified grammar language wasn't supported.SchemaParser.parseSchema(Source, String),
Schema.createValidator(ErrorHandler)
public ValidationHandler getValidationHandler(String uri,
ErrorHandler errorHandler)
throws IOException,
SAXException,
ValidatorException
Return a ValidationHandler validating an XML document according to
the schema found at the specified location.
The Validator will attempt to automatically detect the grammar
language of the specified schema, while each validation error or warning will
be passed to the specified ErrorHandler which will have the ability
to generate and throw a SAXException back to the caller.
getValidationHandler in interface Validatoruri - the location of the schema to use to validate the document.errorHandler - the ErrorHandler notified of validation problems.
ValidationHandler able to SAX events from
the original XML document to validate.
IOException - if an I/O error occurred parsing the schema.
SAXException - if a grammar error occurred parsing the schema.
ValidatorException - if the grammar language of the specified schema
could not be detected or was not supported.SchemaParser.parseSchema(Source, String),
Schema.createValidator(ErrorHandler)
public ValidationHandler getValidationHandler(String uri,
String grammar,
ErrorHandler errorHandler)
throws IOException,
SAXException,
ValidatorException
Return a ValidationHandler validating an XML document according to
the schema found at the specified location.
Each validation error or warning will be passed to the specified
ErrorHandler which will have the ability to generate and throw a
SAXException back to the caller.
getValidationHandler in interface Validatoruri - the location of the schema to use to validate the document.grammar - the grammar language of the schema to parse.errorHandler - the ErrorHandler notified of validation problems.
ValidationHandler able to SAX events from
the original XML document to validate.
IOException - if an I/O error occurred parsing the schema.
SAXException - if a grammar error occurred parsing the schema.
ValidatorException - if the specified grammar language wasn't supported.SchemaParser.parseSchema(Source, String),
Schema.createValidator(ErrorHandler)
public ValidationHandler getValidationHandler(Source source)
throws IOException,
SAXException,
ValidatorException
Return a ValidationHandler validating an XML document according to
the schema found at the specified location.
The Validator will attempt to automatically detect the grammar
language of the specified schema, and each error or warning occurring while
validating the document will trigger a SAXException to be thrown back
to the caller.
getValidationHandler in interface Validatorsource - the Source identifying the schema to use for validation.
ValidationHandler able to SAX events from
the original XML document to validate.
IOException - if an I/O error occurred parsing the schema.
SAXException - if a grammar error occurred parsing the schema.
ValidatorException - if the grammar language of the specified schema
could not be detected or was not supported.SchemaParser.parseSchema(Source, String),
Schema.createValidator(ErrorHandler)
public ValidationHandler getValidationHandler(Source source,
String grammar)
throws IOException,
SAXException,
ValidatorException
Return a ValidationHandler validating an XML document according to
the schema found at the specified location.
Each error or warning occurring while validating the document will trigger
a SAXException to be thrown back to the caller.
getValidationHandler in interface Validatorsource - the Source identifying the schema to use for validation.grammar - the grammar language of the schema to parse.
ValidationHandler able to SAX events from
the original XML document to validate.
IOException - if an I/O error occurred parsing the schema.
SAXException - if a grammar error occurred parsing the schema.
ValidatorException - if the specified grammar language wasn't supported.SchemaParser.parseSchema(Source, String),
Schema.createValidator(ErrorHandler)
public ValidationHandler getValidationHandler(Source source,
ErrorHandler errorHandler)
throws IOException,
SAXException,
ValidatorException
Return a ValidationHandler validating an XML document according to
the schema found at the specified location.
The Validator will attempt to automatically detect the grammar
language of the specified schema, while each validation error or warning will
be passed to the specified ErrorHandler which will have the ability
to generate and throw a SAXException back to the caller.
getValidationHandler in interface Validatorsource - the Source identifying the schema to use for validation.errorHandler - the ErrorHandler notified of validation problems.
ValidationHandler able to SAX events from
the original XML document to validate.
IOException - if an I/O error occurred parsing the schema.
SAXException - if a grammar error occurred parsing the schema.
ValidatorException - if the grammar language of the specified schema
could not be detected or was not supported.SchemaParser.parseSchema(Source, String),
Schema.createValidator(ErrorHandler)
public ValidationHandler getValidationHandler(Source source,
String grammar,
ErrorHandler errorHandler)
throws IOException,
SAXException,
ValidatorException
Return a ValidationHandler validating an XML document according to
the schema found at the specified location.
Each validation error or warning will be passed to the specified
ErrorHandler which will have the ability to generate and throw a
SAXException back to the caller.
getValidationHandler in interface Validatorsource - the Source identifying the schema to use for validation.grammar - the grammar language of the schema to parse.errorHandler - the ErrorHandler notified of validation problems.
ValidationHandler able to SAX events from
the original XML document to validate.
IOException - if an I/O error occurred parsing the schema.
SAXException - if a grammar error occurred parsing the schema.
ValidatorException - if the specified grammar language wasn't supported.SchemaParser.parseSchema(Source, String),
Schema.createValidator(ErrorHandler)protected abstract SchemaParser lookupParserByGrammar(String grammar)
Attempt to acquire a SchemaParser interface able to understand
the grammar language specified.
grammar - the grammar language that must be understood by the returned
SchemaParser
SchemaParser instance or null if none was found able
to understand the specified grammar language.protected abstract SchemaParser lookupParserByName(String name)
Attempt to acquire a SchemaParser interface associated with the
specified instance name.
name - the name associated with the SchemaParser to be returned.
SchemaParser instance or null if none was found.protected abstract void releaseParser(SchemaParser parser)
Release a previously acquired SchemaParser instance back to its
original component manager.
This method is supplied in case solid implementations of this class relied
on the ServiceManager to manage SchemaParsers instances.
parser - the SchemaParser whose instance is to be released.
protected Schema getSchema(SchemaParser parser,
Source source,
String grammar)
throws IOException,
SAXException
Return a Schema instance from the specified SchemaParser
associated with the given Source and grammar language.
This method simply implements resolution returning the Schema
instance acquired calling parser.getSchema(source,grammar).
parser - the SchemaParser producing the Schema.source - the Source associated with the Schema to return.grammar - the grammar language of the schema to produce.
SAXException - if a grammar error occurred parsing the schema.
IOException - if an I/O error occurred parsing the schema.
protected String detectGrammar(Source source)
throws IOException,
SAXException,
ValidatorException
Attempt to detect the grammar language used by the schema identified
by the specified Source.
source - a Source instance pointing to the schema to be analyzed.
IOException - if an I/O error occurred accessing the schema.
SAXException - if an error occurred parsing the schema.
ValidatorException - if the language of the schema could not be guessed.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||