Package org.teiid.core.util
Class ExternalizeUtil
- java.lang.Object
-
- org.teiid.core.util.ExternalizeUtil
-
public class ExternalizeUtil extends Object
Utilities used by Externalizable classes to read/write objects from ObjectInput/ObjectOutput instances.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> T[]
readArray(ObjectInput in, Class<T> type)
Reads an array of String that was written to the output by this utility classstatic <T extends Enum<T>>
TreadEnum(ObjectInput in, Class<T> clazz, T defaultVal)
static List<?>
readList(ObjectInput in)
static <T> List<T>
readList(ObjectInput in, Class<T> type)
Reads a List that was written by this utility class.static <K,V>
Map<K,V>readMap(ObjectInput in)
Reads a Map that was written by this utility classstatic String[]
readStringArray(ObjectInput in)
static void
writeArray(ObjectOutput out, Object[] array)
Writes an array to the output.static void
writeCollection(ObjectOutput out, Collection<?> coll)
Writes a Collection to the output using its Iterator.static void
writeEnum(ObjectOutput out, Enum<?> value)
static void
writeList(ObjectOutput out, List<?> coll)
static void
writeMap(ObjectOutput out, Map<?,?> map)
Writes the key-value pairs of the given map to the output.
-
-
-
Method Detail
-
writeArray
public static void writeArray(ObjectOutput out, Object[] array) throws IOException
Writes an array to the output.- Parameters:
out
- the output instancearray
- reference to an array. Can be null.- Throws:
IOException
-
writeCollection
public static void writeCollection(ObjectOutput out, Collection<?> coll) throws IOException
Writes a Collection to the output using its Iterator.- Parameters:
out
- the output instancecoll
- reference to a Collection. Can be null.- Throws:
IOException
-
writeList
public static void writeList(ObjectOutput out, List<?> coll) throws IOException
- Throws:
IOException
-
writeMap
public static void writeMap(ObjectOutput out, Map<?,?> map) throws IOException
Writes the key-value pairs of the given map to the output.- Parameters:
out
- the output instancemap
- reference to a Map. Can be null.- Throws:
IOException
-
readArray
public static <T> T[] readArray(ObjectInput in, Class<T> type) throws IOException, ClassNotFoundException
Reads an array of String that was written to the output by this utility class- Parameters:
in
-- Returns:
- a non-null String[]
- Throws:
IOException
ClassNotFoundException
-
readStringArray
public static String[] readStringArray(ObjectInput in) throws IOException, ClassNotFoundException
- Throws:
IOException
ClassNotFoundException
-
readList
public static <T> List<T> readList(ObjectInput in, Class<T> type) throws IOException, ClassNotFoundException
Reads a List that was written by this utility class.- Parameters:
in
-- Returns:
- a non-null List
- Throws:
IOException
ClassNotFoundException
-
readList
public static List<?> readList(ObjectInput in) throws IOException, ClassNotFoundException
- Throws:
IOException
ClassNotFoundException
-
readMap
public static <K,V> Map<K,V> readMap(ObjectInput in) throws IOException, ClassNotFoundException
Reads a Map that was written by this utility class- Parameters:
in
-- Returns:
- a non-null Map
- Throws:
IOException
ClassNotFoundException
-
writeEnum
public static void writeEnum(ObjectOutput out, Enum<?> value) throws IOException
- Throws:
IOException
-
readEnum
public static <T extends Enum<T>> T readEnum(ObjectInput in, Class<T> clazz, T defaultVal) throws IOException
- Throws:
IOException
-
-