Source Code Cross Referenced for StoredSortedKeySet.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: StoredSortedKeySet.java,v 1.27.2.2 2008/01/07 15:14:06 cwl Exp $
007:         */
008:
009:        package com.sleepycat.collections;
010:
011:        import java.util.Comparator;
012:        import java.util.SortedSet;
013:
014:        import com.sleepycat.bind.EntryBinding;
015:        import com.sleepycat.je.Database;
016:
017:        /**
018:         * The SortedSet returned by Map.keySet() and which can also be constructed
019:         * directly if a Map is not needed.
020:         * Since this collection is a set it only contains one element for each key,
021:         * even when duplicates are allowed.  Key set iterators are therefore
022:         * particularly useful for enumerating the unique keys of a store or index that
023:         * allows duplicates.
024:         *
025:         * <p>In addition to the standard SortedSet methods, this class provides the
026:         * following methods for stored sorted sets only.  Note that the use of these
027:         * methods is not compatible with the standard Java collections interface.</p>
028:         * <ul>
029:         * <li>{@link #headSet(Object, boolean)}</li>
030:         * <li>{@link #tailSet(Object, boolean)}</li>
031:         * <li>{@link #subSet(Object, boolean, Object, boolean)}</li>
032:         * </ul>
033:         *
034:         * @author Mark Hayes
035:         */
036:        public class StoredSortedKeySet extends StoredKeySet implements 
037:                SortedSet {
038:
039:            /**
040:             * Creates a sorted key set view of a {@link Database}.
041:             *
042:             * @param database is the Database underlying the new collection.
043:             *
044:             * @param keyBinding is the binding used to translate between key buffers
045:             * and key objects.
046:             *
047:             * @param writeAllowed is true to create a read-write collection or false
048:             * to create a read-only collection.
049:             *
050:             * @throws IllegalArgumentException if formats are not consistently
051:             * defined or a parameter is invalid.
052:             *
053:             * @throws RuntimeExceptionWrapper if a {@link
054:             * com.sleepycat.je.DatabaseException} is thrown.
055:             */
056:            public StoredSortedKeySet(Database database,
057:                    EntryBinding keyBinding, boolean writeAllowed) {
058:
059:                super (new DataView(database, keyBinding, null, null,
060:                        writeAllowed, null));
061:            }
062:
063:            StoredSortedKeySet(DataView keySetView) {
064:
065:                super (keySetView);
066:            }
067:
068:            /**
069:             * Returns null since comparators are not supported.  The natural ordering
070:             * of a stored collection is data byte order, whether the data classes
071:             * implement the {@link java.lang.Comparable} interface or not.
072:             * This method does not conform to the {@link SortedSet#comparator}
073:             * interface.
074:             *
075:             * @return null.
076:             */
077:            public Comparator comparator() {
078:
079:                return null;
080:            }
081:
082:            /**
083:             * Returns the first (lowest) element currently in this sorted set.
084:             * This method conforms to the {@link SortedSet#first} interface.
085:             *
086:             * @return the first element.
087:             *
088:             * @throws RuntimeExceptionWrapper if a {@link
089:             * com.sleepycat.je.DatabaseException} is thrown.
090:             */
091:            public Object first() {
092:
093:                return getFirstOrLast(true);
094:            }
095:
096:            /**
097:             * Returns the last (highest) element currently in this sorted set.
098:             * This method conforms to the {@link SortedSet#last} interface.
099:             *
100:             * @return the last element.
101:             *
102:             * @throws RuntimeExceptionWrapper if a {@link
103:             * com.sleepycat.je.DatabaseException} is thrown.
104:             */
105:            public Object last() {
106:
107:                return getFirstOrLast(false);
108:            }
109:
110:            /**
111:             * Returns a view of the portion of this sorted set whose elements are
112:             * strictly less than toKey.
113:             * This method conforms to the {@link SortedSet#headSet} interface.
114:             *
115:             * <p>Note that the return value is a StoredCollection and must be treated
116:             * as such; for example, its iterators must be explicitly closed.</p>
117:             *
118:             * @param toKey is the upper bound.
119:             *
120:             * @return the subset.
121:             *
122:             * @throws RuntimeExceptionWrapper if a {@link
123:             * com.sleepycat.je.DatabaseException} is thrown.
124:             */
125:            public SortedSet headSet(Object toKey) {
126:
127:                return subSet(null, false, toKey, false);
128:            }
129:
130:            /**
131:             * Returns a view of the portion of this sorted set whose elements are
132:             * strictly less than toKey, optionally including toKey.
133:             * This method does not exist in the standard {@link SortedSet} interface.
134:             *
135:             * <p>Note that the return value is a StoredCollection and must be treated
136:             * as such; for example, its iterators must be explicitly closed.</p>
137:             *
138:             * @param toKey is the upper bound.
139:             *
140:             * @param toInclusive is true to include toKey.
141:             *
142:             * @return the subset.
143:             *
144:             * @throws RuntimeExceptionWrapper if a {@link
145:             * com.sleepycat.je.DatabaseException} is thrown.
146:             */
147:            public SortedSet headSet(Object toKey, boolean toInclusive) {
148:
149:                return subSet(null, false, toKey, toInclusive);
150:            }
151:
152:            /**
153:             * Returns a view of the portion of this sorted set whose elements are
154:             * greater than or equal to fromKey.
155:             * This method conforms to the {@link SortedSet#tailSet} interface.
156:             *
157:             * <p>Note that the return value is a StoredCollection and must be treated
158:             * as such; for example, its iterators must be explicitly closed.</p>
159:             *
160:             * @param fromKey is the lower bound.
161:             *
162:             * @return the subset.
163:             *
164:             * @throws RuntimeExceptionWrapper if a {@link
165:             * com.sleepycat.je.DatabaseException} is thrown.
166:             */
167:            public SortedSet tailSet(Object fromKey) {
168:
169:                return subSet(fromKey, true, null, false);
170:            }
171:
172:            /**
173:             * Returns a view of the portion of this sorted set whose elements are
174:             * strictly greater than fromKey, optionally including fromKey.
175:             * This method does not exist in the standard {@link SortedSet} interface.
176:             *
177:             * <p>Note that the return value is a StoredCollection and must be treated
178:             * as such; for example, its iterators must be explicitly closed.</p>
179:             *
180:             * @param fromKey is the lower bound.
181:             *
182:             * @param fromInclusive is true to include fromKey.
183:             *
184:             * @return the subset.
185:             *
186:             * @throws RuntimeExceptionWrapper if a {@link
187:             * com.sleepycat.je.DatabaseException} is thrown.
188:             */
189:            public SortedSet tailSet(Object fromKey, boolean fromInclusive) {
190:
191:                return subSet(fromKey, fromInclusive, null, false);
192:            }
193:
194:            /**
195:             * Returns a view of the portion of this sorted set whose elements range
196:             * from fromKey, inclusive, to toKey, exclusive.
197:             * This method conforms to the {@link SortedSet#subSet} interface.
198:             *
199:             * <p>Note that the return value is a StoredCollection and must be treated
200:             * as such; for example, its iterators must be explicitly closed.</p>
201:             *
202:             * @param fromKey is the lower bound.
203:             *
204:             * @param toKey is the upper bound.
205:             *
206:             * @return the subset.
207:             *
208:             * @throws RuntimeExceptionWrapper if a {@link
209:             * com.sleepycat.je.DatabaseException} is thrown.
210:             */
211:            public SortedSet subSet(Object fromKey, Object toKey) {
212:
213:                return subSet(fromKey, true, toKey, false);
214:            }
215:
216:            /**
217:             * Returns a view of the portion of this sorted set whose elements are
218:             * strictly greater than fromKey and strictly less than toKey,
219:             * optionally including fromKey and toKey.
220:             * This method does not exist in the standard {@link SortedSet} interface.
221:             *
222:             * <p>Note that the return value is a StoredCollection and must be treated
223:             * as such; for example, its iterators must be explicitly closed.</p>
224:             *
225:             * @param fromKey is the lower bound.
226:             *
227:             * @param fromInclusive is true to include fromKey.
228:             *
229:             * @param toKey is the upper bound.
230:             *
231:             * @param toInclusive is true to include toKey.
232:             *
233:             * @return the subset.
234:             *
235:             * @throws RuntimeExceptionWrapper if a {@link
236:             * com.sleepycat.je.DatabaseException} is thrown.
237:             */
238:            public SortedSet subSet(Object fromKey, boolean fromInclusive,
239:                    Object toKey, boolean toInclusive) {
240:
241:                try {
242:                    return new StoredSortedKeySet(view.subView(fromKey,
243:                            fromInclusive, toKey, toInclusive, null));
244:                } catch (Exception e) {
245:                    throw StoredContainer.convertException(e);
246:                }
247:            }
248:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.