aboutsummaryrefslogtreecommitdiff
path: root/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/util/MOASPSSEntityResolver.java
diff options
context:
space:
mode:
Diffstat (limited to 'moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/util/MOASPSSEntityResolver.java')
-rw-r--r--moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/util/MOASPSSEntityResolver.java64
1 files changed, 33 insertions, 31 deletions
diff --git a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/util/MOASPSSEntityResolver.java b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/util/MOASPSSEntityResolver.java
index ee6fe0a..047c2bf 100644
--- a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/util/MOASPSSEntityResolver.java
+++ b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/util/MOASPSSEntityResolver.java
@@ -36,20 +36,21 @@ import at.gv.egovernment.moaspss.logging.LogMsg;
import at.gv.egovernment.moaspss.logging.Logger;
import at.gv.egovernment.moaspss.util.Constants;
-
/**
- * An <code>EntityResolver</code> that looks up entities stored as
- * local resources.
- *
- * <p>The following DTDs are mapped to local resources:
+ * 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,
+ * <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
*/
@@ -57,65 +58,66 @@ public class MOASPSSEntityResolver 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
+ * 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)
+ * <code>null</code>, if the entity could not be found.
+ * @see org.xml.sax.EntityResolver#resolveEntity(java.lang.String,
+ * java.lang.String)
*/
+ @Override
public InputSource resolveEntity(String publicId, String systemId) throws SAXException {
InputStream stream;
int slashPos;
-
+
if (Logger.isDebugEnabled()) {
Logger.debug(
- new LogMsg("resolveEntity: p=" + publicId + " s=" + systemId));
+ 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"));
+ getClass().getResourceAsStream(
+ Constants.SCHEMA_ROOT + "XMLSchema.dtd"));
} else if (publicId.equalsIgnoreCase("datatypes")) {
return new InputSource(
- getClass().getResourceAsStream(
- Constants.SCHEMA_ROOT + "datatypes.dtd"));
+ getClass().getResourceAsStream(
+ Constants.SCHEMA_ROOT + "datatypes.dtd"));
}
} else if (systemId != null) {
// get the URI path
try {
- URI uri = new URI(systemId);
+ final URI uri = new URI(systemId);
systemId = uri.getPath();
-
+
if ("".equals(systemId.trim())) {
return null;
}
-
+
// if (!"file".equals(uri.getScheme()) || "".equals(systemId.trim())) {
// return null;
// }
ExternalURIVerifier.verify(uri.getHost(), uri.getPort());
-
- } catch (MalformedURIException e) {
+
+ } catch (final MalformedURIException e) {
return null;
- }
- catch (MOAApplicationException e) {
- throw new SAXException(e);
+ } catch (final MOAApplicationException e) {
+ throw new SAXException(e);
}
-
+
// try to get the resource from the full path
stream = getClass().getResourceAsStream(systemId);
if (stream != null) {
- InputSource source = new InputSource(stream);
+ final InputSource source = new InputSource(stream);
source.setSystemId(systemId);
return source;
@@ -126,9 +128,9 @@ public class MOASPSSEntityResolver implements EntityResolver {
if (slashPos >= 0 && systemId.length() > slashPos) {
systemId = systemId.substring(slashPos + 1, systemId.length());
stream =
- getClass().getResourceAsStream(Constants.SCHEMA_ROOT + systemId);
+ getClass().getResourceAsStream(Constants.SCHEMA_ROOT + systemId);
if (stream != null) {
- InputSource source = new InputSource(stream);
+ final InputSource source = new InputSource(stream);
source.setSystemId(systemId);
return source;