/** * 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). * * @param expression a property expression * @return the expression with punctuation removed */ public static String extractIdFromPropertyExpression(String expression) { return InternalCommonsUtils.extractIdFromPropertyExpression(expression); }
/** * Returns true if the input is null, or is a zero length string (excluding leading/trailing whitespace). */ public static boolean isBlank(String input) { return InternalCommonsUtils.isBlank(input); }
public PropertyModel label(String label) { assert InternalCommonsUtils.isNonBlank(label); this.label = label; return this; }
/** * 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. */ public static String defaultLabel(String id, Messages messages, String propertyExpression) { String key = id + "-label"; if (messages.contains(key)) return messages.get(key); return toUserPresentable(extractIdFromPropertyExpression(InternalCommonsUtils.lastTerm(propertyExpression))); }
/** * Creates a sorted copy of the provided elements, then turns that into a comma separated list. * * @return the elements converted to strings, sorted, joined with comma ... or "(none)" if the elements are null or * empty */ public static String joinSorted(Collection elements) { return InternalCommonsUtils.joinSorted(elements); }
public PropertyModelImpl(BeanModel model, String name, PropertyConduit conduit, Messages messages) { this.model = model; this.name = name; this.conduit = conduit; id = InternalCommonsUtils.extractIdFromPropertyExpression(name); label = InternalCommonsUtils.defaultLabel(id, messages, name); // TAP5-2305 if (conduit != null) { Sortable sortableAnnotation = conduit.getAnnotation(Sortable.class); if (sortableAnnotation != null) { sortable = sortableAnnotation.value(); } else { // Primitive types need to be converted to wrapper types before checking to see // if they are sortable. Class wrapperType = PlasticUtils.toWrapperType(getPropertyType()); sortable = Comparable.class.isAssignableFrom(wrapperType); } } }
/** * Joins together some number of elements to form a comma separated list. */ public static String join(List elements) { return InternalCommonsUtils.join(elements); }
/** * 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). * * @param method * @return short string representation */ public static String asString(Method method) { return InternalCommonsUtils.asString(method); }
/** * 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. * * @param map * to store value into * @param key * for which a value is added * @param value * to add * @param <K> * the type of key * @param <V> * the type of the list */ public static <K, V> void addToMapList(Map<K, List<V>> map, K key, V value) { InternalCommonsUtils.addToMapList(map, key, value); }
/** * Sniffs the object to see if it is a {@link Location} or {@link Locatable}. Returns null if null or not * convertable to a location. */ public static Location locationOf(Object location) { return InternalCommonsUtils.locationOf(location); }
/** * 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. */ public static String defaultLabel(String id, Messages messages, String propertyExpression) { return InternalCommonsUtils.defaultLabel(id, messages, propertyExpression); }
/** * 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. */ public static String lastTerm(String input) { return InternalCommonsUtils.lastTerm(input); }
/** * Creates a sorted copy of the provided elements, then turns that into a comma separated list. * * @return the elements converted to strings, sorted, joined with comma ... or "(none)" if the elements are null or * empty */ public static String joinSorted(Collection elements) { return InternalCommonsUtils.joinSorted(elements); }
/** * Joins together some number of elements to form a comma separated list. */ public static String join(List elements) { return InternalCommonsUtils.join(elements, ", "); }
/** * 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). * * @param method * @return short string representation */ public static String asString(Method method) { return InternalCommonsUtils.asString(method); }
/** * 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. * * @param map * to store value into * @param key * for which a value is added * @param value * to add * @param <K> * the type of key * @param <V> * the type of the list */ public static <K, V> void addToMapList(Map<K, List<V>> map, K key, V value) { InternalCommonsUtils.addToMapList(map, key, value); }
/** * Sniffs the object to see if it is a {@link Location} or {@link Locatable}. Returns null if null or not * convertable to a location. */ public static Location locationOf(Object location) { return InternalCommonsUtils.locationOf(location); }
/** * 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. */ public static String defaultLabel(String id, Messages messages, String propertyExpression) { return InternalCommonsUtils.defaultLabel(id, messages, propertyExpression); }
/** * 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. */ public static String lastTerm(String input) { return InternalCommonsUtils.lastTerm(input); }
public static boolean isNonBlank(String input) { return InternalCommonsUtils.isNonBlank(input); }