diff options
author | mcentner <mcentner@d688527b-c9ab-4aba-bd8d-4036d912da1d> | 2007-08-08 07:25:32 +0000 |
---|---|---|
committer | mcentner <mcentner@d688527b-c9ab-4aba-bd8d-4036d912da1d> | 2007-08-08 07:25:32 +0000 |
commit | 43e57a42832ea8b4ceb0317f3c9028a4174ffa7b (patch) | |
tree | f5ed9074b8d7b89b2dd5b22d326f63be103e7551 /common/src/at/gv/egovernment/moa/util/MOAEntityResolver.java | |
parent | 10889e9dea2cc2f70b475e6ff7af37fdba1621d9 (diff) | |
download | moa-id-spss-43e57a42832ea8b4ceb0317f3c9028a4174ffa7b.tar.gz moa-id-spss-43e57a42832ea8b4ceb0317f3c9028a4174ffa7b.tar.bz2 moa-id-spss-43e57a42832ea8b4ceb0317f3c9028a4174ffa7b.zip |
Adapted project directory structure to suit the new maven based build process.
git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@909 d688527b-c9ab-4aba-bd8d-4036d912da1d
Diffstat (limited to 'common/src/at/gv/egovernment/moa/util/MOAEntityResolver.java')
-rw-r--r-- | common/src/at/gv/egovernment/moa/util/MOAEntityResolver.java | 103 |
1 files changed, 0 insertions, 103 deletions
diff --git a/common/src/at/gv/egovernment/moa/util/MOAEntityResolver.java b/common/src/at/gv/egovernment/moa/util/MOAEntityResolver.java deleted file mode 100644 index 9406612e2..000000000 --- a/common/src/at/gv/egovernment/moa/util/MOAEntityResolver.java +++ /dev/null @@ -1,103 +0,0 @@ -package at.gv.egovernment.moa.util; - -import java.io.InputStream; - -import org.apache.xerces.util.URI; -import org.apache.xerces.util.URI.MalformedURIException; -import org.xml.sax.EntityResolver; -import org.xml.sax.InputSource; - -import at.gv.egovernment.moa.logging.LogMsg; -import at.gv.egovernment.moa.logging.Logger; - -/** - * An <code>EntityResolver</code> that looks up entities stored as - * local resources. - * - * <p>The following DTDs are mapped to local resources: - * <ul> - * <li>The XMLSchema.dtd</li> - * <li>The datatypes.dtd</li> - * </ul> - * </p> - * <p>For all other resources, an attempt is made to resolve them as resources, - * either absolute or relative to <code>Constants.SCHEMA_ROOT</code>. - * - * @author Patrick Peck - * @author Sven Aigner - */ -public class MOAEntityResolver implements EntityResolver { - - /** - * Resolve an entity. - * - * The <code>systemId</code> parameter is used to perform the lookup of the - * entity as a resource, either by interpreting the <code>systemId</code> as - * an absolute resource path, or by appending the last path component of - * <code>systemId</code> to <code>Constants.SCHEMA_ROOT</code>. - * - * @param publicId The public ID of the resource. - * @param systemId The system ID of the resource. - * @return An <code>InputSource</code> from which the entity can be read, or - * <code>null</code>, if the entity could not be found. - * @see org.xml.sax.EntityResolver#resolveEntity(java.lang.String, java.lang.String) - */ - public InputSource resolveEntity(String publicId, String systemId) { - InputStream stream; - int slashPos; - - if (Logger.isDebugEnabled()) { - Logger.debug( - new LogMsg("resolveEntity: p=" + publicId + " s=" + systemId)); - } - - if (publicId != null) { - // check if we can resolve some standard dtd's - if (publicId.equalsIgnoreCase("-//W3C//DTD XMLSchema 200102//EN")) { - return new InputSource( - getClass().getResourceAsStream( - Constants.SCHEMA_ROOT + "XMLSchema.dtd")); - } else if (publicId.equalsIgnoreCase("datatypes")) { - return new InputSource( - getClass().getResourceAsStream( - Constants.SCHEMA_ROOT + "datatypes.dtd")); - } - } else if (systemId != null) { - // get the URI path - try { - URI uri = new URI(systemId); - systemId = uri.getPath(); - if (!"file".equals(uri.getScheme()) || "".equals(systemId.trim())) { - return null; - } - } catch (MalformedURIException e) { - return null; - } - - // try to get the resource from the full path - stream = getClass().getResourceAsStream(systemId); - if (stream != null) { - InputSource source = new InputSource(stream); - - source.setSystemId(systemId); - return source; - } - - // try to get the resource from the last path component - slashPos = systemId.lastIndexOf('/'); - if (slashPos >= 0 && systemId.length() > slashPos) { - systemId = systemId.substring(slashPos + 1, systemId.length()); - stream = - getClass().getResourceAsStream(Constants.SCHEMA_ROOT + systemId); - if (stream != null) { - InputSource source = new InputSource(stream); - - source.setSystemId(systemId); - return source; - } - } - } - - return null; // nothing found - let the parser handle the entity - } -}
\ No newline at end of file |