Top Description Inners Constructors Methods
io.netty5.handler.codec

public final Class HeadersUtils

extends Object
Class Inheritance
Imports
java.util.AbstractCollection, .AbstractList, .Collection, .Iterator, .List, .Map.Entry, .Set

Provides utility methods related to Headers.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private abstract static class
private static class
private static class
private static class

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static <K, V> List<String>

Returns:

a List of header values or an empty List if no values are found.
getAllAsString
(Headers<K, V, ?> headers, K
the name of the header to retrieve
name
)

Headers#get(Object) and convert each element of List to a String.

public static <K, V> String

Returns:

the first header value if the header is found. null if there's no such entry.
getAsString
(Headers<K, V, ?>
the headers to get the name from
headers
,
K
the name of the header to retrieve
name
)

Headers#get(Object) and convert the result to a String.

public static Iterator<Map.Entry<String, String>>
iteratorAsString(Iterable<Map.Entry<CharSequence, CharSequence>> headers)

Headers#iterator() which converts each Entry's key and value to a String.

public static Set<String>

Returns:

a Set of header values or an empty Set if no values are found.
namesAsString
(Headers<CharSequence, CharSequence, ?>
the headers to get the names from
headers
)

Headers#names() and convert each element of Set to a String.

public static <K, V> String

Returns:

a String representation of the headers
toString
(Class<?>
the class of headers
headersClass
,
Iterator<Map.Entry<K, V>>
the iterator on the actual headers
headersIt
,
int
the size of the iterator
size
)

Helper for implementing toString for DefaultHeaders and wrappers such as DefaultHttpHeaders.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

HeadersUtilsback to summary
private HeadersUtils()

Method Detail

getAllAsStringback to summary
public static <K, V> List<String> getAllAsString(Headers<K, V, ?> headers, K name)

Headers#get(Object) and convert each element of List to a String.

Parameters
name:K

the name of the header to retrieve

Returns:List<String>

a List of header values or an empty List if no values are found.

getAsStringback to summary
public static <K, V> String getAsString(Headers<K, V, ?> headers, K name)

Headers#get(Object) and convert the result to a String.

Parameters
headers:Headers<K, V, ?>

the headers to get the name from

name:K

the name of the header to retrieve

Returns:String

the first header value if the header is found. null if there's no such entry.

iteratorAsStringback to summary
public static Iterator<Map.Entry<String, String>> iteratorAsString(Iterable<Map.Entry<CharSequence, CharSequence>> headers)

Headers#iterator() which converts each Entry's key and value to a String.

namesAsStringback to summary
public static Set<String> namesAsString(Headers<CharSequence, CharSequence, ?> headers)

Headers#names() and convert each element of Set to a String.

Parameters
headers:Headers<CharSequence, CharSequence, ?>

the headers to get the names from

Returns:Set<String>

a Set of header values or an empty Set if no values are found.

toStringback to summary
public static <K, V> String toString(Class<?> headersClass, Iterator<Map.Entry<K, V>> headersIt, int size)

Helper for implementing toString for DefaultHeaders and wrappers such as DefaultHttpHeaders.

Parameters
headersClass:Class<?>

the class of headers

headersIt:Iterator<Map.Entry<K, V>>

the iterator on the actual headers

size:int

the size of the iterator

Returns:String

a String representation of the headers

io.netty5.handler.codec back to summary

private final Class HeadersUtils.CharSequenceDelegatingStringSet

extends HeadersUtils.DelegatingStringSet<CharSequence>
Class Inheritance

Field Summary

Inherited from io.netty5.handler.codec.HeadersUtils.DelegatingStringSet:
allNames

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public boolean
add(String
element to be added to this set
e
)

Overrides java.util.AbstractCollection.add.

Implements java.util.Set.add, java.util.Collection.add.

Adds the specified element to this set if it is not already present (optional operation).
public boolean
addAll(Collection<? extends String>
collection containing elements to be added to this set
c
)

Overrides java.util.AbstractCollection.addAll.

Implements java.util.Set.addAll, java.util.Collection.addAll.

