|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectde.folt.util.OpenTMSSupportFunctions
public class OpenTMSSupportFunctions
| Constructor Summary | |
|---|---|
OpenTMSSupportFunctions()
|
|
| Method Summary | |
|---|---|
static java.util.Hashtable<java.lang.String,java.lang.String> |
argumentReader(java.lang.String fileName)
argumentReader reads arguments from a file into a hash table |
static java.util.Hashtable<java.lang.String,java.lang.String> |
argumentReader(java.lang.String[] args)
argumentReader stores a string array which is parameter encoded as key=value in a hash table the behavior is a follows key starts with - ("-key") then the following string is the value of the key and stores as (key, value) Exception is if the value after the key starts again with "-" the key is stored as (key, key) in the hash table otherwise it is stored as (i, string) where i the string is the i-th element in the string array |
static java.util.Hashtable<java.lang.String,java.lang.String> |
argumentReader(java.lang.String[] args,
boolean combineArgs)
argumentReader stores a string array which is parameter encoded as key=value in a hash table the behavior is a follows key starts with - ("-key") then the following string is the value of the key and stores as (key, value) Exception is if the value after the key starts again with "-" the key is stored as (key, key) in the hash table otherwise it is stored as (i, string) where i the string is the i-th element in the string array |
static void |
argumentReader(java.lang.String fileName,
java.util.Hashtable<java.lang.String,java.lang.String> hashArgs)
argumentReader reads arguments from a file into a given hash table |
static java.lang.String |
checkUTF8Normal(java.lang.String file)
checkUTF8Normal checks if an xml file is UTF-8 encoded; looks "encoding=\"UTF-8\"" |
static java.lang.String |
convertToDuration(long duration)
convertToDuration converts a duration to a time string |
static boolean |
copyFile(java.io.File in,
java.io.File out)
copyFile make a copy of a file |
static boolean |
copyFile(java.lang.String inFile,
java.lang.String outFile)
copyFile make a copy of a file |
static java.lang.String |
copyFileToString(java.lang.String filename)
copyFileToString - copies the content of a file to a string (byte copy usage) encoded as Base64 |
static boolean |
copyStringToFile(java.lang.String content,
java.lang.String filename)
copyStringToFile copies a string to a file where the string is base64 encoded |
static java.lang.String |
decodeBASE64(java.lang.String string)
decodeBASE64 returns a decoded string from a Base64 encoded string |
static java.lang.String |
determineBOMFromFile(java.lang.String file)
determineBOMFromFile determines the format of a file; return values are: "UTF-8-Nobom" for a standard xml file UTF-8encoded "UTF-8" Check: (bom[0] == (byte) 0xEF) && (bom[1] == (byte) 0xBB) && (bom[2] == (byte) 0xBF)) "UTF-16BE" Check: ((bom[0] == (byte) 0xFE) && (bom[1] == (byte) 0xFF)) "UTF-16LE" Check: ((bom[0] == (byte) 0xFF) && (bom[1] == (byte) 0xFE)) "UTF-32BE" Check: ((bom[0] == (byte) 0x00) && (bom[1] == (byte) 0x00) && (bom[2] == (byte) 0xFE) && (bom[3] == (byte) 0xFF)) "UTF-32LE" Check: ((bom[0] == (byte) 0xFF) && (bom[1] == (byte) 0xFE) && (bom[2] == (byte) 0x00) && (bom[3] == (byte) 0x00)) "Nobom" otherwise |
static java.lang.String |
encodeBASE64(java.lang.String string)
encodeBASE64 returns a string as Base64 encoded string |
static java.lang.String |
exceptionToString(java.lang.Exception e)
exceptionToString writes the stack trace to a string |
static java.lang.String |
fillParam(java.util.Hashtable hash,
java.lang.String type)
fillParam |
java.util.Vector<java.lang.String> |
getAllFiles(java.lang.String sourcepath)
initial method to start getting all files in for a directory and its sub directories |
void |
getAllRecFiles(java.io.File file,
java.lang.String sourcepath)
Get all the files in the directory (file) specified and its sub directories sourcepath is the start path of file (to determine the absolute pathname for a file |
static java.lang.String |
getArgumentsConcatenationString()
|
static java.lang.String |
getCallingMethod(int iLevel)
getCallingMethod |
static java.util.Date |
getCompileDate(java.lang.Class classname)
getCompileDate get the compile time of a class |
static java.lang.String |
getCurrentDirectory()
getCurrentDirectory return the current directory |
static java.lang.reflect.Method |
getCurrentMethod()
getCurrentMethod get the method of the currently executing method |
static java.lang.String |
getCurrentMethodName()
getCurrentMethodName get the method name of the currently executing method |
static java.lang.String |
getCurrentUser()
getCurrentUser returns the currently set user = System.getProperty("user.name") |
static java.lang.String |
getDateString()
getDateString - returns a date formated as 11.08.2008 23:54:23:1234 |
static java.lang.String |
getDateStringFine()
getDateStringFine returns date as 110820082354231234 (see also getDateString) |
static java.lang.String[] |
getItemsFromFile(java.lang.String fileName)
readLanguageCodesFromFile read the language codes from a file |
static java.lang.reflect.Method |
getMethod(java.lang.String methodName,
java.lang.Class classformethod)
getMethod get the method for a given Class |
java.lang.String |
getVersionfinal(java.lang.Class classe)
getVersionfinal from http://stackoverflow.com/questions/1917686/compile-date-and-time |
static int |
iGetThreadNumber(int iMaxThreads)
iGetThreadNumber returns the number of threads to use min(Runtime.getRuntime().availableProcessors(), iMaxThreads) |
static void |
printParameterInfoFor(java.lang.reflect.Method method)
|
static java.lang.String |
quoteForCSVSExport(java.lang.String string)
quoteForCSVSExport quotes a String for CSV export LF = \n CR = \r tab = \t \ = \\ |
static java.lang.String |
quoteForCSVSExport(java.lang.String string,
java.lang.String nullValue)
quoteForCSVSExport quotes a String for CSV export LF = \n CR = \r tab = \t \ = \\ |
static java.lang.String |
readFileIntoString(java.lang.String filename,
java.lang.String encoding)
readFileIntoString reads the contents of a file into a string |
static java.util.Vector<java.lang.String> |
readFileIntoVector(java.lang.String filename,
java.lang.String encoding)
readFileIntoVector |
static java.lang.String |
removeBOMFromFile(java.lang.String file)
removeBOMFromFile removes the bom indicators from a file; problem is that Java does not handle them correctly but reads them... |
static void |
replaceStringInFile(java.lang.String filename,
java.lang.String[] oldPattern,
java.lang.String[] replPattern)
replaceStringInFile replaces a given string from an array with another string array in a file. |
static void |
replaceStringInFile(java.lang.String filename,
java.lang.String oldPattern,
java.lang.String replPattern)
replaceStringInFile replaces a given string with another string in a file |
static void |
replaceStringInFile(java.lang.String filename,
java.lang.String oldPattern,
java.lang.String replPattern,
boolean bWritePerLine,
java.lang.String unicodeEncoding)
replaceStringInFile replaces a given string with another string in a file |
static void |
replaceStringInFileMultiLine(java.lang.String filename,
java.lang.String oldPattern,
java.lang.String replPattern)
replaceStringInFile replaces a given string with another string in a file using MULTILINE regexp expressions |
static byte[] |
returnBOMFromFile(java.lang.String file)
Method determines the BOM (Byte Order Mark of a file and returns it |
static java.lang.String |
returnCurrentDate()
returnCurrentDate |
static void |
setArgumentsConcatenationString(java.lang.String argumentsConcatenationString)
|
static boolean |
simpleCopyStringToFile(java.lang.String content,
java.lang.String filename)
simpleCopyStringToFile copies a string to a file where the string is base64 encoded |
static boolean |
writeBOMToFile(java.lang.String filename,
byte[] bom)
Write a bom to a file |
static void |
writeToOut(java.io.DataOutputStream out,
java.lang.String string)
writeToOut |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public OpenTMSSupportFunctions()
| Method Detail |
|---|
public static java.util.Hashtable<java.lang.String,java.lang.String> argumentReader(java.lang.String fileName)
fileName - the name of the file containing the arguments
public static void argumentReader(java.lang.String fileName,
java.util.Hashtable<java.lang.String,java.lang.String> hashArgs)
fileName - the name of the file containing the argumentshashArgs - the hash table where to add the argumentspublic static java.util.Hashtable<java.lang.String,java.lang.String> argumentReader(java.lang.String[] args)
args - a string array which is parameter as described above
public static java.util.Hashtable<java.lang.String,java.lang.String> argumentReader(java.lang.String[] args,
boolean combineArgs)
args - a string array which is parameter as described abovecombineArgs - if true then multiple arguments following -key arg1 arg2 arg3
are concatenated into a string "arg1;arg2;arg3" otherwise
default behavior (multiple arguments get just a key counter as
key
public static java.lang.String checkUTF8Normal(java.lang.String file)
file - the file to check
public static java.lang.String convertToDuration(long duration)
duration - the duration time in seconds
public static boolean copyFile(java.io.File in,
java.io.File out)
throws java.lang.Exception
inFile - file to be copiesoutFile - target file
java.lang.Exception
public static boolean copyFile(java.lang.String inFile,
java.lang.String outFile)
throws java.lang.Exception
inFile - file to be copiesoutFile - target file
java.lang.Exceptionpublic static java.lang.String copyFileToString(java.lang.String filename)
filename - the file to copy to the string
public static boolean copyStringToFile(java.lang.String content,
java.lang.String filename)
content - the base64 encoded stringfilename - output file name
public static java.lang.String decodeBASE64(java.lang.String string)
string - the encoded string
public static java.lang.String determineBOMFromFile(java.lang.String file)
"UTF-8-Nobom" for a standard xml file UTF-8encoded "UTF-8" Check: (bom[0] == (byte) 0xEF) && (bom[1] == (byte) 0xBB) && (bom[2] == (byte) 0xBF)) "UTF-16BE" Check: ((bom[0] == (byte) 0xFE) && (bom[1] == (byte) 0xFF)) "UTF-16LE" Check: ((bom[0] == (byte) 0xFF) && (bom[1] == (byte) 0xFE)) "UTF-32BE" Check: ((bom[0] == (byte) 0x00) && (bom[1] == (byte) 0x00) && (bom[2] == (byte) 0xFE) && (bom[3] == (byte) 0xFF)) "UTF-32LE" Check: ((bom[0] == (byte) 0xFF) && (bom[1] == (byte) 0xFE) && (bom[2] == (byte) 0x00) && (bom[3] == (byte) 0x00)) "Nobom" otherwise
file -
public static java.lang.String encodeBASE64(java.lang.String string)
string - string to encode
public static java.lang.String exceptionToString(java.lang.Exception e)
e - - the exception to print
public static java.lang.String fillParam(java.util.Hashtable hash,
java.lang.String type)
hash - type -
public static java.lang.String getArgumentsConcatenationString()
public static java.lang.String getCallingMethod(int iLevel)
iLevel -
public static java.util.Date getCompileDate(java.lang.Class classname)
classname - the class name
public static java.lang.String getCurrentDirectory()
public static java.lang.reflect.Method getCurrentMethod()
public static java.lang.String getCurrentMethodName()
public static java.lang.String getCurrentUser()
public static java.lang.String getDateString()
public static java.lang.String getDateStringFine()
public static java.lang.String[] getItemsFromFile(java.lang.String fileName)
fileName - the file name to use
public static java.lang.reflect.Method getMethod(java.lang.String methodName,
java.lang.Class classformethod)
methodName - the method name as stringclassformethod - the class to search for method
public static int iGetThreadNumber(int iMaxThreads)
iMaxThreads - maximum number of threads
public static void printParameterInfoFor(java.lang.reflect.Method method)
public static java.lang.String quoteForCSVSExport(java.lang.String string)
string - the string to replace the characters in
public static java.lang.String quoteForCSVSExport(java.lang.String string,
java.lang.String nullValue)
string - the string to replace the characters innullValue - the string to use for null value
public static java.lang.String readFileIntoString(java.lang.String filename,
java.lang.String encoding)
encoding - the encoding to use; if null UTF-8 is assumed
public static java.util.Vector<java.lang.String> readFileIntoVector(java.lang.String filename,
java.lang.String encoding)
encoding -
public static java.lang.String removeBOMFromFile(java.lang.String file)
file - the file to check for the bom and possible remove it
public static void replaceStringInFile(java.lang.String filename,
java.lang.String oldPattern,
java.lang.String replPattern)
filename - filename where replacements should be doneoldPattern - the old patternreplPattern - the new pattern
public static void replaceStringInFile(java.lang.String filename,
java.lang.String[] oldPattern,
java.lang.String[] replPattern)
filename - filename where replacements should be doneoldPattern - the old pattern arrayreplPattern - the new pattern array; oldPattern size must be equals to
replPattern size
public static void replaceStringInFile(java.lang.String filename,
java.lang.String oldPattern,
java.lang.String replPattern,
boolean bWritePerLine,
java.lang.String unicodeEncoding)
filename - filename where replacements should be doneoldPattern - the old patternreplPattern - the new patternunicodeEncoding -
public static void replaceStringInFileMultiLine(java.lang.String filename,
java.lang.String oldPattern,
java.lang.String replPattern)
filename - filename where replacements should be doneoldPattern - the old patternreplPattern - the new patternpublic static byte[] returnBOMFromFile(java.lang.String file)
file -
public static java.lang.String returnCurrentDate()
public static void setArgumentsConcatenationString(java.lang.String argumentsConcatenationString)
public static boolean simpleCopyStringToFile(java.lang.String content,
java.lang.String filename)
content - the base64 encoded stringfilename - output file name
public static boolean writeBOMToFile(java.lang.String filename,
byte[] bom)
filename - the filenamebom - the bom to write to the file
public static void writeToOut(java.io.DataOutputStream out,
java.lang.String string)
out - string - public java.util.Vector<java.lang.String> getAllFiles(java.lang.String sourcepath)
file - directory where the search should start from
public void getAllRecFiles(java.io.File file,
java.lang.String sourcepath)
file - directory where the search should start fromsourcepath - sourcepath is the start path of file (to determine the
absolute pathname for a file)public java.lang.String getVersionfinal(java.lang.Class classe)
classe -
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||