http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/geode-core/src/main/java/org/apache/geode/DataSerializer.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/DataSerializer.java b/geode-core/src/main/java/org/apache/geode/DataSerializer.java index 09b6ced..29b20a2 100644 --- a/geode-core/src/main/java/org/apache/geode/DataSerializer.java +++ b/geode-core/src/main/java/org/apache/geode/DataSerializer.java @@ -1,18 +1,16 @@ /* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license + * agreements. See the NOTICE file distributed with this work for additional information regarding + * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. You may obtain a + * copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. */ package org.apache.geode; @@ -69,63 +67,54 @@ import org.apache.geode.internal.offheap.StoredObject; import org.apache.geode.pdx.PdxInstance; /** - * Provides static helper methods for reading and writing - * non-primitive data when working with a {@link DataSerializable}. - * For instance, classes that implement <code>DataSerializable</code> - * can use the <code>DataSerializer</code> in their - * <code>toData</code> and <code>fromData</code> methods: + * Provides static helper methods for reading and writing non-primitive data when working with a + * {@link DataSerializable}. For instance, classes that implement <code>DataSerializable</code> can + * use the <code>DataSerializer</code> in their <code>toData</code> and <code>fromData</code> + * methods: * - * <!-- - * The source code for the Employee class resides in - * tests/com/examples/ds/Employee.java - * Please keep the below code snippet in sync with that file. - * --> + * <!-- The source code for the Employee class resides in tests/com/examples/ds/Employee.java Please + * keep the below code snippet in sync with that file. --> * * <PRE> -public class Employee implements DataSerializable { - private int id; - private String name; - private Date birthday; - private Company employer; - - public void toData(DataOutput out) throws IOException { - out.writeInt(this.id); - out.writeUTF(this.name); - DataSerializer.writeDate(this.birthday, out); - DataSerializer.writeObject(this.employer, out); - } - - public void fromData(DataInput in) - throws IOException, ClassNotFoundException { - - this.id = in.readInt(); - this.name = in.readUTF(); - this.birthday = DataSerializer.readDate(in); - this.employer = (Company) DataSerializer.readObject(in); - } -} - + * public class Employee implements DataSerializable { + * private int id; + * private String name; + * private Date birthday; + * private Company employer; + * + * public void toData(DataOutput out) throws IOException { + * out.writeInt(this.id); + * out.writeUTF(this.name); + * DataSerializer.writeDate(this.birthday, out); + * DataSerializer.writeObject(this.employer, out); + * } + * + * public void fromData(DataInput in) throws IOException, ClassNotFoundException { + * + * this.id = in.readInt(); + * this.name = in.readUTF(); + * this.birthday = DataSerializer.readDate(in); + * this.employer = (Company) DataSerializer.readObject(in); + * } + * } + * * </PRE> * * <P> * - * Instances of <code>DataSerializer</code> are used to data serialize - * objects (such as instances of standard Java classes or third-party - * classes for which the source code is not available) that do not - * implement the <code>DataSerializable</code> interface. + * Instances of <code>DataSerializer</code> are used to data serialize objects (such as instances of + * standard Java classes or third-party classes for which the source code is not available) that do + * not implement the <code>DataSerializable</code> interface. * * <P> * - * The following <code>DataSerializer</code> data serializes instances - * of <code>Company</code>. In order for the data serialization - * framework to consult this custom serializer, it must be {@linkplain - * #register(Class) registered} with the framework. + * The following <code>DataSerializer</code> data serializes instances of <code>Company</code>. In + * order for the data serialization framework to consult this custom serializer, it must be + * {@linkplain #register(Class) registered} with the framework. * - * <!-- - * The source code for the CompanySerializer class resides in - * tests/com/examples/ds/CompanySerializer.java - * Please keep the below code snippet in sync with that file. - * --> + * <!-- The source code for the CompanySerializer class resides in + * tests/com/examples/ds/CompanySerializer.java Please keep the below code snippet in sync with that + * file. --> * * <PRE> public class CompanySerializer extends DataSerializer { @@ -175,21 +164,21 @@ public class CompanySerializer extends DataSerializer { } * </PRE> * - * Just like {@link Instantiator}s, a <code>DataSerializer</code> may - * be sent to other members of the distributed system when it is - * {@linkplain #register(Class) registered}. The data serialization - * framework does not require that a <code>DataSerializer</code> be - * {@link Serializable}, but it does require that it provide a - * {@linkplain #DataSerializer() zero-argument constructor}. + * Just like {@link Instantiator}s, a <code>DataSerializer</code> may be sent to other members of + * the distributed system when it is {@linkplain #register(Class) registered}. The data + * serialization framework does not require that a <code>DataSerializer</code> be + * {@link Serializable}, but it does require that it provide a {@linkplain #DataSerializer() + * zero-argument constructor}. * * @see #writeObject(Object, DataOutput) * @see #readObject * - * @since GemFire 3.5 */ + * @since GemFire 3.5 + */ public abstract class DataSerializer { - + private static final Logger logger = LogService.getLogger(); - + /** The eventId of this <code>DataSerializer</code> */ private EventID eventId; @@ -197,29 +186,25 @@ public abstract class DataSerializer { private ClientProxyMembershipID context; protected static final boolean TRACE_SERIALIZABLE = - Boolean.getBoolean("DataSerializer.TRACE_SERIALIZABLE"); + Boolean.getBoolean("DataSerializer.TRACE_SERIALIZABLE"); /* Used to prevent standard Java serialization when sending data to a non-Java client */ - protected static final ThreadLocal<Boolean> DISALLOW_JAVA_SERIALIZATION = new ThreadLocal<Boolean>(); + protected static final ThreadLocal<Boolean> DISALLOW_JAVA_SERIALIZATION = + new ThreadLocal<Boolean>(); - ////////////////////// Instance Fields ///////////////////// + ////////////////////// Instance Fields ///////////////////// - ////////////////////// Static Methods ////////////////////// + ////////////////////// Static Methods ////////////////////// /** - * Writes an instance of <code>Class</code> to a - * <code>DataOutput</code>. - * This method will handle a - * <code>null</code> value and not throw a - * <code>NullPointerException</code>. + * Writes an instance of <code>Class</code> to a <code>DataOutput</code>. This method will handle + * a <code>null</code> value and not throw a <code>NullPointerException</code>. * - * @throws IOException - * A problem occurs while writing to <code>out</code> + * @throws IOException A problem occurs while writing to <code>out</code> * * @see #readClass */ - public static void writeClass(Class<?> c, DataOutput out) - throws IOException { + public static void writeClass(Class<?> c, DataOutput out) throws IOException { InternalDataSerializer.checkOut(out); @@ -229,8 +214,7 @@ public abstract class DataSerializer { if (c == null || c.isPrimitive()) { InternalDataSerializer.writePrimitiveClass(c, out); - } - else { + } else { // non-primitive classes have a second CLASS byte // if readObject/writeObject is called: // the first CLASS byte indicates it's a Class, the second @@ -243,16 +227,15 @@ public abstract class DataSerializer { } /** - * Writes class name to a <code>DataOutput</code>. This method will handle a - * <code>null</code> value and not throw a <code>NullPointerException</code>. + * Writes class name to a <code>DataOutput</code>. This method will handle a <code>null</code> + * value and not throw a <code>NullPointerException</code>. * - * @throws IOException - * A problem occurs while writing to <code>out</code> + * @throws IOException A problem occurs while writing to <code>out</code> * * @see #readNonPrimitiveClassName(DataInput) */ public static void writeNonPrimitiveClassName(String className, DataOutput out) - throws IOException { + throws IOException { InternalDataSerializer.checkOut(out); @@ -264,19 +247,14 @@ public abstract class DataSerializer { } /** - * Reads an instance of <code>Class</code> from a - * <code>DataInput</code>. The class will be loaded using the - * {@linkplain Thread#getContextClassLoader current content class - * loader}. - * The return value may be <code>null</code>. + * Reads an instance of <code>Class</code> from a <code>DataInput</code>. The class will be loaded + * using the {@linkplain Thread#getContextClassLoader current content class loader}. The return + * value may be <code>null</code>. * - * @throws IOException - * A problem occurs while reading from <code>in</code> - * @throws ClassNotFoundException - * The class cannot be loaded + * @throws IOException A problem occurs while reading from <code>in</code> + * @throws ClassNotFoundException The class cannot be loaded */ - public static Class<?> readClass(DataInput in) - throws IOException, ClassNotFoundException { + public static Class<?> readClass(DataInput in) throws IOException, ClassNotFoundException { InternalDataSerializer.checkIn(in); @@ -286,23 +264,22 @@ public abstract class DataSerializer { className = swizzleClassNameForRead(className, in); Class<?> c = InternalDataSerializer.getCachedClass(className); // fix for bug 41206 return c; - } - else { + } else { return InternalDataSerializer.decodePrimitiveClass(typeCode); } } - + /** - * For backward compatibility we must swizzle the package of - * some classes that had to be moved when GemFire was open- - * sourced. This preserves backward-compatibility. + * For backward compatibility we must swizzle the package of some classes that had to be moved + * when GemFire was open- sourced. This preserves backward-compatibility. * * @param name the fully qualified class name * @param in the source of the class name * @return the name of the class in this implementation */ private static String swizzleClassNameForRead(String name, DataInput in) { - // TCPServer classes are used before a cache exists and support for old clients has been initialized + // TCPServer classes are used before a cache exists and support for old clients has been + // initialized String oldPackage = "com.gemstone.org.jgroups.stack.tcpserver"; String newPackage = "org.apache.geode.distributed.internal.tcpserver"; if (name.startsWith(oldPackage)) { @@ -314,18 +291,18 @@ public abstract class DataSerializer { } return name; } - + /** - * For backward compatibility we must swizzle the package of - * some classes that had to be moved when GemFire was open- - * sourced. This preserves backward-compatibility. + * For backward compatibility we must swizzle the package of some classes that had to be moved + * when GemFire was open- sourced. This preserves backward-compatibility. * * @param name the fully qualified class name * @param out the consumer of the serialized object * @return the name of the class in this implementation */ private static String swizzleClassNameForWrite(String name, DataOutput out) { - // TCPServer classes are used before a cache exists and support for old clients has been initialized + // TCPServer classes are used before a cache exists and support for old clients has been + // initialized String oldPackage = "com.gemstone.org.jgroups.stack.tcpserver"; String newPackage = "org.apache.geode.distributed.internal.tcpserver"; if (name.startsWith(newPackage)) { @@ -337,19 +314,16 @@ public abstract class DataSerializer { } return name; } - + /** - * Reads name of an instance of <code>Class</code> from a - * <code>DataInput</code>. + * Reads name of an instance of <code>Class</code> from a <code>DataInput</code>. * * The return value may be <code>null</code>. * - * @throws IOException - * A problem occurs while reading from <code>in</code> + * @throws IOException A problem occurs while reading from <code>in</code> * @see #writeNonPrimitiveClassName(String, DataOutput) */ - public static String readNonPrimitiveClassName(DataInput in) - throws IOException { + public static String readNonPrimitiveClassName(DataInput in) throws IOException { InternalDataSerializer.checkIn(in); @@ -357,42 +331,38 @@ public abstract class DataSerializer { } /** - * Writes an instance of Region. A Region is serialized as just a reference - * to a full path only. It will be recreated on the other end by calling - * {@link CacheFactory#getAnyInstance} and then calling - * <code>getRegion</code> on it. - * This method will handle a - * <code>null</code> value and not throw a - * <code>NullPointerException</code>. + * Writes an instance of Region. A Region is serialized as just a reference to a full path only. + * It will be recreated on the other end by calling {@link CacheFactory#getAnyInstance} and then + * calling <code>getRegion</code> on it. This method will handle a <code>null</code> value and not + * throw a <code>NullPointerException</code>. */ - public static void writeRegion(Region<?,?> rgn, DataOutput out) - throws IOException { + public static void writeRegion(Region<?, ?> rgn, DataOutput out) throws IOException { writeString((rgn != null) ? rgn.getFullPath() : null, out); } /** - * Reads an instance of Region. A Region is serialized as a reference to a - * full path only. It is recreated on the other end by calling - * {@link CacheFactory#getAnyInstance} and then calling - * <code>getRegion</code> on it. - * The return value may be <code>null</code>. + * Reads an instance of Region. A Region is serialized as a reference to a full path only. It is + * recreated on the other end by calling {@link CacheFactory#getAnyInstance} and then calling + * <code>getRegion</code> on it. The return value may be <code>null</code>. * * @param in the input stream * @return the Region instance * @throws org.apache.geode.cache.CacheClosedException if a cache has not been created or the only - * created one is closed. - * @throws RegionNotFoundException if there is no region by this name - * in the Cache + * created one is closed. + * @throws RegionNotFoundException if there is no region by this name in the Cache */ - public static <K,V> Region<K,V> readRegion(DataInput in) - throws IOException, ClassNotFoundException { + public static <K, V> Region<K, V> readRegion(DataInput in) + throws IOException, ClassNotFoundException { String fullPath = readString(in); - Region<K,V> rgn = null; + Region<K, V> rgn = null; if (fullPath != null) { // use getExisting to fix bug 43151 - rgn = ((Cache)GemFireCacheImpl.getExisting("Needed cache to find region.")).getRegion(fullPath); + rgn = ((Cache) GemFireCacheImpl.getExisting("Needed cache to find region.")) + .getRegion(fullPath); if (rgn == null) { - throw new RegionNotFoundException(LocalizedStrings.DataSerializer_REGION_0_COULD_NOT_BE_FOUND_WHILE_READING_A_DATASERIALIZER_STREAM.toLocalizedString(fullPath)); + throw new RegionNotFoundException( + LocalizedStrings.DataSerializer_REGION_0_COULD_NOT_BE_FOUND_WHILE_READING_A_DATASERIALIZER_STREAM + .toLocalizedString(fullPath)); } } return rgn; @@ -400,24 +370,18 @@ public abstract class DataSerializer { /** - * Writes an instance of <code>Date</code> to a - * <code>DataOutput</code>. Note that even though <code>date</code> - * may be an instance of a subclass of <code>Date</code>, - * <code>readDate</code> will always return an instance of - * <code>Date</code>, <B>not</B> an instance of the subclass. To - * preserve the class type of <code>date</code>,\ - * {@link #writeObject(Object, DataOutput)} should be used for data serialization. - * This method will handle a - * <code>null</code> value and not throw a - * <code>NullPointerException</code>. + * Writes an instance of <code>Date</code> to a <code>DataOutput</code>. Note that even though + * <code>date</code> may be an instance of a subclass of <code>Date</code>, <code>readDate</code> + * will always return an instance of <code>Date</code>, <B>not</B> an instance of the subclass. To + * preserve the class type of <code>date</code>,\ {@link #writeObject(Object, DataOutput)} should + * be used for data serialization. This method will handle a <code>null</code> value and not throw + * a <code>NullPointerException</code>. * - * @throws IOException - * A problem occurs while writing to <code>out</code> + * @throws IOException A problem occurs while writing to <code>out</code> * * @see #readDate */ - public static void writeDate(Date date, DataOutput out) - throws IOException { + public static void writeDate(Date date, DataOutput out) throws IOException { InternalDataSerializer.checkOut(out); @@ -431,19 +395,18 @@ public abstract class DataSerializer { } else { v = date.getTime(); if (v == -1L) { - throw new IllegalArgumentException("Dates whose getTime returns -1 can not be DataSerialized."); + throw new IllegalArgumentException( + "Dates whose getTime returns -1 can not be DataSerialized."); } } out.writeLong(v); } /** - * Reads an instance of <code>Date</code> from a - * <code>DataInput</code>. - * The return value may be <code>null</code>. + * Reads an instance of <code>Date</code> from a <code>DataInput</code>. The return value may be + * <code>null</code>. * - * @throws IOException - * A problem occurs while reading from <code>in</code> + * @throws IOException A problem occurs while reading from <code>in</code> */ public static Date readDate(DataInput in) throws IOException { InternalDataSerializer.checkIn(in); @@ -462,25 +425,19 @@ public abstract class DataSerializer { } /** - * Writes an instance of <code>File</code> to a - * <code>DataOutput</code>. Note that even though <code>file</code> - * may be an instance of a subclass of <code>File</code>, - * <code>readFile</code> will always return an instance of - * <code>File</code>, <B>not</B> an instance of the subclass. To - * preserve the class type of <code>file</code>, - * {@link #writeObject(Object, DataOutput)} should be used for data serialization. - * This method will handle a - * <code>null</code> value and not throw a - * <code>NullPointerException</code>. + * Writes an instance of <code>File</code> to a <code>DataOutput</code>. Note that even though + * <code>file</code> may be an instance of a subclass of <code>File</code>, <code>readFile</code> + * will always return an instance of <code>File</code>, <B>not</B> an instance of the subclass. To + * preserve the class type of <code>file</code>, {@link #writeObject(Object, DataOutput)} should + * be used for data serialization. This method will handle a <code>null</code> value and not throw + * a <code>NullPointerException</code>. * - * @throws IOException - * A problem occurs while writing to <code>out</code> + * @throws IOException A problem occurs while writing to <code>out</code> * * @see #readFile * @see File#getCanonicalPath */ - public static void writeFile(File file, DataOutput out) - throws IOException { + public static void writeFile(File file, DataOutput out) throws IOException { InternalDataSerializer.checkOut(out); @@ -492,12 +449,10 @@ public abstract class DataSerializer { } /** - * Reads an instance of <code>File</code> from a - * <code>DataInput</code>. - * The return value may be <code>null</code>. + * Reads an instance of <code>File</code> from a <code>DataInput</code>. The return value may be + * <code>null</code>. * - * @throws IOException - * A problem occurs while reading from <code>in</code> + * @throws IOException A problem occurs while reading from <code>in</code> */ public static File readFile(DataInput in) throws IOException { InternalDataSerializer.checkIn(in); @@ -515,30 +470,22 @@ public abstract class DataSerializer { } /** - * Writes an instance of <code>InetAddress</code> to a - * <code>DataOutput</code>. The <code>InetAddress</code> is data - * serialized by writing its {@link InetAddress#getAddress byte} - * representation to the <code>DataOutput</code>. {@link - * #readInetAddress} converts the <code>byte</code> representation - * to an instance of <code>InetAddress</code> using {@link - * InetAddress#getAddress}. As a result, if <code>address</code> - * is an instance of a user-defined subclass of - * <code>InetAddress</code> (that is, not an instance of one of the - * subclasses from the <code>java.net</code> package), its class - * will not be preserved. In order to be able to read an instance - * of the user-defined class, {@link #writeObject(Object, DataOutput)} should be used. - * This method will handle a - * <code>null</code> value and not throw a - * <code>NullPointerException</code>. + * Writes an instance of <code>InetAddress</code> to a <code>DataOutput</code>. The + * <code>InetAddress</code> is data serialized by writing its {@link InetAddress#getAddress byte} + * representation to the <code>DataOutput</code>. {@link #readInetAddress} converts the + * <code>byte</code> representation to an instance of <code>InetAddress</code> using + * {@link InetAddress#getAddress}. As a result, if <code>address</code> is an instance of a + * user-defined subclass of <code>InetAddress</code> (that is, not an instance of one of the + * subclasses from the <code>java.net</code> package), its class will not be preserved. In order + * to be able to read an instance of the user-defined class, + * {@link #writeObject(Object, DataOutput)} should be used. This method will handle a + * <code>null</code> value and not throw a <code>NullPointerException</code>. * - * @throws IOException - * A problem occurs while writing to <code>out</code> + * @throws IOException A problem occurs while writing to <code>out</code> * * @see #readInetAddress */ - public static void writeInetAddress(InetAddress address, - DataOutput out) - throws IOException { + public static void writeInetAddress(InetAddress address, DataOutput out) throws IOException { InternalDataSerializer.checkOut(out); @@ -550,18 +497,15 @@ public abstract class DataSerializer { } /** - * Reads an instance of <code>InetAddress</code> from a - * <code>DataInput</code>. - * The return value may be <code>null</code>. + * Reads an instance of <code>InetAddress</code> from a <code>DataInput</code>. The return value + * may be <code>null</code>. * - * @throws IOException - * A problem occurs while reading from <code>in</code> - * or the address read from <code>in</code> is unknown + * @throws IOException A problem occurs while reading from <code>in</code> or the address read + * from <code>in</code> is unknown * * @see InetAddress#getAddress */ - public static InetAddress readInetAddress(DataInput in) - throws IOException { + public static InetAddress readInetAddress(DataInput in) throws IOException { InternalDataSerializer.checkIn(in); @@ -577,7 +521,8 @@ public abstract class DataSerializer { } return addr; } catch (UnknownHostException ex) { - IOException ex2 = new IOException(LocalizedStrings.DataSerializer_WHILE_READING_AN_INETADDRESS.toLocalizedString()); + IOException ex2 = new IOException( + LocalizedStrings.DataSerializer_WHILE_READING_AN_INETADDRESS.toLocalizedString()); ex2.initCause(ex); throw ex2; } @@ -585,20 +530,16 @@ public abstract class DataSerializer { } /** - * Writes an instance of <code>String</code> to a - * <code>DataOutput</code>. - * This method will handle a - * <code>null</code> value and not throw a - * <code>NullPointerException</code>. - * <p>As of 5.7 strings longer than 0xFFFF can be serialized. + * Writes an instance of <code>String</code> to a <code>DataOutput</code>. This method will handle + * a <code>null</code> value and not throw a <code>NullPointerException</code>. + * <p> + * As of 5.7 strings longer than 0xFFFF can be serialized. * - * @throws IOException - * A problem occurs while writing to <code>out</code> + * @throws IOException A problem occurs while writing to <code>out</code> * * @see #readString */ - public static void writeString(String value, DataOutput out) - throws IOException { + public static void writeString(String value, DataOutput out) throws IOException { InternalDataSerializer.checkOut(out); @@ -618,13 +559,13 @@ public abstract class DataSerializer { // the string's contents, iterates over the array to compute the // encoded length, creates a byte[] to hold the encoded bytes, // iterates over the char[] again to create the encode bytes, - // then writes the bytes. Since we usually deal with ISO-8859-1 + // then writes the bytes. Since we usually deal with ISO-8859-1 // strings, we can accelerate this by accessing chars directly - // with charAt and fill a single-byte buffer. If we run into + // with charAt and fill a single-byte buffer. If we run into // a multibyte char, we revert to using writeUTF() int len = value.length(); int utfLen = len; // added for bug 40932 - for (int i=0; i<len; i++) { + for (int i = 0; i < len; i++) { char c = value.charAt(i); if ((c <= 0x007F) && (c >= 0x0001)) { // nothing needed @@ -654,8 +595,7 @@ public abstract class DataSerializer { out.writeByte(DSCODE.STRING); out.writeUTF(value); } - } - else { + } else { if (len > 0xFFFF) { if (isDebugEnabled) { logger.trace(LogMarker.SERIALIZER, "Writing HUGE_STRING_BYTES of len={}", len); @@ -676,12 +616,10 @@ public abstract class DataSerializer { } /** - * Reads an instance of <code>String</code> from a - * <code>DataInput</code>. The return value may be + * Reads an instance of <code>String</code> from a <code>DataInput</code>. The return value may be * <code>null</code>. * - * @throws IOException - * A problem occurs while reading from <code>in</code> + * @throws IOException A problem occurs while reading from <code>in</code> * * @see #writeString */ @@ -690,17 +628,14 @@ public abstract class DataSerializer { } /** - * Writes an instance of <code>Boolean</code> to a - * <code>DataOutput</code>. + * Writes an instance of <code>Boolean</code> to a <code>DataOutput</code>. * - * @throws IOException - * A problem occurs while writing to <code>out</code> + * @throws IOException A problem occurs while writing to <code>out</code> * @throws NullPointerException if value is null. * * @see #readBoolean */ - public static void writeBoolean(Boolean value, DataOutput out) - throws IOException { + public static void writeBoolean(Boolean value, DataOutput out) throws IOException { InternalDataSerializer.checkOut(out); @@ -712,11 +647,9 @@ public abstract class DataSerializer { } /** - * Reads an instance of <code>Boolean</code> from a - * <code>DataInput</code>. + * Reads an instance of <code>Boolean</code> from a <code>DataInput</code>. * - * @throws IOException - * A problem occurs while reading from <code>in</code> + * @throws IOException A problem occurs while reading from <code>in</code> */ public static Boolean readBoolean(DataInput in) throws IOException { InternalDataSerializer.checkIn(in); @@ -729,17 +662,14 @@ public abstract class DataSerializer { } /** - * Writes an instance of <code>Character</code> to a - * <code>DataOutput</code>. + * Writes an instance of <code>Character</code> to a <code>DataOutput</code>. * - * @throws IOException - * A problem occurs while writing to <code>out</code> + * @throws IOException A problem occurs while writing to <code>out</code> * @throws NullPointerException if value is null. * * @see #readCharacter */ - public static void writeCharacter(Character value, DataOutput out) - throws IOException { + public static void writeCharacter(Character value, DataOutput out) throws IOException { InternalDataSerializer.checkOut(out); @@ -751,14 +681,11 @@ public abstract class DataSerializer { } /** - * Reads an instance of <code>Character</code> from a - * <code>DataInput</code>. + * Reads an instance of <code>Character</code> from a <code>DataInput</code>. * - * @throws IOException - * A problem occurs while reading from <code>in</code> + * @throws IOException A problem occurs while reading from <code>in</code> */ - public static Character readCharacter(DataInput in) - throws IOException { + public static Character readCharacter(DataInput in) throws IOException { InternalDataSerializer.checkIn(in); @@ -770,17 +697,14 @@ public abstract class DataSerializer { } /** - * Writes an instance of <code>Byte</code> to a - * <code>DataOutput</code>. + * Writes an instance of <code>Byte</code> to a <code>DataOutput</code>. * - * @throws IOException - * A problem occurs while writing to <code>out</code> + * @throws IOException A problem occurs while writing to <code>out</code> * @throws NullPointerException if value is null. * * @see #readByte */ - public static void writeByte(Byte value, DataOutput out) - throws IOException { + public static void writeByte(Byte value, DataOutput out) throws IOException { InternalDataSerializer.checkOut(out); @@ -792,11 +716,9 @@ public abstract class DataSerializer { } /** - * Reads an instance of <code>Byte</code> from a - * <code>DataInput</code>. + * Reads an instance of <code>Byte</code> from a <code>DataInput</code>. * - * @throws IOException - * A problem occurs while reading from <code>in</code> + * @throws IOException A problem occurs while reading from <code>in</code> */ public static Byte readByte(DataInput in) throws IOException { InternalDataSerializer.checkIn(in); @@ -809,17 +731,14 @@ public abstract class DataSerializer { } /** - * Writes an instance of <code>Short</code> to a - * <code>DataOutput</code>. + * Writes an instance of <code>Short</code> to a <code>DataOutput</code>. * - * @throws IOException - * A problem occurs while writing to <code>out</code> + * @throws IOException A problem occurs while writing to <code>out</code> * @throws NullPointerException if value is null. * * @see #readShort */ - public static void writeShort(Short value, DataOutput out) - throws IOException { + public static void writeShort(Short value, DataOutput out) throws IOException { InternalDataSerializer.checkOut(out); @@ -831,11 +750,9 @@ public abstract class DataSerializer { } /** - * Reads an instance of <code>Short</code> from a - * <code>DataInput</code>. + * Reads an instance of <code>Short</code> from a <code>DataInput</code>. * - * @throws IOException - * A problem occurs while reading from <code>in</code> + * @throws IOException A problem occurs while reading from <code>in</code> */ public static Short readShort(DataInput in) throws IOException { InternalDataSerializer.checkIn(in); @@ -848,17 +765,14 @@ public abstract class DataSerializer { } /** - * Writes an instance of <code>Integer</code> to a - * <code>DataOutput</code>. + * Writes an instance of <code>Integer</code> to a <code>DataOutput</code>. * - * @throws IOException - * A problem occurs while writing to <code>out</code> + * @throws IOException A problem occurs while writing to <code>out</code> * @throws NullPointerException if value is null. * * @see #readInteger */ - public static void writeInteger(Integer value, DataOutput out) - throws IOException { + public static void writeInteger(Integer value, DataOutput out) throws IOException { InternalDataSerializer.checkOut(out); @@ -870,11 +784,9 @@ public abstract class DataSerializer { } /** - * Reads an instance of <code>Integer</code> from a - * <code>DataInput</code>. + * Reads an instance of <code>Integer</code> from a <code>DataInput</code>. * - * @throws IOException - * A problem occurs while reading from <code>in</code> + * @throws IOException A problem occurs while reading from <code>in</code> */ public static Integer readInteger(DataInput in) throws IOException { InternalDataSerializer.checkIn(in); @@ -887,17 +799,14 @@ public abstract class DataSerializer { } /** - * Writes an instance of <code>Long</code> to a - * <code>DataOutput</code>. + * Writes an instance of <code>Long</code> to a <code>DataOutput</code>. * - * @throws IOException - * A problem occurs while writing to <code>out</code> + * @throws IOException A problem occurs while writing to <code>out</code> * @throws NullPointerException if value is null. * * @see #readLong */ - public static void writeLong(Long value, DataOutput out) - throws IOException { + public static void writeLong(Long value, DataOutput out) throws IOException { InternalDataSerializer.checkOut(out); @@ -909,11 +818,9 @@ public abstract class DataSerializer { } /** - * Reads an instance of <code>Long</code> from a - * <code>DataInput</code>. + * Reads an instance of <code>Long</code> from a <code>DataInput</code>. * - * @throws IOException - * A problem occurs while reading from <code>in</code> + * @throws IOException A problem occurs while reading from <code>in</code> */ public static Long readLong(DataInput in) throws IOException { InternalDataSerializer.checkIn(in); @@ -926,17 +833,14 @@ public abstract class DataSerializer { } /** - * Writes an instance of <code>Float</code> to a - * <code>DataOutput</code>. + * Writes an instance of <code>Float</code> to a <code>DataOutput</code>. * - * @throws IOException - * A problem occurs while writing to <code>out</code> + * @throws IOException A problem occurs while writing to <code>out</code> * @throws NullPointerException if value is null. * * @see #readFloat */ - public static void writeFloat(Float value, DataOutput out) - throws IOException { + public static void writeFloat(Float value, DataOutput out) throws IOException { InternalDataSerializer.checkOut(out); @@ -948,11 +852,9 @@ public abstract class DataSerializer { } /** - * Reads an instance of <code>Float</code> from a - * <code>DataInput</code>. + * Reads an instance of <code>Float</code> from a <code>DataInput</code>. * - * @throws IOException - * A problem occurs while reading from <code>in</code> + * @throws IOException A problem occurs while reading from <code>in</code> */ public static Float readFloat(DataInput in) throws IOException { InternalDataSerializer.checkIn(in); @@ -965,17 +867,14 @@ public abstract class DataSerializer { } /** - * Writes an instance of <code>Double</code> to a - * <code>DataOutput</code>. + * Writes an instance of <code>Double</code> to a <code>DataOutput</code>. * - * @throws IOException - * A problem occurs while writing to <code>out</code> + * @throws IOException A problem occurs while writing to <code>out</code> * @throws NullPointerException if value is null. * * @see #readDouble */ - public static void writeDouble(Double value, DataOutput out) - throws IOException { + public static void writeDouble(Double value, DataOutput out) throws IOException { InternalDataSerializer.checkOut(out); @@ -987,11 +886,9 @@ public abstract class DataSerializer { } /** - * Reads an instance of <code>Double</code> from a - * <code>DataInput</code>. + * Reads an instance of <code>Double</code> from a <code>DataInput</code>. * - * @throws IOException - * A problem occurs while reading from <code>in</code> + * @throws IOException A problem occurs while reading from <code>in</code> */ public static Double readDouble(DataInput in) throws IOException { InternalDataSerializer.checkIn(in); @@ -1004,17 +901,14 @@ public abstract class DataSerializer { } /** - * Writes a primitive <code>boolean</code> to a - * <code>DataOutput</code>. + * Writes a primitive <code>boolean</code> to a <code>DataOutput</code>. * - * @throws IOException - * A problem occurs while writing to <code>out</code> + * @throws IOException A problem occurs while writing to <code>out</code> * * @see DataOutput#writeBoolean * @since GemFire 5.1 */ - public static void writePrimitiveBoolean(boolean value, DataOutput out) - throws IOException { + public static void writePrimitiveBoolean(boolean value, DataOutput out) throws IOException { InternalDataSerializer.checkOut(out); @@ -1026,11 +920,9 @@ public abstract class DataSerializer { } /** - * Reads a primitive <code>boolean</code> from a - * <code>DataInput</code>. + * Reads a primitive <code>boolean</code> from a <code>DataInput</code>. * - * @throws IOException - * A problem occurs while reading from <code>in</code> + * @throws IOException A problem occurs while reading from <code>in</code> * @see DataInput#readBoolean * @since GemFire 5.1 */ @@ -1045,17 +937,14 @@ public abstract class DataSerializer { } /** - * Writes a primitive <code>byte</code> to a - * <code>DataOutput</code>. + * Writes a primitive <code>byte</code> to a <code>DataOutput</code>. * - * @throws IOException - * A problem occurs while writing to <code>out</code> + * @throws IOException A problem occurs while writing to <code>out</code> * * @see DataOutput#writeByte * @since GemFire 5.1 */ - public static void writePrimitiveByte(byte value, DataOutput out) - throws IOException { + public static void writePrimitiveByte(byte value, DataOutput out) throws IOException { InternalDataSerializer.checkOut(out); @@ -1067,11 +956,9 @@ public abstract class DataSerializer { } /** - * Reads a primitive <code>byte</code> from a - * <code>DataInput</code>. + * Reads a primitive <code>byte</code> from a <code>DataInput</code>. * - * @throws IOException - * A problem occurs while reading from <code>in</code> + * @throws IOException A problem occurs while reading from <code>in</code> * @see DataInput#readByte * @since GemFire 5.1 */ @@ -1086,17 +973,14 @@ public abstract class DataSerializer { } /** - * Writes a primitive <code>char</code> to a - * <code>DataOutput</code>. + * Writes a primitive <code>char</code> to a <code>DataOutput</code>. * - * @throws IOException - * A problem occurs while writing to <code>out</code> + * @throws IOException A problem occurs while writing to <code>out</code> * * @see DataOutput#writeChar * @since GemFire 5.1 */ - public static void writePrimitiveChar(char value, DataOutput out) - throws IOException { + public static void writePrimitiveChar(char value, DataOutput out) throws IOException { InternalDataSerializer.checkOut(out); @@ -1108,11 +992,9 @@ public abstract class DataSerializer { } /** - * Reads a primitive <code>char</code> from a - * <code>DataInput</code>. + * Reads a primitive <code>char</code> from a <code>DataInput</code>. * - * @throws IOException - * A problem occurs while reading from <code>in</code> + * @throws IOException A problem occurs while reading from <code>in</code> * @see DataInput#readChar * @since GemFire 5.1 */ @@ -1127,17 +1009,14 @@ public abstract class DataSerializer { } /** - * Writes a primitive <code>short</code> to a - * <code>DataOutput</code>. + * Writes a primitive <code>short</code> to a <code>DataOutput</code>. * - * @throws IOException - * A problem occurs while writing to <code>out</code> + * @throws IOException A problem occurs while writing to <code>out</code> * * @see DataOutput#writeShort * @since GemFire 5.1 */ - public static void writePrimitiveShort(short value, DataOutput out) - throws IOException { + public static void writePrimitiveShort(short value, DataOutput out) throws IOException { InternalDataSerializer.checkOut(out); @@ -1149,11 +1028,9 @@ public abstract class DataSerializer { } /** - * Reads a primitive <code>short</code> from a - * <code>DataInput</code>. + * Reads a primitive <code>short</code> from a <code>DataInput</code>. * - * @throws IOException - * A problem occurs while reading from <code>in</code> + * @throws IOException A problem occurs while reading from <code>in</code> * @see DataInput#readShort * @since GemFire 5.1 */ @@ -1168,18 +1045,15 @@ public abstract class DataSerializer { } /** - * Writes a primitive <code>int</code> as an unsigned byte to a - * <code>DataOutput</code>. + * Writes a primitive <code>int</code> as an unsigned byte to a <code>DataOutput</code>. * - * @throws IOException - * A problem occurs while writing to <code>out</code> + * @throws IOException A problem occurs while writing to <code>out</code> * * @see DataOutput#writeByte * @see DataInput#readUnsignedByte * @since GemFire 5.1 */ - public static void writeUnsignedByte(int value, DataOutput out) - throws IOException { + public static void writeUnsignedByte(int value, DataOutput out) throws IOException { InternalDataSerializer.checkOut(out); @@ -1191,11 +1065,10 @@ public abstract class DataSerializer { } /** - * Reads a primitive <code>int</code> as an unsigned byte from a - * <code>DataInput</code> using {@link DataInput#readUnsignedByte}. + * Reads a primitive <code>int</code> as an unsigned byte from a <code>DataInput</code> using + * {@link DataInput#readUnsignedByte}. * - * @throws IOException - * A problem occurs while reading from <code>in</code> + * @throws IOException A problem occurs while reading from <code>in</code> * @since GemFire 5.1 */ public static int readUnsignedByte(DataInput in) throws IOException { @@ -1209,18 +1082,15 @@ public abstract class DataSerializer { } /** - * Writes a primitive <code>int</code> as an unsigned short to a - * <code>DataOutput</code>. + * Writes a primitive <code>int</code> as an unsigned short to a <code>DataOutput</code>. * - * @throws IOException - * A problem occurs while writing to <code>out</code> + * @throws IOException A problem occurs while writing to <code>out</code> * * @see DataOutput#writeShort * @see DataInput#readUnsignedShort * @since GemFire 5.1 */ - public static void writeUnsignedShort(int value, DataOutput out) - throws IOException { + public static void writeUnsignedShort(int value, DataOutput out) throws IOException { InternalDataSerializer.checkOut(out); @@ -1232,11 +1102,10 @@ public abstract class DataSerializer { } /** - * Reads a primitive <code>int</code> as an unsigned short from a - * <code>DataInput</code> using {@link DataInput#readUnsignedShort}. + * Reads a primitive <code>int</code> as an unsigned short from a <code>DataInput</code> using + * {@link DataInput#readUnsignedShort}. * - * @throws IOException - * A problem occurs while reading from <code>in</code> + * @throws IOException A problem occurs while reading from <code>in</code> * @since GemFire 5.1 */ public static int readUnsignedShort(DataInput in) throws IOException { @@ -1250,16 +1119,13 @@ public abstract class DataSerializer { } /** - * Writes a primitive <code>int</code> to a - * <code>DataOutput</code>. + * Writes a primitive <code>int</code> to a <code>DataOutput</code>. * - * @throws IOException - * A problem occurs while writing to <code>out</code> + * @throws IOException A problem occurs while writing to <code>out</code> * * @see DataOutput#writeInt */ - public static void writePrimitiveInt(int value, DataOutput out) - throws IOException { + public static void writePrimitiveInt(int value, DataOutput out) throws IOException { InternalDataSerializer.checkOut(out); @@ -1271,11 +1137,9 @@ public abstract class DataSerializer { } /** - * Reads a primitive <code>int</code> from a - * <code>DataInput</code>. + * Reads a primitive <code>int</code> from a <code>DataInput</code>. * - * @throws IOException - * A problem occurs while reading from <code>in</code> + * @throws IOException A problem occurs while reading from <code>in</code> * @see DataInput#readInt * @since GemFire 5.1 */ @@ -1290,17 +1154,14 @@ public abstract class DataSerializer { } /** - * Writes a primitive <code>long</code> to a - * <code>DataOutput</code>. + * Writes a primitive <code>long</code> to a <code>DataOutput</code>. * - * @throws IOException - * A problem occurs while writing to <code>out</code> + * @throws IOException A problem occurs while writing to <code>out</code> * * @see DataOutput#writeLong * @since GemFire 5.1 */ - public static void writePrimitiveLong(long value, DataOutput out) - throws IOException { + public static void writePrimitiveLong(long value, DataOutput out) throws IOException { InternalDataSerializer.checkOut(out); @@ -1312,11 +1173,9 @@ public abstract class DataSerializer { } /** - * Reads a primitive <code>long</code> from a - * <code>DataInput</code>. + * Reads a primitive <code>long</code> from a <code>DataInput</code>. * - * @throws IOException - * A problem occurs while reading from <code>in</code> + * @throws IOException A problem occurs while reading from <code>in</code> * @see DataInput#readLong * @since GemFire 5.1 */ @@ -1331,17 +1190,14 @@ public abstract class DataSerializer { } /** - * Writes a primitive <code>float</code> to a - * <code>DataOutput</code>. + * Writes a primitive <code>float</code> to a <code>DataOutput</code>. * - * @throws IOException - * A problem occurs while writing to <code>out</code> + * @throws IOException A problem occurs while writing to <code>out</code> * * @see DataOutput#writeFloat * @since GemFire 5.1 */ - public static void writePrimitiveFloat(float value, DataOutput out) - throws IOException { + public static void writePrimitiveFloat(float value, DataOutput out) throws IOException { InternalDataSerializer.checkOut(out); @@ -1353,11 +1209,9 @@ public abstract class DataSerializer { } /** - * Reads a primitive <code>float</code> from a - * <code>DataInput</code>. + * Reads a primitive <code>float</code> from a <code>DataInput</code>. * - * @throws IOException - * A problem occurs while reading from <code>in</code> + * @throws IOException A problem occurs while reading from <code>in</code> * @see DataInput#readFloat * @since GemFire 5.1 */ @@ -1372,17 +1226,14 @@ public abstract class DataSerializer { } /** - * Writes a primtive <code>double</code> to a - * <code>DataOutput</code>. + * Writes a primtive <code>double</code> to a <code>DataOutput</code>. * - * @throws IOException - * A problem occurs while writing to <code>out</code> + * @throws IOException A problem occurs while writing to <code>out</code> * * @see DataOutput#writeDouble * @since GemFire 5.1 */ - public static void writePrimitiveDouble(double value, DataOutput out) - throws IOException { + public static void writePrimitiveDouble(double value, DataOutput out) throws IOException { InternalDataSerializer.checkOut(out); @@ -1394,11 +1245,9 @@ public abstract class DataSerializer { } /** - * Reads a primitive <code>double</code> from a - * <code>DataInput</code>. + * Reads a primitive <code>double</code> from a <code>DataInput</code>. * - * @throws IOException - * A problem occurs while reading from <code>in</code> + * @throws IOException A problem occurs while reading from <code>in</code> * @see DataInput#readDouble * @since GemFire 5.1 */ @@ -1413,19 +1262,14 @@ public abstract class DataSerializer { } /** - * Writes an array of <code>byte</code>s to a - * <code>DataOutput</code>. - * This method will serialize a - * <code>null</code> array and not throw a - * <code>NullPointerException</code>. + * Writes an array of <code>byte</code>s to a <code>DataOutput</code>. This method will serialize + * a <code>null</code> array and not throw a <code>NullPointerException</code>. * - * @throws IOException - * A problem occurs while writing to <code>out</code> + * @throws IOException A problem occurs while writing to <code>out</code> * * @see #readByteArray */ - public static void writeByteArray(byte[] array, DataOutput out) - throws IOException { + public static void writeByteArray(byte[] array, DataOutput out) throws IOException { int len = 0; if (array != null) { len = array.length; @@ -1434,27 +1278,22 @@ public abstract class DataSerializer { } /** - * Writes the first <code>len</code> elements - * of an array of <code>byte</code>s to a - * <code>DataOutput</code>. - * This method will serialize a - * <code>null</code> array and not throw a + * Writes the first <code>len</code> elements of an array of <code>byte</code>s to a + * <code>DataOutput</code>. This method will serialize a <code>null</code> array and not throw a * <code>NullPointerException</code>. * - * @param len the actual number of entries to write. If len is greater - * than then length of the array then the entire array is written. - * @throws IOException - * A problem occurs while writing to <code>out</code> + * @param len the actual number of entries to write. If len is greater than then length of the + * array then the entire array is written. + * @throws IOException A problem occurs while writing to <code>out</code> * * @see #readByteArray */ - public static void writeByteArray(byte[] array, int len, DataOutput out) - throws IOException { + public static void writeByteArray(byte[] array, int len, DataOutput out) throws IOException { InternalDataSerializer.checkOut(out); int length = len; // to avoid warnings about parameter assignment - + if (array == null) { length = -1; } else { @@ -1470,31 +1309,27 @@ public abstract class DataSerializer { out.write(array, 0, length); } } + /** - * Serialize the given object <code>obj</code> into a byte array - * using {@link #writeObject(Object, DataOutput)} and then writes the byte array - * to the given data output <code>out</code> in the same format - * {@link #writeByteArray(byte[], DataOutput)} does. - * This method will serialize a - * <code>null</code> obj and not throw a + * Serialize the given object <code>obj</code> into a byte array using + * {@link #writeObject(Object, DataOutput)} and then writes the byte array to the given data + * output <code>out</code> in the same format {@link #writeByteArray(byte[], DataOutput)} does. + * This method will serialize a <code>null</code> obj and not throw a * <code>NullPointerException</code>. * * @param obj the object to serialize and write * @param out the data output to write the byte array to - * @throws IllegalArgumentException - * if a problem occurs while serialize <code>obj</code> - * @throws IOException - * if a problem occurs while writing to <code>out</code> + * @throws IllegalArgumentException if a problem occurs while serialize <code>obj</code> + * @throws IOException if a problem occurs while writing to <code>out</code> * * @see #readByteArray * @since GemFire 5.0.2 */ - public static void writeObjectAsByteArray(Object obj, DataOutput out) - throws IOException { + public static void writeObjectAsByteArray(Object obj, DataOutput out) throws IOException { Object object = obj; if (obj instanceof CachedDeserializable) { if (obj instanceof StoredObject) { - StoredObject so = (StoredObject)obj; + StoredObject so = (StoredObject) obj; if (logger.isTraceEnabled(LogMarker.SERIALIZER)) { logger.trace(LogMarker.SERIALIZER, "writeObjectAsByteArray StoredObject"); } @@ -1508,20 +1343,21 @@ public abstract class DataSerializer { if (object == null) { logger.trace(LogMarker.SERIALIZER, "writeObjectAsByteArray null"); } else { - logger.trace(LogMarker.SERIALIZER, "writeObjectAsByteArray obj.getClass={}", object.getClass()); + logger.trace(LogMarker.SERIALIZER, "writeObjectAsByteArray obj.getClass={}", + object.getClass()); } } if (object instanceof byte[] || object == null) { - writeByteArray((byte[])object, out); + writeByteArray((byte[]) object, out); } else if (out instanceof ObjToByteArraySerializer) { - ((ObjToByteArraySerializer)out).writeAsSerializedByteArray(object); - }/*else if (obj instanceof Sendable) { - ((Sendable)obj).sendTo(out); - } */ + ((ObjToByteArraySerializer) out).writeAsSerializedByteArray(object); + } /* + * else if (obj instanceof Sendable) { ((Sendable)obj).sendTo(out); } + */ else { HeapDataOutputStream hdos; if (object instanceof HeapDataOutputStream) { - hdos = (HeapDataOutputStream)object; + hdos = (HeapDataOutputStream) object; } else { Version v = InternalDataSerializer.getVersionForDataStreamOrNull(out); if (v == null) { @@ -1531,7 +1367,8 @@ public abstract class DataSerializer { try { DataSerializer.writeObject(object, hdos); } catch (IOException e) { - RuntimeException e2 = new IllegalArgumentException(LocalizedStrings.DataSerializer_PROBELM_WHILE_SERIALIZING.toLocalizedString()); + RuntimeException e2 = new IllegalArgumentException( + LocalizedStrings.DataSerializer_PROBELM_WHILE_SERIALIZING.toLocalizedString()); e2.initCause(e); throw e2; } @@ -1542,49 +1379,41 @@ public abstract class DataSerializer { } /** - * Reads an array of <code>byte</code>s from a - * <code>DataInput</code>. + * Reads an array of <code>byte</code>s from a <code>DataInput</code>. * - * @throws IOException - * A problem occurs while reading from <code>in</code> + * @throws IOException A problem occurs while reading from <code>in</code> * * @see #writeByteArray(byte[], DataOutput) */ - public static byte[] readByteArray(DataInput in) - throws IOException { - - InternalDataSerializer.checkIn(in); + public static byte[] readByteArray(DataInput in) throws IOException { - int length = InternalDataSerializer.readArrayLength(in); - if (length == -1) { - return null; - } else { - byte[] array = new byte[length]; - in.readFully(array, 0, length); + InternalDataSerializer.checkIn(in); - if (logger.isTraceEnabled(LogMarker.SERIALIZER)) { - logger.trace(LogMarker.SERIALIZER, "Read byte array of length {}", length); - } + int length = InternalDataSerializer.readArrayLength(in); + if (length == -1) { + return null; + } else { + byte[] array = new byte[length]; + in.readFully(array, 0, length); - return array; + if (logger.isTraceEnabled(LogMarker.SERIALIZER)) { + logger.trace(LogMarker.SERIALIZER, "Read byte array of length {}", length); } + + return array; } + } /** - * Writes an array of <code>String</code>s to a - * <code>DataOutput</code>. - * This method will serialize a - * <code>null</code> array and not throw a - * <code>NullPointerException</code>. + * Writes an array of <code>String</code>s to a <code>DataOutput</code>. This method will + * serialize a <code>null</code> array and not throw a <code>NullPointerException</code>. * - * @throws IOException - * A problem occurs while writing to <code>out</code> + * @throws IOException A problem occurs while writing to <code>out</code> * * @see #readStringArray * @see #writeString */ - public static void writeStringArray(String[] array, DataOutput out) - throws IOException { + public static void writeStringArray(String[] array, DataOutput out) throws IOException { InternalDataSerializer.checkOut(out); @@ -1606,50 +1435,42 @@ public abstract class DataSerializer { } /** - * Reads an array of <code>String</code>s from a - * <code>DataInput</code>. + * Reads an array of <code>String</code>s from a <code>DataInput</code>. * - * @throws IOException - * A problem occurs while reading from <code>in</code> + * @throws IOException A problem occurs while reading from <code>in</code> * * @see #writeStringArray */ - public static String[] readStringArray(DataInput in) - throws IOException { - - InternalDataSerializer.checkIn(in); + public static String[] readStringArray(DataInput in) throws IOException { - int length = InternalDataSerializer.readArrayLength(in); - if (length == -1) { - return null; - } else { - String[] array = new String[length]; - for (int i = 0; i < length; i++) { - array[i] = readString(in); - } + InternalDataSerializer.checkIn(in); - if (logger.isTraceEnabled(LogMarker.SERIALIZER)) { - logger.trace(LogMarker.SERIALIZER, "Read String array of length {}", length); - } + int length = InternalDataSerializer.readArrayLength(in); + if (length == -1) { + return null; + } else { + String[] array = new String[length]; + for (int i = 0; i < length; i++) { + array[i] = readString(in); + } - return array; + if (logger.isTraceEnabled(LogMarker.SERIALIZER)) { + logger.trace(LogMarker.SERIALIZER, "Read String array of length {}", length); } + + return array; } + } /** - * Writes an array of <code>short</code>s to a - * <code>DataOutput</code>. - * This method will serialize a - * <code>null</code> array and not throw a - * <code>NullPointerException</code>. + * Writes an array of <code>short</code>s to a <code>DataOutput</code>. This method will serialize + * a <code>null</code> array and not throw a <code>NullPointerException</code>. * - * @throws IOException - * A problem occurs while writing to <code>out</code> + * @throws IOException A problem occurs while writing to <code>out</code> * * @see #readShortArray */ - public static void writeShortArray(short[] array, DataOutput out) - throws IOException { + public static void writeShortArray(short[] array, DataOutput out) throws IOException { InternalDataSerializer.checkOut(out); @@ -1671,65 +1492,55 @@ public abstract class DataSerializer { } /** - * Reads an array of <code>short</code>s from a - * <code>DataInput</code>. + * Reads an array of <code>short</code>s from a <code>DataInput</code>. * - * @throws IOException - * A problem occurs while reading from <code>in</code> + * @throws IOException A problem occurs while reading from <code>in</code> * * @see #writeShortArray */ - public static short[] readShortArray(DataInput in) - throws IOException { - - InternalDataSerializer.checkIn(in); + public static short[] readShortArray(DataInput in) throws IOException { - int length = InternalDataSerializer.readArrayLength(in); - if (length == -1) { - return null; - } else { - short[] array = new short[length]; - for (int i = 0; i < length; i++) { - array[i] = in.readShort(); - } + InternalDataSerializer.checkIn(in); - if (logger.isTraceEnabled(LogMarker.SERIALIZER)) { - logger.trace(LogMarker.SERIALIZER, "Read short array of length {}", length); - } + int length = InternalDataSerializer.readArrayLength(in); + if (length == -1) { + return null; + } else { + short[] array = new short[length]; + for (int i = 0; i < length; i++) { + array[i] = in.readShort(); + } - return array; + if (logger.isTraceEnabled(LogMarker.SERIALIZER)) { + logger.trace(LogMarker.SERIALIZER, "Read short array of length {}", length); } + + return array; } + } /** - * Writes an array of <code>char</code>s to a - * <code>DataOutput</code>. + * Writes an array of <code>char</code>s to a <code>DataOutput</code>. * - * @throws IOException - * A problem occurs while writing to <code>out</code> + * @throws IOException A problem occurs while writing to <code>out</code> * * @see #readCharArray * @since GemFire 5.7 */ - public static void writeCharArray(char[] array, DataOutput out) - throws IOException { + public static void writeCharArray(char[] array, DataOutput out) throws IOException { - InternalDataSerializer.writeCharArray(array, array != null ? array.length - : -1, out); + InternalDataSerializer.writeCharArray(array, array != null ? array.length : -1, out); } /** - * Reads an array of <code>char</code>s from a - * <code>DataInput</code>. + * Reads an array of <code>char</code>s from a <code>DataInput</code>. * - * @throws IOException - * A problem occurs while reading from <code>in</code> + * @throws IOException A problem occurs while reading from <code>in</code> * * @see #writeCharArray * @since GemFire 5.7 */ - public static char[] readCharArray(DataInput in) - throws IOException { + public static char[] readCharArray(DataInput in) throws IOException { InternalDataSerializer.checkIn(in); @@ -1749,18 +1560,16 @@ public abstract class DataSerializer { return array; } } + /** - * Writes an array of <code>boolean</code>s to a - * <code>DataOutput</code>. + * Writes an array of <code>boolean</code>s to a <code>DataOutput</code>. * - * @throws IOException - * A problem occurs while writing to <code>out</code> + * @throws IOException A problem occurs while writing to <code>out</code> * * @see #readBooleanArray * @since GemFire 5.7 */ - public static void writeBooleanArray(boolean[] array, DataOutput out) - throws IOException { + public static void writeBooleanArray(boolean[] array, DataOutput out) throws IOException { InternalDataSerializer.checkOut(out); @@ -1782,17 +1591,14 @@ public abstract class DataSerializer { } /** - * Reads an array of <code>boolean</code>s from a - * <code>DataInput</code>. + * Reads an array of <code>boolean</code>s from a <code>DataInput</code>. * - * @throws IOException - * A problem occurs while reading from <code>in</code> + * @throws IOException A problem occurs while reading from <code>in</code> * * @see #writeBooleanArray * @since GemFire 5.7 */ - public static boolean[] readBooleanArray(DataInput in) - throws IOException { + public static boolean[] readBooleanArray(DataInput in) throws IOException { InternalDataSerializer.checkIn(in); @@ -1812,19 +1618,16 @@ public abstract class DataSerializer { return array; } } + /** - * Writes an <code>int</code> array to a <code>DataOutput</code>. - * This method will serialize a - * <code>null</code> array and not throw a - * <code>NullPointerException</code>. + * Writes an <code>int</code> array to a <code>DataOutput</code>. This method will serialize a + * <code>null</code> array and not throw a <code>NullPointerException</code>. * - * @throws IOException - * A problem occurs while writing to <code>out</code> + * @throws IOException A problem occurs while writing to <code>out</code> * * @see #readIntArray */ - public static void writeIntArray(int[] array, DataOutput out) - throws IOException { + public static void writeIntArray(int[] array, DataOutput out) throws IOException { InternalDataSerializer.checkOut(out); @@ -1849,47 +1652,40 @@ public abstract class DataSerializer { /** * Reads an <code>int</code> array from a <code>DataInput</code>. * - * @throws IOException - * A problem occurs while reading from <code>in</code> + * @throws IOException A problem occurs while reading from <code>in</code> * * @see #writeIntArray */ - public static int[] readIntArray(DataInput in) - throws IOException { - - InternalDataSerializer.checkIn(in); + public static int[] readIntArray(DataInput in) throws IOException { - int length = InternalDataSerializer.readArrayLength(in); - if (length == -1) { - return null; - } else { - int[] array = new int[length]; - for (int i = 0; i < length; i++) { - array[i] = in.readInt(); - } + InternalDataSerializer.checkIn(in); - if (logger.isTraceEnabled(LogMarker.SERIALIZER)) { - logger.trace(LogMarker.SERIALIZER, "Read int array of length {}", length); - } + int length = InternalDataSerializer.readArrayLength(in); + if (length == -1) { + return null; + } else { + int[] array = new int[length]; + for (int i = 0; i < length; i++) { + array[i] = in.readInt(); + } - return array; + if (logger.isTraceEnabled(LogMarker.SERIALIZER)) { + logger.trace(LogMarker.SERIALIZER, "Read int array of length {}", length); } + + return array; } + } /** - * Writes an array of <code>long</code>s to a - * <code>DataOutput</code>. - * This method will serialize a - * <code>null</code> array and not throw a - * <code>NullPointerException</code>. + * Writes an array of <code>long</code>s to a <code>DataOutput</code>. This method will serialize + * a <code>null</code> array and not throw a <code>NullPointerException</code>. * - * @throws IOException - * A problem occurs while writing to <code>out</code> + * @throws IOException A problem occurs while writing to <code>out</code> * * @see #readLongArray */ - public static void writeLongArray(long[] array, DataOutput out) - throws IOException { + public static void writeLongArray(long[] array, DataOutput out) throws IOException { InternalDataSerializer.checkOut(out); @@ -1911,50 +1707,42 @@ public abstract class DataSerializer { } /** - * Reads an array of <code>long</code>s from a - * <code>DataInput</code>. + * Reads an array of <code>long</code>s from a <code>DataInput</code>. * - * @throws IOException - * A problem occurs while reading from <code>in</code> + * @throws IOException A problem occurs while reading from <code>in</code> * * @see #writeLongArray */ - public static long[] readLongArray(DataInput in) - throws IOException { - - InternalDataSerializer.checkIn(in); + public static long[] readLongArray(DataInput in) throws IOException { - int length = InternalDataSerializer.readArrayLength(in); - if (length == -1) { - return null; - } else { - long[] array = new long[length]; - for (int i = 0; i < length; i++) { - array[i] = in.readLong(); - } + InternalDataSerializer.checkIn(in); - if (logger.isTraceEnabled(LogMarker.SERIALIZER)) { - logger.trace(LogMarker.SERIALIZER, "Read long array of length {}", length); - } + int length = InternalDataSerializer.readArrayLength(in); + if (length == -1) { + return null; + } else { + long[] array = new long[length]; + for (int i = 0; i < length; i++) { + array[i] = in.readLong(); + } - return array; + if (logger.isTraceEnabled(LogMarker.SERIALIZER)) { + logger.trace(LogMarker.SERIALIZER, "Read long array of length {}", length); } + + return array; } + } /** - * Writes an array of <code>float</code>s to a - * <code>DataOutput</code>. - * This method will serialize a - * <code>null</code> array and not throw a - * <code>NullPointerException</code>. + * Writes an array of <code>float</code>s to a <code>DataOutput</code>. This method will serialize + * a <code>null</code> array and not throw a <code>NullPointerException</code>. * - * @throws IOException - * A problem occurs while writing to <code>out</code> + * @throws IOException A problem occurs while writing to <code>out</code> * * @see #readFloatArray */ - public static void writeFloatArray(float[] array, DataOutput out) - throws IOException { + public static void writeFloatArray(float[] array, DataOutput out) throws IOException { InternalDataSerializer.checkOut(out); @@ -1976,50 +1764,42 @@ public abstract class DataSerializer { } /** - * Reads an array of <code>float</code>s from a - * <code>DataInput</code>. + * Reads an array of <code>float</code>s from a <code>DataInput</code>. * - * @throws IOException - * A problem occurs while reading from <code>in</code> + * @throws IOException A problem occurs while reading from <code>in</code> * * @see #writeFloatArray */ - public static float[] readFloatArray(DataInput in) - throws IOException { + public static float[] readFloatArray(DataInput in) throws IOException { - InternalDataSerializer.checkIn(in); - - int length = InternalDataSerializer.readArrayLength(in); - if (length == -1) { - return null; - } else { - float[] array = new float[length]; - for (int i = 0; i < length; i++) { - array[i] = in.readFloat(); - } + InternalDataSerializer.checkIn(in); - if (logger.isTraceEnabled(LogMarker.SERIALIZER)) { - logger.trace(LogMarker.SERIALIZER, "Read float array of length {}", length); - } + int length = InternalDataSerializer.readArrayLength(in); + if (length == -1) { + return null; + } else { + float[] array = new float[length]; + for (int i = 0; i < length; i++) { + array[i] = in.readFloat(); + } - return array; + if (logger.isTraceEnabled(LogMarker.SERIALIZER)) { + logger.trace(LogMarker.SERIALIZER, "Read float array of length {}", length); } + + return array; } + } /** - * Writes an array of <code>double</code>s to a - * <code>DataOutput</code>. - * This method will serialize a - * <code>null</code> array and not throw a - * <code>NullPointerException</code>. + * Writes an array of <code>double</code>s to a <code>DataOutput</code>. This method will + * serialize a <code>null</code> array and not throw a <code>NullPointerException</code>. * - * @throws IOException - * A problem occurs while writing to <code>out</code> + * @throws IOException A problem occurs while writing to <code>out</code> * * @see #readDoubleArray */ - public static void writeDoubleArray(double[] array, DataOutput out) - throws IOException { + public static void writeDoubleArray(double[] array, DataOutput out) throws IOException { InternalDataSerializer.checkOut(out); @@ -2041,157 +1821,143 @@ public abstract class DataSerializer { } /** - * Reads an array of <code>double</code>s from a - * <code>DataInput</code>. + * Reads an array of <code>double</code>s from a <code>DataInput</code>. * - * @throws IOException - * A problem occurs while reading from <code>in</code> + * @throws IOException A problem occurs while reading from <code>in</code> * * @see #writeDoubleArray */ - public static double[] readDoubleArray(DataInput in) - throws IOException { + public static double[] readDoubleArray(DataInput in) throws IOException { - InternalDataSerializer.checkIn(in); - - int length = InternalDataSerializer.readArrayLength(in); - if (length == -1) { - return null; - } else { - double[] array = new double[length]; - for (int i = 0; i < length; i++) { - array[i] = in.readDouble(); - } + InternalDataSerializer.checkIn(in); - if (logger.isTraceEnabled(LogMarker.SERIALIZER)) { - logger.trace(LogMarker.SERIALIZER, "Read double array of length {}", length); - } + int length = InternalDataSerializer.readArrayLength(in); + if (length == -1) { + return null; + } else { + double[] array = new double[length]; + for (int i = 0; i < length; i++) { + array[i] = in.readDouble(); + } - return array; + if (logger.isTraceEnabled(LogMarker.SERIALIZER)) { + logger.trace(LogMarker.SERIALIZER, "Read double array of length {}", length); } + + return array; } + } /** - * Writes an array of <code>Object</code>s to a - * <code>DataOutput</code>. - * This method will serialize a - * <code>null</code> array and not throw a - * <code>NullPointerException</code>. + * Writes an array of <code>Object</code>s to a <code>DataOutput</code>. This method will + * serialize a <code>null</code> array and not throw a <code>NullPointerException</code>. * - * @throws IOException - * A problem occurs while writing to <code>out</code> + * @throws IOException A problem occurs while writing to <code>out</code> * * @see #readObjectArray * @see #writeObject(Object, DataOutput) */ - public static void writeObjectArray(Object[] array, DataOutput out) - throws IOException { + public static void writeObjectArray(Object[] array, DataOutput out) throws IOException { InternalDataSerializer.writeObjectArray(array, out, false); } - + /** - * Reads an array of <code>Object</code>s from a - * <code>DataInput</code>. + * Reads an array of <code>Object</code>s from a <code>DataInput</code>. * - * @throws IOException - * A problem occurs while reading from <code>in</code> + * @throws IOException A problem occurs while reading from <code>in</code> * * @see #writeObjectArray * @see #readObject */ - public static Object[] readObjectArray(DataInput in) - throws IOException, ClassNotFoundException { + public static Object[] readObjectArray(DataInput in) throws IOException, ClassNotFoundException { - InternalDataSerializer.checkIn(in); + InternalDataSerializer.checkIn(in); - int length = InternalDataSerializer.readArrayLength(in); - if (length == -1) { - return null; + int length = InternalDataSerializer.readArrayLength(in); + if (length == -1) { + return null; + } else { + Class<?> c = null; + byte typeCode = in.readByte(); + String typeString = null; + if (typeCode == DSCODE.CLASS) { + typeString = readString(in); + } + + GemFireCacheImpl cache = GemFireCacheImpl.getInstance(); + boolean lookForPdxInstance = false; + ClassNotFoundException cnfEx = null; + if (typeCode == DSCODE.CLASS && cache != null + && cache.getPdxReadSerializedByAnyGemFireServices()) { + try { + c = InternalDataSerializer.getCachedClass(typeString); + lookForPdxInstance = true; + } catch (ClassNotFoundException ignore) { + c = Object.class; + cnfEx = ignore; + } } else { - Class<?> c = null; - byte typeCode = in.readByte(); - String typeString = null; if (typeCode == DSCODE.CLASS) { - typeString = readString(in); - } - - GemFireCacheImpl cache = GemFireCacheImpl.getInstance(); - boolean lookForPdxInstance = false; - ClassNotFoundException cnfEx = null; - if (typeCode == DSCODE.CLASS - && cache != null && cache.getPdxReadSerializedByAnyGemFireServices()) { - try { - c = InternalDataSerializer.getCachedClass(typeString); - lookForPdxInstance = true; - } catch (ClassNotFoundException ignore) { - c = Object.class; - cnfEx = ignore; - } + c = InternalDataSerializer.getCachedClass(typeString); } else { - if (typeCode == DSCODE.CLASS) { - c = InternalDataSerializer.getCachedClass(typeString); - } else { - c = InternalDataSerializer.decodePrimitiveClass(typeCode); - } - } - Object o = null; - if (length > 0) { - o = readObject(in); - if (lookForPdxInstance && o instanceof PdxInstance) { - lookForPdxInstance = false; - c = Object.class; - } - } - Object[] array = (Object[]) Array.newInstance(c, length); - if (length > 0) { - array[0] = o; - } - for (int i = 1; i < length; i++) { - o = readObject(in); - if (lookForPdxInstance && o instanceof PdxInstance) { - // create an Object[] and copy all the entries we already did into it - lookForPdxInstance = false; - c = Object.class; - Object[] newArray = (Object[])Array.newInstance(c, length); - System.arraycopy(array, 0, newArray, 0, i); - array = newArray; - } - array[i] = o; + c = InternalDataSerializer.decodePrimitiveClass(typeCode); } - if (lookForPdxInstance && cnfEx != null && length > 0) { - // We have a non-empty array and didn't find any - // PdxInstances in it. So we should have been able - // to load the element type. - // Note that empty arrays in this case will deserialize - // as an Object[] since we can't tell if the element - // type is a pdx one. - throw cnfEx; + } + Object o = null; + if (length > 0) { + o = readObject(in); + if (lookForPdxInstance && o instanceof PdxInstance) { + lookForPdxInstance = false; + c = Object.class; } - - if (logger.isTraceEnabled(LogMarker.SERIALIZER)) { - logger.trace(LogMarker.SERIALIZER, "Read Object array of length {}", length); + } + Object[] array = (Object[]) Array.newInstance(c, length); + if (length > 0) { + array[0] = o; + } + for (int i = 1; i < length; i++) { + o = readObject(in); + if (lookForPdxInstance && o instanceof PdxInstance) { + // create an Object[] and copy all the entries we already did into it + lookForPdxInstance = false; + c = Object.class; + Object[] newArray = (Object[]) Array.newInstance(c, length); + System.arraycopy(array, 0, newArray, 0, i); + array = newArray; } + array[i] = o; + } + if (lookForPdxInstance && cnfEx != null && length > 0) { + // We have a non-empty array and didn't find any + // PdxInstances in it. So we should have been able + // to load the element type. + // Note that empty arrays in this case will deserialize + // as an Object[] since we can't tell if the element + // type is a pdx one. + throw cnfEx; + } - return array; + if (logger.isTraceEnabled(LogMarker.SERIALIZER)) { + logger.trace(LogMarker.SERIALIZER, "Read Object array of length {}", length); } + + return array; } - + } + /** * Writes an array of <tt>byte[]</tt> to a <tt>DataOutput</tt>. * - * @throws IOException - * A problem occurs while writing to <tt>out</tt>. + * @throws IOException A problem occurs while writing to <tt>out</tt>. * */ - public static void writeArrayOfByteArrays(byte[][] array, DataOutput out) - throws IOException { - + public static void writeArrayOfByteArrays(byte[][] array, DataOutput out) throws IOException { + InternalDataSerializer.checkOut(out); int length; if (array == null) { length = -1; - } - else { + } else { length = array.length; } InternalDataSerializer.writeArrayLength(length, out); @@ -2204,19 +1970,17 @@ public abstract class DataSerializer { } } } - + /** - * Reads an array of <code>byte[]</code>s from a - * <code>DataInput</code>. + * Reads an array of <code>byte[]</code>s from a <code>DataInput</code>. * - * @throws IOException - * A problem occurs while reading from <code>in</code> + * @throws IOException A problem occurs while reading from <code>in</code> */ public static byte[][] readArrayOfByteArrays(DataInput in) - throws IOException, ClassNotFoundException { - + throws IOException, ClassNotFoundException { + InternalDataSerializer.checkIn(in); - + int length = InternalDataSerializer.readArrayLength(in); if (length == -1) { return null; @@ -2225,35 +1989,29 @@ public abstract class DataSerializer { for (int i = 0; i < length; i++) { array[i] = readByteArray(in); } - + if (logger.isTraceEnabled(LogMarker.SERIALIZER)) { logger.trace(LogMarker.SERIALIZER, "Read byte[][] of length {}", length); } - + return array; } } - - + + /** - * Writes an <code>ArrayList</code> to a <code>DataOutput</code>. - * Note that even though <code>list</code> may be an instance of a - * subclass of <code>ArrayList</code>, <code>readArrayList</code> - * will always return an instance of <code>ArrayList</code>, - * <B>not</B> an instance of the subclass. To preserve the class - * type of <code>list</code>, {@link #writeObject(Object, DataOutput)} should be used - * for data serialization. - * This method will serialize a - * <code>null</code> list and not throw a - * <code>NullPointerException</code>. + * Writes an <code>ArrayList</code> to a <code>DataOutput</code>. Note that even though + * <code>list</code> may be an instance of a subclass of <code>ArrayList</code>, + * <code>readArrayList</code> will always return an instance of <code>ArrayList</code>, <B>not</B> + * an instance of the subclass. To preserve the class type of <code>list</code>, + * {@link #writeObject(Object, DataOutput)} should be used for data serialization. This method + * will serialize a <code>null</code> list and not throw a <code>NullPointerException</code>. * - * @throws IOException - * A problem occurs while writing to <code>out</code> + * @throws IOException A problem occurs while writing to <code>out</code> * * @see #readArrayList */ - public static void writeArrayList(ArrayList<?> list, DataOutput out) - throws IOException { + public static void writeArrayList(ArrayList<?> list, DataOutput out) throws IOException { InternalDataSerializer.checkOut(out); @@ -2268,27 +2026,25 @@ public abstract class DataSerializer { logger.trace(LogMarker.SERIALIZER, "Writing ArrayList with {} elements: {}", size, list); } if (size > 0) { - for (int i=0; i < size; i++) { + for (int i = 0; i < size; i++) { writeObject(list.get(i), out); } } } - - + + /** * Reads an <code>ArrayList</code> from a <code>DataInput</code>. * - * @throws IOException - * A problem occurs while reading from <code>in</code> - * @throws ClassNotFoundException - * The class of one of the <Code>ArrayList</code>'s - * elements cannot be found. + * @throws IOException A problem occurs while reading from <code>in</code> + * @throws ClassNotFoundException The class of one of the <Code>ArrayList</code>'s elements cannot + * be found. * * @see #writeArrayList */ public static <E> ArrayList<E> readArrayList(DataInput in) - throws IOException, ClassNotFoundException { + throws IOException, ClassNotFoundException { InternalDataSerializer.checkIn(in); @@ -2311,22 +2067,18 @@ public abstract class DataSerializer { } /** - * Writes an <code>Vector</code> to a <code>DataOutput</code>. - * Note that even though <code>list</code> may be an instance of a - * subclass of <code>Vector</code>, <code>readVector</code> - * will always return an instance of <code>Vector</code>, - * <B>not</B> an instance of the subclass. To preserve the class - * type of <code>list</code>, {@link #writeObject(Object, DataOutput)} should be used - * for data serialization. + * Writes an <code>Vector</code> to a <code>DataOutput</code>. Note that even though + * <code>list</code> may be an instance of a subclass of <code>Vector</code>, + * <code>readVector</code> will always return an instance of <code>Vector</code>, <B>not</B> an + * instance of the subclass. To preserve the class type of <code>list</code>, + * {@link #writeObject(Object, DataOutput)} should be used for data serialization. * - * @throws IOException - * A problem occurs while writing to <code>out</code> + * @throws IOException A problem occurs while writing to <code>out</code> * * @see #readVector * @since GemFire 5.7 */ - public static void writeVector(Vector<?> list, DataOutput out) - throws IOException { + public static void writeVector(Vector<?> list, DataOutput out) throws IOException { InternalDataSerializer.checkOut(out); @@ -2341,7 +2093,7 @@ public abstract class DataSerializer { logger.trace(LogMarker.SERIALIZER, "Writing Vector with {} elements: {}", size, list); } if (size > 0) { - for (int i=0; i < size; i++) { + for (int i = 0; i < size; i++) { writeObject(list.get(i), out); } } @@ -2350,17 +2102,14 @@ public abstract class DataSerializer { /** * Reads an <code>Vector</code> from a <
<TRUNCATED>
