org.jboss.util.xml
Class JBossEntityResolver

java.lang.Object
  extended by org.jboss.util.xml.JBossEntityResolver
All Implemented Interfaces:
EntityResolver

public class JBossEntityResolver
extends Object
implements EntityResolver

Local entity resolver to handle standard J2EE DTDs and Schemas as well as JBoss specific DTDs.

Function boolean isEntityResolved() is here to avoid validation errors in descriptors that do not have a DOCTYPE declaration.

Version:
$Revision: 1.6.2.23 $
Author:
Scott.Stark@jboss.org, Thomas.Diesler@jboss.org

Constructor Summary
JBossEntityResolver()
           
 
Method Summary
static Map getEntityMap()
          Obtain a read-only view of the current entity map.
 boolean isEntityResolved()
          Returns the boolean value to inform id DTD was found in the XML file or not
static boolean isWarnOnNonFileURLs()
           
static void registerEntity(String id, String dtdFileName)
          Register the mapping from the public id/system id to the dtd/xsd file name.
 void registerLocalEntity(String id, String dtdOrSchema)
          Register the mapping from the public id/system id to the dtd/xsd file name.
 InputSource resolveEntity(String publicId, String systemId)
          Returns DTD/Schema inputSource.
static void setWarnOnNonFileURLs(boolean warnOnNonFileURLs)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JBossEntityResolver

public JBossEntityResolver()
Method Detail

getEntityMap

public static Map getEntityMap()
Obtain a read-only view of the current entity map.

Returns:
Map of the publicID/systemID to dtd/schema file name

isWarnOnNonFileURLs

public static boolean isWarnOnNonFileURLs()

setWarnOnNonFileURLs

public static void setWarnOnNonFileURLs(boolean warnOnNonFileURLs)

registerEntity

public static void registerEntity(String id,
                                  String dtdFileName)
Register the mapping from the public id/system id to the dtd/xsd file name. This overwrites any existing mapping.

Parameters:
id - the DOCTYPE public id or system id such as "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN"
dtdFileName - the simple dtd/xsd file name, "ejb-jar.dtd"

registerLocalEntity

public void registerLocalEntity(String id,
                                String dtdOrSchema)
Register the mapping from the public id/system id to the dtd/xsd file name. This overwrites any existing mapping.

Parameters:
id - the DOCTYPE public id or system id such as "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN"
dtdOrSchema - the simple dtd/xsd file name, "ejb-jar.dtd"

resolveEntity

public InputSource resolveEntity(String publicId,
                                 String systemId)
                          throws SAXException,
                                 IOException
Returns DTD/Schema inputSource. The resolution logic is: 1. Check the publicId against the current registered values in the class mapping of entity name to dtd/schema file name. If found, the resulting file name is passed to the loadClasspathResource to locate the file as a classpath resource. 2. Check the systemId against the current registered values in the class mapping of entity name to dtd/schema file name. If found, the resulting file name is passed to the loadClasspathResource to locate the file as a classpath resource. 3. Strip the systemId name down to the simple file name by removing an URL style path elements (myschemas/x.dtd becomes x.dtd), and call loadClasspathResource to locate the simple file name as a classpath resource. 4. Attempt to resolve the systemId as a URL from which the schema can be read. If the URL input stream can be opened this returned as the resolved input.

Specified by:
resolveEntity in interface EntityResolver
Parameters:
publicId - - Public ID of DTD, or null if it is a schema
systemId - - the system ID of DTD or Schema
Returns:
InputSource of entity
Throws:
SAXException
IOException

isEntityResolved

public boolean isEntityResolved()
Returns the boolean value to inform id DTD was found in the XML file or not

Returns:
boolean - true if DTD was found in XML


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