public class IOUtils extends Object
Modifier and Type | Class and Description |
---|---|
static class |
IOUtils.NoHeaderObjectInputStream |
static class |
IOUtils.NoHeaderObjectOutputStream |
Constructor and Description |
---|
IOUtils() |
Modifier and Type | Method and Description |
---|---|
static Object |
deepClone(Object obj)
A deep copy makes a distinct copy of each of the object's fields, recursing through the
entire graph of other objects referenced by the object being copied.
|
static void |
deserializeSupportCodeChangeCollection(ObjectInput in,
Collection collection)
|
static int |
getAnonymousPort()
Get an anonymous socket port.
|
static Map<Class<?>,IClassSerializer<?>> |
getClassSerializers() |
static IClassSerializer<?> |
getDefaultSerializer() |
static boolean |
isArchive(String fileName) |
static boolean |
isPortBusy(int port,
String bindAddr)
Checks whether a supplied socket port is busy.
|
static void |
marshalValue(Class type,
Object value,
ObjectOutput out)
Marshals
value to an ObjectOutputStream stream, out ,
using RMI's serialization format for arguments or return values. |
static Object |
objectFromByteBuffer(byte[] buffer)
Creates an object from a byte buffer.
|
static byte[] |
objectToByteBuffer(Object obj)
Serializes an object into a byte buffer.
|
static boolean[] |
readBooleanArray(ObjectInput in) |
static byte[] |
readByteArray(ObjectInput in) |
static IEntryPacket[] |
readEntryPacketArray(ObjectInput in) |
static Exception[] |
readExceptionArray(ObjectInput in) |
static int |
readInt(ObjectInput in) |
static int[] |
readIntegerArray(ObjectInput in) |
static List |
readList(ObjectInput in) |
static List<String> |
readListString(ObjectInput in) |
static long |
readLong(ObjectInput in) |
static long[] |
readLongArray(ObjectInput in) |
static <T> Map<String,T> |
readMapRepetitiveKeys(ObjectInput in) |
static Map<String,Object> |
readMapStringObject(ObjectInput in) |
static Map<String,String> |
readMapStringString(ObjectInput in) |
static <T extends ISwapExternalizable> |
readNullableSwapExternalizableObject(ObjectInput in) |
static <T> T |
readObject(ObjectInput in) |
static Object |
readObject(ObjectInput in,
SupportCodeChangeAnnotationContainer supportCodeChangeAnnotationContainer,
boolean useIOUtilsReadObject)
Tasks are loaded with a fresh class loader.
|
static Object[] |
readObjectArray(ObjectInput in) |
static Object[] |
readObjectArrayCompressed(ObjectInput in) |
static <T> T |
readRepetitiveObject(ObjectInput in)
Objects read and written with repetitive must be immutable (cannot be changed as they are
kept in underlying map, changing them will affect the next repetitiveRead/Write
|
static String |
readRepetitiveString(ObjectInput in)
Read strings that were Shrinked using
writeRepetitiveString(ObjectOutput, String) |
static String[] |
readRepetitiveStringArray(ObjectInput in) |
static short |
readShort(ObjectInput in) |
static short[] |
readShortArray(ObjectInput in) |
static String |
readString(ObjectInput in) |
static String[] |
readStringArray(ObjectInput in) |
static Set<String> |
readStringSet(ObjectInput in) |
static <T extends ISwapExternalizable> |
readSwapExternalizableObject(ObjectInput in) |
static ITemplatePacket[] |
readTemplatePacketArray(ObjectInput in) |
static Throwable[] |
readThrowableArray(ObjectInput in) |
static UUID |
readUUID(ObjectInput in) |
static <T> T |
readWithCachedStubs(ObjectInput in) |
static void |
serializeSupportCodeChangeCollection(ObjectOutput out,
Collection collection)
Complement of
#deserializeSupportCodeChangeCollection(ObjectInput in, Collection collection)) |
static Object |
unmarshalValue(Class type,
ObjectInput in)
Unmarshals a value of the specified
type from the ObjectInputStream
stream, in , using RMI's serialization format for arguments or return values and
returns the result. |
static void |
writeBooleanArray(ObjectOutput out,
boolean[] array) |
static void |
writeByteArray(ObjectOutput out,
byte[] array) |
static void |
writeInt(ObjectOutput out,
int value) |
static void |
writeIntegerArray(ObjectOutput out,
int[] array) |
static void |
writeList(ObjectOutput out,
List list) |
static void |
writeListString(ObjectOutput out,
List<String> list) |
static void |
writeLong(ObjectOutput out,
long value) |
static void |
writeLongArray(ObjectOutput out,
long[] array) |
static <T> void |
writeMapRepetitiveKeys(ObjectOutput out,
Map<String,T> map) |
static void |
writeMapStringObject(ObjectOutput out,
Map<String,Object> map) |
static void |
writeMapStringString(ObjectOutput out,
Map<String,String> map) |
static void |
writeNullableSwapExternalizableObject(ObjectOutput out,
ISwapExternalizable swapExternalizable) |
static void |
writeObject(ObjectOutput out,
Object obj) |
static void |
writeObjectArray(ObjectOutput out,
Object[] array) |
static void |
writeObjectArrayCompressed(ObjectOutput out,
Object[] array) |
static void |
writeRepetitiveObject(ObjectOutput out,
Object obj)
Should only be used for objects that their class is known to SystemJars.DATA_GRID_JAR,
meaning at SystemJars.DATA_GRID_JAR, its dependencies or JDK Objects read and written with
repetitive must be immutable (cannot be changed as they are kept in underlying map, changing
them will affect the next repetitiveRead/Write
|
static void |
writeRepetitiveString(ObjectOutput out,
String s)
Shrink string over the wire, should be used for constant number of strings which are
repetitive (i.e space names, class names)
|
static void |
writeRepetitiveStringArray(ObjectOutput out,
String[] array) |
static void |
writeShort(ObjectOutput out,
short value) |
static void |
writeShortArray(ObjectOutput out,
short[] array) |
static void |
writeString(ObjectOutput out,
String s) |
static void |
writeStringArray(ObjectOutput out,
String[] array) |
static void |
writeStringSet(ObjectOutput out,
Set<String> set) |
static void |
writeSwapExternalizableObject(ObjectOutput out,
ISwapExternalizable swapExternalizable) |
static void |
writeUUID(ObjectOutput out,
UUID value) |
static void |
writeWithCachedStubs(ObjectOutput out,
Object obj) |
public static boolean isArchive(String fileName)
public static Object objectFromByteBuffer(byte[] buffer) throws Exception
Exception
public static byte[] objectToByteBuffer(Object obj) throws Exception
Exception
public static Object deepClone(Object obj)
obj
- the object to clone, the object and object context must implement
java.io.Serializable.IllegalArgumentException
- Failed to perform deep clone. The object of the context
object is not implements java.io.Serializable.public static void writeUUID(ObjectOutput out, UUID value) throws IOException
IOException
public static UUID readUUID(ObjectInput in) throws IOException
IOException
public static void marshalValue(Class type, Object value, ObjectOutput out) throws IOException
value
to an ObjectOutputStream
stream, out
,
using RMI's serialization format for arguments or return values. For primitive types, the
primitive type's class should be specified (i.e., for the type int
, specify
int.class
), and the primitive value should be wrapped in instances of the
appropriate wrapper class, such as java.lang.Integer
or
java.lang.Boolean
.type
- Class
object for the value to be marshalledvalue
- value to marshalout
- stream to which the value is marshalledIOException
- if an I/O error occurs marshalling the value to the output streampublic static Object unmarshalValue(Class type, ObjectInput in) throws IOException, ClassNotFoundException
type
from the ObjectInputStream
stream, in
, using RMI's serialization format for arguments or return values and
returns the result. For primitive types, the primitive type's class should be specified
(i.e., for the primitive type int
, specify int.class
).type
- Class
object for the value to be unmarshalledin
- stream from which the value is unmarshalledIOException
- if an I/O error occurs marshalling the value to the output
streamClassNotFoundException
- if the type
's class could not be foundpublic static boolean isPortBusy(int port, String bindAddr) throws UnknownHostException
port
- the port to check.bindAddr
- check if port busy on specific InetAddress
, If bindAddr is
null, it will default accepting connections on any/all local addressestrue
if supplied port is busy, otherwise false
.UnknownHostException
- if no IP address for the host
could be found, or if
a scope_id was specified for a global IPv6 address.public static int getAnonymousPort() throws IOException
java.net.ServerSocket
with
a port of 0IOException
public static void writeShortArray(ObjectOutput out, short[] array) throws IOException
IOException
public static short[] readShortArray(ObjectInput in) throws IOException
IOException
public static void writeIntegerArray(ObjectOutput out, int[] array) throws IOException
IOException
public static int[] readIntegerArray(ObjectInput in) throws IOException
IOException
public static void writeLongArray(ObjectOutput out, long[] array) throws IOException
IOException
public static long[] readLongArray(ObjectInput in) throws IOException
IOException
public static void writeByteArray(ObjectOutput out, byte[] array) throws IOException
IOException
public static byte[] readByteArray(ObjectInput in) throws IOException
IOException
public static void writeBooleanArray(ObjectOutput out, boolean[] array) throws IOException
IOException
public static boolean[] readBooleanArray(ObjectInput in) throws IOException
IOException
public static void writeRepetitiveString(ObjectOutput out, String s) throws IOException
IOException
public static String readRepetitiveString(ObjectInput in) throws IOException, ClassNotFoundException
writeRepetitiveString(ObjectOutput, String)
IOException
ClassNotFoundException
public static void writeString(ObjectOutput out, String s) throws IOException
IOException
public static String readString(ObjectInput in) throws IOException, ClassNotFoundException
IOException
ClassNotFoundException
public static void writeStringArray(ObjectOutput out, String[] array) throws IOException
IOException
public static String[] readStringArray(ObjectInput in) throws IOException, ClassNotFoundException
IOException
ClassNotFoundException
public static void writeStringSet(ObjectOutput out, Set<String> set) throws IOException
IOException
public static Set<String> readStringSet(ObjectInput in) throws IOException, ClassNotFoundException
IOException
ClassNotFoundException
public static void writeRepetitiveStringArray(ObjectOutput out, String[] array) throws IOException
IOException
public static String[] readRepetitiveStringArray(ObjectInput in) throws IOException, ClassNotFoundException
IOException
ClassNotFoundException
public static void writeList(ObjectOutput out, List list) throws IOException
IOException
public static List readList(ObjectInput in) throws IOException, ClassNotFoundException
IOException
ClassNotFoundException
public static void writeListString(ObjectOutput out, List<String> list) throws IOException
IOException
public static List<String> readListString(ObjectInput in) throws IOException, ClassNotFoundException
IOException
ClassNotFoundException
public static void writeMapStringString(ObjectOutput out, Map<String,String> map) throws IOException
IOException
public static Map<String,String> readMapStringString(ObjectInput in) throws IOException, ClassNotFoundException
IOException
ClassNotFoundException
public static void writeMapStringObject(ObjectOutput out, Map<String,Object> map) throws IOException
IOException
public static Map<String,Object> readMapStringObject(ObjectInput in) throws IOException, ClassNotFoundException
IOException
ClassNotFoundException
public static <T> void writeMapRepetitiveKeys(ObjectOutput out, Map<String,T> map) throws IOException
IOException
public static <T> Map<String,T> readMapRepetitiveKeys(ObjectInput in) throws IOException, ClassNotFoundException
IOException
ClassNotFoundException
public static void writeRepetitiveObject(ObjectOutput out, Object obj) throws IOException
IOException
public static void writeObject(ObjectOutput out, Object obj) throws IOException
IOException
public static <T> T readRepetitiveObject(ObjectInput in) throws IOException, ClassNotFoundException
IOException
ClassNotFoundException
public static <T> T readObject(ObjectInput in) throws IOException, ClassNotFoundException
IOException
ClassNotFoundException
public static void writeObjectArray(ObjectOutput out, Object[] array) throws IOException
IOException
public static Object[] readObjectArray(ObjectInput in) throws IOException, ClassNotFoundException
IOException
ClassNotFoundException
public static Throwable[] readThrowableArray(ObjectInput in) throws IOException, ClassNotFoundException
IOException
ClassNotFoundException
public static Exception[] readExceptionArray(ObjectInput in) throws IOException, ClassNotFoundException
IOException
ClassNotFoundException
public static IEntryPacket[] readEntryPacketArray(ObjectInput in) throws IOException, ClassNotFoundException
IOException
ClassNotFoundException
public static ITemplatePacket[] readTemplatePacketArray(ObjectInput in) throws IOException, ClassNotFoundException
IOException
ClassNotFoundException
public static void writeObjectArrayCompressed(ObjectOutput out, Object[] array) throws IOException
IOException
public static Object[] readObjectArrayCompressed(ObjectInput in) throws IOException, ClassNotFoundException
IOException
ClassNotFoundException
public static void writeSwapExternalizableObject(ObjectOutput out, ISwapExternalizable swapExternalizable) throws IOException
IOException
public static <T extends ISwapExternalizable> T readSwapExternalizableObject(ObjectInput in) throws IOException, ClassNotFoundException
IOException
ClassNotFoundException
public static void writeNullableSwapExternalizableObject(ObjectOutput out, ISwapExternalizable swapExternalizable) throws IOException
IOException
public static <T extends ISwapExternalizable> T readNullableSwapExternalizableObject(ObjectInput in) throws IOException, ClassNotFoundException
IOException
ClassNotFoundException
public static void writeWithCachedStubs(ObjectOutput out, Object obj) throws IOException
IOException
public static <T> T readWithCachedStubs(ObjectInput in) throws IOException, ClassNotFoundException
IOException
ClassNotFoundException
public static Object readObject(ObjectInput in, SupportCodeChangeAnnotationContainer supportCodeChangeAnnotationContainer, boolean useIOUtilsReadObject) throws ClassNotFoundException, IOException
public static void serializeSupportCodeChangeCollection(ObjectOutput out, Collection collection) throws IOException
#deserializeSupportCodeChangeCollection(ObjectInput in, Collection collection))
IOException
public static void deserializeSupportCodeChangeCollection(ObjectInput in, Collection collection) throws IOException, ClassNotFoundException
IOException
ClassNotFoundException
public static void writeShort(ObjectOutput out, short value) throws IOException
IOException
public static void writeInt(ObjectOutput out, int value) throws IOException
IOException
public static void writeLong(ObjectOutput out, long value) throws IOException
IOException
public static short readShort(ObjectInput in) throws IOException
IOException
public static int readInt(ObjectInput in) throws IOException
IOException
public static long readLong(ObjectInput in) throws IOException
IOException
public static Map<Class<?>,IClassSerializer<?>> getClassSerializers()
public static IClassSerializer<?> getDefaultSerializer()
Copyright © GigaSpaces.