Class ResourceUtil


  • public class ResourceUtil
    extends Object
    Utilities for resources.
    Author:
    Jeremy Thomerson
    • 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​(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 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 encode
        reference -
        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 a Locale (for example 'en_GB').
        Parameters:
        locale - the string representation of a Locale
        Returns:
        the corresponding Locale instance
      • readString

        public static String readString​(org.apache.wicket.util.resource.IResourceStream resourceStream,
                                        Charset charset)
        read string with specified encoding from resource stream
        Parameters:
        resourceStream - string source
        charset - charset for the string encoding (use null 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