Class ResourceUtil


  • @ProviderType
    public final class ResourceUtil
    extends Object
    Utils for JCR resources.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean getPropertyBoolean​(org.apache.sling.api.resource.Resource resource, String namePattern)
      Convenience method for getting a single-value boolean property from a resource.
      static Calendar getPropertyCalendar​(org.apache.sling.api.resource.Resource resource, String namePattern)
      Convenience method for getting a single-value Calendar property from a resource.
      static Date getPropertyDate​(org.apache.sling.api.resource.Resource resource, String namePattern)
      Convenience method for getting a single-value Date property from a resource.
      static BigDecimal getPropertyDecimal​(org.apache.sling.api.resource.Resource resource, String namePattern)
      Conventience method for getting a single-value BigDecimal property from a resource.
      static Double getPropertyDouble​(org.apache.sling.api.resource.Resource resource, String namePattern)
      Conventience method for getting a single-value Double property from a resource.
      static Long getPropertyLong​(org.apache.sling.api.resource.Resource resource, String namePattern)
      Conventience method for getting a single-value Long property from a resource.
      static org.apache.sling.api.resource.Resource getPropertyReference​(org.apache.sling.api.resource.Resource resource, String namePattern)
      Get a Resource from a path specified in a resource property.
      static String getPropertyString​(org.apache.sling.api.resource.Resource resource, String namePattern)
      Convenience method for getting a single-value String property from a resource.
      static List<String> getPropertyStrings​(org.apache.sling.api.resource.Resource resource, String namePattern)
      Convenience method for getting a multi-value String property from a resource.
    • Method Detail

      • getPropertyBoolean

        public static boolean getPropertyBoolean​(org.apache.sling.api.resource.Resource resource,
                                                 String namePattern)
        Convenience method for getting a single-value boolean property from a resource.
        Parameters:
        resource - The resource from which to get the property.
        namePattern - Property name.
        Returns:
        Property value if present, else false.
      • getPropertyCalendar

        public static Calendar getPropertyCalendar​(org.apache.sling.api.resource.Resource resource,
                                                   String namePattern)
        Convenience method for getting a single-value Calendar property from a resource.
        Parameters:
        resource - The resource from which to get the property.
        namePattern - Property name.
        Returns:
        Property value.
      • getPropertyDate

        public static Date getPropertyDate​(org.apache.sling.api.resource.Resource resource,
                                           String namePattern)
        Convenience method for getting a single-value Date property from a resource.
        Parameters:
        resource - The resource from which to get the property.
        namePattern - Property name.
        Returns:
        Property value.
      • getPropertyDecimal

        public static BigDecimal getPropertyDecimal​(org.apache.sling.api.resource.Resource resource,
                                                    String namePattern)
        Conventience method for getting a single-value BigDecimal property from a resource.
        Parameters:
        resource - The resource from which to get the property.
        namePattern - Property name.
        Returns:
        Property value.
      • getPropertyDouble

        public static Double getPropertyDouble​(org.apache.sling.api.resource.Resource resource,
                                               String namePattern)
        Conventience method for getting a single-value Double property from a resource.
        Parameters:
        resource - The resource from which to get the property.
        namePattern - Property name.
        Returns:
        Property value.
      • getPropertyLong

        public static Long getPropertyLong​(org.apache.sling.api.resource.Resource resource,
                                           String namePattern)
        Conventience method for getting a single-value Long property from a resource.
        Parameters:
        resource - The resource from which to get the property.
        namePattern - Property name.
        Returns:
        Property value.
      • getPropertyReference

        public static org.apache.sling.api.resource.Resource getPropertyReference​(org.apache.sling.api.resource.Resource resource,
                                                                                  String namePattern)
        Get a Resource from a path specified in a resource property. Returns null if the path cannot be resolved to a resource.
        Parameters:
        resource - The resource from which to get the property.
        namePattern - Name of the property storing the resource path.
        Returns:
        The referenced resource.
      • getPropertyString

        public static String getPropertyString​(org.apache.sling.api.resource.Resource resource,
                                               String namePattern)
        Convenience method for getting a single-value String property from a resource.
        Parameters:
        resource - The resource from which to get the property.
        namePattern - Property name.
        Returns:
        Property value.
      • getPropertyStrings

        public static List<String> getPropertyStrings​(org.apache.sling.api.resource.Resource resource,
                                                      String namePattern)
        Convenience method for getting a multi-value String property from a resource.
        Parameters:
        resource - The resource from which to get the property.
        namePattern - Property name.
        Returns:
        Property values.