org.jboss.xb.util
Class AbstractSchemaBindingValidator

java.lang.Object
  extended by org.jboss.xb.util.AbstractSchemaBindingValidator
All Implemented Interfaces:
SchemaBindingValidator
Direct Known Subclasses:
DefaultSchemaBindingValidator

public abstract class AbstractSchemaBindingValidator
extends Object
implements SchemaBindingValidator

Mostly a holder for excluded and validated types, namespaces.

Version:
$Revision: 1.1 $
Author:
Alexey Loubyansky, Ales Justin

Field Summary
protected  Set<String> excludedNs
           
protected  Set<QName> excludedTypes
           
protected static org.jboss.logging.Logger log
           
protected  Set<QName> validatedElements
           
protected  Set<QName> validatedTypes
           
protected static QName WILDCARD
           
 
Constructor Summary
protected AbstractSchemaBindingValidator()
           
protected AbstractSchemaBindingValidator(SchemaBindingResolver resolver)
           
 
Method Summary
 void enableLogging(boolean value)
           
 void excludeNs(String ns)
          Types and elements from the namespace passed into this method will be excluded from validation.
 void excludeType(QName qName)
          Excludes the specified type from validation.
 SchemaBindingResolver getSchemaResolver()
           
protected  void handleError(String msg)
          This an error handler method.
 void includeNs(String ns)
          Removes the namespace from the excluded set.
 void includeType(QName qName)
          Removes the specified type from the excluded set.
 boolean isLoggingEnabled()
           
 boolean isNsExcluded(String ns)
          Checks if the specified namespace is excluded from validation.
 boolean isTypeExcluded(QName qName)
          Checks if the type is excluded from validation.
protected  void log(String msg)
          This method is supposed to log a message.
 void reset()
          Resets instance variables (such as a set of validated types and elements).
 void setSchemaResolver(SchemaBindingResolver resolver)
           
 void validate(InputSource is, SchemaBinding binding)
          This method will check that the XSD represented with InputSource and SchemaBinding are consistent.
 void validate(String xsdName, Class<?>... cls)
          Validate xsd schema against classes.
protected abstract  void validate(org.apache.xerces.xs.XSModel xsSchema, SchemaBinding schemaBinding)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static final org.jboss.logging.Logger log

WILDCARD

protected static final QName WILDCARD

excludedNs

protected Set<String> excludedNs

excludedTypes

protected Set<QName> excludedTypes

validatedTypes

protected Set<QName> validatedTypes

validatedElements

protected Set<QName> validatedElements
Constructor Detail

AbstractSchemaBindingValidator

protected AbstractSchemaBindingValidator()

AbstractSchemaBindingValidator

protected AbstractSchemaBindingValidator(SchemaBindingResolver resolver)
Parameters:
resolver - default schema resolver
Method Detail

reset

public void reset()
Resets instance variables (such as a set of validated types and elements). This method is required to invoked before another validation. It is called internally at the end of validate(XSModel xsSchema, SchemaBinding schemaBinding). NOTE: this method doesn't clear excluded namespaces and types.


isLoggingEnabled

public boolean isLoggingEnabled()

enableLogging

public void enableLogging(boolean value)

excludeNs

public void excludeNs(String ns)
Description copied from interface: SchemaBindingValidator
Types and elements from the namespace passed into this method will be excluded from validation.

Specified by:
excludeNs in interface SchemaBindingValidator
Parameters:
ns - namespace to exclude

isNsExcluded

public boolean isNsExcluded(String ns)
Description copied from interface: SchemaBindingValidator
Checks if the specified namespace is excluded from validation.

Specified by:
isNsExcluded in interface SchemaBindingValidator
Parameters:
ns - the namespace to check
Returns:
true if the namespace is excluded

includeNs

public void includeNs(String ns)
Description copied from interface: SchemaBindingValidator
Removes the namespace from the excluded set. If the namespace has not been excluded, the method does nothing.

Specified by:
includeNs in interface SchemaBindingValidator
Parameters:
ns - the namespace to remove from the excluded set.

excludeType

public void excludeType(QName qName)
Description copied from interface: SchemaBindingValidator
Excludes the specified type from validation.

Specified by:
excludeType in interface SchemaBindingValidator
Parameters:
qName - the QName of the type to exclude from validation

isTypeExcluded

public boolean isTypeExcluded(QName qName)
Description copied from interface: SchemaBindingValidator
Checks if the type is excluded from validation.

Specified by:
isTypeExcluded in interface SchemaBindingValidator
Parameters:
qName - the QName of the type to check
Returns:
true if the type is excluded from validation

includeType

public void includeType(QName qName)
Description copied from interface: SchemaBindingValidator
Removes the specified type from the excluded set. If the type has not been excluded, the method does nothing.

Specified by:
includeType in interface SchemaBindingValidator
Parameters:
qName - the QName of type to remove from the excluded set.

getSchemaResolver

public SchemaBindingResolver getSchemaResolver()
Returns:
The default resolver used to resolve schemas

setSchemaResolver

public void setSchemaResolver(SchemaBindingResolver resolver)
Parameters:
resolver - The default resolver used to resolve schemas

validate

public void validate(InputSource is,
                     SchemaBinding binding)
Description copied from interface: SchemaBindingValidator
This method will check that the XSD represented with InputSource and SchemaBinding are consistent. The consistency is checked to certain degree and is far from 100%. Currently it checks just for basic things such as the existence of type definitions, attribute and element declarations and element ordering.

Specified by:
validate in interface SchemaBindingValidator
Parameters:
is - InputSource of the XSD
binding - SchemaBinding

validate

public void validate(String xsdName,
                     Class<?>... cls)
Description copied from interface: SchemaBindingValidator
Validate xsd schema against classes.

Specified by:
validate in interface SchemaBindingValidator
Parameters:
xsdName - the schema name
cls - the classes to check

validate

protected abstract void validate(org.apache.xerces.xs.XSModel xsSchema,
                                 SchemaBinding schemaBinding)

handleError

protected void handleError(String msg)
This an error handler method. Default implementation throws IllegalStateException with the message passed in as the argument.

Parameters:
msg - the error message

log

protected void log(String msg)
This method is supposed to log a message. Default implementation uses trace logging.

Parameters:
msg - the message to log.


Copyright © 2010 JBoss Inc.. All Rights Reserved.