public class Util extends Object
Util
provides various static utility methods.Constructor and Description |
---|
Util() |
Modifier and Type | Method and Description |
---|---|
static void |
closeOrRelease(org.apache.lucene.index.IndexReader reader)
Depending on the type of the
reader this method either
closes or releases the reader. |
static int |
compare(Comparable<?>[] c1,
Comparable<?>[] c2)
Compares two arrays of Comparable(s) in the same style as
compare(Value[], Value[]) . |
static int |
compare(Comparable c1,
Comparable c2)
Compares values
c1 and c2 . |
static int |
compare(javax.jcr.Value[] a,
javax.jcr.Value[] b)
Compares two arrays of Value(s) in the same style as
compare(Comparable[], Comparable[]) . |
static int |
compare(javax.jcr.Value v1,
javax.jcr.Value v2)
Compares the two values.
|
static IOException |
createIOException(Throwable t)
Creates an
IOException with t as its cause. |
static org.apache.lucene.search.Query |
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 . |
static Pattern |
createRegexp(String likePattern)
Creates a regexp from
likePattern . |
static void |
disposeDocument(org.apache.lucene.document.Document old)
Disposes the document
old . |
static Comparable |
getComparable(InternalValue value)
Returns a comparable for the internal
value . |
static Comparable |
getComparable(javax.jcr.Value value)
Returns a comparable for the internal
value . |
static long |
getLength(InternalValue value)
Returns length of the internal value.
|
static boolean |
isDocumentReady(org.apache.lucene.document.Document doc)
Returns
true if the document is ready to be added to the
index. |
public static void disposeDocument(org.apache.lucene.document.Document old)
old
. Closes any potentially open
readers held by the document.old
- the document to dispose.public static boolean isDocumentReady(org.apache.lucene.document.Document doc)
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.public static org.apache.lucene.search.Query createMatchAllQuery(String name, IndexFormatVersion version, org.apache.jackrabbit.core.query.lucene.PerQueryCache cache)
name
.name
- the property name.version
- the index format version.name
.public static IOException createIOException(Throwable t)
IOException
with t
as its cause.t
- the cause.public static void closeOrRelease(org.apache.lucene.index.IndexReader reader) throws IOException
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.public static Comparable getComparable(InternalValue value) throws javax.jcr.RepositoryException
value
.value
- an internal value.value
.javax.jcr.RepositoryException
- if retrieving the Comparable
fails.public static Comparable getComparable(javax.jcr.Value value) throws javax.jcr.ValueFormatException, javax.jcr.RepositoryException
value
.value
- an internal value.value
.javax.jcr.ValueFormatException
- if the given value
cannot be converted into a
comparable (i.e. unsupported type).javax.jcr.RepositoryException
- if an error occurs while converting the value.public static int compare(Comparable c1, Comparable c2)
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.c1
should come before
c2
c1
should come after
c2
0
if they are equal.public static int compare(Comparable<?>[] c1, Comparable<?>[] c2)
compare(Value[], Value[])
.
The 2 methods *have* to work in the same way for the sort to be
consistentpublic static int compare(javax.jcr.Value[] a, javax.jcr.Value[] b) throws javax.jcr.RepositoryException
compare(Comparable[], Comparable[])
.
The 2 methods *have* to work in the same way for the sort to be
consistentjavax.jcr.RepositoryException
public static int compare(javax.jcr.Value v1, javax.jcr.Value v2) throws javax.jcr.ValueFormatException, javax.jcr.RepositoryException
Comparison of binary values is not supported.
v1
- the first value.v2
- the second value.Comparable.compareTo(Object)
.javax.jcr.ValueFormatException
- if the given value
cannot be converted into a
comparable (i.e. unsupported type).javax.jcr.RepositoryException
- if an error occurs while converting the value.public static Pattern createRegexp(String likePattern)
likePattern
.likePattern
- the pattern.Pattern
.public static long getLength(InternalValue value)
value
- a value.-1
if the length
cannot be determined.Copyright © 2004-2020 The Apache Software Foundation. All Rights Reserved.