Package org.apache.sling.resourceresolver.impl.mapping

# Class MapEntries

java.lang.Object
org.apache.sling.resourceresolver.impl.mapping.MapEntries

All Implemented Interfaces:
  `org.apache.sling.api.resource.observation.ExternalResourceChangeListener`, `org.apache.sling.api.resource.observation.ResourceChangeListener`, `MapEntriesHandler`

public class MapEntries extends Object implements MapEntriesHandler, org.apache.sling.api.resource.observation.ResourceChangeListener, org.apache.sling.api.resource.observation.ExternalResourceChangeListener

## Field Summary

Fields
Modifier and Type
Field
Description
`static final int`
`DEFAULT_DEFAULT_VANITY_PATH_REDIRECT_STATUS`
`static final String`
`DEFAULT_MAP_ROOT`
`static final String`
`PROP_REDIRECT_EXTERNAL`
`static final String`
`PROP_REDIRECT_EXTERNAL_STATUS`

### Fields inherited from interface org.apache.sling.resourceresolver.impl.mapping.MapEntriesHandler

`EMPTY`

### Fields inherited from interface org.apache.sling.api.resource.observation.ResourceChangeListener

`CHANGE_ADDED, CHANGE_CHANGED, CHANGE_PROVIDER_ADDED, CHANGE_PROVIDER_REMOVED, CHANGE_REMOVED, CHANGES, PATHS, PROPERTY_NAMES_HINT`

## Constructor Summary

Constructors
Constructor
Description
`MapEntries(MapConfigurationProvider factory, org.osgi.framework.BundleContext bundleContext, org.osgi.service.event.EventAdmin eventAdmin, StringInterpolationProvider stringInterpolationProvider, Optional<org.apache.sling.resourceresolver.impl.ResourceResolverMetrics> metrics)`

## Method Summary

Modifier and Type
Method
Description
`void`
`dispose()`
Cleans up this class.
`@NotNull Map<String,Collection<String>>`
`getAliasMap(@NotNull String parentPath)`
Returns all alias entries for children of the specified `parentPath`
`@NotNull Map<String,Collection<String>>`
`getAliasMap(@NotNull org.apache.sling.api.resource.Resource parent)`
`@NotNull Collection<MapEntry>`
`getMapMaps()`
Return a flat listing of map entries used for mapping resources to URLs
`@NotNull List<MapEntry>`
`getResolveMaps()`
Creates a flat listing of all the map entries used for resolving URLs to resources
`@NotNull Iterator<MapEntry>`
`getResolveMapsIterator(String requestPath)`
Creates an iterator over the possibly applicable mapping entries for resolving a resource
`@NotNull Map<String,List<String>>`
`getVanityPathMappings()`
Returns vanity paths mappings
`void`
`onChange(List<org.apache.sling.api.resource.observation.ResourceChange> changes)`
Handles the change to any of the node properties relevant for vanity paths or aliases mappings.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### PROP_REDIRECT_EXTERNAL

public static final String PROP_REDIRECT_EXTERNAL

See Also:
  - Constant Field Values

### PROP_REDIRECT_EXTERNAL_STATUS

public static final String PROP_REDIRECT_EXTERNAL_STATUS

See Also:
  - Constant Field Values

### DEFAULT_MAP_ROOT

public static final String DEFAULT_MAP_ROOT

See Also:
  - Constant Field Values

### DEFAULT_DEFAULT_VANITY_PATH_REDIRECT_STATUS

public static final int DEFAULT_DEFAULT_VANITY_PATH_REDIRECT_STATUS

See Also:
  - Constant Field Values

## Constructor Details

### MapEntries

public MapEntries(MapConfigurationProvider factory, org.osgi.framework.BundleContext bundleContext, org.osgi.service.event.EventAdmin eventAdmin, StringInterpolationProvider stringInterpolationProvider, Optional<org.apache.sling.resourceresolver.impl.ResourceResolverMetrics> metrics) throws org.apache.sling.api.resource.LoginException, IOException

Throws:
  `org.apache.sling.api.resource.LoginException`
  `IOException`

## Method Details

### dispose

public void dispose()
Cleans up this class.

### getResolveMaps

@NotNull public @NotNull List<MapEntry> getResolveMaps()
Description copied from interface: `MapEntriesHandler`
Creates a flat listing of all the map entries used for resolving URLs to resources

This method returns information about all resolve rules, such as vanity paths, mapping entries, virtual URLs and URL mappings.

This list is computed on-demand and therefore should not be used in performance-critical code.

Specified by:
  `getResolveMaps` in interface `MapEntriesHandler`
Returns:
  an unmodifiable, sorted, list of resolution map entries

### getResolveMapsIterator

@NotNull public @NotNull Iterator<MapEntry> getResolveMapsIterator(String requestPath)
Description copied from interface: `MapEntriesHandler`
Creates an iterator over the possibly applicable mapping entries for resolving a resource

This method uses the request path to filter out any unapplicable mapping entries and is therefore preferrable over `MapEntriesHandler.getResolveMaps()`.

The iterator will iterate over the mapping entries in the order of the pattern length.

Specified by:
  `getResolveMapsIterator` in interface `MapEntriesHandler`
Parameters:
  `requestPath` - the requestPath
Returns:
  the map entry iterator

### getMapMaps

@NotNull public @NotNull Collection<MapEntry> getMapMaps()
Description copied from interface: `MapEntriesHandler`
Return a flat listing of map entries used for mapping resources to URLs

This method returns information about all mapping rules. Note that vanity paths are excluded.

Specified by:
  `getMapMaps` in interface `MapEntriesHandler`
Returns:
  an unmodifiable collection of map entries

### getVanityPathMappings

@NotNull public @NotNull Map<String,List<String>> getVanityPathMappings()
Description copied from interface: `MapEntriesHandler`
Returns vanity paths mappings

The keys in the map are resource paths and the values are the vanity mappings.

Specified by:
  `getVanityPathMappings` in interface `MapEntriesHandler`
Returns:
  an unmodifiable list of vanity path mappings

### getAliasMap

@NotNull public @NotNull Map<String,Collection<String>> getAliasMap(@NotNull @NotNull String parentPath)
Description copied from interface: `MapEntriesHandler`
Returns all alias entries for children of the specified `parentPath`

The returned map has resource names as keys and the assigned aliases as values.

Specified by:
  `getAliasMap` in interface `MapEntriesHandler`
Parameters:
  `parentPath` - the parent path
Returns:
  a map of all child alias entries, possibly empty

### getAliasMap

@NotNull public @NotNull Map<String,Collection<String>> getAliasMap(@NotNull @NotNull org.apache.sling.api.resource.Resource parent)

Specified by:
  `getAliasMap` in interface `MapEntriesHandler`

### onChange

public void onChange(List<org.apache.sling.api.resource.observation.ResourceChange> changes)
Handles the change to any of the node properties relevant for vanity paths or aliases mappings. The `MapEntries(MapConfigurationProvider, BundleContext, EventAdmin, StringInterpolationProvider, Optional)` constructor makes sure the event listener is registered to only get appropriate events.

Specified by:
  `onChange` in interface `org.apache.sling.api.resource.observation.ResourceChangeListener`