| java.lang.Object com.hp.hpl.jena.enhanced.Polymorphic com.hp.hpl.jena.enhanced.EnhNode com.hp.hpl.jena.rdf.model.impl.ResourceImpl com.hp.hpl.jena.rdf.model.impl.RDFListImpl
RDFListImpl | public class RDFListImpl extends ResourceImpl implements RDFList(Code) | |
Standard implementation the list abstraction from rdf.model.
author: Ian Dickinson, HP Labs author: (email) version: CVS $Id: RDFListImpl.java,v 1.17 2008/01/02 12:05:10 andy_seaborne Exp $ |
Inner Class :protected class RDFListIterator extends NiceIterator | |
Constructor Summary | |
public | RDFListImpl(Node n, EnhGraph g)
Construct an implementation of RDFList in the given graph, where the
given node is the head of the list. |
Method Summary | |
public void | add(RDFNode value)
Add the given value to the end of the list. | public RDFList | append(Iterator nodes)
Answer a new list that is formed by adding each element of this list to
the head of the the list formed from the
given nodes . | public RDFList | append(RDFList list)
Answer a new list that is formed by adding each element of this list to
the head of the given list . | public void | apply(ApplyFn fn)
Apply a function to each value in the list in turn. | public List | asJavaList()
Answer the contents of this RDF list as a Java list of RDFNode values. | protected void | checkNotNil(String msg)
Check that the current list cell is not the nil list, and throw an empty
list exception if it is. | protected void | checkValid()
Answer true if this is a valid list cell, which means either that it
is nil, or it has the appropriate type and a first and next relation.
Updated 17-06-2003: RDFCore last comments process has decided that the
rdf:type of a list is implied by the domain constraints on rdf:first
and rdf:rest, so no longer needs to be asserted directly. | public Set | collectStatements() | public void | concatenate(RDFList list)
Change the tail of this list to point to the given list, so that this
list becomes the list of the concatenation of the elements of both lists.
This is a side-effecting operation on this list; for a non side-effecting
alternative, see
RDFListImpl.append . | public void | concatenate(Iterator nodes)
Add the nodes returned by the given iterator to the end of this list. | public RDFList | cons(RDFNode value)
Return a reference to a new list cell whose head is value
and whose tail is this list. | public boolean | contains(RDFNode value)
Answer true if the given node appears as the value of a value of any
of the cells of this list. | public RDFList | copy()
Answer a list that contains all of the elements of this list in the same
order, but is a duplicate copy in the underlying model. | protected RDFList | copy(Iterator i)
Create a copy of the list of nodes returned by an iterator. | protected RDFList | findElement(boolean last, int index)
Find and return an element of this list - either the last element before
the end of the list, or the i'th element from the front (starting from
zero). | public RDFNode | get(int i)
Answer the node that is the i'th element of the list, assuming that the
head is item zero. | public RDFNode | getHead()
Answer the value that is at the head of the list. | public boolean | getStrict()
Answer true lists are operating in strict mode, in which the
well- formedness of the list is checked at every operation. | public RDFList | getTail()
Answer the list that is the tail of this list. | public String | getValidityErrorMessage()
Answer the error message returned by the last failed validity check,
if any. | public int | indexOf(RDFNode value)
Answer the index of the first occurrence of the given value in the list,
or -1 if the value is not in the list. | public int | indexOf(RDFNode value, int start)
Answer the index of the first occurrence of the given value in the list
after index start , or -1 if the value is not in the list
after the given start point. | public boolean | isEmpty() Answer true if this list is the empty list. | public boolean | isValid()
Answer true if the list is well-formed, by checking that each node is
correctly typed, and has a head and tail pointer from the correct
vocabulary. | public ExtendedIterator | iterator()
Answer an iterator over the elements of the list. | public Class | listAbstractionClass() | public Property | listFirst() | public Resource | listNil() | public Property | listRest() | public Resource | listType() | public ExtendedIterator | mapWith(Map1 fn) | public Resource | newListCell(RDFNode value, Resource tail)
Construct a new list cell with the given value and tail. | public Object | reduce(ReduceFn fn, Object initial)
Apply a function to each value in the list in turn, accumulating the
results in an accumulator. | public RDFList | remove(RDFNode val) Remove the given value from this list. | public void | removeAll() Deprecated. | public RDFList | removeHead()
Remove the value from the head of the list. | public void | removeList() Remove all of the components of this list from the model. | public RDFNode | replace(int i, RDFNode value)
Replace the value at the i'th position in the list with the given value. | public boolean | sameListAs(RDFList list)
Answer true if this list has the same elements in the same order as the
given list. | public RDFNode | setHead(RDFNode value)
Update the head of the list to have the given value, and return the
previous value. | public void | setStrict(boolean strict)
Set a flag to indicate whether to strictly check the well-formedness of
lists at each operation. | public RDFList | setTail(RDFList tail)
Update the list cell at the front of the list to have the given list as
tail. | protected static Resource | setTailAux(Resource root, Resource tail, Property pTail)
Helper method for setting the list tail, that assumes we have
a resource that is a list.
Parameters: root - The resource representing the list cell we're setting thetail of Parameters: tail - The new tail for this list, as a resource. | public int | size()
Answer the number of elements in the list. | public RDFList | with(RDFNode value)
Answer the list that is this list with the given value added to the end
of the list. |
factory | public static Implementation factory(Code) | | A factory for generating RDFList facets from nodes in enhanced graphs.
|
m_errorMsg | protected String m_errorMsg(Code) | | Error message if validity check fails
|
m_listFirst | protected Property m_listFirst(Code) | | The URI for the 'first' property in this list
|
m_listNil | protected Resource m_listNil(Code) | | The URI for the 'nil' Resource in this list
|
m_listRest | protected Property m_listRest(Code) | | The URI for the 'rest' property in this list
|
m_listType | protected Resource m_listType(Code) | | The URI for the rdf:type of this list
|
m_tail | protected RDFList m_tail(Code) | | Pointer to the node that is the tail of the list
|
s_checkValid | protected static boolean s_checkValid(Code) | | Flag to indicate whether we are checking for valid lists during list operations. Default false.
|
RDFListImpl | public RDFListImpl(Node n, EnhGraph g)(Code) | |
Construct an implementation of RDFList in the given graph, where the
given node is the head of the list.
Parameters: n - The node that is the head of the list, currently Parameters: g - The enh graph that contains n |
add | public void add(RDFNode value)(Code) | |
Add the given value to the end of the list. This is a side-effecting
operation on the underlying model that is only defined if this is not the
empty list. If this list is the empty (nil) list, we cannot perform a
side-effecting update without changing the URI of this node (from rdf:nil RDFListImpl.with and
RDFListImpl.cons .
Parameters: value - A value to add to the end of the list exception: EmptyListUpdateException - if an attempt is made to add to the empty list. |
append | public RDFList append(Iterator nodes)(Code) | |
Answer a new list that is formed by adding each element of this list to
the head of the the list formed from the
given nodes . This is a non side-effecting
operation on either this list or the given list, but generates a copy
of this list. For a more storage efficient alternative, see
RDFListImpl.concatenate concatenate .
Parameters: nodes - An iterator whose range is RDFNode A new RDFList that contains all of this elements of this list,followed by all of the elements of the given iterator. |
append | public RDFList append(RDFList list)(Code) | |
Answer a new list that is formed by adding each element of this list to
the head of the given list . This is a non side-effecting
operation on either this list or the given list, but generates a copy
of this list. For a more storage efficient alternative, see
RDFListImpl.concatenate concatenate .
Parameters: list - The argument list A new RDFList that contains all of this elements of this list,followed by all of the elements of the given list. |
apply | public void apply(ApplyFn fn)(Code) | |
Apply a function to each value in the list in turn.
Parameters: fn - The function to apply to each list node. |
asJavaList | public List asJavaList()(Code) | |
Answer the contents of this RDF list as a Java list of RDFNode values.
The contents of this list as a Java List. |
checkNotNil | protected void checkNotNil(String msg)(Code) | |
Check that the current list cell is not the nil list, and throw an empty
list exception if it is.
Parameters: msg - The context message for the empty list exception exception: EmptyListException - if the list is the nil list |
checkValid | protected void checkValid()(Code) | |
Answer true if this is a valid list cell, which means either that it
is nil, or it has the appropriate type and a first and next relation.
Updated 17-06-2003: RDFCore last comments process has decided that the
rdf:type of a list is implied by the domain constraints on rdf:first
and rdf:rest, so no longer needs to be asserted directly. The test
for rdf:type has therefore been removed.
True if this list cell passes basic validity checks |
collectStatements | public Set collectStatements()(Code) | | Answer a set of all of the RDF statements whose subject is one of the cells
of this list.
A list of the statements that form the encoding of this list. |
concatenate | public void concatenate(RDFList list)(Code) | |
Change the tail of this list to point to the given list, so that this
list becomes the list of the concatenation of the elements of both lists.
This is a side-effecting operation on this list; for a non side-effecting
alternative, see
RDFListImpl.append . Due to the problem of maintaining
the URI invariant on a node, this operation will throw an exception if an
attempt is made to concatenate onto an empty list. To avoid this, test for
an empty list: if true replace the empty list with the argument list, otherwise
proceed with the concatenate as usual. An alternative solution is to use
RDFListImpl.append and replace the original list with the return value.
Parameters: list - The argument list to concatenate to this list exception: EmptyListUpdateException - if this list is the nil list |
concatenate | public void concatenate(Iterator nodes)(Code) | |
Add the nodes returned by the given iterator to the end of this list.
Parameters: nodes - An iterator whose range is RDFNode exception: EmptyListUpdateException - if this list is the nil list See Also: RDFListImpl.concatenate(RDFList) See Also: for details on avoiding the empty list update exception. |
cons | public RDFList cons(RDFNode value)(Code) | |
Return a reference to a new list cell whose head is value
and whose tail is this list.
Parameters: value - A new value to add to the head of the list The new list, whose head is value |
contains | public boolean contains(RDFNode value)(Code) | |
Answer true if the given node appears as the value of a value of any
of the cells of this list.
Parameters: value - A value to test for True if the list contains value. |
copy | public RDFList copy()(Code) | |
Answer a list that contains all of the elements of this list in the same
order, but is a duplicate copy in the underlying model.
A copy of the current list |
copy | protected RDFList copy(Iterator i)(Code) | |
Create a copy of the list of nodes returned by an iterator.
Parameters: i - An iterator of RDFNodes A list formed from all of the nodes of i, in sequence |
findElement | protected RDFList findElement(boolean last, int index)(Code) | |
Find and return an element of this list - either the last element before
the end of the list, or the i'th element from the front (starting from
zero). Note that this method assumes the pre-condition that
this is not the empty list.
Parameters: last - If true, find the element whose tail is nil Parameters: index - If last is false, find the index'th elementfrom the head of the list The list cell exception: ListIndexException - if try to access an element beyond the endof the list exception: InvalidListException - if try to find the end of a badly formedlist |
get | public RDFNode get(int i)(Code) | |
Answer the node that is the i'th element of the list, assuming that the
head is item zero. If the list is too short to have an i'th element,
throws a
ListIndexException .
Parameters: i - The index into the list, from 0 The list value at index i, or null exception: ListIndexException - if the list has fewer than (i + 1)elements. |
getHead | public RDFNode getHead()(Code) | |
Answer the value that is at the head of the list.
The value that is associated with the head of the list. exception: EmptyListException - if this list is the empty list |
getStrict | public boolean getStrict()(Code) | |
Answer true lists are operating in strict mode, in which the
well- formedness of the list is checked at every operation.
True lists are being strictly checked. |
getTail | public RDFList getTail()(Code) | |
Answer the list that is the tail of this list.
The tail of the list, as a list exception: EmptyListException - if this list is the empty list |
getValidityErrorMessage | public String getValidityErrorMessage()(Code) | |
Answer the error message returned by the last failed validity check,
if any.
The most recent error message, or null. |
indexOf | public int indexOf(RDFNode value)(Code) | |
Answer the index of the first occurrence of the given value in the list,
or -1 if the value is not in the list.
Parameters: value - The value to search for The index of the first occurrence of value in the list, or-1 if not found. |
indexOf | public int indexOf(RDFNode value, int start)(Code) | |
Answer the index of the first occurrence of the given value in the list
after index start , or -1 if the value is not in the list
after the given start point.
Parameters: value - The value to search for Parameters: start - The index into the list to start searching from The index (from zero, the front of the list) of the firstoccurrence of value in the list not less thanstart , or -1 if not found. exception: ListIndexException - if start is greater than thelength of the list. |
isEmpty | public boolean isEmpty()(Code) | | Answer true if this list is the empty list.
True if this is the empty (nil) list, otherwise false. |
isValid | public boolean isValid()(Code) | |
Answer true if the list is well-formed, by checking that each node is
correctly typed, and has a head and tail pointer from the correct
vocabulary.
True if the list is well-formed. |
iterator | public ExtendedIterator iterator()(Code) | |
Answer an iterator over the elements of the list. Note that this iterator
does not take a snapshot of the list, so changes to the list statements
in the model while iterating will affect the behaviour of the iterator.
To get an iterator that is not affected by model changes, use
RDFListImpl.asJavaList .
A closable iterator over the elements of the list. |
listAbstractionClass | public Class listAbstractionClass()(Code) | | |
mapWith | public ExtendedIterator mapWith(Map1 fn)(Code) | | Answer an iterator of the elements of this list, to each of which
the given map function has been applied.
Parameters: fn - A Map function The iterator of the elements of this list mapped with the given map function. |
newListCell | public Resource newListCell(RDFNode value, Resource tail)(Code) | |
Construct a new list cell with the given value and tail.
Parameters: value - The value at the head of the new list cell Parameters: tail - The tail of the list cell A new list cell as a resource |
reduce | public Object reduce(ReduceFn fn, Object initial)(Code) | |
Apply a function to each value in the list in turn, accumulating the
results in an accumulator. The final value of the accumulator is returned
as the value of reduce() .
Parameters: fn - The reduction function to apply Parameters: initial - The initial value for the accumulator The final value of the accumulator. |
remove | public RDFList remove(RDFNode val)(Code) | | Remove the given value from this list. If val does not occur in
the list, no action is taken. Since removing the head of the list will invalidate
the list head cell, in general the list must return the list that results from this
operation. However, in many cases the return value will be the same as the object
that this method is invoked on
Parameters: val - The value to be removed from the list The resulting list, which will be the same as the current list in mostcases, except when val occurs at the head of the list. |
removeAll | public void removeAll()(Code) | | Deprecated. Since an RDFList does not behave like a Java container, it is not
the case that the contents of the list can be removed and the container filled with values
again. Therefore, this method name has been deprecated in favour of
RDFListImpl.removeList
RDFListImpl.removeList |
removeHead | public RDFList removeHead()(Code) | |
Remove the value from the head of the list. The tail of the list remains
in the model. Note that no changes are made to list cells that point to
this list cell as their tail. Immediately following a
removeHead operation, such lists will be in a non-valid
state.
The remainder of the list after the head is removed (i.e. thepre-removal list tail) |
removeList | public void removeList()(Code) | | Remove all of the components of this list from the model. Once this operation
has completed, the
RDFList resource on which it was called will no
longer be a resource in the model, so further methods calls on the list object
(for example,
RDFListImpl.size will fail. Due to restrictions on the encoding
of lists in RDF, it is not possible to perform an operation which empties a list
and then adds further values to that list. Client code wishing to perform
such an operation should do so in two steps: first remove the old list, then
create a new list with the new contents. It is important that RDF statements
that reference the old list (in the object position) be updated to point
to the newly created list.
Note that this
is operation is only removing the list cells themselves, not the resources
referenced by the list - unless being the object of an rdf:first
statement is the only mention of that resource in the model.
|
replace | public RDFNode replace(int i, RDFNode value)(Code) | |
Replace the value at the i'th position in the list with the given value.
If the list is too short to have an i'th element, throws a
ListIndexException .
Parameters: i - The index into the list, from 0 Parameters: value - The new value to associate with the i'th list element The value that was previously at position i in the list exception: ListIndexException - if the list has fewer than (i + 1)elements. |
sameListAs | public boolean sameListAs(RDFList list)(Code) | |
Answer true if this list has the same elements in the same order as the
given list. Note that the standard equals test just tests
for equality of two given list cells. While such a test is sufficient
for many purposes, this test provides a broader equality definition, but
is correspondingly more expensive to test.
Parameters: list - The list to test against True if the given list and this list are the same length, andcontain equal elements in the same order. |
setHead | public RDFNode setHead(RDFNode value)(Code) | |
Update the head of the list to have the given value, and return the
previous value.
Parameters: value - The value that will become the value of the list head exception: EmptyListException - if this list is the empty list |
setStrict | public void setStrict(boolean strict)(Code) | |
Set a flag to indicate whether to strictly check the well-formedness of
lists at each operation. Default false. Note that the flag that is
manipulated is actually a static: it applies to all lists. However, RDFList
is a Java interface, and Java does not permit static methods in interfaces.
Parameters: strict - The static flag for whether lists will be checked strictly. |
setTail | public RDFList setTail(RDFList tail)(Code) | |
Update the list cell at the front of the list to have the given list as
tail. The old tail is returned, and remains in the model.
Parameters: tail - The new tail for this list. The old tail. |
setTailAux | protected static Resource setTailAux(Resource root, Resource tail, Property pTail)(Code) | |
Helper method for setting the list tail, that assumes we have
a resource that is a list.
Parameters: root - The resource representing the list cell we're setting thetail of Parameters: tail - The new tail for this list, as a resource. The old tail, as a resource. |
size | public int size()(Code) | |
Answer the number of elements in the list.
The length of the list as an integer |
with | public RDFList with(RDFNode value)(Code) | |
Answer the list that is this list with the given value added to the end
of the list. This operation differs from
RDFListImpl.add in that it will
always work, even on an empty list, but the return value is the updated
list. Specifically, in the case of adding a value to the empty list, the
returned list will not be the same as this list. Client code should
not assume that this is an in-place update, but should ensure that the resulting
list is asserted back into the graph into the appropriate relationships.
Parameters: value - A value to add to the end of the list The list that results from adding a value to the end of this list |
Methods inherited from com.hp.hpl.jena.rdf.model.impl.ResourceImpl | public Resource abort()(Code)(Java Doc) public Resource addLiteral(Property p, boolean o)(Code)(Java Doc) public Resource addLiteral(Property p, long o)(Code)(Java Doc) public Resource addLiteral(Property p, char o)(Code)(Java Doc) public Resource addLiteral(Property p, double o)(Code)(Java Doc) public Resource addLiteral(Property p, float o)(Code)(Java Doc) public Resource addLiteral(Property p, Object o)(Code)(Java Doc) public Resource addProperty(Property p, long o)(Code)(Java Doc) public Resource addProperty(Property p, float o)(Code)(Java Doc) public Resource addProperty(Property p, double o)(Code)(Java Doc) public Resource addProperty(Property p, String o)(Code)(Java Doc) public Resource addProperty(Property p, String o, String l)(Code)(Java Doc) public Resource addProperty(Property p, String lexicalForm, RDFDatatype datatype)(Code)(Java Doc) public Resource addProperty(Property p, RDFNode o)(Code)(Java Doc) public Resource addTypedProperty(Property p, boolean o)(Code)(Java Doc) public Resource addTypedProperty(Property p, Object o)(Code)(Java Doc) public Resource begin()(Code)(Java Doc) public Resource commit()(Code)(Java Doc) public AnonId getId()(Code)(Java Doc) public String getLocalName()(Code)(Java Doc) public Model getModel()(Code)(Java Doc) protected ModelCom getModelCom()(Code)(Java Doc) public String getNameSpace()(Code)(Java Doc) public Node getNode()(Code)(Java Doc) public Statement getProperty(Property p)(Code)(Java Doc) public Statement getRequiredProperty(Property p)(Code)(Java Doc) public String getURI()(Code)(Java Doc) public boolean hasLiteral(Property p, boolean o)(Code)(Java Doc) public boolean hasLiteral(Property p, long o)(Code)(Java Doc) public boolean hasLiteral(Property p, char o)(Code)(Java Doc) public boolean hasLiteral(Property p, double o)(Code)(Java Doc) public boolean hasLiteral(Property p, float o)(Code)(Java Doc) public boolean hasLiteral(Property p, Object o)(Code)(Java Doc) public boolean hasProperty(Property p)(Code)(Java Doc) public boolean hasProperty(Property p, String o)(Code)(Java Doc) public boolean hasProperty(Property p, String o, String l)(Code)(Java Doc) public boolean hasProperty(Property p, RDFNode o)(Code)(Java Doc) public boolean hasTypedProperty(Property p, boolean o)(Code)(Java Doc) public boolean hasURI(String uri)(Code)(Java Doc) public RDFNode inModel(Model m)(Code)(Java Doc) public StmtIterator listProperties(Property p)(Code)(Java Doc) public StmtIterator listProperties()(Code)(Java Doc) protected ModelCom mustHaveModel()(Code)(Java Doc) public Resource removeAll(Property p)(Code)(Java Doc) public Resource removeProperties()(Code)(Java Doc) public String toString()(Code)(Java Doc) public Object visitWith(RDFVisitor rv)(Code)(Java Doc)
|
|
|