Class WarningValue
- java.lang.Object
-
- org.apache.http.impl.client.cache.WarningValue
-
class WarningValue extends java.lang.Object
This class provides for parsing and understanding Warning headers. As the Warning header can be multi-valued, but the values can contain separators like commas inside quoted strings, we cannot use the regularHeader.getElements()
call to access the values.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
ASCTIME_DATE
private static java.lang.String
DATE1
private static java.lang.String
DATE2
private static java.lang.String
DATE3
private static java.lang.String
DOMAINLABEL
private static java.lang.String
HOST
private static java.lang.String
HOSTNAME
private static java.lang.String
HOSTPORT
private static java.util.regex.Pattern
HOSTPORT_PATTERN
private static java.lang.String
HTTP_DATE
private int
init_offs
private static java.lang.String
IPV4ADDRESS
private static java.lang.String
MONTH
private int
offs
private static java.lang.String
PORT
private static java.lang.String
RFC1123_DATE
private static java.lang.String
RFC850_DATE
private java.lang.String
src
private static java.lang.String
TIME
private static java.lang.String
TOPLABEL
private static java.lang.String
WARN_DATE
private static java.util.regex.Pattern
WARN_DATE_PATTERN
private java.lang.String
warnAgent
private int
warnCode
private java.util.Date
warnDate
private java.lang.String
warnText
private static java.lang.String
WEEKDAY
private static java.lang.String
WKDAY
-
Constructor Summary
Constructors Constructor Description WarningValue(java.lang.String s)
WarningValue(java.lang.String s, int offs)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
consumeCharacter(char c)
protected void
consumeHostPort()
protected void
consumeLinearWhitespace()
protected void
consumeQuotedString()
protected void
consumeToken()
protected void
consumeWarnAgent()
protected void
consumeWarnCode()
protected void
consumeWarnDate()
protected void
consumeWarnText()
protected void
consumeWarnValue()
java.lang.String
getWarnAgent()
Returns the "warn-agent" string associated with this warning, which is either the name or pseudonym of the server that added this particular Warning header.int
getWarnCode()
Returns the 3-digit code associated with this warning.java.util.Date
getWarnDate()
Returns the date and time when this warning was added, ornull
if a warning date was not supplied in the header.static WarningValue[]
getWarningValues(org.apache.http.Header h)
Returns an array of the parseable warning values contained in the given header value, which is assumed to be a Warning header.java.lang.String
getWarnText()
Returns the human-readable warning text for this warning.private boolean
isChar(char c)
private boolean
isControl(char c)
private boolean
isSeparator(char c)
private boolean
isTokenChar(char c)
private void
parseError()
java.lang.String
toString()
Formats aWarningValue
as aString
suitable for including in a header.
-
-
-
Field Detail
-
offs
private int offs
-
init_offs
private int init_offs
-
src
private final java.lang.String src
-
warnCode
private int warnCode
-
warnAgent
private java.lang.String warnAgent
-
warnText
private java.lang.String warnText
-
warnDate
private java.util.Date warnDate
-
TOPLABEL
private static final java.lang.String TOPLABEL
- See Also:
- Constant Field Values
-
DOMAINLABEL
private static final java.lang.String DOMAINLABEL
- See Also:
- Constant Field Values
-
HOSTNAME
private static final java.lang.String HOSTNAME
- See Also:
- Constant Field Values
-
IPV4ADDRESS
private static final java.lang.String IPV4ADDRESS
- See Also:
- Constant Field Values
-
HOST
private static final java.lang.String HOST
- See Also:
- Constant Field Values
-
PORT
private static final java.lang.String PORT
- See Also:
- Constant Field Values
-
HOSTPORT
private static final java.lang.String HOSTPORT
- See Also:
- Constant Field Values
-
HOSTPORT_PATTERN
private static final java.util.regex.Pattern HOSTPORT_PATTERN
-
MONTH
private static final java.lang.String MONTH
- See Also:
- Constant Field Values
-
WEEKDAY
private static final java.lang.String WEEKDAY
- See Also:
- Constant Field Values
-
WKDAY
private static final java.lang.String WKDAY
- See Also:
- Constant Field Values
-
TIME
private static final java.lang.String TIME
- See Also:
- Constant Field Values
-
DATE3
private static final java.lang.String DATE3
- See Also:
- Constant Field Values
-
DATE2
private static final java.lang.String DATE2
- See Also:
- Constant Field Values
-
DATE1
private static final java.lang.String DATE1
- See Also:
- Constant Field Values
-
ASCTIME_DATE
private static final java.lang.String ASCTIME_DATE
- See Also:
- Constant Field Values
-
RFC850_DATE
private static final java.lang.String RFC850_DATE
- See Also:
- Constant Field Values
-
RFC1123_DATE
private static final java.lang.String RFC1123_DATE
- See Also:
- Constant Field Values
-
HTTP_DATE
private static final java.lang.String HTTP_DATE
- See Also:
- Constant Field Values
-
WARN_DATE
private static final java.lang.String WARN_DATE
- See Also:
- Constant Field Values
-
WARN_DATE_PATTERN
private static final java.util.regex.Pattern WARN_DATE_PATTERN
-
-
Method Detail
-
getWarningValues
public static WarningValue[] getWarningValues(org.apache.http.Header h)
Returns an array of the parseable warning values contained in the given header value, which is assumed to be a Warning header. Improperly formatted warning values will be skipped, in keeping with the philosophy of "ignore what you cannot understand."- Parameters:
h
- WarningHeader
to parse- Returns:
- array of
WarnValue
objects
-
consumeLinearWhitespace
protected void consumeLinearWhitespace()
-
isChar
private boolean isChar(char c)
-
isControl
private boolean isControl(char c)
-
isSeparator
private boolean isSeparator(char c)
-
consumeToken
protected void consumeToken()
-
isTokenChar
private boolean isTokenChar(char c)
-
consumeHostPort
protected void consumeHostPort()
-
consumeWarnAgent
protected void consumeWarnAgent()
-
consumeQuotedString
protected void consumeQuotedString()
-
consumeWarnText
protected void consumeWarnText()
-
consumeWarnDate
protected void consumeWarnDate()
-
consumeWarnValue
protected void consumeWarnValue()
-
consumeCharacter
protected void consumeCharacter(char c)
-
consumeWarnCode
protected void consumeWarnCode()
-
parseError
private void parseError()
-
getWarnCode
public int getWarnCode()
Returns the 3-digit code associated with this warning.- Returns:
int
-
getWarnAgent
public java.lang.String getWarnAgent()
Returns the "warn-agent" string associated with this warning, which is either the name or pseudonym of the server that added this particular Warning header.- Returns:
String
-
getWarnText
public java.lang.String getWarnText()
Returns the human-readable warning text for this warning. Note that the original quoted-string is returned here, including escaping for any contained characters. In other words, if the header was:Warning: 110 fred "Response is stale"
then this method will return"\"Response is stale\""
(surrounding quotes included).- Returns:
String
-
getWarnDate
public java.util.Date getWarnDate()
Returns the date and time when this warning was added, ornull
if a warning date was not supplied in the header.- Returns:
Date
-
toString
public java.lang.String toString()
Formats aWarningValue
as aString
suitable for including in a header. For example, you can:WarningValue wv = ...; HttpResponse resp = ...; resp.addHeader("Warning", wv.toString());
- Overrides:
toString
in classjava.lang.Object
- Returns:
String
-
-