|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.spinn3r.api.BaseClient
public abstract class BaseClient
Generic client support used which need to be in all APIs. See Main.java for usage example. All implementations need to catch and handle Exceptions.
| Field Summary | |
|---|---|
static java.lang.String |
ACCEPT_ENCODING_HEADER
|
static java.lang.String |
COMMENT_HANDLER
|
protected Config |
config
|
static int |
DEFAULT_CONNECT_TIMEOUT
These properties specify the default connect and read timeout (resp.) for the protocol handler used by java.net.URLConnection. |
static java.lang.String |
DEFAULT_HOST
Default hostname for building the router URL. |
static boolean |
DEFAULT_HTTP_KEEPALIVE
Whether we should use HTTP Keep Alive in java.net.URL. |
static int |
DEFAULT_MAX_REDIRECTS
Specify the maximum number of redirects to use. |
static int |
DEFAULT_READ_TIMEOUT
Lower read timeout. |
protected boolean |
disable_parse
|
static java.lang.String |
FEED_HANDLER
|
static java.lang.String |
GZIP_ENCODING
|
protected boolean |
isCompressed
True if the last API call was compressed. |
static java.lang.String |
LINK_HANDLER
|
static int |
NETWORKADDRESS_CACHE_TTL
Specified in java.security to indicate the caching policy for successful name lookups from the name service.. |
static java.lang.String |
NS_API
|
static java.lang.String |
NS_ATOM
|
static java.lang.String |
NS_COMMENT
|
static java.lang.String |
NS_DC
|
static java.lang.String |
NS_FEED
|
static java.lang.String |
NS_LINK
|
static java.lang.String |
NS_POST
|
static java.lang.String |
NS_SOURCE
|
static java.lang.String |
NS_TARGET
|
static java.lang.String |
NS_WEBLOG
|
static java.lang.String |
PERMALINK_HANDLER
|
static int |
RESTART_BUFFER
Go back in time to make sure we recrawl everything. |
protected java.util.List |
results
|
static long |
RETRY_MAX
Maximum number of retries. |
static java.lang.String |
USER_AGENT
|
static java.lang.String |
USER_AGENT_HEADER
|
| Constructor Summary | |
|---|---|
BaseClient()
|
|
| Method Summary | |
|---|---|
static void |
addParam(java.lang.StringBuffer buff,
java.lang.String name,
java.lang.Object value)
|
static void |
addParam(java.lang.StringBuffer buff,
java.lang.String name,
java.lang.Object value,
boolean optional)
|
static void |
addParam(java.lang.StringBuffer buff,
java.lang.String name,
java.lang.Object value,
boolean optional,
boolean urlencode)
Add a parameter to the first request URL. |
ContentApi.Response |
doProtobufFetch(java.lang.String resource)
|
org.w3c.dom.Document |
doXmlFetch(java.lang.String resource)
|
boolean |
empty(java.lang.String value)
|
void |
fetch(Config config)
|
protected java.lang.String |
generateFirstRequestURL()
Generate the first request URL based just on configuration directives. |
long |
getCallDuration()
Get the value of callDuration. |
Config |
getConfig()
Get the value of config. |
protected int |
getConservativeLimit()
Conservative limit for items which should work in all situations (but might be slower) |
static org.w3c.dom.Element |
getElementByTagName(org.w3c.dom.Element current,
java.lang.String name)
|
static org.w3c.dom.Element |
getElementByTagName(org.w3c.dom.Element current,
java.lang.String name,
java.lang.String namespace)
|
static java.lang.String |
getElementCDATAByTagName(org.w3c.dom.Element current,
java.lang.String name)
|
static java.lang.String |
getElementCDATAByTagName(org.w3c.dom.Element current,
java.lang.String name,
java.lang.String namespace)
|
java.lang.String |
getHost()
Get the host name for API calls. |
java.io.InputStream |
getInputStream()
Get the InputStream for dealing with the XML of the API directly. |
java.lang.String |
getLastRequestURL()
Get the last requested URL for debug and logging purposes. |
int |
getLimit()
Return the correct limit, factoring in the limit set by the user. |
protected int |
getMaxLimit()
Return the maximum number of request per call. |
java.lang.String |
getNextRequestURL()
Get the value of nextRequestURL. |
static java.util.Map<java.lang.String,java.lang.String> |
getopt(java.lang.String[] args)
Parse command line arguments like --foo=bar where foo is the key and bar is the value. |
protected int |
getOptimalLimit()
Return the optimal limit for fetches. |
long |
getParseDuration()
Get the value of parseDuration. |
java.util.Date |
getRestartPoint()
When the API needs to shutdown you need to call this method FIRST and persist it. |
abstract java.lang.String |
getRouter()
Return the router for this client. |
long |
getSleepDuration()
Get the value of sleepDuration. |
boolean |
hasMoreResults()
Return true if more results are available. |
protected static void |
padd(int v,
java.lang.StringBuffer buff)
|
static java.util.List |
parseChildNodesAsList(org.w3c.dom.Element current,
java.lang.String name)
|
static float |
parseFloat(java.lang.String v,
float _default)
|
static int |
parseInt(java.lang.String v)
|
protected abstract BaseResult |
parseItem(ContentApi.Entry current)
|
protected BaseResult |
parseItem(ContentApi.Entry entry,
BaseResult result)
|
protected BaseResult |
parseItem(org.w3c.dom.Element current)
Parse an individual item which might be specific to this client. |
protected BaseResult |
parseItem(org.w3c.dom.Element current,
BaseResult result)
|
static long |
parseLong(java.lang.String v)
|
static java.util.List |
parseTags(org.w3c.dom.Element current)
|
protected void |
protobufParse(ContentApi.Response response)
We've received a response from the API so parse it out. |
void |
setCallDuration(long callDuration)
Set the value of callDuration. |
void |
setConfig(Config config)
Set the value of config. |
void |
setHost(java.lang.String v)
Set the host for API alls. |
void |
setLastRequestURL(java.lang.String lastRequestURL)
Set the value of lastRequestURL. |
void |
setNextRequestURL(java.lang.String next)
Set the value of nextRequestURL. |
protected java.lang.String |
setParam(java.lang.String v,
java.lang.String key,
java.lang.Object value)
Set a parameter in the HTTP URL. |
void |
setParseDuration(long parseDuration)
Set the value of parseDuration. |
void |
setSleepDuration(long sleepDuration)
Set the value of sleepDuration. |
static java.lang.String |
toISO8601(java.util.Date date)
Return a date to an ISO 8601 value for specifying to the URL with an 'after' param. |
protected void |
xmlParse(org.w3c.dom.Document doc)
We've received a response from the API so parse it out. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface com.spinn3r.api.Client |
|---|
fetch, getResults |
| Field Detail |
|---|
public static long RETRY_MAX
public static final int RESTART_BUFFER
public static final java.lang.String NS_API
public static final java.lang.String NS_DC
public static final java.lang.String NS_ATOM
public static final java.lang.String NS_WEBLOG
public static final java.lang.String NS_SOURCE
public static final java.lang.String NS_POST
public static final java.lang.String NS_FEED
public static final java.lang.String NS_LINK
public static final java.lang.String NS_TARGET
public static final java.lang.String NS_COMMENT
public static final java.lang.String USER_AGENT_HEADER
public static final java.lang.String ACCEPT_ENCODING_HEADER
public static java.lang.String FEED_HANDLER
public static java.lang.String PERMALINK_HANDLER
public static java.lang.String COMMENT_HANDLER
public static java.lang.String LINK_HANDLER
public static final java.lang.String GZIP_ENCODING
public static java.lang.String USER_AGENT
public static java.lang.String DEFAULT_HOST
public static int NETWORKADDRESS_CACHE_TTL
public static int DEFAULT_CONNECT_TIMEOUT
public static int DEFAULT_READ_TIMEOUT
public static int DEFAULT_MAX_REDIRECTS
public static boolean DEFAULT_HTTP_KEEPALIVE
protected boolean disable_parse
protected java.util.List results
protected Config config
protected boolean isCompressed
| Constructor Detail |
|---|
public BaseClient()
| Method Detail |
|---|
public java.io.InputStream getInputStream()
throws java.io.IOException
getInputStream in interface Clientjava.io.IOException
public void fetch(Config config)
throws java.io.IOException,
ParseException,
java.lang.InterruptedException
java.io.IOException
ParseException
java.lang.InterruptedException
public ContentApi.Response doProtobufFetch(java.lang.String resource)
throws java.io.IOException,
java.lang.InterruptedException
java.io.IOException
java.lang.InterruptedException
public org.w3c.dom.Document doXmlFetch(java.lang.String resource)
throws java.io.IOException,
ParseException,
java.lang.InterruptedException
java.io.IOException
ParseException
java.lang.InterruptedException
protected void xmlParse(org.w3c.dom.Document doc)
throws java.lang.Exception
java.lang.Exception
protected void protobufParse(ContentApi.Response response)
throws java.lang.Exception
java.lang.Exceptionprotected java.lang.String generateFirstRequestURL()
protected int getMaxLimit()
protected int getOptimalLimit()
protected int getConservativeLimit()
public abstract java.lang.String getRouter()
getRouter in interface Client
protected BaseResult parseItem(org.w3c.dom.Element current)
throws java.lang.Exception
java.lang.Exception
protected abstract BaseResult parseItem(ContentApi.Entry current)
throws java.lang.Exception
java.lang.Exception
protected BaseResult parseItem(org.w3c.dom.Element current,
BaseResult result)
throws java.lang.Exception
java.lang.Exception
protected BaseResult parseItem(ContentApi.Entry entry,
BaseResult result)
throws java.lang.Exception
java.lang.Exceptionpublic boolean empty(java.lang.String value)
public static int parseInt(java.lang.String v)
public static long parseLong(java.lang.String v)
public static float parseFloat(java.lang.String v,
float _default)
public static java.util.List parseTags(org.w3c.dom.Element current)
public static java.util.List parseChildNodesAsList(org.w3c.dom.Element current,
java.lang.String name)
public static org.w3c.dom.Element getElementByTagName(org.w3c.dom.Element current,
java.lang.String name)
public static org.w3c.dom.Element getElementByTagName(org.w3c.dom.Element current,
java.lang.String name,
java.lang.String namespace)
public static java.lang.String getElementCDATAByTagName(org.w3c.dom.Element current,
java.lang.String name)
public static java.lang.String getElementCDATAByTagName(org.w3c.dom.Element current,
java.lang.String name,
java.lang.String namespace)
public static java.lang.String toISO8601(java.util.Date date)
protected static void padd(int v,
java.lang.StringBuffer buff)
public static void addParam(java.lang.StringBuffer buff,
java.lang.String name,
java.lang.Object value)
public static void addParam(java.lang.StringBuffer buff,
java.lang.String name,
java.lang.Object value,
boolean optional)
public static void addParam(java.lang.StringBuffer buff,
java.lang.String name,
java.lang.Object value,
boolean optional,
boolean urlencode)
protected java.lang.String setParam(java.lang.String v,
java.lang.String key,
java.lang.Object value)
public java.lang.String getLastRequestURL()
getLastRequestURL in interface Clientpublic void setLastRequestURL(java.lang.String lastRequestURL)
lastRequestURL.
public java.lang.String getNextRequestURL()
nextRequestURL.
getNextRequestURL in interface Clientpublic void setNextRequestURL(java.lang.String next)
nextRequestURL.
public Config getConfig()
config.
getConfig in interface Clientpublic void setConfig(Config config)
config.
setConfig in interface Clientpublic long getCallDuration()
callDuration.
getCallDuration in interface Clientpublic void setCallDuration(long callDuration)
callDuration.
public long getSleepDuration()
sleepDuration.
getSleepDuration in interface Clientpublic void setSleepDuration(long sleepDuration)
sleepDuration.
setSleepDuration in interface Clientpublic long getParseDuration()
parseDuration.
getParseDuration in interface Clientpublic void setParseDuration(long parseDuration)
parseDuration.
setParseDuration in interface Clientpublic void setHost(java.lang.String v)
setHost in interface Clientpublic java.lang.String getHost()
Client
getHost in interface Clientpublic java.util.Date getRestartPoint()
getRestartPoint in interface Clientpublic int getLimit()
public boolean hasMoreResults()
public static java.util.Map<java.lang.String,java.lang.String> getopt(java.lang.String[] args)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||