Source Code Cross Referenced for SortedSetToByteSortedSetAdapter.java in  » Development » PCJ » bak » pcj » adapter » 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 » Development » PCJ » bak.pcj.adapter 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Primitive Collections for Java.
003:         *  Copyright (C) 2003  Søren Bak
004:         *
005:         *  This library is free software; you can redistribute it and/or
006:         *  modify it under the terms of the GNU Lesser General Public
007:         *  License as published by the Free Software Foundation; either
008:         *  version 2.1 of the License, or (at your option) any later version.
009:         *
010:         *  This library is distributed in the hope that it will be useful,
011:         *  but WITHOUT ANY WARRANTY; without even the implied warranty of
012:         *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013:         *  Lesser General Public License for more details.
014:         *
015:         *  You should have received a copy of the GNU Lesser General Public
016:         *  License along with this library; if not, write to the Free Software
017:         *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
018:         */
019:        package bak.pcj.adapter;
020:
021:        import bak.pcj.ByteIterator;
022:        import bak.pcj.set.ByteSortedSet;
023:        import bak.pcj.set.AbstractByteSet;
024:        import bak.pcj.adapter.IteratorToByteIteratorAdapter;
025:
026:        import java.util.SortedSet;
027:
028:        /**
029:         *  This class represents adaptions of Java Collections Framework
030:         *  sets to primitive sets of byte values.
031:         *  The adapter is implemented as a wrapper around the set. 
032:         *  Thus, changes to the underlying set are reflected by this
033:         *  set and vice versa.
034:         *
035:         *  <p>
036:         *  Adapters from JCF collections to primitive collections will
037:         *  fail if the JCF collection contains <tt>null</tt> values or
038:         *  values of the wrong class. However, adapters are not fast
039:         *  failing in the case that the underlying collection should
040:         *  contain illegal values. To implement fast failure would require
041:         *  every operation to check every element of the underlying
042:         *  collection before doing anything. Instead validation methods
043:         *  are provided. They can be called using the assertion facility
044:         *  in the client code:
045:         *  <pre>
046:         *      SortedSetToByteSortedSetAdapter s;
047:         *      ...
048:         *      <b>assert</b> s.validate();
049:         *  </pre>
050:         *  or by letting the adapter throw an exception on illegal values:
051:         *  <pre>
052:         *      SortedSetToByteSortedSetAdapter s;
053:         *      ...
054:         *      s.evalidate();  // Throws an exception on illegal values
055:         *  </pre>
056:         *  Either way, validation must be invoked directly by the client
057:         *  code.
058:         *
059:         *  @author     S&oslash;ren Bak
060:         *  @version    1.0     20-08-2003 23:16
061:         *  @since      1.2
062:         */
063:        public class SortedSetToByteSortedSetAdapter extends
064:                SetToByteSetAdapter implements  ByteSortedSet {
065:
066:            /**
067:             *  Creates a new adaption to a set of byte
068:             *  values.
069:             *
070:             *  @param      set
071:             *              the underlying set. This set must
072:             *              consist of values of class
073:             *              {@link Byte Byte}. Otherwise a
074:             *              {@link ClassCastException ClassCastException}
075:             *              will be thrown by some methods.
076:             *
077:             *  @throws     NullPointerException
078:             *              if <tt>set</tt> is <tt>null</tt>.
079:             */
080:            public SortedSetToByteSortedSetAdapter(SortedSet set) {
081:                super (set);
082:            }
083:
084:            /**
085:             *  Creates a new adaption to a set of byte
086:             *  values. The set to adapt is optionally validated.
087:             *
088:             *  @param      set
089:             *              the underlying set. This set must
090:             *              consist of values of class
091:             *              {@link Byte Byte}. Otherwise a
092:             *              {@link ClassCastException ClassCastException}
093:             *              will be thrown by some methods.
094:             *
095:             *  @param      validate
096:             *              indicates whether <tt>set</tt> should
097:             *              be checked for illegal values.
098:             *
099:             *  @throws     NullPointerException
100:             *              if <tt>set</tt> is <tt>null</tt>.
101:             *
102:             *  @throws     IllegalStateException
103:             *              if <tt>validate</tt> is <tt>true</tt> and
104:             *              <tt>set</tt> contains a <tt>null</tt> value
105:             *              or a value that is not of class
106:             *              {@link Byte Byte}.
107:             */
108:            public SortedSetToByteSortedSetAdapter(SortedSet set,
109:                    boolean validate) {
110:                super (set, validate);
111:            }
112:
113:            public byte first() {
114:                return ((Byte) (((SortedSet) set).first())).byteValue();
115:            }
116:
117:            public ByteSortedSet headSet(byte to) {
118:                return new SortedSetToByteSortedSetAdapter(((SortedSet) set)
119:                        .headSet(new Byte(to)));
120:            }
121:
122:            public byte last() {
123:                return ((Byte) (((SortedSet) set).last())).byteValue();
124:            }
125:
126:            public ByteSortedSet subSet(byte from, byte to) {
127:                return new SortedSetToByteSortedSetAdapter(((SortedSet) set)
128:                        .subSet(new Byte(from), new Byte(to)));
129:            }
130:
131:            public ByteSortedSet tailSet(byte from) {
132:                return new SortedSetToByteSortedSetAdapter(((SortedSet) set)
133:                        .tailSet(new Byte(from)));
134:            }
135:
136:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.