Source Code Cross Referenced for EncapsInputStream.java in  » 6.0-JDK-Modules-com.sun » corba » com » sun » corba » se » impl » encoding » 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 » 6.0 JDK Modules com.sun » corba » com.sun.corba.se.impl.encoding 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2001-2004 Sun Microsystems, Inc.  All Rights Reserved.
003:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004:         *
005:         * This code is free software; you can redistribute it and/or modify it
006:         * under the terms of the GNU General Public License version 2 only, as
007:         * published by the Free Software Foundation.  Sun designates this
008:         * particular file as subject to the "Classpath" exception as provided
009:         * by Sun in the LICENSE file that accompanied this code.
010:         *
011:         * This code is distributed in the hope that it will be useful, but WITHOUT
012:         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013:         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
014:         * version 2 for more details (a copy is included in the LICENSE file that
015:         * accompanied this code).
016:         *
017:         * You should have received a copy of the GNU General Public License version
018:         * 2 along with this work; if not, write to the Free Software Foundation,
019:         * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020:         *
021:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022:         * CA 95054 USA or visit www.sun.com if you need additional information or
023:         * have any questions.
024:         */
025:
026:        package com.sun.corba.se.impl.encoding;
027:
028:        import java.nio.ByteBuffer;
029:        import org.omg.CORBA.CompletionStatus;
030:        import com.sun.org.omg.SendingContext.CodeBase;
031:        import com.sun.corba.se.spi.ior.iiop.GIOPVersion;
032:        import com.sun.corba.se.impl.encoding.CDRInputStream;
033:        import com.sun.corba.se.impl.encoding.BufferManagerFactory;
034:        import com.sun.corba.se.impl.encoding.CodeSetConversion;
035:        import com.sun.corba.se.impl.encoding.OSFCodeSetRegistry;
036:        import com.sun.corba.se.impl.protocol.giopmsgheaders.Message;
037:
038:        import com.sun.corba.se.spi.orb.ORB;
039:
040:        import com.sun.corba.se.spi.logging.CORBALogDomains;
041:
042:        import com.sun.corba.se.impl.logging.ORBUtilSystemException;
043:
044:        /**
045:         * Encapsulations are supposed to explicitly define their
046:         * code sets and GIOP version.  The original resolution to issue 2784 
047:         * said that the defaults were UTF-8 and UTF-16, but that was not
048:         * agreed upon.
049:         *
050:         * These streams currently use CDR 1.2 with ISO8859-1 for char/string and
051:         * UTF16 for wchar/wstring.  If no byte order marker is available,
052:         * the endianness of the encapsulation is used.
053:         *
054:         * When more encapsulations arise that have their own special code
055:         * sets defined, we can make all constructors take such parameters.
056:         */
057:        public class EncapsInputStream extends CDRInputStream {
058:            private ORBUtilSystemException wrapper;
059:
060:            // corba/EncapsOutputStream
061:            // corba/ORBSingleton
062:            // iiop/ORB
063:            public EncapsInputStream(org.omg.CORBA.ORB orb, byte[] buf,
064:                    int size, boolean littleEndian, GIOPVersion version) {
065:                super (orb, ByteBuffer.wrap(buf), size, littleEndian, version,
066:                        Message.CDR_ENC_VERSION, BufferManagerFactory
067:                                .newBufferManagerRead(
068:                                        BufferManagerFactory.GROW,
069:                                        Message.CDR_ENC_VERSION, (ORB) orb));
070:
071:                wrapper = ORBUtilSystemException.get((ORB) orb,
072:                        CORBALogDomains.RPC_ENCODING);
073:
074:                performORBVersionSpecificInit();
075:            }
076:
077:            public EncapsInputStream(org.omg.CORBA.ORB orb,
078:                    ByteBuffer byteBuffer, int size, boolean littleEndian,
079:                    GIOPVersion version) {
080:                super (orb, byteBuffer, size, littleEndian, version,
081:                        Message.CDR_ENC_VERSION, BufferManagerFactory
082:                                .newBufferManagerRead(
083:                                        BufferManagerFactory.GROW,
084:                                        Message.CDR_ENC_VERSION,
085:                                        (com.sun.corba.se.spi.orb.ORB) orb));
086:
087:                performORBVersionSpecificInit();
088:            }
089:
090:            // ior/IdentifiableBase
091:            // ior/IIOPProfile
092:            // corba/ORBSingleton
093:            // iiop/ORB
094:            public EncapsInputStream(org.omg.CORBA.ORB orb, byte[] data,
095:                    int size) {
096:                this (orb, data, size, GIOPVersion.V1_2);
097:            }
098:
099:            // corba/AnyImpl
100:            public EncapsInputStream(EncapsInputStream eis) {
101:                super (eis);
102:
103:                wrapper = ORBUtilSystemException.get((ORB) (eis.orb()),
104:                        CORBALogDomains.RPC_ENCODING);
105:
106:                performORBVersionSpecificInit();
107:            }
108:
109:            // CDREncapsCodec
110:            // ServiceContext
111:            //
112:            // Assumes big endian (can use consumeEndian to read and set
113:            // the endianness if it is an encapsulation with a byte order
114:            // mark at the beginning)
115:            public EncapsInputStream(org.omg.CORBA.ORB orb, byte[] data,
116:                    int size, GIOPVersion version) {
117:                this (orb, data, size, false, version);
118:            }
119:
120:            /**
121:             * Full constructor with a CodeBase parameter useful for
122:             * unmarshaling RMI-IIOP valuetypes (technically against the
123:             * intention of an encapsulation, but necessary due to OMG
124:             * issue 4795.  Used by ServiceContexts.
125:             */
126:            public EncapsInputStream(org.omg.CORBA.ORB orb, byte[] data,
127:                    int size, GIOPVersion version, CodeBase codeBase) {
128:                super (orb, ByteBuffer.wrap(data), size, false, version,
129:                        Message.CDR_ENC_VERSION, BufferManagerFactory
130:                                .newBufferManagerRead(
131:                                        BufferManagerFactory.GROW,
132:                                        Message.CDR_ENC_VERSION, (ORB) orb));
133:
134:                this .codeBase = codeBase;
135:
136:                performORBVersionSpecificInit();
137:            }
138:
139:            public CDRInputStream dup() {
140:                return new EncapsInputStream(this );
141:            }
142:
143:            protected CodeSetConversion.BTCConverter createCharBTCConverter() {
144:                return CodeSetConversion.impl().getBTCConverter(
145:                        OSFCodeSetRegistry.ISO_8859_1);
146:            }
147:
148:            protected CodeSetConversion.BTCConverter createWCharBTCConverter() {
149:                // Wide characters don't exist in GIOP 1.0
150:                if (getGIOPVersion().equals(GIOPVersion.V1_0))
151:                    throw wrapper
152:                            .wcharDataInGiop10(CompletionStatus.COMPLETED_MAYBE);
153:
154:                // In GIOP 1.1, we shouldn't have byte order markers.  Take the order
155:                // of the stream if we don't see them.
156:                if (getGIOPVersion().equals(GIOPVersion.V1_1))
157:                    return CodeSetConversion.impl().getBTCConverter(
158:                            OSFCodeSetRegistry.UTF_16, isLittleEndian());
159:
160:                // Assume anything else adheres to GIOP 1.2 requirements.
161:                //
162:                // Our UTF_16 converter will work with byte order markers, and if
163:                // they aren't present, it will use the provided endianness.
164:                //
165:                // With no byte order marker, it's big endian in GIOP 1.2.  
166:                // formal 00-11-03 15.3.16.
167:                return CodeSetConversion.impl().getBTCConverter(
168:                        OSFCodeSetRegistry.UTF_16, false);
169:            }
170:
171:            public CodeBase getCodeBase() {
172:                return codeBase;
173:            }
174:
175:            private CodeBase codeBase;
176:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.