Top Description Fields Constructors Methods
org.eclipse.jetty.http.pathmap

public Class PathMappings<E>

extends AbstractMap<PathSpec, E>
implements Iterable<MappedResource<E>>, Dumpable, Predicate<String>
Class Inheritance
All Implemented Interfaces
java.util.function.Predicate, org.eclipse.jetty.util.component.Dumpable, java.lang.Iterable
Annotations
@ManagedObject:Path Mappings
Type Parameters
<E>
the type of mapping endpoint
Imports
java.io.IOException, java.util.AbstractMap, .ArrayList, .Collections, .HashMap, .Iterator, .List, .Map, .Set, .TreeSet, java.util.function.Predicate, java.util.stream.Stream, org.eclipse.jetty.util.Index, org.eclipse.jetty.util.annotation.ManagedAttribute, .ManagedObject, org.eclipse.jetty.util.component.Dumpable, org.slf4j.Logger, .LoggerFactory

Path Mappings of PathSpec to Resource.

Sorted into search order upon entry into the Set

Field Summary

Modifier and TypeField and Description
private final Map<String, MappedResource<E>>
private final Set<MappedResource<E>>
private boolean
private boolean
private boolean
private boolean
_orderIsSignificant

When _orderIsSignificant is true, the order of the MappedResources is significant and a match needs to be iteratively tried against each mapping (ordered by group then add order) to find the first that matches.

private final Index.Mutable<MappedResource<E>>
private MappedResource<E>
private MappedResource<E>
private final Index.Mutable<MappedResource<E>>
private static final Logger
private static final int

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private boolean
public String
public void
dump(Appendable
The appendable to dump to
out
,
String
The indent to apply after any new lines.
indent
)

Implements org.eclipse.jetty.util.component.Dumpable.dump.

Dump this object (and children) into an Appendable using the provided indent after any new lines.
public Set<Map.Entry<PathSpec, E>>
entrySet()

Implements abstract java.util.AbstractMap.entrySet.

Implements java.util.Map.entrySet.

Returns a Set view of the mappings contained in this map.
public E
get(Object
the key whose associated value is to be returned
key
)

Overrides java.util.AbstractMap.get.

Implements java.util.Map.get.

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.
public E
get(PathSpec pathSpec)

public List<MappedResource<E>>
public MatchedResource<E>

Returns:

A MatchedResource instance or null if no mappings matched.
getMatched
(String
The path to match
path
)

Find the best single match for a path.

private MatchedResource<E>

Returns:

A MatchedResource instance or null if no mappings matched.
getMatchedIteratively
(String
The path to match.
path
)

Iterate over all mappings, returning the first that matches.

public List<MatchedResource<E>>

Returns:

the list of mapped resource the path matches on
getMatchedList
(String
the path to return matches on
path
)

Return a list of MatchedResource matches for the specified path.

public List<MappedResource<E>>

Returns:

the list of mapped resource the path matches on
getMatches
(String
the path to return matches on
path
)

Return a list of MappedResource matches for the specified path.

public Iterator<MappedResource<E>>
iterator()

Implements java.lang.Iterable.iterator.

Returns an iterator over elements of type T.
private boolean
public E
put(String
key with which the specified value is to be associated
pathSpecString
,
E
value to be associated with the specified key
resource
)

Overrides java.util.AbstractMap.put.

Implements java.util.Map.put.

Associates the specified value with the specified key in this map (optional operation).
public E
put(PathSpec
key with which the specified value is to be associated
pathSpec
,
E
value to be associated with the specified key
resource
)

Overrides java.util.AbstractMap.put.

Implements java.util.Map.put.

Associates the specified value with the specified key in this map (optional operation).
public E
remove(Object
key whose mapping is to be removed from the map
key
)

Overrides java.util.AbstractMap.remove.

Implements java.util.Map.remove.

Removes the mapping for a key from this map if it is present (optional operation).
public E
remove(PathSpec pathSpec)

public boolean
public void
public int
size()

Overrides java.util.AbstractMap.size.

Implements java.util.Map.size.

Returns the number of key-value mappings in this map.
public Stream<MappedResource<E>>
public boolean

Returns:

true if the path matches
test
(String
the path to return matches on
path
)

Implements java.util.function.Predicate.test.

Test if the mappings contains a specified path.
public String
toString()

Overrides java.util.AbstractMap.toString.

