V
- The header value target type. There can be multiple values for a
single header.public class HeaderReader<V>
extends java.lang.Object
Constructor and Description |
---|
HeaderReader(java.lang.String header)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addValues(java.util.Collection<V> values)
Adds values to the given list.
|
protected boolean |
canAdd(V value,
java.util.Collection<V> values)
Indicates if the value can be added the the list.
|
protected Parameter |
createParameter(java.lang.String name)
Creates a new parameter with a null value.
|
protected Parameter |
createParameter(java.lang.String name,
java.lang.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.
|
java.lang.String |
readActualNamedValue()
Reads a parameter value which is either a token or a quoted string.
|
java.lang.String |
readComment()
Reads the next comment.
|
static java.util.Date |
readDate(java.lang.String date,
boolean cookie)
Parses a date string.
|
java.lang.String |
readDigits()
Reads the next digits.
|
static Header |
readHeader(java.lang.CharSequence header)
Read a header.
|
static Header |
readHeader(java.io.InputStream is,
java.lang.StringBuilder sb)
Read a header.
|
<NV extends NamedValue<java.lang.String>> |
readNamedValue(java.lang.Class<NV> resultClass)
Reads the next pair as a parameter.
|
Parameter |
readParameter()
Reads the next pair as a parameter.
|
java.lang.String |
readQuotedString()
Reads the next quoted string.
|
java.lang.String |
readRawText()
Read the next text until a space separator is reached.
|
java.lang.String |
readRawValue()
Read the next header value of a multi-value header.
|
java.lang.String |
readToken()
Reads the next token.
|
V |
readValue()
Read the next value.
|
java.util.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(java.lang.String header)
header
- The header to read.public static java.util.Date readDate(java.lang.String date, boolean cookie)
date
- The date string to parse.cookie
- Indicates if the date is in the cookie format.public static Header readHeader(java.lang.CharSequence header) throws java.io.IOException
header
- The header line to parse.java.io.IOException
public static Header readHeader(java.io.InputStream is, java.lang.StringBuilder sb) throws java.io.IOException
is
- The message input stream.sb
- The string builder to reuse.java.io.IOException
public void addValues(java.util.Collection<V> values)
values
- The list of values to update.protected boolean canAdd(V value, java.util.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(java.lang.String name)
name
- The parameter name.protected Parameter createParameter(java.lang.String name, java.lang.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 java.lang.String readActualNamedValue() throws java.io.IOException
java.io.IOException
public java.lang.String readComment() throws java.io.IOException
java.io.IOException
public java.lang.String readDigits()
public <NV extends NamedValue<java.lang.String>> NV readNamedValue(java.lang.Class<NV> resultClass) throws java.io.IOException
resultClass
- The named value class to return.java.io.IOException
public Parameter readParameter() throws java.io.IOException
java.io.IOException
public java.lang.String readQuotedString() throws java.io.IOException
java.io.IOException
public java.lang.String readRawText()
public java.lang.String readRawValue()
public java.lang.String readToken()
public V readValue() throws java.io.IOException
java.io.IOException
public java.util.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-2024 Restlet.