KickJava   Java API By Example, From Geeks To Geeks.

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


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: MinCardinalityQRestrictionImpl.java,v $
10  * Revision $Revision: 1.4 $
11  * Release status $State: Exp $
12  *
13  * Last modified on $Date: 2005/02/21 12:06:27 $
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.*;
29 import com.hp.hpl.jena.ontology.*;
30
31
32 /**
33  * <p>
34  * Implementation of the min qualified cardinality restriction
35  * </p>
36  *
37  * @author Ian Dickinson, HP Labs
38  * (<a HREF="mailto:Ian.Dickinson@hp.com" >email</a>)
39  * @version CVS $Id: MinCardinalityQRestrictionImpl.java,v 1.4 2005/02/21 12:06:27 andy_seaborne Exp $
40  */

41 public class MinCardinalityQRestrictionImpl
42     extends QualifiedRestrictionImpl
43     implements MinCardinalityQRestriction
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 MinCardinalityQRestrictionImpl( n, eg );
60             }
61             else {
62                 throw new ConversionException( "Cannot convert node " + n + " to MinCardinalityQRestriction");
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, MinCardinalityQRestriction.class );
70         }
71     };
72     
73
74     // Instance variables
75
//////////////////////////////////
76

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

85     public MinCardinalityQRestrictionImpl( Node n, EnhGraph g ) {
86         super( n, g );
87     }
88
89
90     // Constructors
91
//////////////////////////////////
92

93     // External signature methods
94
//////////////////////////////////
95

96     /**
97      * <p>Assert that this restriction restricts the property to have the given
98      * min cardinality. Any existing statements for <code>cardinalityQ</code>
99      * will be removed.</p>
100      * @param cardinality The cardinality of the restricted property
101      * @exception OntProfileException If the {@link Profile#MIN_CARDINALITY_Q()} property is not supported in the current language profile.
102      */

103     public void setMinCardinalityQ( int cardinality ) {
104         setPropertyValue( getProfile().MIN_CARDINALITY_Q(), "MIN_CARDINALITY_Q", getModel().createTypedLiteral( cardinality ) );
105     }
106
107     /**
108      * <p>Answer the cardinality of the restricted property.</p>
109      * @return The cardinality of the restricted property
110      * @exception OntProfileException If the {@link Profile#MIN_CARDINALITY_Q()} property is not supported in the current language profile.
111      */

112     public int getMinCardinalityQ() {
113         return objectAsInt( getProfile().MIN_CARDINALITY_Q(), "MIN_CARDINALITY_Q" );
114     }
115
116     /**
117      * <p>Answer true if this property restriction has the given cardinality.</p>
118      * @param cardinality The cardinality to test against
119      * @return True if the given cardinality is the cardinality of the restricted property in this restriction
120      * @exception OntProfileException If the {@link Profile#MIN_CARDINALITY_Q()} property is not supported in the current language profile.
121      */

122     public boolean hasMinCardinalityQ( int cardinality ) {
123         return hasPropertyValue( getProfile().MIN_CARDINALITY_Q(), "MIN_CARDINALITY_Q", getModel().createTypedLiteral( cardinality ) );
124     }
125     
126     /**
127      * <p>Remove the statement that this restriction has the given cardinality
128      * for the restricted property. If this statement
129      * is not true of the current model, nothing happens.</p>
130      * @param cardinality A cardinality value to be removed from this restriction
131      * @exception OntProfileException If the {@link Profile#MIN_CARDINALITY_Q()} property is not supported in the current language profile.
132      */

133     public void removeMinCardinalityQ( int cardinality ) {
134         removePropertyValue( getProfile().MIN_CARDINALITY_Q(), "MIN_CARDINALITY_Q", getModel().createTypedLiteral( cardinality ) );
135     }
136     
137
138     // Internal implementation methods
139
//////////////////////////////////
140

141     //==============================================================================
142
// Inner class definitions
143
//==============================================================================
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