Source Code Cross Referenced for StoredKeySet.java in  » JMX » je » com » sleepycat » collections » 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 » JMX » je » com.sleepycat.collections 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*-
002:         * See the file LICENSE for redistribution information.
003:         *
004:         * Copyright (c) 2000,2008 Oracle.  All rights reserved.
005:         *
006:         * $Id: StoredKeySet.java,v 1.31.2.2 2008/01/07 15:14:06 cwl Exp $
007:         */
008:
009:        package com.sleepycat.collections;
010:
011:        import java.util.Set;
012:
013:        import com.sleepycat.bind.EntryBinding;
014:        import com.sleepycat.je.Database;
015:        import com.sleepycat.je.DatabaseEntry;
016:        import com.sleepycat.je.DatabaseException;
017:        import com.sleepycat.je.OperationStatus;
018:
019:        /**
020:         * The Set returned by Map.keySet() and which can also be constructed directly
021:         * if a Map is not needed.
022:         * Since this collection is a set it only contains one element for each key,
023:         * even when duplicates are allowed.  Key set iterators are therefore
024:         * particularly useful for enumerating the unique keys of a store or index that
025:         * allows duplicates.
026:         *
027:         * @author Mark Hayes
028:         */
029:        public class StoredKeySet extends StoredCollection implements  Set {
030:
031:            /**
032:             * Creates a key set view of a {@link Database}.
033:             *
034:             * @param database is the Database underlying the new collection.
035:             *
036:             * @param keyBinding is the binding used to translate between key buffers
037:             * and key objects.
038:             *
039:             * @param writeAllowed is true to create a read-write collection or false
040:             * to create a read-only collection.
041:             *
042:             * @throws IllegalArgumentException if formats are not consistently
043:             * defined or a parameter is invalid.
044:             *
045:             * @throws RuntimeExceptionWrapper if a {@link DatabaseException} is
046:             * thrown.
047:             */
048:            public StoredKeySet(Database database, EntryBinding keyBinding,
049:                    boolean writeAllowed) {
050:
051:                super (new DataView(database, keyBinding, null, null,
052:                        writeAllowed, null));
053:            }
054:
055:            StoredKeySet(DataView keySetView) {
056:
057:                super (keySetView);
058:            }
059:
060:            /**
061:             * Adds the specified key to this set if it is not already present
062:             * (optional operation).
063:             * When a key is added the value in the underlying data store will be
064:             * empty.
065:             * This method conforms to the {@link Set#add} interface.
066:             *
067:             * @throws UnsupportedOperationException if the collection is indexed, or
068:             * if the collection is read-only.
069:             *
070:             * @throws RuntimeExceptionWrapper if a {@link DatabaseException} is
071:             * thrown.
072:             */
073:            public boolean add(Object key) {
074:
075:                DataCursor cursor = null;
076:                boolean doAutoCommit = beginAutoCommit();
077:                try {
078:                    cursor = new DataCursor(view, true);
079:                    OperationStatus status = cursor.putNoOverwrite(key, null,
080:                            false);
081:                    closeCursor(cursor);
082:                    commitAutoCommit(doAutoCommit);
083:                    return (status == OperationStatus.SUCCESS);
084:                } catch (Exception e) {
085:                    closeCursor(cursor);
086:                    throw handleException(e, doAutoCommit);
087:                }
088:            }
089:
090:            /**
091:             * Removes the specified key from this set if it is present (optional
092:             * operation).
093:             * If duplicates are allowed, this method removes all duplicates for the
094:             * given key.
095:             * This method conforms to the {@link Set#remove} interface.
096:             *
097:             * @throws UnsupportedOperationException if the collection is read-only.
098:             *
099:             * @throws RuntimeExceptionWrapper if a {@link DatabaseException} is
100:             * thrown.
101:             */
102:            public boolean remove(Object key) {
103:
104:                return removeKey(key, null);
105:            }
106:
107:            /**
108:             * Returns true if this set contains the specified key.
109:             * This method conforms to the {@link Set#contains} interface.
110:             *
111:             * @throws RuntimeExceptionWrapper if a {@link DatabaseException} is
112:             * thrown.
113:             */
114:            public boolean contains(Object key) {
115:
116:                return containsKey(key);
117:            }
118:
119:            boolean hasValues() {
120:
121:                return false;
122:            }
123:
124:            Object makeIteratorData(BaseIterator iterator,
125:                    DatabaseEntry keyEntry, DatabaseEntry priKeyEntry,
126:                    DatabaseEntry valueEntry) {
127:
128:                return view.makeKey(keyEntry, priKeyEntry);
129:            }
130:
131:            boolean iterateDuplicates() {
132:
133:                return false;
134:            }
135:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.