V - The header value target type. There can be multiple values for a
single header.public class HeaderReader<V> extends Object
| Constructor and Description |
|---|
HeaderReader(String header)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addValues(Collection<V> values)
Adds values to the given list.
|
protected boolean |
canAdd(V value,
Collection<V> values)
Indicates if the value can be added the the list.
|
protected Parameter |
createParameter(String name)
Creates a new parameter with a null value.
|
protected Parameter |
createParameter(String name,
String value)
Creates a new parameter.
|
void |
mark()
Marks the current position in this reader.
|
int |
peek()
Reads the next character without moving the reader index.
|
int |
read()
Reads the next character.
|
String |
readActualNamedValue()
Reads a parameter value which is either a token or a quoted string.
|
String |
readComment()
Reads the next comment.
|
static Date |
readDate(String date,
boolean cookie)
Parses a date string.
|
String |
readDigits()
Reads the next digits.
|
static Header |
readHeader(CharSequence header)
Read a header.
|
static Header |
readHeader(InputStream is,
StringBuilder sb)
Read a header.
|
<NV extends NamedValue<String>> |
readNamedValue(Class<NV> resultClass)
Reads the next pair as a parameter.
|
Parameter |
readParameter()
Reads the next pair as a parameter.
|
String |
readQuotedString()
Reads the next quoted string.
|
String |
readRawText()
Read the next text until a space separator is reached.
|
String |
readRawValue()
Read the next header value of a multi-value header.
|
String |
readToken()
Reads the next token.
|
V |
readValue()
Read the next value.
|
List<V> |
readValues()
Returns a new list with all values added.
|
void |
reset()
Repositions this stream to the position at the time the
mark
method was last called on this input stream. |
boolean |
skipParameterSeparator()
Skips the next parameter separator (semi-colon) including leading and
trailing spaces.
|
boolean |
skipSpaces()
Skips the next spaces.
|
boolean |
skipValueSeparator()
Skips the next value separator (comma) including leading and trailing spaces.
|
void |
unread()
Unreads the last character.
|
public HeaderReader(String header)
header - The header to read.public static Date readDate(String date, boolean cookie)
date - The date string to parse.cookie - Indicates if the date is in the cookie format.public static Header readHeader(CharSequence header) throws IOException
header - The header line to parse.IOExceptionpublic static Header readHeader(InputStream is, StringBuilder sb) throws IOException
is - The message input stream.sb - The string builder to reuse.IOExceptionpublic void addValues(Collection<V> values)
values - The list of values to update.protected boolean canAdd(V value, Collection<V> values)
Encoding.IDENTITY constants for example. By default it
returns true for non null values.value - The value to add.values - The target collection.protected final Parameter createParameter(String name)
name - The parameter name.protected Parameter createParameter(String name, String value)
name - The parameter name.value - The parameter value or null.public void mark()
reset method repositions this reader at the last marked
position.public int peek()
public int read()
public String readActualNamedValue() throws IOException
IOExceptionpublic String readComment() throws IOException
IOExceptionpublic String readDigits()
public <NV extends NamedValue<String>> NV readNamedValue(Class<NV> resultClass) throws IOException
resultClass - The named value class to return.IOExceptionpublic Parameter readParameter() throws IOException
IOExceptionpublic String readQuotedString() throws IOException
IOExceptionpublic String readRawText()
public String readRawValue()
public String readToken()
public V readValue() throws IOException
IOExceptionpublic List<V> readValues()
public void reset()
mark
method was last called on this input stream.public boolean skipParameterSeparator()
public boolean skipSpaces()
public boolean skipValueSeparator()
public void unread()
Copyright © 2005–2025. All rights reserved.