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


001:        /*
002:         	(c) Copyright 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
003:         	All rights reserved - see end of file.
004:         	$Id: NodeToTriplesMapBase.java,v 1.18 2008/01/03 15:41:18 chris-dollin Exp $
005:         */
006:
007:        package com.hp.hpl.jena.mem;
008:
009:        import java.util.*;
010:
011:        import com.hp.hpl.jena.graph.*;
012:        import com.hp.hpl.jena.graph.Triple.Field;
013:        import com.hp.hpl.jena.util.iterator.*;
014:
015:        /**
016:         A base class for the "normal" and "faster" NodeToTriplesMaps.
017:        
018:         @author kers
019:         */
020:        public abstract class NodeToTriplesMapBase {
021:            /**
022:                 The map from nodes to Bunch(Triple).
023:             */
024:            public BunchMap bunchMap = new HashedBunchMap();
025:
026:            /**
027:                 The number of triples held in this NTM, maintained incrementally 
028:                 (because it's a pain to compute from scratch).
029:             */
030:            protected int size = 0;
031:
032:            protected final Field indexField;
033:            protected final Field f2;
034:            protected final Field f3;
035:
036:            public NodeToTriplesMapBase(Field indexField, Field f2, Field f3) {
037:                this .indexField = indexField;
038:                this .f2 = f2;
039:                this .f3 = f3;
040:            }
041:
042:            /**
043:                 Add <code>t</code> to this NTM; the node <code>o</code> <i>must</i>
044:                 be the index node of the triple. Answer <code>true</code> iff the triple
045:                 was not previously in the set, ie, it really truly has been added. 
046:             */
047:            public abstract boolean add(Triple t);
048:
049:            /**
050:                 Remove <code>t</code> from this NTM. Answer <code>true</code> iff the 
051:                 triple was previously in the set, ie, it really truly has been removed. 
052:             */
053:            public abstract boolean remove(Triple t);
054:
055:            public abstract Iterator iterator(Object o,
056:                    HashCommon.NotifyEmpty container);
057:
058:            /**
059:                 Answer true iff this NTM contains the concrete triple <code>t</code>.
060:             */
061:            public abstract boolean contains(Triple t);
062:
063:            public abstract boolean containsBySameValueAs(Triple t);
064:
065:            /**
066:                The nodes which appear in the index position of the stored triples; useful
067:                for eg listSubjects().
068:             */
069:            public final Iterator domain() {
070:                return bunchMap.keyIterator();
071:            }
072:
073:            protected final Object getIndexField(Triple t) {
074:                return indexField.getField(t).getIndexingValue();
075:            }
076:
077:            /**
078:                Clear this NTM; it will contain no triples.
079:             */
080:            public void clear() {
081:                bunchMap.clear();
082:                size = 0;
083:            }
084:
085:            public int size() {
086:                return size;
087:            }
088:
089:            public void removedOneViaIterator() {
090:                size -= 1; /* System.err.println( ">> rOVI: size := " + size ); */
091:            }
092:
093:            public boolean isEmpty() {
094:                return size == 0;
095:            }
096:
097:            public abstract ExtendedIterator iterator(Node index, Node n2,
098:                    Node n3);
099:
100:            /**
101:                Answer an iterator over all the triples that are indexed by the item <code>y</code>.
102:                Note that <code>y</code> need not be a Node (because of indexing values).
103:             */
104:            public abstract Iterator iteratorForIndexed(Object y);
105:
106:            /**
107:                Answer an iterator over all the triples in this NTM.
108:             */
109:            public ExtendedIterator iterateAll() {
110:                final Iterator nodes = domain();
111:                // System.err.println( "*>> NTM:iterateAll: nodes = " + IteratorCollection.iteratorToList( domain() ) );
112:                return new NiceIterator() {
113:                    private Iterator current = NullIterator.instance;
114:                    private NotifyMe emptier = new NotifyMe();
115:
116:                    // private Object cn = "(none)";
117:
118:                    public Object next() {
119:                        if (hasNext() == false)
120:                            noElements("NodeToTriples iterator");
121:                        return current.next();
122:                    }
123:
124:                    class NotifyMe implements  HashCommon.NotifyEmpty {
125:                        public void emptied() {
126:                            // System.err.println( ">> exhausted iterator for " + cn ); 
127:                            nodes.remove();
128:                        }
129:                    }
130:
131:                    public boolean hasNext() {
132:                        while (true) {
133:                            if (current.hasNext())
134:                                return true;
135:                            if (nodes.hasNext() == false)
136:                                return false;
137:                            Object next = nodes.next();
138:                            // cn = next;
139:                            // System.err.println( ">----> NTM:iterateAll:hasNext: node " + next );
140:                            current = iterator(next, emptier);
141:                        }
142:                    }
143:
144:                    public void remove() {
145:                        current.remove();
146:                    }
147:                };
148:            }
149:        }
150:
151:        /*
152:         * (c) Copyright 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP All rights
153:         * reserved.
154:         * 
155:         * Redistribution and use in source and binary forms, with or without
156:         * modification, are permitted provided that the following conditions are met:
157:         * 1. Redistributions of source code must retain the above copyright notice,
158:         * this list of conditions and the following disclaimer. 2. Redistributions in
159:         * binary form must reproduce the above copyright notice, this list of
160:         * conditions and the following disclaimer in the documentation and/or other
161:         * materials provided with the distribution. 3. The name of the author may not
162:         * be used to endorse or promote products derived from this software without
163:         * specific prior written permission.
164:         * 
165:         * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
166:         * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
167:         * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
168:         * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
169:         * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
170:         * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
171:         * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
172:         * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
173:         * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
174:         * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
175:         */
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.