Package com.franz.util
Class Util
java.lang.Object
com.franz.util.Util
Various static utility functions.
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
compare
(int[] a, int[] b) Compares two array lexicographically.static String
getCatalogFromSpec
(String repoAndCatalog) Parses a store spec of the form [CATALOG:]REPO and returns the CATALOG.static String
getRepoFromSpec
(String repoAndCatalog) Parses a store spec of the form [CATALOG:]REPO and returns the REPO part.static <T> Iterable<T>
iter
(CloseableIteration<T> i) Converts an RDF4J iteration object into a Java iterable.static int
mismatch
(int[] a, int[] b) Computes the first index where two arrays differ.static void
verifyContextNotNull
(Resource... contexts)
-
Method Details
-
iter
Converts an RDF4J iteration object into a Java iterable.Note that the 'iterable' can be iterated over only once. The purpose of this method is to enable RDF4J iterable objects to be used in for-each loops:
try (TupleQueryResult result = ...) { for (BindingSet set : Util.iter(result)) { ... } }
- Type Parameters:
T
- Type of objects returned from the iteration.- Parameters:
i
- RDF4J iterable object.- Returns:
- An iterable to be used in a for-each loop.
-
getCatalogFromSpec
Parses a store spec of the form [CATALOG:]REPO and returns the CATALOG. Returnsnull
if there is no CATALOG.- Parameters:
repoAndCatalog
- Store specification ([CATALOG:]REPO).- Returns:
- Catalog name or
null
.
-
getRepoFromSpec
Parses a store spec of the form [CATALOG:]REPO and returns the REPO part.- Parameters:
repoAndCatalog
- Store specification ([CATALOG:]REPO).- Returns:
- Repository name.
-
mismatch
public static int mismatch(int[] a, int[] b) Computes the first index where two arrays differ.If the arrays are identical -1 is returned.
If one array is a prefix of the other then the length of the shorter array is returned.
- Parameters:
a
- First array.b
- Second array.- Returns:
- First differing index or -1.
- Throws:
NullPointerException
- If either array is null.
-
compare
public static int compare(int[] a, int[] b) Compares two array lexicographically.- Parameters:
a
- First array.b
- Second array.- Returns:
- Comparison result as specified by
Comparable.compareTo(Object)
. - Throws:
NullPointerException
- If either array is null.
-
verifyContextNotNull
-