Returns a string representation of this map.
Inherited from java.util.AbstractMap:
clearclonecontainsKeycontainsValueequalshashCodeisEmptykeySetputAllvalues

Field Detail

_exactMapback to summary
private final Map<String, MappedResource<E>> _exactMap
_mappingsback to summary
private final Set<MappedResource<E>> _mappings
_optimizedExactback to summary
private boolean _optimizedExact
_optimizedPrefixback to summary
private boolean _optimizedPrefix
_optimizedSuffixback to summary
private boolean _optimizedSuffix
_orderIsSignificantback to summary
private boolean _orderIsSignificant

When _orderIsSignificant is true, the order of the MappedResources is significant and a match needs to be iteratively tried against each mapping (ordered by group then add order) to find the first that matches.

_prefixMapback to summary
private final Index.Mutable<MappedResource<E>> _prefixMap
_servletDefaultback to summary
private MappedResource<E> _servletDefault
_servletRootback to summary
private MappedResource<E> _servletRoot
_suffixMapback to summary
private final Index.Mutable<MappedResource<E>> _suffixMap
LOGback to summary
private static final Logger LOG
PREFIX_TAIL_LENback to summary
private static final int PREFIX_TAIL_LEN

Constructor Detail

PathMappingsback to summary
public PathMappings()

Method Detail

canBeOptimizedback to summary
private boolean canBeOptimized(PathSpecGroup suffixGlob)
dumpback to summary
public String dump()

Overrides default org.eclipse.jetty.util.component.Dumpable.dump.

Annotations
@Override
dumpback to summary
public void dump(Appendable out, String indent) throws IOException

Implements org.eclipse.jetty.util.component.Dumpable.dump.

Doc from org.eclipse.jetty.util.component.Dumpable.dump.

Dump this object (and children) into an Appendable using the provided indent after any new lines. The indent should not be applied to the first object dumped.

Parameters
out:Appendable

The appendable to dump to

indent:String

The indent to apply after any new lines.

Annotations
@Override
Exceptions
IOException:
if unable to write to Appendable
entrySetback to summary
public Set<Map.Entry<PathSpec, E>> entrySet()

Implements abstract java.util.AbstractMap.entrySet.

Implements java.util.Map.entrySet.

Doc from java.util.Map.entrySet.

