|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectit.unimo.dbgroup.momis.tools.Tools
Collection of various useful static tools methods.
| Constructor Summary | |
Tools()
|
|
| Method Summary | |
static java.lang.String |
bundedStringCreate(java.util.Collection c,
java.lang.String boundary)
Converts a Collection of strings in a single string formatted with a mime like formalism: The first line contains a boundary that separates string example: |
static java.util.Vector |
bundedStringDecode(java.lang.String bounded)
a single string formatted with a mime like formalism in a Vector of strings. |
static java.lang.String |
getLastFieldBySeparator(java.lang.String s,
char separator)
|
static java.lang.String |
getObjectInfo(java.lang.Object o)
Return information about the given object Information are: - class name - list of public methods |
static boolean |
isReadable(java.lang.String fileName)
Tests if a file exists and is redable. |
static java.lang.String |
leggiFile(java.lang.String fileName)
Reads a file and put it in a string using a StringBuffer. |
static byte[] |
leggiFileB(java.lang.String fileName)
Reads a file and put it into an array of Bytes. |
static void |
main(java.lang.String[] args)
Routine used to test the class. |
static java.lang.Object |
mdeserialize(byte[] strm)
Routine used for Object deserialization |
static java.lang.Object |
mDeserialize64(java.lang.String strm)
Routine used for Object deserialization |
static byte[] |
mserialize(java.lang.Object ser)
Routine used for Object serialization |
static java.lang.String |
mSerialize64(java.lang.Object ser)
Serializae an Object in a base64 String. |
static java.util.Map |
readConfFile(java.lang.String fileName)
Parse a simple configuration file. |
static void |
scriviFile(java.lang.String fileName,
byte[] buf)
Write the content of an array of bytes in a file. |
static void |
scriviFile(java.lang.String fileName,
java.lang.String s)
Write the content of a string in a file. |
static java.util.Vector |
splitString(java.lang.String s,
char separator)
Split a string separated by the "separator" char in single strings. |
static java.lang.String |
stringCenterAndPad(java.lang.String sinput,
int length)
Returns a string of the given length, centering the given string. |
static java.lang.String |
stringInsertAnte(java.lang.String s,
java.lang.String cante)
Add characters before each line of a string. |
static java.lang.String |
stringReplaceInString(java.lang.String sin,
java.lang.String sold,
java.lang.String snew)
in a strings, replace a given pattern with one other. |
static java.lang.String |
stringStackTrace(java.lang.Exception e)
Return the stack trace of an exception in a string. |
static java.lang.String |
stripAnsi(java.lang.String sin)
Strips the ANSI char from a string. |
static java.lang.String |
stripCrtlM(java.lang.String sin)
Strips the ^M char in the given string. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public Tools()
| Method Detail |
public static java.lang.String leggiFile(java.lang.String fileName)
fileName - name of the file to be read.
public static void scriviFile(java.lang.String fileName,
java.lang.String s)
fileName - name of the file to be written.s - file content.public static byte[] leggiFileB(java.lang.String fileName)
fileName - name of the file to be read.
public static void scriviFile(java.lang.String fileName,
byte[] buf)
fileName - name of the file to be written.buf - file content.public static java.lang.String getObjectInfo(java.lang.Object o)
public static java.lang.String stripAnsi(java.lang.String sin)
sin - string to be cleaned.public static java.lang.String stripCrtlM(java.lang.String sin)
sin - string to be cleaned.
public static java.lang.String stringCenterAndPad(java.lang.String sinput,
int length)
sinput - string to be centered.length - length of the ouput string.public static java.util.Map readConfFile(java.lang.String fileName)
Example of configuration file:
# # Configuration file test # # param1=first parameter param2=10 param3=test other1=o1 other2=02 stop=stop
fileName - name of the configuration file.
public static boolean isReadable(java.lang.String fileName)
fileName - name of the file to be read.
public static byte[] mserialize(java.lang.Object ser)
ser - Object have to serialize
public static java.lang.Object mdeserialize(byte[] strm)
[9 Mar 2000, Alberto Corni] removed deprecations
strm - Input string with serialized objectpublic static java.lang.String mSerialize64(java.lang.Object ser)
ser - Object to serialize
public static java.lang.Object mDeserialize64(java.lang.String strm)
[9 Mar 2000, Alberto Corni] removed deprecations
strm - Input string with serialized object
public static java.lang.String stringInsertAnte(java.lang.String s,
java.lang.String cante)
s - string to convert.cante - characters to antepone.
public static java.lang.String stringStackTrace(java.lang.Exception e)
public static java.util.Vector splitString(java.lang.String s,
char separator)
s - the string to splitseparator - the character separator of the various strings
public static java.lang.String stringReplaceInString(java.lang.String sin,
java.lang.String sold,
java.lang.String snew)
sin - string to be modified.sold - The string to replacesnew - The string to replace with
public static java.lang.String bundedStringCreate(java.util.Collection c,
java.lang.String boundary)
----thisIsTheBoundaryLine------- this is the string at the first position ----thisIsTheBoundaryLine------- this is the string at the Second position ----thisIsTheBoundaryLine------- this is the string at the last position
public static java.util.Vector bundedStringDecode(java.lang.String bounded)
public static java.lang.String getLastFieldBySeparator(java.lang.String s,
char separator)
public static void main(java.lang.String[] args)
Tests the tools.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||