|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object cz.vity.freerapid.plugins.webclient.utils.PlugUtils
public final class PlugUtils
Constructor Summary | |
---|---|
PlugUtils()
|
Method Summary | |
---|---|
static void |
addParameters(org.apache.commons.httpclient.methods.PostMethod postMethod,
String content,
String[] parameters)
Parses content and search for parameter's value in tag form. |
static boolean |
find(String regexp,
String contentString)
Help method to test whether given regular expression matches given content string. |
static long |
getFileSizeFromString(String value)
Parses input string and converts it into bytes. |
static int |
getNumberBetween(String content,
String stringBefore,
String stringAfter)
Returns number between 2 other strings. |
static String |
getParameter(String name,
String content)
Find and return value of given parameter in html tag (eg. input). |
static String |
getStringBetween(String content,
String stringBefore,
String stringAfter)
Returns string between 2 other strings. |
static int |
getWaitTimeBetween(String content,
String stringBefore,
String stringAfter,
TimeUnit srcTimeUnit)
Returns time value in seconds between 2 other strings. |
static void |
checkFileSize(HttpFile file,
String content,
String fileSizeBefore,
String fileSizeAfter)
Extracts file name from the site |
static void |
checkName(HttpFile file,
String content,
String fileNameBefore,
String fileNameAfter)
Extracts file name from the site. |
static Matcher |
matcher(String regexp,
String contentString)
Help method to get Matcher for given regular expression and string. |
static String |
recognize(BufferedImage image,
String commandLineOptions)
Method calls GOCR implementation to recognize text from image. |
static String |
replaceEntities(String s)
Replace entity \& with character &. |
static String |
unescapeHtml(String str)
Unescapes a string containing entity escapes to a string containing the actual Unicode characters corresponding to the escapes. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public PlugUtils()
Method Detail |
---|
public static long getFileSizeFromString(String value)
1.35 Gb, 0.5 Mb 5 465kB, 45654 6544 bytes, 54654654, 280B, also buggy 280BB
- default value is B
value
- input string parsed from page
public static Matcher matcher(String regexp, String contentString)
regexp
- regular expressioncontentString
- string that is searched for regular expression pattern
Pattern
public static boolean find(String regexp, String contentString)
regexp
- regular expressioncontentString
- string that is searched for regular expression pattern
Pattern
public static String unescapeHtml(String str)
Unescapes a string containing entity escapes to a string containing the actual Unicode characters corresponding to the escapes. Supports HTML 4.0 entities.
For example, the string "<Français>" will become "<Français>"
If an entity is unrecognized, it is left alone, and inserted verbatim into the result string. e.g. ">&zzzz;x" will become ">&zzzz;x".
str
- the String
to unescape, may be null
String
, null
if null string inputpublic static String getParameter(String name, String content) throws PluginImplementationException
Find and return value of given parameter in html tag (eg. input).
For example, the for content "input type="hidden" name="par" value="val>"
and parameter "par" returns "val"
name
- name of parametercontent
- String
to search in
String
value of parameter
PluginImplementationException
- given name not found in given contentpublic static void addParameters(org.apache.commons.httpclient.methods.PostMethod postMethod, String content, String[] parameters) throws PluginImplementationException
<form>
should have structure name="paramName" .... value="paramValue"
This parameter and its value are added to POST method.
postMethod
- method to add found parameterscontent
- String
to search inparameters
- form parameter names
PluginImplementationException
- any of the parameter were not found in given contentgetParameter(String, String)
public static String replaceEntities(String s)
Replace entity \& with character &.
Used in partly decode given URL, where unescapeHtml is not suitable
s
- String
where replace
String
with replacementpublic static String recognize(BufferedImage image, String commandLineOptions)
image
- an image from which text should be recognizedcommandLineOptions
- additional command line options for GOCR application
public static void checkName(HttpFile file, String content, String fileNameBefore, String fileNameAfter) throws PluginImplementationException
file
- file to apply found file namecontent
- content to searchfileNameBefore
- string before file name, character '\n' is replaced as \\s*fileNameAfter
- string after file name, character '\n' is replaced as \\s*
PluginImplementationException
- file name was not foundpublic static void checkFileSize(HttpFile file, String content, String fileSizeBefore, String fileSizeAfter) throws PluginImplementationException
file
- file to apply found file namecontent
- content to searchfileSizeBefore
- string before file name - without white space characters on the RIGHT side, character '\n' is replaced as \\s*fileSizeAfter
- string after file name - without white space characters on the LEFT side, character '\n' is replaced as \\s*
PluginImplementationException
- file size string was not foundpublic static String getStringBetween(String content, String stringBefore, String stringAfter) throws PluginImplementationException
content
- searched contentstringBefore
- string before searched string - without white space characters on the RIGHT sidestringAfter
- string after searched string - without white space characters on the LEFT side
PluginImplementationException
- No string between stringBefore and stringAfterpublic static int getNumberBetween(String content, String stringBefore, String stringAfter) throws PluginImplementationException
content
- searched contentstringBefore
- string before searched string - without white space characters on the RIGHT sidestringAfter
- string after searched string - without white space characters on the LEFT side
PluginImplementationException
- No number between stringBefore and stringAfterpublic static int getWaitTimeBetween(String content, String stringBefore, String stringAfter, TimeUnit srcTimeUnit) throws PluginImplementationException
content
- searched contentstringBefore
- string before searched string - without white space characters on the RIGHT sidestringAfter
- string after searched string - without white space characters on the LEFT sidesrcTimeUnit
- source time unit - usually TimeUnit.SECONDS
or TimeUnit.MILLISECONDS
PluginImplementationException
- No wait time value between stringBefore and stringAfter
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |