Class TextUtils


  • public class TextUtils
    extends java.lang.Object
    utilities 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 void copyHtmlToClipboard​(java.lang.String html)
      Shortcut for scripting: Copies html with mimetype text/html to the system clipboard.
      static void copyToClipboard​(java.lang.String string)
      Shortcut for scripting: Copies string to the system clipboard.
      static org.freeplane.core.resources.TranslatedObject createTranslatedString​(java.lang.String key)  
      static void escapeUtf8​(java.io.Writer out, java.lang.String str)
      Escapes the UTF-8 non-ASCII characters in a String to a Writer.
      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 a String.
      static java.lang.String format​(java.lang.String resourceKey, java.lang.Object... messageArguments)  
      java.text.SimpleDateFormat getDefaultDateFormat()
      accessor for scripts.
      java.text.SimpleDateFormat getDefaultDateTimeFormat()
      accessor for scripts.
      java.text.DecimalFormat getDefaultNumberFormat()
      accessor for scripts.
      static java.lang.String getOptionalText​(java.lang.String string)  
      static java.lang.String getOptionalText​(java.lang.String string, java.lang.String defaultValue)  
      static java.lang.String getOptionalTranslation​(java.lang.String text)  
      static java.lang.String getOriginalRawText​(java.lang.String key)  
      static java.lang.String getRawText​(java.lang.String key)  
      static java.lang.String getRawText​(java.lang.String key, java.lang.String defaultString)  
      static java.lang.String getShortText​(java.lang.String text, int maximumCharacters, java.lang.String continuationMark)  
      static java.lang.String getText​(java.lang.String key)  
      static java.lang.String getText​(java.lang.String key, java.lang.String defaultString)  
      static boolean isEmpty​(java.lang.String str)  
      static boolean isNumber​(java.lang.String text)  
      static boolean matchesUriPattern​(java.lang.String text)
      in opposite to the URI make scheme mandatory.
      static java.lang.String removeMnemonic​(java.lang.String rawLabel)  
      static java.lang.String removeTranslateComment​(java.lang.String inputString)
      Removes the "TranslateMe" sign from the end of not translated texts.
      static java.lang.Number toNumber​(java.lang.String text)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TextUtils

        public TextUtils()
    • 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: Copies string to the system clipboard.
      • copyHtmlToClipboard

        public static void copyHtmlToClipboard​(java.lang.String html)
        Shortcut for scripting: Copies html with 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 a String.

        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, null if null string input
      • escapeUtf8

        public static void escapeUtf8​(java.io.Writer out,
                                      java.lang.String str)
                               throws java.io.IOException
        Escapes the UTF-8 non-ASCII characters in a String to a Writer.

        A null string input has no effect.

        Parameters:
        out - Writer to write escaped string into
        str - String to escape values in, may be null
        Throws:
        java.lang.IllegalArgumentException - if the Writer is null
        java.io.IOException - if error occurs on underlying Writer
        See Also:
        escapeUtf8(java.lang.String)