net.sourceforge.openstego.util
Class CommonUtil

java.lang.Object
  extended by net.sourceforge.openstego.util.CommonUtil

public class CommonUtil
extends java.lang.Object

Common utilities for OpenStego


Method Summary
static int byteToInt(int b)
          Byte to Int converter
static int ceilingHalf(int num)
          Returns the ceiling of the half of the input value
static int floorHalf(int num)
          Returns the floor of the half of the input value
static byte[] getFileBytes(java.io.File file)
          Method to get byte array data from given file
static byte[] getStreamBytes(java.io.InputStream is)
          Method to get byte array data from given InputStream
static double max(double x, double y)
          Get maximum of two given values
static int max(int x, int y)
          Get maximum of two given values
static double min(double x, double y)
          Get minimum of two given values
static int min(int x, int y)
          Get minimum of two given values
static int mod(int num, int div)
          Returns the modulus of the input value (taking care of the sign of the value)
static java.util.List parseFileList(java.lang.String fileList, java.lang.String delimiter)
          Method to parse a delimiter separated list of files into arraylist of filenames.
static void setEnabled(javax.swing.JTextField textField, boolean enabled)
          Method to enable/disable a Swing JTextField object
static void writeFile(byte[] fileData, java.io.File file)
          Method to write file data to disk
static void writeFile(byte[] fileData, java.lang.String fileName)
          Method to write file data to disk
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getStreamBytes

public static byte[] getStreamBytes(java.io.InputStream is)
                             throws OpenStegoException
Method to get byte array data from given InputStream

Parameters:
is - InputStream to read
Returns:
Stream data as byte array
Throws:
OpenStegoException

getFileBytes

public static byte[] getFileBytes(java.io.File file)
                           throws OpenStegoException
Method to get byte array data from given file

Parameters:
file - File to read
Returns:
File data as byte array
Throws:
OpenStegoException

writeFile

public static void writeFile(byte[] fileData,
                             java.lang.String fileName)
                      throws OpenStegoException
Method to write file data to disk

Parameters:
fileData - File data
fileName - File name (If this is null, then data is written to stdout)
Throws:
OpenStegoException

writeFile

public static void writeFile(byte[] fileData,
                             java.io.File file)
                      throws OpenStegoException
Method to write file data to disk

Parameters:
fileData - File data
file - File object (If this is null, then data is written to stdout)
Throws:
OpenStegoException

setEnabled

public static void setEnabled(javax.swing.JTextField textField,
                              boolean enabled)
Method to enable/disable a Swing JTextField object

Parameters:
textField - Swing JTextField object
enabled - Flag to indicate whether to enable or disable the object

parseFileList

public static java.util.List parseFileList(java.lang.String fileList,
                                           java.lang.String delimiter)
Method to parse a delimiter separated list of files into arraylist of filenames. It supports wildcard characters "*" and "?" within the filenames.

Parameters:
fileList - Delimiter separated list of filenames
delimiter - Delimiter for tokenization
Returns:
List of filenames after tokenizing and wildcard expansion

byteToInt

public static int byteToInt(int b)
Byte to Int converter

Parameters:
b - Input byte value
Returns:
Int value

floorHalf

public static int floorHalf(int num)
Returns the floor of the half of the input value

Parameters:
num - Input number
Returns:
Floor of the half of the input number

ceilingHalf

public static int ceilingHalf(int num)
Returns the ceiling of the half of the input value

Parameters:
num - Input number
Returns:
Ceiling of the half of the input number

mod

public static int mod(int num,
                      int div)
Returns the modulus of the input value (taking care of the sign of the value)

Parameters:
num - Input number
div - Divisor for modulus
Returns:
Modulus of num by div

max

public static int max(int x,
                      int y)
Get maximum of two given values

Parameters:
x - Value 1
y - value 2
Returns:
Max of the two values

max

public static double max(double x,
                         double y)
Get maximum of two given values

Parameters:
x - Value 1
y - value 2
Returns:
Max of the two values

min

public static int min(int x,
                      int y)
Get minimum of two given values

Parameters:
x - Value 1
y - value 2
Returns:
Min of the two values

min

public static double min(double x,
                         double y)
Get minimum of two given values

Parameters:
x - Value 1
y - value 2
Returns:
Min of the two values


Copyright © 2007-2009 Samir Vaidya. All Rights Reserved.