gnu.javax.net.ssl.provider

Class ExtensionList

Implemented Interfaces:
Builder, Constructed, Iterable<E>

public class ExtensionList
extends Object
implements Builder, Iterable<E>

A list of extensions, that may appear in either the ClientHello or ServerHello. The form of the extensions list is: Extension extensions_list<1..2^16-1>

Nested Class Summary

class
ExtensionList.ExtensionsIterator
List iterator interface to an extensions list.

Constructor Summary

ExtensionList(List extensions)
ExtensionList(ByteBuffer buffer)

Method Summary

ByteBuffer
buffer()
Extension
get(int index)
Iterator
iterator()
int
length()
Returns the length of this extension list, in bytes.
void
set(int index, Extension e)
Sets the extension at index i to e.
void
set(int index, Extension.Type t, int eLength)
Reserve space for an extension at index i in the list.
void
setLength(int newLength)
Set the total length of this list, in bytes.
int
size()
Returns the number of extensions this list contains.
String
toString()
String
toString(String prefix)

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Details

ExtensionList

public ExtensionList(List extensions)

ExtensionList

public ExtensionList(ByteBuffer buffer)

Method Details

buffer

public ByteBuffer buffer()
Specified by:
buffer in interface Builder

get

public Extension get(int index)

iterator

public Iterator iterator()
Specified by:
iterator in interface Iterable<E>

length

public int length()
Returns the length of this extension list, in bytes.
Specified by:
length in interface Constructed
Returns:
The length of this extension list, in bytes.

set

public void set(int index,
                Extension e)
Sets the extension at index i to e. Note that setting an element at an index may invalidate any other elements that come after element at index i. In other words, no attempt is made to move existing elements in this list, and since extensions are variable length, you can not guarantee that extensions later in the list will still be valid.

Thus, elements of this list must be set in order of increasing index.

Parameters:
index - The index to set the extension at.
e - The extension.
Throws:
BufferOverflowException - If setting the extension overflows the buffer.
IllegalArgumentException - If it isn't possible to find the given index in the current list (say, if no element index - 1 is set), or if setting the extension will overflow the current list length (given by length()).

set

public void set(int index,
                Extension.Type t,
                int eLength)
Reserve space for an extension at index i in the list. In other words, this does the job of set(int,Extension), but does not copy the extension value to the underlying buffer.
Parameters:
index - The index of the extension to reserve space for.
t - The type of the extension.
eLength - The number of bytes to reserve for this extension. The total number of bytes used by this method is this length, plus four.

setLength

public void setLength(int newLength)
Set the total length of this list, in bytes.
Parameters:
newLength - The new list length.

size

public int size()
Returns the number of extensions this list contains.
Returns:
The number of extensions.

toString

public String toString()
Overrides:
toString in interface Object

toString

public String toString(String prefix)
Specified by:
toString in interface Constructed