Adds all of the elements in the specified collection to this set if they're not already present (optional operation).
Inherited from io.netty5.handler.codec.HeadersUtils.DelegatingStringSet:
clearcontainsisEmptyiteratorremovesize

Constructor Detail

CharSequenceDelegatingStringSetback to summary
pack-priv CharSequenceDelegatingStringSet(Set<CharSequence> allNames)

Method Detail

addback to summary
public boolean add(String e)

Overrides java.util.AbstractCollection.add.

Implements java.util.Set.add, java.util.Collection.add.

Doc from java.util.Set.add.

Adds the specified element to this set if it is not already present (optional operation). More formally, adds the specified element e to this set if the set contains no element e2 such that Objects.equals(e, e2). If this set already contains the element, the call leaves the set unchanged and returns false. In combination with the restriction on constructors, this ensures that sets never contain duplicate elements.

The stipulation above does not imply that sets must accept all elements; sets may refuse to add any particular element, including null, and throw an exception, as described in the specification for Collection.add. Individual set implementations should clearly document any restrictions on the elements that they may contain.

Parameters
e:String

element to be added to this set

Returns:boolean

true if this set did not already contain the specified element

Annotations
@Override
addAllback to summary
public boolean addAll(Collection<? extends String> c)

Overrides java.util.AbstractCollection.addAll.

Implements java.util.Set.addAll, java.util.Collection.addAll.

Doc from java.util.Set.addAll.

Adds all of the elements in the specified collection to this set if they're not already present (optional operation). If the specified collection is also a set, the addAll operation effectively modifies this set so that its value is the union of the two sets. The behavior of this operation is undefined if the specified collection is modified while the operation is in progress.

Parameters
c:Collection<? extends String>

collection containing elements to be added to this set

Returns:boolean

true if this set changed as a result of the call

Annotations
@Override
io.netty5.handler.codec back to summary

private abstract Class HeadersUtils.DelegatingStringSet<T>

extends AbstractCollection<String>
implements Set<String>
Class Inheritance
All Implemented Interfaces
java.util.Set, java.util.Collection, java.lang.Iterable
Known Direct Subclasses
io.netty5.handler.codec.HeadersUtils.CharSequenceDelegatingStringSet

Field Summary

Modifier and TypeField and Description
protected final Set<T>

Constructor Summary

AccessConstructor and Description
pack-priv
DelegatingStringSet(Set<T> allNames)

Method Summary

Modifier and TypeMethod and Description
public void
clear()

Overrides java.util.AbstractCollection.clear.

Implements java.util.Set.clear, java.util.Collection.clear.

Removes all of the elements from this set (optional operation).
public boolean
contains(Object
element whose presence in this set is to be tested
o
)

Overrides java.util.AbstractCollection.contains.

Implements java.util.Set.contains, java.util.Collection.contains.

Returns true if this set contains the specified element.
public boolean
isEmpty()

Overrides java.util.AbstractCollection.isEmpty.

Implements java.util.Set.isEmpty, java.util.Collection.isEmpty.

Returns true if this set contains no elements.
public Iterator<String>
iterator()

Implements abstract java.util.AbstractCollection.iterator.

Implements java.util.Set.iterator, java.util.Collection.iterator.

Returns an iterator over the elements in this set.
public boolean
remove(Object
object to be removed from this set, if present
o
)

Overrides java.util.AbstractCollection.remove.

Implements java.util.Set.remove, java.util.Collection.remove.

Removes the specified element from this set if it is present (optional operation).
public int
size()

Implements abstract java.util.AbstractCollection.size.

Implements java.util.Set.size, java.util.Collection.size.

Returns the number of elements in this set (its cardinality).
Inherited from java.util.AbstractCollection:
addaddAllcontainsAllremoveAllretainAlltoArraytoArraytoString

Field Detail

allNamesback to summary
protected final Set<T> allNames

Constructor Detail

DelegatingStringSetback to summary
pack-priv DelegatingStringSet(Set<T> allNames)

Method Detail

clearback to summary
public void clear()

Overrides java.util.AbstractCollection.clear.

