1 28 29 package com.caucho.iiop; 30 31 import java.io.IOException ; 32 33 public class UnmarshallObject { 34 public final static int BOOLEAN = 0; 35 public final static int BYTE = 1; 36 public final static int SHORT = 2; 37 public final static int CHAR = 3; 38 public final static int INT = 4; 39 public final static int LONG = 5; 40 public final static int FLOAT = 6; 41 public final static int DOUBLE = 7; 42 43 public final static int STRING = 8; 44 45 public final static int BOOLEAN_ARRAY = 9; 46 public final static int BYTE_ARRAY = 10; 47 public final static int SHORT_ARRAY = 11; 48 public final static int CHAR_ARRAY = 12; 49 public final static int INT_ARRAY = 13; 50 public final static int LONG_ARRAY = 14; 51 public final static int FLOAT_ARRAY = 15; 52 public final static int DOUBLE_ARRAY = 16; 53 public final static int STRING_ARRAY = 17; 54 55 private int code; 56 57 private UnmarshallObject(int code) 58 { 59 this.code = code; 60 } 61 62 public Object unmarshall(IiopReader reader) 63 throws IOException 64 { 65 switch (code) { 66 case BOOLEAN: 67 return new Boolean (reader.read_boolean()); 68 case BYTE: 69 return new Byte (reader.read_octet()); 70 case SHORT: 71 return new Short (reader.read_short()); 72 case CHAR: 73 return new Character (reader.read_wchar()); 74 case INT: 75 return new Integer (reader.read_long()); 76 case LONG: 77 return new Long (reader.read_longlong()); 78 case FLOAT: 79 return new Float (reader.read_float()); 80 case DOUBLE: 81 return new Double (reader.read_double()); 82 case STRING: 83 return reader.read_wstring(); 84 case BOOLEAN_ARRAY: 85 { 86 boolean []array = new boolean[reader.read_sequence_length()]; 87 reader.read_boolean_array(array, 0, array.length); 88 return array; 89 } 90 case BYTE_ARRAY: 91 { 92 byte []array = new byte[reader.read_sequence_length()]; 93 reader.read_octet_array(array, 0, array.length); 94 return array; 95 } 96 case CHAR_ARRAY: 97 { 98 char []array = new char[reader.read_sequence_length()]; 99 reader.read_wchar_array(array, 0, array.length); 100 return array; 101 } 102 case SHORT_ARRAY: 103 { 104 short []array = new short[reader.read_sequence_length()]; 105 reader.read_short_array(array, 0, array.length); 106 return array; 107 } 108 case INT_ARRAY: 109 { 110 int []array = new int[reader.read_sequence_length()]; 111 reader.read_long_array(array, 0, array.length); 112 return array; 113 } 114 case LONG_ARRAY: 115 { 116 long []array = new long[reader.read_sequence_length()]; 117 reader.read_longlong_array(array, 0, array.length); 118 return array; 119 } 120 case FLOAT_ARRAY: 121 { 122 float []array = new float[reader.read_sequence_length()]; 123 reader.read_float_array(array, 0, array.length); 124 return array; 125 } 126 case DOUBLE_ARRAY: 127 { 128 double []array = new double[reader.read_sequence_length()]; 129 reader.read_double_array(array, 0, array.length); 130 return array; 131 } 132 case STRING_ARRAY: 133 { 134 String []array = new String [reader.read_sequence_length()]; 135 for (int i = 0; i < array.length; i++) 136 array[i] = reader.read_wstring(); 137 return array; 138 } 139 default: 140 throw new IOException ("unknown type"); 141 } 142 } 143 } 144 | Popular Tags |