public final class Response extends Object
Modifier and Type | Field and Description |
---|---|
String |
DEFAULT_ENC
The default enconding we use (ISO-8859-1).
|
Constructor and Description |
---|
Response()
Constructor for the Response object
|
Modifier and Type | Method and Description |
---|---|
void |
dumpHeaders(Logger logger) |
static String |
getContentCharSet(String val,
String def)
Parse the charset spec, i.e.
|
byte[] |
getData() |
String |
getHeader(String header,
String defaultValue)
Gets the first header among HTTP headers or return the default value if
the header is not in the response.
|
ArrayList<Anchor> |
getImageLinks()
Gets all img-src links discovered - only responses of text/html are
analyzed by the html parser.
|
long |
getInvertizeTime() |
ArrayList<Anchor> |
getLinks()
Gets all links discovered - only responses of text/html are analyzed by
the html parser.
|
byte[] |
getMD5()
Gets the md5 attribute of the data stream.
|
String |
getMsg() |
long |
getParseTime() |
Reader |
getReader()
Returns the content of this response with charset specified in HTTP
header.
|
Reader |
getReader(String charset)
Returns a correct reader of the data stream.
|
int |
getStatus() |
long |
getTimestamp()
Gets the timestamp attribute of the Response object
|
long |
getUID() |
String |
getURI() |
boolean |
isFatalErr()
Fatal error is defined as
status lower than 0. |
boolean |
isMiscErr()
Error is miscellaneous when it is not a fatal error and it is not a
success.
|
String |
isRedirect()
Response is a redirect when
status is HTTP_MOVED_PERM or
HTTP_MOVED_TEMP or HTTP_SEE_OTHER or 307, then this method returns
location HTTP header value. |
boolean |
isSuccess()
Response is a success when it ends with
status HTTP_OK. |
void |
load(DataInput in)
Loads the object from a stream.
|
Document |
process()
Process just the text/html document and create its Egothor's counterpart,
return null in the case of other content types.
|
void |
setData(byte[] data)
Sets the data attribute of the Response object
|
void |
setEncoder(EventEncoder encoder) |
void |
setHeaders(HashMap<String,String> headers)
Sets the headers attribute of the Response object
|
void |
setMsg(String msg)
Sets the msg attribute of the Response object
|
void |
setStatus(int status)
Sets the status attribute of the Response object
|
long |
setTimestamp()
Sets the timestamp attribute of the Response object
|
void |
setUID(long uid) |
void |
setURI(String uri) |
void |
store(DataOutput out)
Saves the response into a stream.
|
public final String DEFAULT_ENC
public void dumpHeaders(Logger logger)
public void setUID(long uid)
public long getUID()
public void setURI(String uri)
public String getURI()
public void setData(byte[] data)
data
- The new data valuepublic byte[] getData()
public long getParseTime()
public long getInvertizeTime()
public void setHeaders(HashMap<String,String> headers)
headers
- The new headers valuepublic void setMsg(String msg)
msg
- The new msg valuepublic String getMsg()
public void setStatus(int status)
status
- The new status valuepublic long setTimestamp()
public static String getContentCharSet(String val, String def)
text/html;charset=ISO-8859-2
.
If the charset attribute is not given, def
is returned.val
- Description of the Parameterdef
- Description of the Parameterpublic boolean isFatalErr()
status
lower than 0.public String getHeader(String header, String defaultValue)
header
- Description of the ParameterdefaultValue
- public ArrayList<Anchor> getLinks()
public ArrayList<Anchor> getImageLinks()
public Document process()
public byte[] getMD5()
public boolean isMiscErr()
isFatalErr()
,
isSuccess()
public Reader getReader(String charset)
charset
- a charset to be used over the datapublic Reader getReader()
DEFAULT_ENC
is used instead.public String isRedirect()
status
is HTTP_MOVED_PERM or
HTTP_MOVED_TEMP or HTTP_SEE_OTHER or 307, then this method returns
location
HTTP header value.public boolean isSuccess()
status
HTTP_OK.public long getTimestamp()
public void store(DataOutput out) throws IOException
out
- The streamIOException
public void load(DataInput in) throws IOException
in
- The streamIOException
public void setEncoder(EventEncoder encoder)
public int getStatus()
Copyright © 2016 Egothor. All Rights Reserved.