Source Code Cross Referenced for IndividualImpl.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: IndividualImpl.java,v $
010:         * Revision           $Revision: 1.17 $
011:         * Release status     $State: Exp $
012:         *
013:         * Last modified on   $Date: 2008/01/23 12:47:00 $
014:         *               by   $Author: ian_dickinson $
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.ontology.*;
023:        import com.hp.hpl.jena.rdf.model.*;
024:        import com.hp.hpl.jena.util.iterator.ExtendedIterator;
025:        import com.hp.hpl.jena.enhanced.*;
026:        import com.hp.hpl.jena.graph.*;
027:
028:        /**
029:         * <p>
030:         * Implementation for the ontology abstraction representing ontology class descriptions.
031:         * </p>
032:         *
033:         * @author Ian Dickinson, HP Labs
034:         *         (<a  href="mailto:Ian.Dickinson@hp.com" >email</a>)
035:         * @version CVS $Id: IndividualImpl.java,v 1.17 2008/01/23 12:47:00 ian_dickinson Exp $
036:         */
037:        public class IndividualImpl extends OntResourceImpl implements 
038:                Individual {
039:            // Constants
040:            //////////////////////////////////
041:
042:            // Static variables
043:            //////////////////////////////////
044:
045:            /**
046:             * A factory for generating Individual facets from nodes in enhanced graphs.
047:             * Note: should not be invoked directly by user code: use
048:             * {@link com.hp.hpl.jena.rdf.model.RDFNode#as as()} instead.
049:             */
050:            public static Implementation factory = new Implementation() {
051:                public EnhNode wrap(Node n, EnhGraph eg) {
052:                    if (canWrap(n, eg)) {
053:                        return new IndividualImpl(n, eg);
054:                    } else {
055:                        throw new ConversionException("Cannot convert node "
056:                                + n.toString() + " to Individual");
057:                    }
058:                }
059:
060:                public boolean canWrap(Node node, EnhGraph eg) {
061:                    // node will support being an Individual facet if it is a URI node or bNode
062:                    Profile profile = (eg instanceof  OntModel) ? ((OntModel) eg)
063:                            .getProfile()
064:                            : null;
065:                    return (profile != null)
066:                            && profile.isSupported(node, eg, Individual.class);
067:                }
068:            };
069:
070:            // Instance variables
071:            //////////////////////////////////
072:
073:            // Constructors
074:            //////////////////////////////////
075:
076:            /**
077:             * <p>
078:             * Construct an individual represented by the given node in the given graph.
079:             * </p>
080:             *
081:             * @param n The node that represents the resource
082:             * @param g The enh graph that contains n
083:             */
084:            public IndividualImpl(Node n, EnhGraph g) {
085:                super (n, g);
086:            }
087:
088:            // External signature methods
089:            //////////////////////////////////
090:
091:            /**
092:             * <p>Set the ontology class for this individual, replacing any
093:             * existing class membership. Class membership is encoded using the
094:             * <code>rdf:type</code> property. Any existing statements for the RDF type
095:             * will first be removed.</p>
096:             *
097:             * @param cls The RDF resource denoting the new class to which this individual belongs,
098:             *                 which will replace any existing <code>rdf:type</code> property.
099:             */
100:            public void setOntClass(Resource cls) {
101:                setRDFType(cls);
102:            }
103:
104:            /**
105:             * <p>Add the given ontology class as one of the classes to which
106:             * this individual belongs. Class membership is encoded using the
107:             * <code>rdf:type</code> property. </p>
108:             *
109:             * @param cls An RDF resource denoting an additional class to which this individual
110:             * belongs.
111:             */
112:            public void addOntClass(Resource cls) {
113:                addRDFType(cls);
114:            }
115:
116:            /**
117:             * <p>
118:             * Answer an ontology class to which this individual belongs. If the individual
119:             * belongs to more than one class, which is common in ontology models using
120:             * a reasoner, then the return value will be one of
121:             * the possible values but <strong>it is not specified which one</strong>.
122:             * In the case of multiple classes, callers <strong>should not</strong> rely on
123:             * the return value being consistent, e.g. across runs, since it may
124:             * depend on the underlying hash indexes in the model. </p>
125:             * <p>This method considers any ontology class for the individual, not just
126:             * <em>direct</em> classes. It is equivalent to <code>getOntClass(false)</code>.
127:             * </p>
128:             *
129:             * @return A resource denoting the ontology class for this individual, or one of them if
130:             * more than one is defined.
131:             * @exception ConversionException if the return value is known to be an
132:             * ontology class, assuming strict type checking is turned on for the underlying
133:             * <code>OntModel</code>. See {@link OntModel#setStrictMode(boolean)}
134:             */
135:            public OntClass getOntClass() {
136:                return getOntClass(false);
137:            }
138:
139:            /**
140:             * <p>
141:             * Answer an ontology class to which this individual belongs. If the resource
142:             * belongs to more than one class, which is common in ontology models using
143:             * a reasoner, then the return value will be one of
144:             * the possible values but <strong>it is not specified which one</strong>.
145:             * In the case of multiple classes, callers <strong>should not</strong> rely on
146:             * the return value being consistent, e.g. across runs, since it may
147:             * depend on the underlying hash indexes in the model. </p>
148:             *
149:             * @param direct If <code>true</code>, only <em>direct</em> classes are considered.
150:             * A class is a direct class of this <code>Individual</code> if and only if
151:             * there is no other resource is both an <code>rdf:type</code> of this
152:             * individual and a sub-class of the candidate class.
153:             *
154:             * @return A resource denoting the ontology class for this individual, or one of them if
155:             * more than one is defined.
156:             * @exception ConversionException if the return value is known to be an
157:             * ontology class, assuming strict type checking is turned on for the underlying
158:             * <code>OntModel</code>. See {@link OntModel#setStrictMode(boolean)}
159:             */
160:            public OntClass getOntClass(boolean direct) {
161:                return (OntClass) (getRDFType(direct).as(OntClass.class));
162:            }
163:
164:            /**
165:             * <p>
166:             * Answer an iterator over the ontology classes to which this individual belongs.
167:             * The members of the iterator will be {@link OntClass} objects.
168:             * </p>
169:             *
170:             * @param direct If true, only answer those resources that are direct types
171:             * of this individual, not the super-classes of the class etc.
172:             * @return An iterator over the set of this individual's classes. Each member
173:             * of the iteration will be an {@link OntClass}.
174:             */
175:            public ExtendedIterator listOntClasses(boolean direct) {
176:                return listRDFTypes(direct).mapWith(
177:                        new AsMapper(OntClass.class));
178:            }
179:
180:            /**
181:             * <p>
182:             * Answer true if this individual is a member of the class denoted by the
183:             * given class resource.
184:             * </p>
185:             *
186:             * @param ontClass Denotes an ontology class to which this individual may belong
187:             * @param direct If true, only consider the direct types of this individual, ignoring
188:             * the super-classes of the stated types.
189:             * @return True if this individual is a member of the given class, possibly taking the
190:             * directness constraint into account.
191:             */
192:            public boolean hasOntClass(Resource ontClass, boolean direct) {
193:                return hasRDFType(ontClass, direct);
194:            }
195:
196:            /**
197:             * <p>
198:             * Answer true if this individual is a member of the class denoted by the
199:             * given ontology class resource.  Not limited to only direct class relationships,
200:             * so this is equivalent to:
201:             * <code><pre>
202:             * hasOntClass( ontClass, false );
203:             * </pre></code>
204:             * </p>
205:             *
206:             * @param ontClass Denotes a class to which this individual may belong
207:             * @return True if this individual has the given class as one of its <code>rdf:type</code>'s.
208:             */
209:            public boolean hasOntClass(Resource ontClass) {
210:                return hasOntClass(ontClass, false);
211:            }
212:
213:            /**
214:             * <p>
215:             * Answer true if this individual is a member of the class denoted by the
216:             * given URI.</p>
217:             *
218:             * @param uri Denotes the URI of a class to which this value may belong
219:             * @return True if this individual has the given class as one of its <code>rdf:type</code>'s.
220:             */
221:            public boolean hasOntClass(String uri) {
222:                return hasRDFType(uri);
223:            }
224:
225:            /**
226:             * <p>Attempt to remove this <code>individual</code> as a member of the
227:             * given ontology class. This relationship is represented by a <code>rdf:type</code>
228:             * statement in the underlying model. If this relationship was originally
229:             * asserted, then removal will always succeed. However, if the <code>rdf:type</code>
230:             * relationship is entailed by the action of an attached reasoner, it may not be
231:             * possible to directly remove it. Callers should instead update the assertions
232:             * and axioms that entail the class membership relationship, and ensure the
233:             * reasoner gets chance to update the entailments.</p>
234:             * <p>If this individual is not a member of the given class, the
235:             * operation has no effect.</p>
236:             *
237:             * @param ontClass A resource denoting a class that that is to be removed from
238:             * the set of classes to which this individual belongs
239:             */
240:            public void removeOntClass(Resource ontClass) {
241:                removeRDFType(ontClass);
242:            }
243:
244:            // Internal implementation methods
245:            //////////////////////////////////
246:
247:            //==============================================================================
248:            // Inner class definitions
249:            //==============================================================================
250:
251:        }
252:
253:        /*
254:         (c) Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
255:         All rights reserved.
256:
257:         Redistribution and use in source and binary forms, with or without
258:         modification, are permitted provided that the following conditions
259:         are met:
260:
261:         1. Redistributions of source code must retain the above copyright
262:         notice, this list of conditions and the following disclaimer.
263:
264:         2. Redistributions in binary form must reproduce the above copyright
265:         notice, this list of conditions and the following disclaimer in the
266:         documentation and/or other materials provided with the distribution.
267:
268:         3. The name of the author may not be used to endorse or promote products
269:         derived from this software without specific prior written permission.
270:
271:         THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
272:         IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
273:         OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
274:         IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
275:         INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
276:         NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
277:         DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
278:         THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
279:         (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
280:         THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
281:         */
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.