Source Code Cross Referenced for DecompressionTest.java in  » Internationalization-Localization » icu4j » com » ibm » icu » dev » test » compression » 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 » Internationalization Localization » icu4j » com.ibm.icu.dev.test.compression 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *******************************************************************************
003:         * Copyright (C) 1996-2005, International Business Machines Corporation and    *
004:         * others. All Rights Reserved.                                                *
005:         *******************************************************************************
006:         */
007:        package com.ibm.icu.dev.test.compression;
008:
009:        import com.ibm.icu.text.UnicodeDecompressor;
010:        import com.ibm.icu.dev.test.TestFmwk;
011:
012:        public class DecompressionTest extends TestFmwk {
013:            public static void main(String[] args) throws Exception {
014:                new DecompressionTest().run(args);
015:            }
016:
017:            /** Print out a segment of a character array, if in verbose mode */
018:            private void log(char[] chars, int start, int count) {
019:                log("|");
020:                for (int i = start; i < start + count; ++i) {
021:                    log(String.valueOf(chars[i]));
022:                }
023:                log("|");
024:            }
025:
026:            /** Print out a segment of a character array, followed by a newline */
027:            private void logln(char[] chars, int start, int count) {
028:                log(chars, start, count);
029:                logln("");
030:            }
031:
032:            /** Decompress the two segments */
033:            private String decompressTest(byte[] segment1, byte[] segment2) {
034:                StringBuffer s = new StringBuffer();
035:                UnicodeDecompressor myDecompressor = new UnicodeDecompressor();
036:
037:                int[] bytesRead = new int[1];
038:                char[] charBuffer = new char[2 * (segment1.length + segment2.length)];
039:                int count1 = 0, count2 = 0;
040:
041:                count1 = myDecompressor.decompress(segment1, 0,
042:                        segment1.length, bytesRead, charBuffer, 0,
043:                        charBuffer.length);
044:
045:                logln("Segment 1 (" + segment1.length + " bytes) "
046:                        + "decompressed into " + count1 + " chars");
047:                logln("Bytes consumed: " + bytesRead[0]);
048:
049:                logln("Got chars: ");
050:                logln(charBuffer, 0, count1);
051:                s.append(charBuffer, 0, count1);
052:
053:                count2 = myDecompressor.decompress(segment2, 0,
054:                        segment2.length, bytesRead, charBuffer, count1,
055:                        charBuffer.length);
056:
057:                logln("Segment 2 (" + segment2.length + " bytes) "
058:                        + "decompressed into " + count2 + " chars");
059:                logln("Bytes consumed: " + bytesRead[0]);
060:
061:                logln("Got chars: ");
062:                logln(charBuffer, count1, count2);
063:
064:                s.append(charBuffer, count1, count2);
065:
066:                logln("Result: ");
067:                logln(charBuffer, 0, count1 + count2);
068:                logln("====================");
069:
070:                return s.toString();
071:            }
072:
073:            public void testDecompression() throws Exception {
074:                String result;
075:
076:                // compressed segment breaking on a define window sequence
077:                /*                   B     o     o     t     h     SD1  */
078:                byte[] segment1 = { 0x42, 0x6f, 0x6f, 0x74, 0x68, 0x19 };
079:
080:                // continuation
081:                /*                   IDX   ,           S     .          */
082:                byte[] segment2 = { 0x01, 0x2c, 0x20, 0x53, 0x2e };
083:
084:                result = decompressTest(segment1, segment2);
085:                if (!result.equals("Booth, S.")) {
086:                    errln("Decompression test failed");
087:                    return;
088:                }
089:
090:                // compressed segment breaking on a quote unicode sequence
091:                /*                   B     o     o     t     SQU        */
092:                byte[] segment3 = { 0x42, 0x6f, 0x6f, 0x74, 0x0e, 0x00 };
093:
094:                // continuation
095:                /*                   h     ,           S     .          */
096:                byte[] segment4 = { 0x68, 0x2c, 0x20, 0x53, 0x2e };
097:
098:                result = decompressTest(segment3, segment4);
099:                if (!result.equals("Booth, S.")) {
100:                    errln("Decompression test failed");
101:                    return;
102:                }
103:
104:                // compressed segment breaking on a quote unicode sequence
105:                /*                   SCU   UQU                         */
106:                byte[] segment5 = { 0x0f, (byte) 0xf0, 0x00 };
107:
108:                // continuation
109:                /*                   B                                 */
110:                byte[] segment6 = { 0x42 };
111:
112:                result = decompressTest(segment5, segment6);
113:                if (!result.equals("B")) {
114:                    errln("Decompression test failed");
115:                    return;
116:                }
117:            }
118:
119:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.