Implements java.util.Set.clear, java.util.Collection.clear.

Doc from java.util.Set.clear.

Removes all of the elements from this set (optional operation). The set will be empty after this call returns.

Annotations
@Override
containsback to summary
public boolean contains(Object o)

Overrides java.util.AbstractCollection.contains.

Implements java.util.Set.contains, java.util.Collection.contains.

Doc from java.util.Set.contains.

Returns true if this set contains the specified element. More formally, returns true if and only if this set contains an element e such that Objects.equals(o, e).

Parameters
o:Object

element whose presence in this set is to be tested

Returns:boolean

true if this set contains the specified element

Annotations
@Override
isEmptyback to summary
public boolean isEmpty()

Overrides java.util.AbstractCollection.isEmpty.

Implements java.util.Set.isEmpty, java.util.Collection.isEmpty.

Doc from java.util.Set.isEmpty.

Returns true if this set contains no elements.

Returns:boolean

true if this set contains no elements

Annotations
@Override
iteratorback to summary
public Iterator<String> iterator()

Implements abstract java.util.AbstractCollection.iterator.

Implements java.util.Set.iterator, java.util.Collection.iterator.

Doc from java.util.Set.iterator.

Returns an iterator over the elements in this set. The elements are returned in no particular order (unless this set is an instance of some class that provides a guarantee).

Returns:Iterator<String>

an iterator over the elements in this set

Annotations
@Override
removeback to summary
public boolean remove(Object o)

Overrides java.util.AbstractCollection.remove.

Implements java.util.Set.remove, java.util.Collection.remove.

Doc from java.util.Set.remove.

Removes the specified element from this set if it is present (optional operation). More formally, removes an element e such that Objects.equals(o, e), if this set contains such an element. Returns true if this set contained the element (or equivalently, if this set changed as a result of the call). (This set will not contain the element once the call returns.)

Parameters
o:Object

object to be removed from this set, if present

Returns:boolean

true if this set contained the specified element

Annotations
@Override
sizeback to summary
public int size()

Implements abstract java.util.AbstractCollection.size.

Implements java.util.Set.size, java.util.Collection.size.

Doc from java.util.Set.size.

Returns the number of elements in this set (its cardinality). If this set contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.

Returns:int

the number of elements in this set (its cardinality)

Annotations
@Override
io.netty5.handler.codec back to summary

private final Class HeadersUtils.StringEntry

extends Object
implements Map.Entry<String, String>
Class Inheritance
All Implemented Interfaces
java.util.Map.Entry

Field Summary

Modifier and TypeField and Description
private final Map.Entry<CharSequence, CharSequence>
private String
private String

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public String
getKey()

Implements java.util.Map.Entry.getKey.

Returns the key corresponding to this entry.
public String
getValue()

Implements java.util.Map.Entry.getValue.

Returns the value corresponding to this entry.
public String
setValue(String
new value to be stored in this entry
value
)

Implements java.util.Map.Entry.setValue.

Replaces the value corresponding to this entry with the specified value (optional operation).
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

entryback to summary
private final Map.Entry<CharSequence, CharSequence> entry
nameback to summary
private String name
valueback to summary
private String value

Constructor Detail

StringEntryback to summary
pack-priv StringEntry(Map.Entry<CharSequence, CharSequence> entry)

Method Detail

getKeyback to summary
public String getKey()

Implements java.util.Map.Entry.getKey.

Doc from java.util.Map.Entry.getKey.

Returns the key corresponding to this entry.

Returns:String

the key corresponding to this entry

Annotations
@Override
getValueback to summary
public String getValue()

Implements java.util.Map.Entry.getValue.

Doc from java.util.Map.Entry.getValue.

