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

java.lang.Object
  |
  +--com.hp.hpl.mesa.rdf.jena.common.ModelCom
        |
        +--com.hp.hpl.mesa.rdf.jena.mem.ModelMem
              |
              +--com.hp.hpl.jena.daml.common.DAMLModelImpl
All Implemented Interfaces:
DAMLModel, Model, ModelCon, ModelI, RDFReaderF, RDFWriterF

public class DAMLModelImpl
extends ModelMem
implements DAMLModel

Implementation for the DAML model interface, which is a specialisation of a Jena RDF store for the application of storing and manipulating DAML objects. The specialisations include storing a set of DAML wrapper objects that provide a convenience interface to the underlying RDF statements, and providing a set of indexes for efficiently retrieving these objects.

TODO: this class should really not extend ModelMem, since that commits it to a particular storage model (in-memory storage). Brian is looking at refactoring the Jena Model implementations, to parameterise them on a storage module, rather than expressing that storage through the class hierarchy. Pending that change, I have decided to directly extend ModelMem.

Version:
CVS info: $Id: DAMLModelImpl.java,v 1.4 2002/01/03 17:59:01 ijd Exp $
Author:
Ian Dickinson, HP Labs (email)

Constructor Summary
DAMLModelImpl()
          Constructor, initialises internal data structures.
 
Method Summary
 DAMLClass createDAMLClass(java.lang.String uri)
          Create an (optionally anonymous) DAML class.
 DAMLDatatypeProperty createDAMLDatatypeProperty(java.lang.String uri)
          Create an (optionally anonymous) DAML datatype property.
 DAMLInstance createDAMLInstance(DAMLClass damlClass, java.lang.String uri)
          Create an (optionally anonymous) instance of the given class.
 DAMLList createDAMLList(java.lang.String uri)
          Create an (optionally anonymous) DAML list.
 DAMLObjectProperty createDAMLObjectProperty(java.lang.String uri)
          Create an (optionally anonymous) DAML object property.
 DAMLOntology createDAMLOntology()
          Create an Ontology (big-'O') element, which holds meta-information for the ontology (small-'o').
 DAMLProperty createDAMLProperty(java.lang.String uri)
          Create an (optionally anonymous) DAML property.
 DAMLRestriction createDAMLRestriction(java.lang.String uri)
          Create an (optionally anonymous) DAML Restriction.
 DAMLCommon createDAMLValue(java.lang.String uri, Resource damlClass, DAMLVocabulary vocabulary)
          Create a new DAML value that is a member of the given class.
 DAMLCommon getDAMLValue(java.lang.String uri)
          Answer the DAML value that corresponds to the given URI, if it exists in the model.
 DAMLCommon getDAMLValue(java.lang.String uri, DAMLClass damlClass, DAMLVocabulary vocabulary)
          Answer the DAML value that corresponds to the given URI, if it exists in the model.
 XMLDatatypeRegistry getDatatypeRegistry()
          Answer a reference to the XML datatype registry for this model, that can be used to map between XML data marked up using XML Schema data descriptions, and Java objects.
 DAMLLoader getLoader()
          Answer the DAML Loader that is used by this store to load DAML source documents.
 boolean getLoadSuccessful()
          Answer true if the most recent load operation was successful.
 boolean getUseEquivalence()
          Answer true if the model will consider equivalence classes when accessing properties and resources.
 java.util.Iterator listDAMLClasses()
          Answer an iterator over all DAML classes that are presently in the model.
 java.util.Iterator listDAMLInstances()
          Answer an iterator over all DAML instances that are presently in the model.
 java.util.Iterator listDAMLProperties()
          Answer an iterator over all DAML properties that are presently in the model.
 Model read(java.io.Reader in, java.lang.String base)
          Read the ontology from the given reader, assuming that its base URI is the given URI.
 Model read(java.io.Reader in, java.lang.String base, java.lang.String lang)
          Read the ontology from the given reader, assuming that its base URI is the given URI.
 Model read(java.lang.String uri)
          Read the ontology indicated by the given uri.
 Model read(java.lang.String uri, java.lang.String lang)
          Read the ontology indicated by the given uri.
 Model read(java.lang.String uri, java.lang.String base, java.lang.String lang)
          Read the ontology indicated by the given uri.
 void setUseEquivalence(boolean useEquivalence)
          Flag to control whether accessing the DAML store will take into account equivalence classes for properties and resources, using daml:equivalentTo and similar statements.
 
Methods inherited from class com.hp.hpl.mesa.rdf.jena.mem.ModelMem
difference, intersection, query, supportsSetOperations, supportsTransactions, union
 
