|
Novell exteNd Director 5.2 API |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.sssw.fw.util.EboMisc
This is a utility class for some useful String operations.
Field Summary | |
static Integer |
EIGHT
Constant for '8' Integer. |
static BigDecimal |
EIGHT_BD
Constant for '8' BigDecimal. |
static Double |
EIGHT_D
Constant for '8' double. |
static Integer |
FIVE
Constant for '5' Integer. |
static BigDecimal |
FIVE_BD
Constant for '5' BigDecimal. |
static Double |
FIVE_D
Constant for '5' double. |
static Integer |
FOUR
Constant for '4' Integer. |
static BigDecimal |
FOUR_BD
Constant for '4' BigDecimal. |
static Double |
FOUR_D
Constant for '4' double. |
static int |
IDX_DURATION_HOURS
constant for hours duration index. |
static int |
IDX_DURATION_MILLIS
Constant for milliseconds duration index. |
static int |
IDX_DURATION_MINUTES
Constant for minutes duration index. |
static int |
IDX_DURATION_SECONDS
Constant for seconds duration index. |
static String[] |
m_emptyStringArray
Empty array used to return a String array of length 0 |
static Integer |
MINUS_ONE
Constant for '-1' Integer. |
static BigDecimal |
MINUS_ONE_BD
Constant for '-1' BigDecimal. |
static Double |
MINUS_ONE_D
Constant for '-1' double. |
static Integer |
NINE
Constant for '9' Integer. |
static BigDecimal |
NINE_BD
Constant for '9' BigDecimal. |
static Double |
NINE_D
Constant for '9' double. |
static Integer |
ONE
Constant for '1' Integer. |
static BigDecimal |
ONE_BD
Constant for '1' BigDecimal. |
static Double |
ONE_D
Constant for '1' double. |
static Integer |
SEVEN
Constant for '7' Integer. |
static BigDecimal |
SEVEN_BD
Constant for '7' BigDecimal. |
static Double |
SEVEN_D
Constant for '7' double. |
static Integer |
SIX
Constant for '6' Integer. |
static BigDecimal |
SIX_BD
Constant for '6' BigDecimal. |
static Double |
SIX_D
Constant for '6' double. |
static Integer |
TEN
Constant for '10' Integer. |
static BigDecimal |
TEN_BD
Constant for '10' BigDecimal. |
static Double |
TEN_D
Constant for '10' double. |
static Integer |
THREE
Constant for '3' Integer. |
static BigDecimal |
THREE_BD
Constant for '3' BigDecimal. |
static Double |
THREE_D
Constants for '3' double. |
static Integer |
TWO
Constant for '2' Integer. |
static BigDecimal |
TWO_BD
Constant for '2' BigDecimal. |
static Double |
TWO_D
Constants for '2' double. |
static Integer |
ZERO
Constant for '0' Integer. |
static BigDecimal |
ZERO_BD
Constant for '0' BigDecimal. |
static Double |
ZERO_D
Constant for '0' double. |
Constructor Summary | |
EboMisc()
|
Method Summary | |
static void |
addArrayElementsToVector(Vector v,
Object[] array)
Adds an object array elements to a Vector object. |
static Object[] |
arrayConcat(Object[] ary1,
Object[] ary2)
Concatenates one object array to another and returns a newly created resulting object array. |
static Object[] |
arrayConcat(Object[] ary1,
Object[] ary2,
Class componentType)
Concatenates one object array to another and returns a newly created resulting object array. |
static Vector |
arrayToVector(Object[] array)
Returns a Vector object containing the elements of the
given object array. |
static byte[] |
condenseBytes(byte[] bytes)
Condenses the byte array passed in by transforming each 2 bytes into a byte. |
static boolean |
contains(int[] array,
int x)
Returns true if the array contains the specified int. |
static boolean |
contains(Object[] array,
Object obj)
Returns true if the array contains the specified Object. |
static void |
deleteDirectory(File directory)
Invokes system operation to delete a directory. |
static void |
dumpBytes(byte[] bytes)
Prints the specified bytes to System.out. |
static void |
dumpBytes(byte[] bytes,
int maxLen)
Prints the bytes from a specified byte array to System.out. |
static void |
dumpStack(int lines)
Prints the first n levels of the current stack trace to System.out. |
static boolean |
emptyString(String s)
Returns true if s is null or contains only white space |
static Object[] |
enumToArray(Enumeration enum,
Class componentType)
Returns an array filled with the elements of the enumeration. |
static int |
enumToArray(Enumeration enum,
Object[] array)
Copies the values of an enumeration to an array. |
static ArrayList |
enumToArrayList(Enumeration enum)
Copies the values of an enumeration to an ArrayList. |
static int |
enumToVector(Enumeration enum,
Vector v)
Copies the values of an enumeration to a Vector. |
static boolean |
equals(byte[] array1,
byte[] array2)
Compares two byte arrays. |
static boolean |
equals(int[] array1,
int[] array2)
Compares two int arrays. |
static boolean |
equals(Object[] array1,
Object[] array2)
Compares two object arrays. |
static boolean |
equals(Object obj1,
Object obj2)
Compares the two objects. |
static File |
findFile(String path,
String fileName)
Searches the paths given for the named file. |
static BigDecimal |
getBigDecimal(int i)
Returns the BigDecimal version of 'dec'. |
static Boolean |
getBoolean(boolean b)
Returns the Boolean version of 'b'. |
static Double |
getDouble(double d)
Returns the Double version of 'd'. |
static int[] |
getDuration(long millis)
Gets an int array from a millisecond with the following int values in the int array: Hours - indexed by IDX_DURATION_HOURS Minutes - indexed by IDX_DURATION_MINUTES Seconds - indexed by IDX_DURATION_SECONDS miliseconds - indexed by IDX_DURATION_MILLIS |
static String |
getDurationDesc(long millis,
boolean skipZeros)
Gets the duration description for a milliseconds value. |
static String |
getHexString(byte[] bytes)
Returns a hex digit String from the given byte array. |
static String |
getHexString(byte[] bytes,
int len)
Returns a hex digit String from the given byte array. |
static String |
getIndent(int indentLevel)
Returns a String that represents an amount of indenting. |
static Integer |
getInteger(int i)
Returns the Integer version of 'i'. |
static int |
getIntValue(BigDecimal dec,
int defaultValue)
Returns the defaultValue, if 'dec' is null. |
static int |
getIntValue(Integer i,
int defaultValue)
Returns the defaultValue if 'i' is null. |
static String |
getLimitedString(Object value,
FontMetrics fm,
int limit,
boolean noEllipsis)
No information available |
static String |
getLimitedString(Object value,
int limit)
Returns the first 'limit' characters of the text, or up to the first newline, whichever comes first. |
static String |
getLimitedString(Object value,
int limit,
boolean noEllipsis)
No information available |
static String |
getPropSummary(Map props,
boolean nice)
Gets a summary string for a set of properties. |
static String |
getStackTrace()
Returns a String containing the current stack trace (i.e. |
static String |
getStackTrace(int skipLines)
Gets the current stack trace. |
static String |
getStackTrace(Throwable ex)
Gets a String containing current stack trace of the specified exception. |
static String |
getStackTrace(Throwable ex,
int skipLines)
Gets the stack trace from a throwable. |
static boolean |
hasAncestor(EboException ex,
Class ancestor)
Checks to see if the specified EboException has the given class as its ancestor. |
static int |
indexOf(Object[] array,
Object obj)
Returns the index of the object in the given array or -1 if not found in the array. |
static boolean |
isEachInList(Object[] list1,
Object[] list2)
Returns true if each object (testing via equals()) in the first list is in the second list. |
static boolean |
isEmpty(Object[] ary)
Returns true if the given array is null or is empty. |
static double |
log(double base,
double power)
Handy helper to supplement the a Math.log() method that only * works in base e. |
static Field |
lookupConstant(String name)
Returns a Field object representing a static final field. |
static int |
lookupIntConstant(String name)
Returns the value of a static final int field. |
static String |
lookupStringConstant(String name)
Returns the value of a static final String field. |
static String |
parseFileName(String path,
String seperator)
Parses a String that contains path and filename, and returns just the filename. |
static long |
position(byte[] array,
byte[] pattern)
Determines the byte position at which the specified byte pattern begins within the byte[]
value that this byte[] object represents. |
static String |
printValue(Object obj)
Prints the value and type of the object. |
static Object[] |
removeArrayElement(Object[] array,
int ndx)
Removes an element from an array, returning a newly created array with the element removed. |
static boolean |
safeEquals(Timestamp t1,
Timestamp t2)
Safely test two Timestamps for equality. |
static boolean |
stackContains(String s)
Returns true if 's' is present in the current stack trace. |
static boolean |
stackContains(String s,
int lines)
No information available |
static byte[] |
stretchBytes(byte[] bytes,
int len)
Stretchs the byte array passed in by transforming each byte into a pair of bytes. |
static Hashtable |
stringToHashtable(String s)
Converts a comma-separated list into a hashtable |
static int |
stringToInt(String s,
int defaultvalue)
Converts a string to an int. |
static String |
stringToUTF8(String text)
Deprecated. |
static String[] |
stringToUTF8(String[] textArray)
Deprecated. |
static String |
toUnicodeEscapeString(String str)
Converts a string to a unicode escaped string. |
static Object[] |
vectorToArray(Vector v,
Class componentType)
Copies the values of a Vector to an array. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
public static final Integer MINUS_ONE
public static final Integer ZERO
public static final Integer ONE
public static final Integer TWO
public static final Integer THREE
public static final Integer FOUR
public static final Integer FIVE
public static final Integer SIX
public static final Integer SEVEN
public static final Integer EIGHT
public static final Integer NINE
public static final Integer TEN
public static final Double MINUS_ONE_D
public static final Double ZERO_D
public static final Double ONE_D
public static final Double TWO_D
public static final Double THREE_D
public static final Double FOUR_D
public static final Double FIVE_D
public static final Double SIX_D
public static final Double SEVEN_D
public static final Double EIGHT_D
public static final Double NINE_D
public static final Double TEN_D
public static final BigDecimal MINUS_ONE_BD
public static final BigDecimal ZERO_BD
public static final BigDecimal ONE_BD
public static final BigDecimal TWO_BD
public static final BigDecimal THREE_BD
public static final BigDecimal FOUR_BD
public static final BigDecimal FIVE_BD
public static final BigDecimal SIX_BD
public static final BigDecimal SEVEN_BD
public static final BigDecimal EIGHT_BD
public static final BigDecimal NINE_BD
public static final BigDecimal TEN_BD
public static final String[] m_emptyStringArray
public static final int IDX_DURATION_HOURS
public static final int IDX_DURATION_MINUTES
public static final int IDX_DURATION_SECONDS
public static final int IDX_DURATION_MILLIS
Constructor Detail |
public EboMisc()
Method Detail |
public static final Boolean getBoolean(boolean b)
public static final Integer getInteger(int i)
public static final Double getDouble(double d)
public static final BigDecimal getBigDecimal(int i)
public static final int getIntValue(Integer i, int defaultValue)
public static final int getIntValue(BigDecimal dec, int defaultValue)
public static String getLimitedString(Object value, int limit)
public static String getLimitedString(Object value, int limit, boolean noEllipsis)
public static String getLimitedString(Object value, FontMetrics fm, int limit, boolean noEllipsis)
public static int stringToInt(String s, int defaultvalue)
s
- a string to be converted to int.defaultvalue
- a default value if the input string cannot be converted.public static boolean equals(Object obj1, Object obj2)
public static boolean equals(int[] array1, int[] array2)
public static boolean equals(byte[] array1, byte[] array2)
public static boolean equals(Object[] array1, Object[] array2)
public static Object[] arrayConcat(Object[] ary1, Object[] ary2)
* Note: the component type is determined by the component type of the * first array. If the component type must be of some base class * common to each, then use the form of arrayConcat that takes * the component type as an arg.
ary1
- the first array. This will be first in the resultary2
- the second array. This will appear after the first in the result.public static Object[] arrayConcat(Object[] ary1, Object[] ary2, Class componentType)
ary1
- the first array. This will be first in the resultary2
- the second array. This will appear after the first in the result.componentType
- the component type of the resulting array.public static Object[] removeArrayElement(Object[] array, int ndx)
array
- the array to remove an element fromndx
- the index of the object in the array to remove. If the ndx
is out of bounds then return the original array.public static Vector arrayToVector(Object[] array)
Vector
object containing the elements of the
given object array.array
- an object array whose elements will be added to the vector.Vector
object containing the elements of the
given object array.public static void addArrayElementsToVector(Vector v, Object[] array)
Vector
object.v
- a Vector
object to add the elements toarray
- an object array whose elements will be added to the vector.public static Object[] vectorToArray(Vector v, Class componentType)
vector
- a Vector
object whose elements are to be copied
into an object array.componentType
- the class of the type of element for the array. An array of
this type class will be created.Vector
object or an empty array if the Vector
object is empty.public static Object[] enumToArray(Enumeration enum, Class componentType)
public static int enumToArray(Enumeration enum, Object[] array)
enum
- the enumerationarray
- the array to copy the values to. Note that this code assumes
* that the array is big enough to house the number of elements in the enumeration.public static int enumToVector(Enumeration enum, Vector v)
enum
- the enumerationv
- the vector to copy the values to.public static ArrayList enumToArrayList(Enumeration enum)
enum
- the enumerationpublic static long position(byte[] array, byte[] pattern)
pattern
begins within the byte[]
value that this byte[]
object represents.pattern
- the byte array for which to searchpublic static boolean contains(Object[] array, Object obj)
public static int indexOf(Object[] array, Object obj)
public static boolean contains(int[] array, int x)
public static boolean isEachInList(Object[] list1, Object[] list2)
list1
- the fist object arraylist2
- the second object arraypublic static boolean isEmpty(Object[] ary)
ary
- an object array to testpublic static boolean emptyString(String s)
EboStringMisc.isEmpty
public static final String getIndent(int indentLevel)
public static Hashtable stringToHashtable(String s)
s
- a String.public static double log(double base, double power)
public static String getHexString(byte[] bytes)
bytes
- a byte arraypublic static String getHexString(byte[] bytes, int len)
bytes
- a byte array.len
- the length of the byte arraypublic static byte[] stretchBytes(byte[] bytes, int len)
bytes
- byte array to stretchlen
- the length of the new arraypublic static byte[] condenseBytes(byte[] bytes)
bytes
- byte array to condensepublic static void dumpBytes(byte[] bytes)
public static void dumpBytes(byte[] bytes, int maxLen)
bytes
- a byte array.maxLen
- a maximum length of the byte array.public static String printValue(Object obj)
public static void dumpStack(int lines)
public static boolean stackContains(String s)
public static boolean stackContains(String s, int lines)
public static String getStackTrace()
public static String getStackTrace(Throwable ex)
ex
- a throwable object.public static String getStackTrace(int skipLines)
sipLines
- a specified number of lines to be skiped for the stack trace.public static String getStackTrace(Throwable ex, int skipLines)
ex
- a throwable object.skipLines
- an int value to indicate how many lines to skip.public static int lookupIntConstant(String name) throws Exception
name
- a string to be searched.public static String lookupStringConstant(String name) throws Exception
name
- a name to be searched.public static Field lookupConstant(String name) throws Exception
Field
object representing a static final field.
'name' is the name of the field, e.g. "com.sssw.rt.util.MetaData.META_NAME"name
- a name to be searched.Field
object.public static boolean hasAncestor(EboException ex, Class ancestor)
e.g.: boolean yes = EboMisc.hasAncestor(agoex, EboDataException.class);
public static File findFile(String path, String fileName)
path
- a specified path where to locate a filefilename
- a file to be located.File
object corresponding to the first path that contains
the given file or null if the file is not found. The directories
in the path string are assumed to be separated by the platform
specific path separator character.public static String stringToUTF8(String text)
text
- a string to be convertedpublic static String[] stringToUTF8(String[] textArray)
public static String toUnicodeEscapeString(String str)
str
- a string to be converted.public static void deleteDirectory(File directory)
public static String parseFileName(String path, String seperator)
path
- a full path of a file name.seperator
- a seperatorpublic static boolean safeEquals(Timestamp t1, Timestamp t2)
t1
- the first Timestampt2
- the second Timestamppublic static String getPropSummary(Map props, boolean nice)
props
- the propertiesnice
- if true, use tabs and newlines to format the outputpublic static String getDurationDesc(long millis, boolean skipZeros)
millis
- a milliseonds valueskipZeros
- if true skips zerospublic static int[] getDuration(long millis)
|
Novell exteNd Director 5.2 API |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |