Top Description Inners Methods
org.eclipse.jetty.util

public Interface Index<V>

Known Direct Subinterfaces
org.eclipse.jetty.util.Index.Mutable
Type Parameters
<V>
the entry type
Imports
java.nio.ByteBuffer, java.util.LinkedHashMap, .Map, .Set, java.util.function.Function, .Supplier

An immutable String lookup data structure.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
Index.Builder<
the entry type
V
>

Builder of Index instances.

public static interface
Index.Mutable<
the entry type
V
>

A mutable String lookup data structure.

Method Summary

Modifier and TypeMethod and Description
public static <
The type of the index
V
>
Index.Mutable<V>

Returns:

A case sensitive mutable Index tacking visible ASCII alphabet to a max capacity.
buildMutableVisibleAsciiAlphabet
(boolean caseSensitive, int
The max capacity of the index
maxCapacity
)

A special purpose static builder for fast creation of specific Index type

public default boolean

Returns:

true if there is a match, false otherwise
contains
(String
The key
s
)

Check if there is an exact match from a String key

public static <V> Index<V>
empty(boolean caseSensitive)

public V

Returns:

the value for the string key
get
(String
The key
s
)

Get an exact match from a String key

public V

Returns:

The value or null if not found
get
(ByteBuffer
The buffer
b
)

Get an exact match from a segment of a ByteBuffer as key

public V

Returns:

the value for the string / offset / length
get
(String
The key
s
,
int
The offset within the string of the key
offset
,
int
the length of the key
len
)

Get an exact match from a String key

public V

Returns:

The value or null if not found
get
(ByteBuffer
The buffer
b
,
int
The offset within the buffer of the key
offset
,
int
the length of the key
len
)

Get an exact match from a segment of a ByteBuffer as key

public V

Returns:

The value or null if not found
getBest
(String
The string
s
,
int
The offset within the string of the key
offset
,
int
the length of the key
len
)

Get the best match from key in a String.

public V

Returns:

The value or null if not found
getBest
(String
The string
s
)

Get the best match from key in a String, which may be a prefix match or an exact match.

public V

Returns:

The value or null if not found
getBest
(ByteBuffer
The buffer
b
,
int
The offset within the buffer of the key
offset
,
int
the length of the key
len
)

Get the best match from key in a byte buffer.

public default V

Returns:

The value or null if not found
getBest
(ByteBuffer
The buffer
b
)

Get the best match from key in a byte buffer.

public V

Returns:

The value or null if not found
getBest
(byte[]
The buffer
b
,
int
The offset within the array of the key
offset
,
int
the length of the key
len
)

Get the best match from key in a byte array.

public default V

Returns:

The value or null if not found
getBest
(byte[]
The buffer
b
)

Get the best match from key in a byte array.

public boolean

Returns:

true if the index does not contain any entry.
isEmpty
()

Check if the index contains any entry.

public Set<String>

Returns:

a Set of the keys contained in this index.
keySet
()

Get a Set of the keys contained in this index.

public int

Returns:

the index' entries count.
size
()

Get the number of entries in the index.

Method Detail

buildMutableVisibleAsciiAlphabetback to summary
public static <V> Index.Mutable<V> buildMutableVisibleAsciiAlphabet(boolean caseSensitive, int maxCapacity)

A special purpose static builder for fast creation of specific Index type

Parameters
<V>
The type of the index
maxCapacity:int

The max capacity of the index

Returns:Index.Mutable<V>

A case sensitive mutable Index tacking visible ASCII alphabet to a max capacity.

containsback to summary
public default boolean contains(String s)

Check if there is an exact match from a String key

Parameters
s:String

The key

Returns:boolean

true if there is a match, false otherwise

emptyback to summary
public static <V> Index<V> empty(boolean caseSensitive)
getback to summary
public V get(String s)

Get an exact match from a String key

Parameters
s:String

The key

Returns:V

the value for the string key

getback to summary
public V get(ByteBuffer b)

Get an exact match from a segment of a ByteBuffer as key

Parameters
b:ByteBuffer

The buffer

Returns:V

The value or null if not found

getback to summary
public V get(String s, int offset, int len)

Get an exact match from a String key

Parameters
s:String

The key

offset:int

The offset within the string of the key

len:int

the length of the key

Returns:V

the value for the string / offset / length

getback to summary
public V get(ByteBuffer b, int offset, int len)

Get an exact match from a segment of a ByteBuffer as key

Parameters
b:ByteBuffer

The buffer

offset:int

The offset within the buffer of the key

len:int

the length of the key

Returns:V

The value or null if not found

getBestback to summary
public V getBest(String s, int offset, int len)

Get the best match from key in a String.

Parameters
s:String

The string

