Package org.simpleframework.http.message
Class RequestConsumer.Token
java.lang.Object
org.simpleframework.http.message.RequestConsumer.Token
- All Implemented Interfaces:
CharSequence
- Enclosing class:
RequestConsumer
This is a sequence of characters representing the header data
consumed. Here the internal byte buffer is simply wrapped so
that it can be a represented as a
CharSequence
.
Wrapping the consumed array in this manner ensures that no
further memory allocation is required.-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
Token
(byte[] array, int off, int size) Constructor for theByteSequence
object. -
Method Summary
Modifier and TypeMethodDescriptionchar
charAt
(int index) This is used to acquire the character at the specified index.int
length()
This returns the length of the header in bytes.subSequence
(int start, int end) This returns a section of characters within the specified range.toString()
This is used to create a string from the header bytes.This is used to create a string from the header bytes.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.CharSequence
chars, codePoints, isEmpty
-
Field Details
-
array
public byte[] arrayThis is the array that contains the header bytes. -
size
public int sizeThis is the number of bytes to use from the array. -
off
public int offThis is the offset in the array the token begins at.
-
-
Constructor Details
-
Token
private Token(byte[] array, int off, int size) Constructor for theByteSequence
object. This is used to represent the data that has been consumed by the header. It acts as a light weight wrapper for the data and avoids having to create new strings for each event.- Parameters:
array
- this is the array representing the headeroff
- the starting offset for the token rangesize
- the number of bytes used for the token
-
-
Method Details
-
length
public int length()This returns the length of the header in bytes. The length includes the request line and all of the control characters including the carriage return and line feed at the end of the request header.- Specified by:
length
in interfaceCharSequence
- Returns:
- this returns the number of bytes for the header
-
charAt
public char charAt(int index) This is used to acquire the character at the specified index. Characters returned from this method are simply the bytes casted to a character. This may not convert the character correctly and a more sensible method should be used.- Specified by:
charAt
in interfaceCharSequence
- Parameters:
index
- the index to extract the character from- Returns:
- this returns the character found at the index
-
subSequence
This returns a section of characters within the specified range. Acquiring a section in this manner is simply done by setting a start and end offset within the internal array.- Specified by:
subSequence
in interfaceCharSequence
- Parameters:
start
- this is the start index to be usedend
- this is the end index to be used- Returns:
- this returns a new sequence within the original
-
toString
This is used to create a string from the header bytes. This converts the header bytes to a string using a compatible encoding. This may produce different results depending on the time it is invoked, as the header consumes more data.- Specified by:
toString
in interfaceCharSequence
- Overrides:
toString
in classObject
- Returns:
- this returns an encoded version of the header
-
toString
This is used to create a string from the header bytes. This converts the header bytes to a string using a compatible encoding. This may produce different results depending on the time it is invoked, as the header consumes more data.- Parameters:
charset
- this is the encoding to use for the header- Returns:
- this returns an encoded version of the header
-