Package org.apache.wicket.resource
Class ResourceUtil
- java.lang.Object
-
- org.apache.wicket.resource.ResourceUtil
-
public class ResourceUtil extends java.lang.Object
Utilities for resources.- Author:
- Jeremy Thomerson
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ResourceReference.UrlAttributes
decodeResourceReferenceAttributes(java.lang.String encodedAttributes)
Reads resource reference attributes (style, locale, variation) encoded in the given string.static ResourceReference.UrlAttributes
decodeResourceReferenceAttributes(org.apache.wicket.request.Url url)
Reads resource reference attributes (style, locale, variation) encoded in the given URL.static java.lang.String
encodeResourceReferenceAttributes(ResourceReference.UrlAttributes attributes)
Encodes the given resource reference attributes returning the corresponding textual representation.static void
encodeResourceReferenceAttributes(org.apache.wicket.request.Url url, ResourceReference reference)
Encodes the attributes of the given resource reference in the specified url.static java.lang.CharSequence
escapeAttributesSeparator(java.lang.String attribute)
Escapes any occurrences of - character in the style and variation attributes with ~.static java.util.Locale
parseLocale(java.lang.String locale)
Parses the string representation of aLocale
(for example 'en_GB').static java.lang.String
readString(org.apache.wicket.util.resource.IResourceStream resourceStream)
read string with platform default encoding from resource streamstatic java.lang.String
readString(org.apache.wicket.util.resource.IResourceStream resourceStream, java.nio.charset.Charset charset)
read string with specified encoding from resource streamstatic java.lang.String
unescapeAttributesSeparator(java.lang.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(java.lang.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(org.apache.wicket.request.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 java.lang.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(org.apache.wicket.request.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 java.lang.CharSequence escapeAttributesSeparator(java.lang.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 java.util.Locale parseLocale(java.lang.String locale)
Parses the string representation of aLocale
(for example 'en_GB').- Parameters:
locale
- the string representation of aLocale
- Returns:
- the corresponding
Locale
instance
-
readString
public static java.lang.String readString(org.apache.wicket.util.resource.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 java.lang.String readString(org.apache.wicket.util.resource.IResourceStream resourceStream, java.nio.charset.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 java.lang.String unescapeAttributesSeparator(java.lang.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
-
-