Source Code Cross Referenced for RepositoryResult.java in  » RSS-RDF » sesame » org » openrdf » repository » 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 » sesame » org.openrdf.repository 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright Aduna (http://www.aduna-software.com/) (c) 2007.
003:         *
004:         * Licensed under the Aduna BSD-style license.
005:         */
006:        package org.openrdf.repository;
007:
008:        import java.util.ArrayList;
009:        import java.util.Collection;
010:        import java.util.List;
011:
012:        import info.aduna.iteration.CloseableIteration;
013:        import info.aduna.iteration.DistinctIteration;
014:        import info.aduna.iteration.IterationWrapper;
015:
016:        /**
017:         * A RepositoryResult is a result collection of objects (for example
018:         * {@link org.openrdf.model.Statement}, {@link org.openrdf.model.Namespace},
019:         * or {@link org.openrdf.model.Resource} objects) that can be iterated over. It
020:         * keeps an open connection to the backend for lazy retrieval of individual
021:         * results. Additionally it has some utility methods to fetch all results and
022:         * add them to a collection.
023:         * <p>
024:         * By default, a RepositoryResult is not necessarily a (mathematical) set: it
025:         * may contain duplicate objects. Duplicate filtering can be {{@link #enableDuplicateFilter() switched on},
026:         * but this should not be used lightly as the filtering mechanism is potentially
027:         * memory-intensive.
028:         * <p>
029:         * A RepositoryResult needs to be {@link #close() closed} after use to free up
030:         * any resources (open connections, read locks, etc.) it has on the underlying
031:         * repository.
032:         * 
033:         * @see RepositoryConnection#getStatements(org.openrdf.model.Resource,
034:         *      org.openrdf.model.URI, org.openrdf.model.Value, boolean,
035:         *      org.openrdf.model.Resource[])
036:         * @see RepositoryConnection#getNamespaces()
037:         * @see RepositoryConnection#getContextIDs()
038:         * @author jeen
039:         * @author Arjohn Kampman
040:         */
041:        public class RepositoryResult<T> extends
042:                IterationWrapper<T, RepositoryException> {
043:
044:            public RepositoryResult(
045:                    CloseableIteration<? extends T, RepositoryException> iter) {
046:                super (iter);
047:            }
048:
049:            /**
050:             * Switches on duplicate filtering while iterating over objects. The
051:             * RepositoryResult will keep track of the previously returned objects in a
052:             * {@link java.util.Set} and on calling next() or hasNext() will ignore any
053:             * objects that already occur in this Set.
054:             * <P>
055:             * Caution: use of this filtering mechanism is potentially memory-intensive.
056:             * 
057:             * @throws RepositoryException
058:             *         if a problem occurred during initialization of the filter.
059:             */
060:            public void enableDuplicateFilter() throws RepositoryException {
061:                wrappedIter = new DistinctIteration<T, RepositoryException>(
062:                        wrappedIter);
063:            }
064:
065:            /**
066:             * Returns a {@link List} containing all objects of this RepositoryResult in
067:             * order of iteration. The RepositoryResult is fully consumed and
068:             * automatically closed by this operation.
069:             * <P>
070:             * Note: use this method with caution! It pulls the entire RepositoryResult
071:             * in memory and as such is potentially very memory-intensive.
072:             * 
073:             * @return a List containing all objects of this RepositoryResult.
074:             * @throws RepositoryException
075:             *         if a problem occurred during retrieval of the results.
076:             * @see #addTo(Collection)
077:             */
078:            public List<T> asList() throws RepositoryException {
079:                return addTo(new ArrayList<T>());
080:            }
081:
082:            /**
083:             * Adds all objects of this RepositoryResult to the supplied collection. The
084:             * RepositoryResult is fully consumed and automatically closed by this
085:             * operation.
086:             * 
087:             * @return A reference to the collection that was supplied.
088:             * @throws RepositoryException
089:             *         if a problem occurred during retrieval of the results.
090:             */
091:            public <C extends Collection<T>> C addTo(C collection)
092:                    throws RepositoryException {
093:                try {
094:                    while (hasNext()) {
095:                        collection.add(next());
096:                    }
097:
098:                    return collection;
099:                } finally {
100:                    close();
101:                }
102:            }
103:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.