diff options
Diffstat (limited to 'pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/MobileBKUHelper.java')
-rw-r--r-- | pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/MobileBKUHelper.java | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/MobileBKUHelper.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/MobileBKUHelper.java index 410ba3c1..04397f14 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/MobileBKUHelper.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/MobileBKUHelper.java @@ -24,6 +24,11 @@ import org.apache.commons.httpclient.Cookie; import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.HttpState; import org.apache.commons.httpclient.protocol.Protocol; +import org.jsoup.nodes.Document; +import org.jsoup.nodes.Element; +import org.jsoup.nodes.Node; +import org.jsoup.select.Elements; +import org.jsoup.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -148,6 +153,23 @@ public class MobileBKUHelper { } return found.substring(startidx + 1, endidx); } + + /** + * This method is the same as the non optional method but instead of throwing the exception it returns null + * @return the string or null + */ + public static String extractValueFromTagWithParamOptional(String data, String tag, + String param, String value, String returnparam) { + String str; + try { + str = extractValueFromTagWithParam(data, tag, param, value, returnparam); + } catch (Exception e) { + log.debug("Optional value is not available"); + str = null; + } + return str; + + } /** * Extracts the content from an XML tag from data with the given param="value" @@ -291,4 +313,21 @@ public class MobileBKUHelper { } return client; } + + /*** + * + * @param htmlString describes the html data in String representation + * @param attributeName is the attribute which should be selected + * @return returns the attribute name or null otherswise + */ + public static String getNameAttribute(String htmlString, String attributeName) { + + Document doc = Jsoup.parse(htmlString); + Elements inputs = doc.select("div input#" + attributeName); + + if (inputs.size() == 0 ) return null; + + String name = inputs.get(0).attr("name"); + return name; + } } |