Source Code Cross Referenced for NodeToTriplesMap.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 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP, all rights reserved.
003:          [See end of file]
004:          $Id: NodeToTriplesMap.java,v 1.46 2008/01/02 12:09:51 andy_seaborne 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.*;
013:        import com.hp.hpl.jena.util.iterator.*;
014:
015:        /**
016:         NodeToTriplesMap: a map from nodes to sets of triples.
017:         Subclasses must override at least one of useXXXInFilter methods.
018:         @author kers
019:         */
020:        public class NodeToTriplesMap extends NodeToTriplesMapBase {
021:            public NodeToTriplesMap(Field indexField, Field f2, Field f3) {
022:                super (indexField, f2, f3);
023:            }
024:
025:            /** 
026:             	@see com.hp.hpl.jena.mem.Temp#add(com.hp.hpl.jena.graph.Triple)
027:             */
028:            public boolean add(Triple t) {
029:                Object o = getIndexField(t);
030:                OpenSetBunch s = (OpenSetBunch) bunchMap.get(o);
031:                if (s == null)
032:                    bunchMap.put(o, s = createSetBunch());
033:                if (s.baseSet().add(t)) {
034:                    size += 1;
035:                    return true;
036:                } else
037:                    return false;
038:            }
039:
040:            private static class OpenSetBunch extends SetBunch {
041:                private static final TripleBunch empty = new ArrayBunch();
042:
043:                public OpenSetBunch() {
044:                    super (empty);
045:                }
046:
047:                public Set baseSet() {
048:                    return elements;
049:                }
050:            }
051:
052:            private OpenSetBunch createSetBunch() {
053:                return new OpenSetBunch();
054:            }
055:
056:            /** 
057:             	@see com.hp.hpl.jena.mem.Temp#remove(com.hp.hpl.jena.graph.Triple)
058:             */
059:            public boolean remove(Triple t) {
060:                Object o = getIndexField(t);
061:                OpenSetBunch s = (OpenSetBunch) bunchMap.get(o);
062:                if (s == null)
063:                    return false;
064:                else {
065:                    Set base = s.baseSet();
066:                    boolean result = base.remove(t);
067:                    if (result)
068:                        size -= 1;
069:                    if (base.isEmpty())
070:                        bunchMap.remove(o);
071:                    return result;
072:                }
073:            }
074:
075:            public Iterator iterator(Object o, HashCommon.NotifyEmpty container) {
076:                TripleBunch b = bunchMap.get(o);
077:                return b == null ? NullIterator.instance : b.iterator();
078:            }
079:
080:            /** 
081:             	@see com.hp.hpl.jena.mem.Temp#contains(com.hp.hpl.jena.graph.Triple)
082:             */
083:            public boolean contains(Triple t) {
084:                TripleBunch s = bunchMap.get(getIndexField(t));
085:                return s == null ? false : s.contains(t);
086:            }
087:
088:            protected static boolean equalsObjectOK(Triple t) {
089:                Node o = t.getObject();
090:                return o.isLiteral() ? o.getLiteralDatatype() == null : true;
091:            }
092:
093:            public boolean containsBySameValueAs(Triple t) {
094:                return equalsObjectOK(t) ? contains(t) : slowContains(t);
095:            }
096:
097:            protected boolean slowContains(Triple t) {
098:                TripleBunch s = bunchMap.get(getIndexField(t));
099:                if (s == null)
100:                    return false;
101:                else {
102:                    Iterator it = s.iterator();
103:                    while (it.hasNext())
104:                        if (t.matches((Triple) it.next()))
105:                            return true;
106:                    return false;
107:                }
108:            }
109:
110:            /** 
111:             	@see com.hp.hpl.jena.mem.Temp#iterateAll(com.hp.hpl.jena.graph.Triple)
112:             */
113:            public ExtendedIterator iterateAll(Triple pattern) {
114:                return indexField.filterOn(pattern).and(f2.filterOn(pattern))
115:                        .and(f3.filterOn(pattern)).filterKeep(iterateAll());
116:            }
117:
118:            public ExtendedIterator iterator(Node index, Node n2, Node n3) {
119:                TripleBunch s = bunchMap.get(index.getIndexingValue());
120:                return s == null ? NullIterator.instance : f2.filterOn(n2).and(
121:                        f3.filterOn(n3)).filterKeep(s.iterator());
122:            }
123:
124:            /**
125:                Answer an iterator over all the triples that are indexed by the item <code>y</code>.
126:                Note that <code>y</code> need not be a Node (because of indexing values).
127:             */
128:            public Iterator iteratorForIndexed(Object y) {
129:                return get(y).iterator();
130:            }
131:
132:            /** 
133:                @see com.hp.hpl.jena.mem.Temp#get(java.lang.Object)
134:             */
135:            private TripleBunch get(Object y) {
136:                return bunchMap.get(y);
137:            }
138:        }
139:
140:        /*
141:         (c) Copyright 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
142:         All rights reserved.
143:
144:         Redistribution and use in source and binary forms, with or without
145:         modification, are permitted provided that the following conditions
146:         are met:
147:
148:         1. Redistributions of source code must retain the above copyright
149:         notice, this list of conditions and the following disclaimer.
150:
151:         2. Redistributions in binary form must reproduce the above copyright
152:         notice, this list of conditions and the following disclaimer in the
153:         documentation and/or other materials provided with the distribution.
154:
155:         3. The name of the author may not be used to endorse or promote products
156:         derived from this software without specific prior written permission.
157:
158:         THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
159:         IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
160:         OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
161:         IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
162:         INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
163:         NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
164:         DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
165:         THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
166:         (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
167:         THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
168:         */
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.