KickJava   Java API By Example, From Geeks To Geeks.

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


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 08-Sep-2003
9  * Filename $RCSfile: QualifiedRestrictionImpl.java,v $
10  * Revision $Revision: 1.4 $
11  * Release status $State: Exp $
12  *
13  * Last modified on $Date: 2005/02/21 12:06:52 $
14  * by $Author: andy_seaborne $
15  *
16  * (c) Copyright 2001, 2002, 2003, 2004, 2005 Hewlett-Packard Development Company, LP
17  * [See end of file]
18  *****************************************************************************/

19
20 // Package
21
///////////////
22
package com.hp.hpl.jena.ontology.impl;
23
24
25 // Imports
26
///////////////
27
import com.hp.hpl.jena.enhanced.*;
28 import com.hp.hpl.jena.graph.Node;
29 import com.hp.hpl.jena.ontology.*;
30
31
32 /**
33  * <p>
34  * Implementation of qualied restrictions.
35  * </p>
36  *
37  * @author Ian Dickinson, HP Labs
38  * (<a HREF="mailto:Ian.Dickinson@hp.com" >email</a>)
39  * @version CVS $Id: QualifiedRestrictionImpl.java,v 1.4 2005/02/21 12:06:52 andy_seaborne Exp $
40  */

41 public class QualifiedRestrictionImpl
42     extends RestrictionImpl
43     implements QualifiedRestriction
44 {
45     // Constants
46
//////////////////////////////////
47

48     // Static variables
49
//////////////////////////////////
50

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

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

77     // Constructors
78
//////////////////////////////////
79

80     /**
81      * <p>
82      * Construct a qualified restriction node represented by the given node in the given graph.
83      * </p>
84      *
85      * @param n The node that represents the resource
86      * @param g The enh graph that contains n
87      */

88     public QualifiedRestrictionImpl( Node n, EnhGraph g ) {
89         super( n, g );
90     }
91
92
93     // External signature methods
94
//////////////////////////////////
95

96     /**
97      * <p>Assert that this qualified restriction restricts the property to have a given
98      * cardinality and to have values belonging to the class denoted by <code>hasClassQ</code>.
99      * Any existing statements for <code>hasClassQ</code>
100      * will be removed.</p>
101      * @param cls The class to which all of the value of the restricted property must belong
102      * @exception OntProfileException If the {@link Profile#HAS_CLASS_Q()} property is not supported in the current language profile.
103      */

104     public void setHasClassQ( OntClass cls ) {
105         setPropertyValue( getProfile().HAS_CLASS_Q(), "HAS_CLASS_Q", cls );
106     }
107
108     /**
109      * <p>Answer the class to which all values of the restricted property belong.</p>
110      * @return The ontology class of the restricted property values
111      * @exception OntProfileException If the {@link Profile#HAS_CLASS_Q()} property is not supported in the current language profile.
112      */

113     public OntClass getHasClassQ() {
114         return (OntClass) objectAs( getProfile().HAS_CLASS_Q(), "HAS_CLASS_Q", OntClass.class );
115     }
116
117     /**
118      * <p>Answer true if this qualified property restriction has the given class as
119      * the class to which all of the property values must belong.</p>
120      * @param cls The class to test against
121      * @return True if the given class is the class to which all members of this restriction must belong
122      * @exception OntProfileException If the {@link Profile#HAS_CLASS_Q()} property is not supported in the current language profile.
123      */

124     public boolean hasHasClassQ( OntClass cls ) {
125         return hasPropertyValue( getProfile().HAS_CLASS_Q(), "HAS_CLASS_Q", cls );
126     }
127     
128     /**
129      * <p>Remove the statement that this restriction has the given class
130      * as the class to which all values must belong. If this statement
131      * is not true of the current model, nothing happens.</p>
132      * @param cls The ont class that is the object of the <code>hasClassQ</code> property.
133      */

134     public void removeHasClassQ( OntClass cls ) {
135         removePropertyValue( getProfile().HAS_CLASS_Q(), "HAS_CLASS_Q", cls );
136     }
137
138
139     // Internal implementation methods
140
//////////////////////////////////
141

142     //==============================================================================
143
// Inner class definitions
144
//==============================================================================
145

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

174
Popular Tags