gausssoft.io
Class IOUtils

java.lang.Object
  |
  +--gausssoft.io.IOUtils
All Implemented Interfaces:
IOConstants

public class IOUtils
extends Object
implements IOConstants

This class holds a series of useful methods relating to IO functions.

Since:
GSDK 1.1
Author:
Allan Crooks
See Also:
IOConstants

Fields inherited from interface gausssoft.io.IOConstants
NULLOUT
 
Method Summary
static void argCheck(byte[] b, int off, int len)
          Utility method to check for valid parameters for any kind of array read or write operation.
static void argCircularCheck(byte[] b, int off, int len)
          Utility method to check for valid parameters for any kind of circular array read or write operation.
static void argIndexCheck(byte[] b, int index)
          Utility method to check that a byte array is not null, and the index variable is a valid index in the array.
static boolean isSerializable(Object obj)
          Returns true if this object could be written to an ObjectOutputStream without throwing a NotSerializableException.
static void writeCircularArray(OutputStream out, byte[] b, int off, int len)
          Utility method that will write a series of bytes in an array to an OutputStream, which are stored in the array in a circular manner.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

argIndexCheck

public static void argIndexCheck(byte[] b,
                                 int index)
Utility method to check that a byte array is not null, and the index variable is a valid index in the array.

The method will return normally if nothing is incorrect, otherwise it will throw the relevant exception.

Parameters:
b - The byte array to check.
index - The index position to check.
Throws:
NullPointerException - If b is null.
IndexOutOfBoundsException - If index is invalid.

argCircularCheck

public static void argCircularCheck(byte[] b,
                                    int off,
                                    int len)
Utility method to check for valid parameters for any kind of circular array read or write operation.

If the method returns normally, it will ensure that:

Parameters:
b - The byte array to check.
off - The index position where the operation will begin.
len - The number of bytes in the array to be processed.
Throws:
NullPointerException - If b is null.
IllegalArgumentException - If len is less than 0.
IndexOutOfBoundsException - If off is invalid, or if len is longer than the size of the array.

argCheck

public static void argCheck(byte[] b,
                            int off,
                            int len)
Utility method to check for valid parameters for any kind of array read or write operation.

If the method returns normally, it will ensure that:

Parameters:
b - The byte array to check.
off - The index position where the operation will begin.
len - The number of bytes in the array to be processed.
Throws:
NullPointerException - If b is null.
IllegalArgumentException - If len is less than 0.
IndexOutOfBoundsException - If off is invalid, or if off + len is an invalid index position.

writeCircularArray

public static void writeCircularArray(OutputStream out,
                                      byte[] b,
                                      int off,
                                      int len)
                               throws IOException
Utility method that will write a series of bytes in an array to an OutputStream, which are stored in the array in a circular manner.

This method can also be used for writing an array which isn't circular into a stream.

Parameters:
out - The OutputStream to write to.
b - The circular byte array to write to the stream.
off - The index position of the first data byte.
len - The number of bytes to write into the stream.
Throws:
NullPointerException - If b or out is null.
IllegalArgumentException - If len is less than 0.
IndexOutOfBoundsException - If off is invalid, or if len is larger than the length of the array.
IOException - If there was a problem writing the array.

isSerializable

public static boolean isSerializable(Object obj)
Returns true if this object could be written to an ObjectOutputStream without throwing a NotSerializableException.
Parameters:
obj - The object to test.
Returns:
true if this object can be written to an ObjectOutputStream safely.
See Also:
Serializable, ObjectOutputStream