List of usage examples for java.io UTFDataFormatException initCause
public synchronized Throwable initCause(Throwable cause)
From source file:org.apache.geode.internal.InternalDataSerializer.java
private static void initializeWellKnownSerializers() { // ArrayBlockingQueue does not have zero-arg constructor // LinkedBlockingQueue does have zero-arg constructor but no way to get capacity classesToSerializers.put("java.lang.String", new WellKnownPdxDS() { @Override/* w w w. j a v a 2 s .co m*/ public boolean toData(Object o, DataOutput out) throws IOException { try { writeString((String) o, out); } catch (UTFDataFormatException ex) { // See bug 30428 String s = "While writing a String of length " + ((String) o).length(); UTFDataFormatException ex2 = new UTFDataFormatException(s); ex2.initCause(ex); throw ex2; } return true; } }); classesToSerializers.put("java.net.InetAddress", new WellKnownDS() { @Override public boolean toData(Object o, DataOutput out) throws IOException { InetAddress address = (InetAddress) o; out.writeByte(INET_ADDRESS); writeInetAddress(address, out); return true; } }); classesToSerializers.put("java.net.Inet4Address", new WellKnownDS() { @Override public boolean toData(Object o, DataOutput out) throws IOException { InetAddress address = (InetAddress) o; out.writeByte(INET_ADDRESS); writeInetAddress(address, out); return true; } }); classesToSerializers.put("java.net.Inet6Address", new WellKnownDS() { @Override public boolean toData(Object o, DataOutput out) throws IOException { InetAddress address = (InetAddress) o; out.writeByte(INET_ADDRESS); writeInetAddress(address, out); return true; } }); classesToSerializers.put("java.lang.Class", new WellKnownDS() { @Override public boolean toData(Object o, DataOutput out) throws IOException { Class c = (Class) o; if (c.isPrimitive()) { writePrimitiveClass(c, out); } else { out.writeByte(CLASS); writeClass(c, out); } return true; } }); classesToSerializers.put("java.lang.Boolean", new WellKnownPdxDS() { @Override public boolean toData(Object o, DataOutput out) throws IOException { Boolean value = (Boolean) o; out.writeByte(BOOLEAN); writeBoolean(value, out); return true; } }); classesToSerializers.put("java.lang.Character", new WellKnownPdxDS() { @Override public boolean toData(Object o, DataOutput out) throws IOException { Character value = (Character) o; out.writeByte(CHARACTER); writeCharacter(value, out); return true; } }); classesToSerializers.put("java.lang.Byte", new WellKnownPdxDS() { @Override public boolean toData(Object o, DataOutput out) throws IOException { Byte value = (Byte) o; out.writeByte(BYTE); writeByte(value, out); return true; } }); classesToSerializers.put("java.lang.Short", new WellKnownPdxDS() { @Override public boolean toData(Object o, DataOutput out) throws IOException { Short value = (Short) o; out.writeByte(SHORT); writeShort(value, out); return true; } }); classesToSerializers.put("java.lang.Integer", new WellKnownPdxDS() { @Override public boolean toData(Object o, DataOutput out) throws IOException { Integer value = (Integer) o; out.writeByte(INTEGER); writeInteger(value, out); return true; } }); classesToSerializers.put("java.lang.Long", new WellKnownPdxDS() { @Override public boolean toData(Object o, DataOutput out) throws IOException { Long value = (Long) o; out.writeByte(LONG); writeLong(value, out); return true; } }); classesToSerializers.put("java.lang.Float", new WellKnownPdxDS() { @Override public boolean toData(Object o, DataOutput out) throws IOException { Float value = (Float) o; out.writeByte(FLOAT); writeFloat(value, out); return true; } }); classesToSerializers.put("java.lang.Double", new WellKnownPdxDS() { @Override public boolean toData(Object o, DataOutput out) throws IOException { Double value = (Double) o; out.writeByte(DOUBLE); writeDouble(value, out); return true; } }); classesToSerializers.put("[Z", // boolean[] new WellKnownPdxDS() { @Override public boolean toData(Object o, DataOutput out) throws IOException { out.writeByte(BOOLEAN_ARRAY); writeBooleanArray((boolean[]) o, out); return true; } }); classesToSerializers.put("[B", // byte[] new WellKnownPdxDS() { @Override public boolean toData(Object o, DataOutput out) throws IOException { byte[] array = (byte[]) o; out.writeByte(BYTE_ARRAY); writeByteArray(array, out); return true; } }); classesToSerializers.put("[C", // char[] new WellKnownPdxDS() { @Override public boolean toData(Object o, DataOutput out) throws IOException { out.writeByte(CHAR_ARRAY); writeCharArray((char[]) o, out); return true; } }); classesToSerializers.put("[D", // double[] new WellKnownPdxDS() { @Override public boolean toData(Object o, DataOutput out) throws IOException { double[] array = (double[]) o; out.writeByte(DOUBLE_ARRAY); writeDoubleArray(array, out); return true; } }); classesToSerializers.put("[F", // float[] new WellKnownPdxDS() { @Override public boolean toData(Object o, DataOutput out) throws IOException { float[] array = (float[]) o; out.writeByte(FLOAT_ARRAY); writeFloatArray(array, out); return true; } }); classesToSerializers.put("[I", // int[] new WellKnownPdxDS() { @Override public boolean toData(Object o, DataOutput out) throws IOException { int[] array = (int[]) o; out.writeByte(INT_ARRAY); writeIntArray(array, out); return true; } }); classesToSerializers.put("[J", // long[] new WellKnownPdxDS() { @Override public boolean toData(Object o, DataOutput out) throws IOException { long[] array = (long[]) o; out.writeByte(LONG_ARRAY); writeLongArray(array, out); return true; } }); classesToSerializers.put("[S", // short[] new WellKnownPdxDS() { @Override public boolean toData(Object o, DataOutput out) throws IOException { short[] array = (short[]) o; out.writeByte(SHORT_ARRAY); writeShortArray(array, out); return true; } }); classesToSerializers.put("[Ljava.lang.String;", // String[] new WellKnownPdxDS() { @Override public boolean toData(Object o, DataOutput out) throws IOException { String[] array = (String[]) o; out.writeByte(STRING_ARRAY); writeStringArray(array, out); return true; } }); classesToSerializers.put(TimeUnit.NANOSECONDS.getClass().getName(), new WellKnownDS() { @Override public boolean toData(Object o, DataOutput out) throws IOException { out.writeByte(TIME_UNIT); out.writeByte(TIME_UNIT_NANOSECONDS); return true; } }); classesToSerializers.put(TimeUnit.MICROSECONDS.getClass().getName(), new WellKnownDS() { @Override public boolean toData(Object o, DataOutput out) throws IOException { out.writeByte(TIME_UNIT); out.writeByte(TIME_UNIT_MICROSECONDS); return true; } }); classesToSerializers.put(TimeUnit.MILLISECONDS.getClass().getName(), new WellKnownDS() { @Override public boolean toData(Object o, DataOutput out) throws IOException { out.writeByte(TIME_UNIT); out.writeByte(TIME_UNIT_MILLISECONDS); return true; } }); classesToSerializers.put(TimeUnit.SECONDS.getClass().getName(), new WellKnownDS() { @Override public boolean toData(Object o, DataOutput out) throws IOException { out.writeByte(TIME_UNIT); out.writeByte(TIME_UNIT_SECONDS); return true; } }); classesToSerializers.put("java.util.Date", new WellKnownPdxDS() { @Override public boolean toData(Object o, DataOutput out) throws IOException { Date date = (Date) o; out.writeByte(DATE); writeDate(date, out); return true; } }); classesToSerializers.put("java.io.File", new WellKnownDS() { @Override public boolean toData(Object o, DataOutput out) throws IOException { File file = (File) o; out.writeByte(FILE); writeFile(file, out); return true; } }); classesToSerializers.put("java.util.ArrayList", new WellKnownPdxDS() { @Override public boolean toData(Object o, DataOutput out) throws IOException { ArrayList list = (ArrayList) o; out.writeByte(ARRAY_LIST); writeArrayList(list, out); return true; } }); classesToSerializers.put("java.util.LinkedList", new WellKnownDS() { @Override public boolean toData(Object o, DataOutput out) throws IOException { LinkedList list = (LinkedList) o; out.writeByte(LINKED_LIST); writeLinkedList(list, out); return true; } }); classesToSerializers.put("java.util.Vector", new WellKnownPdxDS() { @Override public boolean toData(Object o, DataOutput out) throws IOException { out.writeByte(VECTOR); writeVector((Vector) o, out); return true; } }); classesToSerializers.put("java.util.Stack", new WellKnownDS() { @Override public boolean toData(Object o, DataOutput out) throws IOException { out.writeByte(STACK); writeStack((Stack) o, out); return true; } }); classesToSerializers.put("java.util.HashSet", new WellKnownPdxDS() { @Override public boolean toData(Object o, DataOutput out) throws IOException { HashSet list = (HashSet) o; out.writeByte(HASH_SET); writeHashSet(list, out); return true; } }); classesToSerializers.put("java.util.LinkedHashSet", new WellKnownPdxDS() { @Override public boolean toData(Object o, DataOutput out) throws IOException { out.writeByte(LINKED_HASH_SET); writeLinkedHashSet((LinkedHashSet) o, out); return true; } }); classesToSerializers.put("java.util.HashMap", new WellKnownPdxDS() { @Override public boolean toData(Object o, DataOutput out) throws IOException { HashMap list = (HashMap) o; out.writeByte(HASH_MAP); writeHashMap(list, out); return true; } }); classesToSerializers.put("java.util.IdentityHashMap", new WellKnownDS() { @Override public boolean toData(Object o, DataOutput out) throws IOException { out.writeByte(IDENTITY_HASH_MAP); writeIdentityHashMap((IdentityHashMap) o, out); return true; } }); classesToSerializers.put("java.util.Hashtable", new WellKnownPdxDS() { @Override public boolean toData(Object o, DataOutput out) throws IOException { out.writeByte(HASH_TABLE); writeHashtable((Hashtable) o, out); return true; } }); classesToSerializers.put("java.util.Properties", new WellKnownDS() { @Override public boolean toData(Object o, DataOutput out) throws IOException { Properties props = (Properties) o; out.writeByte(PROPERTIES); writeProperties(props, out); return true; } }); classesToSerializers.put("java.util.TreeMap", new WellKnownDS() { @Override public boolean toData(Object o, DataOutput out) throws IOException { out.writeByte(TREE_MAP); writeTreeMap((TreeMap) o, out); return true; } }); classesToSerializers.put("java.util.TreeSet", new WellKnownDS() { @Override public boolean toData(Object o, DataOutput out) throws IOException { out.writeByte(TREE_SET); writeTreeSet((TreeSet) o, out); return true; } }); if (is662SerializationEnabled()) { classesToSerializers.put("java.math.BigInteger", new WellKnownDS() { @Override public boolean toData(Object o, DataOutput out) throws IOException { out.writeByte(BIG_INTEGER); writeBigInteger((BigInteger) o, out); return true; } }); classesToSerializers.put("java.math.BigDecimal", new WellKnownDS() { @Override public boolean toData(Object o, DataOutput out) throws IOException { out.writeByte(BIG_DECIMAL); writeBigDecimal((BigDecimal) o, out); return true; } }); classesToSerializers.put("java.util.UUID", new WellKnownDS() { @Override public boolean toData(Object o, DataOutput out) throws IOException { out.writeByte(UUID); writeUUID((UUID) o, out); return true; } }); classesToSerializers.put("java.sql.Timestamp", new WellKnownDS() { @Override public boolean toData(Object o, DataOutput out) throws IOException { out.writeByte(TIMESTAMP); writeTimestamp((Timestamp) o, out); return true; } }); } }