legacy
Class Helpers

java.lang.Object
  extended by legacy.Helpers

public class Helpers
extends java.lang.Object

Helpers.class defines methods and classes for reuse.

Author:
Benjamin Tarrant

Constructor Summary
Helpers()
           
 
Method Summary
static boolean classExtends(java.lang.Class sibling, java.lang.Class parent)
          c(Class,Class) determins it the first class is a sebling of the second.
static boolean classExtends(java.lang.String siblingCanonicalName, java.lang.String parentCanonicalName)
          c(Class,Class) determins it the first class is a sebling of the second.
static java.lang.String getCallerClass(int depth)
          getCallerClass() used by methods which restrice access or require knowlage of the caller of itsef.
static java.lang.String getCallerMethod(int depth)
          getCallerMethod() used by methods which restrice access or require knowlage of the caller of itsef.
static java.lang.String getExtension(java.lang.String ext)
          getExtension(String ext) returns in general the extension of a file or a sub string of the last index of "." in a string to the end of that string
static java.io.InputStream getInputStreamProtocol(java.lang.String location)
          getInputStreamProtocol(String) return a readable stream from a string location.
Allowed Protocols
jar:// ie jar://c:/path/my.jar/mypackage/myfile.txt Warning will not allow recusive jar files and oly allows acces to local storage devices
zip:// indenticle to above
file:// ie file://c:/myfile.txt where myfile.txt is located on a logical(local) device
http:// as per URL
socket://address/port ie socket://127.0.0.1/256 where a socket will stream the data from a port 256 from this machine

failing this getInputStreamProtocol will attemt to load the location as from a url or file.
static Arrays<java.lang.Integer> getIntegerArray()
          getIntegerArray() gets a casted Array<?>type for use/reuse to prevent extensive object construction
static Arrays<RGB> getRGBArray()
          getRGBArray() gets a casted Array<?>type for use/reuse to prevent extensive object construction
static void main(java.lang.String[] args)
           
static int pack(int x, int y, int z, int u)
          pack packs 4 byte values ranging from 0 to 255 into a single integer
static int[] unpack(int value)
          unpack extracts four bytes from an integer and return the values hi to low bytes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Helpers

public Helpers()
Method Detail

getRGBArray

public static Arrays<RGB> getRGBArray()
getRGBArray() gets a casted Array<?>type for use/reuse to prevent extensive object construction

Returns:
the casted Arrays<RGB>

getIntegerArray

public static Arrays<java.lang.Integer> getIntegerArray()
getIntegerArray() gets a casted Array<?>type for use/reuse to prevent extensive object construction

Returns:
the casted Arrays<Integer>

getCallerMethod

public static java.lang.String getCallerMethod(int depth)
getCallerMethod() used by methods which restrice access or require knowlage of the caller of itsef.

Parameters:
depth - how far back to look into stack
Returns:
the caller of the method define as class and method name where <init> may apply

getCallerClass

public static java.lang.String getCallerClass(int depth)
getCallerClass() used by methods which restrice access or require knowlage of the caller of itsef.

Parameters:
depth - how far back to look into stack
Returns:
the caller of the method define as class

classExtends

public static boolean classExtends(java.lang.Class sibling,
                                   java.lang.Class parent)
c(Class,Class) determins it the first class is a sebling of the second.

Parameters:
sibling - as .class ie classExtends(for.class,bar.class) Not class.getClass()
parent - as .class ie classExtends(for.class,bar.class) Not class.getClass()
Returns:
true if extension false otherwise

classExtends

public static boolean classExtends(java.lang.String siblingCanonicalName,
                                   java.lang.String parentCanonicalName)
c(Class,Class) determins it the first class is a sebling of the second.

Parameters:
siblingCanonicalName - as canonical name for
parentCanonicalName - as canonical name for
Returns:
true if extension false otherwise

getExtension

public static java.lang.String getExtension(java.lang.String ext)
getExtension(String ext) returns in general the extension of a file or a sub string of the last index of "." in a string to the end of that string

Parameters:
ext - string expected to contain an extension
Returns:
the extension

getInputStreamProtocol

public static java.io.InputStream getInputStreamProtocol(java.lang.String location)
getInputStreamProtocol(String) return a readable stream from a string location.
Allowed Protocols
jar:// ie jar://c:/path/my.jar/mypackage/myfile.txt Warning will not allow recusive jar files and oly allows acces to local storage devices
zip:// indenticle to above
file:// ie file://c:/myfile.txt where myfile.txt is located on a logical(local) device
http:// as per URL
socket://address/port ie socket://127.0.0.1/256 where a socket will stream the data from a port 256 from this machine

failing this getInputStreamProtocol will attemt to load the location as from a url or file.

Parameters:
location - we are looking at
Returns:
and imput stream for the location or null otherwise

pack

public static final int pack(int x,
                             int y,
                             int z,
                             int u)
pack packs 4 byte values ranging from 0 to 255 into a single integer

Parameters:
x - byte mask 0xFF000000
y - byte mask 0x00FF0000
z - byte mask 0x0000FF00
u - byte mask 0x000000FF
Returns:
result as 0xXXYYZZUU

unpack

public static final int[] unpack(int value)
unpack extracts four bytes from an integer and return the values hi to low bytes

Parameters:
value - to unpack
Returns:
the result array

main

public static void main(java.lang.String[] args)