com.google.common.base.Predicate<org.apache.http.HttpResponse>, Filter<org.apache.http.HttpResponse>, FlyweightPrototype<Filter<org.apache.http.HttpResponse>>, java.util.function.Predicate<org.apache.http.HttpResponse>public class IsProbablyBinary extends AbstractFilter<org.apache.http.HttpResponse>
| Modifier and Type | Field | Description |
|---|---|---|
static int |
BINARY_CHECK_SCAN_LENGTH |
|
static IsProbablyBinary |
INSTANCE |
|
static int |
THRESHOLD |
The number of zeroes that must appear to cause the page to be considered probably
binary.
|
FILTER_PACKAGE_NAME| Modifier and Type | Method | Description |
|---|---|---|
boolean |
apply(org.apache.http.HttpResponse httpResponse) |
This method implements a simple heuristic for guessing whether a page is binary.
|
Filter<org.apache.http.HttpResponse> |
copy() |
|
java.lang.String |
toString() |
A string representation of the state of this filter.
|
static IsProbablyBinary |
valueOf() |
Get a new
IsProbablyBinary that will accept only http responses whose content stream appears to be binary. |
static IsProbablyBinary |
valueOf(java.lang.String emptySpec) |
Deprecated.
Please use
valueOf() instead. |
toStringpublic static final IsProbablyBinary INSTANCE
public static final int BINARY_CHECK_SCAN_LENGTH
public static final int THRESHOLD
public boolean apply(org.apache.http.HttpResponse httpResponse)
The first BINARY_CHECK_SCAN_LENGTH bytes are scanned: if we find more than
THRESHOLD zeroes, we deduce that this page is binary. Note that this works
also with UTF-8, as no UTF-8 legal character encoding contains these characters (unless
you're encoding 0, but this is not our case).
true if this page has most probably a binary content.java.lang.NullPointerException - if the page has no byte content.@Deprecated public static IsProbablyBinary valueOf(java.lang.String emptySpec)
valueOf() instead.IsProbablyBinary that will accept only http responses whose content stream appears to be binary.emptySpec - an empty string.IsProbablyBinary that will accept only http responses whose content stream appears to be binary.public static IsProbablyBinary valueOf()
IsProbablyBinary that will accept only http responses whose content stream appears to be binary.IsProbablyBinary that will accept only http responses whose content stream appears to be binary.public java.lang.String toString()
toString in class java.lang.Objectpublic Filter<org.apache.http.HttpResponse> copy()