Class ResourceType


  • public final class ResourceType
    extends java.lang.Object
    The ResourceType encapsulates details about a Sling resource type and provides methods for parsing resource type strings.

    The following patterns are supported for parsing:

    1. a/b/c - path-based
    2. a/b/c/1.0.0 - path-based, versioned
    3. a.b.c - Java package name
    4. a.b.c/1.0.0 - Java package name, versioned
    5. a - flat (sub-set of path-based)
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object obj)  
      @NotNull java.lang.String getResourceLabel()
      Returns a resource type's label.
      @NotNull java.lang.String getType()
      Returns the resource type string, without any version information.
      @Nullable org.osgi.framework.Version getVersion()
      Returns the version, if available.
      int hashCode()  
      static @NotNull ResourceType parseResourceType​(@NotNull java.lang.String resourceTypeString)
      Given a resourceTypeString, this method will extract a ResourceType object.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Method Detail

      • getResourceLabel

        @NotNull
        public @NotNull java.lang.String getResourceLabel()
        Returns a resource type's label. The label is important for script selection, since it will provide the name of the main script for this resource type. For more details check the Apache Sling URL to Script Resolution page
        Returns:
        the resource type label
      • getType

        @NotNull
        public @NotNull java.lang.String getType()
        Returns the resource type string, without any version information.
        Returns:
        the resource type string
      • getVersion

        @Nullable
        public @Nullable org.osgi.framework.Version getVersion()
        Returns the version, if available.
        Returns:
        the version, if available; null otherwise
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • parseResourceType

        @NotNull
        public static @NotNull ResourceType parseResourceType​(@NotNull
                                                              @NotNull java.lang.String resourceTypeString)
        Given a resourceTypeString, this method will extract a ResourceType object.

        The accepted patterns are:

        1. a/b/c - path-based
        2. a/b/c/1.0.0 - path-based, versioned
        3. a.b.c - Java package name
        4. a.b.c/1.0.0 - Java package name, versioned
        5. a - flat (sub-set of path-based)
        Parameters:
        resourceTypeString - the resource type string to parse
        Returns:
        a ResourceType object
        Throws:
        java.lang.IllegalArgumentException - if the resourceTypeString cannot be parsed
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object