Returns a Set view of the mappings contained in this map. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress (except through the iterator's own remove operation, or through the setValue operation on a map entry returned by the iterator) the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Set.remove, removeAll, retainAll and clear operations. It does not support the add or addAll operations.

Returns:Set<Map.Entry<PathSpec, E>>

a set view of the mappings contained in this map

Annotations
@Override
getback to summary
public E get(Object key)

Overrides java.util.AbstractMap.get.

Implements java.util.Map.get.

Doc from java.util.AbstractMap.get.

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

More formally, if this map contains a mapping from a key k to a value v such that Objects.equals(key, k), then this method returns v; otherwise it returns null. (There can be at most one such mapping.)

If this map permits null values, then a return value of null does not necessarily indicate that the map contains no mapping for the key; it's also possible that the map explicitly maps the key to null. The containsKey operation may be used to distinguish these two cases.

Parameters
key:Object

Doc from java.util.Map.get.

the key whose associated value is to be returned

Returns:E

Doc from java.util.Map.get.

the value to which the specified key is mapped, or null if this map contains no mapping for the key

Annotations
@Override
getback to summary
public E get(PathSpec pathSpec)
getMappingsback to summary
public List<MappedResource<E>> getMappings()
Annotations
@ManagedAttribute:mappings
readonly:true
getMatchedback to summary
public MatchedResource<E> getMatched(String path)

Find the best single match for a path.

The match may be found by optimized direct lookups when possible, otherwise all mappings are iterated over and the first match returned

Parameters
path:String

The path to match

Returns:MatchedResource<E>

A MatchedResource instance or null if no mappings matched.

See Also
getMatchedIteratively(String)
getMatchedIterativelyback to summary
private MatchedResource<E> getMatchedIteratively(String path)

Iterate over all mappings, returning the first that matches.

Parameters
path:String

The path to match.

Returns:MatchedResource<E>

A MatchedResource instance or null if no mappings matched.

See Also
getMatched(String)
getMatchedListback to summary
public List<MatchedResource<E>> getMatchedList(String path)

Return a list of MatchedResource matches for the specified path.

Parameters
path:String

the path to return matches on

Returns:List<MatchedResource<E>>

the list of mapped resource the path matches on

getMatchesback to summary
public List<MappedResource<E>> getMatches(String path)

Return a list of MappedResource matches for the specified path.

Parameters
path:String

the path to return matches on

Returns:List<MappedResource<E>>

the list of mapped resource the path matches on

iteratorback to summary
public Iterator<MappedResource<E>> iterator()

Implements java.lang.Iterable.iterator.

Doc from java.lang.Iterable.iterator.

Returns an iterator over elements of type T.

Returns:Iterator<MappedResource<E>>

an Iterator.

Annotations
@Override
nonServletPathSpecback to summary
private boolean nonServletPathSpec()
putback to summary
public E put(String pathSpecString, E resource)

Overrides java.util.AbstractMap.put.

Implements java.util.Map.put.

Doc from java.util.AbstractMap.put.

Associates the specified value with the specified key in this map (optional operation). If the map previously contained a mapping for the key, the old value is replaced by the specified value. (A map m is said to contain a mapping for a key k if and only if m.containsKey(k) would return true.)

Parameters
pathSpecString:String

Doc from java.util.Map.put.

key with which the specified value is to be associated

resource:E

Doc from java.util.Map.put.

value to be associated with the specified key

Returns:E

Doc from java.util.Map.put.

the previous value associated with key, or null if there was no mapping for key. (A null return can also indicate that the map previously associated null with key, if the implementation supports null values.)

putback to summary
public E put(PathSpec pathSpec, E resource)

Overrides java.util.AbstractMap.put.

Implements java.util.Map.put.

Doc from java.util.AbstractMap.put.

Associates the specified value with the specified key in this map (optional operation). If the map previously contained a mapping for the key, the old value is replaced by the specified value. (A map m is said to contain a mapping for a key k if and only if m.containsKey(k) would return true.)

Parameters
pathSpec:PathSpec

Doc from java.util.Map.put.

key with which the specified value is to be associated

resource:E

Doc from java.util.Map.put.

value to be associated with the specified key

Returns:E

Doc from java.util.Map.put.

the previous value associated with key, or null if there was no mapping for key. (A null return can also indicate that the map previously associated null with key, if the implementation supports null values.)

Annotations
@Override
removeback to summary
public E remove(Object key)

Overrides java.util.AbstractMap.remove.

Implements java.util.Map.remove.

Doc from java.util.AbstractMap.remove.

Removes the mapping for a key from this map if it is present (optional operation). More formally, if this map contains a mapping from key k to value v such that Objects.equals(key, k), that mapping is removed. (The map can contain at most one such mapping.)

Returns the value to which this map previously associated the key, or null if the map contained no mapping for the key.

If this map permits null values, then a return value of null does not necessarily indicate that the map contained no mapping for the key; it's also possible that the map explicitly mapped the key to null.

The map will not contain a mapping for the specified key once the call returns.

Parameters
key:Object

Doc from java.util.Map.remove.

key whose mapping is to be removed from the map

Returns:E

Doc from java.util.Map.remove.

the previous value associated with key, or null if there was no mapping for key.

Annotations
@Override
removeback to summary
public E remove(PathSpec pathSpec)
removeIfback to summary
public boolean removeIf(Predicate<MappedResource<E>> predicate)
resetback to summary
public void reset()
sizeback to summary
public int size()

Overrides java.util.AbstractMap.size.

Implements java.util.Map.size.

Doc from java.util.AbstractMap.size.

Returns the number of key-value mappings in this map. If the map contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.

Returns:int

Doc from java.util.Map.size.

the number of key-value mappings in this map

streamResourcesback to summary
public Stream<MappedResource<E>> streamResources()
testback to summary
public boolean test(String path)

Implements java.util.function.Predicate.test.

Test if the mappings contains a specified path.

Parameters
path:String

the path to return matches on

Returns:boolean

true if the path matches

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.util.AbstractMap.toString.

Doc from java.util.AbstractMap.toString.

Returns a string representation of this map. The string representation consists of a list of key-value mappings in the order returned by the map's entrySet view's iterator, enclosed in braces ("{}"). Adjacent mappings are separated by the characters ", " (comma and space). Each key-value mapping is rendered as the key followed by an equals sign ("=") followed by the associated value. Keys and values are converted to strings as by String#valueOf(Object).

Returns:String

a string representation of this map

Annotations
@Override