org.jboss.xb.binding.sunday.unmarshalling
Class DefaultSchemaResolver

java.lang.Object
  extended by org.jboss.xb.binding.resolver.AbstractMutableSchemaResolver
      extended by org.jboss.xb.binding.sunday.unmarshalling.DefaultSchemaResolver
All Implemented Interfaces:
MutableSchemaResolver, SchemaBindingResolver

public class DefaultSchemaResolver
extends AbstractMutableSchemaResolver

A default SchemaBindingResolver that uses a JBossEntityResolver to locate the schema xsd.

Version:
$Revision: 3021 $
Author:
Scott.Stark@jboss.org

Constructor Summary
DefaultSchemaResolver()
           
DefaultSchemaResolver(org.jboss.util.xml.JBossEntityResolver resolver)
           
 
Method Summary
 void addClassBinding(String nsUri, Class<?> clazz)
           
 void addClassBinding(String nsUri, String reference)
          Add an in-memory schema.
 void addClassBindingForLocation(String schemaLocation, Class<?> clazz)
           
 void addSchemaInitializer(String nsUri, SchemaBindingInitializer sbi)
          Registers an instance of SchemaBindingInitializer for the namespace URI.
 void addSchemaInitializer(String nsUri, String sbiClassName)
          Registers a SchemaBindingInitializer for the namespace URI.
 void addSchemaLocation(String nsUri, String location)
          Registers a location for the namespace URI.
 void addSchemaParseAnnotations(String nsUri, Boolean value)
          Whether to parse annotations for this namespace.
protected  Class<?>[] getClassesForSchemaLocation(String uri)
           
protected  Class<?>[] getClassesForURI(String uri)
           
 void mapLocationToClass(String schemaLocation, Class<?> clazz)
          Maps schema location to a class which should be used as the base for the SchemaBinding.
 void mapLocationToClasses(String schemaLocation, Class<?>... classes)
          Maps schema location to an array of classes that should be used as the base for the SchemaBinding.
 void mapURIToClass(String nsUri, Class<?> clazz)
          Maps a namespace URI to a class which will be used as the base for the SchemaBinding.
 void mapURIToClasses(String nsUri, Class<?>... clazz)
          Maps a namespace URI to an array of classes that will be used as the base for the SchemaBinding.
 void mapURIToClasses(String nsUri, String... reference)
          Maps a namespace URI to an array of classes that will be used as the base for the SchemaBinding.
 Class<?> removeClassBinding(String nsUri)
           
 Class<?> removeClassBindingForLocation(String schemaLocation)
           
 Class<?>[] removeLocationToClassMapping(String schemaLocation)
          Removes schema location to class mapping.
 Boolean removeSchemaParseAnnotations(String nsUri)
          Removes the parse annotation configuration for this namespace.
 Class<?>[] removeURIToClassMapping(String nsUri)
          Removes namespace URI to class mapping
 
Methods inherited from class org.jboss.xb.binding.resolver.AbstractMutableSchemaResolver
getBaseURI, isCacheResolvedSchemas, loadReference, mapLocationToClass, mapLocationToClasses, mapSchemaInitializer, mapSchemaInitializer, mapSchemaLocation, mapURIToClass, removeSchemaInitializer, removeSchemaLocation, resolve, resolveAsLSInput, resolveClassFromSchemaLocation, setBaseURI, setCacheResolvedSchemas, setParseXSDAnnotations, unsetParseXSDAnnotations
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultSchemaResolver

public DefaultSchemaResolver()

DefaultSchemaResolver

public DefaultSchemaResolver(org.jboss.util.xml.JBossEntityResolver resolver)
Method Detail

addSchemaLocation

public void addSchemaLocation(String nsUri,
                              String location)
Registers a location for the namespace URI.

This method delegates to mapSchemaLocation(nsUri, location). This location is looked using the JBossEntityResolver, i.e. it is a classpath location

Parameters:
nsUri - the namespace location
location - the classpath location

addSchemaParseAnnotations

public void addSchemaParseAnnotations(String nsUri,
                                      Boolean value)
Whether to parse annotations for this namespace. This method delegates to parseXSDAnnotations(nsUri, value).

Parameters:
nsUri - the namespace
value - the value of the option

removeSchemaParseAnnotations

public Boolean removeSchemaParseAnnotations(String nsUri)
Removes the parse annotation configuration for this namespace. This method delegates to unsetParseXSDAnnotations(nsURI).

Parameters:
nsUri - the namespace
Returns:
the previous value

addSchemaInitializer

public void addSchemaInitializer(String nsUri,
                                 String sbiClassName)
                          throws Exception
