aboutsummaryrefslogtreecommitdiff
path: root/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/StreamEntityResolver.java
diff options
context:
space:
mode:
Diffstat (limited to 'moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/StreamEntityResolver.java')
-rw-r--r--moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/StreamEntityResolver.java47
1 files changed, 25 insertions, 22 deletions
diff --git a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/StreamEntityResolver.java b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/StreamEntityResolver.java
index 5d328cf..06efdda 100644
--- a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/StreamEntityResolver.java
+++ b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/StreamEntityResolver.java
@@ -21,7 +21,6 @@
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
-
package at.gv.egovernment.moaspss.util;
import java.io.IOException;
@@ -33,23 +32,26 @@ import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
/**
- * An <code>EntityResolver</code> that maps system IDs to
+ * An <code>EntityResolver</code> that maps system IDs to
* <code>InputStream</code>s.
- *
+ *
* @author Patrick Peck
* @version $Id$
*/
public class StreamEntityResolver implements EntityResolver {
-
- /** A mapping from Public ID or System ID to an <code>InputStream</code>
- * containing the entity. */
- private Map mappedEntities;
-
+
+ /**
+ * A mapping from Public ID or System ID to an <code>InputStream</code>
+ * containing the entity.
+ */
+ private final Map mappedEntities;
+
/**
* Create a <code>StreamEntityResolver</code>.
- *
- * @param mappedEntities A mapping from public or system IDs
- * (<code>String</code> objects) to <code>InputStream</code>s.
+ *
+ * @param mappedEntities A mapping from public or system IDs
+ * (<code>String</code> objects) to
+ * <code>InputStream</code>s.
*/
public StreamEntityResolver(Map mappedEntities) {
this.mappedEntities = mappedEntities;
@@ -57,32 +59,33 @@ public class StreamEntityResolver implements EntityResolver {
/**
* Resolve an entity by looking it up in the mapped entities.
- *
+ *
* First, the public ID is looked up in the mapping, then the system ID.
- *
+ *
* @param publicId The public ID of the entity.
* @param systemId The system ID of the entity.
- * @return An <code>InputStream</code> containing the entity or
- * <code>null</code> if no entity could be found.
+ * @return An <code>InputStream</code> containing the entity or
+ * <code>null</code> if no entity could be found.
* @throws SAXException Signalling a parsing exception.
- * @throws IOException Error reading the entity.
+ * @throws IOException Error reading the entity.
*/
- public InputSource resolveEntity(String publicId, String systemId)
- throws SAXException, IOException {
-
+ @Override
+ public InputSource resolveEntity(String publicId, String systemId)
+ throws SAXException, IOException {
+
InputSource src = null;
-
+
if (publicId != null && mappedEntities.get(publicId) != null) {
src = new InputSource((InputStream) mappedEntities.get(publicId));
} else if (systemId != null && mappedEntities.get(systemId) != null) {
src = new InputSource((InputStream) mappedEntities.get(systemId));
}
-
+
if (src != null) {
src.setPublicId(publicId);
src.setSystemId(systemId);
}
-
+
return src;
}
}