Source Code Cross Referenced for CompositionBase.java in  » RSS-RDF » Jena-2.5.5 » com » hp » hpl » jena » graph » compose » 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.graph.compose 
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            4 Mar 2003
009:         * Filename           $RCSfile: CompositionBase.java,v $
010:         * Revision           $Revision: 1.15 $
011:         * Release status     $State: Exp $
012:         *
013:         * Last modified on   $Date: 2008/01/02 12:10:19 $
014:         *               by   $Author: andy_seaborne $
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.graph.compose;
019:
020:        // Imports
021:        ///////////////
022:        import com.hp.hpl.jena.graph.*;
023:        import com.hp.hpl.jena.graph.impl.*;
024:        import com.hp.hpl.jena.util.IteratorCollection;
025:        import com.hp.hpl.jena.util.iterator.*;
026:
027:        import java.util.*;
028:
029:        /**
030:         * <p>
031:         * Base class for graphs that are composed of multiple sub-graphs.  This is to provide
032:         * a home for shared functionality that was previously in {@link Dyadic} before
033:         * refactoring.
034:         * </p>
035:         *
036:         * @author Ian Dickinson, moved kers' code from Dyadic to this class, added commentage
037:         * @author Chris Dollin (kers)
038:         * @version CVS $Id: CompositionBase.java,v 1.15 2008/01/02 12:10:19 andy_seaborne Exp $
039:         */
040:        public abstract class CompositionBase extends GraphBase {
041:            /**
042:             * <p>
043:             * Answer a {@link Filter} that will reject any element that is a member of iterator i.
044:             * As a side-effect, i will be closed. 
045:             * </p>
046:             * 
047:             * @param i A closable iterator
048:             * @return A Filter that will accept any object not a member of i.
049:             */
050:            public static Filter reject(final ClosableIterator i) {
051:                final Set suppress = IteratorCollection.iteratorToSet(i);
052:                return new Filter() {
053:                    public boolean accept(Object o) {
054:                        return !suppress.contains(o);
055:                    }
056:                };
057:            }
058:
059:            /**
060:             * <p>
061:             * Answer an iterator over the elements of iterator a that are not members of iterator b.
062:             * As a side-effect, iterator b will be closed.
063:             * </p>
064:             * 
065:             * @param a An iterator that will be filtered by rejecting the elements of b
066:             * @param b A closable iterator 
067:             * @return The iteration of elements in a but not in b.
068:             */
069:            public static ClosableIterator butNot(final ClosableIterator a,
070:                    final ClosableIterator b) {
071:                return new FilterIterator(reject(b), a);
072:            }
073:
074:            /**
075:             * <p>
076:             * Answer an iterator that will record every element delived by <code>next()</code> in
077:             * the set <code>seen</code>. 
078:             * </p>
079:             * 
080:             * @param i A closable iterator
081:             * @param seen A set that will record each element of i in turn
082:             * @return An iterator that records the elements of i.
083:             */
084:            public static ExtendedIterator recording(final ClosableIterator i,
085:                    final Set seen) {
086:                return new NiceIterator() {
087:                    public void remove() {
088:                        i.remove();
089:                    }
090:
091:                    public boolean hasNext() {
092:                        return i.hasNext();
093:                    }
094:
095:                    public Object next() {
096:                        Object x = i.next();
097:                        try {
098:                            seen.add(x);
099:                        } catch (OutOfMemoryError e) {
100:                            throw e;
101:                        }
102:                        return x;
103:                    }
104:
105:                    public void close() {
106:                        i.close();
107:                    }
108:                };
109:            }
110:
111:            //static final Object absent = new Object();
112:
113:            /**
114:             * <p>
115:             * Answer an iterator over the elements of iterator i that are not in the set <code>seen</code>. 
116:             * </p>
117:             * 
118:             * @param i An extended iterator
119:             * @param seen A set of objects
120:             * @return An iterator over the elements of i that are not in the set <code>seen</code>.
121:             */
122:            public static ExtendedIterator rejecting(final ExtendedIterator i,
123:                    final Set seen) {
124:                Filter seenFilter = new Filter() {
125:                    public boolean accept(Object x) {
126:                        return seen.contains(x);
127:                    }
128:                };
129:                return i.filterDrop(seenFilter);
130:            }
131:
132:            /**
133:                 Answer an iterator over the elements of <code>i</code> that are not in
134:                 the graph <code>seen</code>.
135:             */
136:            public static ExtendedIterator rejecting(final ExtendedIterator i,
137:                    final Graph seen) {
138:                Filter seenFilter = new Filter() {
139:                    public boolean accept(Object x) {
140:                        return seen.contains((Triple) x);
141:                    }
142:                };
143:                return i.filterDrop(seenFilter);
144:            }
145:
146:            /**
147:             * <p>
148:             * Answer a {@link Filter} that will accept any object that is an element of 
149:             * iterator i.  As a side-effect, i will be evaluated and closed. 
150:             * </p>
151:             * 
152:             * @param i A closable iterator 
153:             * @return A Filter that will accept any object in iterator i.
154:             */
155:            public static Filter ifIn(final ClosableIterator i) {
156:                final Set allow = IteratorCollection.iteratorToSet(i);
157:                return new Filter() {
158:                    public boolean accept(Object x) {
159:                        return allow.contains(x);
160:                    }
161:                };
162:            }
163:
164:            /**
165:             * <p>
166:             * Answer a {@link Filter} that will accept any triple that is an edge of 
167:             * graph g. 
168:             * </p>
169:             * 
170:             * @param g A graph 
171:             * @return A Filter that will accept any triple that is an edge in g.
172:             */
173:            public static Filter ifIn(final Graph g) {
174:                return new Filter() {
175:                    public boolean accept(Object x) {
176:                        return g.contains((Triple) x);
177:                    }
178:                };
179:            }
180:
181:            // Internal implementation methods
182:            //////////////////////////////////
183:
184:            //==============================================================================
185:            // Inner class definitions
186:            //==============================================================================
187:
188:        }
189:
190:        /*
191:         (c) Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
192:         All rights reserved.
193:
194:         Redistribution and use in source and binary forms, with or without
195:         modification, are permitted provided that the following conditions
196:         are met:
197:
198:         1. Redistributions of source code must retain the above copyright
199:         notice, this list of conditions and the following disclaimer.
200:
201:         2. Redistributions in binary form must reproduce the above copyright
202:         notice, this list of conditions and the following disclaimer in the
203:         documentation and/or other materials provided with the distribution.
204:
205:         3. The name of the author may not be used to endorse or promote products
206:         derived from this software without specific prior written permission.
207:
208:         THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
209:         IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
210:         OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
211:         IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
212:         INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
213:         NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
214:         DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
215:         THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
216:         (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
217:         THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
218:         */
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.