001: /*****************************************************************************
002: * Source code information
003: * -----------------------
004: * Original author Ian Dickinson, HP Labs Bristol
005: * Author email Ian.Dickinson@hp.com
006: * Package Jena 2
007: * Web http://sourceforge.net/projects/jena/
008: * Created 01-Apr-2003
009: * Filename $RCSfile: ObjectPropertyImpl.java,v $
010: * Revision $Revision: 1.12 $
011: * Release status $State: Exp $
012: *
013: * Last modified on $Date: 2008/01/02 12:08:02 $
014: * by $Author: andy_seaborne $
015: *
016: * (c) Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
017: * (see footer for full conditions)
018: *****************************************************************************/package com.hp.hpl.jena.ontology.impl;
019:
020: // Imports
021: ///////////////
022: import com.hp.hpl.jena.enhanced.*;
023: import com.hp.hpl.jena.graph.*;
024: import com.hp.hpl.jena.ontology.*;
025: import com.hp.hpl.jena.util.iterator.ExtendedIterator;
026:
027: /**
028: * <p>
029: * Implementation of the object property abstraction
030: * </p>
031: *
032: * @author Ian Dickinson, HP Labs
033: * (<a href="mailto:Ian.Dickinson@hp.com" >email</a>)
034: * @version CVS $Id: ObjectPropertyImpl.java,v 1.12 2008/01/02 12:08:02 andy_seaborne Exp $
035: */
036: public class ObjectPropertyImpl extends OntPropertyImpl implements
037: ObjectProperty {
038: // Constants
039: //////////////////////////////////
040:
041: // Static variables
042: //////////////////////////////////
043:
044: /**
045: * A factory for generating ObjectProperty facets from nodes in enhanced graphs.
046: * Note: should not be invoked directly by user code: use
047: * {@link com.hp.hpl.jena.rdf.model.RDFNode#as as()} instead.
048: */
049: public static Implementation factory = new Implementation() {
050: public EnhNode wrap(Node n, EnhGraph eg) {
051: if (canWrap(n, eg)) {
052: return new ObjectPropertyImpl(n, eg);
053: } else {
054: throw new ConversionException("Cannot convert node "
055: + n + " to ObjectProperty");
056: }
057: }
058:
059: public boolean canWrap(Node node, EnhGraph eg) {
060: // node will support being an ObjectProperty facet if it has rdf:type owl:ObjectProperty or equivalent
061: Profile profile = (eg instanceof OntModel) ? ((OntModel) eg)
062: .getProfile()
063: : null;
064: return (profile != null)
065: && profile.isSupported(node, eg,
066: ObjectProperty.class);
067: }
068: };
069:
070: // Instance variables
071: //////////////////////////////////
072:
073: // Constructors
074: //////////////////////////////////
075:
076: /**
077: * <p>
078: * Construct a functional property node represented by the given node in the given graph.
079: * </p>
080: *
081: * @param n The node that represents the resource
082: * @param g The enh graph that contains n
083: */
084: public ObjectPropertyImpl(Node n, EnhGraph g) {
085: super (n, g);
086: }
087:
088: // External signature methods
089: //////////////////////////////////
090:
091: /**
092: * <p>Answer a property that is an inverse of this property, ensuring that it
093: * presents the ObjectProperty facet.</p>
094: * @return A property inverse to this property
095: * @exception OntProfileException If the {@link Profile#INVERSE_OF()} property is not supported in the current language profile.
096: */
097: public OntProperty getInverseOf() {
098: return super .getInverseOf().asObjectProperty();
099: }
100:
101: /**
102: * <p>Answer an iterator over all of the properties that are declared to be inverse properties of
103: * this property, esnuring that each presents the objectProperty facet.</p>
104: * @return An iterator over the properties inverse to this property.
105: * @exception OntProfileException If the {@link Profile#INVERSE_OF()} property is not supported in the current language profile.
106: */
107: public ExtendedIterator listInverseOf() {
108: return super .listInverseOf().mapWith(
109: new AsMapper(ObjectProperty.class));
110: }
111:
112: /**
113: * <p>Answer the property that is the inverse of this property, ensuring that it presents
114: * the object property facet.</p>
115: * @return The property that is the inverse of this property, or null.
116: */
117: public OntProperty getInverse() {
118: OntProperty inv = super .getInverse();
119: return (inv != null) ? inv.asObjectProperty() : null;
120: }
121:
122: // Internal implementation methods
123: //////////////////////////////////
124:
125: //==============================================================================
126: // Inner class definitions
127: //==============================================================================
128:
129: }
130:
131: /*
132: (c) Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
133: All rights reserved.
134:
135: Redistribution and use in source and binary forms, with or without
136: modification, are permitted provided that the following conditions
137: are met:
138:
139: 1. Redistributions of source code must retain the above copyright
140: notice, this list of conditions and the following disclaimer.
141:
142: 2. Redistributions in binary form must reproduce the above copyright
143: notice, this list of conditions and the following disclaimer in the
144: documentation and/or other materials provided with the distribution.
145:
146: 3. The name of the author may not be used to endorse or promote products
147: derived from this software without specific prior written permission.
148:
149: THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
150: IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
151: OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
152: IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
153: INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
154: NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
155: DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
156: THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
157: (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
158: THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
159: */
|