Source Code Cross Referenced for RestrictionImpl.java in  » RSS-RDF » Jena-2.5.5 » com » hp » hpl » jena » ontology » impl » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » RSS RDF » Jena 2.5.5 » com.hp.hpl.jena.ontology.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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            31-Mar-2003
009:         * Filename           $RCSfile: RestrictionImpl.java,v $
010:         * Revision           $Revision: 1.19 $
011:         * Release status     $State: Exp $
012:         *
013:         * Last modified on   $Date: 2008/01/02 12:08:03 $
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.graph.*;
023:        import com.hp.hpl.jena.enhanced.*;
024:        import com.hp.hpl.jena.ontology.*;
025:        import com.hp.hpl.jena.rdf.model.*;
026:
027:        /**
028:         * <p>
029:         * Implementation of the ontology abstraction representing restrictions.
030:         * </p>
031:         *
032:         * @author Ian Dickinson, HP Labs
033:         *         (<a  href="mailto:Ian.Dickinson@hp.com" >email</a>)
034:         * @version CVS $Id: RestrictionImpl.java,v 1.19 2008/01/02 12:08:03 andy_seaborne Exp $
035:         */
036:        public class RestrictionImpl extends OntClassImpl implements 
037:                Restriction {
038:            // Constants
039:            //////////////////////////////////
040:
041:            // Static variables
042:            //////////////////////////////////
043:
044:            /**
045:             * A factory for generating Restriction 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 RestrictionImpl(n, eg);
053:                    } else {
054:                        throw new ConversionException("Cannot convert node "
055:                                + n + " to Restriction");
056:                    }
057:                }
058:
059:                public boolean canWrap(Node node, EnhGraph eg) {
060:                    // node will support being an Restriction facet if it has rdf:type owl:Restriction or equivalent
061:                    Profile profile = (eg instanceof  OntModel) ? ((OntModel) eg)
062:                            .getProfile()
063:                            : null;
064:                    return (profile != null)
065:                            && profile.isSupported(node, eg, Restriction.class);
066:                }
067:            };
068:
069:            // Instance variables
070:            //////////////////////////////////
071:
072:            // Constructors
073:            //////////////////////////////////
074:
075:            /**
076:             * <p>
077:             * Construct a restriction node represented by the given node in the given graph.
078:             * </p>
079:             * 
080:             * @param n The node that represents the resource
081:             * @param g The enh graph that contains n
082:             */
083:            public RestrictionImpl(Node n, EnhGraph g) {
084:                super (n, g);
085:            }
086:
087:            // External signature methods
088:            //////////////////////////////////
089:
090:            // onProperty
091:
092:            /**
093:             * <p>Assert that the property that this restriction applies to is the given property. Any existing 
094:             * statements for <code>onProperty</code> will be removed.</p>
095:             * @param prop The property that this restriction applies to
096:             * @exception OntProfileException If the {@link Profile#ON_PROPERTY()} property is not supported in the current language profile.   
097:             */
098:            public void setOnProperty(Property prop) {
099:                setPropertyValue(getProfile().ON_PROPERTY(), "ON_PROPERTY",
100:                        prop);
101:            }
102:
103:            /**
104:             * <p>Answer the property that this property restriction applies to. If there is
105:             * more than one such resource, an arbitrary selection is made (though well-defined property restrictions
106:             * should not have more than one <code>onProperty</code> statement.</p>
107:             * @return The property that this property restriction applies to
108:             * @exception OntProfileException If the {@link Profile#ON_PROPERTY()} property is not supported in the current language profile.   
109:             */
110:            public OntProperty getOnProperty() {
111:                return (OntProperty) objectAs(getProfile().ON_PROPERTY(),
112:                        "ON_PROPERTY", OntProperty.class);
113:            }
114:
115:            /**
116:             * <p>Answer true if this restriction is a property restriction on the given property.</p>
117:             * @param prop A property to test against
118:             * @return True if this restriction is a restriction on <code>prop</code>
119:             * @exception OntProfileException If the {@link Profile#ON_PROPERTY()} property is not supported in the current language profile.   
120:             */
121:            public boolean onProperty(Property prop) {
122:                return hasPropertyValue(getProfile().ON_PROPERTY(),
123:                        "ON_PROPERTY", prop);
124:            }
125:
126:            /**
127:             * <p>Remove the given property as the property that this restriction applies to.  If this statement
128:             * is not true of the current model, nothing happens.</p>
129:             * @param prop The property to be removed as a the property that this restriction applies to
130:             */
131:            public void removeOnProperty(Property prop) {
132:                removePropertyValue(getProfile().ON_PROPERTY(), "ON_PROPERTY",
133:                        prop);
134:            }
135:
136:            /** 
137:             * <p>Answer a view of this restriction as an all values from  expression</p>
138:             * @return This class, but viewed as an AllValuesFromRestriction node
139:             * @exception ConversionException if the class cannot be converted to an all values from restriction
140:             * given the lanuage profile and the current state of the underlying model.
141:             */
142:            public AllValuesFromRestriction asAllValuesFromRestriction() {
143:                return (AllValuesFromRestriction) as(AllValuesFromRestriction.class);
144:            }
145:
146:            /** 
147:             * <p>Answer a view of this restriction as a some values from  expression</p>
148:             * @return This class, but viewed as a SomeValuesFromRestriction node
149:             * @exception ConversionException if the class cannot be converted to an all values from restriction
150:             * given the lanuage profile and the current state of the underlying model.
151:             */
152:            public SomeValuesFromRestriction asSomeValuesFromRestriction() {
153:                return (SomeValuesFromRestriction) as(SomeValuesFromRestriction.class);
154:            }
155:
156:            /** 
157:             * <p>Answer a view of this restriction as a has value expression</p>
158:             * @return This class, but viewed as a HasValueRestriction node
159:             * @exception ConversionException if the class cannot be converted to a has value restriction
160:             * given the lanuage profile and the current state of the underlying model.
161:             */
162:            public HasValueRestriction asHasValueRestriction() {
163:                return (HasValueRestriction) as(HasValueRestriction.class);
164:            }
165:
166:            /** 
167:             * <p>Answer a view of this restriction as a cardinality restriction class expression</p>
168:             * @return This class, but viewed as a CardinalityRestriction node
169:             * @exception ConversionException if the class cannot be converted to a cardinality restriction
170:             * given the lanuage profile and the current state of the underlying model.
171:             */
172:            public CardinalityRestriction asCardinalityRestriction() {
173:                return (CardinalityRestriction) as(CardinalityRestriction.class);
174:            }
175:
176:            /** 
177:             * <p>Answer a view of this restriction as a min cardinality restriction class expression</p>
178:             * @return This class, but viewed as a MinCardinalityRestriction node
179:             * @exception ConversionException if the class cannot be converted to a min cardinality restriction
180:             * given the lanuage profile and the current state of the underlying model.
181:             */
182:            public MinCardinalityRestriction asMinCardinalityRestriction() {
183:                return (MinCardinalityRestriction) as(MinCardinalityRestriction.class);
184:            }
185:
186:            /** 
187:             * <p>Answer a view of this restriction as a max cardinality restriction class expression</p>
188:             * @return This class, but viewed as a MaxCardinalityRestriction node
189:             * @exception ConversionException if the class cannot be converted to a max cardinality restriction
190:             * given the lanuage profile and the current state of the underlying model.
191:             */
192:            public MaxCardinalityRestriction asMaxCardinalityRestriction() {
193:                return (MaxCardinalityRestriction) as(MaxCardinalityRestriction.class);
194:            }
195:
196:            // type tests
197:
198:            /** 
199:             * <p>Answer true if this restriction is an all values from restriction</p>
200:             * @return True if this is an allValuesFrom property restriction
201:             * @exception ProfileException if {@link Profile#ALL_VALUES_FROM()} is not supported in the current profile
202:             */
203:            public boolean isAllValuesFromRestriction() {
204:                checkProfile(getProfile().ALL_VALUES_FROM(), "ALL_VALUES_FROM");
205:                return hasProperty(getProfile().ALL_VALUES_FROM());
206:            }
207:
208:            /** 
209:             * <p>Answer true if this restriction is a some values from restriction</p>
210:             * @return True if this is a someValuesFrom property restriction
211:             * @exception ProfileException if {@link Profile#SOME_VALUES_FROM()} is not supported in the current profile
212:             */
213:            public boolean isSomeValuesFromRestriction() {
214:                checkProfile(getProfile().SOME_VALUES_FROM(),
215:                        "SOME_VALUES_FROM");
216:                return hasProperty(getProfile().SOME_VALUES_FROM());
217:            }
218:
219:            /** 
220:             * <p>Answer true if this restriction is a has value restriction</p>
221:             * @return True if this is a hasValue property restriction
222:             * @exception ProfileException if {@link Profile#HAS_VALUE()} is not supported in the current profile
223:             */
224:            public boolean isHasValueRestriction() {
225:                checkProfile(getProfile().HAS_VALUE(), "HAS_VALUE");
226:                return hasProperty(getProfile().HAS_VALUE());
227:            }
228:
229:            /** 
230:             * <p>Answer true if this restriction is a cardinality restriction (ie is a property restriction
231:             * constructed with an <code>owl:cardinality</code> operator, or similar). This is not a test for
232:             * a restriction that tests cardinalities in general.</p>
233:             * @return True if this is a cardinality property restriction
234:             * @exception ProfileException if {@link Profile#CARDINALITY()} is not supported in the current profile
235:             */
236:            public boolean isCardinalityRestriction() {
237:                checkProfile(getProfile().CARDINALITY(), "CARDINALITY");
238:                return hasProperty(getProfile().CARDINALITY());
239:            }
240:
241:            /** 
242:             * <p>Answer true if this restriction is a min cardinality restriction (ie is a property restriction
243:             * constructed with an <code>owl:minCardinality</code> operator, or similar). This is not a test for
244:             * a restriction that tests cardinalities in general.</p>
245:             * @return True if this is a minCardinality property restriction
246:             * @exception ProfileException if {@link Profile#MIN_CARDINALITY()} is not supported in the current profile
247:             */
248:            public boolean isMinCardinalityRestriction() {
249:                checkProfile(getProfile().MIN_CARDINALITY(), "MIN_CARDINALITY");
250:                return hasProperty(getProfile().MIN_CARDINALITY());
251:            }
252:
253:            /** 
254:             * <p>Answer true if this restriction is a max cardinality restriction (ie is a property restriction
255:             * constructed with an <code>owl:maxCardinality</code> operator, or similar). This is not a test for
256:             * a restriction that tests cardinalities in general.</p>
257:             * @return True if this is a maxCardinality property restriction
258:             * @exception ProfileException if {@link Profile#MAX_CARDINALITY()} is not supported in the current profile
259:             */
260:            public boolean isMaxCardinalityRestriction() {
261:                checkProfile(getProfile().MAX_CARDINALITY(), "MAX_CARDINALITY");
262:                return hasProperty(getProfile().MAX_CARDINALITY());
263:            }
264:
265:            // conversions
266:
267:            /** 
268:             * <p>Convert this restriction to an all values from class expression.</p>
269:             * @param cls The class to which all values of the restricted property must belong, to be in the
270:             * extension of this restriction
271:             * @return This class, but converted to a AllValuesFromRestriction class expression
272:             * @exception ProfileException if {@link Profile#ALL_VALUES_FROM()} is not supported in the current profile
273:             */
274:            public AllValuesFromRestriction convertToAllValuesFromRestriction(
275:                    Resource cls) {
276:                setPropertyValue(getProfile().ALL_VALUES_FROM(),
277:                        "ALL_VALUES_FROM", cls);
278:                return (AllValuesFromRestriction) as(AllValuesFromRestriction.class);
279:            }
280:
281:            /** 
282:             * <p>Convert this restriction to a some values from class expression</p>
283:             * @param cls The class to which at least one value of the restricted property must belong, to be in the
284:             * extension of this restriction
285:             * @return This class, but converted to a SomeValuesFromRestriction node
286:             * @exception ProfileException if {@link Profile#SOME_VALUES_FROM()} is not supported in the current profile
287:             */
288:            public SomeValuesFromRestriction convertToSomeValuesFromRestriction(
289:                    Resource cls) {
290:                setPropertyValue(getProfile().SOME_VALUES_FROM(),
291:                        "SOME_VALUES_FROM", cls);
292:                return (SomeValuesFromRestriction) as(SomeValuesFromRestriction.class);
293:            }
294:
295:            /** 
296:             * <p>Convert this restriction to a has value class expression</p>
297:             * @param value The value which the restricted property must have, for resource to be
298:             * in the extension of this restriction
299:             * @return This class, but converted to a HasValueRestriction
300:             * @exception ProfileException if {@link Profile#HAS_VALUE()} is not supported in the current profile
301:             */
302:            public HasValueRestriction convertToHasValueRestriction(
303:                    RDFNode value) {
304:                setPropertyValue(getProfile().HAS_VALUE(), "HAS_VALUE", value);
305:                return (HasValueRestriction) as(HasValueRestriction.class);
306:            }
307:
308:            /** 
309:             * <p>Convert this restriction to a cardinality restriction class expression</p>
310:             * @param cardinality The exact cardinality for the restricted property
311:             * @return This class, but converted to a CardinalityRestriction node
312:             * @exception ProfileException if {@link Profile#CARDINALITY()} is not supported in the current profile
313:             */
314:            public CardinalityRestriction convertToCardinalityRestriction(
315:                    int cardinality) {
316:                setPropertyValue(getProfile().CARDINALITY(), "CARDINALITY",
317:                        getModel().createTypedLiteral(cardinality));
318:                return (CardinalityRestriction) as(CardinalityRestriction.class);
319:            }
320:
321:            /** 
322:             * <p>Convert this restriction to a min cardinality restriction class expression</p>
323:             * @param cardinality The minimum cardinality for the restricted property
324:             * @return This class, but converted to a MinCardinalityRestriction node
325:             * @exception ProfileException if {@link Profile#MIN_CARDINALITY()} is not supported in the current profile
326:             */
327:            public MinCardinalityRestriction convertToMinCardinalityRestriction(
328:                    int cardinality) {
329:                setPropertyValue(getProfile().MIN_CARDINALITY(),
330:                        "MIN_CARDINALITY", getModel().createTypedLiteral(
331:                                cardinality));
332:                return (MinCardinalityRestriction) as(MinCardinalityRestriction.class);
333:            }
334:
335:            /** 
336:             * <p>Convert this restriction to a max cardinality restriction class expression</p>
337:             * @param cardinality The maximum cardinality for the restricted property
338:             * @return This class, but converted to a MaxCardinalityRestriction node
339:             * @exception ProfileException if {@link Profile#MAX_CARDINALITY()} is not supported in the current profile
340:             */
341:            public MaxCardinalityRestriction convertToMaxCardinalityRestriction(
342:                    int cardinality) {
343:                setPropertyValue(getProfile().MAX_CARDINALITY(),
344:                        "MAX_CARDINALITY", getModel().createTypedLiteral(
345:                                cardinality));
346:                return (MaxCardinalityRestriction) as(MaxCardinalityRestriction.class);
347:            }
348:
349:            // Internal implementation methods
350:            //////////////////////////////////
351:
352:            //==============================================================================
353:            // Inner class definitions
354:            //==============================================================================
355:
356:        }
357:
358:        /*
359:         (c) Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
360:         All rights reserved.
361:
362:         Redistribution and use in source and binary forms, with or without
363:         modification, are permitted provided that the following conditions
364:         are met:
365:
366:         1. Redistributions of source code must retain the above copyright
367:         notice, this list of conditions and the following disclaimer.
368:
369:         2. Redistributions in binary form must reproduce the above copyright
370:         notice, this list of conditions and the following disclaimer in the
371:         documentation and/or other materials provided with the distribution.
372:
373:         3. The name of the author may not be used to endorse or promote products
374:         derived from this software without specific prior written permission.
375:
376:         THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
377:         IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
378:         OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
379:         IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
380:         INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
381:         NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
382:         DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
383:         THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
384:         (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
385:         THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
386:         */
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.