1 5 6 9 package com.sun.corba.se.impl.orbutil; 10 11 import java.io.*; 12 import java.util.Hashtable ; 13 14 class LegacyHookGetFields extends ObjectInputStream.GetField { 15 private Hashtable fields = null; 16 17 LegacyHookGetFields(Hashtable fields){ 18 this.fields = fields; 19 } 20 21 24 public java.io.ObjectStreamClass getObjectStreamClass() { 25 return null; 26 } 27 28 32 public boolean defaulted(String name) 33 throws IOException, IllegalArgumentException { 34 return (!fields.containsKey(name)); 35 } 36 37 40 public boolean get(String name, boolean defvalue) 41 throws IOException, IllegalArgumentException { 42 if (defaulted(name)) 43 return defvalue; 44 else return ((Boolean )fields.get(name)).booleanValue(); 45 } 46 47 50 public char get(String name, char defvalue) 51 throws IOException, IllegalArgumentException { 52 if (defaulted(name)) 53 return defvalue; 54 else return ((Character )fields.get(name)).charValue(); 55 56 } 57 58 61 public byte get(String name, byte defvalue) 62 throws IOException, IllegalArgumentException { 63 if (defaulted(name)) 64 return defvalue; 65 else return ((Byte )fields.get(name)).byteValue(); 66 67 } 68 69 72 public short get(String name, short defvalue) 73 throws IOException, IllegalArgumentException { 74 if (defaulted(name)) 75 return defvalue; 76 else return ((Short )fields.get(name)).shortValue(); 77 78 } 79 80 83 public int get(String name, int defvalue) 84 throws IOException, IllegalArgumentException { 85 if (defaulted(name)) 86 return defvalue; 87 else return ((Integer )fields.get(name)).intValue(); 88 89 } 90 91 94 public long get(String name, long defvalue) 95 throws IOException, IllegalArgumentException { 96 if (defaulted(name)) 97 return defvalue; 98 else return ((Long )fields.get(name)).longValue(); 99 100 } 101 102 105 public float get(String name, float defvalue) 106 throws IOException, IllegalArgumentException { 107 if (defaulted(name)) 108 return defvalue; 109 else return ((Float )fields.get(name)).floatValue(); 110 111 } 112 113 116 public double get(String name, double defvalue) 117 throws IOException, IllegalArgumentException { 118 if (defaulted(name)) 119 return defvalue; 120 else return ((Double )fields.get(name)).doubleValue(); 121 122 } 123 124 127 public Object get(String name, Object defvalue) 128 throws IOException, IllegalArgumentException { 129 if (defaulted(name)) 130 return defvalue; 131 else return fields.get(name); 132 133 } 134 135 public String toString(){ 136 return fields.toString(); 137 } 138 } 139 | Popular Tags |