1 7 8 package com.sun.corba.se.impl.encoding; 9 10 import java.util.HashMap ; 11 import java.util.Map ; 12 import java.util.Iterator ; 13 import java.util.List ; 14 import java.util.Collections ; 15 import java.util.ArrayList ; 16 import java.io.IOException ; 17 import java.io.PrintStream ; 18 import java.io.ByteArrayOutputStream ; 19 import java.math.BigDecimal ; 20 import java.math.BigInteger ; 21 22 import org.omg.CORBA.TypeCode ; 23 import org.omg.CORBA.StructMember ; 24 import org.omg.CORBA.UnionMember ; 25 import org.omg.CORBA.ValueMember ; 26 import org.omg.CORBA.TCKind ; 27 import org.omg.CORBA.Any ; 28 import org.omg.CORBA.Principal ; 29 import org.omg.CORBA.BAD_TYPECODE ; 30 import org.omg.CORBA.BAD_PARAM ; 31 import org.omg.CORBA.BAD_OPERATION ; 32 import org.omg.CORBA.INTERNAL ; 33 import org.omg.CORBA.MARSHAL ; 34 35 import org.omg.CORBA.TypeCodePackage.BadKind ; 36 37 import org.omg.CORBA_2_3.portable.InputStream ; 38 import org.omg.CORBA_2_3.portable.OutputStream ; 39 40 import com.sun.corba.se.spi.ior.iiop.GIOPVersion; 41 import com.sun.corba.se.impl.corba.TypeCodeImpl; 42 import com.sun.corba.se.spi.orb.ORB; 43 import com.sun.corba.se.impl.encoding.OSFCodeSetRegistry; 44 import com.sun.corba.se.impl.encoding.MarshalInputStream; 45 import com.sun.corba.se.impl.encoding.CodeSetConversion; 46 import com.sun.corba.se.impl.encoding.CDRInputStream; 47 import com.sun.corba.se.impl.encoding.CDROutputStream; 48 49 public class WrapperInputStream extends org.omg.CORBA_2_3.portable.InputStream implements TypeCodeReader 50 { 51 private CDRInputStream stream; 52 private Map typeMap = null; 53 private int startPos = 0; 54 55 public WrapperInputStream(CDRInputStream s) { 56 super(); 57 stream = s; 58 startPos = stream.getPosition(); 59 } 60 61 public int read() throws IOException { return stream.read(); } 62 public int read(byte b[]) throws IOException { return stream.read(b); } 63 public int read(byte b[], int off, int len) throws IOException { 64 return stream.read(b, off, len); 65 } 66 public long skip(long n) throws IOException { return stream.skip(n); } 67 public int available() throws IOException { return stream.available(); } 68 public void close() throws IOException { stream.close(); } 69 public void mark(int readlimit) { stream.mark(readlimit); } 70 public void reset() { stream.reset(); } 71 public boolean markSupported() { return stream.markSupported(); } 72 public int getPosition() { return stream.getPosition(); } 73 public void consumeEndian() { stream.consumeEndian(); } 74 public boolean read_boolean() { return stream.read_boolean(); } 75 public char read_char() { return stream.read_char(); } 76 public char read_wchar() { return stream.read_wchar(); } 77 public byte read_octet() { return stream.read_octet(); } 78 public short read_short() { return stream.read_short(); } 79 public short read_ushort() { return stream.read_ushort(); } 80 public int read_long() { return stream.read_long(); } 81 public int read_ulong() { return stream.read_ulong(); } 82 public long read_longlong() { return stream.read_longlong(); } 83 public long read_ulonglong() { return stream.read_ulonglong(); } 84 public float read_float() { return stream.read_float(); } 85 public double read_double() { return stream.read_double(); } 86 public String read_string() { return stream.read_string(); } 87 public String read_wstring() { return stream.read_wstring(); } 88 89 public void read_boolean_array(boolean[] value, int offset, int length) { 90 stream.read_boolean_array(value, offset, length); 91 } 92 public void read_char_array(char[] value, int offset, int length) { 93 stream.read_char_array(value, offset, length); 94 } 95 public void read_wchar_array(char[] value, int offset, int length) { 96 stream.read_wchar_array(value, offset, length); 97 } 98 public void read_octet_array(byte[] value, int offset, int length) { 99 stream.read_octet_array(value, offset, length); 100 } 101 public void read_short_array(short[] value, int offset, int length) { 102 stream.read_short_array(value, offset, length); 103 } 104 public void read_ushort_array(short[] value, int offset, int length) { 105 stream.read_ushort_array(value, offset, length); 106 } 107 public void read_long_array(int[] value, int offset, int length) { 108 stream.read_long_array(value, offset, length); 109 } 110 public void read_ulong_array(int[] value, int offset, int length) { 111 stream.read_ulong_array(value, offset, length); 112 } 113 public void read_longlong_array(long[] value, int offset, int length) { 114 stream.read_longlong_array(value, offset, length); 115 } 116 public void read_ulonglong_array(long[] value, int offset, int length) { 117 stream.read_ulonglong_array(value, offset, length); 118 } 119 public void read_float_array(float[] value, int offset, int length) { 120 stream.read_float_array(value, offset, length); 121 } 122 public void read_double_array(double[] value, int offset, int length) { 123 stream.read_double_array(value, offset, length); 124 } 125 126 public org.omg.CORBA.Object read_Object() { return stream.read_Object(); } 127 public java.io.Serializable read_value() {return stream.read_value();} 128 public TypeCode read_TypeCode() { return stream.read_TypeCode(); } 129 public Any read_any() { return stream.read_any(); } 130 public Principal read_Principal() { return stream.read_Principal(); } 131 public java.math.BigDecimal read_fixed() { return stream.read_fixed(); } 132 public org.omg.CORBA.Context read_Context() { return stream.read_Context(); } 133 134 public org.omg.CORBA.ORB orb() { return stream.orb(); } 135 136 public void addTypeCodeAtPosition(TypeCodeImpl tc, int position) { 137 if (typeMap == null) { 138 typeMap = new HashMap (16); 140 } 141 typeMap.put(new Integer (position), tc); 143 } 144 145 public TypeCodeImpl getTypeCodeAtPosition(int position) { 146 if (typeMap == null) 147 return null; 148 return (TypeCodeImpl)typeMap.get(new Integer (position)); 151 } 152 153 public void setEnclosingInputStream(InputStream enclosure) { 154 } 156 157 public TypeCodeReader getTopLevelStream() { 158 return this; 160 } 161 162 public int getTopLevelPosition() { 163 return getPosition() - startPos; 167 } 168 169 public void performORBVersionSpecificInit() { 170 stream.performORBVersionSpecificInit(); 173 } 174 175 public void resetCodeSetConverters() { 176 stream.resetCodeSetConverters(); 177 } 178 179 181 public void printTypeMap() { 182 System.out.println("typeMap = {"); 183 List sortedKeys = new ArrayList (typeMap.keySet()); 184 Collections.sort(sortedKeys); 185 Iterator i = sortedKeys.iterator(); 186 while (i.hasNext()) { 187 Integer pos = (Integer )i.next(); 188 TypeCodeImpl tci = (TypeCodeImpl)typeMap.get(pos); 189 System.out.println(" key = " + pos.intValue() + ", value = " + tci.description()); 190 } 191 System.out.println("}"); 192 } 193 } 194 | Popular Tags |