Source Code Cross Referenced for UnmodifiableSortedMap.java in  » Library » Apache-common-Collections » org » apache » commons » collections » map » 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 » Library » Apache common Collections » org.apache.commons.collections.map 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Copyright 2003-2004 The Apache Software Foundation
003:         *
004:         *  Licensed under the Apache License, Version 2.0 (the "License");
005:         *  you may not use this file except in compliance with the License.
006:         *  You may obtain a copy of the License at
007:         *
008:         *      http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         *  Unless required by applicable law or agreed to in writing, software
011:         *  distributed under the License is distributed on an "AS IS" BASIS,
012:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         *  See the License for the specific language governing permissions and
014:         *  limitations under the License.
015:         */
016:        package org.apache.commons.collections.map;
017:
018:        import java.io.IOException;
019:        import java.io.ObjectInputStream;
020:        import java.io.ObjectOutputStream;
021:        import java.io.Serializable;
022:        import java.util.Collection;
023:        import java.util.Comparator;
024:        import java.util.Map;
025:        import java.util.Set;
026:        import java.util.SortedMap;
027:
028:        import org.apache.commons.collections.Unmodifiable;
029:        import org.apache.commons.collections.collection.UnmodifiableCollection;
030:        import org.apache.commons.collections.set.UnmodifiableSet;
031:
032:        /**
033:         * Decorates another <code>SortedMap</code> to ensure it can't be altered.
034:         * <p>
035:         * This class is Serializable from Commons Collections 3.1.
036:         *
037:         * @since Commons Collections 3.0
038:         * @version $Revision: 155406 $ $Date: 2005-02-26 12:55:26 +0000 (Sat, 26 Feb 2005) $
039:         * 
040:         * @author Stephen Colebourne
041:         */
042:        public final class UnmodifiableSortedMap extends
043:                AbstractSortedMapDecorator implements  Unmodifiable,
044:                Serializable {
045:
046:            /** Serialization version */
047:            private static final long serialVersionUID = 5805344239827376360L;
048:
049:            /**
050:             * Factory method to create an unmodifiable sorted map.
051:             * 
052:             * @param map  the map to decorate, must not be null
053:             * @throws IllegalArgumentException if map is null
054:             */
055:            public static SortedMap decorate(SortedMap map) {
056:                if (map instanceof  Unmodifiable) {
057:                    return map;
058:                }
059:                return new UnmodifiableSortedMap(map);
060:            }
061:
062:            //-----------------------------------------------------------------------
063:            /**
064:             * Constructor that wraps (not copies).
065:             * 
066:             * @param map  the map to decorate, must not be null
067:             * @throws IllegalArgumentException if map is null
068:             */
069:            private UnmodifiableSortedMap(SortedMap map) {
070:                super (map);
071:            }
072:
073:            //-----------------------------------------------------------------------
074:            /**
075:             * Write the map out using a custom routine.
076:             * 
077:             * @param out  the output stream
078:             * @throws IOException
079:             * @since Commons Collections 3.1
080:             */
081:            private void writeObject(ObjectOutputStream out) throws IOException {
082:                out.defaultWriteObject();
083:                out.writeObject(map);
084:            }
085:
086:            /**
087:             * Read the map in using a custom routine.
088:             * 
089:             * @param in  the input stream
090:             * @throws IOException
091:             * @throws ClassNotFoundException
092:             * @since Commons Collections 3.1
093:             */
094:            private void readObject(ObjectInputStream in) throws IOException,
095:                    ClassNotFoundException {
096:                in.defaultReadObject();
097:                map = (Map) in.readObject();
098:            }
099:
100:            //-----------------------------------------------------------------------
101:            public void clear() {
102:                throw new UnsupportedOperationException();
103:            }
104:
105:            public Object put(Object key, Object value) {
106:                throw new UnsupportedOperationException();
107:            }
108:
109:            public void putAll(Map mapToCopy) {
110:                throw new UnsupportedOperationException();
111:            }
112:
113:            public Object remove(Object key) {
114:                throw new UnsupportedOperationException();
115:            }
116:
117:            public Set entrySet() {
118:                Set set = super .entrySet();
119:                return UnmodifiableEntrySet.decorate(set);
120:            }
121:
122:            public Set keySet() {
123:                Set set = super .keySet();
124:                return UnmodifiableSet.decorate(set);
125:            }
126:
127:            public Collection values() {
128:                Collection coll = super .values();
129:                return UnmodifiableCollection.decorate(coll);
130:            }
131:
132:            //-----------------------------------------------------------------------
133:            public Object firstKey() {
134:                return getSortedMap().firstKey();
135:            }
136:
137:            public Object lastKey() {
138:                return getSortedMap().lastKey();
139:            }
140:
141:            public Comparator comparator() {
142:                return getSortedMap().comparator();
143:            }
144:
145:            public SortedMap subMap(Object fromKey, Object toKey) {
146:                SortedMap map = getSortedMap().subMap(fromKey, toKey);
147:                return new UnmodifiableSortedMap(map);
148:            }
149:
150:            public SortedMap headMap(Object toKey) {
151:                SortedMap map = getSortedMap().headMap(toKey);
152:                return new UnmodifiableSortedMap(map);
153:            }
154:
155:            public SortedMap tailMap(Object fromKey) {
156:                SortedMap map = getSortedMap().tailMap(fromKey);
157:                return new UnmodifiableSortedMap(map);
158:            }
159:
160:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.