Source Code Cross Referenced for EnhNode.java in  » RSS-RDF » Jena-2.5.5 » com » hp » hpl » jena » enhanced » 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.enhanced 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:          (c) Copyright 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
003:          [See end of file]
004:          $Id: EnhNode.java,v 1.19 2008/01/02 12:09:12 andy_seaborne Exp $
005:         */
006:
007:        package com.hp.hpl.jena.enhanced;
008:
009:        import com.hp.hpl.jena.graph.*;
010:        import com.hp.hpl.jena.rdf.model.*;
011:
012:        /**
013:         * <p>
014:         * A specialisation of Polymorphic that models an extended node in a an extended graph. An extended node
015:         * wraps a normal node, and adds additional convenience access or user affordances, though the state
016:         * remains in the graph itself.
017:         * </p>
018:         * @author <a href="mailto:Jeremy.Carroll@hp.com">Jeremy Carroll</a> (original code)<br>
019:         *         <a href="mailto:Chris.Dollin@hp.com">Chris Dollin</a> (original code)<br>
020:         *         <a href="mailto:Ian.Dickinson@hp.com">Ian Dickinson</a> (refactoring and commentage)
021:         */
022:        public class EnhNode extends Polymorphic implements  FrontsNode {
023:
024:            /** The graph node that this enhanced node is wrapping */
025:            final protected Node node;
026:
027:            /** The enhanced graph containing this node */
028:            final protected EnhGraph enhGraph;
029:
030:            public EnhNode(Node n, EnhGraph g) {
031:                super ();
032:                node = n;
033:                enhGraph = g;
034:            }
035:
036:            // External interface
037:
038:            /** 
039:             * Answer the graph node that this enhanced node wraps
040:             * @return A plain node
041:             */
042:            public Node asNode() {
043:                return node;
044:            }
045:
046:            /**
047:             * Answer the graph containing this node
048:             * @return An enhanced graph 
049:             */
050:            public EnhGraph getGraph() {
051:                return enhGraph;
052:            }
053:
054:            /**
055:                An enhanced node is Anon[ymous] iff its underlying node is Blank.
056:             */
057:            public final boolean isAnon() {
058:                return node.isBlank();
059:            }
060:
061:            /**
062:                An enhanced node is Literal iff its underlying node is too.
063:             */
064:            public final boolean isLiteral() {
065:                return node.isLiteral();
066:            }
067:
068:            /**
069:                An enhanced node is a URI resource iff its underlying node is too.
070:             */
071:            public final boolean isURIResource() {
072:                return node.isURI();
073:            }
074:
075:            /**
076:                An enhanced node is a resource if it's node is a URI node or a blank node.
077:             */
078:            public final boolean isResource() {
079:                return node.isURI() || node.isBlank();
080:            }
081:
082:            /**
083:             * Answer a facet of this node, where that facet is denoted by the
084:             * given type.
085:             * 
086:             * @param t A type denoting the desired facet of the underlying node
087:             * @return An enhanced nodet that corresponds to t; this may be <i>this</i>
088:             *         Java object, or a different object.
089:             */
090:            public EnhNode viewAs(Class t) {
091:                return (EnhNode) asInternal(t);
092:            }
093:
094:            /** allow subclasses to implement RDFNode & its subinterface */
095:            public RDFNode as(Class t) {
096:                return (RDFNode) viewAs(t);
097:            }
098:
099:            /**
100:                API-level method for polymorphic testing
101:             */
102:            public boolean canAs(Class t) {
103:                return canSupport(t);
104:            }
105:
106:            /**
107:             * The hash code of an enhanced node is defined to be the same as the underlying node.
108:             * @return The hashcode as an int
109:             */
110:            final public int hashCode() {
111:                return node.hashCode();
112:            }
113:
114:            /**
115:             * An enhanced node is equal to another enhanced node n iff the underlying 
116:             * nodes are equal. We generalise to allow the other object to be any class
117:             * implementing asNode, because we allow other implemementations of
118:             * Resource than EnhNodes, at least in principle.
119:             * This is deemed to be a complete and correct interpretation of enhanced node
120:             * equality, which is why this method has been marked final.
121:             * 
122:             * @param o An object to test for equality with this node
123:             * @return True if o is equal to this node.
124:             */
125:            final public boolean equals(Object o) {
126:                return o instanceof  FrontsNode
127:                        && node.equals(((FrontsNode) o).asNode());
128:            }
129:
130:            public boolean isValid() {
131:                return true;
132:            }
133:
134:            /** 
135:                Answer an new enhanced node object that presents <i>this</i> in a way 
136:                which satisfies type <code>t</code>. The new object is linked into this
137:                object's sibling ring. If the node cannot be converted, throw an
138:                UnsupportedPolymorphismException.
139:             */
140:            protected Polymorphic convertTo(Class t) {
141:                EnhGraph eg = getGraph();
142:                if (eg == null)
143:                    throw new UnsupportedPolymorphismException(this , t);
144:                Implementation imp = getPersonality().getImplementation(t);
145:                if (imp == null)
146:                    throw new UnsupportedPolymorphismException(this , t);
147:                Polymorphic result = imp.wrap(asNode(), eg);
148:                this .addView(result);
149:                return result;
150:            }
151:
152:            /**
153:                answer true iff this enhanced node can support the class <code>t</code>,
154:                ie it is already a value <code>t</code> or it can be reimplemented
155:                as a <code>t</code> via the graph's personality's implementation.
156:                If this node has no graph, answer false.       
157:             */
158:            protected boolean canSupport(Class t) {
159:                if (alreadyHasView(t))
160:                    return true;
161:                if (getGraph() == null)
162:                    return false;
163:                Implementation imp = getPersonality().getImplementation(t);
164:                return imp == null ? false : imp.canWrap(asNode(), getGraph());
165:            }
166:
167:            /**
168:             * Answer the personality object bound to this enhanced node, which we obtain from 
169:             * the associated enhanced graph.
170:             * 
171:             * @return The personality object
172:             */
173:            protected Personality getPersonality() {
174:                return ((GraphPersonality) getGraph().getPersonality())
175:                        .nodePersonality();
176:            }
177:
178:        }
179:
180:        /*
181:         (c) Copyright 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
182:         All rights reserved.
183:
184:         Redistribution and use in source and binary forms, with or without
185:         modification, are permitted provided that the following conditions
186:         are met:
187:
188:         1. Redistributions of source code must retain the above copyright
189:         notice, this list of conditions and the following disclaimer.
190:
191:         2. Redistributions in binary form must reproduce the above copyright
192:         notice, this list of conditions and the following disclaimer in the
193:         documentation and/or other materials provided with the distribution.
194:
195:         3. The name of the author may not be used to endorse or promote products
196:         derived from this software without specific prior written permission.
197:
198:         THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
199:         IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
200:         OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
201:         IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
202:         INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
203:         NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
204:         DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
205:         THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
206:         (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
207:         THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
208:         */
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.