|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.rapidminer.tools.Tools
public class Tools
Tools for RapidMiner.
| Field Summary | |
|---|---|
static java.lang.String[] |
availableTimeZoneNames
|
static java.lang.String[] |
FALSE_STRINGS
|
static java.lang.String |
RESOURCE_PREFIX
|
static int |
SYSTEM_TIME_ZONE
|
static java.lang.String[] |
TRUE_STRINGS
|
| Constructor Summary | |
|---|---|
Tools()
|
|
| Method Summary | |
|---|---|
static void |
addResourceSource(ResourceSource source)
Adds a new resource source. |
static boolean |
booleanValue(java.lang.String string,
boolean deflt)
|
static java.lang.Class |
classForName(java.lang.String className)
TODO: Looks like this can be replaced by Plugin.getMajorClassLoader() |
static java.lang.String |
classNameWOPackage(java.lang.Class c)
Deprecated. Call c.getSimpleName() directly. |
static void |
copy(java.io.File srcPath,
java.io.File dstPath)
|
static void |
copyStreamSynchronously(java.io.InputStream in,
java.io.OutputStream out,
boolean closeOutputStream)
Copies the contents read from the input stream to the output stream in the current thread. |
static boolean |
delete(java.io.File file)
Deletes the file. |
static boolean |
equals(java.lang.Object o1,
java.lang.Object o2)
In contrast to o1.equals(o2), this method also works with p1==null. |
static java.lang.String |
escape(java.lang.String unescaped)
Esacapes quotes, newlines, and backslashes. |
static java.lang.String |
escape(java.lang.String source,
char escapeChar,
char[] specialCharacters)
Prefixes every occurrence |
static java.lang.String |
escapeHTML(java.lang.String string)
This method will encode the given string by replacing all forbidden characters by the appropriate HTML entity. |
static java.lang.String |
escapeQuoteCharsInQuotes(java.lang.String line,
java.util.regex.Pattern separatorPattern,
char quotingChar,
char escapeChar,
boolean showWarning)
Replace quote chars in-quote characters by escapeChar+quotingChar Example: seperatorPatern = ',' , quotingChar = '"' , escapeCahr = '\\' line = '"Charles says: "Some people never go crazy, What truly horrible lives they must live"", 1968, "US"' return = '"Charles says: \"Some people never go crazy, What truly horrible lives they must live\"", "1968", "US"' |
static java.lang.String |
escapeXML(java.lang.String string)
Replaces angle brackets by html entities. |
static void |
findImplementationsInJar(java.lang.ClassLoader loader,
java.util.jar.JarFile jar,
java.lang.Class<?> superClass,
java.util.List<java.lang.String> implementations)
|
static void |
findImplementationsInJar(java.util.jar.JarFile jar,
java.lang.Class superClass,
java.util.List<java.lang.String> implementations)
|
static java.io.File |
findSourceFile(java.lang.StackTraceElement e)
|
static java.lang.String |
format(java.lang.Object value,
int valueType)
Formats the value according to the given valueType. |
static java.lang.String |
formatBytes(long numberOfBytes)
|
static java.lang.String |
formatDate(java.util.Date date)
Format date as a short time string. |
static java.lang.String |
formatDateTime(java.util.Date date)
Format date as a short time string. |
static java.lang.String |
formatDuration(long milliseconds)
Format the given amount of milliseconds as a human readable string. |
static java.lang.String |
formatIntegerIfPossible(double value)
Returns a number string with no fraction digits if possible. |
static java.lang.String |
formatIntegerIfPossible(double value,
int numberOfDigits)
Returns a number string with no fraction digits if possible. |
static java.lang.String |
formatIntegerIfPossible(double value,
int numberOfDigits,
boolean groupingCharacter)
Returns a number string with no fraction digits if possible. |
static java.lang.String |
formatNumber(double value)
Returns a formatted string of the given number (number format with usually three fraction digits). |
static java.lang.String |
formatNumber(double value,
int numberOfDigits)
Returns a formatted string of the given number (uses the property rapidminer.gui.fractiondigits.numbers if the given number of digits is smaller than 0 (usually 3)). |
static java.lang.String |
formatNumber(double value,
int numberOfDigits,
boolean groupingCharacters)
Returns a formatted string of the given number (uses the property rapidminer.gui.fractiondigits.numbers if the given number of digits is smaller than 0 (usually 3)). |
static java.lang.String |
formatPercent(double value)
Returns a formatted string of the given number (percent format with two fraction digits). |
static java.lang.String |
formatSizeInBytes(long bytes)
|
static java.lang.String |
formatTime(java.util.Date date)
Format date as a short time string. |
static java.lang.String[] |
getAllTimeZones()
|
static java.nio.charset.Charset |
getDefaultEncoding()
This method tries to identify the encoding if a GUI is running and a process is defined. |
static java.lang.String |
getExcelColumnName(int index)
Returns the column name of the the n'th column like excel names it. |
static java.io.File |
getFile(java.io.File parent,
java.lang.String name)
Creates a file relative to the given parent if name is not an absolute file name. |
static void |
getFirstToken(java.io.StreamTokenizer tokenizer)
Delivers the next token and skip empty lines. |
static java.util.Locale |
getFormatLocale()
|
static void |
getLastToken(java.io.StreamTokenizer tokenizer,
boolean endOfFileOk)
Delivers the next token and checks if its the end of line. |
static java.lang.String |
getLineSeparator()
Returns the correct line separator for the current operating system. |
static java.lang.String |
getLineSeparators(int number)
Returns the correct line separator for the current operating system concatenated for the given number of times. |
static void |
getNextToken(java.io.StreamTokenizer tokenizer)
Delivers the next token and checks for an unexpected end of line or file. |
static java.util.Calendar |
getPreferredCalendar()
|
static java.util.TimeZone |
getPreferredTimeZone()
|
static int |
getPreferredTimeZoneIndex()
|
static java.io.BufferedReader |
getReader(java.io.File file,
java.nio.charset.Charset encoding)
This method checks if the given file is a Zip file containing one entry (in case of file extension .zip). |
static java.lang.String |
getRelativePath(java.io.File firstFile,
java.io.File secondFile)
Returns the relative path of the first file resolved against the second. |
static java.net.URL |
getResource(java.lang.ClassLoader loader,
java.lang.String name)
|
static java.net.URL |
getResource(java.lang.ClassLoader loader,
java.lang.String prefix,
java.lang.String name)
|
static java.net.URL |
getResource(java.lang.String name)
Returns the desired resource. |
static java.util.TimeZone |
getTimeZone(int index)
|
static java.lang.String |
indent(int indent)
Returns a whitespace with length indent. |
static boolean |
isEqual(double d1,
double d2)
Returns true if the difference between both numbers is smaller than IS_ZERO. |
static boolean |
isGreater(double d1,
double d2)
Returns true if the d1 is greater than d2 and they are not equal. |
static boolean |
isGreaterEqual(double d1,
double d2)
Returns true if the d1 is greater than d1 or both are equal, or if one of the values is NaN |
static boolean |
isLess(double d1,
double d2)
Returns true if the d1 is less than d2 and they are not equal. |
static boolean |
isLessEqual(double d1,
double d2)
Returns true if the d1 is less than d1 or both are equal. |
static boolean |
isNotEqual(double d1,
double d2)
Returns no isEqual(double, double). |
static boolean |
isZero(double d)
Returns isEqual(double, double) for d and 0. |
static java.lang.Process |
launchFileEditor(java.io.File file,
int line)
|
static java.lang.String[] |
mergeQuotedSplits(java.lang.String line,
java.lang.String[] splittedTokens,
java.lang.String quoteString)
Deprecated. Please use quotedSplit(String, Pattern, char, char) or quotedSplit(String, Pattern)
instead |
static java.lang.String |
ordinalNumber(int n)
Returns the name for an ordinal number. |
static void |
prependResourceSource(ResourceSource source)
Adds a new resource source before the others. |
static java.lang.String[] |
quotedSplit(java.lang.String line,
java.util.regex.Pattern separatorPattern)
Splits the given line according to the given separator pattern while only those separators will be regarded not lying inside of a quoting string. |
static java.lang.String[] |
quotedSplit(java.lang.String line,
java.util.regex.Pattern separatorPattern,
char quotingChar,
char escapeChar)
Splits the given line according to the given separator pattern while only those separators will be regarded not lying inside of a quoting string. |
static java.lang.String |
readOutput(java.io.BufferedReader in)
Reads the output of the reader and delivers it as string. |
static java.lang.String |
readTextFile(java.io.File file)
Reads a text file into a single string. |
static java.lang.String |
readTextFile(java.io.InputStream in)
|
static java.lang.String |
readTextFile(java.io.Reader r)
|
static byte[] |
readUrl(java.net.URL url)
This method will return a byte array containing the raw data from the given url. |
static java.lang.String |
removeAllLineSeparators(java.lang.String text)
Removes all possible line feed character combinations. |
static void |
sendEmail(java.lang.String address,
java.lang.String subject,
java.lang.String content)
Deprecated. Use MailUtilities.sendEmail(String,String,String) instead |
static void |
setFormatLocale(java.util.Locale locale)
|
static java.lang.String |
toString(java.util.Collection<?> collection)
As toString(Collection, String) with ", ". |
static java.lang.String |
toString(java.util.Collection<?> collection,
java.lang.String separator)
Returns a string containing the toString()-representation of the elements of collection, separated by the given separator. |
static java.lang.String |
toString(java.lang.Object[] collection)
|
static java.lang.String |
toString(java.lang.Object[] collection,
java.lang.String separator)
|
static java.lang.String |
transformAllLineSeparators(java.lang.String text)
Replaces all possible line feed character combinations by "\n". |
static java.lang.String |
unescape(java.lang.String escaped)
|
static java.util.List<java.lang.String> |
unescape(java.lang.String source,
char escapeChar,
char[] specialCharacters,
char splitCharacter)
Splits the string at every split character unless escaped. |
static java.util.List<java.lang.String> |
unescape(java.lang.String source,
char escapeChar,
char[] specialCharacters,
char splitCharacter,
int splitLimit)
Splits the string at every split character unless escaped. |
static void |
waitForEOL(java.io.StreamTokenizer tokenizer)
Skips all tokens before next end of line (EOL). |
static void |
waitForProcess(Operator operator,
java.lang.Process process,
java.lang.String name)
Waits for process to die and writes log messages. |
static void |
writeTextFile(java.io.File file,
java.lang.String text)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String RESOURCE_PREFIX
public static java.lang.String[] availableTimeZoneNames
public static final int SYSTEM_TIME_ZONE
public static final java.lang.String[] TRUE_STRINGS
public static final java.lang.String[] FALSE_STRINGS
| Constructor Detail |
|---|
public Tools()
| Method Detail |
|---|
public static void setFormatLocale(java.util.Locale locale)
public static java.util.Locale getFormatLocale()
public static java.lang.String[] getAllTimeZones()
public static java.util.TimeZone getTimeZone(int index)
public static java.util.TimeZone getPreferredTimeZone()
public static int getPreferredTimeZoneIndex()
public static java.util.Calendar getPreferredCalendar()
public static java.lang.String format(java.lang.Object value,
int valueType)
value - valueType -
public static java.lang.String formatPercent(double value)
public static java.lang.String formatNumber(double value)
public static java.lang.String formatNumber(double value,
int numberOfDigits)
public static java.lang.String formatNumber(double value,
int numberOfDigits,
boolean groupingCharacters)
public static java.lang.String formatIntegerIfPossible(double value)
public static java.lang.String formatIntegerIfPossible(double value,
int numberOfDigits)
public static java.lang.String formatIntegerIfPossible(double value,
int numberOfDigits,
boolean groupingCharacter)
public static java.lang.String formatTime(java.util.Date date)
public static java.lang.String formatDate(java.util.Date date)
public static java.lang.String formatDateTime(java.util.Date date)
public static java.lang.String formatDuration(long milliseconds)
public static java.lang.String ordinalNumber(int n)
public static boolean isEqual(double d1,
double d2)
public static boolean isZero(double d)
isEqual(double, double) for d and 0.
public static boolean isNotEqual(double d1,
double d2)
isEqual(double, double).
public static boolean isGreater(double d1,
double d2)
public static boolean isGreaterEqual(double d1,
double d2)
public static boolean isLess(double d1,
double d2)
public static boolean isLessEqual(double d1,
double d2)
public static java.lang.String getLineSeparator()
public static java.lang.String getLineSeparators(int number)
public static java.lang.String transformAllLineSeparators(java.lang.String text)
public static java.lang.String removeAllLineSeparators(java.lang.String text)
@Deprecated public static java.lang.String classNameWOPackage(java.lang.Class c)
public static java.lang.String readOutput(java.io.BufferedReader in)
throws java.io.IOException
java.io.IOException
public static java.io.File getFile(java.io.File parent,
java.lang.String name)
public static java.io.BufferedReader getReader(java.io.File file,
java.nio.charset.Charset encoding)
throws java.io.IOException
java.io.IOExceptionpublic static java.nio.charset.Charset getDefaultEncoding()
RapidMiner.PROPERTY_RAPIDMINER_GENERAL_DEFAULT_ENCODING. If this is not possible, this method just
returns the default system encoding.
public static java.lang.String getRelativePath(java.io.File firstFile,
java.io.File secondFile)
throws java.io.IOException
java.io.IOException
public static void waitForProcess(Operator operator,
java.lang.Process process,
java.lang.String name)
throws OperatorException
OperatorException
@Deprecated
public static void sendEmail(java.lang.String address,
java.lang.String subject,
java.lang.String content)
MailUtilities.sendEmail(String,String,String) instead
public static void addResourceSource(ResourceSource source)
public static void prependResourceSource(ResourceSource source)
public static java.net.URL getResource(java.lang.ClassLoader loader,
java.lang.String name)
public static java.net.URL getResource(java.lang.ClassLoader loader,
java.lang.String prefix,
java.lang.String name)
public static java.net.URL getResource(java.lang.String name)
public static java.lang.String readTextFile(java.io.InputStream in)
throws java.io.IOException
java.io.IOException
public static java.lang.String readTextFile(java.io.File file)
throws java.io.IOException
java.io.IOException
public static java.lang.String readTextFile(java.io.Reader r)
throws java.io.IOException
java.io.IOException
public static void writeTextFile(java.io.File file,
java.lang.String text)
throws java.io.IOException
java.io.IOException
public static boolean booleanValue(java.lang.String string,
boolean deflt)
public static java.io.File findSourceFile(java.lang.StackTraceElement e)
public static java.lang.Process launchFileEditor(java.io.File file,
int line)
throws java.io.IOException
java.io.IOExceptionpublic static java.lang.String escapeXML(java.lang.String string)
public static java.lang.String escapeHTML(java.lang.String string)
public static void findImplementationsInJar(java.util.jar.JarFile jar,
java.lang.Class superClass,
java.util.List<java.lang.String> implementations)
public static void findImplementationsInJar(java.lang.ClassLoader loader,
java.util.jar.JarFile jar,
java.lang.Class<?> superClass,
java.util.List<java.lang.String> implementations)
public static java.lang.Class classForName(java.lang.String className)
throws java.lang.ClassNotFoundException
Plugin.getMajorClassLoader()
java.lang.ClassNotFoundException
public static java.lang.String[] quotedSplit(java.lang.String line,
java.util.regex.Pattern separatorPattern)
public static java.lang.String[] quotedSplit(java.lang.String line,
java.util.regex.Pattern separatorPattern,
char quotingChar,
char escapeChar)
@Deprecated
public static java.lang.String[] mergeQuotedSplits(java.lang.String line,
java.lang.String[] splittedTokens,
java.lang.String quoteString)
throws java.io.IOException
quotedSplit(String, Pattern, char, char) or quotedSplit(String, Pattern)
instead
line - the original linesplittedTokens - the tokens as they were originally splittedquoteString - the string which should be used as quote indicator, e.g. " or '
java.io.IOException - if an open quote was not ended
public static void getFirstToken(java.io.StreamTokenizer tokenizer)
throws java.io.IOException
java.io.IOException
public static void getLastToken(java.io.StreamTokenizer tokenizer,
boolean endOfFileOk)
throws java.io.IOException
java.io.IOException
public static void getNextToken(java.io.StreamTokenizer tokenizer)
throws java.io.IOException
java.io.IOException
public static void waitForEOL(java.io.StreamTokenizer tokenizer)
throws java.io.IOException
java.io.IOExceptionpublic static boolean delete(java.io.File file)
public static void copy(java.io.File srcPath,
java.io.File dstPath)
throws java.io.IOException
java.io.IOExceptionpublic static java.lang.String indent(int indent)
public static java.lang.String formatBytes(long numberOfBytes)
public static void copyStreamSynchronously(java.io.InputStream in,
java.io.OutputStream out,
boolean closeOutputStream)
throws java.io.IOException
closeOutputStream -
java.io.IOExceptionpublic static java.lang.String escape(java.lang.String unescaped)
public static java.lang.String getExcelColumnName(int index)
index - the index of the column
public static java.lang.String escapeQuoteCharsInQuotes(java.lang.String line,
java.util.regex.Pattern separatorPattern,
char quotingChar,
char escapeChar,
boolean showWarning)
public static java.lang.String unescape(java.lang.String escaped)
public static java.lang.String toString(java.util.Collection<?> collection)
toString(Collection, String) with ", ".
public static java.lang.String toString(java.util.Collection<?> collection,
java.lang.String separator)
public static java.lang.String toString(java.lang.Object[] collection)
public static java.lang.String toString(java.lang.Object[] collection,
java.lang.String separator)
public static java.lang.String formatSizeInBytes(long bytes)
public static byte[] readUrl(java.net.URL url)
public static java.lang.String escape(java.lang.String source,
char escapeChar,
char[] specialCharacters)
public static java.util.List<java.lang.String> unescape(java.lang.String source,
char escapeChar,
char[] specialCharacters,
char splitCharacter)
public static java.util.List<java.lang.String> unescape(java.lang.String source,
char escapeChar,
char[] specialCharacters,
char splitCharacter,
int splitLimit)
public static boolean equals(java.lang.Object o1,
java.lang.Object o2)
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||