public class TapestryInternalUtils extends Object
Modifier and Type | Field and Description |
---|---|
static Mapper<Asset,StylesheetLink> |
assetToStylesheetLink
Common mapper, used primarily with
Flow.map(org.apache.tapestry5.func.Mapper) |
Constructor and Description |
---|
TapestryInternalUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
copy(InputStream in,
OutputStream out)
Copies some content from an input stream to an output stream.
|
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 Thread[] |
getAllThreads()
Gathers together an array containing all the threads.
|
static <K,V> V |
getAndDeref(Map<K,? extends Reference<V>> map,
K key)
Extracts a value from a map of references.
|
static String |
getLabelForEnum(Messages messages,
Enum value) |
static String |
getLabelForEnum(Messages messages,
String prefix,
Enum value)
Converts an enum to a label string, allowing for overrides from a message catalog.
|
static boolean |
isEqual(EventContext left,
EventContext right) |
static <T> boolean |
isEqual(T left,
T right)
Determines if the two values are equal.
|
static String |
lastTerm(String input)
Strips a dotted sequence (such as a property expression, or a qualified class name) down to the last term of that
expression, by locating the last period ('.') in the string.
|
static Map<String,String> |
mapFromKeysAndValues(String... keysAndValues) |
static Orderable<String> |
mixinTypeAndOrder(String mixinDef) |
static KeyValue |
parseKeyValue(String input)
Parses a key/value pair where the key and the value are seperated by an equals sign.
|
static String[] |
splitAtCommas(String value)
Splits a value around commas.
|
static String[] |
splitMixinConstraints(String s) |
static String[] |
splitPath(String path)
Splits a path at each slash.
|
static Asset2 |
toAsset2(Asset asset)
Converts an Asset to an Asset2 if necessary.
|
static String |
toClassAttributeValue(List<String> classes)
Converts an list of strings into a space-separated string combining them all, suitable for use as an HTML class
attribute value.
|
static String |
toFileSuffix(String fileName) |
static InternalPropertyConduit |
toInternalPropertyConduit(PropertyConduit conduit) |
static LinkCreationListener2 |
toLinkCreationListener2(LinkCreationListener delegate) |
static OptionModel |
toOptionModel(Map.Entry input)
Converts a map entry to an
OptionModel . |
static OptionModel |
toOptionModel(Object input)
Converts an object to an
OptionModel . |
static OptionModel |
toOptionModel(String input)
Converts a string to an
OptionModel . |
static <E> List<OptionModel> |
toOptionModels(List<E> input)
Processes a list input into a series of objects compatible with
toOptionModel(Object) . |
static <K,V> List<OptionModel> |
toOptionModels(Map<K,V> input)
Processes a map input into a series of map entries compatible with
toOptionModel(Map.Entry) . |
static List<OptionModel> |
toOptionModels(String input)
Parses a string input into a series of value=label pairs compatible with
toOptionModel(String) . |
static <E> SelectModel |
toSelectModel(List<E> input)
Wraps the result of
toOptionModels(List) as a SelectModel (with no option groups). |
static <K,V> SelectModel |
toSelectModel(Map<K,V> input)
Wraps the result of
toOptionModels(Map) as a SelectModel (with no option groups). |
static SelectModel |
toSelectModel(String input)
Wraps the result of
toOptionModels(String) as a SelectModel (with no option groups). |
static String |
toUserPresentable(String id)
Capitalizes the string, and inserts a space before each upper case character (or sequence of upper case
characters).
|
public static Mapper<Asset,StylesheetLink> assetToStylesheetLink
Flow.map(org.apache.tapestry5.func.Mapper)
public TapestryInternalUtils()
public static String toUserPresentable(String id)
public static Map<String,String> mapFromKeysAndValues(String... keysAndValues)
public static OptionModel toOptionModel(String input)
OptionModel
. The string is of the form "value=label". If the equals sign is
omitted, then the same value is used for both value and label.public static List<OptionModel> toOptionModels(String input)
toOptionModel(String)
. Splits
on commas. Ignores whitespace around commas.input
- comma seperated list of termspublic static SelectModel toSelectModel(String input)
toOptionModels(String)
as a SelectModel
(with no option groups).
See TAP5-2184 for why this ends up causing some trouble!public static OptionModel toOptionModel(Map.Entry input)
OptionModel
.public static <K,V> List<OptionModel> toOptionModels(Map<K,V> input)
toOptionModel(Map.Entry)
.input
- map of elementspublic static <K,V> SelectModel toSelectModel(Map<K,V> input)
toOptionModels(Map)
as a SelectModel
(with no option groups).public static OptionModel toOptionModel(Object input)
OptionModel
.public static <E> List<OptionModel> toOptionModels(List<E> input)
toOptionModel(Object)
.input
- list of elementspublic static <E> SelectModel toSelectModel(List<E> input)
toOptionModels(List)
as a SelectModel
(with no option groups).public static KeyValue parseKeyValue(String input)
KeyValue
.public static String extractIdFromPropertyExpression(String expression)
expression
- a property expressionpublic static String defaultLabel(String id, Messages messages, String propertyExpression)
public static String lastTerm(String input)
public static String toClassAttributeValue(List<String> classes)
classes
- classes to combinepublic static String getLabelForEnum(Messages messages, String prefix, Enum value)
messages
- the messages to search for the labelprefix
- prepended to keyvalue
- to get a label forpublic static String getLabelForEnum(Messages messages, Enum value)
public static <T> boolean isEqual(T left, T right)
left
- value to compare, possibly nullright
- value to compare, possibly nullpublic static String[] splitAtCommas(String value)
public static void copy(InputStream in, OutputStream out) throws IOException
in
- source of dataout
- sink of dataIOException
public static boolean isEqual(EventContext left, EventContext right)
public static Asset2 toAsset2(Asset asset)
public static InternalPropertyConduit toInternalPropertyConduit(PropertyConduit conduit)
public static Orderable<String> mixinTypeAndOrder(String mixinDef)
mixinDef
- the original mixin definition.public static String[] splitMixinConstraints(String s)
public static LinkCreationListener2 toLinkCreationListener2(LinkCreationListener delegate)
public static String toFileSuffix(String fileName)
public static <K,V> V getAndDeref(Map<K,? extends Reference<V>> map, K key)
public static Thread[] getAllThreads()
5.6.3 - Copyright © 2003-2021 The Apache Software Foundation.