Class MessageTool.TextKey

  • Enclosing class:
    MessageTool

    public class MessageTool.TextKey
    extends java.lang.Object
    Helper class to simplify tool usage when retrieving no-arg messages from the default bundle that have periods in their key.

    So instead of $text.get("forms.profile.title"),1 you can just type $text.forms.profile.title. Also, this lets you do things like:

       #if( $text.forms.profile.exists )
          #set( $profiletext = $text.forms.profile )
          <h1>$profiletext.title</h1>
          <h3>$profiletext.subtitle</h3>
       #end
     

    Since:
    VelocityTools 1.2
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.Object[] args  
      private java.lang.String bundle  
      private java.lang.String key  
      private java.util.Locale locale  
    • Constructor Summary

      Constructors 
      Constructor Description
      TextKey​(java.lang.String key, java.lang.String bundle, java.lang.Object[] args, java.util.Locale locale)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      MessageTool.TextKey bundle​(java.lang.String setme)
      Returns a new TextKey with the specified resource bundle set.
      MessageTool.TextKey clearArgs()
      This will return a new TextKey that has no arguments to be inserted into the text output.
      boolean exists()
      Checks for the existence of the key that we've built up.
      MessageTool.TextKey get​(java.lang.String appendme)
      Appends a period and the new key to the current key and returns a new TextKey instance with the combined result as its key.
      boolean getExists()
      Convenience method to allow $text.key.exists syntax.
      MessageTool.TextKey insert​(java.lang.Object addme)
      Returns a new TextKey with the specified argument to be inserted into the text output.
      MessageTool.TextKey insert​(java.lang.Object[] addme)
      Returns a new TextKey with the specified array of arguments to be inserted into the text output.
      MessageTool.TextKey insert​(java.lang.Object addme, java.lang.Object metoo)
      Returns a new TextKey with the specified arguments to be inserted into the text output.
      MessageTool.TextKey insert​(java.lang.Object addme, java.lang.Object metoo, java.lang.Object methree)
      Returns a new TextKey with the specified arguments to be inserted into the text output.
      MessageTool.TextKey insert​(java.util.List addme)
      Returns a new TextKey with the specified List of arguments to be inserted into the text output.
      MessageTool.TextKey locale​(java.util.Locale setme)
      Returns a new TextKey with the specified resource bundle set.
      java.lang.String toString()
      Renders the text output according to the collected key value, bundle, and arguments.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • key

        private final java.lang.String key
      • bundle

        private final java.lang.String bundle
      • args

        private final java.lang.Object[] args
      • locale

        private final java.util.Locale locale
    • Constructor Detail

      • TextKey

        public TextKey​(java.lang.String key,
                       java.lang.String bundle,
                       java.lang.Object[] args,
                       java.util.Locale locale)
        Since:
        VelocityTools 1.4
    • Method Detail

      • get

        public MessageTool.TextKey get​(java.lang.String appendme)
        Appends a period and the new key to the current key and returns a new TextKey instance with the combined result as its key.
      • bundle

        public MessageTool.TextKey bundle​(java.lang.String setme)
        Returns a new TextKey with the specified resource bundle set.
        Since:
        VelocityTools 1.3
      • locale

        public MessageTool.TextKey locale​(java.util.Locale setme)
        Returns a new TextKey with the specified resource bundle set.
        Since:
        VelocityTools 1.4
      • insert

        public MessageTool.TextKey insert​(java.lang.Object addme)
        Returns a new TextKey with the specified argument to be inserted into the text output. If arguments already exist for this TextKey, the new arguments will be appended to the old ones in the new TextKey that is returned.
        Since:
        VelocityTools 1.3
      • insert

        public MessageTool.TextKey insert​(java.lang.Object addme,
                                          java.lang.Object metoo)
        Returns a new TextKey with the specified arguments to be inserted into the text output. If arguments already exist for this TextKey, the new arguments will be appended to the old ones in the new TextKey that is returned.
        Since:
        VelocityTools 1.3
      • insert

        public MessageTool.TextKey insert​(java.lang.Object addme,
                                          java.lang.Object metoo,
                                          java.lang.Object methree)
        Returns a new TextKey with the specified arguments to be inserted into the text output. If arguments already exist for this TextKey, the new arguments will be appended to the old ones in the new TextKey that is returned.
        Since:
        VelocityTools 1.3
      • insert

        public MessageTool.TextKey insert​(java.util.List addme)
        Returns a new TextKey with the specified List of arguments to be inserted into the text output. If arguments already exist for this TextKey, the new arguments will be appended to the old ones in the new TextKey that is returned.
        Since:
        VelocityTools 1.3
      • insert

        public MessageTool.TextKey insert​(java.lang.Object[] addme)
        Returns a new TextKey with the specified array of arguments to be inserted into the text output. If arguments already exist for this TextKey, the new arguments will be appended to the old ones in the new TextKey that is returned.
        Since:
        VelocityTools 1.3
      • clearArgs

        public MessageTool.TextKey clearArgs()
        This will return a new TextKey that has no arguments to be inserted into the text output.
        Since:
        VelocityTools 1.3
      • getExists

        public boolean getExists()
        Convenience method to allow $text.key.exists syntax.
        Since:
        VelocityTools 1.3
      • exists

        public boolean exists()
        Checks for the existence of the key that we've built up.
        Since:
        VelocityTools 1.3
      • toString

        public java.lang.String toString()
        Renders the text output according to the collected key value, bundle, and arguments.
        Overrides:
        toString in class java.lang.Object