KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > hp > hpl > jena > ontology > daml > impl > DAMLObjectPropertyImpl


1 /*****************************************************************************
2  * Source code information
3  * -----------------------
4  * Original author Ian Dickinson, HP Labs Bristol
5  * Author email Ian.Dickinson@hp.com
6  * Package Jena
7  * Created 4 Jan 2001
8  * Filename $RCSfile: DAMLObjectPropertyImpl.java,v $
9  * Revision $Revision: 1.7 $
10  * Release status Preview-release $State: Exp $
11  *
12  * Last modified on $Date: 2005/02/21 12:05:26 $
13  * by $Author: andy_seaborne $
14  *
15  * (c) Copyright 2001, 2002, 2002, 2003, 2004, 2005 Hewlett-Packard Development Company, LP
16  * (see footer for full conditions)
17  *****************************************************************************/

18
19 // Package
20
///////////////
21
package com.hp.hpl.jena.ontology.daml.impl;
22
23
24 // Imports
25
///////////////
26
import com.hp.hpl.jena.enhanced.*;
27 import com.hp.hpl.jena.graph.*;
28 import com.hp.hpl.jena.ontology.*;
29 import com.hp.hpl.jena.ontology.daml.*;
30 import com.hp.hpl.jena.vocabulary.*;
31
32
33
34 /**
35  * <p>Java encapsulation of an object property in a DAML ontology. An object property
36  * is a partition of the class of properties, in which the range of the property
37  * is a DAML instance (rather than a datatype). Object properties may be transitive
38  * and unambiguous, which are modelled in the specification by sub-classes of
39  * <code>ObjectProperty</code> named <code>TransitiveProperty</code> and
40  * <code>UnambiguousProperty</code>. In this API, transitivity and uniqueness are
41  * modelled as attributes of the DAMLObjectProperty object.</p>
42  *
43  * @author Ian Dickinson, HP Labs (<a HREF="mailto:Ian.Dickinson@hp.com">email</a>)
44  * @version CVS info: $Id: DAMLObjectPropertyImpl.java,v 1.7 2005/02/21 12:05:26 andy_seaborne Exp $
45  */

46 public class DAMLObjectPropertyImpl
47     extends DAMLPropertyImpl
48     implements DAMLObjectProperty
49 {
50     // Constants
51
//////////////////////////////////
52

53
54     // Static variables
55
//////////////////////////////////
56

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

62     public static Implementation factory = new Implementation() {
63         public EnhNode wrap( Node n, EnhGraph eg ) {
64             if (canWrap( n, eg )) {
65                 return new DAMLObjectPropertyImpl( n, eg );
66             }
67             else {
68                 throw new ConversionException( "Cannot convert node " + n.toString() + " to DAMLObjectProperty" );
69             }
70         }
71             
72         public boolean canWrap( Node n, EnhGraph g ) {
73             return hasType( n, g, DAML_OIL.ObjectProperty );
74         }
75     };
76
77
78     // Instance variables
79
//////////////////////////////////
80

81     /** Property accessor for inverseOf */
82     private PropertyAccessor m_propInverseOf = new PropertyAccessorImpl( getVocabulary().inverseOf(), this );
83
84
85
86     // Constructors
87
//////////////////////////////////
88

89     /**
90      * <p>
91      * Construct a DAML object property represented by the given node in the given graph.
92      * </p>
93      *
94      * @param n The node that represents the resource
95      * @param g The enh graph that contains n
96      */

97     public DAMLObjectPropertyImpl( Node n, EnhGraph g ) {
98         super( n, g );
99     }
100
101
102     // External signature methods
103
//////////////////////////////////
104

105
106     /**
107      * <p>Set the flag to indicate that this property is to be considered
108      * transitive - that is, it is defined by the DAML class <code>TransitiveProperty</code>.</p>
109      *
110      * @param transitive True for a transitive property
111      */

112     public void setIsTransitive( boolean transitive ) {
113         if (transitive) {
114             addRDFType( getVocabulary().TransitiveProperty() );
115         }
116         else {
117             removeRDFType( getVocabulary().TransitiveProperty() );
118         }
119     }
120
121
122     /**
123      * <p>Answer true if this property is transitive.</p>
124      *
125      * @return True if this property is transitive
126      */

127     public boolean isTransitive() {
128         return hasRDFType( getVocabulary().TransitiveProperty() ) ||
129                DAMLHierarchy.getInstance().isTransitiveProperty( this );
130     }
131
132
133     /**
134      * <p>Set the flag to indicate that this property is to be considered
135      * unabiguous - that is, it is defined by the DAML class <code>UnambiguousProperty</code>.</p>
136      *
137      * @param unambiguous True for a unabiguous property
138      */

139     public void setIsUnambiguous( boolean unambiguous ) {
140         if (unambiguous) {
141             addRDFType( getVocabulary().UnambiguousProperty() );
142         }
143         else {
144             removeRDFType( getVocabulary().UnambiguousProperty() );
145         }
146     }
147
148
149     /**
150      * <p>Answer true if this property is an unambiguous property.</p>
151      *
152      * @return True if this property is unambiguous
153      */

154     public boolean isUnambiguous() {
155         return hasRDFType( getVocabulary().UnambiguousProperty() );
156     }
157
158
159     /**
160      * <p>Property accessor for the <code>inverseOf</code> property of a DAML Property. This denotes
161      * that the named property (say, P) is an inverse of this property (say, Q). Formally,
162      * if (x, y) is an instance of P, then (y, x) is an instance of Q. According to the
163      * DAML specification, inverseOf is only defined for object properties (i.e. not
164      * datatype properties).</p>
165      *
166      * @return Property accessor for <code>inverseOf</code>
167      */

168     public PropertyAccessor prop_inverseOf() {
169         return m_propInverseOf;
170     }
171
172
173
174
175     // Internal implementation methods
176
//////////////////////////////////
177

178
179
180
181     //==============================================================================
182
// Inner class definitions
183
//==============================================================================
184

185
186 }
187
188 /*
189  * (c) Copyright 2001, 2002, 2002, 2003, 2004, 2005 Hewlett-Packard Development Company, LP
190  * All rights reserved.
191  *
192  * Redistribution and use in source and binary forms, with or without
193  * modification, are permitted provided that the following conditions
194  * are met:
195  * 1. Redistributions of source code must retain the above copyright
196  * notice, this list of conditions and the following disclaimer.
197  * 2. Redistributions in binary form must reproduce the above copyright
198  * notice, this list of conditions and the following disclaimer in the
199  * documentation and/or other materials provided with the distribution.
200  * 3. The name of the author may not be used to endorse or promote products
201  * derived from this software without specific prior written permission.
202  *
203  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
204  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
205  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
206  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
207  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
208  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
209  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
210  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
211  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
212  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
213  */

214
Popular Tags