Operations may throw RDFDataException if the list is not well-formed.
Operations check for exactly rdf:first, and exactly one rdf:rest,
but do not check for cycles unless noted in their javadoc.
To get a list of all the items in a list, use members(org.apache.jena.graph.Graph, org.apache.jena.graph.Node) operations, which
does check for cycles, or if the list is known to be well-formed, one of the elements(org.apache.jena.graph.Graph, org.apache.jena.graph.Node)
operations, which do not check for cycles.
The contains(org.apache.jena.graph.Graph, org.apache.jena.graph.Node, org.apache.jena.graph.Node) operation does not check for cycles so that repeated use on
a list does not perform duplicate checking work repeatedly.
If a list is potentially mal-formed by having a cycle, check first with
isWellformedList(Graph, Node) or
isWellformedListEx(Graph, Node).
List validation only needs to be performed once.
List arising from parsing Turtle or TriG syntax for lists will be cycle-free.
This class is not public API.
See also GraphList which uses a "findable" abstraction in combination
with GNode to work on a graph or lists of triples.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleancontains(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node list, org.apache.jena.graph.Node item) Return whether an item is in the list.static List<org.apache.jena.graph.Node> elements(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node list) Return the elements of a well-formed RDF list.static voidelements(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node list, Collection<org.apache.jena.graph.Node> acc) Accumulate the elements of a well-formed RDF list.static voidforEach(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node list, Consumer<org.apache.jena.graph.Node> action) Run an action on each element of a list, in order.static org.apache.jena.graph.Nodeget(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node list, int index) Return the list element at an index (indexes start at 0).static intindexOf(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node list, org.apache.jena.graph.Node item) Return the first index of an occurrence of a node in a list.static booleanisListNode(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node node) static booleanisWellformedList(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node list) Check for a valid list; return true if well-formed else return false.static booleanisWellformedList(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node list, boolean closedCells) Check for a valid list; return true if well-formed else return false.static voidisWellformedListEx(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node list) Check for a valid list; throw aRDFDataExceptionif the list is bad in some way.static voidisWellformedListEx(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node list, boolean closedCells) Check for a valid list; throw aRDFDataExceptionif the list is bad in some way.static Iterator<org.apache.jena.graph.Node> iterator(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node list) Return an iterator over the list.static longlistLength(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node list) Return the length of a well-formed list.static List<org.apache.jena.graph.Node> members(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node list) Return the members of a well-formed RDF list.static voidmembers(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node list, Collection<org.apache.jena.graph.Node> acc) Accumulate the members of a well-formed RDF list.
-
Constructor Details
-
GList
public GList()
-
-
Method Details
-
isWellformedListEx
public static void isWellformedListEx(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node list) Check for a valid list; throw aRDFDataExceptionif the list is bad in some way. TheRDFDataExceptionmessage indicates the problem with the list.- Parameters:
graph-list-
-
isWellformedListEx
public static void isWellformedListEx(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node list, boolean closedCells) Check for a valid list; throw aRDFDataExceptionif the list is bad in some way. TheRDFDataExceptionmessage indicates the problem with the list.- Parameters:
graph-list-closedCells- - whether to check that onlyrdf:firstandrdf:nextare used on a list cell
-
isWellformedList
public static boolean isWellformedList(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node list) Check for a valid list; return true if well-formed else return false. UseisWellformedListEx(Graph, Node)to get an except with an informational message about the problem detected.- Parameters:
graph-list-
-
isWellformedList
public static boolean isWellformedList(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node list, boolean closedCells) Check for a valid list; return true if well-formed else return false. UseisWellformedListEx(Graph, Node, boolean)to get an except with an informational message about the problem detected.- Parameters:
graph-list-closedCells- - whether to check that only rdf:first and rdf:next are used on a list cell
-
members
public static List<org.apache.jena.graph.Node> members(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node list) Return the members of a well-formed RDF list.- Throws:
RDFDataException- if the list is not well-formed, including if it has a cycle.
-
members
public static void members(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node list, Collection<org.apache.jena.graph.Node> acc) Accumulate the members of a well-formed RDF list.- Throws:
RDFDataException- if the list is not well-formed, including if it has a cycle.
-
elements
public static List<org.apache.jena.graph.Node> elements(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node list) Return the elements of a well-formed RDF list. This operation does not check for cycles.members(org.apache.jena.graph.Graph, org.apache.jena.graph.Node)is has the same result and incorporates a well-formness cycle check. -
elements
public static void elements(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node list, Collection<org.apache.jena.graph.Node> acc) Accumulate the elements of a well-formed RDF list. This operation does not check for cycles. -
forEach
public static void forEach(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node list, Consumer<org.apache.jena.graph.Node> action) Run an action on each element of a list, in order.- See Also:
-
listLength
public static long listLength(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node list) Return the length of a well-formed list. This operations assumes the list is well-formed. SeeisWellformedList(Graph, Node)for check a list. -
iterator
public static Iterator<org.apache.jena.graph.Node> iterator(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node list) Return an iterator over the list. The iterator does not check for well-formed lists. Ensure the list is well-formed -isWellformedListEx(Graph, Node).- See Also:
-
indexOf
public static int indexOf(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node list, org.apache.jena.graph.Node item) Return the first index of an occurrence of a node in a list. Return -1 for not in list. Indexes start at 0.- Parameters:
graph-list-item- to check
-
contains
public static boolean contains(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node list, org.apache.jena.graph.Node item) Return whether an item is in the list. Return for not in list.- Parameters:
graph-list-item- to check for
-
get
public static org.apache.jena.graph.Node get(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node list, int index) Return the list element at an index (indexes start at 0).Do not use this to iterate over a list - consider using
members(org.apache.jena.graph.Graph, org.apache.jena.graph.Node)to collect the list in a single pass. -
isListNode
public static boolean isListNode(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node node)
-