Source Code Cross Referenced for StoredEntrySet.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: StoredEntrySet.java,v 1.30.2.2 2008/01/07 15:14:06 cwl Exp $
007:         */
008:
009:        package com.sleepycat.collections;
010:
011:        import java.util.Map;
012:        import java.util.Set;
013:
014:        import com.sleepycat.je.DatabaseEntry;
015:        import com.sleepycat.je.DatabaseException;
016:        import com.sleepycat.je.OperationStatus;
017:        import com.sleepycat.util.RuntimeExceptionWrapper;
018:
019:        /**
020:         * The Set returned by Map.entrySet().  This class may not be instantiated
021:         * directly.  Contrary to what is stated by {@link Map#entrySet} this class
022:         * does support the {@link #add} and {@link #addAll} methods.
023:         *
024:         * <p>The {@link java.util.Map.Entry#setValue} method of the Map.Entry objects
025:         * that are returned by this class and its iterators behaves just as the {@link
026:         * StoredIterator#set} method does.</p>
027:         *
028:         * @author Mark Hayes
029:         */
030:        public class StoredEntrySet extends StoredCollection implements  Set {
031:
032:            StoredEntrySet(DataView mapView) {
033:
034:                super (mapView);
035:            }
036:
037:            /**
038:             * Adds the specified element to this set if it is not already present
039:             * (optional operation).
040:             * This method conforms to the {@link Set#add} interface.
041:             *
042:             * @param mapEntry must be a {@link java.util.Map.Entry} instance.
043:             *
044:             * @return true if the key-value pair was added to the set (and was not
045:             * previously present).
046:             *
047:             * @throws UnsupportedOperationException if the collection is read-only.
048:             *
049:             * @throws ClassCastException if the mapEntry is not a {@link
050:             * java.util.Map.Entry} instance.
051:             *
052:             * @throws RuntimeExceptionWrapper if a {@link DatabaseException} is thrown.
053:             */
054:            public boolean add(Object mapEntry) {
055:
056:                Map.Entry entry = (Map.Entry) mapEntry; // allow ClassCastException
057:                return add(entry.getKey(), entry.getValue());
058:            }
059:
060:            /**
061:             * Removes the specified element from this set if it is present (optional
062:             * operation).
063:             * This method conforms to the {@link Set#remove} interface.
064:             *
065:             * @param mapEntry is a {@link java.util.Map.Entry} instance to be removed.
066:             *
067:             * @return true if the key-value pair was removed from the set, or false if
068:             * the mapEntry is not a {@link java.util.Map.Entry} instance or is not
069:             * present in the set.
070:             *
071:             * @throws UnsupportedOperationException if the collection is read-only.
072:             *
073:             * @throws RuntimeExceptionWrapper if a {@link DatabaseException} is thrown.
074:             */
075:            public boolean remove(Object mapEntry) {
076:
077:                if (!(mapEntry instanceof  Map.Entry)) {
078:                    return false;
079:                }
080:                Map.Entry entry = (Map.Entry) mapEntry;
081:                DataCursor cursor = null;
082:                boolean doAutoCommit = beginAutoCommit();
083:                try {
084:                    cursor = new DataCursor(view, true);
085:                    OperationStatus status = cursor.findBoth(entry.getKey(),
086:                            entry.getValue(), true);
087:                    if (status == OperationStatus.SUCCESS) {
088:                        cursor.delete();
089:                    }
090:                    closeCursor(cursor);
091:                    commitAutoCommit(doAutoCommit);
092:                    return (status == OperationStatus.SUCCESS);
093:                } catch (Exception e) {
094:                    closeCursor(cursor);
095:                    throw handleException(e, doAutoCommit);
096:                }
097:            }
098:
099:            /**
100:             * Returns true if this set contains the specified element.
101:             * This method conforms to the {@link Set#contains} interface.
102:             *
103:             * @param mapEntry is a {@link java.util.Map.Entry} instance to be checked.
104:             *
105:             * @return true if the key-value pair is present in the set, or false if
106:             * the mapEntry is not a {@link java.util.Map.Entry} instance or is not
107:             * present in the set.
108:             *
109:             * @throws RuntimeExceptionWrapper if a {@link DatabaseException} is thrown.
110:             */
111:            public boolean contains(Object mapEntry) {
112:
113:                if (!(mapEntry instanceof  Map.Entry)) {
114:                    return false;
115:                }
116:                Map.Entry entry = (Map.Entry) mapEntry;
117:                DataCursor cursor = null;
118:                try {
119:                    cursor = new DataCursor(view, false);
120:                    OperationStatus status = cursor.findBoth(entry.getKey(),
121:                            entry.getValue(), false);
122:                    return (status == OperationStatus.SUCCESS);
123:                } catch (Exception e) {
124:                    throw StoredContainer.convertException(e);
125:                } finally {
126:                    closeCursor(cursor);
127:                }
128:            }
129:
130:            // javadoc is inherited
131:            public String toString() {
132:                StringBuffer buf = new StringBuffer();
133:                buf.append("[");
134:                StoredIterator i = storedIterator();
135:                try {
136:                    while (i.hasNext()) {
137:                        Map.Entry entry = (Map.Entry) i.next();
138:                        if (buf.length() > 1)
139:                            buf.append(',');
140:                        Object key = entry.getKey();
141:                        Object val = entry.getValue();
142:                        if (key != null)
143:                            buf.append(key.toString());
144:                        buf.append('=');
145:                        if (val != null)
146:                            buf.append(val.toString());
147:                    }
148:                    buf.append(']');
149:                    return buf.toString();
150:                } finally {
151:                    i.close();
152:                }
153:            }
154:
155:            Object makeIteratorData(BaseIterator iterator,
156:                    DatabaseEntry keyEntry, DatabaseEntry priKeyEntry,
157:                    DatabaseEntry valueEntry) {
158:
159:                return new StoredMapEntry(view.makeKey(keyEntry, priKeyEntry),
160:                        view.makeValue(priKeyEntry, valueEntry), this , iterator);
161:            }
162:
163:            boolean hasValues() {
164:
165:                return true;
166:            }
167:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.