org.icepdf.core.util
Class Utils

java.lang.Object
  extended by org.icepdf.core.util.Utils

public class Utils
extends java.lang.Object

Author:
Mark Collette Date: 18-Feb-2005 Time: 3:53:40 PM

Constructor Summary
Utils()
           
 
Method Summary
static java.lang.String convertByteArrayToByteString(byte[] bytes)
          When converting between String chars and bytes, there's an implied encoding to be used, dependent on the context and platform.
static java.lang.String convertByteArrayToHexString(byte[] buffer, boolean addSpaceSeparator)
           
static java.lang.String convertByteArrayToHexString(byte[] buffer, boolean addSpaceSeparator, int addDelimiterEverNBytes, char delimiter)
           
static java.lang.String convertByteArrayToHexString(byte[] buffer, int offset, int length, boolean addSpaceSeparator, int addDelimiterEverNBytes, char delimiter)
           
static byte[] convertByteCharSequenceToByteArray(java.lang.CharSequence string)
          When converting between String chars and bytes, there's an implied encoding to be used, dependent on the context and platform.
static java.lang.String getContentAndReplaceInputStream(java.io.InputStream[] inArray, boolean convertToHex)
           
static java.lang.String getContentFromSeekableInput(SeekableInput in, boolean convertToHex)
           
static int numBytesToHoldBits(int numBits)
           
static void printMemory(java.lang.String str)
           
static int readIntWithVaryingBytesBE(java.io.InputStream in, int numBytes)
           
static long readLongWithVaryingBytesBE(java.io.InputStream in, int numBytes)
           
static boolean reflectGraphicsEnvironmentISHeadlessInstance(java.lang.Object graphicsEnvironment, boolean defaultReturnIfNoMethod)
          boolean java.awt.GraphicsEnvironment.isHeadless() does not exist in Java 1.3, since it was introduced in Java 1.4, so we use reflection to call it, if it exists.
static SeekableInput replaceInputStreamWithSeekableInput(java.io.InputStream in)
           
static void setIntIntoByteArrayBE(int value, byte[] buffer, int offset)
          Sets the value into the buffer, at the designated offset, using big-endian rules Callers is responsible to ensure that value will fit into buffer, starting at offset
static void setShortIntoByteArrayBE(short value, byte[] buffer, int offset)
          Sets the value into the buffer, at the designated offset, using big-endian rules Callers is responsible to ensure that value will fit into buffer, starting at offset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Utils

public Utils()
Method Detail

setIntIntoByteArrayBE

public static void setIntIntoByteArrayBE(int value,
                                         byte[] buffer,
                                         int offset)
Sets the value into the buffer, at the designated offset, using big-endian rules Callers is responsible to ensure that value will fit into buffer, starting at offset

Parameters:
value - to be set into buffer
buffer - into which value is to be set
offset - into buffer which value is to be set

setShortIntoByteArrayBE

public static void setShortIntoByteArrayBE(short value,
                                           byte[] buffer,
                                           int offset)
Sets the value into the buffer, at the designated offset, using big-endian rules Callers is responsible to ensure that value will fit into buffer, starting at offset

Parameters:
value - to be set into buffer
buffer - into which value is to be set
offset - into buffer which value is to be set

readLongWithVaryingBytesBE

public static long readLongWithVaryingBytesBE(java.io.InputStream in,
                                              int numBytes)
                                       throws java.io.IOException
Parameters:
in - InputStream to read from
numBytes - number of bytes to read to make integral value from [0, 8]
Returns:
Integral value, which is composed of numBytes bytes, read using big-endian rules from in
Throws:
java.io.IOException

readIntWithVaryingBytesBE

public static int readIntWithVaryingBytesBE(java.io.InputStream in,
                                            int numBytes)
                                     throws java.io.IOException
Parameters:
in - InputStream to read from
numBytes - number of bytes to read to make integral value from [0, 4]
Returns:
Integral value, which is composed of numBytes bytes, read using big-endian rules from in
Throws:
java.io.IOException

convertByteArrayToHexString

public static java.lang.String convertByteArrayToHexString(byte[] buffer,
                                                           boolean addSpaceSeparator)

convertByteArrayToHexString

public static java.lang.String convertByteArrayToHexString(byte[] buffer,
                                                           boolean addSpaceSeparator,
                                                           int addDelimiterEverNBytes,
                                                           char delimiter)

convertByteArrayToHexString

public static java.lang.String convertByteArrayToHexString(byte[] buffer,
                                                           int offset,
                                                           int length,
                                                           boolean addSpaceSeparator,
                                                           int addDelimiterEverNBytes,
                                                           char delimiter)

reflectGraphicsEnvironmentISHeadlessInstance

public static boolean reflectGraphicsEnvironmentISHeadlessInstance(java.lang.Object graphicsEnvironment,
                                                                   boolean defaultReturnIfNoMethod)
boolean java.awt.GraphicsEnvironment.isHeadless() does not exist in Java 1.3, since it was introduced in Java 1.4, so we use reflection to call it, if it exists. In the event of not being able to call graphicsEnvironment.isHeadless(), instead of throwing an Exception, we simply return defaultReturnIfNoMethod

Parameters:
graphicsEnvironment - java.awt.GraphicsEnvironment to call isHeadless() on
defaultReturnIfNoMethod - Value to return if could not call graphicsEnvironment.isHeadless()

getContentAndReplaceInputStream

public static java.lang.String getContentAndReplaceInputStream(java.io.InputStream[] inArray,
                                                               boolean convertToHex)

getContentFromSeekableInput

public static java.lang.String getContentFromSeekableInput(SeekableInput in,
                                                           boolean convertToHex)

replaceInputStreamWithSeekableInput

public static SeekableInput replaceInputStreamWithSeekableInput(java.io.InputStream in)

printMemory

public static void printMemory(java.lang.String str)

numBytesToHoldBits

public static int numBytesToHoldBits(int numBits)

convertByteCharSequenceToByteArray

public static byte[] convertByteCharSequenceToByteArray(java.lang.CharSequence string)
When converting between String chars and bytes, there's an implied encoding to be used, dependent on the context and platform. If none is specified, then String(byte[]) will use the platform's default encoding. This method is for when encoding is not relevant, when the String simply holds byte values in each char.

See Also:
LiteralStringObject, HexStringObject, StandardEncryption

convertByteArrayToByteString

public static java.lang.String convertByteArrayToByteString(byte[] bytes)
When converting between String chars and bytes, there's an implied encoding to be used, dependent on the context and platform. If none is specified, then String(byte[]) will use the platform's default encoding. This method is for when encoding is not relevant, when the String simply holds byte values in each char.

See Also:
LiteralStringObject, HexStringObject, StandardEncryption