Package org.opensaml.saml.metadata.resolver.impl

# Class RegexRequestURLBuilder

java.lang.Object
org.opensaml.saml.metadata.resolver.impl.RegexRequestURLBuilder

All Implemented Interfaces:
  `Function<CriteriaSet,String>`

public class RegexRequestURLBuilder extends Object implements Function<CriteriaSet,String>
Function which produces a URL by evaluating a supplied regular expression against the criteria entity ID, and applying the result to a supplied replacement string.

The function uses standard Java regular expression components from the `java.util.regex` package. It is therefore helpful to have an understanding of the use of these Java classes.

The runtime logic is effectively:

>      Pattern pattern = Pattern.compile(regex);
>      Matcher matcher = pattern.matcher(entityID);
>      if (matcher.matches()) {
>        return matcher.replaceAll(replacement);
>      else {
>        return null;
>      }

For supported regular expression syntax see `Pattern`. For details on the replacement operation, see `Matcher.replaceAll(String)`.

It is expected that the typical use case is that the supplied replacement string will be a combination of literal text combined with back references to the regular expression match groups, e.g. $1, $2, etc.

If the regular expression does not match the entity ID, or if there is an error in evaluating the regular expression, then null is returned.

## Field Summary

Fields
Modifier and Type
Field
Description
`private final org.slf4j.Logger`
`log`
Logger.
`private final Pattern`
`pattern`
The compiled pattern.
`private final String`
`template`
The replacement template.

## Constructor Summary

Constructors
Constructor
Description
`RegexRequestURLBuilder(String regex, String replacement)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`String`
`apply(CriteriaSet criteria)`

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

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

### Methods inherited from interface java.util.function.Function

`andThen, compose`

## Field Details

### log

@Nonnull private final org.slf4j.Logger log
Logger.

### pattern

@Nonnull private final Pattern pattern
The compiled pattern.

### template

@Nonnull private final String template
The replacement template.

## Constructor Details

### RegexRequestURLBuilder

public RegexRequestURLBuilder(@Nonnull @NotEmpty String regex, @Nonnull @NotEmpty String replacement)
Constructor.

Parameters:
  `regex` - the regular expression against which to evaluate the entity ID
  `replacement` - the replacement template string.

## Method Details

### apply

@Nullable public String apply(@Nullable CriteriaSet criteria)

Specified by:
  `apply` in interface `Function<CriteriaSet,String>`