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

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

public class DefaultSchemaResolver
extends Object
implements SchemaBindingResolver

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

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

Constructor Summary
DefaultSchemaResolver()
           
DefaultSchemaResolver(JBossEntityResolver resolver)
           
 
Method Summary
 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.
 String getBaseURI()
           
 boolean isCacheResolvedSchemas()
           
 SchemaBindingInitializer removeSchemaInitializer(String nsUri)
          Unregisters and returns the SchemaBindingInitializer for the namespace URI.
 void removeSchemaLocation(String nsUri)
          Removes a location for the namespace URI.
 Boolean removeSchemaParseAnnotations(String nsUri)
          Removes the parse annotation configuration for this namespace
 SchemaBinding resolve(String nsURI, String baseURI, String schemaLocation)
          Uses the JBossEntityResolver.resolveEntity by: 1.
 org.w3c.dom.ls.LSInput resolveAsLSInput(String nsURI, String baseURI, String schemaLocation)
          This one is used to resolve imported schemas with
 void setBaseURI(String baseURI)
           
 void setCacheResolvedSchemas(boolean cacheResolvedSchemas)
          Passing in true will make the schema resolver to cache successfully resolved schemas (which is the default) with namespace URI being the identifier of a schema.
 
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(JBossEntityResolver resolver)
Method Detail

isCacheResolvedSchemas

public boolean isCacheResolvedSchemas()
Returns:
true if resolved SchemaBinding's are cached, false otherwise

setCacheResolvedSchemas

public void setCacheResolvedSchemas(boolean cacheResolvedSchemas)
Passing in true will make the schema resolver to cache successfully resolved schemas (which is the default) with namespace URI being the identifier of a schema. False will flush the cache and make the schema resolver to resolve schemas on each request.

Parameters:
cacheResolvedSchemas -

addSchemaLocation

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

This location is looked using the JBossEntityResolver, i.e. it is a classpath location

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

removeSchemaLocation

public void removeSchemaLocation(String nsUri)
Removes a location for the namespace URI.

Parameters:
nsUri - the namespace location

addSchemaParseAnnotations

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

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

removeSchemaParseAnnotations

public Boolean removeSchemaParseAnnotations(String nsUri)
Removes the parse annotation configuration for this namespace

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.

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.

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

removeSchemaInitializer

public SchemaBindingInitializer removeSchemaInitializer(String nsUri)
Unregisters and returns the SchemaBindingInitializer for the namespace URI.

Parameters:
nsUri - the namespace URI to unregister SchemaBindingInitializer for
Returns:
unregistered SchemaBindingInitializer for the namespace URI or null if there was no SchemaBindingInitialzer registered for the namespace URI

getBaseURI

public String getBaseURI()
Specified by:
getBaseURI in interface SchemaBindingResolver

setBaseURI

public void setBaseURI(String baseURI)
Specified by:
setBaseURI in interface SchemaBindingResolver

resolve

public SchemaBinding resolve(String nsURI,
                             String baseURI,
                             String schemaLocation)
Uses the JBossEntityResolver.resolveEntity by: 1. Using the nsUri as the systemID 2. Using the schemaLocation as the systemID 3. If that fails, the baseURI is not null, the xsd is located using URL(baseURL, schemaLocation) 4. If the baseURI is null, the xsd is located using URL(schemaLocation)

Specified by:
resolve in interface SchemaBindingResolver
Parameters:
nsURI - - namespace URI of the element with the schema reference
baseURI - - an optional baseURI for resolving the schemaLocation.
schemaLocation - - the option schema location uri that matches nsUri if one exists
Returns:
an instance of SchemaBinding correspnding to the namespace URI or null if the namespace URI is not recognized (though, in this case it could also throw an exception)

resolveAsLSInput

public org.w3c.dom.ls.LSInput resolveAsLSInput(String nsURI,
                                               String baseURI,
                                               String schemaLocation)
Description copied from interface: SchemaBindingResolver
This one is used to resolve imported schemas with

Specified by:
resolveAsLSInput in interface SchemaBindingResolver
Returns:
LIInput for the resolved namespace schema if found, null otherwise


Copyright © 2002 JBoss Group, LLC. All Rights Reserved.