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

# Class Mapping

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

public class Mapping extends Object
The `Mapping` class conveys the mapping configuration used by the `ResourceResolverFactoryImpl`.

## Field Summary

Fields
Modifier and Type
Field
Description
`static final int`
`BOTH`
defines the 'both' direction
`static final Mapping`
`DIRECT`
Simple mapper instance mapping path to URLs 1:1 in both directions
`static final int`
`INBOUND`
defines the 'inbound' direction, that is mapping request path to item path
`static final int`
`OUTBOUND`
defined the 'outbound' direction, that is mapping item path to URL path

## Constructor Summary

Constructors
Constructor
Description
`Mapping(String config)`
`Mapping(String[] parts)`

## Method Summary

Modifier and Type
Method
Description
`String`
`getFrom()`
`String`
`getTo()`
`String`
`mapHandle(String handle)`
Replaces the prefix from by the new prefix to, if and only if `handle` starts with the from prefix.
`boolean`
`mapsInbound()`
Checks, if this mapping is defined for inbound mapping.
`boolean`
`mapsOutbound()`
Checks, if this mapping is defined for outbound mapping.
`String`
`mapUri(String uriPath)`
Replaces the prefix to by the new prefix from, if and only if `uriPath` starts with the to prefix.
`static String[]`
`split(String map)`
`String`
`toString()`

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

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

## Field Details

### INBOUND

public static final int INBOUND
defines the 'inbound' direction, that is mapping request path to item path

See Also:
  - Constant Field Values

### OUTBOUND

public static final int OUTBOUND
defined the 'outbound' direction, that is mapping item path to URL path

See Also:
  - Constant Field Values

### BOTH

public static final int BOTH
defines the 'both' direction

See Also:
  - Constant Field Values

### DIRECT

public static final Mapping DIRECT
Simple mapper instance mapping path to URLs 1:1 in both directions

## Constructor Details

### Mapping

public Mapping(String config)

### Mapping

public Mapping(String[] parts)

## Method Details

### toString

public String toString()

Overrides:
  `toString` in class `Object`

### mapUri

public String mapUri(String uriPath)
Replaces the prefix to by the new prefix from, if and only if `uriPath` starts with the to prefix. If `uriPath` does not start with the to prefix, or if this mapping is not defined as a 'inward' mapping, `null` is returned.

Parameters:
  `uriPath` - The URI path for which to replace the to prefix by the from prefix.
Returns:
  The string after replacement or `null` if the `uriPath` does not start with the to prefix, or `mapsInbound()` returns `false`.

### mapHandle

public String mapHandle(String handle)
Replaces the prefix from by the new prefix to, if and only if `handle` starts with the from prefix. If `uriPath` does not start with the from prefix, or if this mapping is not defined as a 'outward' mapping, `null` is returned.

Parameters:
  `handle` - The URI path for which to replace the from prefix by the to prefix.
Returns:
  The string after replacement or `null` if the `handle` does not start with the from prefix, or `mapsOutbound()` returns `false`.

### getFrom

public String getFrom()

### getTo

public String getTo()

### mapsInbound

public boolean mapsInbound()
Checks, if this mapping is defined for inbound mapping.

Returns:
  `true` if this mapping is defined for inbound mapping; `false` otherwise

### mapsOutbound

public boolean mapsOutbound()
Checks, if this mapping is defined for outbound mapping.

Returns:
  `true` if this mapping is defined for outbound mapping; `false` otherwise

### split

public static String[] split(String map)