diff options
author | Thomas Lenz <thomas.lenz@egiz.gv.at> | 2021-03-24 11:08:57 +0000 |
---|---|---|
committer | Thomas Lenz <thomas.lenz@egiz.gv.at> | 2021-03-24 11:08:57 +0000 |
commit | 666d8c9f8cec7573e60a14ab039c0874f6a9ec53 (patch) | |
tree | d9b2506506cf544ea3758322fd5488c913073427 /moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/StreamEntityResolver.java | |
parent | d003a873fdeec22b1dd57d61590a12a1691ae137 (diff) | |
parent | cd65b47cc30e7119593bbb05afa48d4f896a4859 (diff) | |
download | moa-sig-666d8c9f8cec7573e60a14ab039c0874f6a9ec53.tar.gz moa-sig-666d8c9f8cec7573e60a14ab039c0874f6a9ec53.tar.bz2 moa-sig-666d8c9f8cec7573e60a14ab039c0874f6a9ec53.zip |
Merge branch 'feature/codestyle_and_gitlab_ci' into 'master'
Feature/codestyle and gitlab ci
See merge request egiz/moa-sig!1
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.java | 47 |
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; } } |