Methods inherited from class com.hp.hpl.mesa.rdf.jena.common.ModelCom
abort, add, add, add, add, add, add, add, add, add, add, add, add, add, add, begin, close, commit, containerContains, containerIndexOf, containerSize, contains, contains, contains, contains, contains, contains, contains, contains, contains, contains, contains, containsAll, containsAll, containsAny, containsAny, convert, convert, convert, createAlt, createAlt, createBag, createBag, createLiteral, createLiteral, createLiteral, createLiteral, createLiteral, createLiteral, createLiteral, createLiteral, createLiteral, createProperty, createProperty, createResource, createResource, createResource, createResource, createResource, createResource, createSeq, createSeq, createStatement, createStatement, createStatement, createStatement, createStatement, createStatement, createStatement, createStatement, createStatement, createStatement, createStatement, equals, getAlt, getAlt, getBag, getBag, getProperty, getProperty, getProperty, getReader, getReader, getResource, getResource, getSeq, getSeq, getWriter, getWriter, independent, isReified, listContainerMembers, listNameSpaces, listObjects, listObjectsOfProperty, listObjectsOfProperty, listReifiedStatements, listStatements, listStatements, listSubjects, listSubjectsWithProperty, listSubjectsWithProperty, listSubjectsWithProperty, listSubjectsWithProperty, listSubjectsWithProperty, listSubjectsWithProperty, listSubjectsWithProperty, listSubjectsWithProperty, listSubjectsWithProperty, listSubjectsWithProperty, remove, remove, remove, setReaderClassName, setWriterClassName, size, write, write, write
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.hp.hpl.mesa.rdf.jena.model.Model
abort, add, add, add, begin, close, commit, contains, contains, contains, containsAll, containsAll, containsAny, containsAny, createLiteral, createLiteral, createProperty, createResource, createResource, createStatement, difference, equals, getProperty, getProperty, getResource, independent, intersection, isReified, listNameSpaces, listObjects, listObjectsOfProperty, listObjectsOfProperty, listReifiedStatements, listStatements, listStatements, listSubjects, listSubjectsWithProperty, listSubjectsWithProperty, query, remove, size, supportsSetOperations, supportsTransactions, union, write, write, write
 
Methods inherited from interface com.hp.hpl.mesa.rdf.jena.model.ModelCon
add, add, add, add, add, add, add, add, add, add, add, contains, contains, contains, contains, contains, contains, contains, contains, createAlt, createAlt, createBag, createBag, createLiteral, createLiteral, createLiteral, createLiteral, createLiteral, createLiteral, createLiteral, createProperty, createResource, createResource, createResource, createResource, createSeq, createSeq, createStatement, createStatement, createStatement, createStatement, createStatement, createStatement, createStatement, createStatement, createStatement, createStatement, getAlt, getAlt, getBag, getBag, getProperty, getResource, getSeq, getSeq, listSubjectsWithProperty, listSubjectsWithProperty, listSubjectsWithProperty, listSubjectsWithProperty, listSubjectsWithProperty, listSubjectsWithProperty, listSubjectsWithProperty, listSubjectsWithProperty, remove, remove
 
Methods inherited from interface com.hp.hpl.mesa.rdf.jena.model.RDFReaderF
getReader, getReader, setReaderClassName
 
Methods inherited from interface com.hp.hpl.mesa.rdf.jena.model.RDFWriterF
getWriter, getWriter, setWriterClassName
 
Methods inherited from interface com.hp.hpl.mesa.rdf.jena.common.ModelI
containerContains, containerIndexOf, containerSize, convert, convert, convert, listContainerMembers
 

Constructor Detail

DAMLModelImpl

public DAMLModelImpl()
Constructor, initialises internal data structures.
Method Detail

createDAMLOntology

public DAMLOntology createDAMLOntology()
Create an Ontology (big-'O') element, which holds meta-information for the ontology (small-'o'). N.B. This does not create a new ontology, it simply makes an entry in the current model.
Specified by:
createDAMLOntology in interface DAMLModel
Returns:
A new DAMLOntology object, which is created by adding the appropriate statements to the RDF model.

createDAMLInstance

public DAMLInstance createDAMLInstance(DAMLClass damlClass,
                                       java.lang.String uri)
Create an (optionally anonymous) instance of the given class.
Specified by:
createDAMLInstance in interface DAMLModel
Parameters:
damlClass - The class of the newly created DAMLInstance
uri - The URI for the new instance, or null to create an anonymous instance.
Returns:
A new DAMLInstance object, which is created by adding the appropriate statements to the RDF model.

createDAMLClass

public DAMLClass createDAMLClass(java.lang.String uri)
Create an (optionally anonymous) DAML class.
Specified by:
createDAMLClass in interface DAMLModel
Parameters:
uri - The URI for the new class, or null to create an anonymous class.
Returns:
A new DAMLClass object, which is created by adding the appropriate statements to the RDF model.

