Source Code Cross Referenced for EnhGraph.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 2002, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
003:          [See end of file]
004:          $Id: EnhGraph.java,v 1.20 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.util.cache.*;
011:
012:        /**
013:         A specialisation of Polymorphic that models an extended graph - that is, one that 
014:         contains{@link EnhNode Enhanced nodes} or one that itself exposes additional 
015:         capabilities beyond the graph API.
016:         <p>   
017:         <span style="color:red">WARNING</span>. The polymorphic aspects of EnhGraph 
018:         are <span style="color:red">not supported</span> and are not expected to be
019:         supported in this way for the indefinite future.
020:        
021:         @author <a href="mailto:Jeremy.Carroll@hp.com">Jeremy Carroll</a> (original code)
022:         <br><a href="mailto:Chris.Dollin@hp.com">Chris Dollin</a> (original code)
023:         <br><a href="mailto:Ian.Dickinson@hp.com">Ian Dickinson</a> 
024:         (refactoring and commentage)
025:         */
026:
027:        public class EnhGraph extends Polymorphic {
028:            // Instance variables
029:            /** The graph that this enhanced graph is wrapping */
030:            protected Graph graph;
031:
032:            /** Counter that helps to ensure that caches are kept distinct */
033:            static private int cnt = 0;
034:
035:            /** Cache of enhanced nodes that have been created */
036:            protected Cache enhNodes = CacheManager.createCache(
037:                    CacheManager.ENHNODECACHE, "EnhGraph-" + cnt++, 1000);
038:
039:            /** The unique personality that is bound to this polymorphic instace */
040:            private Personality personality;
041:
042:            public boolean isValid() {
043:                return true;
044:            }
045:
046:            // Constructors
047:            /**
048:             * Construct an enhanced graph from the given underlying graph, and
049:             * a factory for generating enhanced nodes.
050:             * 
051:             * @param g The underlying plain graph, may be null to defer binding to a given 
052:             *      graph until later.
053:             * @param p The personality factory, that maps types to realisations
054:             */
055:            public EnhGraph(Graph g, Personality p) {
056:                super ();
057:                graph = g;
058:                personality = p;
059:            }
060:
061:            // External methods
062:
063:            /**
064:             * Answer the normal graph that this enhanced graph is wrapping.
065:             * @return A graph
066:             */
067:            public Graph asGraph() {
068:                return graph;
069:            }
070:
071:            /**
072:             * Hashcode for an enhnaced graph is delegated to the underlyin graph.
073:             * @return The hashcode as an int
074:             */
075:            final public int hashCode() {
076:                return graph.hashCode();
077:            }
078:
079:            /**
080:             * An enhanced graph is equal to another graph g iff the underlying graphs
081:             * are equal.
082:             * This  is deemed to be a complete and correct interpretation of enhanced
083:             * graph equality, which is why this method has been marked final.
084:             * <p> Note that this equality test does not look for correspondance between
085:             * the structures in the two graphs.  To test whether another graph has the
086:             * same nodes and edges as this one, use {@link #isIsomorphicWith}.
087:             * </p>
088:             * @param o An object to test for equality with this node
089:             * @return True if o is equal to this node.
090:             * @see #isIsomorphicWith
091:             */
092:            final public boolean equals(Object o) {
093:                return this  == o || o instanceof  EnhGraph
094:                        && graph.equals(((EnhGraph) o).asGraph());
095:            }
096:
097:            /**
098:             * Answer true if the given enhanced graph contains the same nodes and 
099:             * edges as this graph.  The default implementation delegates this to the
100:             * underlying graph objects.
101:             * 
102:             * @param eg A graph to test
103:             * @return True if eg is a graph with the same structure as this.
104:             */
105:            final public boolean isIsomorphicWith(EnhGraph eg) {
106:                return graph.isIsomorphicWith(eg.graph);
107:            }
108:
109:            /**
110:             * Answer an enhanced node that wraps the given node and conforms to the given
111:             * interface type.
112:             * 
113:             * @param n A node (assumed to be in this graph)
114:             * @param interf A type denoting the enhanced facet desired
115:             * @return An enhanced node
116:             */
117:            public EnhNode getNodeAs(Node n, Class interf) {
118:                // We use a cache to avoid reconstructing the same Node too many times.
119:                EnhNode eh = (EnhNode) enhNodes.get(n);
120:                if (eh != null)
121:                    return eh.viewAs(interf);
122:
123:                // not in the cache, so build a new one
124:                eh = (EnhNode) ((GraphPersonality) personality)
125:                        .nodePersonality().newInstance(interf, n, this );
126:                enhNodes.put(n, eh);
127:                return eh;
128:            }
129:
130:            /**
131:             * Answer the cache controlle for this graph
132:             * @return A cache controller object
133:             */
134:            public CacheControl getNodeCacheControl() {
135:                return enhNodes;
136:            }
137:
138:            /**
139:             * Set the cache controller object for this graph
140:             * @param cc The cache controller
141:             */
142:            public void setNodeCache(Cache cc) {
143:                enhNodes = cc;
144:            }
145:
146:            /** 
147:             * Answer an enhanced graph that presents <i>this</i> in a way which satisfies type
148:             * t.  This is a stub method that has not yet been implemented.
149:             @deprecated
150:             @param t A type
151:             @return A polymorphic instance, possibly but not necessarily this, that conforms to t.
152:             */
153:            protected Polymorphic convertTo(Class t) {
154:                throw new PersonalityConfigException(
155:                        "Alternative perspectives on graphs has not been implemented yet");
156:            }
157:
158:            /**
159:                we can't convert to anything. 
160:                @deprecated
161:             */
162:            protected boolean canSupport(Class t) {
163:                return false;
164:            }
165:
166:            /**
167:             * Answer the personality object bound to this polymorphic instance
168:             * 
169:             * @return The personality object
170:             */
171:            protected Personality getPersonality() {
172:                return personality;
173:            }
174:
175:        }
176:
177:        /*
178:         (c) Copyright 2002, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
179:         All rights reserved.
180:
181:         Redistribution and use in source and binary forms, with or without
182:         modification, are permitted provided that the following conditions
183:         are met:
184:
185:         1. Redistributions of source code must retain the above copyright
186:         notice, this list of conditions and the following disclaimer.
187:
188:         2. Redistributions in binary form must reproduce the above copyright
189:         notice, this list of conditions and the following disclaimer in the
190:         documentation and/or other materials provided with the distribution.
191:
192:         3. The name of the author may not be used to endorse or promote products
193:         derived from this software without specific prior written permission.
194:
195:         THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
196:         IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
197:         OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
198:         IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
199:         INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
200:         NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
201:         DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
202:         THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
203:         (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
204:         THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
205:         */
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.