public abstract class Client
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
_password |
protected java.lang.String |
_username |
static java.lang.String |
API_VERSION |
static int |
DEFAULT_TIMEOUT |
boolean |
isVerbose
Client verbosity flag.
|
static int |
POLLS_INTERVAL |
static int |
SOFTWARE_VENDOR_ID |
Modifier | Constructor and Description |
---|---|
protected |
Client(java.lang.String username,
java.lang.String password) |
Modifier and Type | Method and Description |
---|---|
abstract void |
close()
Closes opened connections (if any), cleans up resources.
|
abstract boolean |
connect()
Opens API-specific connection if not opened yet.
|
Captcha |
decode(byte[] img) |
Captcha |
decode(byte[] img,
int type) |
Captcha |
decode(byte[] img,
int type,
byte[] banner,
java.lang.String banner_text) |
Captcha |
decode(byte[] img,
int type,
int timeout) |
Captcha |
decode(byte[] img,
java.lang.String challenge) |
Captcha |
decode(byte[] img,
java.lang.String challenge,
int timeout) |
Captcha |
decode(byte[] img,
java.lang.String challenge,
int type,
byte[] banner,
java.lang.String banner_text,
int timeout) |
Captcha |
decode(byte[] img,
java.lang.String challenge,
int type,
byte[] banner,
java.lang.String banner_text,
java.lang.String grid,
int timeout)
Tries to solve a CAPTCHA by uploading it and polling for its status and text with arbitrary timeout.
|
Captcha |
decode(java.io.File f) |
Captcha |
decode(java.io.File f,
int timeout) |
Captcha |
decode(java.io.File f,
int type,
java.io.File banner_f,
java.lang.String banner_text) |
Captcha |
decode(java.io.File f,
int type,
int timeout) |
Captcha |
decode(java.io.File f,
java.lang.String challenge) |
Captcha |
decode(java.io.File f,
java.lang.String challenge,
int timeout) |
Captcha |
decode(java.io.File f,
java.lang.String challenge,
int type,
java.io.File banner_f,
java.lang.String banner_text,
int timeout) |
Captcha |
decode(java.io.InputStream st) |
Captcha |
decode(java.io.InputStream st,
int timeout) |
Captcha |
decode(java.io.InputStream st,
int type,
java.io.InputStream banner_st,
java.lang.String banner_text) |
Captcha |
decode(java.io.InputStream st,
int type,
java.io.InputStream banner_st,
java.lang.String banner_text,
java.lang.String grid) |
Captcha |
decode(java.io.InputStream st,
int type,
int timeout) |
Captcha |
decode(java.io.InputStream st,
java.lang.String challenge) |
Captcha |
decode(java.io.InputStream st,
java.lang.String challenge,
int timeout) |
Captcha |
decode(java.io.InputStream st,
java.lang.String challenge,
int type,
java.io.InputStream banner_st,
java.lang.String banner_text,
int timeout) |
Captcha |
decode(java.io.InputStream st,
java.lang.String challenge,
int type,
java.io.InputStream banner_st,
java.lang.String banner_text,
java.lang.String grid,
int timeout) |
Captcha |
decode(java.lang.String fn) |
Captcha |
decode(java.lang.String fn,
int timeout) |
Captcha |
decode(java.lang.String fn,
int type,
int timeout) |
Captcha |
decode(java.lang.String fn,
int type,
java.lang.String banner_fn,
java.lang.String banner_text) |
Captcha |
decode(java.lang.String fn,
int type,
java.lang.String banner_fn,
java.lang.String banner_text,
int timeout) |
Captcha |
decode(java.lang.String fn,
java.lang.String challenge) |
Captcha |
decode(java.lang.String fn,
java.lang.String challenge,
int timeout) |
Captcha |
decode(java.lang.String fn,
java.lang.String challenge,
int type,
java.lang.String banner_fn,
java.lang.String banner_text,
int timeout) |
double |
getBalance()
Fetches user balance (in US cents).
|
Captcha |
getCaptcha(Captcha captcha) |
abstract Captcha |
getCaptcha(int id)
Fetches an uploaded CAPTCHA details.
|
protected org.json.JSONObject |
getCredentials() |
java.lang.String |
getText(Captcha captcha) |
java.lang.String |
getText(int id)
Fetches an uploaded CAPTCHA text.
|
abstract User |
getUser()
Fetches user details.
|
protected byte[] |
load(java.io.File f) |
protected byte[] |
load(java.io.InputStream st) |
byte[] |
load(java.lang.String fn) |
protected void |
log(java.lang.String call) |
protected void |
log(java.lang.String call,
java.lang.String msg) |
boolean |
report(Captcha captcha) |
abstract boolean |
report(int id)
Reports an incorrectly solved CAPTCHA
|
abstract Captcha |
upload(byte[] img) |
abstract Captcha |
upload(byte[] img,
int type,
byte[] banner,
java.lang.String banner_text) |
abstract Captcha |
upload(byte[] img,
java.lang.String challenge,
int type,
byte[] banner,
java.lang.String banner_text) |
abstract Captcha |
upload(byte[] img,
java.lang.String challenge,
int type,
byte[] banner,
java.lang.String banner_text,
java.lang.String grid)
Uploads a CAPTCHA to the service.
|
Captcha |
upload(java.io.File f) |
Captcha |
upload(java.io.InputStream st) |
Captcha |
upload(java.lang.String fn) |
public static final java.lang.String API_VERSION
public static final int SOFTWARE_VENDOR_ID
public static final int DEFAULT_TIMEOUT
public static final int POLLS_INTERVAL
public boolean isVerbose
When it's set to true, the client will dump API calls for debug purpose.
protected java.lang.String _username
protected java.lang.String _password
protected Client(java.lang.String username, java.lang.String password)
username
- DBC account usernamepassword
- DBC account passwordprotected void log(java.lang.String call, @Nullable java.lang.String msg)
protected void log(java.lang.String call)
protected org.json.JSONObject getCredentials()
@NotNull protected byte[] load(@NotNull java.io.InputStream st) throws java.io.IOException
java.io.IOException
@NotNull protected byte[] load(@NotNull java.io.File f) throws java.io.IOException, java.io.FileNotFoundException
java.io.IOException
java.io.FileNotFoundException
@NotNull public byte[] load(@NotNull java.lang.String fn) throws java.io.IOException, java.io.FileNotFoundException
java.io.IOException
java.io.FileNotFoundException
public abstract void close()
public abstract boolean connect() throws java.io.IOException
java.io.IOException
@NotNull public abstract User getUser() throws java.io.IOException, Exception
java.io.IOException
Exception
public double getBalance() throws java.io.IOException, Exception
java.io.IOException
Exception
@Nullable public abstract Captcha upload(byte[] img, java.lang.String challenge, int type, byte[] banner, java.lang.String banner_text, java.lang.String grid) throws java.io.IOException, Exception
img
- CAPTCHA image byte vectorjava.io.IOException
Exception
@Nullable public abstract Captcha upload(byte[] img, java.lang.String challenge, int type, byte[] banner, java.lang.String banner_text) throws java.io.IOException, Exception
java.io.IOException
Exception
@NotNull public abstract Captcha upload(byte[] img, int type, byte[] banner, java.lang.String banner_text) throws java.io.IOException, Exception
java.io.IOException
Exception
@Nullable public abstract Captcha upload(byte[] img) throws java.io.IOException, Exception
java.io.IOException
Exception
@Nullable public Captcha upload(@NotNull java.io.InputStream st) throws java.io.IOException, Exception
st
- CAPTCHA image streamjava.io.IOException
Exception
upload(byte[], java.lang.String, int, byte[], java.lang.String, java.lang.String)
@Nullable public Captcha upload(@NotNull java.io.File f) throws java.io.IOException, java.io.FileNotFoundException, Exception
f
- CAPTCHA image filejava.io.IOException
java.io.FileNotFoundException
Exception
upload(byte[], java.lang.String, int, byte[], java.lang.String, java.lang.String)
@Nullable public Captcha upload(@NotNull java.lang.String fn) throws java.io.IOException, java.io.FileNotFoundException, Exception
fn
- CAPTCHA image file namejava.io.IOException
java.io.FileNotFoundException
Exception
upload(byte[], java.lang.String, int, byte[], java.lang.String, java.lang.String)
@NotNull public abstract Captcha getCaptcha(int id) throws java.io.IOException, Exception
id
- CAPTCHA IDjava.io.IOException
Exception
@NotNull public Captcha getCaptcha(@NotNull Captcha captcha) throws java.io.IOException, Exception
captcha
- CAPTCHA objectjava.io.IOException
Exception
getCaptcha(int)
public java.lang.String getText(int id) throws java.io.IOException, Exception
id
- CAPTCHA IDjava.io.IOException
Exception
public java.lang.String getText(@NotNull Captcha captcha) throws java.io.IOException, Exception
captcha
- CAPTCHA objectjava.io.IOException
Exception
getText(int)
public abstract boolean report(int id) throws java.io.IOException, Exception
id
- CAPTCHA IDjava.io.IOException
Exception
public boolean report(@NotNull Captcha captcha) throws java.io.IOException, Exception
captcha
- CAPTCHA objectjava.io.IOException
Exception
report(int)
@Nullable public Captcha decode(byte[] img, java.lang.String challenge, int type, byte[] banner, java.lang.String banner_text, java.lang.String grid, int timeout) throws java.io.IOException, Exception, java.lang.InterruptedException
img
- CAPTCHA image byte vectortimeout
- Solving timeout (in seconds)java.io.IOException
Exception
java.lang.InterruptedException
@Nullable public Captcha decode(byte[] img, java.lang.String challenge, int type, byte[] banner, java.lang.String banner_text, int timeout) throws java.io.IOException, Exception, java.lang.InterruptedException
java.io.IOException
Exception
java.lang.InterruptedException
@Nullable public Captcha decode(byte[] img, int type, byte[] banner, java.lang.String banner_text) throws java.io.IOException, Exception, java.lang.InterruptedException
java.io.IOException
Exception
java.lang.InterruptedException
@Nullable public Captcha decode(byte[] img, int type) throws java.io.IOException, Exception, java.lang.InterruptedException
java.io.IOException
Exception
java.lang.InterruptedException
@Nullable public Captcha decode(byte[] img, java.lang.String challenge) throws java.io.IOException, Exception, java.lang.InterruptedException
java.io.IOException
Exception
java.lang.InterruptedException
@Nullable public Captcha decode(byte[] img, int type, int timeout) throws java.io.IOException, Exception, java.lang.InterruptedException
java.io.IOException
Exception
java.lang.InterruptedException
@Nullable public Captcha decode(byte[] img, java.lang.String challenge, int timeout) throws java.io.IOException, Exception, java.lang.InterruptedException
java.io.IOException
Exception
java.lang.InterruptedException
@Nullable public Captcha decode(byte[] img) throws java.io.IOException, Exception, java.lang.InterruptedException
java.io.IOException
Exception
java.lang.InterruptedException
decode(byte[], int)
@Nullable public Captcha decode(@NotNull java.io.InputStream st, java.lang.String challenge, int type, @NotNull java.io.InputStream banner_st, java.lang.String banner_text, java.lang.String grid, int timeout) throws java.io.IOException, Exception, java.lang.InterruptedException
st
- CAPTCHA image streamtimeout
- Solving timeout (in seconds)java.io.IOException
Exception
java.lang.InterruptedException
decode(byte[], java.lang.String, int, byte[], java.lang.String, java.lang.String, int)
@Nullable public Captcha decode(@NotNull java.io.InputStream st, java.lang.String challenge, int type, @NotNull java.io.InputStream banner_st, java.lang.String banner_text, int timeout) throws java.io.IOException, Exception, java.lang.InterruptedException
java.io.IOException
Exception
java.lang.InterruptedException
@Nullable public Captcha decode(@NotNull java.io.InputStream st, int type, @NotNull java.io.InputStream banner_st, java.lang.String banner_text, java.lang.String grid) throws java.io.IOException, Exception, java.lang.InterruptedException
java.io.IOException
Exception
java.lang.InterruptedException
@Nullable public Captcha decode(@NotNull java.io.InputStream st, int type, @NotNull java.io.InputStream banner_st, java.lang.String banner_text) throws java.io.IOException, Exception, java.lang.InterruptedException
java.io.IOException
Exception
java.lang.InterruptedException
@Nullable public Captcha decode(@NotNull java.io.InputStream st, int type, int timeout) throws java.io.IOException, Exception, java.lang.InterruptedException
java.io.IOException
Exception
java.lang.InterruptedException
@Nullable public Captcha decode(@NotNull java.io.InputStream st, java.lang.String challenge) throws java.io.IOException, Exception, java.lang.InterruptedException
java.io.IOException
Exception
java.lang.InterruptedException
@Nullable public Captcha decode(@NotNull java.io.InputStream st, java.lang.String challenge, int timeout) throws java.io.IOException, Exception, java.lang.InterruptedException
java.io.IOException
Exception
java.lang.InterruptedException
@Nullable public Captcha decode(@NotNull java.io.InputStream st, int timeout) throws java.io.IOException, Exception, java.lang.InterruptedException
java.io.IOException
Exception
java.lang.InterruptedException
@Nullable public Captcha decode(@NotNull java.io.InputStream st) throws java.io.IOException, Exception, java.lang.InterruptedException
java.io.IOException
Exception
java.lang.InterruptedException
decode(InputStream, int)
@Nullable public Captcha decode(@NotNull java.io.File f, java.lang.String challenge, int type, @NotNull java.io.File banner_f, java.lang.String banner_text, int timeout) throws java.io.IOException, Exception, java.lang.InterruptedException
f
- CAPTCHA image filetimeout
- Solving timeout (in seconds)java.io.IOException
Exception
java.lang.InterruptedException
decode(byte[], java.lang.String, int, byte[], java.lang.String, java.lang.String, int)
@Nullable public Captcha decode(@NotNull java.io.File f, int type, @NotNull java.io.File banner_f, java.lang.String banner_text) throws java.io.IOException, Exception, java.lang.InterruptedException
java.io.IOException
Exception
java.lang.InterruptedException
@Nullable public Captcha decode(@NotNull java.io.File f, int type, int timeout) throws java.io.IOException, Exception, java.lang.InterruptedException
java.io.IOException
Exception
java.lang.InterruptedException
@Nullable public Captcha decode(@NotNull java.io.File f, java.lang.String challenge) throws java.io.IOException, Exception, java.lang.InterruptedException
java.io.IOException
Exception
java.lang.InterruptedException
@Nullable public Captcha decode(@NotNull java.io.File f, java.lang.String challenge, int timeout) throws java.io.IOException, Exception, java.lang.InterruptedException
java.io.IOException
Exception
java.lang.InterruptedException
@Nullable public Captcha decode(@NotNull java.io.File f, int timeout) throws java.io.IOException, java.io.FileNotFoundException, Exception, java.lang.InterruptedException
java.io.IOException
java.io.FileNotFoundException
Exception
java.lang.InterruptedException
@Nullable public Captcha decode(@NotNull java.io.File f) throws java.io.IOException, java.io.FileNotFoundException, Exception, java.lang.InterruptedException
java.io.IOException
java.io.FileNotFoundException
Exception
java.lang.InterruptedException
decode(File, int)
@Nullable public Captcha decode(@NotNull java.lang.String fn, java.lang.String challenge, int type, @NotNull java.lang.String banner_fn, java.lang.String banner_text, int timeout) throws java.io.IOException, Exception, java.lang.InterruptedException
fn
- CAPTCHA image file nametimeout
- Solving timeout (in seconds)java.io.IOException
Exception
java.lang.InterruptedException
decode(byte[], java.lang.String, int, byte[], java.lang.String, java.lang.String, int)
@Nullable public Captcha decode(@NotNull java.lang.String fn, int type, @NotNull java.lang.String banner_fn, java.lang.String banner_text) throws java.io.IOException, Exception, java.lang.InterruptedException
java.io.IOException
Exception
java.lang.InterruptedException
@Nullable public Captcha decode(@NotNull java.lang.String fn, int type, @NotNull java.lang.String banner_fn, java.lang.String banner_text, int timeout) throws java.io.IOException, Exception, java.lang.InterruptedException
java.io.IOException
Exception
java.lang.InterruptedException
@Nullable public Captcha decode(@NotNull java.lang.String fn, int type, int timeout) throws java.io.IOException, Exception, java.lang.InterruptedException
java.io.IOException
Exception
java.lang.InterruptedException
@Nullable public Captcha decode(@NotNull java.lang.String fn, java.lang.String challenge) throws java.io.IOException, Exception, java.lang.InterruptedException
java.io.IOException
Exception
java.lang.InterruptedException
@Nullable public Captcha decode(@NotNull java.lang.String fn, java.lang.String challenge, int timeout) throws java.io.IOException, Exception, java.lang.InterruptedException
java.io.IOException
Exception
java.lang.InterruptedException
@Nullable public Captcha decode(@NotNull java.lang.String fn, int timeout) throws java.io.IOException, java.io.FileNotFoundException, Exception, java.lang.InterruptedException
java.io.IOException
java.io.FileNotFoundException
Exception
java.lang.InterruptedException