com.hp.hpl.jena.ontology.daml
Interface DAMLList

All Superinterfaces:
FrontsNode, RDFList, RDFNode, Resource

public interface DAMLList
extends RDFList

Java representation of a DAML List. A list is the specified interpretation of rdf:parseType="daml:Collection" attributes, where a sequence of values is interpreted as a nested sequence of head/tail list cells. One consequence of this is that the list is quite specifically ordered, whereas the daml:collection is said to be an unordered collection. Consquently, we must caution that future versions of the DAML specificiation may create an unordered interpretation of daml:collection, and client code should not rely on the positionality of elements in the current list interpretation.

Version:
CVS info: $Id: DAMLList.java,v 1.6 2004/12/06 13:50:18 andy_seaborne Exp $
Author:
Ian Dickinson, HP Labs (email)

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.hp.hpl.jena.rdf.model.RDFList
RDFList.ApplyFn, RDFList.ReduceFn
 
Method Summary
 DAMLList cons(DAMLCommon value)
          Answer a new list formed by creating a new DAMLList element whose first is the given value and whose rest is the current list.
 DAMLList findLast()
          Find the last list element, i.e.
 ExtendedIterator getAll()
          Answer an iteration over the values in the list.
 int getCount()
          Answer a count of the items in the list.
 RDFNode getFirst()
          Answer the value at the head of the list.
 DAMLCommon getItem(int i)
          Answer the i'th element of the list, if it exists.
 DAMLList getNil()
          Answer the well-known constant denoting the nil list.
 DAMLList getRest()
          Answer the list that consists of all values of the list save the first.
 boolean isNil(Resource resource)
          Answer true if the given resource is the nil list.
 void setFirst(DAMLCommon value)
          Set the property daml:first for the given list element.
 void setRest(DAMLList tail)
          Set the property daml:rest for the given list element.
 void setRestNil()
          Set the property daml:rest for the given list element to be the nil list.
 
Methods inherited from interface com.hp.hpl.jena.rdf.model.RDFList
add, append, append, apply, asJavaList, concatenate, concatenate, cons, contains, copy, get, getHead, getStrict, getTail, getValidityErrorMessage, indexOf, indexOf, isEmpty, isValid, iterator, mapWith, reduce, remove, removeAll, removeHead, replace, sameListAs, setHead, setStrict, setTail, size, with
 
Methods inherited from interface com.hp.hpl.jena.rdf.model.Resource
abort, addProperty, addProperty, addProperty, addProperty, addProperty, addProperty, addProperty, addProperty, addProperty, begin, commit, equals, getId, getLocalName, getModel, getNameSpace, getNode, getProperty, getRequiredProperty, getURI, hasProperty, hasProperty, hasProperty, hasProperty, hasProperty, hasProperty, hasProperty, hasProperty, hasProperty, hasProperty, hasURI, isAnon, listProperties, listProperties, removeAll, removeProperties, toString
 
Methods inherited from interface com.hp.hpl.jena.rdf.model.RDFNode
as, canAs, inModel, visitWith
 
Methods inherited from interface com.hp.hpl.jena.graph.FrontsNode
asNode
 

Method Detail

getAll

ExtendedIterator getAll()
Answer an iteration over the values in the list.

Returns:
An iterator over the DAML values in the list

getFirst

RDFNode getFirst()

Answer the value at the head of the list. Since, strictly speaking, DAML collections are unordered, the position items in the list should not be relied on in client code, as the definition of 'first' in the list may change in future releases. However, the identity

      List L = L.getFirst() + L.getRest()
 
is guaranteed, providing that the contents of L do not change.

Returns:
The first value in the list.

cons

DAMLList cons(DAMLCommon value)

Answer a new list formed by creating a new DAMLList element whose first is the given value and whose rest is the current list. This is the 'cons' operator familiar from other list processing languages.

Parameters:
value - The new value to be added to the head of the list
Returns:
a new list whose daml:first is the value, and whose daml:rest is this list.

getRest

DAMLList getRest()

Answer the list that consists of all values of the list save the first. Since, strictly speaking, DAML collections are unordered, this corresponds to returning the collection minus an unspecified one of its values. However, the identity

      List L = L.getFirst() + L.getRest()
 
is guaranteed, providing that the contents of L do not change.

Returns:
a list that contains all the elements of the current list, save the first one.

getCount

int getCount()

Answer a count of the items in the list. Does not check for duplications, so this is the count of entries in the list, not the count of distinct items in the list.

Returns:
The number of entries in the list

setFirst

void setFirst(DAMLCommon value)

Set the property daml:first for the given list element. This is a single value that denotes the value at this position of the list.

Parameters:
value - The value to be assigned to the 'first' property of a list cell

setRest

void setRest(DAMLList tail)

Set the property daml:rest for the given list element. This is a single value that denotes the tail of the list.

Parameters:
tail - The value to be assigned to the tail of the list.

setRestNil

void setRestNil()

Set the property daml:rest for the given list element to be the nil list. This correctly terminates the list at this point.


getNil

DAMLList getNil()

Answer the well-known constant denoting the nil list.

Returns:
The resource denoting nil

isNil

boolean isNil(Resource resource)

Answer true if the given resource is the nil list.

Parameters:
resource - The resource to be tested
Returns:
true if the resource is the nil list

findLast

DAMLList findLast()

Find the last list element, i.e. the one whose rest is nil.

Returns:
A list element

getItem

DAMLCommon getItem(int i)

Answer the i'th element of the list, if it exists. If i is less than 1, or is larger than the length of the list, throw an illegal argument exception.

Parameters:
i - The position of the list to return
Returns:
The DAML value at the i'th position in the list
Throws:
ListIndexException - if i is less than one, or larger than the length of the list.


Copyright © 2000, 2001, 2002, 2003, 2004 Hewlett-Packard Development Company, LP