offset:int

The offset within the string of the key

len:int

the length of the key

Returns:V

The value or null if not found

getBestback to summary
public V getBest(String s)

Get the best match from key in a String, which may be a prefix match or an exact match.

Parameters
s:String

The string

Returns:V

The value or null if not found

getBestback to summary
public V getBest(ByteBuffer b, int offset, int len)

Get the best match from key in a byte buffer. The key is assumed to by ISO_8859_1 characters.

Parameters
b:ByteBuffer

The buffer

offset:int

The offset within the buffer of the key

len:int

the length of the key

Returns:V

The value or null if not found

getBestback to summary
public default V getBest(ByteBuffer b)

Get the best match from key in a byte buffer. The key is assumed to by ISO_8859_1 characters.

Parameters
b:ByteBuffer

The buffer

Returns:V

The value or null if not found

getBestback to summary
public V getBest(byte[] b, int offset, int len)

Get the best match from key in a byte array. The key is assumed to by ISO_8859_1 characters.

Parameters
b:byte[]

The buffer

offset:int

The offset within the array of the key

len:int

the length of the key

Returns:V

The value or null if not found

getBestback to summary
public default V getBest(byte[] b)

Get the best match from key in a byte array. The key is assumed to by ISO_8859_1 characters.

Parameters
b:byte[]

The buffer

Returns:V

The value or null if not found

isEmptyback to summary
public boolean isEmpty()

Check if the index contains any entry.

Returns:boolean

true if the index does not contain any entry.

keySetback to summary
public Set<String> keySet()

Get a Set of the keys contained in this index.

Returns:Set<String>

a Set of the keys contained in this index.

sizeback to summary
public int size()

Get the number of entries in the index.

Returns:int

the index' entries count.

org.eclipse.jetty.util back to summary

public Class Index.Builder<V>

extends Object
Class Inheritance
Known Direct Subclasses
org.eclipse.jetty.util.Index.Mutable.Builder
Type Parameters
<V>
the entry type

Builder of Index instances.

Field Summary

Modifier and TypeField and Description
pack-priv boolean
pack-priv Map<String, V>

Constructor Summary

AccessConstructor and Description
public
Builder()

Create a new index builder instance.

pack-priv
Builder(boolean caseSensitive, Map<String, V> contents)

Method Summary

Modifier and TypeMethod and Description
public Index<V>

Returns:

a Index instance.
build
()

Build a Index instance.

public Index.Builder<V>

Returns:

this
caseSensitive
(boolean
true if the index has to be case-sensitive
caseSensitive
)

Configure the index to be either case-sensitive or not.

private Map<String, V>
public Index.Mutable.Builder<V>

Returns:

a Mutable.Builder configured like this builder.
mutable
()

Configure the index to be mutable.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public Index.Builder<V>

Returns:

this
with
(V
The value
value
)

Configure a pre-existing entry with a key that is the toString() representation of the value.

public Index.Builder<V>

Returns:

this
with
(String
The key
key
,
V
The value for the key string
value
)

Configure a pre-existing entry.

public Index.Builder<V>

Returns:

this
withAll
(V[]
an array of values
values
,
Function<V, String>
a Function that generates the key of each entry of the values array
keyFunction
)

Configure some pre-existing entries.

public Index.Builder<V>

Returns:

this
withAll
(Supplier<Map<String, V>>
a Map Supplier of entries
entriesSupplier
)

Configure some pre-existing entries.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

caseSensitiveback to summary
pack-priv boolean caseSensitive
contentsback to summary
pack-priv Map<String, V> contents

Constructor Detail

Builderback to summary
public Builder()

Create a new index builder instance.

Builderback to summary
pack-priv Builder(boolean caseSensitive, Map<String, V> contents)

Method Detail

buildback to summary
public Index<V> build()

Build a Index instance.

Returns:Index<V>

a Index instance.

caseSensitiveback to summary
public Index.Builder<V> caseSensitive(boolean caseSensitive)

Configure the index to be either case-sensitive or not. Default value is false.

Parameters
caseSensitive:boolean

true if the index has to be case-sensitive

Returns:Index.Builder<V>

this

contentsback to summary
private Map<String, V> contents()
mutableback to summary
public Index.Mutable.Builder<V> mutable()

Configure the index to be mutable.

Returns:Index.Mutable.Builder<V>

a Mutable.Builder configured like this builder.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
withback to summary
public Index.Builder<V> with(V value)

Configure a pre-existing entry with a key that is the toString() representation of the value.

Parameters
value:V

The value

Returns:Index.Builder<V>

this

withback to summary
public Index.Builder<V> with(String key, V value)

Configure a pre-existing entry.

Parameters
key:String

The key

value:V

The value for the key string

