Class ContentPolicyStyle

  • All Implemented Interfaces:
    Style, java.util.Map<java.lang.String,​java.lang.Object>, ValueMap

    public class ContentPolicyStyle
    extends java.lang.Object
    implements Style
    A compatibility wrapper using a content policy as a style. The goal is to use components using the currentStyle binding with the new content policies, without the need to change the component. This will not be a complete style implementation but rather focuses on the reading of the map values.
    Since:
    6.1
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface java.util.Map

        java.util.Map.Entry<K extends java.lang.Object,​V extends java.lang.Object>
    • Field Summary

      • Fields inherited from interface org.apache.sling.api.resource.ValueMap

        EMPTY
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()  
      boolean containsKey​(java.lang.Object o)  
      boolean containsValue​(java.lang.Object o)  
      java.util.Set<java.util.Map.Entry<java.lang.String,​java.lang.Object>> entrySet()  
      java.lang.Object get​(java.lang.Object o)  
      <T> T get​(java.lang.String name, java.lang.Class<T> type)
      Return named value converted to type T or null if not existing.
      <T> T get​(java.lang.String name, T defaultValue)
      return named value converted to the type T of the default value or the default value if the named value does not exist
      Cell getCell()
      Returns the cell of this style
      java.lang.String getDefiningPath​(java.lang.String name)
      Returns the cell path that defines the style property with the given name.
      Resource getDefiningResource​(java.lang.String name)
      Returns the resource that defines the style property with the given name.
      Design getDesign()
      Returns the design this style is defined in.
      java.lang.String getPath()
      Returns the path to this cell resource
      Style getSubStyle​(java.lang.String relPath)
      Returns a sub style for the give one, by virtually extending the cell stack.
      boolean isEmpty()  
      java.util.Set<java.lang.String> keySet()  
      java.lang.Object put​(java.lang.String s, java.lang.Object o)  
      void putAll​(java.util.Map<? extends java.lang.String,​?> map)  
      java.lang.Object remove​(java.lang.Object o)  
      int size()  
      java.util.Collection<java.lang.Object> values()  
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.Map

        compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
    • Constructor Detail

      • ContentPolicyStyle

        public ContentPolicyStyle​(ContentPolicy contentPolicy,
                                  Cell cell)
    • Method Detail

      • getDesign

        public Design getDesign()
        Description copied from interface: Style
        Returns the design this style is defined in.
        Specified by:
        getDesign in interface Style
        Returns:
        the design.
      • getPath

        public java.lang.String getPath()
        Description copied from interface: Style
        Returns the path to this cell resource
        Specified by:
        getPath in interface Style
        Returns:
        the path
      • getCell

        public Cell getCell()
        Description copied from interface: Style
        Returns the cell of this style
        Specified by:
        getCell in interface Style
        Returns:
        the cell
      • get

        public <T> T get​(java.lang.String name,
                         java.lang.Class<T> type)
        Description copied from interface: Style
        Return named value converted to type T or null if not existing. Please note that this also supports a Resource class as type in order to retrieve a style resource (e.g. image)
        Specified by:
        get in interface Style
        Specified by:
        get in interface ValueMap
        Type Parameters:
        T - The class of the type
        Parameters:
        name - the name of the property or resource
        type - The class of the type
        Returns:
        Return named value converted to type T or null if non existing or can't be converted.
      • get

        public <T> T get​(java.lang.String name,
                         T defaultValue)
        Description copied from interface: Style
        return named value converted to the type T of the default value or the default value if the named value does not exist
        Specified by:
        get in interface Style
        Specified by:
        get in interface ValueMap
        Type Parameters:
        T - The expected type
        Parameters:
        name - the name of the property
        defaultValue - the default value
        Returns:
        the value.
      • getDefiningResource

        public Resource getDefiningResource​(java.lang.String name)
        Description copied from interface: Style
        Returns the resource that defines the style property with the given name.
        Specified by:
        getDefiningResource in interface Style
        Parameters:
        name - name of the style property
        Returns:
        resource or null
      • getDefiningPath

        public java.lang.String getDefiningPath​(java.lang.String name)
        Description copied from interface: Style
        Returns the cell path that defines the style property with the given name.
        Specified by:
        getDefiningPath in interface Style
        Parameters:
        name - name of the style property
        Returns:
        path or null
      • getSubStyle

        public Style getSubStyle​(java.lang.String relPath)
        Description copied from interface: Style
        Returns a sub style for the give one, by virtually extending the cell stack.
        Specified by:
        getSubStyle in interface Style
        Parameters:
        relPath - relative path of the sub style.
        Returns:
        the new style
      • size

        public int size()
        Specified by:
        size in interface java.util.Map<java.lang.String,​java.lang.Object>
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface java.util.Map<java.lang.String,​java.lang.Object>
      • containsKey

        public boolean containsKey​(java.lang.Object o)
        Specified by:
        containsKey in interface java.util.Map<java.lang.String,​java.lang.Object>
      • containsValue

        public boolean containsValue​(java.lang.Object o)
        Specified by:
        containsValue in interface java.util.Map<java.lang.String,​java.lang.Object>
      • get

        public java.lang.Object get​(java.lang.Object o)
        Specified by:
        get in interface java.util.Map<java.lang.String,​java.lang.Object>
      • put

        public java.lang.Object put​(java.lang.String s,
                                    java.lang.Object o)
        Specified by:
        put in interface java.util.Map<java.lang.String,​java.lang.Object>
      • remove

        public java.lang.Object remove​(java.lang.Object o)
        Specified by:
        remove in interface java.util.Map<java.lang.String,​java.lang.Object>
      • putAll

        public void putAll​(java.util.Map<? extends java.lang.String,​?> map)
        Specified by:
        putAll in interface java.util.Map<java.lang.String,​java.lang.Object>
      • clear

        public void clear()
        Specified by:
        clear in interface java.util.Map<java.lang.String,​java.lang.Object>
      • keySet

        public java.util.Set<java.lang.String> keySet()
        Specified by:
        keySet in interface java.util.Map<java.lang.String,​java.lang.Object>
      • values

        public java.util.Collection<java.lang.Object> values()
        Specified by:
        values in interface java.util.Map<java.lang.String,​java.lang.Object>
      • entrySet

        public java.util.Set<java.util.Map.Entry<java.lang.String,​java.lang.Object>> entrySet()
        Specified by:
        entrySet in interface java.util.Map<java.lang.String,​java.lang.Object>