createDAMLProperty

public DAMLProperty createDAMLProperty(java.lang.String uri)
Create an (optionally anonymous) DAML property. Note that it is recommended to use one of the more specific property classes from the new DAML release: see createDAMLObjectProperty(java.lang.String) or createDAMLDatatypeProperty(java.lang.String).
Specified by:
createDAMLProperty in interface DAMLModel
Parameters:
uri - The URI for the new property, or null to create an anonymous property.
Returns:
A new DAMLProperty object, which is created by adding the appropriate statements to the RDF model.

createDAMLObjectProperty

public DAMLObjectProperty createDAMLObjectProperty(java.lang.String uri)
Create an (optionally anonymous) DAML object property.
Specified by:
createDAMLObjectProperty in interface DAMLModel
Parameters:
uri - The URI for the new object property, or null to create an anonymous object property.
Returns:
A new DAMLObjectProperty object, which is created by adding the appropriate statements to the RDF model.

createDAMLDatatypeProperty

public DAMLDatatypeProperty createDAMLDatatypeProperty(java.lang.String uri)
Create an (optionally anonymous) DAML datatype property.
Specified by:
createDAMLDatatypeProperty in interface DAMLModel
Parameters:
uri - The URI for the new datatype property, or null to create an anonymous datatype property.
Returns:
A new DAMLDatatypeProperty object, which is created by adding the appropriate statements to the RDF model.

createDAMLList

public DAMLList createDAMLList(java.lang.String uri)
Create an (optionally anonymous) DAML list.
Specified by:
createDAMLList in interface DAMLModel
Parameters:
uri - The URI for the new list, or null to create an anonymous list.
Returns:
A new DAMLList object, which is created by adding the appropriate statements to the RDF model.

createDAMLRestriction

public DAMLRestriction createDAMLRestriction(java.lang.String uri)
Create an (optionally anonymous) DAML Restriction.
Specified by:
createDAMLRestriction in interface DAMLModel
Parameters:
uri - The URI for the new restriction, or null to create an anonymous restriction.
Returns:
A new DAMLRestriction object, which is created by adding the appropriate statements to the RDF model.

createDAMLValue

public DAMLCommon createDAMLValue(java.lang.String uri,
                                  Resource damlClass,
                                  DAMLVocabulary vocabulary)
Create a new DAML value that is a member of the given class. The appropriate DAMLCommon sub-class will be instantiated, so, for example, if the DAMLClass is DAML_OIL.Restriction, a DAMLRestriction object will be returned. Note that if a URI is given, and a value with that URI already exists in the model, that instance will be returned instead of creating a new DAML value. This is necessary to maintain consistency of the model.
Specified by:
createDAMLValue in interface DAMLModel
Parameters:
uri - The URI of the new DAML value, or null for an anonymous value
damlClass - The class to which the new DAML value will belong
vocabulary - The vocabulary to use for the new value, or null to use the default vocabulary.
Returns:
an instance of a DAMLCommon value that corresponds to the given class.

getDAMLValue

public DAMLCommon getDAMLValue(java.lang.String uri)
Answer the DAML value that corresponds to the given URI, if it exists in the model. If the URI does not match any of the resources presently in the model, null is returned.
Specified by:
getDAMLValue in interface DAMLModel
Parameters:
uri - The URI of the DAML resource to look for.
Returns:
An existing DAML resource from the model, matching uri, or null if no such resource is found.

getDAMLValue

public DAMLCommon getDAMLValue(java.lang.String uri,
                               DAMLClass damlClass,
                               DAMLVocabulary vocabulary)
Answer the DAML value that corresponds to the given URI, if it exists in the model. If the URI does not match any of the resources presently in the model, create a new DAML resource with the given URI and vocabulary, from the given DAML class.
Specified by:
getDAMLValue in interface DAMLModel
Parameters:
uri - The URI of the DAML resource to look for.
damlClass - The class of the new resource to create if no existing resource is found.
vocabulary - The vocabulary to use for the new value (if needed), or null to use the default vocabulary.
Returns:
An existing DAML resource from the model, matching uri, or a new resource if no existing resource is found.

listDAMLClasses

public java.util.Iterator listDAMLClasses()
Answer an iterator over all DAML classes that are presently in the model.
Specified by:
listDAMLClasses in interface DAMLModel
Returns:
an iterator over all currently defined classes (including Restrictions).

listDAMLProperties

public java.util.Iterator listDAMLProperties()
Answer an iterator over all DAML properties that are presently in the model.
Specified by:
listDAMLProperties in interface DAMLModel
Returns:
an iterator over all currently defined properties (i.e. rdf:Property and all sub-classes).

listDAMLInstances

