Package org.apache.wicket.resource
Class ResourceUtil
- java.lang.Object
-
- org.apache.wicket.resource.ResourceUtil
-
public class ResourceUtil extends Object
Utilities for resources.- Author:
- Jeremy Thomerson
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ResourceReference.UrlAttributes
decodeResourceReferenceAttributes(String encodedAttributes)
Reads resource reference attributes (style, locale, variation) encoded in the given string.static ResourceReference.UrlAttributes
decodeResourceReferenceAttributes(Url url)
Reads resource reference attributes (style, locale, variation) encoded in the given URL.static String
encodeResourceReferenceAttributes(ResourceReference.UrlAttributes attributes)
Encodes the given resource reference attributes returning the corresponding textual representation.static void
encodeResourceReferenceAttributes(Url url, ResourceReference reference)
Encodes the attributes of the given resource reference in the specified url.static CharSequence
escapeAttributesSeparator(String attribute)
Escapes any occurrences of - character in the style and variation attributes with ~.static Locale
parseLocale(String locale)
Parses the string representation of aLocale
(for example 'en_GB').static String
readString(IResourceStream resourceStream)
read string with platform default encoding from resource streamstatic String
readString(IResourceStream resourceStream, Charset charset)
read string with specified encoding from resource streamstatic String
unescapeAttributesSeparator(String attribute)
Reverts the escaping applied by escapeAttributesSeparator(String) - unescapes occurrences of ~ character in the style and variation attributes with -.
-
-
-
Method Detail
-
decodeResourceReferenceAttributes
public static ResourceReference.UrlAttributes decodeResourceReferenceAttributes(String encodedAttributes)
Reads resource reference attributes (style, locale, variation) encoded in the given string.- Parameters:
encodedAttributes
- the string containing the resource attributes- Returns:
- the encoded attributes
- See Also:
ResourceReference.UrlAttributes
-
decodeResourceReferenceAttributes
public static ResourceReference.UrlAttributes decodeResourceReferenceAttributes(Url url)
Reads resource reference attributes (style, locale, variation) encoded in the given URL.- Parameters:
url
- the url containing the resource attributes- Returns:
- the encoded attributes
- See Also:
ResourceReference.UrlAttributes
-
encodeResourceReferenceAttributes
public static String encodeResourceReferenceAttributes(ResourceReference.UrlAttributes attributes)
Encodes the given resource reference attributes returning the corresponding textual representation.- Parameters:
attributes
- the resource reference attributes to encode- Returns:
- the textual representation for the given attributes
- See Also:
ResourceReference.UrlAttributes
-
encodeResourceReferenceAttributes
public static void encodeResourceReferenceAttributes(Url url, ResourceReference reference)
Encodes the attributes of the given resource reference in the specified url.- Parameters:
url
- the resource reference attributes to encodereference
-- See Also:
ResourceReference.UrlAttributes
,Url
-
escapeAttributesSeparator
public static CharSequence escapeAttributesSeparator(String attribute)
Escapes any occurrences of - character in the style and variation attributes with ~. Any occurrence of ~ is encoded as ~~.- Parameters:
attribute
- the attribute to escape- Returns:
- the attribute with escaped separator character
-
parseLocale
public static Locale parseLocale(String locale)
Parses the string representation of aLocale
(for example 'en_GB').
-
readString
public static String readString(IResourceStream resourceStream)
read string with platform default encoding from resource stream- Parameters:
resourceStream
-- Returns:
- string read from resource stream
- See Also:
readString(org.apache.wicket.util.resource.IResourceStream, java.nio.charset.Charset)
-
readString
public static String readString(IResourceStream resourceStream, Charset charset)
read string with specified encoding from resource stream- Parameters:
resourceStream
- string sourcecharset
- charset for the string encoding (usenull
for platform default)- Returns:
- string read from resource stream
-
unescapeAttributesSeparator
public static String unescapeAttributesSeparator(String attribute)
Reverts the escaping applied by escapeAttributesSeparator(String) - unescapes occurrences of ~ character in the style and variation attributes with -.- Parameters:
attribute
- the attribute to unescape- Returns:
- the attribute with escaped separator character
-
-