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()
Returns the final buffer, possibly containing the built object.
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()
Convert this Object to a human-readable String.
String
toString(String prefix)
Returns a printable representation of this structure, with the given prefix prepended to each line.

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()
Returns the final buffer, possibly containing the built object. The returned buffer will be "trimmed" to size: its position will be zero, and its limit and capacity set to the length of the built object.
Specified by:
buffer in interface Builder
Returns:
The underlying buffer.

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()
Convert this Object to a human-readable String. There are no limits placed on how long this String should be or what it should contain. We suggest you make it as intuitive as possible to be able to place it into System.out.println() and such.

It is typical, but not required, to ensure that this method never completes abruptly with a RuntimeException.

This method will be called when performing string concatenation with this object. If the result is null, string concatenation will instead use "null".

The default implementation returns getClass().getName() + "@" + Integer.toHexString(hashCode()).

Overrides:
toString in interface Object
Returns:
the String representing this Object, which may be null

toString

public String toString(String prefix)
Returns a printable representation of this structure, with the given prefix prepended to each line.
Specified by:
toString in interface Constructed
Parameters:
prefix - The prefix to prepend to each line of the output. This value may be null.
Returns:
A printable representation of this structure.