public java.util.Iterator listDAMLInstances()
Answer an iterator over all DAML instances that are presently in the model.
Specified by:
listDAMLInstances in interface DAMLModel
Returns:
an iterator over all currently defined DAML instances.

read

public Model read(java.lang.String uri)
Read the ontology indicated by the given uri. Note that, depending on the settings in the embedded DAMLLoader, ontology import statements embedded in this document will be processed and the ontologies fetched and loaded.
Specified by:
read in interface Model
Overrides:
read in class ModelCom
Parameters:
uri - The URI identifying an ontology to be added, which is assumed to be represented in the XML serialisation of RDF.
Returns:
self.

read

public Model read(java.lang.String uri,
                  java.lang.String lang)
Read the ontology indicated by the given uri. Note that, depending on the settings in the embedded DAMLLoader, ontology import statements embedded in this document will be processed and the ontologies fetched and loaded.
Specified by:
read in interface Model
Overrides:
read in class ModelCom
Parameters:
uri - The URI identifying an ontology to be added, which is assumed to be represented in the XML serialisation of RDF.
lang - The encoding language of the source document
Returns:
self.

read

public Model read(java.io.Reader in,
                  java.lang.String base)
Read the ontology from the given reader, assuming that its base URI is the given URI. Note that, depending on the settings in the embedded DAMLLoader, ontology import statements embedded in this document will be processed and the ontologies fetched and loaded.
Specified by:
read in interface Model
Overrides:
read in class ModelCom
Parameters:
in - A reader, from which will be read the DAML definitions, which are assumed to be represented in the XML serialisation of RDF.
base - The base URI for any relative definitions that are loaded.
Returns:
self.

read

public Model read(java.lang.String uri,
                  java.lang.String base,
                  java.lang.String lang)
Read the ontology indicated by the given uri. Note that, depending on the settings in the embedded DAMLLoader, ontology import statements embedded in this document will be processed and the ontologies fetched and loaded.
Specified by:
read in interface DAMLModel
Parameters:
uri - The URI identifying an ontology to be added.
base - The base URI for any relative names that are loaded from the source document
lang - Denotes the language the statements are represented in.
Returns:
self.
See Also:
Model.read( java.lang.String, java.lang.String )

read

public Model read(java.io.Reader in,
                  java.lang.String base,
                  java.lang.String lang)
Read the ontology from the given reader, assuming that its base URI is the given URI. Note that, depending on the settings in the embedded DAMLLoader, ontology import statements embedded in this document will be processed and the ontologies fetched and loaded. Use getLoadSuccessful() to check whether the load operation was successful.
Specified by:
read in interface Model
Overrides:
read in class ModelCom
Parameters:
in - A reader, from which will be read the DAML definitions.
base - The base URI for any relative definitions that are loaded.
lang - Denotes the language the statements are represented in.
Returns:
self.

getLoader

public DAMLLoader getLoader()
Answer the DAML Loader that is used by this store to load DAML source documents. Fine control over loading policy, such as whether imported ontologies are automatically loaded, are controlled by the loader class.
Specified by:
getLoader in interface DAMLModel
Returns:
a reference to this model's loader.

getLoadSuccessful

public boolean getLoadSuccessful()
Answer true if the most recent load operation was successful. If not, consult DAMLLoader.getStatus() for details, and check error log.
Specified by:
getLoadSuccessful in interface DAMLModel
Returns:
true if the most recent model load was successful

getDatatypeRegistry

public XMLDatatypeRegistry getDatatypeRegistry()
Answer a reference to the XML datatype registry for this model, that can be used to map between XML data marked up using XML Schema data descriptions, and Java objects. This registry is also used to detect resources in the model that correspond to DAMLDataInstance objects, and type declarations that correspond to DAMLDatatype objects.
Specified by:
getDatatypeRegistry in interface DAMLModel
Returns:
an XML data translator registry

setUseEquivalence

public void setUseEquivalence(boolean useEquivalence)
Flag to control whether accessing the DAML store will take into account equivalence classes for properties and resources, using daml:equivalentTo and similar statements. Turning this flag on is correct according to the DAML semantics, but will impose a significant performance problem in the current version. Turning the flag off will improve performance, at the cost of not conforming strictly to the DAML specification.
Specified by:
setUseEquivalence in interface DAMLModel
Parameters:
useEquivalence - If true, accessing properties and resources will check for equivalent values, at a cost of reduced performance.

getUseEquivalence

public boolean getUseEquivalence()
Answer true if the model will consider equivalence classes when accessing properties and resources. See setUseEquivalence(boolean) for details.
Specified by:
getUseEquivalence in interface DAMLModel
Returns:
true if equivalence classes are being considered.


Copyright © 2001 Hewlett-Packard. All Rights Reserved.