Package org.freeplane.core.util
Class TextUtils
- java.lang.Object
-
- org.freeplane.core.util.TextUtils
-
public class TextUtils extends java.lang.Objectutilities for translations, conversions to/from number and dates etc. In scripts available as "global variable"textUtils.
-
-
Constructor Summary
Constructors Constructor Description TextUtils()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidcopyHtmlToClipboard(java.lang.String html)Shortcut for scripting: Copieshtmlwith mimetype text/html to the system clipboard.static voidcopyToClipboard(java.lang.String string)Shortcut for scripting: Copiesstringto the system clipboard.static org.freeplane.core.resources.TranslatedObjectcreateTranslatedString(java.lang.String key)static voidescapeUtf8(java.io.Writer out, java.lang.String str)Escapes the UTF-8 non-ASCII characters in aStringto aWriter.static java.lang.StringescapeUtf8(java.lang.String str)The escapeUtf8 method is a stripped down version of the StringEscapeUtils.escapeJava method in Commons Lang 2.6 It escapes the UTF-8 non-ASCII characters in aString.static java.lang.Stringformat(java.lang.String resourceKey, java.lang.Object... messageArguments)java.text.SimpleDateFormatgetDefaultDateFormat()accessor for scripts.java.text.SimpleDateFormatgetDefaultDateTimeFormat()accessor for scripts.java.text.DecimalFormatgetDefaultNumberFormat()accessor for scripts.static java.lang.StringgetOptionalText(java.lang.String string)static java.lang.StringgetOptionalText(java.lang.String string, java.lang.String defaultValue)static java.lang.StringgetOptionalTranslation(java.lang.String text)static java.lang.StringgetOriginalRawText(java.lang.String key)static java.lang.StringgetRawText(java.lang.String key)static java.lang.StringgetRawText(java.lang.String key, java.lang.String defaultString)static java.lang.StringgetShortText(java.lang.String text, int maximumCharacters, java.lang.String continuationMark)static java.lang.StringgetText(java.lang.String key)static java.lang.StringgetText(java.lang.String key, java.lang.String defaultString)static booleanisEmpty(java.lang.String str)static booleanisNumber(java.lang.String text)static booleanmatchesUriPattern(java.lang.String text)in opposite to the URI make scheme mandatory.static java.lang.StringremoveMnemonic(java.lang.String rawLabel)static java.lang.StringremoveTranslateComment(java.lang.String inputString)Removes the "TranslateMe" sign from the end of not translated texts.static java.lang.NumbertoNumber(java.lang.String text)
-
-
-
Method Detail
-
format
public static java.lang.String format(java.lang.String resourceKey, java.lang.Object... messageArguments)
-
getOptionalText
public static java.lang.String getOptionalText(java.lang.String string)
-
getOptionalText
public static java.lang.String getOptionalText(java.lang.String string, java.lang.String defaultValue)
-
removeMnemonic
public static java.lang.String removeMnemonic(java.lang.String rawLabel)
-
removeTranslateComment
public static java.lang.String removeTranslateComment(java.lang.String inputString)
Removes the "TranslateMe" sign from the end of not translated texts.
-
createTranslatedString
public static org.freeplane.core.resources.TranslatedObject createTranslatedString(java.lang.String key)
-
getText
public static java.lang.String getText(java.lang.String key)
-
getRawText
public static java.lang.String getRawText(java.lang.String key)
-
getOriginalRawText
public static java.lang.String getOriginalRawText(java.lang.String key)
-
getText
public static java.lang.String getText(java.lang.String key, java.lang.String defaultString)
-
getRawText
public static java.lang.String getRawText(java.lang.String key, java.lang.String defaultString)
-
getOptionalTranslation
public static java.lang.String getOptionalTranslation(java.lang.String text)
-
toNumber
public static java.lang.Number toNumber(java.lang.String text) throws java.lang.NumberFormatException- Throws:
java.lang.NumberFormatException
-
isNumber
public static boolean isNumber(java.lang.String text)
-
isEmpty
public static boolean isEmpty(java.lang.String str)
-
matchesUriPattern
public static boolean matchesUriPattern(java.lang.String text)
in opposite to the URI make scheme mandatory.
-
getShortText
public static java.lang.String getShortText(java.lang.String text, int maximumCharacters, java.lang.String continuationMark)
-
getDefaultNumberFormat
public java.text.DecimalFormat getDefaultNumberFormat()
accessor for scripts.
-
getDefaultDateFormat
public java.text.SimpleDateFormat getDefaultDateFormat()
accessor for scripts.
-
getDefaultDateTimeFormat
public java.text.SimpleDateFormat getDefaultDateTimeFormat()
accessor for scripts.
-
copyToClipboard
public static void copyToClipboard(java.lang.String string)
Shortcut for scripting: Copiesstringto the system clipboard.
-
copyHtmlToClipboard
public static void copyHtmlToClipboard(java.lang.String html)
Shortcut for scripting: Copieshtmlwith mimetype text/html to the system clipboard.
-
escapeUtf8
public static java.lang.String escapeUtf8(java.lang.String str)
The escapeUtf8 method is a stripped down version of the StringEscapeUtils.escapeJava method in Commons Lang 2.6 It escapes the UTF-8 non-ASCII characters in aString.Such a character becomes
'\\'and'u'followed by a 4 digit hex code.Any ASCII character will stay intact
Example:
input string: jalapeƱo output string: jalape\u00F1o
- Parameters:
str- String to escape values in, may be null- Returns:
- String with escaped values,
nullif null string input
-
escapeUtf8
public static void escapeUtf8(java.io.Writer out, java.lang.String str) throws java.io.IOExceptionEscapes the UTF-8 non-ASCII characters in aStringto aWriter.A
nullstring input has no effect.- Parameters:
out- Writer to write escaped string intostr- String to escape values in, may be null- Throws:
java.lang.IllegalArgumentException- if the Writer isnulljava.io.IOException- if error occurs on underlying Writer- See Also:
escapeUtf8(java.lang.String)
-
-