From fe73c23c8c2b8a110b886ce9b5263c5387d82cc6 Mon Sep 17 00:00:00 2001 From: agazzarini Date: Thu, 16 Apr 2015 19:16:56 +0200 Subject: [PATCH] [ issue #12 ] some code clean up --- .../java/org/gazzax/labs/solrdf/NTriples.java | 2 +- .../java/org/gazzax/labs/solrdf/Strings.java | 7 + .../java/org/gazzax/labs/solrdf/Utility.java | 121 --- .../PerSegmentSingleValuedFaceting.java | 691 +++++++++--------- .../handler/search/faceting/RDFacets.java | 14 +- .../rq/DateRangeEndpointCalculator.java | 15 +- .../rq/DoubleRangeEndpointCalculator.java | 8 +- .../labs/solrdf/log/MessageCatalog.java | 1 + 8 files changed, 395 insertions(+), 464 deletions(-) delete mode 100644 solrdf/src/main/java/org/gazzax/labs/solrdf/Utility.java diff --git a/solrdf/src/main/java/org/gazzax/labs/solrdf/NTriples.java b/solrdf/src/main/java/org/gazzax/labs/solrdf/NTriples.java index 5698900..f4a9ce6 100644 --- a/solrdf/src/main/java/org/gazzax/labs/solrdf/NTriples.java +++ b/solrdf/src/main/java/org/gazzax/labs/solrdf/NTriples.java @@ -7,7 +7,7 @@ import com.hp.hpl.jena.rdf.model.AnonId; /** - * Booch utility for parsing RDF resources. + * Booch utility for parsing NTriples. * * @author Andrea Gazzarini * @since 1.0 diff --git a/solrdf/src/main/java/org/gazzax/labs/solrdf/Strings.java b/solrdf/src/main/java/org/gazzax/labs/solrdf/Strings.java index a67e84e..105ebdf 100644 --- a/solrdf/src/main/java/org/gazzax/labs/solrdf/Strings.java +++ b/solrdf/src/main/java/org/gazzax/labs/solrdf/Strings.java @@ -27,6 +27,13 @@ public static boolean isNullOrEmpty(final String value) { return value == null || value.trim().length() == 0; } + /** + * Removes unnecessary decimal zeros from a numeric string. + * As an extreme case, where all decimals are 0, it ends with an integer string (e.g 10.000 = 10) + * + * @param numericStringValue the numeric string. + * @return a new string with unnecessary decimal zeros removed. + */ public static String round(final String numericStringValue) { final int indexOfDot = numericStringValue.indexOf("."); if (indexOfDot == -1) { diff --git a/solrdf/src/main/java/org/gazzax/labs/solrdf/Utility.java b/solrdf/src/main/java/org/gazzax/labs/solrdf/Utility.java deleted file mode 100644 index babba70..0000000 --- a/solrdf/src/main/java/org/gazzax/labs/solrdf/Utility.java +++ /dev/null @@ -1,121 +0,0 @@ -package org.gazzax.labs.solrdf; - -import com.google.common.hash.HashCode; -import com.google.common.hash.HashFunction; -import com.google.common.hash.Hashing; -import com.hp.hpl.jena.graph.Node; - -/** - * General-purposes Booch utility. - * - * @author Andrea Gazzarini - * @since 1.0 - */ -public abstract class Utility { - private static final HashFunction MURMUR_HASH_3 = Hashing.murmur3_128(); - - /** - * Returns the local name part of the given URI. - * Basically here because I didn't understand how Node.getLocalName() works. - * - * @param uri the URI. - * @return the local name part of the given URI. - */ - public static String localName(final String uri) { - return uri.substring(startIndexOfLocalName(uri) + 1); - } - - /** - * Returns the local name part of the given URI. - * Basically here because I didn't understand how Node.getLocalName() works. - * - * @param uri the URI. - * @return the local name part of the given URI. - */ - public static String localName(final Node uri) { - return localName(uri.getURI()); - } - - /** - * Returns the domain part of the given URI. - * Basically here because I didn't understand how Node.getNameSpace() works. - * - * @param uri the URI. - * @return the domain part of the given URI. - */ - public static String namespace(final String uri) { - return uri.substring(0, startIndexOfLocalName(uri) + 1); - } - - /** - * Returns the domain part of the given URI. - * Basically here because I didn't understand how Node.getNameSpace() works. - * - * @param uri the URI. - * @return the domain part of the given URI. - */ - public static String namespace(final Node uri) { - return namespace(uri.getURI()); - } - - /** - * Returns true if the given byte array represents a variable. The incoming - * value is considered a variable if - * - *