Source Code Cross Referenced for StoredValueSet.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: StoredValueSet.java,v 1.40.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.EntityBinding;
014:        import com.sleepycat.bind.EntryBinding;
015:        import com.sleepycat.je.Database;
016:        import com.sleepycat.je.DatabaseEntry;
017:        import com.sleepycat.je.DatabaseException;
018:        import com.sleepycat.je.OperationStatus;
019:
020:        /**
021:         * The Set returned by Map.values() and Map.duplicates(), and which can also be
022:         * constructed directly if a Map is not needed.
023:         * Although this collection is a set it may contain duplicate values.  Only if
024:         * an entity value binding is used are all elements guaranteed to be unique.
025:         *
026:         * @author Mark Hayes
027:         */
028:        public class StoredValueSet extends StoredCollection implements  Set {
029:
030:            /*
031:             * This class is also used internally for the set returned by duplicates().
032:             */
033:
034:            /**
035:             * Creates a value set view of a {@link Database}.
036:             *
037:             * @param database is the Database underlying the new collection.
038:             *
039:             * @param valueBinding is the binding used to translate between value
040:             * buffers and value objects.
041:             *
042:             * @param writeAllowed is true to create a read-write collection or false
043:             * to create a read-only collection.
044:             *
045:             * @throws IllegalArgumentException if formats are not consistently
046:             * defined or a parameter is invalid.
047:             *
048:             * @throws RuntimeExceptionWrapper if a {@link DatabaseException} is
049:             * thrown.
050:             */
051:            public StoredValueSet(Database database, EntryBinding valueBinding,
052:                    boolean writeAllowed) {
053:
054:                super (new DataView(database, null, valueBinding, null,
055:                        writeAllowed, null));
056:            }
057:
058:            /**
059:             * Creates a value set entity view of a {@link Database}.
060:             *
061:             * @param database is the Database underlying the new collection.
062:             *
063:             * @param valueEntityBinding is the binding used to translate between
064:             * key/value buffers and entity value objects.
065:             *
066:             * @param writeAllowed is true to create a read-write collection or false
067:             * to create a read-only collection.
068:             *
069:             * @throws IllegalArgumentException if formats are not consistently
070:             * defined or a parameter is invalid.
071:             *
072:             * @throws RuntimeExceptionWrapper if a {@link DatabaseException} is
073:             * thrown.
074:             */
075:            public StoredValueSet(Database database,
076:                    EntityBinding valueEntityBinding, boolean writeAllowed) {
077:
078:                super (new DataView(database, null, null, valueEntityBinding,
079:                        writeAllowed, null));
080:            }
081:
082:            StoredValueSet(DataView valueSetView) {
083:
084:                super (valueSetView);
085:            }
086:
087:            /**
088:             * Adds the specified entity to this set if it is not already present
089:             * (optional operation).
090:             * This method conforms to the {@link Set#add} interface.
091:             *
092:             * @param entity is the entity to be added.
093:             *
094:             * @return true if the entity was added, that is the key-value pair
095:             * represented by the entity was not previously present in the collection.
096:             *
097:             * @throws UnsupportedOperationException if the collection is read-only,
098:             * if the collection is indexed, or if an entity binding is not used.
099:             *
100:             * @throws RuntimeExceptionWrapper if a {@link DatabaseException} is
101:             * thrown.
102:             */
103:            public boolean add(Object entity) {
104:
105:                if (view.isSecondary()) {
106:                    throw new UnsupportedOperationException(
107:                            "add() not allowed with index");
108:                } else if (view.range.isSingleKey()) {
109:                    /* entity is actually just a value in this case */
110:                    if (!view.dupsAllowed) {
111:                        throw new UnsupportedOperationException(
112:                                "duplicates required");
113:                    }
114:                    DataCursor cursor = null;
115:                    boolean doAutoCommit = beginAutoCommit();
116:                    try {
117:                        cursor = new DataCursor(view, true);
118:                        cursor.useRangeKey();
119:                        OperationStatus status = cursor.putNoDupData(null,
120:                                entity, null, true);
121:                        closeCursor(cursor);
122:                        commitAutoCommit(doAutoCommit);
123:                        return (status == OperationStatus.SUCCESS);
124:                    } catch (Exception e) {
125:                        closeCursor(cursor);
126:                        throw handleException(e, doAutoCommit);
127:                    }
128:                } else if (view.entityBinding == null) {
129:                    throw new UnsupportedOperationException(
130:                            "add() requires entity binding");
131:                } else {
132:                    return add(null, entity);
133:                }
134:            }
135:
136:            /**
137:             * Returns true if this set contains the specified element.
138:             * This method conforms to the {@link java.util.Set#contains}
139:             * interface.
140:             *
141:             * @param value the value to check.
142:             *
143:             * @return whether the set contains the given value.
144:             */
145:            public boolean contains(Object value) {
146:
147:                return containsValue(value);
148:            }
149:
150:            /**
151:             * Removes the specified value from this set if it is present (optional
152:             * operation).
153:             * If an entity binding is used, the key-value pair represented by the
154:             * given entity is removed.  If an entity binding is used, the first
155:             * occurrence of a key-value pair with the given value is removed.
156:             * This method conforms to the {@link Set#remove} interface.
157:             *
158:             * @throws UnsupportedOperationException if the collection is read-only.
159:             *
160:             * @throws RuntimeExceptionWrapper if a {@link DatabaseException} is
161:             * thrown.
162:             */
163:            public boolean remove(Object value) {
164:
165:                return removeValue(value);
166:            }
167:
168:            Object makeIteratorData(BaseIterator iterator,
169:                    DatabaseEntry keyEntry, DatabaseEntry priKeyEntry,
170:                    DatabaseEntry valueEntry) {
171:
172:                return view.makeValue(priKeyEntry, valueEntry);
173:            }
174:
175:            boolean hasValues() {
176:
177:                return true;
178:            }
179:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.