Registers a SchemaBindingInitializer for the namespace URI. When the schema binding that corresponds to the namespace URI is resolved, the init(SchemaBinding schema) method will be invoked on the instance of SchemaBindingInitializer with the SchemaBinding returned from the XsdBinder.bind() method. This method delegates to mapSchemaInitializer(nsUri, sbiClassName).

Parameters:
nsUri - the namespace URI to register the schema initializer for
sbiClassName - the class name SchemaBindingInitializer
Throws:
Exception - for any error

addSchemaInitializer

public void addSchemaInitializer(String nsUri,
                                 SchemaBindingInitializer sbi)
Registers an instance of SchemaBindingInitializer for the namespace URI. When the schema binding that corresponds to the namespace URI is resolved, the init(SchemaBinding schema) method will be invoked on the instance of SchemaBindingInitializer with the SchemaBinding returned from the XsdBinder.bind() method. This method delegates to mapSchemaInitializer(nsUri, sbi).

Parameters:
nsUri - the namespace URI to register the schema initializer for
sbi - an instance of SchemaBindingInitializer

addClassBinding

public void addClassBinding(String nsUri,
                            String reference)
                     throws ClassNotFoundException
Add an in-memory schema.

Parameters:
nsUri - schema namespace
reference - the schema reference class name
Throws:
Exception - for any error
ClassNotFoundException

addClassBinding

public void addClassBinding(String nsUri,
                            Class<?> clazz)

removeClassBinding

public Class<?> removeClassBinding(String nsUri)

addClassBindingForLocation

public void addClassBindingForLocation(String schemaLocation,
                                       Class<?> clazz)

removeClassBindingForLocation

public Class<?> removeClassBindingForLocation(String schemaLocation)

getClassesForSchemaLocation

protected Class<?>[] getClassesForSchemaLocation(String uri)
Specified by:
getClassesForSchemaLocation in class AbstractMutableSchemaResolver

getClassesForURI

protected Class<?>[] getClassesForURI(String uri)
Specified by:
getClassesForURI in class AbstractMutableSchemaResolver

mapLocationToClass

public void mapLocationToClass(String schemaLocation,
                               Class<?> clazz)
Description copied from interface: MutableSchemaResolver
Maps schema location to a class which should be used as the base for the SchemaBinding.

Parameters:
schemaLocation - the location of the schema
clazz - the class to build the SchemaBinding from

mapLocationToClasses

public void mapLocationToClasses(String schemaLocation,
                                 Class<?>... classes)
Description copied from interface: MutableSchemaResolver
Maps schema location to an array of classes that should be used as the base for the SchemaBinding.

Parameters:
schemaLocation - the location of the schema
classes - the array of classes to build the SchemaBinding from

mapURIToClass

public void mapURIToClass(String nsUri,
                          Class<?> clazz)
Description copied from interface: MutableSchemaResolver
Maps a namespace URI to a class which will be used as the base for the SchemaBinding.

Parameters:
nsUri - the namespace URI
clazz - class to build the SchemaBinding from

mapURIToClasses

public void mapURIToClasses(String nsUri,
                            String... reference)
                     throws ClassNotFoundException
Description copied from interface: MutableSchemaResolver
Maps a namespace URI to an array of classes that will be used as the base for the SchemaBinding.

Specified by:
mapURIToClasses in interface MutableSchemaResolver
Overrides:
mapURIToClasses in class AbstractMutableSchemaResolver
Parameters:
nsUri - the namespace URI
reference - array of fully qualified class names to build the SchemaBinding from
Throws:
ClassNotFoundException - if at least one of the references cannot be loaded

mapURIToClasses

public void mapURIToClasses(String nsUri,
                            Class<?>... clazz)
Description copied from interface: MutableSchemaResolver
Maps a namespace URI to an array of classes that will be used as the base for the SchemaBinding.

Parameters:
nsUri - the namespace URI

removeLocationToClassMapping

public Class<?>[] removeLocationToClassMapping(String schemaLocation)
Description copied from interface: MutableSchemaResolver
Removes schema location to class mapping.

Parameters:
schemaLocation - the schema location
Returns:
the array of classes used to build the SchemaBinding or null, if the schema location wasn't mapped.

removeURIToClassMapping

public Class<?>[] removeURIToClassMapping(String nsUri)
Description copied from interface: MutableSchemaResolver
Removes namespace URI to class mapping

Parameters:
nsUri - the namespace URI to unmap
Returns:
classes mapped to the namespace URI or null if the URI was not mapped.


Copyright © 2011 JBoss, a division of Red Hat, Inc.. All Rights Reserved.