Returns the value corresponding to this entry. If the mapping has been removed from the backing map (by the iterator's remove operation), the results of this call are undefined.

Returns:String

the value corresponding to this entry

Annotations
@Override
setValueback to summary
public String setValue(String value)

Implements java.util.Map.Entry.setValue.

Doc from java.util.Map.Entry.setValue.

Replaces the value corresponding to this entry with the specified value (optional operation). (Writes through to the map.) The behavior of this call is undefined if the mapping has already been removed from the map (by the iterator's remove operation).

Parameters
value:String

new value to be stored in this entry

Returns:String

old value corresponding to the entry

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override
io.netty5.handler.codec back to summary

private final Class HeadersUtils.StringEntryIterator

extends Object
implements Iterator<Map.Entry<String, String>>
Class Inheritance
All Implemented Interfaces
java.util.Iterator

Field Summary

Modifier and TypeField and Description
private final Iterator<Map.Entry<CharSequence, CharSequence>>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public boolean
hasNext()

Implements java.util.Iterator.hasNext.

Returns true if the iteration has more elements.
public Map.Entry<String, String>
next()

Implements java.util.Iterator.next.

Returns the next element in the iteration.
public void
remove()

Overrides default java.util.Iterator.remove.

Removes from the underlying collection the last element returned by this iterator (optional operation).
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

iterback to summary
private final Iterator<Map.Entry<CharSequence, CharSequence>> iter

Constructor Detail

StringEntryIteratorback to summary
pack-priv StringEntryIterator(Iterator<Map.Entry<CharSequence, CharSequence>> iter)

Method Detail

hasNextback to summary
public boolean hasNext()

Implements java.util.Iterator.hasNext.

Doc from java.util.Iterator.hasNext.

Returns true if the iteration has more elements. (In other words, returns true if next would return an element rather than throwing an exception.)

Returns:boolean

true if the iteration has more elements

Annotations
@Override
nextback to summary
public Map.Entry<String, String> next()

Implements java.util.Iterator.next.

Doc from java.util.Iterator.next.

Returns the next element in the iteration.

Returns:Map.Entry<String, String>

the next element in the iteration

Annotations
@Override
removeback to summary
public void remove()

Overrides default java.util.Iterator.remove.

Doc from java.util.Iterator.remove.

Removes from the underlying collection the last element returned by this iterator (optional operation). This method can be called only once per call to next.

The behavior of an iterator is unspecified if the underlying collection is modified while the iteration is in progress in any way other than by calling this method, unless an overriding class has specified a concurrent modification policy.

The behavior of an iterator is unspecified if this method is called after a call to the forEachRemaining method.

Annotations
@Override
io.netty5.handler.codec back to summary

private final Class HeadersUtils.StringIterator<T>

extends Object
implements Iterator<String>
Class Inheritance
All Implemented Interfaces
java.util.Iterator

Field Summary

Modifier and TypeField and Description
private final Iterator<T>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public boolean
hasNext()

Implements java.util.Iterator.hasNext.

Returns true if the iteration has more elements.
public String
next()

Implements java.util.Iterator.next.

Returns the next element in the iteration.
public void
remove()

Overrides default java.util.Iterator.remove.

Removes from the underlying collection the last element returned by this iterator (optional operation).
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

iterback to summary
private final Iterator<T> iter

Constructor Detail

StringIteratorback to summary
pack-priv StringIterator(Iterator<T> iter)

Method Detail

hasNextback to summary
public boolean hasNext()

Implements java.util.Iterator.hasNext.

Doc from java.util.Iterator.hasNext.

Returns true if the iteration has more elements. (In other words, returns true if next would return an element rather than throwing an exception.)

Returns:boolean

true if the iteration has more elements

Annotations
@Override
nextback to summary
public String next()

Implements java.util.Iterator.next.

Doc from java.util.Iterator.next.

Returns the next element in the iteration.

Returns:String

the next element in the iteration

Annotations
@Override
removeback to summary
public void remove()

Overrides default java.util.Iterator.remove.

Doc from java.util.Iterator.remove.

Removes from the underlying collection the last element returned by this iterator (optional operation). This method can be called only once per call to next.

The behavior of an iterator is unspecified if the underlying collection is modified while the iteration is in progress in any way other than by calling this method, unless an overriding class has specified a concurrent modification policy.

The behavior of an iterator is unspecified if this method is called after a call to the forEachRemaining method.

Annotations
@Override