From 7a056ec4aae9fd644245063f1aeaa4d296e76da1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=CC=88rg=20Prante?= Date: Tue, 8 Nov 2016 21:14:24 +0100 Subject: [PATCH] sonarqube fixes, set RouteHandler interface to public --- build.gradle | 2 +- .../java/org/xbib/content/ToXContent.java | 19 +++-- .../org/xbib/content/settings/Settings.java | 55 ++++++------ .../xbib/content/util/geo/GeoHashUtils.java | 10 +-- .../org/xbib/content/util/geo/GeoPoint.java | 1 + .../content/json/diff/DiffFactorizer.java | 6 +- .../org/xbib/content/json/diff/JsonDiff.java | 3 +- .../json/diff/LeastCommonSubsequence.java | 3 +- .../xbib/content/json/jackson/NodeType.java | 4 +- .../xbib/content/json/jackson/Wrapper.java | 6 +- .../content/json/patch/DualPathOperation.java | 6 +- .../json/patch/PathValueOperation.java | 3 +- .../java/org/xbib/content/language/Lang.java | 6 +- .../java/org/xbib/content/language/Range.java | 7 +- .../org/xbib/content/language/Subtag.java | 4 + .../org/xbib/content/language/SubtagSet.java | 3 + .../main/java/org/xbib/content/rdf/RDF.java | 16 ++-- .../xbib/content/rdf/RdfContentFactory.java | 5 +- .../xbib/content/rdf/RouteRdfXContent.java | 2 +- .../content/rdf/internal/DefaultRdfGraph.java | 3 +- .../content/rdf/internal/DefaultResource.java | 18 ++-- .../io/ntriple/NTripleContentGenerator.java | 1 - .../rdf/io/rdfxml/RdfXmlContentParser.java | 85 ++++++++++--------- .../rdf/io/xml/XmlContentGenerator.java | 1 + .../content/rdf/util/LinkedHashMultiMap.java | 9 +- .../xbib/content/rdf/util/package-info.java | 4 + .../java/org/xbib/content/resource/IRI.java | 16 ++-- .../content/resource/IRINamespaceContext.java | 2 +- .../content/resource/XmlNamespaceContext.java | 1 + .../resource/scheme/SchemeRegistry.java | 2 +- .../text/InvalidCharacterException.java | 2 +- .../content/resource/url/UrlEncoding.java | 18 ++-- .../xbib/content/xml/XmlXContentHelper.java | 3 + .../xbib/content/xml/XmlXContentParser.java | 4 + .../xbib/content/xml/json/JsonStaxReader.java | 2 +- .../xml/json/events/JsonReaderXmlEvent.java | 2 +- .../xml/stream/AbstractCharactersEvent.java | 6 +- .../stream/AbstractStaxContentHandler.java | 2 +- .../content/xml/stream/AbstractXMLEvent.java | 4 - .../content/xml/stream/SaxEventConsumer.java | 8 ++ .../xml/stream/StaxEventContentHandler.java | 5 +- .../xbib/content/xml/stream/StaxSource.java | 4 +- .../xml/stream/StaxStreamContentHandler.java | 2 + .../xml/stream/StreamWriterDelegate.java | 2 +- .../content/xml/stream/XMLFilterImplEx.java | 2 +- .../XMLStreamReaderToContentHandler.java | 9 ++ .../xml/transform/ContentTypeListener.java | 12 --- .../xml/transform/StylesheetTransformer.java | 2 +- .../org/xbib/content/xml/util/ISO9075.java | 2 +- .../org/xbib/content/xml/util/ToQName.java | 3 + 50 files changed, 212 insertions(+), 185 deletions(-) create mode 100644 content-rdf/src/main/java/org/xbib/content/rdf/util/package-info.java delete mode 100644 content-xml/src/main/java/org/xbib/content/xml/transform/ContentTypeListener.java diff --git a/build.gradle b/build.gradle index 4c8f67a..c25da96 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,7 @@ ext { allprojects { group = 'org.xbib' - version = '1.0.2' + version = '1.0.3' apply plugin: 'java' apply plugin: 'maven' diff --git a/content-core/src/main/java/org/xbib/content/ToXContent.java b/content-core/src/main/java/org/xbib/content/ToXContent.java index 0e3e448..0f88e09 100644 --- a/content-core/src/main/java/org/xbib/content/ToXContent.java +++ b/content-core/src/main/java/org/xbib/content/ToXContent.java @@ -10,15 +10,6 @@ public interface ToXContent { XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException; - /** - * - */ - interface Params { - String param(String key); - - String param(String key, String defaultValue); - - } Params EMPTY_PARAMS = new Params() { @@ -33,4 +24,14 @@ public interface ToXContent { } }; + + /** + * + */ + interface Params { + String param(String key); + + String param(String key, String defaultValue); + + } } diff --git a/content-core/src/main/java/org/xbib/content/settings/Settings.java b/content-core/src/main/java/org/xbib/content/settings/Settings.java index d477a71..fd1b080 100644 --- a/content-core/src/main/java/org/xbib/content/settings/Settings.java +++ b/content-core/src/main/java/org/xbib/content/settings/Settings.java @@ -41,10 +41,10 @@ public class Settings { public static final Settings EMPTY_SETTINGS = new Builder().build(); public static final String[] EMPTY_ARRAY = new String[0]; public static final int BUFFER_SIZE = 1024 * 8; - private final Map settings; + private final Map map; private Settings(Map settings) { - this.settings = new HashMap<>(settings); + this.map = new HashMap<>(settings); } public static Settings readSettingsFromMap(Map map) throws IOException { @@ -131,27 +131,27 @@ public class Settings { } public Map getAsMap() { - return this.settings; + return this.map; } public Map getAsStructuredMap() { - Map map = new HashMap<>(2); - for (Map.Entry entry : settings.entrySet()) { - processSetting(map, "", entry.getKey(), entry.getValue()); + Map stringObjectMap = new HashMap<>(2); + for (Map.Entry entry : this.map.entrySet()) { + processSetting(stringObjectMap, "", entry.getKey(), entry.getValue()); } - for (Map.Entry entry : map.entrySet()) { + for (Map.Entry entry : stringObjectMap.entrySet()) { if (entry.getValue() instanceof Map) { @SuppressWarnings("unchecked") Map valMap = (Map) entry.getValue(); entry.setValue(convertMapsToArrays(valMap)); } } - return map; + return stringObjectMap; } public Settings getByPrefix(String prefix) { Builder builder = new Builder(); - for (Map.Entry entry : settings.entrySet()) { + for (Map.Entry entry : map.entrySet()) { if (entry.getKey().startsWith(prefix)) { if (entry.getKey().length() < prefix.length()) { continue; @@ -167,10 +167,10 @@ public class Settings { } public boolean containsSetting(String setting) { - if (settings.containsKey(setting)) { + if (map.containsKey(setting)) { return true; } - for (Map.Entry entry : settings.entrySet()) { + for (Map.Entry entry : map.entrySet()) { if (entry.getKey().startsWith(setting)) { return true; } @@ -179,7 +179,7 @@ public class Settings { } public String get(String setting) { - String retVal = settings.get(setting); + String retVal = map.get(setting); if (retVal != null) { return retVal; } @@ -187,7 +187,7 @@ public class Settings { } public String get(String setting, String defaultValue) { - String retVal = settings.get(setting); + String retVal = map.get(setting); return retVal == null ? defaultValue : retVal; } @@ -251,15 +251,15 @@ public class Settings { return parseTimeValue(get(setting), defaultValue); } - public ByteSizeValue getAsBytesSize(String setting, ByteSizeValue defaultValue) throws SettingsException { + public ByteSizeValue getAsBytesSize(String setting, ByteSizeValue defaultValue) { return parseBytesSizeValue(get(setting), defaultValue); } - public String[] getAsArray(String settingPrefix) throws SettingsException { + public String[] getAsArray(String settingPrefix) { return getAsArray(settingPrefix, EMPTY_ARRAY); } - public String[] getAsArray(String settingPrefix, String[] defaultArray) throws SettingsException { + public String[] getAsArray(String settingPrefix, String[] defaultArray) { List result = new ArrayList<>(); if (get(settingPrefix) != null) { String[] strings = splitStringByCommaToArray(get(settingPrefix)); @@ -283,14 +283,14 @@ public class Settings { return result.toArray(new String[result.size()]); } - public Map getGroups(String prefix) throws SettingsException { + public Map getGroups(String prefix) { String settingPrefix = prefix; if (settingPrefix.charAt(settingPrefix.length() - 1) != '.') { settingPrefix = settingPrefix + "."; } // we don't really care that it might happen twice - Map> map = new LinkedHashMap<>(); - for (Object o : settings.keySet()) { + Map> hashMap = new LinkedHashMap<>(); + for (Object o : this.map.keySet()) { String setting = (String) o; if (setting.startsWith(settingPrefix)) { String nameValue = setting.substring(settingPrefix.length()); @@ -302,16 +302,16 @@ public class Settings { } String name = nameValue.substring(0, dotIndex); String value = nameValue.substring(dotIndex + 1); - Map groupSettings = map.get(name); + Map groupSettings = hashMap.get(name); if (groupSettings == null) { groupSettings = new LinkedHashMap<>(); - map.put(name, groupSettings); + hashMap.put(name, groupSettings); } groupSettings.put(value, get(setting)); } } Map retVal = new LinkedHashMap<>(); - for (Map.Entry> entry : map.entrySet()) { + for (Map.Entry> entry : hashMap.entrySet()) { retVal.put(entry.getKey(), new Settings(Collections.unmodifiableMap(entry.getValue()))); } return Collections.unmodifiableMap(retVal); @@ -319,19 +319,12 @@ public class Settings { @Override public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Settings that = (Settings) o; - return settings != null ? settings.equals(that.settings) : that.settings == null; + return this == o || !(o == null || getClass() != o.getClass()) && map.equals(((Settings) o).map); } @Override public int hashCode() { - return settings != null ? settings.hashCode() : 0; + return map.hashCode(); } private void processSetting(Map map, String prefix, String setting, String value) { diff --git a/content-core/src/main/java/org/xbib/content/util/geo/GeoHashUtils.java b/content-core/src/main/java/org/xbib/content/util/geo/GeoHashUtils.java index c95ae15..6bf2b13 100644 --- a/content-core/src/main/java/org/xbib/content/util/geo/GeoHashUtils.java +++ b/content-core/src/main/java/org/xbib/content/util/geo/GeoHashUtils.java @@ -2,7 +2,6 @@ package org.xbib.content.util.geo; import java.util.ArrayList; import java.util.Collection; -import java.util.Iterator; /** * Utilities for encoding and decoding geohashes. Based on @@ -81,7 +80,7 @@ public class GeoHashUtils { * @param geohash Geohash of the defined cell * @return geohashes of all neighbor cells */ - public static Collection neighbors(String geohash) { + public static Collection neighbors(String geohash) { return addNeighbors(geohash, geohash.length(), new ArrayList(8)); } @@ -93,12 +92,7 @@ public class GeoHashUtils { * @return {@link Iterable} of path */ public static Iterable path(final String geohash) { - return new Iterable() { - @Override - public Iterator iterator() { - return new GeohashPathIterator(geohash); - } - }; + return () -> new GeohashPathIterator(geohash); } /** diff --git a/content-core/src/main/java/org/xbib/content/util/geo/GeoPoint.java b/content-core/src/main/java/org/xbib/content/util/geo/GeoPoint.java index 755d4c8..69232b6 100644 --- a/content-core/src/main/java/org/xbib/content/util/geo/GeoPoint.java +++ b/content-core/src/main/java/org/xbib/content/util/geo/GeoPoint.java @@ -9,6 +9,7 @@ public final class GeoPoint { private double lon; public GeoPoint() { + this(0, 0); } /** diff --git a/content-json/src/main/java/org/xbib/content/json/diff/DiffFactorizer.java b/content-json/src/main/java/org/xbib/content/json/diff/DiffFactorizer.java index 34eb4cf..c1f494f 100644 --- a/content-json/src/main/java/org/xbib/content/json/diff/DiffFactorizer.java +++ b/content-json/src/main/java/org/xbib/content/json/diff/DiffFactorizer.java @@ -12,6 +12,9 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; +/** + * + */ final class DiffFactorizer { private static final Equivalence EQUIVALENCE = JsonNumEquals.getInstance(); @@ -91,7 +94,8 @@ final class DiffFactorizer { private static void findPairs(final List diffs) { final int diffsSize = diffs.size(); - Diff addition, removal; + Diff addition; + Diff removal; for (int addIndex = 0; addIndex < diffsSize; addIndex++) { addition = diffs.get(addIndex); diff --git a/content-json/src/main/java/org/xbib/content/json/diff/JsonDiff.java b/content-json/src/main/java/org/xbib/content/json/diff/JsonDiff.java index ffde854..39b3f50 100644 --- a/content-json/src/main/java/org/xbib/content/json/diff/JsonDiff.java +++ b/content-json/src/main/java/org/xbib/content/json/diff/JsonDiff.java @@ -358,7 +358,8 @@ public final class JsonDiff { */ private static void postLCS(final List diffs, final JsonPointer path, final IndexedJsonArray source, final IndexedJsonArray target) { - JsonNode src, dst; + JsonNode src; + JsonNode dst; while (!(source.isEmpty() || target.isEmpty())) { src = source.getElement(); diff --git a/content-json/src/main/java/org/xbib/content/json/diff/LeastCommonSubsequence.java b/content-json/src/main/java/org/xbib/content/json/diff/LeastCommonSubsequence.java index c6835c3..63d504d 100644 --- a/content-json/src/main/java/org/xbib/content/json/diff/LeastCommonSubsequence.java +++ b/content-json/src/main/java/org/xbib/content/json/diff/LeastCommonSubsequence.java @@ -103,7 +103,8 @@ final class LeastCommonSubsequence { } // return result out of the LCS lengths matrix - int x = size1, y = size2; + int x = size1; + int y = size2; while (x > 0 && y > 0) { if (lengths[x][y] == lengths[x - 1][y]) { x--; diff --git a/content-json/src/main/java/org/xbib/content/json/jackson/NodeType.java b/content-json/src/main/java/org/xbib/content/json/jackson/NodeType.java index 1d312bf..44a040a 100644 --- a/content-json/src/main/java/org/xbib/content/json/jackson/NodeType.java +++ b/content-json/src/main/java/org/xbib/content/json/jackson/NodeType.java @@ -48,13 +48,13 @@ public enum NodeType { * Reverse map to find a node type out of this type's name. */ private static final Map NAME_MAP - = new HashMap(); + = new HashMap<>(); /** * Mapping of {@link com.fasterxml.jackson.core.JsonToken} back to node types (used in {@link * #getNodeType(com.fasterxml.jackson.databind.JsonNode)}). */ private static final Map TOKEN_MAP - = new EnumMap(JsonToken.class); + = new EnumMap<>(JsonToken.class); static { TOKEN_MAP.put(JsonToken.START_ARRAY, ARRAY); diff --git a/content-json/src/main/java/org/xbib/content/json/jackson/Wrapper.java b/content-json/src/main/java/org/xbib/content/json/jackson/Wrapper.java index e2347ac..8690fcb 100644 --- a/content-json/src/main/java/org/xbib/content/json/jackson/Wrapper.java +++ b/content-json/src/main/java/org/xbib/content/json/jackson/Wrapper.java @@ -39,9 +39,9 @@ public final class Wrapper { * whatever type it is, it is assignable to the type handled by this wrapper's equivalence. */ @SuppressWarnings("unchecked") - Equivalence equivalence = (Equivalence) this.equivalence; - return equivalence.equals(that.equivalence) - && equivalence.equivalent(this.reference, that.reference); + Equivalence equiv = (Equivalence) this.equivalence; + return equiv.equals(that.equivalence) + && equiv.equivalent(this.reference, that.reference); } else { return false; } diff --git a/content-json/src/main/java/org/xbib/content/json/patch/DualPathOperation.java b/content-json/src/main/java/org/xbib/content/json/patch/DualPathOperation.java index 715302d..60af088 100644 --- a/content-json/src/main/java/org/xbib/content/json/patch/DualPathOperation.java +++ b/content-json/src/main/java/org/xbib/content/json/patch/DualPathOperation.java @@ -1,7 +1,6 @@ package org.xbib.content.json.patch; import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.jsontype.TypeSerializer; @@ -32,8 +31,7 @@ public abstract class DualPathOperation extends JsonPatchOperation { @Override public final void serialize(final JsonGenerator jgen, - final SerializerProvider provider) - throws IOException, JsonProcessingException { + final SerializerProvider provider) throws IOException { jgen.writeStartObject(); jgen.writeStringField("op", op); jgen.writeStringField("path", path.toString()); @@ -44,7 +42,7 @@ public abstract class DualPathOperation extends JsonPatchOperation { @Override public final void serializeWithType(final JsonGenerator jgen, final SerializerProvider provider, final TypeSerializer typeSer) - throws IOException, JsonProcessingException { + throws IOException { serialize(jgen, provider); } diff --git a/content-json/src/main/java/org/xbib/content/json/patch/PathValueOperation.java b/content-json/src/main/java/org/xbib/content/json/patch/PathValueOperation.java index ef5f40a..7e3090f 100644 --- a/content-json/src/main/java/org/xbib/content/json/patch/PathValueOperation.java +++ b/content-json/src/main/java/org/xbib/content/json/patch/PathValueOperation.java @@ -1,7 +1,6 @@ package org.xbib.content.json.patch; import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.annotation.JsonSerialize; @@ -46,7 +45,7 @@ public abstract class PathValueOperation @Override public final void serializeWithType(final JsonGenerator jgen, final SerializerProvider provider, final TypeSerializer typeSer) - throws IOException, JsonProcessingException { + throws IOException { serialize(jgen, provider); } diff --git a/content-language/src/main/java/org/xbib/content/language/Lang.java b/content-language/src/main/java/org/xbib/content/language/Lang.java index c0c11cf..9b21f05 100644 --- a/content-language/src/main/java/org/xbib/content/language/Lang.java +++ b/content-language/src/main/java/org/xbib/content/language/Lang.java @@ -70,7 +70,8 @@ public final class Lang extends SubtagSet { return parse(locale.toString()).primary; } catch (Exception e) { logger.log(Level.FINE, e.getMessage(), e); - Subtag c = null, primary = new Subtag(Type.PRIMARY, locale.getLanguage()); + Subtag c = null; + Subtag primary = new Subtag(Type.PRIMARY, locale.getLanguage()); String country = locale.getCountry(); String variant = locale.getVariant(); if (country != null) { @@ -344,7 +345,8 @@ public final class Lang extends SubtagSet { public Lang canonicalize() { Subtag primary = null; Subtag current; - int p = -1, t = -1; + int p = -1; + int t = -1; List tags = new LinkedList<>(); for (Subtag tag : this) { tags.add(tag); diff --git a/content-language/src/main/java/org/xbib/content/language/Range.java b/content-language/src/main/java/org/xbib/content/language/Range.java index 8b495e2..3b6a3d0 100644 --- a/content-language/src/main/java/org/xbib/content/language/Range.java +++ b/content-language/src/main/java/org/xbib/content/language/Range.java @@ -14,9 +14,9 @@ import java.util.regex.Pattern; */ public class Range extends SubtagSet { - private static final String RANGE = "((?:[a-zA-Z]{1,8}|\\*))((?:[-_](?:[a-zA-Z0-9]{1,8}|\\*))*)"; + private static final String RANGE_PATTERN = "((?:[a-zA-Z]{1,8}|\\*))((?:[-_](?:[a-zA-Z0-9]{1,8}|\\*))*)"; private static final String RANGE_COMPONENT = "[-_]((?:[a-zA-Z0-9]{1,8}|\\*))"; - private static final Pattern P_RANGE = Pattern.compile(RANGE); + private static final Pattern P_RANGE = Pattern.compile(RANGE_PATTERN); private static final Pattern P_RANGE_COMPONENT = Pattern.compile(RANGE_COMPONENT); private static final String LANGUAGE = "((?:[a-zA-Z]{2,3}(?:[-_](?:[a-zA-Z]{3}|\\*)){0,3})|[a-zA-Z]{4}|[a-zA-Z]{5,8}|\\*)"; @@ -309,7 +309,8 @@ public class Range extends SubtagSet { list.add(tag); } } - Subtag primary = null, current = null; + Subtag primary = null; + Subtag current = null; for (Subtag tag : list) { tag.setNext(null); tag.setPrevious(null); diff --git a/content-language/src/main/java/org/xbib/content/language/Subtag.java b/content-language/src/main/java/org/xbib/content/language/Subtag.java index 64240dc..539a170 100644 --- a/content-language/src/main/java/org/xbib/content/language/Subtag.java +++ b/content-language/src/main/java/org/xbib/content/language/Subtag.java @@ -173,6 +173,7 @@ public final class Subtag implements Comparable { } } + @Override public String toString() { switch (type) { case REGION: @@ -184,6 +185,7 @@ public final class Subtag implements Comparable { } } + @Override public int hashCode() { final int prime = 31; int result = 1; @@ -192,6 +194,7 @@ public final class Subtag implements Comparable { return result; } + @Override public boolean equals(Object obj) { if (this == obj) { return true; @@ -345,6 +348,7 @@ public final class Subtag implements Comparable { } } + @Override public int compareTo(Subtag o) { int c = o.type.compareTo(type); return c != 0 ? c : o.name.compareTo(name); diff --git a/content-language/src/main/java/org/xbib/content/language/SubtagSet.java b/content-language/src/main/java/org/xbib/content/language/SubtagSet.java index 213b592..ca52079 100644 --- a/content-language/src/main/java/org/xbib/content/language/SubtagSet.java +++ b/content-language/src/main/java/org/xbib/content/language/SubtagSet.java @@ -6,6 +6,9 @@ import java.util.LinkedList; import java.util.List; import java.util.NoSuchElementException; +/** + * + */ abstract class SubtagSet implements Cloneable, Iterable, Comparable { protected final Subtag primary; diff --git a/content-rdf/src/main/java/org/xbib/content/rdf/RDF.java b/content-rdf/src/main/java/org/xbib/content/rdf/RDF.java index e02a060..8eab784 100644 --- a/content-rdf/src/main/java/org/xbib/content/rdf/RDF.java +++ b/content-rdf/src/main/java/org/xbib/content/rdf/RDF.java @@ -8,24 +8,24 @@ public interface RDF { String NS = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"; String BNODE_PREFIX = "_:"; String SHORTENABLE_BNODE_SUFFIX = "sbl"; - String PROPERTY = NS + "Property"; + String PROPERTY_ELEMENT = NS + "Property"; String XML_LITERAL = NS + "XMLLiteral"; String TYPE = NS + "type"; String VALUE = NS + "value"; - String ALT = NS + "Alt"; - String BAG = NS + "Bag"; - String SEQ = NS + "Seq"; - String LIST = NS + "List"; + String ALT_ELEMENT = NS + "Alt"; + String BAG_ELEMENT = NS + "Bag"; + String SEQ_ELEMENT = NS + "Seq"; + String LIST_ELEMENT = NS + "List"; String FIRST = NS + "first"; String NIL = NS + "nil"; String REST = NS + "rest"; - String STATEMENT = NS + "Statement"; + String STATEMENT_ELEMENT = NS + "Statement"; String OBJECT = NS + "object"; String PREDICATE = NS + "predicate"; String SUBJECT = NS + "subject"; - String DESCRIPTION = NS + "Description"; + String DESCRIPTION_ELEMENT = NS + "Description"; String ID = NS + "ID"; - String RDF = NS + "RDF"; + String RDF_ELEMENT = NS + "RDF"; String ABOUT = NS + "about"; String DATATYPE = NS + "datatype"; String LI = NS + "li"; diff --git a/content-rdf/src/main/java/org/xbib/content/rdf/RdfContentFactory.java b/content-rdf/src/main/java/org/xbib/content/rdf/RdfContentFactory.java index d4675a3..453f36d 100644 --- a/content-rdf/src/main/java/org/xbib/content/rdf/RdfContentFactory.java +++ b/content-rdf/src/main/java/org/xbib/content/rdf/RdfContentFactory.java @@ -19,6 +19,9 @@ import java.io.OutputStream; */ public class RdfContentFactory { + private RdfContentFactory() { + } + public static RdfContentBuilder ntripleBuilder() throws IOException { return NTripleContent.contentBuilder(NTripleContentParams.N_TRIPLE_CONTENT_PARAMS); } @@ -67,7 +70,7 @@ public class RdfContentFactory { public static RdfContentBuilder turtleBuilder(OutputStream out, TurtleContentParams params) throws IOException { - return TurtleContent.contentBuilder(out, TurtleContentParams.TURTLE_CONTENT_PARAMS); + return TurtleContent.contentBuilder(out, params); } public static RdfContentBuilder xmlBuilder() throws IOException { diff --git a/content-rdf/src/main/java/org/xbib/content/rdf/RouteRdfXContent.java b/content-rdf/src/main/java/org/xbib/content/rdf/RouteRdfXContent.java index afa2b93..ea17b4f 100644 --- a/content-rdf/src/main/java/org/xbib/content/rdf/RouteRdfXContent.java +++ b/content-rdf/src/main/java/org/xbib/content/rdf/RouteRdfXContent.java @@ -41,7 +41,7 @@ public class RouteRdfXContent implements RdfContent { * */ @FunctionalInterface - interface RouteHandler { + public interface RouteHandler { void complete(String content, RouteRdfXContentParams params) throws IOException; } } diff --git a/content-rdf/src/main/java/org/xbib/content/rdf/internal/DefaultRdfGraph.java b/content-rdf/src/main/java/org/xbib/content/rdf/internal/DefaultRdfGraph.java index cc85fa1..9aff712 100644 --- a/content-rdf/src/main/java/org/xbib/content/rdf/internal/DefaultRdfGraph.java +++ b/content-rdf/src/main/java/org/xbib/content/rdf/internal/DefaultRdfGraph.java @@ -124,7 +124,7 @@ public class DefaultRdfGraph implements RdfGraph { // nothing to do here } - private Resource expand(Resource resource) { + public Resource expand(Resource resource) { Resource expanded = new DefaultResource(resource.id()); new GraphTriples(resource).triples.forEach(expanded::add); return expanded; @@ -166,5 +166,4 @@ public class DefaultRdfGraph implements RdfGraph { } } - } diff --git a/content-rdf/src/main/java/org/xbib/content/rdf/internal/DefaultResource.java b/content-rdf/src/main/java/org/xbib/content/rdf/internal/DefaultResource.java index e6b4dbb..708884a 100644 --- a/content-rdf/src/main/java/org/xbib/content/rdf/internal/DefaultResource.java +++ b/content-rdf/src/main/java/org/xbib/content/rdf/internal/DefaultResource.java @@ -5,11 +5,11 @@ import org.xbib.content.rdf.RdfConstants; import org.xbib.content.rdf.Resource; import org.xbib.content.rdf.Triple; import org.xbib.content.rdf.XSDResourceIdentifiers; +import org.xbib.content.rdf.util.LinkedHashMultiMap; +import org.xbib.content.rdf.util.MultiMap; import org.xbib.content.resource.IRI; import org.xbib.content.resource.IRINamespaceContext; import org.xbib.content.resource.Node; -import org.xbib.content.rdf.util.LinkedHashMultiMap; -import org.xbib.content.rdf.util.MultiMap; import java.io.IOException; import java.util.ArrayList; @@ -231,7 +231,7 @@ public class DefaultResource implements Resource, Comparable, XSDResou if (object instanceof Map) { add(predicate, (Map) object); } else if (object instanceof List) { - add(predicate, ((List) object)); + add(predicate, (List) object); } else if (object instanceof Resource) { add(predicate, (Resource) object); } else { @@ -251,7 +251,7 @@ public class DefaultResource implements Resource, Comparable, XSDResou if (obj instanceof Map) { r.add(newPredicate(pred), (Map) obj); } else if (obj instanceof List) { - r.add(newPredicate(pred), ((List) obj)); + r.add(newPredicate(pred), (List) obj); } else if (obj instanceof Resource) { r.add(newPredicate(pred), (Resource) obj); } else { @@ -311,7 +311,7 @@ public class DefaultResource implements Resource, Comparable, XSDResou Resource r = newResource(newPredicate(pred)); r.add((Map) obj); } else if (obj instanceof List) { - add(newPredicate(pred), ((List) obj)); + add(newPredicate(pred), (List) obj); } else if (obj instanceof Resource) { add(newPredicate(pred), (Resource) obj); } else { @@ -520,22 +520,22 @@ public class DefaultResource implements Resource, Comparable, XSDResou private static class Triples { - private final List triples; + private final List tripleList; private final boolean recursive; Triples(Resource resource, boolean recursive) { this.recursive = recursive; - this.triples = unfold(resource); + this.tripleList = unfold(resource); } Triples(Resource resource, IRI predicate, Literal literal) { this.recursive = true; - this.triples = find(resource, predicate, literal); + this.tripleList = find(resource, predicate, literal); } List list() { - return triples; + return tripleList; } private List unfold(Resource resource) { diff --git a/content-rdf/src/main/java/org/xbib/content/rdf/io/ntriple/NTripleContentGenerator.java b/content-rdf/src/main/java/org/xbib/content/rdf/io/ntriple/NTripleContentGenerator.java index ecb1fa2..4757a82 100644 --- a/content-rdf/src/main/java/org/xbib/content/rdf/io/ntriple/NTripleContentGenerator.java +++ b/content-rdf/src/main/java/org/xbib/content/rdf/io/ntriple/NTripleContentGenerator.java @@ -45,7 +45,6 @@ public class NTripleContentGenerator @Override public NTripleContentGenerator receive(IRI iri) throws IOException { - //String compact = params.getNamespaceContext().compact(iri); return this; } diff --git a/content-rdf/src/main/java/org/xbib/content/rdf/io/rdfxml/RdfXmlContentParser.java b/content-rdf/src/main/java/org/xbib/content/rdf/io/rdfxml/RdfXmlContentParser.java index 7a95bad..27c54a4 100644 --- a/content-rdf/src/main/java/org/xbib/content/rdf/io/rdfxml/RdfXmlContentParser.java +++ b/content-rdf/src/main/java/org/xbib/content/rdf/io/rdfxml/RdfXmlContentParser.java @@ -136,27 +136,6 @@ public class RdfXmlContentParser implements RdfConst return this; } - private void yield(Object s, Object p, Object o) throws IOException { - yield(new DefaultTriple(resource.newSubject(s), resource.newPredicate(p), resource.newObject(o))); - } - - private void yield(Triple triple) throws IOException { - if (builder != null) { - builder.receive(triple); - } - } - - // produce a (possibly) reified triple - private void yield(Object s, IRI p, Object o, IRI reified) throws IOException { - yield(s, p, o); - if (reified != null) { - yield(reified, RDF_TYPE, RDF_STATEMENT); - yield(reified, RDF_SUBJECT, s); - yield(reified, RDF_PREDICATE, p); - yield(reified, RDF_OBJECT, o); - } - } - // get the most-specific language tag in scope private String getLanguage(Deque stack) { String lang = ""; @@ -194,16 +173,6 @@ public class RdfXmlContentParser implements RdfConst return ip; } - // do we expect to encounter a subject (rather than a predicate?) - private boolean expectSubject(Deque stack) { - boolean b = true; - Iterator it = stack.descendingIterator(); - while (it.hasNext()) { - Frame frame = it.next(); - b = !frame.isSubject; - } - return b; - } // if we're in a predicate, get its frame private Frame parentPredicateFrame(Deque stack) throws SAXException { @@ -247,15 +216,6 @@ public class RdfXmlContentParser implements RdfConst return subjectFrame != null ? subjectFrame.node : null; } - // if we're looking at a subject, is it an item in a Collection? - private boolean isCollectionItem(Deque stack) throws SAXException { - if (inPredicate(stack)) { - Frame predicateFrame = parentPredicateFrame(stack); - return predicateFrame != null && predicateFrame.isCollection; - } else { - return false; - } - } private Resource blankNode() { return new DefaultAnonymousResource("b" + (bn++)); @@ -566,7 +526,7 @@ public class RdfXmlContentParser implements RdfConst String aQn = attrs.getQName(i); IRI aUri = IRI.create(attrs.getURI(i) + attrs.getLocalName(i)); String aVal = attrs.getValue(i); - if (((aUri.toString().equals(RDF_TYPE.toString()) || !aUri.toString().startsWith(RDF_STRING))) + if ((aUri.toString().equals(RDF_TYPE.toString()) || !aUri.toString().startsWith(RDF_STRING)) && !aQn.startsWith("xml:")) { if (object == null) { object = blankNode().id(); @@ -666,5 +626,48 @@ public class RdfXmlContentParser implements RdfConst xmlLiteral.append(""); } } + + // do we expect to encounter a subject (rather than a predicate?) + private boolean expectSubject(Deque stack) { + boolean b = true; + Iterator it = stack.descendingIterator(); + while (it.hasNext()) { + Frame frame = it.next(); + b = !frame.isSubject; + } + return b; + } + + // produce a (possibly) reified triple + private void yield(Object s, IRI p, Object o, IRI reified) throws IOException { + yield(s, p, o); + if (reified != null) { + yield(reified, RDF_TYPE, RDF_STATEMENT); + yield(reified, RDF_SUBJECT, s); + yield(reified, RDF_PREDICATE, p); + yield(reified, RDF_OBJECT, o); + } + } + + private void yield(Object s, Object p, Object o) throws IOException { + yield(new DefaultTriple(resource.newSubject(s), resource.newPredicate(p), resource.newObject(o))); + } + + private void yield(Triple triple) throws IOException { + if (builder != null) { + builder.receive(triple); + } + } + + // if we're looking at a subject, is it an item in a Collection? + private boolean isCollectionItem(Deque stack) throws SAXException { + if (inPredicate(stack)) { + Frame predicateFrame = parentPredicateFrame(stack); + return predicateFrame != null && predicateFrame.isCollection; + } else { + return false; + } + } + } } diff --git a/content-rdf/src/main/java/org/xbib/content/rdf/io/xml/XmlContentGenerator.java b/content-rdf/src/main/java/org/xbib/content/rdf/io/xml/XmlContentGenerator.java index 2bd32fb..a03f456 100644 --- a/content-rdf/src/main/java/org/xbib/content/rdf/io/xml/XmlContentGenerator.java +++ b/content-rdf/src/main/java/org/xbib/content/rdf/io/xml/XmlContentGenerator.java @@ -43,6 +43,7 @@ public class XmlContentGenerator implements RdfContentGenerator implements MultiMap { - private final Map> map = new LinkedHashMap<>(); + private final Map> map; public LinkedHashMultiMap() { + this.map = new LinkedHashMap<>(); } public LinkedHashMultiMap(MultiMap map) { - if (map == null) { - throw new IllegalArgumentException("must not be null"); - } + Objects.requireNonNull(map); + this.map = new LinkedHashMap<>(); for (K k : map.keySet()) { putAll(k, map.get(k)); } diff --git a/content-rdf/src/main/java/org/xbib/content/rdf/util/package-info.java b/content-rdf/src/main/java/org/xbib/content/rdf/util/package-info.java new file mode 100644 index 0000000..73b9a5e --- /dev/null +++ b/content-rdf/src/main/java/org/xbib/content/rdf/util/package-info.java @@ -0,0 +1,4 @@ +/** + * Classes for RDF content utilities. + */ +package org.xbib.content.rdf.util; diff --git a/content-resource/src/main/java/org/xbib/content/resource/IRI.java b/content-resource/src/main/java/org/xbib/content/resource/IRI.java index c7f8f06..8f543cc 100644 --- a/content-resource/src/main/java/org/xbib/content/resource/IRI.java +++ b/content-resource/src/main/java/org/xbib/content/resource/IRI.java @@ -520,8 +520,8 @@ public class IRI implements Comparable, Node { } public boolean isPathAbsolute() { - String path = getPath(); - return (path != null) && path.length() > 0 && path.charAt(0) == '/'; + String s = getPath(); + return s != null && s.length() > 0 && s.charAt(0) == '/'; } public boolean isSameDocumentReference() { @@ -545,9 +545,9 @@ public class IRI implements Comparable, Node { @Override public String toString() { StringBuilder buf = new StringBuilder(); - String scheme = getScheme(); - if (scheme != null && !scheme.isEmpty()) { - buf.append(scheme).append(':'); + String s = getScheme(); + if (s != null && !s.isEmpty()) { + buf.append(s).append(':'); } buf.append(getSchemeSpecificPart()); return buf.toString(); @@ -564,9 +564,9 @@ public class IRI implements Comparable, Node { public String toASCIIString() { StringBuilder buf = new StringBuilder(); - String scheme = getScheme(); - if (scheme != null && !scheme.isEmpty()) { - buf.append(scheme).append(':'); + String s = getScheme(); + if (s != null && !s.isEmpty()) { + buf.append(s).append(':'); } buf.append(getASCIISchemeSpecificPart()); return buf.toString(); diff --git a/content-resource/src/main/java/org/xbib/content/resource/IRINamespaceContext.java b/content-resource/src/main/java/org/xbib/content/resource/IRINamespaceContext.java index d33b7d4..e8e2306 100644 --- a/content-resource/src/main/java/org/xbib/content/resource/IRINamespaceContext.java +++ b/content-resource/src/main/java/org/xbib/content/resource/IRINamespaceContext.java @@ -60,7 +60,7 @@ public final class IRINamespaceContext extends XmlNamespaceContext { @Override public void addNamespace(String prefix, String namespace) { super.addNamespace(prefix, namespace); - sortedNamespacesByPrefixLength = new ArrayList(getNamespaces().values()); + sortedNamespacesByPrefixLength = new ArrayList<>(getNamespaces().values()); // sort from longest to shortest prefix for successful matching Collections.sort(sortedNamespacesByPrefixLength, (s1, s2) -> { Integer l1 = s1.length(); diff --git a/content-resource/src/main/java/org/xbib/content/resource/XmlNamespaceContext.java b/content-resource/src/main/java/org/xbib/content/resource/XmlNamespaceContext.java index d2f9418..a647fa6 100644 --- a/content-resource/src/main/java/org/xbib/content/resource/XmlNamespaceContext.java +++ b/content-resource/src/main/java/org/xbib/content/resource/XmlNamespaceContext.java @@ -116,6 +116,7 @@ public class XmlNamespaceContext implements NamespaceContext { prefixes.get(namespace).iterator() : null; } + @Override public String toString() { return namespaces.toString(); } diff --git a/content-resource/src/main/java/org/xbib/content/resource/scheme/SchemeRegistry.java b/content-resource/src/main/java/org/xbib/content/resource/scheme/SchemeRegistry.java index 6cd2af4..5cb9294 100644 --- a/content-resource/src/main/java/org/xbib/content/resource/scheme/SchemeRegistry.java +++ b/content-resource/src/main/java/org/xbib/content/resource/scheme/SchemeRegistry.java @@ -12,7 +12,7 @@ public final class SchemeRegistry { private final Map schemes; SchemeRegistry() { - schemes = new HashMap(); + schemes = new HashMap<>(); schemes.put(HttpScheme.HTTP_SCHEME_NAME, new HttpScheme()); schemes.put(HttpsScheme.HTTPS_SCHEME_NAME, new HttpsScheme()); schemes.put(FtpScheme.FTP_SCHEME_NAME, new FtpScheme()); diff --git a/content-resource/src/main/java/org/xbib/content/resource/text/InvalidCharacterException.java b/content-resource/src/main/java/org/xbib/content/resource/text/InvalidCharacterException.java index a267291..da2f940 100644 --- a/content-resource/src/main/java/org/xbib/content/resource/text/InvalidCharacterException.java +++ b/content-resource/src/main/java/org/xbib/content/resource/text/InvalidCharacterException.java @@ -6,7 +6,7 @@ package org.xbib.content.resource.text; public class InvalidCharacterException extends RuntimeException { private static final long serialVersionUID = -3037013255350562940L; - private int input; + private final int input; public InvalidCharacterException(int input) { this.input = input; diff --git a/content-resource/src/main/java/org/xbib/content/resource/url/UrlEncoding.java b/content-resource/src/main/java/org/xbib/content/resource/url/UrlEncoding.java index 113d2f6..dffe827 100644 --- a/content-resource/src/main/java/org/xbib/content/resource/url/UrlEncoding.java +++ b/content-resource/src/main/java/org/xbib/content/resource/url/UrlEncoding.java @@ -87,15 +87,6 @@ public final class UrlEncoding { return e; } - private static byte decode(char c, int shift) { - return (byte) ((((c >= '0' && c <= '9') ? c - '0' : (c >= 'A' && c <= 'F') ? c - 'A' + 10 - : (c >= 'a' && c <= 'f') ? c - 'a' + 10 : -1) & 0xf) << shift); - } - - private static byte decode(char c1, char c2) { - return (byte) (decode(c1, 4) | decode(c2, 0)); - } - /** * */ @@ -144,5 +135,14 @@ public final class UrlEncoding { } return i; } + + private static byte decode(char c, int shift) { + return (byte) ((((c >= '0' && c <= '9') ? c - '0' : (c >= 'A' && c <= 'F') ? c - 'A' + 10 + : (c >= 'a' && c <= 'f') ? c - 'a' + 10 : -1) & 0xf) << shift); + } + + private static byte decode(char c1, char c2) { + return (byte) (decode(c1, 4) | decode(c2, 0)); + } } } diff --git a/content-xml/src/main/java/org/xbib/content/xml/XmlXContentHelper.java b/content-xml/src/main/java/org/xbib/content/xml/XmlXContentHelper.java index 808a422..bd5190c 100644 --- a/content-xml/src/main/java/org/xbib/content/xml/XmlXContentHelper.java +++ b/content-xml/src/main/java/org/xbib/content/xml/XmlXContentHelper.java @@ -14,6 +14,9 @@ import java.util.Map; */ public class XmlXContentHelper { + private XmlXContentHelper() { + } + public static Map convertFromXmlToMap(Reader reader) { try { return XmlXContent.xmlXContent().createParser(reader).mapOrderedAndClose(); diff --git a/content-xml/src/main/java/org/xbib/content/xml/XmlXContentParser.java b/content-xml/src/main/java/org/xbib/content/xml/XmlXContentParser.java index 744a1d2..e8552b9 100644 --- a/content-xml/src/main/java/org/xbib/content/xml/XmlXContentParser.java +++ b/content-xml/src/main/java/org/xbib/content/xml/XmlXContentParser.java @@ -150,6 +150,8 @@ public class XmlXContentParser extends AbstractXContentParser { return NumberType.BIG_INTEGER; case BIG_DECIMAL: return NumberType.BIG_DECIMAL; + default: + break; } throw new IllegalStateException("No matching token for number_type [" + numberType + "]"); } @@ -181,6 +183,8 @@ public class XmlXContentParser extends AbstractXContentParser { return Token.END_ARRAY; case VALUE_EMBEDDED_OBJECT: return Token.VALUE_EMBEDDED_OBJECT; + default: + break; } throw new IllegalStateException("No matching token for json_token [" + token + "]"); } diff --git a/content-xml/src/main/java/org/xbib/content/xml/json/JsonStaxReader.java b/content-xml/src/main/java/org/xbib/content/xml/json/JsonStaxReader.java index 0dd7e8b..9e93cd5 100644 --- a/content-xml/src/main/java/org/xbib/content/xml/json/JsonStaxReader.java +++ b/content-xml/src/main/java/org/xbib/content/xml/json/JsonStaxReader.java @@ -64,7 +64,7 @@ public class JsonStaxReader implements XMLStreamReader { } @Override - public Object getProperty(String name) throws IllegalArgumentException { + public Object getProperty(String name) { throw new UnsupportedOperationException("Not supported yet."); } diff --git a/content-xml/src/main/java/org/xbib/content/xml/json/events/JsonReaderXmlEvent.java b/content-xml/src/main/java/org/xbib/content/xml/json/events/JsonReaderXmlEvent.java index 339c0be..c095304 100644 --- a/content-xml/src/main/java/org/xbib/content/xml/json/events/JsonReaderXmlEvent.java +++ b/content-xml/src/main/java/org/xbib/content/xml/json/events/JsonReaderXmlEvent.java @@ -199,7 +199,7 @@ public abstract class JsonReaderXmlEvent { public void addAttribute(QName name, String value) { if (null == attributes) { - attributes = new LinkedList(); + attributes = new LinkedList<>(); } attributes.add(new Attribute(name, value)); } diff --git a/content-xml/src/main/java/org/xbib/content/xml/stream/AbstractCharactersEvent.java b/content-xml/src/main/java/org/xbib/content/xml/stream/AbstractCharactersEvent.java index 752e427..b4bb5d3 100644 --- a/content-xml/src/main/java/org/xbib/content/xml/stream/AbstractCharactersEvent.java +++ b/content-xml/src/main/java/org/xbib/content/xml/stream/AbstractCharactersEvent.java @@ -25,9 +25,9 @@ public abstract class AbstractCharactersEvent extends AbstractXMLEvent implement @Override public boolean isWhiteSpace() { - String data = getData(); - for (int i = 0, s = data.length(); i < s; i++) { - char ch = data.charAt(i); + String s1 = getData(); + for (int i = 0, s = s1.length(); i < s; i++) { + char ch = s1.charAt(i); if (ch != ' ' && ch != '\n' && ch != '\t' && ch != '\r') { return false; } diff --git a/content-xml/src/main/java/org/xbib/content/xml/stream/AbstractStaxContentHandler.java b/content-xml/src/main/java/org/xbib/content/xml/stream/AbstractStaxContentHandler.java index 3575083..dec9fdd 100644 --- a/content-xml/src/main/java/org/xbib/content/xml/stream/AbstractStaxContentHandler.java +++ b/content-xml/src/main/java/org/xbib/content/xml/stream/AbstractStaxContentHandler.java @@ -85,7 +85,7 @@ abstract class AbstractStaxContentHandler implements ContentHandler { throws XMLStreamException; @Override - public final void characters(char ch[], int start, int length) throws SAXException { + public final void characters(char[] ch, int start, int length) throws SAXException { try { charactersInternal(ch, start, length); } catch (XMLStreamException ex) { diff --git a/content-xml/src/main/java/org/xbib/content/xml/stream/AbstractXMLEvent.java b/content-xml/src/main/java/org/xbib/content/xml/stream/AbstractXMLEvent.java index 4551d63..01d5fcf 100644 --- a/content-xml/src/main/java/org/xbib/content/xml/stream/AbstractXMLEvent.java +++ b/content-xml/src/main/java/org/xbib/content/xml/stream/AbstractXMLEvent.java @@ -1,7 +1,6 @@ package org.xbib.content.xml.stream; import java.io.StringWriter; -import java.io.Writer; import java.util.logging.Level; import java.util.logging.Logger; @@ -110,9 +109,6 @@ public abstract class AbstractXMLEvent implements XMLEvent { return getEventType() == START_ELEMENT; } - @Override - public abstract void writeAsEncodedUnicode(Writer writer) throws XMLStreamException; - @Override public String toString() { StringWriter writer = new StringWriter(); diff --git a/content-xml/src/main/java/org/xbib/content/xml/stream/SaxEventConsumer.java b/content-xml/src/main/java/org/xbib/content/xml/stream/SaxEventConsumer.java index 16981e6..f10f0e2 100644 --- a/content-xml/src/main/java/org/xbib/content/xml/stream/SaxEventConsumer.java +++ b/content-xml/src/main/java/org/xbib/content/xml/stream/SaxEventConsumer.java @@ -277,12 +277,15 @@ public class SaxEventConsumer implements XMLEventConsumer { } private void handleNamespace() { + // not used } private void handleAttribute() { + // not used } private void handleDTD() { + // not used } private void handleComment(Comment comment) throws XMLStreamException { @@ -295,17 +298,22 @@ public class SaxEventConsumer implements XMLEventConsumer { } private void handleEntityReference() { + // not used } private void handleSpace() { + // not used } private void handleNotationDecl() { + // not used } private void handleEntityDecl() { + // not used } private void handleCDATA() { + // not used } } diff --git a/content-xml/src/main/java/org/xbib/content/xml/stream/StaxEventContentHandler.java b/content-xml/src/main/java/org/xbib/content/xml/stream/StaxEventContentHandler.java index 505e1c6..4c3f98c 100644 --- a/content-xml/src/main/java/org/xbib/content/xml/stream/StaxEventContentHandler.java +++ b/content-xml/src/main/java/org/xbib/content/xml/stream/StaxEventContentHandler.java @@ -108,7 +108,7 @@ public class StaxEventContentHandler extends AbstractStaxContentHandler { */ @SuppressWarnings("unchecked") private List createNamespaces(SimpleNamespaceContext namespaceContext) { - List namespaces = new ArrayList(); + List namespaces = new ArrayList<>(); String defaultNamespaceUri = namespaceContext.getNamespaceURI(XMLConstants.DEFAULT_NS_PREFIX); if (defaultNamespaceUri != null && defaultNamespaceUri.length() > 0) { namespaces.add(eventFactory.createNamespace(defaultNamespaceUri)); @@ -122,7 +122,7 @@ public class StaxEventContentHandler extends AbstractStaxContentHandler { } private List getAttributes(Attributes attributes) { - List list = new ArrayList(); + List list = new ArrayList<>(); for (int i = 0; i < attributes.getLength(); i++) { QName name = toQName(attributes.getURI(i), attributes.getQName(i)); if (!("xmlns".equals(name.getLocalPart()) || "xmlns".equals(name.getPrefix()))) { @@ -134,6 +134,7 @@ public class StaxEventContentHandler extends AbstractStaxContentHandler { @Override protected void skippedEntityInternal(String name) throws XMLStreamException { + // not used } private static class SaxLocation implements Location { diff --git a/content-xml/src/main/java/org/xbib/content/xml/stream/StaxSource.java b/content-xml/src/main/java/org/xbib/content/xml/stream/StaxSource.java index 81dbce1..d399f36 100644 --- a/content-xml/src/main/java/org/xbib/content/xml/stream/StaxSource.java +++ b/content-xml/src/main/java/org/xbib/content/xml/stream/StaxSource.java @@ -74,8 +74,8 @@ public class StaxSource extends SAXSource { } int eventType = reader.getEventType(); - if (!(eventType == XMLStreamConstants.START_DOCUMENT) - && !(eventType == XMLStreamConstants.START_ELEMENT)) { + if (eventType != XMLStreamConstants.START_DOCUMENT + && eventType != XMLStreamConstants.START_ELEMENT) { throw new IllegalStateException(); } diff --git a/content-xml/src/main/java/org/xbib/content/xml/stream/StaxStreamContentHandler.java b/content-xml/src/main/java/org/xbib/content/xml/stream/StaxStreamContentHandler.java index 5abf60b..1362dab 100644 --- a/content-xml/src/main/java/org/xbib/content/xml/stream/StaxStreamContentHandler.java +++ b/content-xml/src/main/java/org/xbib/content/xml/stream/StaxStreamContentHandler.java @@ -28,6 +28,7 @@ public class StaxStreamContentHandler extends AbstractStaxContentHandler { @Override public void setDocumentLocator(Locator locator) { + // not used } @Override @@ -57,6 +58,7 @@ public class StaxStreamContentHandler extends AbstractStaxContentHandler { @Override protected void skippedEntityInternal(String name) { + // not used } @Override diff --git a/content-xml/src/main/java/org/xbib/content/xml/stream/StreamWriterDelegate.java b/content-xml/src/main/java/org/xbib/content/xml/stream/StreamWriterDelegate.java index cb9da9e..f09c8af 100644 --- a/content-xml/src/main/java/org/xbib/content/xml/stream/StreamWriterDelegate.java +++ b/content-xml/src/main/java/org/xbib/content/xml/stream/StreamWriterDelegate.java @@ -18,7 +18,7 @@ public abstract class StreamWriterDelegate implements XMLStreamWriter { } @Override - public Object getProperty(String name) throws IllegalArgumentException { + public Object getProperty(String name) { return out.getProperty(name); } diff --git a/content-xml/src/main/java/org/xbib/content/xml/stream/XMLFilterImplEx.java b/content-xml/src/main/java/org/xbib/content/xml/stream/XMLFilterImplEx.java index a6760e1..979336d 100644 --- a/content-xml/src/main/java/org/xbib/content/xml/stream/XMLFilterImplEx.java +++ b/content-xml/src/main/java/org/xbib/content/xml/stream/XMLFilterImplEx.java @@ -83,7 +83,7 @@ public class XMLFilterImplEx extends XMLFilterImpl implements LexicalHandler { } @Override - public void comment(char ch[], int start, int length) throws SAXException { + public void comment(char[] ch, int start, int length) throws SAXException { if (lexicalHandler != null) { lexicalHandler.comment(ch, start, length); } diff --git a/content-xml/src/main/java/org/xbib/content/xml/stream/XMLStreamReaderToContentHandler.java b/content-xml/src/main/java/org/xbib/content/xml/stream/XMLStreamReaderToContentHandler.java index ca0e90e..edd6ed4 100644 --- a/content-xml/src/main/java/org/xbib/content/xml/stream/XMLStreamReaderToContentHandler.java +++ b/content-xml/src/main/java/org/xbib/content/xml/stream/XMLStreamReaderToContentHandler.java @@ -324,29 +324,38 @@ public class XMLStreamReaderToContentHandler { } private void handleNamespace() { + // not used } private void handleAttribute() { + // not used } private void handleDTD() { + // not used } private void handleComment() { + // not used } private void handleEntityReference() { + // not used } private void handleSpace() { + // not used } private void handleNotationDecl() { + // not used } private void handleEntityDecl() { + // not used } private void handleCDATA() { + // not used } } diff --git a/content-xml/src/main/java/org/xbib/content/xml/transform/ContentTypeListener.java b/content-xml/src/main/java/org/xbib/content/xml/transform/ContentTypeListener.java deleted file mode 100644 index af6f2ad..0000000 --- a/content-xml/src/main/java/org/xbib/content/xml/transform/ContentTypeListener.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.xbib.content.xml.transform; - -import java.io.IOException; - -/** - * A callback listener for providing information about the content type and encoding of - * the output. - */ -public interface ContentTypeListener { - - void setContentType(String contentType, String encoding) throws IOException; -} diff --git a/content-xml/src/main/java/org/xbib/content/xml/transform/StylesheetTransformer.java b/content-xml/src/main/java/org/xbib/content/xml/transform/StylesheetTransformer.java index ee9982f..b809be3 100644 --- a/content-xml/src/main/java/org/xbib/content/xml/transform/StylesheetTransformer.java +++ b/content-xml/src/main/java/org/xbib/content/xml/transform/StylesheetTransformer.java @@ -37,7 +37,7 @@ public class StylesheetTransformer implements Closeable { private static final StylesheetPool pool = new StylesheetPool(); - private final Map parameters = new HashMap(); + private final Map parameters = new HashMap<>(); private SAXTransformerFactory transformerFactory; diff --git a/content-xml/src/main/java/org/xbib/content/xml/util/ISO9075.java b/content-xml/src/main/java/org/xbib/content/xml/util/ISO9075.java index b763d3e..2c845ba 100644 --- a/content-xml/src/main/java/org/xbib/content/xml/util/ISO9075.java +++ b/content-xml/src/main/java/org/xbib/content/xml/util/ISO9075.java @@ -89,7 +89,7 @@ public class ISO9075 { StringBuilder decoded = new StringBuilder(); for (int i = 0, l = toDecode.length(); i < l; i++) { if (matchesEncodedPattern(toDecode, i)) { - decoded.append(((char) Integer.parseInt(toDecode.substring(i + 2, i + 6), 16))); + decoded.append((char) Integer.parseInt(toDecode.substring(i + 2, i + 6), 16)); i += 6; } else { decoded.append(toDecode.charAt(i)); diff --git a/content-xml/src/main/java/org/xbib/content/xml/util/ToQName.java b/content-xml/src/main/java/org/xbib/content/xml/util/ToQName.java index 6fb3b1c..1b8eb8b 100644 --- a/content-xml/src/main/java/org/xbib/content/xml/util/ToQName.java +++ b/content-xml/src/main/java/org/xbib/content/xml/util/ToQName.java @@ -8,6 +8,9 @@ import javax.xml.namespace.QName; */ public class ToQName { + private ToQName() { + } + public static QName toQName(QName root, NamespaceContext context, String string) { String name = string; String nsPrefix = root.getPrefix();