Class Util

  • public class Util
    extends Object
    Util provides various static utility methods.
    • Constructor Detail

      • Util

        public Util()
    • Method Detail

      • disposeDocument

        public static void disposeDocument​(org.apache.lucene.document.Document old)
        Disposes the document old. Closes any potentially open readers held by the document.
        old - the document to dispose.
      • isDocumentReady

        public static boolean isDocumentReady​(org.apache.lucene.document.Document doc)
        Returns true if the document is ready to be added to the index. That is all text extractors have finished their work.
        doc - the document to check.
        true if the document is ready; false otherwise.
      • createMatchAllQuery

        public static createMatchAllQuery​(String name,
                                                                         IndexFormatVersion version,
                                                                         org.apache.jackrabbit.core.query.lucene.PerQueryCache cache)
        Depending on the index format this method returns a query that matches all nodes that have a property with a given name.
        name - the property name.
        version - the index format version.
        Query that matches all nodes that have a property with the given name.
      • closeOrRelease

        public static void closeOrRelease​(org.apache.lucene.index.IndexReader reader)
                                   throws IOException
        Depending on the type of the reader this method either closes or releases the reader. The reader is released if it implements ReleaseableIndexReader.
        reader - the index reader to close or release.
        IOException - if an error occurs while closing or releasing the index reader.
      • compare

        public static int compare​(Comparable c1,
                                  Comparable c2)
        Compares values c1 and c2. If the values have differing types, then the order is defined on the type itself by calling compareTo() on the respective type class names.
        c1 - the first value.
        c2 - the second value.
        a negative integer if c1 should come before c2
        a positive integer if c1 should come after c2
        0 if they are equal.
      • compare

        public static int compare​(Comparable<?>[] c1,
                                  Comparable<?>[] c2)
        Compares two arrays of Comparable(s) in the same style as compare(Value[], Value[]). The 2 methods *have* to work in the same way for the sort to be consistent
      • compare

        public static int compare​(Value v1,
                                  Value v2)
                           throws ValueFormatException,
        Compares the two values. If the values have differing types, then an attempt is made to convert the second value into the type of the first value.

        Comparison of binary values is not supported.

        v1 - the first value.
        v2 - the second value.
        result of the comparison as specified in Comparable.compareTo(Object).
        ValueFormatException - if the given value cannot be converted into a comparable (i.e. unsupported type).
        RepositoryException - if an error occurs while converting the value.
      • createRegexp

        public static Pattern createRegexp​(String likePattern)
        Creates a regexp from likePattern.
        likePattern - the pattern.
        the regular expression Pattern.
      • getLength

        public static long getLength​(InternalValue value)
        Returns length of the internal value.
        value - a value.
        the length of the internal value or -1 if the length cannot be determined.