Package net.officefloor.server.buffer
Class StreamBufferByteSequence
java.lang.Object
net.officefloor.server.buffer.StreamBufferByteSequence
- All Implemented Interfaces:
CharSequence,ByteSequence
ByteSequence reading from StreamBuffer instances.- Author:
- Daniel Sagenschneider
-
Field Summary
Fields inherited from interface net.officefloor.server.stream.impl.ByteSequence
EMPTY -
Constructor Summary
ConstructorsConstructorDescriptionStreamBufferByteSequence(StreamBuffer<ByteBuffer> buffer, int offset, int length) Instantiate with the firstStreamBuffer. -
Method Summary
Modifier and TypeMethodDescriptionvoidappendStreamBuffer(StreamBuffer<ByteBuffer> buffer, int offset, int length) Appends aStreamBufferto thisByteSequence.bytebyteAt(int index) Obtains thebyteat the index.charcharAt(int index) <T extends Throwable>
StreamBufferByteSequenceDecodes the URI.intlength()Obtains the number ofbytevalues in theByteSequence.<T extends Throwable>
StreamBufferByteSequenceremoveQuotes(Supplier<T> invalidValueExceptionFactory) Removes surrounding HTTP quotes.static voidsetMaxByteLength(int length) Specifies the maximum byte length of anyByteSequence.subSequence(int start, int end) Obtains thisByteSequencedecoded to a HTTPString.<T extends Throwable>
longObtains thisByteSequenceas alongvalue.toString(Charset charset, Function<CoderResult, T> invalidValueExceptionFactory) toUriString(Function<CoderResult, T> invalidValueExceptionFactory) Obtains thisByteSequencedecoded to a URIString.trim()Trims thisByteSequenceof outer HTTP spaces and tabs.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.CharSequence
chars, codePoints, isEmpty, toString
-
Constructor Details
-
StreamBufferByteSequence
Instantiate with the firstStreamBuffer.- Parameters:
buffer- FirstStreamBufferof thisByteSequence.offset- Offset into theStreamBufferto read data.length- Length of data from theStreamBuffer.
-
-
Method Details
-
setMaxByteLength
public static void setMaxByteLength(int length) Specifies the maximum byte length of anyByteSequence.- Parameters:
length- Maximum byte length of anyByteSequence.
-
appendStreamBuffer
Appends aStreamBufferto thisByteSequence.- Parameters:
buffer-StreamBufferto append to thisByteSequence.offset- Offset into theStreamBufferto read data.length- Length of data from theStreamBuffer.
-
trim
Trims thisByteSequenceof outer HTTP spaces and tabs.- Returns:
this.
-
removeQuotes
public <T extends Throwable> StreamBufferByteSequence removeQuotes(Supplier<T> invalidValueExceptionFactory) throws T Removes surrounding HTTP quotes. -
getHttpCharSequence
Obtains this
ByteSequenceas aCharSequencefor HTTPCharactervalues.This is for use with
NonMaterialisedHttpHeadercomparing on the name.- Returns:
CharSequencefor HTTPCharactervalues of thisByteSequence.
-
toHttpString
Obtains thisByteSequencedecoded to a HTTPString.- Returns:
ByteSequencedecoded to a HTTPString.
-
decodeUri
public <T extends Throwable> StreamBufferByteSequence decodeUri(Function<String, T> invalidDecodeExceptionFactory) throws TDecodes the URI. -
toUriString
public <T extends Throwable> String toUriString(Function<CoderResult, T> invalidValueExceptionFactory) throws TObtains thisByteSequencedecoded to a URIString.- Type Parameters:
T- Invalid valueExceptiontype.- Parameters:
invalidValueExceptionFactory- Factory to create theExceptionshould theByteSequencenot be valid for the URI.- Returns:
ByteSequencedecoded to a URIString.- Throws:
T- If invalidByteSequencefor the URI.
-
toString
public <T extends Throwable> String toString(Charset charset, Function<CoderResult, T> invalidValueExceptionFactory) throws T- Type Parameters:
T- Invalid valueExceptiontype.- Parameters:
charset-Charsetfor the decoding theStreamBufferdata.invalidValueExceptionFactory- Factory to create theExceptionshould theByteSequencenot be valid for theCharset.- Returns:
Stringvalue for theStreamBuffervalues.- Throws:
T- If invalidByteSequenceforCharset.
-
toLong
public <T extends Throwable> long toLong(Function<Character, T> invalidDigitExceptionFactory) throws TObtains thisByteSequenceas alongvalue. -
byteAt
public byte byteAt(int index) Description copied from interface:ByteSequenceObtains thebyteat the index.- Specified by:
byteAtin interfaceByteSequence- Parameters:
index- Index of thebyte.- Returns:
byteat the index.
-
length
public int length()Description copied from interface:ByteSequenceObtains the number ofbytevalues in theByteSequence.- Specified by:
lengthin interfaceByteSequence- Specified by:
lengthin interfaceCharSequence- Returns:
- Number of
bytevalues in theByteSequence.
-
charAt
public char charAt(int index) - Specified by:
charAtin interfaceCharSequence
-
subSequence
- Specified by:
subSequencein interfaceCharSequence
-