com.hp.hpl.jena.daml.common
Class PropertyAccessorImpl

java.lang.Object
  |
  +--com.hp.hpl.jena.daml.common.PropertyAccessorImpl
All Implemented Interfaces:
PropertyAccessor
Direct Known Subclasses:
LiteralAccessorImpl

public class PropertyAccessorImpl
extends java.lang.Object
implements PropertyAccessor

Encapsulates the standard methods of modifying a property on a DAML value.

Version:
CVS info: $Id: PropertyAccessorImpl.java,v 1.2 2002/02/27 13:39:07 ian_dickinson Exp $
Author:
Ian Dickinson, HP Labs (email)

Constructor Summary
PropertyAccessorImpl(Property property, DAMLCommon val)
          Construct a new accessor for the given property, which takes the given value type as it range.
 
Method Summary
 void add(Resource value)
          Add a value to the encapsulated property.
 int count()
          Answer the number of values that the encapsulated property has in the RDF model.
 RDFNode get()
          Answer a general value of the encapsulated property.
 java.util.Iterator getAll(boolean closed)
          Answer an iteration over the values that this property has in the RDF model.
 DAMLCommon getDAMLValue()
          Answer a value of the encapsulated property, making the assumption that it is a DAML value.
 Property getProperty()
          Answer the property that this accessor works on
 boolean hasValue(DAMLCommon value)
          Answer true if the encapsulated property has the given value as one of its values.
 void remove(DAMLCommon value)
          Remove a value from the encapsulated property.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PropertyAccessorImpl

public PropertyAccessorImpl(Property property,
                            DAMLCommon val)
Construct a new accessor for the given property, which takes the given value type as it range.
Parameters:
property - The property that this accessor works on
val - The underlying DAML value that this is an accessor to
Method Detail

getProperty

public Property getProperty()
Answer the property that this accessor works on
Specified by:
getProperty in interface PropertyAccessor
Returns:
A property

count

public int count()
Answer the number of values that the encapsulated property has in the RDF model. Note that count counts all RDF values, so it is possible for this method to return a non-zero value, but getDAMLValue() to return null, if none of the values are DAML values.
Specified by:
count in interface PropertyAccessor
Returns:
The number RDF statements for this property in the model.

getAll

public java.util.Iterator getAll(boolean closed)
Answer an iteration over the values that this property has in the RDF model. Note that these values may be any RDF value, depending on what is in the model. Client code should only assume that the values return by the Iterator are RDFNode objects.
Specified by:
getAll in interface PropertyAccessor
Parameters:
closed - If true, and the property is transitive, generate the closure of the property starting from the encapsulated resource.
Returns:
An iteration over the RDF values of the encapsulated property.

get

public RDFNode get()
Answer a general value of the encapsulated property. If it has no values, answer null. If it has one value, answer that value. Otherwise, answer an undetermined member of the set of values. This version of the method makes no assumptions about the property value, other than it is an RDF node. This is the safest, most conservative, assumption. If it is known that a value is certain to be a DAML value, you can use getDAMLValue() instead.
Specified by:
get in interface PropertyAccessor
Returns:
A value for the encapsulated property in the RDF model, or null if the property has no value.

getDAMLValue

public DAMLCommon getDAMLValue()
Answer a value of the encapsulated property, making the assumption that it is a DAML value. If the property has no DAML value, answer null. If it has one DAML value, answer that value. Otherwise, answer an undetermined member of the set of values. This method is optimised to select only DAML values for the property - that is, values that extend DAMLCommon. This method will therefore answer null if there is no DAML value for the property, even if there is one or more vanilla-RDF values. For a more general version of this method, which returns all RDF values, see get().
Specified by:
getDAMLValue in interface PropertyAccessor
Returns:
A DAML value for the encapsulated property in the RDF model, or null if the property has no DAML value.

add

public void add(Resource value)
Add a value to the encapsulated property.
Specified by:
add in interface PropertyAccessor
Parameters:
value - The value to be added.

remove

public void remove(DAMLCommon value)
Remove a value from the encapsulated property.
Specified by:
remove in interface PropertyAccessor
Parameters:
value - The value to be removed.

hasValue

public boolean hasValue(DAMLCommon value)
Answer true if the encapsulated property has the given value as one of its values. Note: does not traverse the closure of the property.
Specified by:
hasValue in interface PropertyAccessor
Parameters:
value - A DAML value to test for
Returns:
True if the RDF model contains a statement giving a value for the encapsulated property matching the given value.


Copyright 2001 Hewlett-Packard. All Rights Reserved.