es.gob.fnmt.net

## Class DroidHttpClient.Parse

- java.lang.Object
- - es.gob.fnmt.net.DroidHttpClient.Parse

- Enclosing class:
    DroidHttpClient

      public static final class DroidHttpClient.Parse
      extends java.lang.Object

  Class to manipulate the HTML content recovered.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `DEFAULT_ATTR_LINK_TAG`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Parse(java.lang.String document)` Constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `filterByTag(java.lang.String tag)` Keep only the content that is under the selected tag.
    `java.lang.String` | `getContent()` Get the html document as a string.
    `org.jsoup.nodes.Element` | `getDocument()` Return the document as an org.jsoup.nodes.Element instance.
    `java.lang.String` | `getURLbyText(java.lang.String text)` Recover the URL in the 'href' attribute, matching the passed text.
    `java.lang.String` | `getURLbyText(java.lang.String text, java.lang.String attribute)` Recover the URL attribute matching the passed text.
    `void` | `removeLinks()` Delete all the links (tag 'a') from the document.
    `void` | `resetContent(java.lang.String document)` Reset the content of the document.
    `void` | `setBaseDocument(java.io.InputStream htmlBase, java.lang.String charsetName, java.lang.String baseUri)` Injects the document element into the base document.

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### DEFAULT_ATTR_LINK_TAG

          public static final java.lang.String DEFAULT_ATTR_LINK_TAG

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### Parse

          public Parse(java.lang.String document)

      Constructor.
      Parameters:
        `document` - html content to manipulate.

  - ### Method Detail

    - #### filterByTag

          public void filterByTag(java.lang.String tag)
                           throws java.lang.Exception

      Keep only the content that is under the selected tag.
      Parameters:
        `tag` - selected tag.
      Throws:
        `java.lang.Exception`

    - #### getContent

          public java.lang.String getContent()

      Get the html document as a string.
      Returns:
        html content as a string.

    - #### getDocument

          public org.jsoup.nodes.Element getDocument()

      Return the document as an org.jsoup.nodes.Element instance.
      Returns:
        the document.

    - #### getURLbyText

          public java.lang.String getURLbyText(java.lang.String text)
                                        throws java.lang.Exception

      Recover the URL in the 'href' attribute, matching the passed text.
      Parameters:
        `text` - where to search the URL.
      Returns:
        URL found.
      Throws:
        `java.lang.Exception`

    - #### getURLbyText

          public java.lang.String getURLbyText(java.lang.String text,
                                               java.lang.String attribute)
                                        throws java.lang.Exception

      Recover the URL attribute matching the passed text.
      Parameters:
        `text` - where to search the URL.
        `attribute` - attribute that owns the URL ('href' in most of cases).
      Returns:
        URL found
      Throws:
        `java.lang.Exception`

    - #### removeLinks

          public void removeLinks()

      Delete all the links (tag 'a') from the document.

    - #### resetContent

          public void resetContent(java.lang.String document)

      Reset the content of the document.
      Parameters:
        `document` -

    - #### setBaseDocument

          public void setBaseDocument(java.io.InputStream htmlBase,
                                      java.lang.String charsetName,
                                      java.lang.String baseUri)
                               throws java.lang.Exception

      Injects the document element into the base document.
      Parameters:
        `htmlBase` - base html document (it must have basic html structure (html/body).
        `charsetName` - charset to use, for example 'UTF-8'.
        `baseUri` - URI of the base document.
      Throws:
        `java.lang.Exception`