Class StructuredValueMap

  • All Implemented Interfaces:
    Map<String,​Object>, org.apache.sling.api.resource.ValueMap

    public class StructuredValueMap
    extends Object
    implements org.apache.sling.api.resource.ValueMap
    A ValueMap which supports nested maps and resolves paths to properties of nested maps. This is useful if you want to use placeholders for a complex set of values, e.g. in a ValueEmbeddingReader. You can use either a path (delimiter: '/') or an object (delimiter: '.') notation, e.g. ${nested/immediate/prop} or ${nested.immediate.prop}. the path notation has precedence over the object notation, e.g. ${nested/prop.name} references the 'prop.name' property of the 'nested' map.
    • Field Detail

      • base

        protected final org.apache.sling.api.resource.ValueMap base
    • Constructor Detail

      • StructuredValueMap

        public StructuredValueMap​(Map<String,​Object> base)
    • Method Detail

      • get

        public <T> T get​(@NotNull
                         @NotNull String name,
                         @NotNull
                         @NotNull Class<T> type)
        Specified by:
        get in interface org.apache.sling.api.resource.ValueMap
      • get

        @NotNull
        public <T> T get​(@NotNull
                         @NotNull String name,
                         @NotNull
                         T defaultValue)
        Specified by:
        get in interface org.apache.sling.api.resource.ValueMap
      • put

        @Nullable
        public @Nullable Object put​(String key,
                                    Object value)
        puts a new value at the path given by the name; if path starts with '/' the path delimiter is used to build nested maps but ignored in the key
        Specified by:
        put in interface Map<String,​Object>
        Parameters:
        key - the key (the path) of the value to store
        value - the value to store
        Returns:
        the removed value; maybe 'null'
      • keySet

        @NotNull
        public @NotNull Set<String> keySet()
        Specified by:
        keySet in interface Map<String,​Object>
        Returns:
        the stripped set of keys including nested keys as paths and excluding the nested maps itself
      • values

        @NotNull
        public @NotNull Collection<Object> values()
        Specified by:
        values in interface Map<String,​Object>
        Returns:
        the stripped set of values including nested values and excluding the nested maps itself
      • _get

        protected Object _get​(@NotNull
                              @NotNull String name,
                              @Nullable
                              @Nullable Class<?> type)
      • _put

        protected Object _put​(@NotNull
                              @NotNull String name,
                              @Nullable
                              @Nullable Object value)
      • _remove

        protected Object _remove​(@NotNull
                                 @NotNull String name)
      • _containsKey

        protected boolean _containsKey​(@NotNull
                                       @NotNull String name)
      • _containsKey

        protected boolean _containsKey​(@NotNull
                                       @NotNull String name,
                                       @NotNull
                                       @NotNull Map<String,​Object> map,
                                       @NotNull
                                       @NotNull String delimiter)
      • _containsValue

        protected boolean _containsValue​(@NotNull
                                         @NotNull Object value)
      • _containsValue

        protected boolean _containsValue​(@NotNull
                                         @NotNull Object value,
                                         @NotNull
                                         @NotNull Map<String,​Object> map)