Class Util

java.lang.Object
com.franz.util.Util

public final class Util extends Object
Various static utility functions.
  • Method Details

    • iter

      public static <T> Iterable<T> iter(CloseableIteration<T> i)
      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

      public static String getCatalogFromSpec(String repoAndCatalog)
      Parses a store spec of the form [CATALOG:]REPO and returns the CATALOG. Returns null if there is no CATALOG.
      Parameters:
      repoAndCatalog - Store specification ([CATALOG:]REPO).
      Returns:
      Catalog name or null.
    • getRepoFromSpec

      public static String getRepoFromSpec(String repoAndCatalog)
      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

      public static void verifyContextNotNull(Resource... contexts)