Returns:Index.Builder<V>

this

withAllback to summary
public Index.Builder<V> withAll(V[] values, Function<V, String> keyFunction)

Configure some pre-existing entries.

Parameters
values:V[]

an array of values

keyFunction:Function<V, String>

a Function that generates the key of each entry of the values array

Returns:Index.Builder<V>

this

withAllback to summary
public Index.Builder<V> withAll(Supplier<Map<String, V>> entriesSupplier)

Configure some pre-existing entries.

Parameters
entriesSupplier:Supplier<Map<String, V>>

a Map Supplier of entries

Returns:Index.Builder<V>

this

org.eclipse.jetty.util back to summary

public Interface Index.Mutable<V>

extends Index<V>
Known Direct Implementers
org.eclipse.jetty.util.AbstractTrie
Type Parameters
<V>
the entry type

A mutable String lookup data structure. Implementations are not thread-safe.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
Index.Mutable.Builder<
the entry type
V
>

Builder of Index.Mutable instances.

Method Summary

Modifier and TypeMethod and Description
public void
clear()

Remove all entries from the index.

public boolean

Returns:

True if the index had capacity to add the field.
put
(String
The key for the entry. Must be non null, but can be empty.
s
,
V
The value of the entry. Must be non null.
v
)

Put an entry into the index.

public boolean

Returns:

True if the Trie had capacity to add the field.
put
(V
The value and key
v
)

Put a value as both a key and a value.

public V

Returns:

The removed value of the entry
remove
(String
The key for the entry
s
)

Remove an entry from the index.

Inherited from org.eclipse.jetty.util.Index:
buildMutableVisibleAsciiAlphabetcontainsemptygetgetgetgetgetBestgetBestgetBestgetBestgetBestgetBestisEmptykeySetsize

Method Detail

clearback to summary
public void clear()

Remove all entries from the index.

putback to summary
public boolean put(String s, V v)

Put an entry into the index.

Parameters
s:String

The key for the entry. Must be non null, but can be empty.

v:V

The value of the entry. Must be non null.

Returns:boolean

True if the index had capacity to add the field.

putback to summary
public boolean put(V v)

Put a value as both a key and a value.

Parameters
v:V

The value and key

Returns:boolean

True if the Trie had capacity to add the field.

removeback to summary
public V remove(String s)

Remove an entry from the index.

Parameters
s:String

The key for the entry

Returns:V

The removed value of the entry

org.eclipse.jetty.util back to summary

public Class Index.Mutable.Builder<V>

extends Index.Builder<V>
Class Inheritance
Type Parameters
<V>
the entry type

Builder of Index.Mutable instances. Such builder cannot be directly created, it is instead returned by calling Index.Builder#mutable().

Field Summary

Modifier and TypeField and Description
private int
Inherited from org.eclipse.jetty.util.Index.Builder:
caseSensitivecontents

Constructor Summary

AccessConstructor and Description
pack-priv
Builder(boolean caseSensitive, Map<String, V> contents)

Method Summary

Modifier and TypeMethod and Description
public Index.Mutable<V>

Returns:

a Mutable instance.
build
()

Overrides org.eclipse.jetty.util.Index.Builder.build.

Build a Mutable instance.

public Index.Mutable.Builder<V>

Returns:

this
maxCapacity
(int
the maximum capacity of the index.
capacity
)

Configure a maximum capacity for the mutable index.

public Index.Mutable.Builder<V>

Returns:

a Mutable.Builder configured like this builder.
mutable
()

Overrides org.eclipse.jetty.util.Index.Builder.mutable.

Configure the index to be mutable.

Inherited from org.eclipse.jetty.util.Index.Builder:
caseSensitivetoStringwithwithwithAllwithAll

Field Detail

maxCapacityback to summary
private int maxCapacity

Constructor Detail

Builderback to summary
pack-priv Builder(boolean caseSensitive, Map<String, V> contents)

Method Detail

buildback to summary
public Index.Mutable<V> build()

Overrides org.eclipse.jetty.util.Index.Builder.build.

Build a Mutable instance.

Returns:Index.Mutable<V>

a Mutable instance.

maxCapacityback to summary
public Index.Mutable.Builder<V> maxCapacity(int capacity)

Configure a maximum capacity for the mutable index. A negative value means there is no capacity limit and the index can grow without limits. The default value is -1.

Parameters
capacity:int

the maximum capacity of the index.

Returns:Index.Mutable.Builder<V>

this

mutableback to summary
public Index.Mutable.Builder<V> mutable()

Overrides org.eclipse.jetty.util.Index.Builder.mutable.

Configure the index to be mutable.

Returns:Index.Mutable.Builder<V>

a Mutable.Builder configured like this builder.