Framework Professional Edition Package


com.prosyst.util.encode
Class Axill

java.lang.Object
  extended by com.prosyst.util.encode.Axill

public class Axill
extends java.lang.Object

Implements useful methods.

Author:
Avgustin Marinov

Field Summary
static boolean debug
           
 
Constructor Summary
Axill()
           
 
Method Summary
static byte[] add(byte[] array, byte[] toAdd, int flag, int type)
          Returns byte array local with the properties:
static void add(java.io.OutputStream baos, byte[] toAdd, int type)
          Adds to array toAdd from flag position with type bytes length in beginning
static boolean equals(byte[] temp1, byte[] temp2)
          Compares if two byte arrays are equals - e.g.
static boolean equals(int[] temp1, int[] temp2)
          Compares if two integer arrays are equals - e.g.
static byte[] extract(byte[] array, int flag, int type)
          Opposite to set
static byte[] get(java.io.InputStream bais, int type)
          Gets array from stream with type bytes length in beginning
static byte[] getN(byte[] array, int n, int type)
          Gets N-th element from array which can be result of M times making of add method with same type (M>=N)
static java.lang.String parseString(java.lang.String str, int blocks)
          Parses string in blocks of 4 chars in "blocks" blocks per line
static void print(java.lang.String comment, byte[] ba)
          Dumps the byte array on the system console, prepending it with the given comment, if debug is enabled.
static void print(java.lang.String comment, int[] ia)
          Dumps the integer array on the system console, prepending it with the given comment, if debug is enabled.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

debug

public static boolean debug
Constructor Detail

Axill

public Axill()
Method Detail

add

public static byte[] add(byte[] array,
                         byte[] toAdd,
                         int flag,
                         int type)
Returns byte array local with the properties:
 for i = 0 to flag - 1 : local[i] = array[i]
 next |type| elements are toAdd.length
 next toAdd.elements are copy of toAdd
 next array.length - flag elements are then last elements from array
 

Parameters:
array - array to which we add elements
toAdd - array which we add
flag - index from which we add toAdd
type - number of bytes which keeps toAdd length (must be 0,1 or 2)
Returns:
byte array described up
Throws:
java.lang.IllegalArgumentException - if wrong Axill type is detected or the start index (flag parameter) exceeds the array length.

extract

public static byte[] extract(byte[] array,
                             int flag,
                             int type)
Opposite to set

Parameters:
array - array from which we extract part
flag - index from which be begin extracting
type - numbers of bytes which keep length
Returns:
extracted byte array
Throws:
java.lang.IllegalArgumentException - if the number of elements to extract is bigger, than the array length, or wrong Axill type is detected

getN

public static byte[] getN(byte[] array,
                          int n,
                          int type)
Gets N-th element from array which can be result of M times making of add method with same type (M>=N)

Parameters:
array - array from witch we takes element
n - number of the element we want to get
type - number of bytes keeping elements length
Returns:
byte array we want to get
Throws:
java.lang.IllegalArgumentException - if wrong Axill type is detected

add

public static void add(java.io.OutputStream baos,
                       byte[] toAdd,
                       int type)
Adds to array toAdd from flag position with type bytes length in beginning

Parameters:
baos - stream we append to
toAdd - byte[] we append
type - number of bytes for length
Throws:
java.lang.IllegalArgumentException - when I/O operation fails

get

public static byte[] get(java.io.InputStream bais,
                         int type)
Gets array from stream with type bytes length in beginning

Parameters:
bais - stream we read from
type - number of bytes represented length
Returns:
array from stream with type bytes length in beginning
Throws:
java.lang.IllegalArgumentException - on I/O error

equals

public static boolean equals(byte[] temp1,
                             byte[] temp2)
Compares if two byte arrays are equals - e.g. must have the same length, and each their elements must have the same values.

Parameters:
temp1 - first array for comparing, cannot be null
temp2 - second array for comparing , cannot be null
Returns:
true if the two arrays are equal

equals

public static boolean equals(int[] temp1,
                             int[] temp2)
Compares if two integer arrays are equals - e.g. must have the same length, and each their elements must have the same values.

Parameters:
temp1 - first array for comparing, cannot be null
temp2 - second array for comparing , cannot be null
Returns:
true if the two arrays are equal

parseString

public static java.lang.String parseString(java.lang.String str,
                                           int blocks)
Parses string in blocks of 4 chars in "blocks" blocks per line

Parameters:
str - the string
blocks - the number of block per line
Returns:
the parsed string, each block is placed on new line

print

public static void print(java.lang.String comment,
                         byte[] ba)
Dumps the byte array on the system console, prepending it with the given comment, if debug is enabled. If value debug is set to true prints byte[] with comment

Parameters:
comment - the comment, that is prepended before the byte array data
ba - the byte array which values are printed separated by space

print

public static void print(java.lang.String comment,
                         int[] ia)
Dumps the integer array on the system console, prepending it with the given comment, if debug is enabled. If value debug is set to true prints byte[] with comment

Parameters:
comment - the comment, that is prepended before the byte array data
ia - the byte array which values are printed separated by space

Framework Professional Edition Package


Copyright © 1999-2007 ProSyst Software GmbH. All Rights Reserved