Class HtmlDocument


  • public class HtmlDocument
    extends java.lang.Object
    This classes provides implementation to retrieve urls from specified tags on an HTML page.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static fr.paris.lutece.util.mail.HtmlDocument.ElementUrl ELEMENT_CSS
      To define a CSS, html element must have: "link" tag name "rel" attribute equal to "stylesheet" The url is contained in the attributed named "href"
      static fr.paris.lutece.util.mail.HtmlDocument.ElementUrl ELEMENT_IMG
      To define an image, html element must have: "img" tag name The url is contained in the attributed named "src"
      static fr.paris.lutece.util.mail.HtmlDocument.ElementUrl ELEMENT_JAVASCRIPT
      To define a javascript, html element must have: "script" tag name "type" attribute equal to "text/javascript" The url is contained in the attributed named "src"
    • Constructor Summary

      Constructors 
      Constructor Description
      HtmlDocument​(java.lang.String strHtml, java.lang.String strBaseUrl, boolean useAbsoluteUrl)
      Instanciates an HtmlDocument after having built the DOM tree.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Map<java.lang.String,​java.net.URL> getAllUrls​(fr.paris.lutece.util.mail.HtmlDocument.ElementUrl elementType)
      Get the urls of all html elements specified by elementType
      java.util.List<UrlAttachment> getAllUrlsAttachement​(fr.paris.lutece.util.mail.HtmlDocument.ElementUrl elementType)
      Get the urls of all html elements specified by elementType
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • ELEMENT_CSS

        public static final fr.paris.lutece.util.mail.HtmlDocument.ElementUrl ELEMENT_CSS
        To define a CSS, html element must have:
        • "link" tag name
        • "rel" attribute equal to "stylesheet"
        The url is contained in the attributed named "href"
      • ELEMENT_JAVASCRIPT

        public static final fr.paris.lutece.util.mail.HtmlDocument.ElementUrl ELEMENT_JAVASCRIPT
        To define a javascript, html element must have:
        • "script" tag name
        • "type" attribute equal to "text/javascript"
        The url is contained in the attributed named "src"
      • ELEMENT_IMG

        public static final fr.paris.lutece.util.mail.HtmlDocument.ElementUrl ELEMENT_IMG
        To define an image, html element must have:
        • "img" tag name
        The url is contained in the attributed named "src"
    • Constructor Detail

      • HtmlDocument

        public HtmlDocument​(java.lang.String strHtml,
                            java.lang.String strBaseUrl,
                            boolean useAbsoluteUrl)
        Instanciates an HtmlDocument after having built the DOM tree.
        Parameters:
        strHtml - The Html code to be parsed.
        strBaseUrl - The Base url used to retrieve urls.
        useAbsoluteUrl - Determine if we use absolute or relative url for HTML element's names
    • Method Detail

      • getAllUrls

        public java.util.Map<java.lang.String,​java.net.URL> getAllUrls​(fr.paris.lutece.util.mail.HtmlDocument.ElementUrl elementType)
        Get the urls of all html elements specified by elementType
        Parameters:
        elementType - the type of element to get
        Returns:
        a Collection containing the urls. Those urls are Objects, as defined by getUrl().
      • getAllUrlsAttachement

        public java.util.List<UrlAttachment> getAllUrlsAttachement​(fr.paris.lutece.util.mail.HtmlDocument.ElementUrl elementType)
        Get the urls of all html elements specified by elementType
        Parameters:
        elementType - the type of element to get
        Returns:
        a Collection containing the urls. Those urls are Objects, as defined by getUrl().