Source Code Cross Referenced for PersistentSortedSet.java in  » Database-ORM » hibernate » org » hibernate » collection » 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 » Database ORM » hibernate » org.hibernate.collection 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        //$Id: PersistentSortedSet.java 7714 2005-08-01 16:29:33Z oneovthafew $
002:        package org.hibernate.collection;
003:
004:        import java.io.Serializable;
005:        import java.util.Comparator;
006:        import java.util.Iterator;
007:        import java.util.SortedSet;
008:        import java.util.TreeMap;
009:
010:        import org.hibernate.EntityMode;
011:        import org.hibernate.HibernateException;
012:        import org.hibernate.engine.SessionImplementor;
013:        import org.hibernate.persister.collection.BasicCollectionPersister;
014:
015:        /**
016:         * A persistent wrapper for a <tt>java.util.SortedSet</tt>. Underlying
017:         * collection is a <tt>TreeSet</tt>.
018:         *
019:         * @see java.util.TreeSet
020:         * @author <a href="mailto:doug.currie@alum.mit.edu">e</a>
021:         */
022:        public class PersistentSortedSet extends PersistentSet implements 
023:                SortedSet {
024:
025:            protected Comparator comparator;
026:
027:            protected Serializable snapshot(BasicCollectionPersister persister,
028:                    EntityMode entityMode) throws HibernateException {
029:                //if (set==null) return new Set(session);
030:                TreeMap clonedSet = new TreeMap(comparator);
031:                Iterator iter = set.iterator();
032:                while (iter.hasNext()) {
033:                    Object copy = persister.getElementType().deepCopy(
034:                            iter.next(), entityMode, persister.getFactory());
035:                    clonedSet.put(copy, copy);
036:                }
037:                return clonedSet;
038:            }
039:
040:            public void setComparator(Comparator comparator) {
041:                this .comparator = comparator;
042:            }
043:
044:            public PersistentSortedSet(SessionImplementor session) {
045:                super (session);
046:            }
047:
048:            public PersistentSortedSet(SessionImplementor session, SortedSet set) {
049:                super (session, set);
050:                comparator = set.comparator();
051:            }
052:
053:            public PersistentSortedSet() {
054:            } //needed for SOAP libraries, etc
055:
056:            /**
057:             * @see PersistentSortedSet#comparator()
058:             */
059:            public Comparator comparator() {
060:                return comparator;
061:            }
062:
063:            /**
064:             * @see PersistentSortedSet#subSet(Object,Object)
065:             */
066:            public SortedSet subSet(Object fromElement, Object toElement) {
067:                read();
068:                SortedSet s;
069:                s = ((SortedSet) set).subSet(fromElement, toElement);
070:                return new SubSetProxy(s);
071:            }
072:
073:            /**
074:             * @see PersistentSortedSet#headSet(Object)
075:             */
076:            public SortedSet headSet(Object toElement) {
077:                read();
078:                SortedSet s = ((SortedSet) set).headSet(toElement);
079:                return new SubSetProxy(s);
080:            }
081:
082:            /**
083:             * @see PersistentSortedSet#tailSet(Object)
084:             */
085:            public SortedSet tailSet(Object fromElement) {
086:                read();
087:                SortedSet s = ((SortedSet) set).tailSet(fromElement);
088:                return new SubSetProxy(s);
089:            }
090:
091:            /**
092:             * @see PersistentSortedSet#first()
093:             */
094:            public Object first() {
095:                read();
096:                return ((SortedSet) set).first();
097:            }
098:
099:            /**
100:             * @see PersistentSortedSet#last()
101:             */
102:            public Object last() {
103:                read();
104:                return ((SortedSet) set).last();
105:            }
106:
107:            /** wrapper for subSets to propagate write to its backing set */
108:            class SubSetProxy extends SetProxy implements  SortedSet {
109:
110:                SubSetProxy(SortedSet s) {
111:                    super (s);
112:                }
113:
114:                public Comparator comparator() {
115:                    return ((SortedSet) this .set).comparator();
116:                }
117:
118:                public Object first() {
119:                    return ((SortedSet) this .set).first();
120:                }
121:
122:                public SortedSet headSet(Object toValue) {
123:                    return new SubSetProxy(((SortedSet) this .set)
124:                            .headSet(toValue));
125:                }
126:
127:                public Object last() {
128:                    return ((SortedSet) this .set).last();
129:                }
130:
131:                public SortedSet subSet(Object fromValue, Object toValue) {
132:                    return new SubSetProxy(((SortedSet) this .set).subSet(
133:                            fromValue, toValue));
134:                }
135:
136:                public SortedSet tailSet(Object fromValue) {
137:                    return new SubSetProxy(((SortedSet) this.set)
138:                            .tailSet(fromValue));
139:                }
140:
141:            }
142:
143:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.