KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > hp > hpl > jena > ontology > impl > ObjectPropertyImpl


1 /*****************************************************************************
2  * Source code information
3  * -----------------------
4  * Original author Ian Dickinson, HP Labs Bristol
5  * Author email Ian.Dickinson@hp.com
6  * Package Jena 2
7  * Web http://sourceforge.net/projects/jena/
8  * Created 01-Apr-2003
9  * Filename $RCSfile: ObjectPropertyImpl.java,v $
10  * Revision $Revision: 1.9 $
11  * Release status $State: Exp $
12  *
13  * Last modified on $Date: 2005/02/21 12:06:38 $
14  * by $Author: andy_seaborne $
15  *
16  * (c) Copyright 2002, 2003, 2004, 2005 Hewlett-Packard Development Company, LP
17  * (see footer for full conditions)
18  *****************************************************************************/

19
20 // Package
21
///////////////
22
package com.hp.hpl.jena.ontology.impl;
23
24
25
26 // Imports
27
///////////////
28
import com.hp.hpl.jena.enhanced.*;
29 import com.hp.hpl.jena.graph.*;
30 import com.hp.hpl.jena.ontology.*;
31 import com.hp.hpl.jena.util.iterator.ExtendedIterator;
32
33
34
35 /**
36  * <p>
37  * Implementation of the object property abstraction
38  * </p>
39  *
40  * @author Ian Dickinson, HP Labs
41  * (<a HREF="mailto:Ian.Dickinson@hp.com" >email</a>)
42  * @version CVS $Id: ObjectPropertyImpl.java,v 1.9 2005/02/21 12:06:38 andy_seaborne Exp $
43  */

44 public class ObjectPropertyImpl
45     extends OntPropertyImpl
46     implements ObjectProperty
47 {
48     // Constants
49
//////////////////////////////////
50

51     // Static variables
52
//////////////////////////////////
53

54     /**
55      * A factory for generating ObjectProperty facets from nodes in enhanced graphs.
56      * Note: should not be invoked directly by user code: use
57      * {@link com.hp.hpl.jena.rdf.model.RDFNode#as as()} instead.
58      */

59     public static Implementation factory = new Implementation() {
60         public EnhNode wrap( Node n, EnhGraph eg ) {
61             if (canWrap( n, eg )) {
62                 return new ObjectPropertyImpl( n, eg );
63             }
64             else {
65                 throw new ConversionException( "Cannot convert node " + n + " to ObjectProperty");
66             }
67         }
68             
69         public boolean canWrap( Node node, EnhGraph eg ) {
70             // node will support being an ObjectProperty facet if it has rdf:type owl:ObjectProperty or equivalent
71
Profile profile = (eg instanceof OntModel) ? ((OntModel) eg).getProfile() : null;
72             return (profile != null) && profile.isSupported( node, eg, ObjectProperty.class );
73         }
74     };
75
76
77     // Instance variables
78
//////////////////////////////////
79

80     // Constructors
81
//////////////////////////////////
82

83     /**
84      * <p>
85      * Construct a functional property node represented by the given node in the given graph.
86      * </p>
87      *
88      * @param n The node that represents the resource
89      * @param g The enh graph that contains n
90      */

91     public ObjectPropertyImpl( Node n, EnhGraph g ) {
92         super( n, g );
93     }
94
95
96     // External signature methods
97
//////////////////////////////////
98

99     /**
100      * <p>Answer a property that is an inverse of this property, ensuring that it
101      * presents the ObjectProperty facet.</p>
102      * @return A property inverse to this property
103      * @exception OntProfileException If the {@link Profile#INVERSE_OF()} property is not supported in the current language profile.
104      */

105     public OntProperty getInverseOf() {
106         return super.getInverseOf().asObjectProperty();
107     }
108
109     /**
110      * <p>Answer an iterator over all of the properties that are declared to be inverse properties of
111      * this property, esnuring that each presents the objectProperty facet.</p>
112      * @return An iterator over the properties inverse to this property.
113      * @exception OntProfileException If the {@link Profile#INVERSE_OF()} property is not supported in the current language profile.
114      */

115     public ExtendedIterator listInverseOf() {
116         return super.listInverseOf().mapWith( new AsMapper( ObjectProperty.class ));
117     }
118
119     /**
120      * <p>Answer the property that is the inverse of this property, ensuring that it presents
121      * the object property facet.</p>
122      * @return The property that is the inverse of this property, or null.
123      */

124     public OntProperty getInverse() {
125         OntProperty inv = super.getInverse();
126         return (inv != null) ? inv.asObjectProperty() : null;
127     }
128     
129
130     // Internal implementation methods
131
//////////////////////////////////
132

133     //==============================================================================
134
// Inner class definitions
135
//==============================================================================
136

137 }
138
139
140 /*
141     (c) Copyright 2002, 2003, 2004, 2005 Hewlett-Packard Development Company, LP
142     All rights reserved.
143
144     Redistribution and use in source and binary forms, with or without
145     modification, are permitted provided that the following conditions
146     are met:
147
148     1. Redistributions of source code must retain the above copyright
149        notice, this list of conditions and the following disclaimer.
150
151     2. Redistributions in binary form must reproduce the above copyright
152        notice, this list of conditions and the following disclaimer in the
153        documentation and/or other materials provided with the distribution.
154
155     3. The name of the author may not be used to endorse or promote products
156        derived from this software without specific prior written permission.
157
158     THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
159     IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
160     OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
161     IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
162     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
163     NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
164     DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
165     THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
166     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
167     THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
168 */

169
170
Popular Tags