Source Code Cross Referenced for CompressionInputStream.java in  » EJB-Server-JBoss-4.2.1 » testsuite » org » jboss » test » invokers » ejb » 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 » EJB Server JBoss 4.2.1 » testsuite » org.jboss.test.invokers.ejb 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 1998, 1999 Sun Microsystems, Inc. All Rights Reserved.
003:         *
004:         * Sun grants you ("Licensee") a non-exclusive, royalty free, license to use,
005:         * modify and redistribute this software in source and binary code form,
006:         * provided that i) this copyright notice and license appear on all copies of
007:         * the software; and ii) Licensee does not utilize the software in a manner
008:         * which is disparaging to Sun.
009:         *
010:         * This software is provided "AS IS," without a warranty of any kind. ALL
011:         * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
012:         * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
013:         * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE
014:         * LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
015:         * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS
016:         * LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
017:         * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
018:         * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
019:         * OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
020:         * POSSIBILITY OF SUCH DAMAGES.
021:         *
022:         * This software is not designed or intended for use in on-line control of
023:         * aircraft, air traffic, aircraft navigation or aircraft communications; or in
024:         * the design, construction, operation or maintenance of any nuclear
025:         * facility. Licensee represents and warrants that it will not use or
026:         * redistribute the Software for such purposes.
027:         */
028:        package org.jboss.test.invokers.ejb;
029:
030:        import java.io.*;
031:        import java.net.*;
032:
033:        /**
034:         * From some old jdk 1.3 rmi guide
035:         */
036:        class CompressionInputStream extends FilterInputStream implements 
037:                CompressionConstants {
038:            /*
039:             * Constructor calls constructor of superclass
040:             */
041:            public CompressionInputStream(InputStream in) {
042:                super (in);
043:            }
044:
045:            /* 
046:             * Buffer of unpacked 6-bit codes 
047:             * from last 32 bits read.
048:             */
049:            int buf[] = new int[5];
050:
051:            /*
052:             * Position of next code to read in buffer (5 signifies end). 
053:             */
054:            int bufPos = 5;
055:
056:            /*
057:             * Reads in format code and decompresses character accordingly.
058:             */
059:
060:            public int read() throws IOException {
061:                try {
062:                    int code;
063:
064:                    // Read in and ignore empty bytes (NOP's) as long as they
065:                    // arrive. 
066:                    do {
067:                        code = readCode();
068:                    } while (code == NOP);
069:
070:                    if (code >= BASE) {
071:                        // Retrieve index of character in codeTable if the
072:                        // code is in the correct range.
073:                        return codeTable.charAt(code - BASE);
074:                    } else if (code == RAW) {
075:                        // read in the lower 4 bits and the higher 4 bits,
076:                        // and return the reconstructed character
077:                        int high = readCode();
078:                        int low = readCode();
079:                        return (high << 4) | low;
080:                    } else
081:                        throw new IOException("unknown compression code: "
082:                                + code);
083:                } catch (EOFException e) {
084:                    // Return the end of file code
085:                    return -1;
086:                }
087:            }
088:
089:            /* 
090:             * This method reads up to len bytes from the input stream. 
091:             * Returns if read blocks before len bytes are read.
092:             */
093:            public int read(byte b[], int off, int len) throws IOException {
094:
095:                if (len <= 0) {
096:                    return 0;
097:                }
098:
099:                int c = read();
100:                if (c == -1) {
101:                    return -1;
102:                }
103:                b[off] = (byte) c;
104:
105:                int i = 1;
106:                // Try to read up to len bytes or until no
107:                // more bytes can be read without blocking.
108:                try {
109:                    for (; (i < len) && (in.available() > 0); i++) {
110:                        c = read();
111:                        if (c == -1) {
112:                            break;
113:                        }
114:                        if (b != null) {
115:                            b[off + i] = (byte) c;
116:                        }
117:                    }
118:                } catch (IOException ee) {
119:                }
120:                return i;
121:            }
122:
123:            /*
124:             * If there is no more data to decode left in buf, read the
125:             * next four bytes from the wire. Then store each group of 6
126:             * bits in an element of buf.  Return one element of buf.
127:             */
128:            private int readCode() throws IOException {
129:                // As soon as all the data in buf has been read
130:                // (when bufPos == 5) read in another four bytes.
131:                if (bufPos == 5) {
132:                    int b1 = in.read();
133:                    int b2 = in.read();
134:                    int b3 = in.read();
135:                    int b4 = in.read();
136:
137:                    // make sure none of the bytes signify the
138:                    // end of the data in the stream
139:                    if ((b1 | b2 | b3 | b4) < 0) {
140:                        throw new EOFException();
141:                    }
142:                    // Assign each group of 6 bits to an element of
143:                    // buf
144:                    int pack = (b1 << 24) | (b2 << 16) | (b3 << 8) | b4;
145:                    buf[0] = (pack >>> 24) & 0x3F;
146:                    buf[1] = (pack >>> 18) & 0x3F;
147:                    buf[2] = (pack >>> 12) & 0x3F;
148:                    buf[3] = (pack >>> 6) & 0x3F;
149:                    buf[4] = (pack >>> 0) & 0x3F;
150:                    bufPos = 0;
151:                }
152:                return buf[bufPos++];
153:            }
154:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.