Package de.isas.mztab2.cvmapping
Class JxPathElement
- java.lang.Object
-
- de.isas.mztab2.cvmapping.JxPathElement
-
public final class JxPathElement extends Object
Utility methods for simpler Java 8 compatible handling of JXPath selections and pointers.- Author:
- nilshoffmann
-
-
Constructor Summary
Constructors Constructor Description JxPathElement()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> List<org.apache.commons.lang3.tuple.Pair<org.apache.commons.jxpath.Pointer,T>>
toList(org.apache.commons.jxpath.JXPathContext context, String xpath, Class<? extends T> type)
Returns the elements selected by the xpath expression from the provided JXPathContext as a list of the given object type.static <T> List<org.apache.commons.lang3.tuple.Pair<org.apache.commons.jxpath.Pointer,T>>
toList(org.apache.commons.jxpath.Pointer pointer, Class<? extends T> type)
Wrap the provided pointer as a list of the given object type.static <T> Stream<T>
toStream(Iterator<? extends T> iter)
Wraps the provided typed iterator into a stream, based on Spliterators.static <T> Stream<T>
toStream(Iterator iter, Class<? extends T> type)
Creates a typed stream from an untyped (pre Java 6) iterator.static <T> Stream<org.apache.commons.lang3.tuple.Pair<org.apache.commons.jxpath.Pointer,T>>
toStream(org.apache.commons.jxpath.Pointer pointer, Class<? extends T> type)
Wrap the provided pointer as a stream of the given object type.static <T> Iterator<T>
typedIter(Iterator iter, Class<? extends T> type)
Creates a typed iterator from an untyped (pre Java 6) iterator.
-
-
-
Method Detail
-
toStream
public static <T> Stream<org.apache.commons.lang3.tuple.Pair<org.apache.commons.jxpath.Pointer,T>> toStream(org.apache.commons.jxpath.Pointer pointer, Class<? extends T> type)
Wrap the provided pointer as a stream of the given object type.- Type Parameters:
T
- the generic object type- Parameters:
pointer
- the pointer in the object treetype
- the object's type- Returns:
- a typed stream of pairs of pointer and typed object
-
toList
public static <T> List<org.apache.commons.lang3.tuple.Pair<org.apache.commons.jxpath.Pointer,T>> toList(org.apache.commons.jxpath.Pointer pointer, Class<? extends T> type)
Wrap the provided pointer as a list of the given object type.- Type Parameters:
T
- the generic object type- Parameters:
pointer
- the pointer in the object treetype
- the object's type- Returns:
- a typed list of pairs of pointer and typed object
-
toList
public static <T> List<org.apache.commons.lang3.tuple.Pair<org.apache.commons.jxpath.Pointer,T>> toList(org.apache.commons.jxpath.JXPathContext context, String xpath, Class<? extends T> type)
Returns the elements selected by the xpath expression from the provided JXPathContext as a list of the given object type.- Type Parameters:
T
- the generic object type- Parameters:
context
- the jxpath object tree contextxpath
- the xpath expression used for subtree / element selectiontype
- the object's type- Returns:
- a typed list of pairs of pointer and typed object
-
typedIter
public static <T> Iterator<T> typedIter(Iterator iter, Class<? extends T> type)
Creates a typed iterator from an untyped (pre Java 6) iterator.- Type Parameters:
T
- the generic object type- Parameters:
iter
- the original iteratortype
- the object's type- Returns:
- a typed iterator of the requested type, backed by the provided iterator.
-
toStream
public static <T> Stream<T> toStream(Iterator iter, Class<? extends T> type)
Creates a typed stream from an untyped (pre Java 6) iterator.- Type Parameters:
T
- the generic object type- Parameters:
iter
- the original iteratortype
- the object's type- Returns:
- a typed iterator of the requested type, backed by the provided iterator.
- See Also:
<T>typedIter(java.util.Iterator,java.lang.Class<? extends T>)
-
toStream
public static <T> Stream<T> toStream(Iterator<? extends T> iter)
Wraps the provided typed iterator into a stream, based on Spliterators.- Type Parameters:
T
- the generic object type- Parameters:
iter
- the original iterator- Returns:
- a typed (unbounded and ordered) stream, backed by the provided iterator.
-
-