Package org.apache.tapestry5.commons.internal.util

# Class InternalCommonsUtils

java.lang.Object
org.apache.tapestry5.commons.internal.util.InternalCommonsUtils

public class InternalCommonsUtils extends Object
Utility methods class for the Commons package.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final AnnotationProvider`
  `NULL_ANNOTATION_PROVIDER`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `InternalCommonsUtils()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static <K, V> void`
  `addToMapList(Map<K,List<V>> map, K key, V value)`
  Adds a value to a specially organized map where the values are lists of objects.
  `static String`
  `asString(Method method)`
  Converts a method to a user presentable string consisting of the containing class name, the method name, and the short form of the parameter list (the class name of each parameter type, shorn of the package name portion).
  `static String`
  `capitalize(String input)`
  Capitalizes a string, converting the first character to uppercase.
  `static boolean`
  `containsSymbols(String input)`
  Return true if the input string contains the marker for symbols that must be expanded.
  `static String`
  `defaultLabel(String id, Messages messages, String propertyExpression)`
  Looks for a label within the messages based on the id.
  `static String`
  `extractIdFromPropertyExpression(String expression)`
  Used to convert a property expression into a key that can be used to locate various resources (Blocks, messages, etc.).
  `static boolean`
  `isNonBlank(String input)`
  `static String`
  `join(List elements)`
  Joins together some number of elements to form a comma separated list.
  `static String`
  `join(List elements, String separator)`
  Joins together some number of elements.
  `static String`
  `joinSorted(Collection elements)`
  Creates a sorted copy of the provided elements, then turns that into a comma separated list.
  `static String`
  `lastTerm(String input)`
  Searches the string for the final period ('.') character and returns everything after that.
  `static Location`
  `locationOf(Object location)`
  Sniffs the object to see if it is a `Location` or `Locatable`.
  `static String`
  `replace(String input, Pattern pattern, String replacement)`
  `static List<String>`
  `sortedKeys(Map map)`
  Extracts the string keys from a map and returns them in sorted order.
  `static String`
  `stripMemberName(String memberName)`
  Strips leading "_" and "$" and trailing "_" from the name.
  `static AnnotationProvider`
  `toAnnotationProvider(Class element)`
  `static AnnotationProvider`
  `toAnnotationProvider(Method element)`
  `static String`
  `toUserPresentable(String id)`
  Capitalizes the string, and inserts a space before each upper case character (or sequence of upper case characters).

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### NULL_ANNOTATION_PROVIDER

    public static final AnnotationProvider NULL_ANNOTATION_PROVIDER
    Since:
      5.3

- ## Constructor Details

  - ### InternalCommonsUtils

    public InternalCommonsUtils()

- ## Method Details

  - ### addToMapList

    public static <K, V> void addToMapList(Map<K,List<V>> map, K key, V value)
    Adds a value to a specially organized map where the values are lists of objects. This somewhat simulates a map that allows multiple values for the same key.
    Type Parameters:
      `K` - the type of key
      `V` - the type of the list
    Parameters:
      `map` - to store value into
      `key` - for which a value is added
      `value` - to add

  - ### locationOf

    public static Location locationOf(Object location)
    Sniffs the object to see if it is a `Location` or `Locatable`. Returns null if null or not convertable to a location.

  - ### toAnnotationProvider

    public static AnnotationProvider toAnnotationProvider(Method element)

  - ### extractIdFromPropertyExpression

    public static String extractIdFromPropertyExpression(String expression)
    Used to convert a property expression into a key that can be used to locate various resources (Blocks, messages, etc.). Strips out any punctuation characters, leaving just words characters (letters, number and the underscore).
    Parameters:
      `expression` - a property expression
    Returns:
      the expression with punctuation removed

  - ### replace

    public static String replace(String input, Pattern pattern, String replacement)

  - ### defaultLabel

    public static String defaultLabel(String id, Messages messages, String propertyExpression)
    Looks for a label within the messages based on the id. If found, it is used, otherwise the name is converted to a user presentable form.

  - ### toUserPresentable

    public static String toUserPresentable(String id)
    Capitalizes the string, and inserts a space before each upper case character (or sequence of upper case characters). Thus "userId" becomes "User Id", etc. Also, converts underscore into space (and capitalizes the following word), thus "user_id" also becomes "User Id".

  - ### toAnnotationProvider

    public static AnnotationProvider toAnnotationProvider(Class element)
    Since:
      5.3

  - ### asString

    public static String asString(Method method)
    Converts a method to a user presentable string consisting of the containing class name, the method name, and the short form of the parameter list (the class name of each parameter type, shorn of the package name portion).
    Parameters:
      `method` -
    Returns:
      short string representation

  - ### stripMemberName

    public static String stripMemberName(String memberName)
    Strips leading "_" and "$" and trailing "_" from the name.

  - ### join

    public static String join(List elements)
    Joins together some number of elements to form a comma separated list.

  - ### join

    public static String join(List elements, String separator)
    Joins together some number of elements. If a value in the list is the empty string, it is replaced with the string "(blank)".
    Parameters:
      `elements` - objects to be joined together
      `separator` - used between elements when joining

  - ### joinSorted

    public static String joinSorted(Collection elements)
    Creates a sorted copy of the provided elements, then turns that into a comma separated list.
    Returns:
      the elements converted to strings, sorted, joined with comma ... or "(none)" if the elements are null or empty

  - ### capitalize

    public static String capitalize(String input)
    Capitalizes a string, converting the first character to uppercase.

  - ### isNonBlank

    public static boolean isNonBlank(String input)

  - ### containsSymbols

    public static boolean containsSymbols(String input)
    Return true if the input string contains the marker for symbols that must be expanded.

  - ### lastTerm

    public static String lastTerm(String input)
    Searches the string for the final period ('.') character and returns everything after that. The input string is generally a fully qualified class name, though tapestry-core also uses this method for the occasional property expression (which is also dot separated). Returns the input string unchanged if it does not contain a period character.

  - ### sortedKeys

    public static List<String> sortedKeys(Map map)
    Extracts the string keys from a map and returns them in sorted order. The keys are converted to strings.
    Parameters:
      `map` - the map to extract keys from (may be null)
    Returns:
      the sorted keys, or the empty set if map is null