0001: /*****************************************************************************
0002: * Source code information
0003: * -----------------------
0004: * Original author Ian Dickinson, HP Labs Bristol
0005: * Author email Ian.Dickinson@hp.com
0006: * Package Jena 2
0007: * Web http://sourceforge.net/projects/jena/
0008: * Created 10 Feb 2003
0009: * Filename $RCSfile: OntModel.java,v $
0010: * Revision $Revision: 1.55 $
0011: * Release status $State: Exp $
0012: *
0013: * Last modified on $Date: 2008/01/23 12:47:17 $
0014: * by $Author: ian_dickinson $
0015: *
0016: * (c) Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
0017: * (see footer for full conditions)
0018: * ****************************************************************************/package com.hp.hpl.jena.ontology;
0019:
0020: // Imports
0021: ///////////////
0022: import com.hp.hpl.jena.graph.query.BindingQueryPlan;
0023: import com.hp.hpl.jena.ontology.event.OntEventManager;
0024: import com.hp.hpl.jena.rdf.model.*;
0025: import com.hp.hpl.jena.util.iterator.ExtendedIterator;
0026:
0027: import java.io.*;
0028: import java.util.*;
0029:
0030: /**
0031: * <p>
0032: * An enhanced view of a Jena model that is known to contain ontology
0033: * data, under a given ontology {@link Profile vocabulary} (such as OWL).
0034: * This class does not by itself compute the deductive extension of the graph
0035: * under the semantic rules of the language. Instead, we wrap an underlying
0036: * model with this ontology interface, that presents a convenience syntax for accessing
0037: * the language elements. Depending on the inference capability of the underlying model,
0038: * the OntModel will appear to contain more or less triples. For example, if
0039: * this class is used to wrap a plain memory or database model, only the
0040: * relationships asserted by the document will be reported through this
0041: * convenience API. Alternatively, if the OntModel wraps an OWL inferencing model,
0042: * the inferred triples from the extension will be reported as well. For
0043: * example, assume the following ontology fragment:
0044: * <code><pre>
0045: * :A rdf:type owl:Class .
0046: * :B rdf:type owl:Class ; rdfs:subClassOf :A .
0047: * :widget rdf:type :B .
0048: * </pre></code>
0049: * In a non-inferencing model, the <code>rdf:type</code> of the widget will be
0050: * reported as class <code>:B</code> only. In a model that can process the OWL
0051: * semantics, the widget's types will include <code>:B</code>, <code>:A</code>,
0052: * and <code>owl:Thing</code>.
0053: * </p>
0054: * <p>
0055: * <strong>Note:</strong> that <code>OntModel</code> is an extension to the
0056: * {@link InfModel} interface. This is to support the case where an ontology model
0057: * wraps an inference graph, and we want to make the special capabilities of the
0058: * <code>InfModel</code>, for example global consistency checking, accessible to
0059: * client programs. Since not all ont models use a reasoner, using these methods
0060: * may result in a runtime exception, though the typical behaviour is that such
0061: * calls will be silently ignored.
0062: * </p>
0063: *
0064: * @author Ian Dickinson, HP Labs
0065: * (<a href="mailto:Ian.Dickinson@hp.com" >email</a>)
0066: * @version CVS $Id: OntModel.java,v 1.55 2008/01/23 12:47:17 ian_dickinson Exp $
0067: */
0068: public interface OntModel extends InfModel {
0069: // Constants
0070: //////////////////////////////////
0071:
0072: // External signature methods
0073: //////////////////////////////////
0074:
0075: /**
0076: * <p>
0077: * Answer an iterator that ranges over the ontology resources in this model, i.e.
0078: * the resources with <code>rdf:type Ontology</code> or equivalent. These resources
0079: * typically contain metadata about the ontology document that contains them.
0080: * </p>
0081: * <p>
0082: * Specifically, the resources in this iterator will those whose type corresponds
0083: * to the value given in the ontology vocabulary associated with this model, see
0084: * {@link Profile#ONTOLOGY}.
0085: * </p>
0086: *
0087: * @return An iterator over ontology resources.
0088: */
0089: public ExtendedIterator listOntologies();
0090:
0091: /**
0092: * <p>
0093: * Answer an iterator that ranges over the property resources in this model, i.e.
0094: * the resources with <code>rdf:type Property</code> or equivalent. An <code>OntProperty</code>
0095: * is equivalent to an <code>rdfs:Property</code> in a normal RDF graph; this type is
0096: * provided as a common super-type for the more specific {@link ObjectProperty} and
0097: * {@link DatatypeProperty} property types.
0098: * </p>
0099: * <p><strong>Note</strong> This method searches for nodes in the underlying model whose
0100: * <code>rdf:type</code> is <code>rdf:Property</code>. This type is <em>entailed</em> by
0101: * specific property sub-types, such as <code>owl:ObjectProperty</code>. An important
0102: * consequence of this is that in <em>models without an attached reasoner</em> (e.g. in the
0103: * <code>OWL_MEM</code> {@link OntModelSpec}), the entailed type will not be present
0104: * and this method will omit such properties from the returned iterator. <br />
0105: * <strong>Solution</strong> There are two
0106: * ways to address to this issue: either use a reasoning engine to ensure that type entailments
0107: * are taking place correctly, or call {@link #listAllOntProperties()}. Note
0108: * that <code>listAllOntProperties</code> is potentially less efficient than this method.</p>
0109: * <p>
0110: * The resources returned by this iterator will those whose type corresponds
0111: * to the value given in the ontology vocabulary associated with this model.
0112: * </p>
0113: *
0114: * @return An iterator over property resources.
0115: */
0116: public ExtendedIterator listOntProperties();
0117:
0118: /**
0119: * <p>Answer an iterator over all of the ontology properties in this model, including
0120: * object properties, datatype properties, annotation properties, etc. This method
0121: * takes a different approach to calculating the set of property resources to return,
0122: * and is robust against the absence of a reasoner attached to the model (see note
0123: * in {@link #listOntProperties()} for explanation). However, the calculation used by
0124: * this method is potentially less efficient than the alternative <code>listOntProperties()</code>.
0125: * Users whose models have an attached reasoner are recommended to use
0126: * {@link #listOntProperties()}.</p>
0127: * @return An iterator over all available properties in a model, irrespective of
0128: * whether a reasoner is available to perform <code>rdf:type</code> entailments.
0129: * Each property will appear exactly once in the iterator.
0130: */
0131: public ExtendedIterator listAllOntProperties();
0132:
0133: /**
0134: * <p>
0135: * Answer an iterator that ranges over the object property resources in this model, i.e.
0136: * the resources with <code>rdf:type ObjectProperty</code> or equivalent. An object
0137: * property is a property that is defined in the ontology language semantics as a
0138: * one whose range comprises individuals (rather than datatyped literals).
0139: * </p>
0140: * <p>
0141: * Specifically, the resources in this iterator will those whose type corresponds
0142: * to the value given in the ontology vocabulary associated with this model: see
0143: * {@link Profile#OBJECT_PROPERTY}.
0144: * </p>
0145: *
0146: * @return An iterator over object property resources.
0147: */
0148: public ExtendedIterator listObjectProperties();
0149:
0150: /**
0151: * <p>
0152: * Answer an iterator that ranges over the datatype property resources in this model, i.e.
0153: * the resources with <code>rdf:type DatatypeProperty</code> or equivalent. An datatype
0154: * property is a property that is defined in the ontology language semantics as a
0155: * one whose range comprises datatyped literals (rather than individuals).
0156: * </p>
0157: * <p>
0158: * Specifically, the resources in this iterator will those whose type corresponds
0159: * to the value given in the ontology vocabulary associated with this model: see
0160: * {@link Profile#DATATYPE_PROPERTY}.
0161: * </p>
0162: *
0163: * @return An iterator over datatype property resources.
0164: */
0165: public ExtendedIterator listDatatypeProperties();
0166:
0167: /**
0168: * <p>
0169: * Answer an iterator that ranges over the functional property resources in this model, i.e.
0170: * the resources with <code>rdf:type FunctionalProperty</code> or equivalent. A functional
0171: * property is a property that is defined in the ontology language semantics as having
0172: * a unique domain element for each instance of the relationship.
0173: * </p>
0174: * <p>
0175: * Specifically, the resources in this iterator will those whose type corresponds
0176: * to the value given in the ontology vocabulary associated with this model: see
0177: * {@link Profile#FUNCTIONAL_PROPERTY}.
0178: * </p>
0179: *
0180: * @return An iterator over functional property resources.
0181: */
0182: public ExtendedIterator listFunctionalProperties();
0183:
0184: /**
0185: * <p>
0186: * Answer an iterator that ranges over the transitive property resources in this model, i.e.
0187: * the resources with <code>rdf:type TransitiveProperty</code> or equivalent.
0188: * </p>
0189: * <p>
0190: * Specifically, the resources in this iterator will those whose type corresponds
0191: * to the value given in the ontology vocabulary associated with this model: see
0192: * {@link Profile#TRANSITIVE_PROPERTY}.
0193: * </p>
0194: *
0195: * @return An iterator over transitive property resources.
0196: */
0197: public ExtendedIterator listTransitiveProperties();
0198:
0199: /**
0200: * <p>
0201: * Answer an iterator that ranges over the symmetric property resources in this model, i.e.
0202: * the resources with <code>rdf:type SymmetricProperty</code> or equivalent.
0203: * </p>
0204: * <p>
0205: * Specifically, the resources in this iterator will those whose type corresponds
0206: * to the value given in the ontology vocabulary associated with this model: see
0207: * {@link Profile#SYMMETRIC_PROPERTY}.
0208: * </p>
0209: *
0210: * @return An iterator over symmetric property resources.
0211: */
0212: public ExtendedIterator listSymmetricProperties();
0213:
0214: /**
0215: * <p>
0216: * Answer an iterator that ranges over the inverse functional property resources in this model, i.e.
0217: * the resources with <code>rdf:type InverseFunctionalProperty</code> or equivalent.
0218: * </p>
0219: * <p>
0220: * Specifically, the resources in this iterator will those whose type corresponds
0221: * to the value given in the ontology vocabulary associated with this model: see
0222: * {@link Profile#INVERSE_FUNCTIONAL_PROPERTY}.
0223: * </p>
0224: *
0225: * @return An iterator over inverse functional property resources.
0226: */
0227: public ExtendedIterator listInverseFunctionalProperties();
0228:
0229: /**
0230: * <p>
0231: * Answer an iterator that ranges over the individual resources in this model, i.e.
0232: * the resources with <code>rdf:type</code> corresponding to a class defined
0233: * in the ontology.
0234: * </p>
0235: *
0236: * @return An iterator over individual resources.
0237: */
0238: public ExtendedIterator listIndividuals();
0239:
0240: /**
0241: * <p>
0242: * Answer an iterator that ranges over the resources in this model that are
0243: * instances of the given class.
0244: * </p>
0245: *
0246: * @return An iterator over individual resources whose <code>rdf:type</code>
0247: * is <code>cls</code>.
0248: */
0249: public ExtendedIterator listIndividuals(Resource cls);
0250:
0251: /**
0252: * <p>
0253: * Answer an iterator that ranges over all of the various forms of class description resource
0254: * in this model. Class descriptions include {@linkplain #listEnumeratedClasses enumerated}
0255: * classes, {@linkplain #listUnionClasses union} classes, {@linkplain #listComplementClasses complement}
0256: * classes, {@linkplain #listIntersectionClasses intersection} classes, {@linkplain #listClasses named}
0257: * classes and {@linkplain #listRestrictions property restrictions}.
0258: * </p>
0259: * @return An iterator over class description resources.
0260: */
0261: public ExtendedIterator listClasses();
0262:
0263: /**
0264: * <p>Answer an iterator over the classes in this ontology model that represent
0265: * the uppermost nodes of the class hierarchy. Depending on the underlying
0266: * reasoner configuration, if any, these will be calculated as the classes
0267: * that have Top (i.e. <code>owl:Thing</code> or <code>daml:Thing</code>)
0268: * as a direct super-class, or the classes which have no declared super-class.</p>
0269: * @return An iterator of the root classes in the local class hierarchy
0270: */
0271: public ExtendedIterator listHierarchyRootClasses();
0272:
0273: /**
0274: * <p>
0275: * Answer an iterator that ranges over the enumerated class class-descriptions
0276: * in this model, i.e. the class resources specified to have a property
0277: * <code>oneOf</code> (or equivalent) and a list of values.
0278: * </p>
0279: *
0280: * @return An iterator over enumerated class resources.
0281: * @see Profile#ONE_OF
0282: */
0283: public ExtendedIterator listEnumeratedClasses();
0284:
0285: /**
0286: * <p>
0287: * Answer an iterator that ranges over the union class-descriptions
0288: * in this model, i.e. the class resources specified to have a property
0289: * <code>unionOf</code> (or equivalent) and a list of values.
0290: * </p>
0291: *
0292: * @return An iterator over union class resources.
0293: * @see Profile#UNION_OF
0294: */
0295: public ExtendedIterator listUnionClasses();
0296:
0297: /**
0298: * <p>
0299: * Answer an iterator that ranges over the complement class-descriptions
0300: * in this model, i.e. the class resources specified to have a property
0301: * <code>complementOf</code> (or equivalent) and a list of values.
0302: * </p>
0303: *
0304: * @return An iterator over complement class resources.
0305: * @see Profile#COMPLEMENT_OF
0306: */
0307: public ExtendedIterator listComplementClasses();
0308:
0309: /**
0310: * <p>
0311: * Answer an iterator that ranges over the intersection class-descriptions
0312: * in this model, i.e. the class resources specified to have a property
0313: * <code>intersectionOf</code> (or equivalent) and a list of values.
0314: * </p>
0315: *
0316: * @return An iterator over complement class resources.
0317: * @see Profile#INTERSECTION_OF
0318: */
0319: public ExtendedIterator listIntersectionClasses();
0320:
0321: /**
0322: * <p>
0323: * Answer an iterator that ranges over the named class-descriptions
0324: * in this model, i.e. resources with <code>rdf:type
0325: * Class</code> (or equivalent) and a node URI.
0326: * </p>
0327: *
0328: * @return An iterator over named class resources.
0329: */
0330: public ExtendedIterator listNamedClasses();
0331:
0332: /**
0333: * <p>
0334: * Answer an iterator that ranges over the property restriction class-descriptions
0335: * in this model, i.e. resources with <code>rdf:type
0336: * Restriction</code> (or equivalent).
0337: * </p>
0338: *
0339: * @return An iterator over restriction class resources.
0340: * @see Profile#RESTRICTION
0341: */
0342: public ExtendedIterator listRestrictions();
0343:
0344: /**
0345: * <p>
0346: * Answer an iterator that ranges over the properties in this model that are declared
0347: * to be annotation properties. Not all supported languages define annotation properties
0348: * (the category of annotation properties is chiefly an OWL innovation).
0349: * </p>
0350: *
0351: * @return An iterator over annotation properties.
0352: * @see Profile#getAnnotationProperties()
0353: */
0354: public ExtendedIterator listAnnotationProperties();
0355:
0356: /**
0357: * <p>
0358: * Answer an iterator that ranges over the nodes that denote pair-wise disjointness between
0359: * sets of classes.
0360: * </p>
0361: *
0362: * @return An iterator over AllDifferent nodes.
0363: */
0364: public ExtendedIterator listAllDifferent();
0365:
0366: /**
0367: * <p>Answer an iterator over the DataRange objects in this ontology, if there
0368: * are any.</p>
0369: * @return An iterator, whose values are {@link DataRange} objects.
0370: */
0371: public ExtendedIterator listDataRanges();
0372:
0373: /**
0374: * <p>
0375: * Answer a resource that represents an ontology description node in this model. If a resource
0376: * with the given URI exists in the model, and can be viewed as an Ontology, return the
0377: * Ontology facet, otherwise return null.
0378: * </p>
0379: *
0380: * @param uri The URI for the ontology node. Conventionally, this corresponds to the base URI
0381: * of the document itself.
0382: * @return An Ontology resource or null.
0383: */
0384: public Ontology getOntology(String uri);
0385:
0386: /**
0387: * <p>
0388: * Answer a resource that represents an Individual node in this model. If a resource
0389: * with the given URI exists in the model, and can be viewed as an Individual, return the
0390: * Individual facet, otherwise return null.
0391: * </p>
0392: *
0393: * @param uri The URI for the required individual
0394: * @return An Individual resource or null.
0395: */
0396: public Individual getIndividual(String uri);
0397:
0398: /**
0399: * <p>
0400: * Answer a resource representing an generic property in this model. If a property
0401: * with the given URI exists in the model, return the
0402: * OntProperty facet, otherwise return null.
0403: * </p>
0404: *
0405: * @param uri The URI for the property.
0406: * @return An OntProperty resource or null.
0407: */
0408: public OntProperty getOntProperty(String uri);
0409:
0410: /**
0411: * <p>
0412: * Answer a resource representing an object property in this model. If a resource
0413: * with the given URI exists in the model, and can be viewed as an ObjectProperty, return the
0414: * ObjectProperty facet, otherwise return null.
0415: * </p>
0416: *
0417: * @param uri The URI for the object property. May not be null.
0418: * @return An ObjectProperty resource or null.
0419: */
0420: public ObjectProperty getObjectProperty(String uri);
0421:
0422: /**
0423: * <p>Answer a resource representing a transitive property. If a resource
0424: * with the given URI exists in the model, and can be viewed as a TransitiveProperty, return the
0425: * TransitiveProperty facet, otherwise return null. </p>
0426: * @param uri The URI for the property. May not be null.
0427: * @return A TransitiveProperty resource or null
0428: */
0429: public TransitiveProperty getTransitiveProperty(String uri);
0430:
0431: /**
0432: * <p>Answer a resource representing a symmetric property. If a resource
0433: * with the given URI exists in the model, and can be viewed as a SymmetricProperty, return the
0434: * SymmetricProperty facet, otherwise return null. </p>
0435: * @param uri The URI for the property. May not be null.
0436: * @return A SymmetricProperty resource or null
0437: */
0438: public SymmetricProperty getSymmetricProperty(String uri);
0439:
0440: /**
0441: * <p>Answer a resource representing an inverse functional property. If a resource
0442: * with the given URI exists in the model, and can be viewed as a InverseFunctionalProperty, return the
0443: * InverseFunctionalProperty facet, otherwise return null. </p>
0444: * @param uri The URI for the property. May not be null.
0445: * @return An InverseFunctionalProperty resource or null
0446: */
0447: public InverseFunctionalProperty getInverseFunctionalProperty(
0448: String uri);
0449:
0450: /**
0451: * <p>
0452: * Answer a resource that represents datatype property in this model. . If a resource
0453: * with the given URI exists in the model, and can be viewed as a DatatypeProperty, return the
0454: * DatatypeProperty facet, otherwise return null.
0455: * </p>
0456: *
0457: * @param uri The URI for the datatype property. May not be null.
0458: * @return A DatatypeProperty resource or null
0459: */
0460: public DatatypeProperty getDatatypeProperty(String uri);
0461:
0462: /**
0463: * <p>
0464: * Answer a resource that represents an annotation property in this model. If a resource
0465: * with the given URI exists in the model, and can be viewed as an AnnotationProperty, return the
0466: * AnnotationProperty facet, otherwise return null.
0467: * </p>
0468: *
0469: * @param uri The URI for the annotation property. May not be null.
0470: * @return An AnnotationProperty resource or null
0471: */
0472: public AnnotationProperty getAnnotationProperty(String uri);
0473:
0474: /**
0475: * <p>Answer a resource presenting the {@link OntResource} facet, which has the given
0476: * URI. If no such resource is currently present in the model, return null.</p>
0477: * @param uri The URI of a resource
0478: * @return An OntResource with the given URI, or null
0479: */
0480: public OntResource getOntResource(String uri);
0481:
0482: /**
0483: * <p>Answer a resource presenting the {@link OntResource} facet, which
0484: * corresponds to the given resource but attached to this model.</p>
0485: * @param res An existing resource
0486: * @return An OntResource attached to this model that has the same URI
0487: * or anonID as the given resource
0488: */
0489: public OntResource getOntResource(Resource res);
0490:
0491: /**
0492: * <p>
0493: * Answer a resource that represents a class description node in this model. If a resource
0494: * with the given URI exists in the model, and can be viewed as an OntClass, return the
0495: * OntClass facet, otherwise return null.
0496: * </p>
0497: *
0498: * @param uri The URI for the class node, or null for an anonymous class.
0499: * @return An OntClass resource or null.
0500: */
0501: public OntClass getOntClass(String uri);
0502:
0503: /**
0504: * <p>Answer a resource representing the class that is the complement of another class. If a resource
0505: * with the given URI exists in the model, and can be viewed as a ComplementClass, return the
0506: * ComplementClass facet, otherwise return null. </p>
0507: * @param uri The URI of the new complement class.
0508: * @return A complement class or null
0509: */
0510: public ComplementClass getComplementClass(String uri);
0511:
0512: /**
0513: * <p>Answer a resource representing the class that is the enumeration of a list of individuals. If a resource
0514: * with the given URI exists in the model, and can be viewed as an EnumeratedClass, return the
0515: * EnumeratedClass facet, otherwise return null. </p>
0516: * @param uri The URI of the new enumeration class.
0517: * @return An enumeration class or null
0518: */
0519: public EnumeratedClass getEnumeratedClass(String uri);
0520:
0521: /**
0522: * <p>Answer a resource representing the class that is the union of a list of class descriptions. If a resource
0523: * with the given URI exists in the model, and can be viewed as a UnionClass, return the
0524: * UnionClass facet, otherwise return null. </p>
0525: * @param uri The URI of the new union class.
0526: * @return A union class description or null
0527: */
0528: public UnionClass getUnionClass(String uri);
0529:
0530: /**
0531: * <p>Answer a resource representing the class that is the intersection of a list of class descriptions. If a resource
0532: * with the given URI exists in the model, and can be viewed as a IntersectionClass, return the
0533: * IntersectionClass facet, otherwise return null. </p>
0534: * @param uri The URI of the new intersection class.
0535: * @return An intersection class description or null
0536: */
0537: public IntersectionClass getIntersectionClass(String uri);
0538:
0539: /**
0540: * <p>
0541: * Answer a resource that represents a property restriction in this model. If a resource
0542: * with the given URI exists in the model, and can be viewed as a Restriction, return the
0543: * Restriction facet, otherwise return null.
0544: * </p>
0545: *
0546: * @param uri The URI for the restriction node.
0547: * @return A Restriction resource or null
0548: */
0549: public Restriction getRestriction(String uri);
0550:
0551: /**
0552: * <p>Answer a class description defined as the class of those individuals that have the given
0553: * resource as the value of the given property. If a resource
0554: * with the given URI exists in the model, and can be viewed as a HasValueRestriction, return the
0555: * HasValueRestriction facet, otherwise return null. </p>
0556: *
0557: * @param uri The URI for the restriction
0558: * @return A resource representing a has-value restriction or null
0559: */
0560: public HasValueRestriction getHasValueRestriction(String uri);
0561:
0562: /**
0563: * <p>Answer a class description defined as the class of those individuals that have at least
0564: * one property with a value belonging to the given class. If a resource
0565: * with the given URI exists in the model, and can be viewed as a SomeValuesFromRestriction, return the
0566: * SomeValuesFromRestriction facet, otherwise return null. </p>
0567: *
0568: * @param uri The URI for the restriction
0569: * @return A resource representing a some-values-from restriction, or null
0570: */
0571: public SomeValuesFromRestriction getSomeValuesFromRestriction(
0572: String uri);
0573:
0574: /**
0575: * <p>Answer a class description defined as the class of those individuals for which all values
0576: * of the given property belong to the given class. If a resource
0577: * with the given URI exists in the model, and can be viewed as an AllValuesFromResriction, return the
0578: * AllValuesFromRestriction facet, otherwise return null. </p>
0579: *
0580: * @param uri The URI for the restriction
0581: * @return A resource representing an all-values-from restriction or null
0582: */
0583: public AllValuesFromRestriction getAllValuesFromRestriction(
0584: String uri);
0585:
0586: /**
0587: * <p>Answer a class description defined as the class of those individuals that have exactly
0588: * the given number of values for the given property. If a resource
0589: * with the given URI exists in the model, and can be viewed as a CardinalityRestriction, return the
0590: * CardinalityRestriction facet, otherwise return null. </p>
0591: *
0592: * @param uri The URI for the restriction
0593: * @return A resource representing a has-value restriction, or null
0594: */
0595: public CardinalityRestriction getCardinalityRestriction(String uri);
0596:
0597: /**
0598: * <p>Answer a class description defined as the class of those individuals that have at least
0599: * the given number of values for the given property. If a resource
0600: * with the given URI exists in the model, and can be viewed as a MinCardinalityRestriction, return the
0601: * MinCardinalityRestriction facet, otherwise return null. </p>
0602: *
0603: * @param uri The URI for the restriction
0604: * @return A resource representing a minimum cardinality restriction, or null
0605: */
0606: public MinCardinalityRestriction getMinCardinalityRestriction(
0607: String uri);
0608:
0609: /**
0610: * <p>Answer a class description defined as the class of those individuals that have at most
0611: * the given number of values for the given property. If a resource
0612: * with the given URI exists in the model, and can be viewed as a MaxCardinalityRestriction, return the
0613: * MaxCardinalityRestriction facet, otherwise return null.</p>
0614: *
0615: * @param uri The URI for the restriction
0616: * @return A resource representing a max-cardinality restriction, or null
0617: */
0618: public MaxCardinalityRestriction getMaxCardinalityRestriction(
0619: String uri);
0620:
0621: /**
0622: * <p>Answer a class description defined as the class of those individuals that have a property
0623: * p, all values of which are members of a given class. Typically used with a cardinality constraint.
0624: * If a resource
0625: * with the given URI exists in the model, and can be viewed as a QualifiedRestriction, return the
0626: * QualifiedRestriction facet, otherwise return null.</p>
0627: *
0628: * @param uri The URI for the restriction
0629: * @return A resource representing a qualified restriction, or null
0630: */
0631: public QualifiedRestriction getQualifiedRestriction(String uri);
0632:
0633: /**
0634: * <p>Answer a class description defined as the class of those individuals that have a property
0635: * p, with cardinality N, all values of which are members of a given class.
0636: * If a resource
0637: * with the given URI exists in the model, and can be viewed as a CardinalityQRestriction, return the
0638: * CardinalityQRestriction facet, otherwise return null.</p>
0639: *
0640: * @param uri The URI for the restriction
0641: * @return A resource representing a qualified cardinality restriction, or null
0642: */
0643: public CardinalityQRestriction getCardinalityQRestriction(String uri);
0644:
0645: /**
0646: * <p>Answer a class description defined as the class of those individuals that have a property
0647: * p, with minimum cardinality N, all values of which are members of a given class.
0648: * If a resource
0649: * with the given URI exists in the model, and can be viewed as a MinCardinalityQRestriction, return the
0650: * MinCardinalityQRestriction facet, otherwise return null.</p>
0651: *
0652: * @param uri The URI for the restriction
0653: * @return A resource representing a qualified minimum cardinality restriction, or null
0654: */
0655: public MinCardinalityQRestriction getMinCardinalityQRestriction(
0656: String uri);
0657:
0658: /**
0659: * <p>Answer a class description defined as the class of those individuals that have a property
0660: * p, with max cardinality N, all values of which are members of a given class.
0661: * If a resource
0662: * with the given URI exists in the model, and can be viewed as a MaxCardinalityQRestriction, return the
0663: * MaxCardinalityQRestriction facet, otherwise return null.</p>
0664: *
0665: * @param uri The URI for the restriction
0666: * @return A resource representing a qualified max cardinality restriction, or null
0667: */
0668: public MaxCardinalityQRestriction getMaxCardinalityQRestriction(
0669: String uri);
0670:
0671: /**
0672: * <p>
0673: * Answer a resource that represents an ontology description node in this model. If a resource
0674: * with the given URI exists in the model, it will be re-used. If not, a new one is created in
0675: * the writable sub-model of the ontology model.
0676: * </p>
0677: *
0678: * @param uri The URI for the ontology node. Conventionally, this corresponds to the base URI
0679: * of the document itself.
0680: * @return An Ontology resource.
0681: */
0682: public Ontology createOntology(String uri);
0683:
0684: /**
0685: * <p>
0686: * Answer a resource that represents an <code>Individual</code> node in this model. A new anonymous resource
0687: * will be created in the writable sub-model of the ontology model.
0688: * </p>
0689: *
0690: * @param cls Resource representing the ontology class to which the individual belongs
0691: * @return A new anonymous Individual of the given class.
0692: */
0693: public Individual createIndividual(Resource cls);
0694:
0695: /**
0696: * <p>
0697: * Answer a resource that represents an Individual node in this model. If a resource
0698: * with the given URI exists in the model, it will be re-used. If not, a new one is created in
0699: * the writable sub-model of the ontology model.
0700: * </p>
0701: *
0702: * @param cls Resource representing the ontology class to which the individual belongs
0703: * @param uri The URI for the individual, or null for an anonymous individual.
0704: * @return An Individual resource.
0705: */
0706: public Individual createIndividual(String uri, Resource cls);
0707:
0708: /**
0709: * <p>
0710: * Answer a resource representing an generic property in this model. Effectively
0711: * this method is an alias for {@link #createProperty( String )}, except that
0712: * the return type is {@link OntProperty}, which allow more convenient access to
0713: * a property's position in the property hierarchy, domain, range, etc.
0714: * </p>
0715: *
0716: * @param uri The URI for the property. May not be null.
0717: * @return An OntProperty resource.
0718: */
0719: public OntProperty createOntProperty(String uri);
0720:
0721: /**
0722: * <p>
0723: * Answer a resource representing an object property in this model,
0724: * and that is not a functional property.
0725: * </p>
0726: *
0727: * @param uri The URI for the object property. May not be null.
0728: * @return An ObjectProperty resource.
0729: * @see #createObjectProperty( String, boolean )
0730: */
0731: public ObjectProperty createObjectProperty(String uri);
0732:
0733: /**
0734: * <p>
0735: * Answer a resource that represents an object property in this model. An object property
0736: * is defined to have a range of individuals, rather than datatypes.
0737: * If a resource
0738: * with the given URI exists in the model, it will be re-used. If not, a new one is created in
0739: * the writable sub-model of the ontology model.
0740: * </p>
0741: *
0742: * @param uri The URI for the object property. May not be null.
0743: * @param functional If true, the resource will also be typed as a {@link FunctionalProperty},
0744: * that is, a property that has a unique range value for any given domain value.
0745: * @return An ObjectProperty resource, optionally also functional.
0746: */
0747: public ObjectProperty createObjectProperty(String uri,
0748: boolean functional);
0749:
0750: /**
0751: * <p>Answer a resource representing a transitive property</p>
0752: * @param uri The URI for the property. May not be null.
0753: * @return An TransitiveProperty resource
0754: * @see #createTransitiveProperty( String, boolean )
0755: */
0756: public TransitiveProperty createTransitiveProperty(String uri);
0757:
0758: /**
0759: * <p>Answer a resource representing a transitive property, which is optionally
0760: * also functional. <strong>Note:</strong> although it is permitted in OWL full
0761: * to have functional transitive properties, it makes the language undecidable.
0762: * Functional transitive properties are not permitted in OWL-Lite or OWL DL.</p>
0763: * @param uri The URI for the property. May not be null.
0764: * @param functional If true, the property is also functional
0765: * @return An TransitiveProperty resource, optionally also functional.
0766: */
0767: public TransitiveProperty createTransitiveProperty(String uri,
0768: boolean functional);
0769:
0770: /**
0771: * <p>Answer a resource representing a symmetric property</p>
0772: * @param uri The URI for the property. May not be null.
0773: * @return An SymmetricProperty resource
0774: * @see #createSymmetricProperty( String, boolean )
0775: */
0776: public SymmetricProperty createSymmetricProperty(String uri);
0777:
0778: /**
0779: * <p>Answer a resource representing a symmetric property, which is optionally
0780: * also functional.</p>
0781: * @param uri The URI for the property. May not be null.
0782: * @param functional If true, the property is also functional
0783: * @return An SymmetricProperty resource, optionally also functional.
0784: */
0785: public SymmetricProperty createSymmetricProperty(String uri,
0786: boolean functional);
0787:
0788: /**
0789: * <p>Answer a resource representing an inverse functional property</p>
0790: * @param uri The URI for the property. May not be null.
0791: * @return An InverseFunctionalProperty resource
0792: * @see #createInverseFunctionalProperty( String, boolean )
0793: */
0794: public InverseFunctionalProperty createInverseFunctionalProperty(
0795: String uri);
0796:
0797: /**
0798: * <p>Answer a resource representing an inverse functional property, which is optionally
0799: * also functional.</p>
0800: * @param uri The URI for the property. May not be null.
0801: * @param functional If true, the property is also functional
0802: * @return An InverseFunctionalProperty resource, optionally also functional.
0803: */
0804: public InverseFunctionalProperty createInverseFunctionalProperty(
0805: String uri, boolean functional);
0806:
0807: /**
0808: * <p>
0809: * Answer a resource that represents datatype property in this model, and that is
0810: * not a functional property.
0811: * </p>
0812: *
0813: * @param uri The URI for the datatype property. May not be null.
0814: * @return A DatatypeProperty resource.
0815: * @see #createDatatypeProperty( String, boolean )
0816: */
0817: public DatatypeProperty createDatatypeProperty(String uri);
0818:
0819: /**
0820: * <p>
0821: * Answer a resource that represents datatype property in this model. A datatype property
0822: * is defined to have a range that is a concrete datatype, rather than an individual.
0823: * If a resource
0824: * with the given URI exists in the model, it will be re-used. If not, a new one is created in
0825: * the writable sub-model of the ontology model.
0826: * </p>
0827: *
0828: * @param uri The URI for the datatype property. May not be null.
0829: * @param functional If true, the resource will also be typed as a {@link FunctionalProperty},
0830: * that is, a property that has a unique range value for any given domain value.
0831: * @return A DatatypeProperty resource.
0832: */
0833: public DatatypeProperty createDatatypeProperty(String uri,
0834: boolean functional);
0835:
0836: /**
0837: * <p>
0838: * Answer a resource that represents an annotation property in this model. If a resource
0839: * with the given URI exists in the model, it will be re-used. If not, a new one is created in
0840: * the writable sub-model of the ontology model.
0841: * </p>
0842: *
0843: * @param uri The URI for the annotation property. May not be null.
0844: * @return An AnnotationProperty resource.
0845: */
0846: public AnnotationProperty createAnnotationProperty(String uri);
0847:
0848: /**
0849: * <p>
0850: * Answer a resource that represents an anonymous class description in this model. A new
0851: * anonymous resource of <code>rdf:type C</code>, where C is the class type from the
0852: * language profile.
0853: * </p>
0854: *
0855: * @return An anonymous Class resource.
0856: */
0857: public OntClass createClass();
0858:
0859: /**
0860: * <p>
0861: * Answer a resource that represents a class description node in this model. If a resource
0862: * with the given URI exists in the model, it will be re-used. If not, a new one is created in
0863: * the writable sub-model of the ontology model.
0864: * </p>
0865: *
0866: * @param uri The URI for the class node, or null for an anonymous class.
0867: * @return A Class resource.
0868: */
0869: public OntClass createClass(String uri);
0870:
0871: /**
0872: * <p>Answer a resource representing the class that is the complement of the given argument class</p>
0873: * @param uri The URI of the new complement class, or null for an anonymous class description.
0874: * @param cls Resource denoting the class that the new class is a complement of
0875: * @return A complement class
0876: */
0877: public ComplementClass createComplementClass(String uri,
0878: Resource cls);
0879:
0880: /**
0881: * <p>Answer a resource representing the class that is the enumeration of the given list of individuals</p>
0882: * @param uri The URI of the new enumeration class, or null for an anonymous class description.
0883: * @param members An optional list of resources denoting the individuals in the enumeration, or null.
0884: * @return An enumeration class
0885: */
0886: public EnumeratedClass createEnumeratedClass(String uri,
0887: RDFList members);
0888:
0889: /**
0890: * <p>Answer a resource representing the class that is the union of the given list of class descriptions</p>
0891: * @param uri The URI of the new union class, or null for an anonymous class description.
0892: * @param members A list of resources denoting the classes that comprise the union
0893: * @return A union class description
0894: */
0895: public UnionClass createUnionClass(String uri, RDFList members);
0896:
0897: /**
0898: * <p>Answer a resource representing the class that is the intersection of the given list of class descriptions.</p>
0899: * @param uri The URI of the new intersection class, or null for an anonymous class description.
0900: * @param members A list of resources denoting the classes that comprise the intersection
0901: * @return An intersection class description
0902: */
0903: public IntersectionClass createIntersectionClass(String uri,
0904: RDFList members);
0905:
0906: /**
0907: * <p>
0908: * Answer a resource that represents an anonymous property restriction in this model. A new
0909: * anonymous resource of <code>rdf:type R</code>, where R is the restriction type from the
0910: * language profile.
0911: * </p>
0912: * @param p The property that is restricted by this restriction, or null to omit from the restriction
0913: * @return An anonymous Restriction resource.
0914: */
0915: public Restriction createRestriction(Property p);
0916:
0917: /**
0918: * <p>
0919: * Answer a resource that represents a property restriction in this model. If a resource
0920: * with the given URI exists in the model, it will be re-used. If not, a new one is created in
0921: * the writable sub-model of the ontology model.
0922: * </p>
0923: *
0924: * @param uri The URI for the restriction node, or null for an anonymous restriction.
0925: * @param p The property that is restricted by this restriction, or null to omit from the restriction
0926: * @return A Restriction resource.
0927: */
0928: public Restriction createRestriction(String uri, Property p);
0929:
0930: /**
0931: * <p>Answer a class description defined as the class of those individuals that have the given
0932: * resource as the value of the given property</p>
0933: *
0934: * @param uri The optional URI for the restriction, or null for an anonymous restriction (which
0935: * should be the normal case)
0936: * @param prop The property the restriction applies to
0937: * @param value The value of the property, as a resource or RDF literal
0938: * @return A new resource representing a has-value restriction
0939: */
0940: public HasValueRestriction createHasValueRestriction(String uri,
0941: Property prop, RDFNode value);
0942:
0943: /**
0944: * <p>Answer a class description defined as the class of those individuals that have at least
0945: * one property with a value belonging to the given class</p>
0946: *
0947: * @param uri The optional URI for the restriction, or null for an anonymous restriction (which
0948: * should be the normal case)
0949: * @param prop The property the restriction applies to
0950: * @param cls The class to which at least one value of the property belongs
0951: * @return A new resource representing a some-values-from restriction
0952: */
0953: public SomeValuesFromRestriction createSomeValuesFromRestriction(
0954: String uri, Property prop, Resource cls);
0955:
0956: /**
0957: * <p>Answer a class description defined as the class of those individuals for which all values
0958: * of the given property belong to the given class</p>
0959: *
0960: * @param uri The optional URI for the restriction, or null for an anonymous restriction (which
0961: * should be the normal case)
0962: * @param prop The property the restriction applies to
0963: * @param cls The class to which any value of the property belongs
0964: * @return A new resource representing an all-values-from restriction
0965: */
0966: public AllValuesFromRestriction createAllValuesFromRestriction(
0967: String uri, Property prop, Resource cls);
0968:
0969: /**
0970: * <p>Answer a class description defined as the class of those individuals that have exactly
0971: * the given number of values for the given property.</p>
0972: *
0973: * @param uri The optional URI for the restriction, or null for an anonymous restriction (which
0974: * should be the normal case)
0975: * @param prop The property the restriction applies to
0976: * @param cardinality The exact cardinality of the property
0977: * @return A new resource representing a cardinality restriction
0978: */
0979: public CardinalityRestriction createCardinalityRestriction(
0980: String uri, Property prop, int cardinality);
0981:
0982: /**
0983: * <p>Answer a class description defined as the class of those individuals that have at least
0984: * the given number of values for the given property.</p>
0985: *
0986: * @param uri The optional URI for the restriction, or null for an anonymous restriction (which
0987: * should be the normal case)
0988: * @param prop The property the restriction applies to
0989: * @param cardinality The minimum cardinality of the property
0990: * @return A new resource representing a min-cardinality restriction
0991: */
0992: public MinCardinalityRestriction createMinCardinalityRestriction(
0993: String uri, Property prop, int cardinality);
0994:
0995: /**
0996: * <p>Answer a class description defined as the class of those individuals that have at most
0997: * the given number of values for the given property.</p>
0998: *
0999: * @param uri The optional URI for the restriction, or null for an anonymous restriction (which
1000: * should be the normal case)
1001: * @param prop The property the restriction applies to
1002: * @param cardinality The maximum cardinality of the property
1003: * @return A new resource representing a max-cardinality restriction
1004: */
1005: public MaxCardinalityRestriction createMaxCardinalityRestriction(
1006: String uri, Property prop, int cardinality);
1007:
1008: /**
1009: * <p>Answer a class description defined as the class of those individuals that have at most
1010: * the given number of values for the given property, all values of which belong to the given
1011: * class.</p>
1012: *
1013: * @param uri The optional URI for the restriction, or null for an anonymous restriction (which
1014: * should be the normal case)
1015: * @param prop The property the restriction applies to
1016: * @param cardinality The maximum cardinality of the property
1017: * @param cls The class to which all values of the restricted property should belong
1018: * @return A new resource representing a max-cardinality-q restriction
1019: */
1020: public MaxCardinalityQRestriction createMaxCardinalityQRestriction(
1021: String uri, Property prop, int cardinality, OntClass cls);
1022:
1023: /**
1024: * <p>Answer a class description defined as the class of those individuals that have at least
1025: * the given number of values for the given property, all values of which belong to the given
1026: * class.</p>
1027: *
1028: * @param uri The optional URI for the restriction, or null for an anonymous restriction (which
1029: * should be the normal case)
1030: * @param prop The property the restriction applies to
1031: * @param cardinality The minimum cardinality of the property
1032: * @param cls The class to which all values of the restricted property should belong
1033: * @return A new resource representing a min-cardinality-q restriction
1034: */
1035: public MinCardinalityQRestriction createMinCardinalityQRestriction(
1036: String uri, Property prop, int cardinality, OntClass cls);
1037:
1038: /**
1039: * <p>Answer a class description defined as the class of those individuals that have exactly
1040: * the given number of values for the given property, all values of which belong to the given
1041: * class.</p>
1042: *
1043: * @param uri The optional URI for the restriction, or null for an anonymous restriction (which
1044: * should be the normal case)
1045: * @param prop The property the restriction applies to
1046: * @param cardinality The cardinality of the property
1047: * @param cls The class to which all values of the restricted property should belong
1048: * @return A new resource representing a cardinality-q restriction
1049: */
1050: public CardinalityQRestriction createCardinalityQRestriction(
1051: String uri, Property prop, int cardinality, OntClass cls);
1052:
1053: /**
1054: * <p>Answer a data range defined as the given set of concrete data values. DataRange resources
1055: * are necessarily bNodes.</p>
1056: *
1057: * @param literals A list of literals that will be the members of the data range,
1058: * or null to define an empty data range
1059: * @return A new data range containing the given literals as permissible values
1060: */
1061: public DataRange createDataRange(RDFList literals);
1062:
1063: /**
1064: * <p>
1065: * Answer a new, anonymous node representing the fact that a given set of classes are all
1066: * pair-wise distinct. <code>AllDifferent</code> is a feature of OWL only, and is something
1067: * of an anomaly in that it exists only to give a place to anchor the <code>distinctMembers</code>
1068: * property, which is the actual expression of the fact.
1069: * </p>
1070: *
1071: * @return A new AllDifferent resource
1072: */
1073: public AllDifferent createAllDifferent();
1074:
1075: /**
1076: * <p>
1077: * Answer a new, anonymous node representing the fact that a given set of classes are all
1078: * pair-wise distinct. <code>AllDifferent</code> is a feature of OWL only, and is something
1079: * of an anomaly in that it exists only to give a place to anchor the <code>distinctMembers</code>
1080: * property, which is the actual expression of the fact.
1081: * </p>
1082: * @param differentMembers A list of the class expressions that denote a set of mutually disjoint classes
1083: * @return A new AllDifferent resource
1084: */
1085: public AllDifferent createAllDifferent(RDFList differentMembers);
1086:
1087: /**
1088: * <p>
1089: * Answer a resource that represents a generic ontology node in this model. If a resource
1090: * with the given URI exists in the model, it will be re-used. If not, a new one is created in
1091: * the writable sub-model of the ontology model.
1092: * </p>
1093: * <p>
1094: * This is a generic method for creating any known ontology value. The selector that determines
1095: * which resource to create is the same as as the argument to the {@link RDFNode#as as()}
1096: * method: the Java class object of the desired abstraction. For example, to create an
1097: * ontology class via this mechanism, use:
1098: * <code><pre>
1099: * OntClass c = (OntClass) myModel.createOntResource( OntClass.class, null,
1100: * "http://example.org/ex#Parrot" );
1101: * </pre></code>
1102: * </p>
1103: *
1104: * @param javaClass The Java class object that represents the ontology abstraction to create
1105: * @param rdfType Optional resource denoting the ontology class to which an individual or
1106: * axiom belongs, if that is the type of resource being created.
1107: * @param uri The URI for the ontology resource, or null for an anonymous resource.
1108: * @return An ontology resource, of the type specified by the <code>javaClass</code>
1109: */
1110: public OntResource createOntResource(Class javaClass,
1111: Resource rdfType, String uri);
1112:
1113: /**
1114: * <p>Answer a resource presenting the {@link OntResource} facet, which has the
1115: * given URI.</p>
1116: * @param uri The URI of the resource, or null for an anonymous resource (i.e. <em>bNode</em>)
1117: * @return An OntResource with the given URI
1118: */
1119: public OntResource createOntResource(String uri);
1120:
1121: /**
1122: * <p>Determine which models this model imports (by looking for, for example,
1123: * <code>owl:imports</code> statements, and load each of those models as an
1124: * import. A check is made to determine if a model has already been imported,
1125: * if so, the import is ignored. Thus this method is safe against circular
1126: * sets of import statements. Note that actual implementation is delegated to
1127: * the associated {@link OntDocumentManager}.
1128: */
1129: public void loadImports();
1130:
1131: /**
1132: * <p>
1133: * Answer a list of the imported URI's in this ontology model. Detection of <code>imports</code>
1134: * statements will be according to the local language profile. Note that, in order to allow this
1135: * method to be called during the imports closure process, we <b>only query the base model</b>,
1136: * thus side-stepping the any attached reasoner.
1137: * </p>
1138: *
1139: * @return The imported ontology URI's as a set. Note that since the underlying graph is
1140: * not ordered, the order of values in the list in successive calls to this method is
1141: * not guaranteed to be preserved.
1142: */
1143: public Set listImportedOntologyURIs();
1144:
1145: /**
1146: * <p>
1147: * Answer a list of the imported URI's in this ontology model, and optionally in the closure
1148: * of this model's imports. Detection of <code>imports</code>
1149: * statements will be according to the local language profile. Note that, in order to allow this
1150: * method to be called during the imports closure process, we <b>only query the base model</b>,
1151: * thus side-stepping the any attached reasoner.
1152: * </p>
1153: * @param closure If true, the set of URI's returned will include not only those directly
1154: * imported by this model, but those imported by the model's imports, and so on transitively.
1155: * @return A set of imported ontology URIs. Note that since the underlying graph is
1156: * not ordered, the order of values in the list in successive calls to this method is
1157: * not guaranteed to be preserved.
1158: */
1159: public Set listImportedOntologyURIs(boolean closure);
1160:
1161: /**
1162: * <p>
1163: * Answer true if this model has had the given URI document imported into it. This is
1164: * important to know since an import only occurs once, and we also want to be able to
1165: * detect cycles of imports.
1166: * </p>
1167: *
1168: * @param uri An ontology URI
1169: * @return True if the document corresponding to the URI has been successfully loaded
1170: * into this model
1171: */
1172: public boolean hasLoadedImport(String uri);
1173:
1174: /**
1175: * <p>
1176: * Record that this model has now imported the document with the given
1177: * URI, so that it will not be re-imported in the future.
1178: * </p>
1179: *
1180: * @param uri A document URI that has now been imported into the model.
1181: */
1182: public void addLoadedImport(String uri);
1183:
1184: /**
1185: * <p>
1186: * Record that this model no longer imports the document with the given
1187: * URI.
1188: * </p>
1189: *
1190: * @param uri A document URI that is no longer imported into the model.
1191: */
1192: public void removeLoadedImport(String uri);
1193:
1194: /**
1195: * <p>
1196: * Answer the language profile (for example, OWL or DAML+OIL) that this model is
1197: * working to.
1198: * </p>
1199: *
1200: * @return A language profile
1201: */
1202: public Profile getProfile();
1203:
1204: /**
1205: * <p>
1206: * Answer the model maker associated with this model (used for constructing the
1207: * constituent models of the imports closure).
1208: * </p>
1209: * @deprecated use getImportModelMaker instead for consistency with name
1210: * changes to OntModelSpec to avoid ambiguity with base vs import makers.
1211: *
1212: * @return The local model maker
1213: */
1214: public ModelMaker getModelMaker();
1215:
1216: /**
1217: * <p>
1218: * Answer the model maker associated with this model (used for constructing the
1219: * constituent models of the imports closure).
1220: * </p>
1221: *
1222: * @return The local model maker
1223: */
1224: public ModelMaker getImportModelMaker();
1225:
1226: /**
1227: * <p>
1228: * Answer the sub-graphs of this model. A sub-graph is defined as a graph that
1229: * is used to contain the triples from an imported document.
1230: * </p>
1231: *
1232: * @return A list of graphs that are contained in this ontology model
1233: */
1234: public List getSubGraphs();
1235:
1236: /**
1237: * <p>Answer an iterator over the ontologies that this ontology imports,
1238: * each of which will have been wrapped as an ontology model using the same
1239: * {@link OntModelSpec} as this model. If this model has no imports,
1240: * the iterator will be non-null but will not have any values.</p>
1241: * @return An iterator, each value of which will be an <code>OntModel</code>
1242: * representing an imported ontology.
1243: * @deprecated This method has been re-named to <code>listSubModels</code>,
1244: * but note that to obtain the same behaviour as <code>listImportedModels</code>
1245: * from Jena 2.4 and earlier, callers should invoke {@link #listSubModels(boolean)}
1246: * with parameter <code>true</code>.
1247: * @see #listSubModels()
1248: * @see #listSubModels(boolean)
1249: */
1250: public ExtendedIterator listImportedModels();
1251:
1252: /**
1253: * <p>Answer an iterator over the ontology models that are sub-models of
1254: * this model. Sub-models are used, for example, to represent composite
1255: * documents such as the imports of a model. So if ontology A imports
1256: * ontologies B and C, each of B and C will be available as one of
1257: * the sub-models of the model containing A. This method replaces the
1258: * older {@link #listImportedModels}. Note that to fully replicate
1259: * the behaviour of <code>listImportedModels</code>, the
1260: * <code>withImports</code> flag must be set to true. Each model
1261: * returned by this method will have been wrapped as an ontology model using the same
1262: * {@link OntModelSpec} as this model. If this model has no sub-models,
1263: * the returned iterator will be non-null but will not have any values.</p>
1264: *
1265: * @param withImports If true, each sub-model returned by this method
1266: * will also include its import models. So if model A imports D, and D
1267: * imports D, when called with <code>withImports</code> set to true, the
1268: * return value for <code>modelA.listSubModels(true)</code> will be an
1269: * iterator, whose only value is a model for D, and that model will contain
1270: * a sub-model representing the import of E. If <code>withImports</code>
1271: * is false, E will not be included as a sub-model of D.
1272: * @return An iterator, each value of which will be an <code>OntModel</code>
1273: * representing a sub-model of this ontology.
1274: */
1275: public ExtendedIterator listSubModels(boolean withImports);
1276:
1277: /**
1278: * <p>Answer an iterator over the ontology models that are sub-models of
1279: * this model. Sub-models are used, for example, to represent composite
1280: * documents such as the imports of a model. So if ontology A imports
1281: * ontologies B and C, each of B and C will be available as one of
1282: * the sub-models of the model containing A.
1283: * <strong>Important note on behaviour change:</strong> please see
1284: * the comment on {@link #listSubModels(boolean)} for explanation
1285: * of the <code>withImports</code> flag. This zero-argument form
1286: * of <code>listSubModels</code> sets <code>withImports</code> to
1287: * false, so the returned models will not themselves contain imports.
1288: * This behaviour differs from the zero-argument method
1289: * {@link #listImportedModels()} in Jena 2.4 an earlier.</p>
1290: * @return An iterator, each value of which will be an <code>OntModel</code>
1291: * representing a sub-model of this ontology.
1292: * @see #listSubModels(boolean)
1293: */
1294: public ExtendedIterator listSubModels();
1295:
1296: /**
1297: * <p>Answer the number of sub-models of this model, not including the
1298: * base model.</p>
1299: * @return The number of sub-models, ≥ zero.
1300: */
1301: public int countSubModels();
1302:
1303: /**
1304: * <p>Answer an <code>OntModel</code> representing the imported ontology
1305: * with the given URI. If an ontology with that URI has not been imported,
1306: * answer null.</p>
1307: * @param uri The URI of an ontology that may have been imported into the
1308: * ontology represented by this model
1309: * @return A model representing the imported ontology with the given URI, or
1310: * null.
1311: */
1312: public OntModel getImportedModel(String uri);
1313:
1314: /**
1315: * <p>
1316: * Answer the base model of this model. The base model is the model
1317: * that contains the triples read from the source document for this
1318: * ontology. It is therefore this base model that will be updated if statements are
1319: * added to a model that is built from a union of documents (via the
1320: * <code>imports</code> statements in the source document).
1321: * </p>
1322: *
1323: * @return The base model for this ontology model
1324: */
1325: public Model getBaseModel();
1326:
1327: /**
1328: * <p>
1329: * Add the given model as one of the sub-models of the enclosed ontology union model. Will
1330: * cause the associated inference engine (if any) to update, so this may be
1331: * an expensive operation in some cases.
1332: * </p>
1333: *
1334: * @param model A sub-model to add
1335: * @see #addSubModel( Model, boolean )
1336: */
1337: public void addSubModel(Model model);
1338:
1339: /**
1340: * <p>
1341: * Add the given model as one of the sub-models of the enclosed ontology union model.
1342: * </p>
1343: *
1344: * @param model A sub-model to add
1345: * @param rebind If true, rebind any associated inferencing engine to the new data (which
1346: * may be an expensive operation)
1347: */
1348: public void addSubModel(Model model, boolean rebind);
1349:
1350: /**
1351: * <p>
1352: * Remove the given model as one of the sub-models of the enclosed ontology union model. Will
1353: * cause the associated inference engine (if any) to update, so this may be
1354: * an expensive operation in some cases.
1355: * </p>
1356: *
1357: * @param model A sub-model to remove
1358: * @see #addSubModel( Model, boolean )
1359: */
1360: public void removeSubModel(Model model);
1361:
1362: /**
1363: * <p>
1364: * Remove the given model as one of the sub-models of the enclosed ontology union model.
1365: * </p>
1366: *
1367: * @param model A sub-model to remove
1368: * @param rebind If true, rebind any associated inferencing engine to the new data (which
1369: * may be an expensive operation)
1370: */
1371: public void removeSubModel(Model model, boolean rebind);
1372:
1373: /**
1374: * <p>Answer true if the given node is a member of the base model of this ontology model.
1375: * This is an important distinction, because only the base model receives updates when the
1376: * ontology model is updated. Thus, removing properties of a resource that is not in the base
1377: * model will not actually side-effect the overall model.</p>
1378: * @param node An RDF node (Resource, Property or Literal) to test
1379: * @return True if the given node is from the base model
1380: */
1381: public boolean isInBaseModel(RDFNode node);
1382:
1383: /**
1384: * <p>Answer true if the given statement is defined in the base model of this ontology model.
1385: * This is an important distinction, because only the base model receives updates when the
1386: * ontology model is updated. Thus, removing a statement that is not in the base
1387: * model will not actually side-effect the overall model.</p>
1388: * @param stmt A statement to test
1389: * @return True if the given statement is from the base model
1390: */
1391: public boolean isInBaseModel(Statement stmt);
1392:
1393: /**
1394: * <p>
1395: * Answer true if this model is currently in <i>strict checking mode</i>. Strict
1396: * mode means
1397: * that converting a common resource to a particular language element, such as
1398: * an ontology class, will be subject to some simple syntactic-level checks for
1399: * appropriateness.
1400: * </p>
1401: *
1402: * @return True if in strict checking mode
1403: */
1404: public boolean strictMode();
1405:
1406: /**
1407: * <p>
1408: * Set the checking mode to strict or non-strict.
1409: * </p>
1410: *
1411: * @param strict
1412: * @see #strictMode()
1413: */
1414: public void setStrictMode(boolean strict);
1415:
1416: /**
1417: * <p>Set the flag that controls whether adding or removing <i>imports</i>
1418: * statements into the
1419: * model will result in the imports closure changing dynamically.</p>
1420: * @param dynamic If true, adding or removing an imports statement to the
1421: * model will result in a change in the imports closure. If false, changes
1422: * to the imports are not monitored dynamically. Default false.
1423: */
1424: public void setDynamicImports(boolean dynamic);
1425:
1426: /**
1427: * <p>Answer true if the imports closure of the model will be dynamically
1428: * updated as imports statements are added and removed.</p>
1429: * @return True if the imports closure is updated dynamically.
1430: */
1431: public boolean getDynamicImports();
1432:
1433: /**
1434: * <p>
1435: * Answer a reference to the document manager that this model is using to manage
1436: * ontology <-> mappings, and to load the imports closure. <strong>Note</strong>
1437: * by default, an ontology model is constructed with a reference to the shared,
1438: * global document manager. Thus changing the settings via this model's document
1439: * manager may affect other models also using the same instance.
1440: * </p>
1441: * @return A reference to this model's document manager
1442: */
1443: public OntDocumentManager getDocumentManager();
1444:
1445: /**
1446: * <p>Answer the ontology model specification that was used to construct this model</p>
1447: * @return An ont model spec instance.
1448: */
1449: public OntModelSpec getSpecification();
1450:
1451: /**
1452: * <p>
1453: * Answer the iterator over the resources from the graph that satisfy the given
1454: * query, followed by the answers to the alternative queries (if specified). A
1455: * typical scenario is that the main query gets resources of a given class (say,
1456: * <code>rdfs:Class</code>), while the altQueries query for aliases for that
1457: * type (such as <code>daml:Class</code>).
1458: * </p>
1459: *
1460: * @param query A query to run against the model
1461: * @param altQueries An optional list of subsidiary queries to chain on to the first
1462: * @return ExtendedIterator An iterator over the (assumed single) results of
1463: * executing the queries.
1464: */
1465: public ExtendedIterator queryFor(BindingQueryPlan query,
1466: List altQueries, Class asKey);
1467:
1468: /**
1469: * <p>If this OntModel is presenting an OWL model, answer the minimum OWL language
1470: * level that the constructs
1471: * used in this model lie entirely within.
1472: * This method requires that the separate download
1473: * <code>owlsyntax.jar</code> is on the Java classpath.
1474: * The three possible return values are
1475: * {@link com.hp.hpl.jena.vocabulary.OWL#FULL_LANG FULL_LANG} for OWL-full,
1476: * {@link com.hp.hpl.jena.vocabulary.OWL#DL_LANG DL_LANG} for OWL-DL or
1477: * {@link com.hp.hpl.jena.vocabulary.OWL#LITE_LANG LITE_LANG} for OWL-Lite.
1478: * Note that these URI's are <strong>not</strong> officially sanctioned by the WebOnt
1479: * working group. For unknown reasons, the working group chose not to assign official
1480: * URI's to represent the different OWL language levels. There is a slim chance that this
1481: * may change in future, in which case these return values will change appropriately.
1482: * In addition to the method return value,
1483: * the given <code>problems</problems> list, if non-null, will be filled with the syntax
1484: * problems detected by the syntax checker.
1485: * </p>
1486: * <p>
1487: * The Jena OWL syntax checker will normally list as problems those constructs used in
1488: * this model that are in OWL Full but not permitted in OWL DL. The exception to this
1489: * is if the {@linkplain #getProfile() language profile} for this model is
1490: * {@linkplain com.hp.hpl.jena.ontology.impl.OWLLiteProfile OWL Lite}, then the syntax checker will
1491: * test for constructs that lie in OWL-DL or OWL-Full and hence outside in OWL-Lite.
1492: * </p>
1493: * <p>
1494: * <strong>Note</strong> that performing this test requires every statement in the model
1495: * to be examined, so it can be quite an expensive operation on large models, or on
1496: * persistent database models.
1497: * </p>
1498: *
1499: * @param problems A list that, if non-null, will have the various problems discovered by the OWL syntax
1500: * checker added to it.
1501: * @return A resource denoting the minimum OWL language level for this model
1502: * @exception OntologyException if this model is not an OWL model
1503: */
1504: public Resource getOWLLanguageLevel(List problems);
1505:
1506: // output operations
1507:
1508: /**
1509: * <p>Write the model as an XML document.
1510: * It is often better to use an OutputStream rather than a Writer, since this
1511: * will avoid character encoding errors.
1512: * <strong>Note:</strong> This method is adapted for the ontology
1513: * model to write out only the base model (which contains the asserted data). To write
1514: * all triples, including imported data and inferred triples, use
1515: * {@link #writeAll( Writer, String, String ) writeAll }.
1516: * </p>
1517: *
1518: * @param writer A writer to which the XML will be written
1519: * @return this model
1520: */
1521: public Model write(Writer writer);
1522:
1523: /**
1524: * <p>Write a serialized representation of a model in a specified language.
1525: * It is often better to use an OutputStream rather than a Writer, since this
1526: * will avoid character encoding errors.
1527: * <strong>Note:</strong> This method is adapted for the ontology
1528: * model to write out only the base model (which contains the asserted data). To write
1529: * all triples, including imported data and inferred triples, use
1530: * {@link #writeAll( Writer, String, String ) writeAll }.
1531: * </p>
1532: * <p>The language in which to write the model is specified by the
1533: * <code>lang</code> argument. Predefined values are "RDF/XML",
1534: * "RDF/XML-ABBREV", "N-TRIPLE" and "N3". The default value,
1535: * represented by <code>null</code> is "RDF/XML".</p>
1536: * @param writer The output writer
1537: * @param lang The output language
1538: * @return this model
1539: */
1540: public Model write(Writer writer, String lang);
1541:
1542: /**
1543: * <p>Write a serialized representation of a model in a specified language.
1544: * It is often better to use an OutputStream rather than a Writer,
1545: * since this will avoid character encoding errors.
1546: * <strong>Note:</strong> This method is adapted for the ontology
1547: * model to write out only the base model (which contains the asserted data). To write
1548: * all triples, including imported data and inferred triples, use
1549: * {@link #writeAll( Writer, String, String ) writeAll }.
1550: * </p>
1551: * <p>The language in which to write the model is specified by the
1552: * <code>lang</code> argument. Predefined values are "RDF/XML",
1553: * "RDF/XML-ABBREV", "N-TRIPLE" and "N3". The default value,
1554: * represented by <code>null</code>, is "RDF/XML".</p>
1555: * @param writer The output writer
1556: * @param base The base URI for relative URI calculations.
1557: * <code>null</code> means use only absolute URI's.
1558: * @param lang The language in which the RDF should be written
1559: * @return this model
1560: */
1561: public Model write(Writer writer, String lang, String base);
1562:
1563: /**
1564: * <p>Write a serialization of this model as an XML document.
1565: * <strong>Note:</strong> This method is adapted for the ontology
1566: * model to write out only the base model (which contains the asserted data). To write
1567: * all triples, including imported data and inferred triples, use
1568: * {@link #writeAll( OutputStream, String, String ) writeAll }.
1569: * </p>
1570: * <p>The language in which to write the model is specified by the
1571: * <code>lang</code> argument. Predefined values are "RDF/XML",
1572: * "RDF/XML-ABBREV", "N-TRIPLE" and "N3". The default value is
1573: * represented by <code>null</code> is "RDF/XML".</p>
1574: * @param out The output stream to which the XML will be written
1575: * @return This model
1576: */
1577: public Model write(OutputStream out);
1578:
1579: /**
1580: * <p>Write a serialized representation of this model in a specified language.
1581: * <strong>Note:</strong> This method is adapted for the ontology
1582: * model to write out only the base model (which contains the asserted data). To write
1583: * all triples, including imported data and inferred triples, use
1584: * {@link #writeAll( OutputStream, String, String ) writeAll }.
1585: * </p>
1586: * <p>The language in which to write the model is specified by the
1587: * <code>lang</code> argument. Predefined values are "RDF/XML",
1588: * "RDF/XML-ABBREV", "N-TRIPLE" and "N3". The default value,
1589: * represented by <code>null</code>, is "RDF/XML".</p>
1590: * @param out The output stream to which the RDF is written
1591: * @param lang The output language
1592: * @return This model
1593: */
1594: public Model write(OutputStream out, String lang);
1595:
1596: /**
1597: * <p>Write a serialized representation of a model in a specified language.
1598: * <strong>Note:</strong> This method is adapted for the ontology
1599: * model to write out only the base model (which contains the asserted data). To write
1600: * all triples, including imported data and inferred triples, use
1601: * {@link #writeAll( OutputStream, String, String ) writeAll }.
1602: * </p>
1603: * <p>The language in which to write the model is specified by the
1604: * <code>lang</code> argument. Predefined values are "RDF/XML",
1605: * "RDF/XML-ABBREV", "N-TRIPLE" and "N3". The default value,
1606: * represented by <code>null</code>, is "RDF/XML".</p>
1607: * @param out The output stream to which the RDF is written
1608: * @param base The base URI to use when writing relative URI's. <code>null</code>
1609: * means use only absolute URI's.
1610: * @param lang The language in which the RDF should be written
1611: * @return This model
1612: */
1613: public Model write(OutputStream out, String lang, String base);
1614:
1615: /**
1616: * <p>Write a serialized representation of all of the contents of the model,
1617: * including inferred statements and statements imported from other
1618: * documents. To write only the data asserted in the base model, use
1619: * {@link #write( Writer, String, String ) write}.
1620: * It is often better to use an OutputStream rather than a Writer,
1621: * since this will avoid character encoding errors.
1622: * </p>
1623: * <p>The language in which to write the model is specified by the
1624: * <code>lang</code> argument. Predefined values are "RDF/XML",
1625: * "RDF/XML-ABBREV", "N-TRIPLE" and "N3". The default value,
1626: * represented by <code>null</code>, is "RDF/XML".</p>
1627: * @param writer The output writer
1628: * @param base The base URI for relative URI calculations.
1629: * <code>null</code> means use only absolute URI's.
1630: * @param lang The language in which the RDF should be written
1631: * @return This model
1632: */
1633: public Model writeAll(Writer writer, String lang, String base);
1634:
1635: /**
1636: * <p>Write a serialized representation of all of the contents of the model,
1637: * including inferred statements and statements imported from other
1638: * documents. To write only the data asserted in the base model, use
1639: * {@link #write( OutputStream, String, String ) write}.
1640: * </p>
1641: * <p>The language in which to write the model is specified by the
1642: * <code>lang</code> argument. Predefined values are "RDF/XML",
1643: * "RDF/XML-ABBREV", "N-TRIPLE" and "N3". The default value,
1644: * represented by <code>null</code>, is "RDF/XML".</p>
1645: * @param out The output stream to which the RDF is written
1646: * @param base The base URI to use when writing relative URI's. <code>null</code>
1647: * means use only absolute URI's.
1648: * @param lang The language in which the RDF should be written
1649: * @return This model
1650: */
1651: public Model writeAll(OutputStream out, String lang, String base);
1652:
1653: /**
1654: * <p>Answer the ontology event manager for this model.</p>
1655: * @return This model's event manager
1656: */
1657: public OntEventManager getEventManager();
1658: }
1659:
1660: /*
1661: (c) Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
1662: All rights reserved.
1663:
1664: Redistribution and use in source and binary forms, with or without
1665: modification, are permitted provided that the following conditions
1666: are met:
1667:
1668: 1. Redistributions of source code must retain the above copyright
1669: notice, this list of conditions and the following disclaimer.
1670:
1671: 2. Redistributions in binary form must reproduce the above copyright
1672: notice, this list of conditions and the following disclaimer in the
1673: documentation and/or other materials provided with the distribution.
1674:
1675: 3. The name of the author may not be used to endorse or promote products
1676: derived from this software without specific prior written permission.
1677:
1678: THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
1679: IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
1680: OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
1681: IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
1682: INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
1683: NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
1684: DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
1685: THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1686: (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
1687: THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1688: */
|