CPD Results
The following document contains the results of PMD's CPD 5.3.2.
Duplications
File | Project | Line |
---|---|---|
eu/fbk/rdfpro/Transformer.java | rdfpro-core | 726 |
eu/fbk/rdfpro/util/Statements.java | rdfpro-core | 1455 |
this.include = include; this.matchedURINamespaces = new HashSet<>(); this.matchedURIs = new HashSet<>(); this.matchedBNodes = new HashSet<>(); this.matchedLanguages = new HashSet<>(); this.matchedDatatypeURIs = new HashSet<>(); this.matchedDatatypeNamespaces = new HashSet<>(); this.matchedLiterals = new HashSet<>(); boolean matchAnyURI = false; boolean matchAnyBNode = false; boolean matchAnyPlainLiteral = false; boolean matchAnyLangLiteral = false; boolean matchAnyTypedLiteral = false; for (final String expression : matchExpressions) { if ("<*>".equals(expression)) { matchAnyURI = true; } else if ("_:*".equals(expression)) { matchAnyBNode = true; } else if ("*".equals(expression)) { matchAnyPlainLiteral = true; } else if ("*@*".equals(expression)) { matchAnyLangLiteral = true; } else if ("*^^*".equals(expression)) { matchAnyTypedLiteral = true; } else if (expression.startsWith("*@")) { this.matchedLanguages.add(expression.substring(2)); } else if (expression.startsWith("*^^")) { if (expression.endsWith(":*")) { this.matchedDatatypeNamespaces.add(Namespaces.DEFAULT.uriFor(expression .substring(3, expression.length() - 2))); } else { this.matchedDatatypeURIs.add((URI) Statements.parseValue( expression.substring(3), Namespaces.DEFAULT)); } } else if (expression.endsWith(":*")) { this.matchedURINamespaces.add(Namespaces.DEFAULT.uriFor(expression.substring( 0, expression.length() - 2))); } else if (expression.endsWith("*>")) { this.matchedURINamespaces .add(expression.substring(1, expression.length() - 2)); } else { final Value value = Statements.parseValue(expression, Namespaces.DEFAULT); if (value instanceof URI) { this.matchedURIs.add((URI) value); } else if (value instanceof BNode) { this.matchedBNodes.add((BNode) value); } else if (value instanceof Literal) { this.matchedLiterals.add((Literal) value); } } } this.matchAnyURI = matchAnyURI; this.matchAnyBNode = matchAnyBNode; this.matchAnyPlainLiteral = matchAnyPlainLiteral; this.matchAnyLangLiteral = matchAnyLangLiteral; this.matchAnyTypedLiteral = matchAnyTypedLiteral; } |
File | Project | Line |
---|---|---|
eu/fbk/rdfpro/Transformer.java | rdfpro-core | 797 |
eu/fbk/rdfpro/util/Statements.java | rdfpro-core | 1524 |
private boolean match(final Value value) { if (value instanceof URI) { return this.matchAnyURI // || contains(this.matchedURIs, value) || containsNs(this.matchedURINamespaces, (URI) value); } else if (value instanceof Literal) { final Literal lit = (Literal) value; final String lang = lit.getLanguage(); final URI dt = lit.getDatatype(); return lang == null && (dt == null || XMLSchema.STRING.equals(dt)) && this.matchAnyPlainLiteral // || lang != null // && (this.matchAnyLangLiteral || contains(this.matchedLanguages, lang)) // || dt != null // && (this.matchAnyTypedLiteral || contains(this.matchedDatatypeURIs, dt) || containsNs( this.matchedDatatypeNamespaces, dt)) // || contains(this.matchedLiterals, lit); } else { return this.matchAnyBNode // || contains(this.matchedBNodes, value); } } private static boolean contains(final Set<?> set, final Object value) { return !set.isEmpty() && set.contains(value); } private static boolean containsNs(final Set<String> set, final URI uri) { if (set.isEmpty()) { return false; } if (set.contains(uri.getNamespace())) { return true; // exact lookup } final String uriString = uri.stringValue(); for (final String elem : set) { if (uriString.startsWith(elem)) { return true; // prefix match } } return false; } } } |
File | Project | Line |
---|---|---|
eu/fbk/rdfpro/GroovyProcessor.java | rdfpro-groovy | 959 |
eu/fbk/rdfpro/SparqlFunctions.java | rdfpro-groovy | 435 |
if (object instanceof Long) { return new GroovyLiteral(object.toString(), XMLSchema.LONG); } else if (object instanceof Integer) { return new GroovyLiteral(object.toString(), XMLSchema.INT); } else if (object instanceof Short) { return new GroovyLiteral(object.toString(), XMLSchema.SHORT); } else if (object instanceof Byte) { return new GroovyLiteral(object.toString(), XMLSchema.BYTE); } else if (object instanceof Double) { return new GroovyLiteral(object.toString(), XMLSchema.DOUBLE); } else if (object instanceof Float) { return new GroovyLiteral(object.toString(), XMLSchema.FLOAT); } else if (object instanceof Boolean) { return new GroovyLiteral(object.toString(), XMLSchema.BOOLEAN); } else if (object instanceof XMLGregorianCalendar) { final XMLGregorianCalendar c = (XMLGregorianCalendar) object; return new GroovyLiteral(c.toXMLFormat(), XMLDatatypeUtil.qnameToURI(c .getXMLSchemaType())); } else if (object instanceof Date) { final GregorianCalendar c = new GregorianCalendar(); c.setTime((Date) object); final XMLGregorianCalendar xc = DATATYPE_FACTORY.newXMLGregorianCalendar(c); return new GroovyLiteral(xc.toXMLFormat(), XMLDatatypeUtil.qnameToURI(xc .getXMLSchemaType())); } else if (object instanceof CharSequence) { return new GroovyLiteral(object.toString(), XMLSchema.STRING); } else { |
File | Project | Line |
---|---|---|
eu/fbk/rdfpro/util/IO.java | rdfpro-core | 805 |
eu/fbk/rdfpro/util/IO.java | rdfpro-core | 1414 |
System.arraycopy(this.buffer, this.pos, cbuf, off, n); this.pos += n; return n; } @Override public long skip(final long n) throws IOException { if (n <= 0) { checkNotClosed(); return 0; } int available = this.count - this.pos; if (available == 0) { fill(); available = this.count; } final long skipped = available < n ? available : n; this.pos += skipped; return skipped; } @Override public void reset() throws IOException { throw new IOException("Mark not supported"); } @Override public void mark(final int readlimit) { } @Override public boolean markSupported() { return false; } @Override public void close() throws IOException { synchronized (this.buffers) { if (this.closed) { return; } this.closed = true; } this.count = this.pos; this.buffers.clear(); this.fetcher.close(); this.fetcher = null; } private void fill() throws IOException { checkNotClosed(); if (this.buffer != null) { this.buffer = null; this.pos = 0; this.count = 0; } if (this.index == this.buffers.size()) { this.fetcher.fetch(this.buffers); this.index = 0; } if (this.index < this.buffers.size()) { final CharBuffer cb = this.buffers.get(this.index++); |
File | Project | Line |
---|---|---|
eu/fbk/rdfpro/util/Scripting.java | rdfpro-core | 267 |
eu/fbk/rdfpro/GroovyProcessor.java | rdfpro-groovy | 344 |
} while (c != d || script.charAt(i - 1) == '\\'); ++i; } else { builder.append(c); ++i; } } } catch (final Exception ex) { throw new IllegalArgumentException("Illegal URI escaping near offset " + i, ex); } return builder.toString(); } // Following code can be factored in Statements // rewriteRDFTerms(String, Function<Value, String>) private static int parseURI(final String string, int i) { final int len = string.length(); if (string.charAt(i) != '<') { return -1; } for (++i; i < len; ++i) { final char c = string.charAt(i); if (c == '<' || c == '\"' || c == '{' || c == '}' || c == '|' || c == '^' || c == '`' || c == '\\' || c == ' ') { return -1; } if (c == '>') { return i + 1; } } return -1; } private static int parseQName(final String string, int i) { final int len = string.length(); char c; if (!isPN_CHARS_BASE(string.charAt(i))) { return -1; } for (; i < len; ++i) { c = string.charAt(i); if (!isPN_CHARS(c) && c != '.') { break; } } if (string.charAt(i - 1) == '.' || string.charAt(i) != ':' || i == len - 1) { |
File | Project | Line |
---|---|---|
eu/fbk/rdfpro/ProcessorRDFS.java | rdfpro-core | 58 |
eu/fbk/rdfpro/util/HashValueFactory.java | rdfpro-core | 64 |
RDF.LI, RDF.LIST, RDF.FIRST, RDF.REST, RDF.NIL, RDF.LANGSTRING, RDFS.RESOURCE, RDFS.LITERAL, RDFS.CLASS, RDFS.SUBCLASSOF, RDFS.SUBPROPERTYOF, RDFS.DOMAIN, RDFS.RANGE, RDFS.COMMENT, RDFS.LABEL, RDFS.DATATYPE, RDFS.CONTAINER, RDFS.MEMBER, RDFS.ISDEFINEDBY, RDFS.SEEALSO, RDFS.CONTAINERMEMBERSHIPPROPERTY, OWL.CLASS, OWL.INDIVIDUAL, OWL.THING, OWL.NOTHING, OWL.EQUIVALENTCLASS, OWL.EQUIVALENTPROPERTY, OWL.SAMEAS, OWL.DIFFERENTFROM, OWL.ALLDIFFERENT, OWL.DISTINCTMEMBERS, OWL.OBJECTPROPERTY, OWL.DATATYPEPROPERTY, OWL.INVERSEOF, OWL.TRANSITIVEPROPERTY, OWL.SYMMETRICPROPERTY, OWL.FUNCTIONALPROPERTY, OWL.INVERSEFUNCTIONALPROPERTY, OWL.RESTRICTION, OWL.ONPROPERTY, OWL.ALLVALUESFROM, OWL.SOMEVALUESFROM, OWL.MINCARDINALITY, OWL.MAXCARDINALITY, OWL.CARDINALITY, OWL.ONTOLOGY, OWL.IMPORTS, OWL.INTERSECTIONOF, OWL.VERSIONINFO, OWL.VERSIONIRI, OWL.PRIORVERSION, OWL.BACKWARDCOMPATIBLEWITH, OWL.INCOMPATIBLEWITH, OWL.DEPRECATEDCLASS, OWL.DEPRECATEDPROPERTY, OWL.ANNOTATIONPROPERTY, OWL.ONTOLOGYPROPERTY, OWL.ONEOF, OWL.HASVALUE, OWL.DISJOINTWITH, OWL.UNIONOF, OWL.COMPLEMENTOF, XMLSchema.DURATION, XMLSchema.DATETIME, |
File | Project | Line |
---|---|---|
eu/fbk/rdfpro/util/StatementDeduplicator.java | rdfpro-core | 278 |
eu/fbk/rdfpro/util/StatementDeduplicator.java | rdfpro-core | 346 |
+ (ctx == null ? 0 : ctx.hashCode()); hash = hash != 0 ? hash : 1; synchronized (this) { int hashIndex = (hash & 0x7FFFFFFF) % this.hashes.length; while (true) { if (this.hashes[hashIndex] == 0) { if (add) { final int valueIndex = hashIndex << 2; this.hashes[hashIndex] = hash; this.values[valueIndex] = subj; this.values[valueIndex + 1] = pred; this.values[valueIndex + 2] = obj; this.values[valueIndex + 3] = ctx; ++this.size; if (this.size >= (this.hashes.length << 1) / 3) { // fill factor 0.66 final Object[] pair = rehash(this.hashes, this.values); this.hashes = (int[]) pair[0]; this.values = (Value[]) pair[1]; } } return true; } else if (this.hashes[hashIndex] == hash) { final int valueIndex = hashIndex << 2; if (subj.equals(this.values[valueIndex]) |
File | Project | Line |
---|---|---|
eu/fbk/rdfpro/util/Scripting.java | rdfpro-core | 332 |
eu/fbk/rdfpro/GroovyProcessor.java | rdfpro-groovy | 190 |
} private static boolean isPN_CHARS(final int c) { return isPN_CHARS_U(c) || ASCIIUtil.isNumber(c) || c == 45 || c == 183 || c >= 768 && c <= 879 || c >= 8255 && c <= 8256; } private static boolean isPN_CHARS_U(final int c) { return isPN_CHARS_BASE(c) || c == 95; } private static boolean isPN_CHARS_BASE(final int c) { return ASCIIUtil.isLetter(c) || c >= 192 && c <= 214 || c >= 216 && c <= 246 || c >= 248 && c <= 767 || c >= 880 && c <= 893 || c >= 895 && c <= 8191 || c >= 8204 && c <= 8205 || c >= 8304 && c <= 8591 || c >= 11264 && c <= 12271 || c >= 12289 && c <= 55295 || c >= 63744 && c <= 64975 || c >= 65008 && c <= 65533 || c >= 65536 && c <= 983039; } |
File | Project | Line |
---|---|---|
eu/fbk/rdfpro/Transformer.java | rdfpro-core | 146 |
eu/fbk/rdfpro/Transformer.java | rdfpro-core | 231 |
Objects.requireNonNull(predicate); final String comp = components.trim().toLowerCase(); final boolean[] flags = new boolean[4]; for (int i = 0; i < comp.length(); ++i) { final char c = comp.charAt(i); final int index = c == 's' ? 0 : c == 'p' ? 1 : c == 'o' ? 2 : c == 'c' || c == 'g' ? 3 : -1; if (index < 0 || flags[index]) { throw new IllegalArgumentException("Invalid components '" + components + "'"); } flags[index] = true; } if (!flags[0] && !flags[1] && !flags[2] && !flags[3]) { return IDENTITY; } return new Transformer() { private final boolean skipSubj = !flags[0]; |
File | Project | Line |
---|---|---|
eu/fbk/rdfpro/Transformer.java | rdfpro-core | 577 |
eu/fbk/rdfpro/util/Statements.java | rdfpro-core | 1365 |
if (ch0 == '+' || ch0 == '-' || ch0 == '=') { action = ch0; if (token.length() == 1) { throw new IllegalArgumentException("No component(s) specified in '" + spec + "'"); } components.clear(); for (int i = 1; i < token.length(); ++i) { final char ch1 = Character.toLowerCase(token.charAt(i)); final int component = ch1 == 's' ? 0 : ch1 == 'p' ? 1 : ch1 == 'o' ? 2 : ch1 == 'c' ? 3 : -1; if (component < 0) { throw new IllegalArgumentException("Invalid component '" + ch1 + "' in '" + spec + "'"); } components.add(component); } } else if (action == 0) { throw new IllegalArgumentException("Missing selector in '" + spec + "'"); } else if (action == '=') { |
File | Project | Line |
---|---|---|
eu/fbk/rdfpro/util/IO.java | rdfpro-core | 1250 |
eu/fbk/rdfpro/util/IO.java | rdfpro-core | 1846 |
return CharBuffer.allocate(2 * BUFFER_SIZE); } public void open() { synchronized (this) { if (this.references < 0) { throw new IllegalStateException("Stream has been closed"); } ++this.references; } } public void close() throws IOException { synchronized (this) { --this.references; if (this.references != 0) { return; } this.references = -1; // prevent further open() to occur } while (true) { try { this.queue.put(EOF); break; } catch (final InterruptedException ex) { // ignore } } while (true) { try { this.latch.await(); break; } catch (final InterruptedException ex) { // ignore } } synchronized (EMITTERS) { EMITTERS.remove(this.writer); |
File | Project | Line |
---|---|---|
eu/fbk/rdfpro/RuleEngineImpl.java | rdfpro-core | 432 |
eu/fbk/rdfpro/RuleEngineImpl.java | rdfpro-core | 723 |
db.addExpr(rule.getWhereExpr()); } } else { for (final StatementPattern ip : rule.getInsertPatterns()) { final Value subj = ip.getSubjectVar().getValue(); final Value pred = ip.getPredicateVar().getValue(); final Value obj = ip.getObjectVar().getValue(); final Value ctx = ip.getContextVar() == null ? null : ip.getContextVar() .getValue(); if (subj instanceof Resource && pred instanceof URI && (ctx == null || ctx instanceof Resource)) { axioms.add(Statements.VALUE_FACTORY.createStatement((Resource) subj, (URI) pred, obj, (Resource) ctx)); } } } } |
File | Project | Line |
---|---|---|
eu/fbk/rdfpro/util/Buffer.java | rdfpro-core | 225 |
eu/fbk/rdfpro/util/Buffer.java | rdfpro-core | 524 |
if (temp >= 0) { if (temp == Integer.MAX_VALUE) { temp = b & 0xFF; } else { final char ch = (char) (temp << 8 | b & 0xFF); if (strIndex == strLength || s.charAt(strIndex++) != ch) { return false; } temp = -1; } } else if (b == 0) { temp = Integer.MAX_VALUE; } else { final char ch = (char) b; if (strIndex == strLength || s.charAt(strIndex++) != ch) { return false; } } } return strIndex == strLength; } |
File | Project | Line |
---|---|---|
eu/fbk/rdfpro/util/IO.java | rdfpro-core | 925 |
eu/fbk/rdfpro/util/IO.java | rdfpro-core | 1534 |
return CharBuffer.allocate(BUFFER_SIZE); } public void open() { synchronized (this) { if (this.references < 0) { throw new IllegalStateException("Reader has been closed"); } ++this.references; } } public void close() throws IOException { synchronized (this) { --this.references; if (this.references != 0) { return; } this.references = -1; // prevent further open() to occur } this.queue.clear(); // nobody will use queued buffers while (true) { try { this.latch.await(); break; } catch (final InterruptedException ex) { // ignore } } synchronized (FETCHERS) { FETCHERS.remove(this.reader); |
File | Project | Line |
---|---|---|
eu/fbk/rdfpro/util/Statements.java | rdfpro-core | 787 |
eu/fbk/rdfpro/tql/TQL.java | rdfpro-tql | 61 |
private static boolean isPN_CHARS_BASE(final int c) { // ok return isLetter(c) || c >= 0x00C0 && c <= 0x00D6 || c >= 0x00D8 && c <= 0x00F6 || c >= 0x00F8 && c <= 0x02FF || c >= 0x0370 && c <= 0x037D || c >= 0x037F && c <= 0x1FFF || c >= 0x200C && c <= 0x200D || c >= 0x2070 && c <= 0x218F || c >= 0x2C00 && c <= 0x2FEF || c >= 0x3001 && c <= 0xD7FF || c >= 0xF900 && c <= 0xFDCF || c >= 0xFDF0 && c <= 0xFFFD || c >= 0x10000 && c <= 0xEFFFF; } |
File | Project | Line |
---|---|---|
eu/fbk/rdfpro/util/QuadModelRepositoryAdapter.java | rdfpro-core | 127 |
eu/fbk/rdfpro/util/QuadModelSailAdapter.java | rdfpro-core | 151 |
} catch (final RepositoryException ex) { throw new ModelException(ex); } } @Override protected int doSizeEstimate(@Nullable final Resource subj, @Nullable final URI pred, @Nullable final Value obj, @Nullable final Resource ctx) { return Integer.MAX_VALUE; // no way to efficiently estimate cardinality } @Override protected Iterator<Statement> doIterator(@Nullable final Resource subj, @Nullable final URI pred, @Nullable final Value obj, final Resource[] ctxs) { try { return Iterators.forIteration(this.connection.getStatements(subj, pred, obj, false, ctxs)); } catch (final RepositoryException ex) { |
File | Project | Line |
---|---|---|
eu/fbk/rdfpro/util/Scripting.java | rdfpro-core | 315 |
eu/fbk/rdfpro/GroovyProcessor.java | rdfpro-groovy | 397 |
if (string.charAt(i - 1) == '.' || string.charAt(i) != ':' || i == len - 1) { return -1; } c = string.charAt(++i); if (!isPN_CHARS_U(c) && c != ':' && c != '%' && !Character.isDigit(c)) { return -1; } for (; i < len; ++i) { c = string.charAt(i); if (!isPN_CHARS(c) && c != '.' && c != ':' && c != '%') { break; } } if (string.charAt(i - 1) == '.') { return -1; } return i; } private static boolean isPN_CHARS(final int c) { |
File | Project | Line |
---|---|---|
eu/fbk/rdfpro/util/IO.java | rdfpro-core | 1521 |
eu/fbk/rdfpro/util/IO.java | rdfpro-core | 1833 |
if (this.buffers.size() < BUFFER_NUM_READ + Environment.getCores() + 1) { buffer.clear(); this.buffers.add(buffer); } } } private ByteBuffer allocate() { synchronized (this.buffers) { if (!this.buffers.isEmpty()) { return this.buffers.remove(this.buffers.size() - 1); } } return ByteBuffer.allocate(2 * BUFFER_SIZE); } public void open() { synchronized (this) { if (this.references < 0) { throw new IllegalStateException("Reader has been closed"); |
File | Project | Line |
---|---|---|
eu/fbk/rdfpro/util/StatementDeduplicator.java | rdfpro-core | 444 |
eu/fbk/rdfpro/util/StatementDeduplicator.java | rdfpro-core | 501 |
PartialIdentityDeduplicator(final int numCachedStatements) { this.hashes = new int[numCachedStatements]; this.values = new Value[numCachedStatements * 4]; this.locks = new Object[LOCK_NUM]; for (int i = 0; i < LOCK_NUM; ++i) { this.locks[i] = new Object(); } } @Override boolean total() { return false; } @Override boolean process(final Resource subj, final URI pred, final Value obj, @Nullable final Resource ctx, final boolean add) { int hash = 6661 * System.identityHashCode(subj) + 961 * System.identityHashCode(pred) |