Class ArticleGetException

  • All Implemented Interfaces:
    java.io.Serializable

    public class ArticleGetException
    extends java.lang.Exception
    An exception that is thrown from inside the lambda-methods created by the class ArticleGet methods - if an error occurs while retrieving a news article body from inside a news web-page.

    yThis class is used, internally, for the occasion where the ArticleGet instance provided by a user has failed to retrieve the news-article from the page. If calling the ArticleGet.apply(...) on a News-Site Vectorized-HTML Web-Page produces null results, or an empty Vector, this exception shall throw immediately letting the user know he has to do further investigation into how to parse Article's from sites.

    Generally, almost all news-Article's on a news-site contain identical boundary HTML '<DIV>' (divider} or '<ARTICLE>' elements. Such web-pages are almost always data-base driven from stored procedures that load textual content from a data-base storage mechanism of some kind, and wrap that content inside of the surround HTML page "rigmarole." It is probably a bit overly-optimistic that a single instance of ArticleGet would perfectly retrieve the content body of every single news Article on, for example, Yahoo! News. Thus, this exception is reserved for cases where the definition for body-content retrieval fails.

    NOTE: If the internal logic that performs the scrape fails, or generates an exception, this will also cause an instance of ArticleGetException to throw.
    See Also:
    Serialized Form


    • Field Summary

       
      Serializable ID
      Modifier and Type Field
      static long serialVersionUID
       
      'final' Exception Convenience Fields
      Modifier and Type Field
      Vector<HTMLNode> page
      URL url
    • Constructor Summary

      Constructors 
      Constructor Description
      ArticleGetException​(String message)
      Creates a new ArticleGetException that may be thrown.
      ArticleGetException​(String message, Throwable cause)
      Creates a new ArticleGetException that may be thrown, having the given message, and a "previously thrown exception" (cause) - either from another thread, or caught and re-branded into an ArticleGetException
      ArticleGetException​(String message, Throwable cause, URL url, Vector<HTMLNode> page)
      When this constructor is used, the URL and page-Vector will be preserved as final (constant) fields within this class instance for future reference and debugging.
      ArticleGetException​(String message, URL url, Vector<HTMLNode> page)
      When this constructor is used, the URL and page-Vector will be preserved as final (constant) fields within this class instance for future reference and debugging.
    • Method Summary

       
      'static' Exception Check Methods
      Modifier and Type Method
      static void check​(URL url, Vector<HTMLNode> page)
      • Methods inherited from class java.lang.Throwable

        addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • serialVersionUID

        🡇     🗕  🗗  🗖
        public static final long serialVersionUID
        This fulfils the SerialVersion UID requirement for all classes that implement Java's interface java.io.Serializable. Using the Serializable Implementation offered by java is very easy, and can make saving program state when debugging a lot easier. It can also be used in place of more complicated systems like "hibernate" to store data as well.

        Note that Java's java.lang.Exception and java.lang.Error classes implement the Serializable interface, and a warning-free build expects this field be defined here.
        See Also:
        Constant Field Values
        Code:
        Exact Field Declaration Expression:
         public static final long serialVersionUID = 1;
        
      • page

        🡅  🡇     🗕  🗗  🗖
        public final java.util.Vector<HTMLNode> page
        If the code that has generated this exception has decided to pass the HTML page-Vector as a parameter to the constructor it has used, when this exception is thrown, that page will be retained in this public, final parameter. Not all four of the provided constructor's for this exception require the page and url be preserved. If the throwing code has declined to provide this reference to the constructor, then the value of this 'page' field will be null.
      • url

        🡅  🡇     🗕  🗗  🗖
        public final java.net.URL url
        If the code that has generated this exception has decided to pass the HTML page-URL as a parameter to the constructor it has used, when this exception is thrown, that page will be retained in this public, final parameter. Not all four of the provided constructor's for this exception require the 'page' and 'URL' be preserved. If the throwing code has declined to provide this reference to the constructor, then the value of this 'URL' field will be null.
    • Constructor Detail

      • ArticleGetException

        🡅  🡇     🗕  🗗  🗖
        public ArticleGetException​(java.lang.String message)
        Creates a new ArticleGetException that may be thrown.
        Parameters:
        message - An explanation of the problem encountered when using the ArticleGet consumer.
      • ArticleGetException

        🡅  🡇     🗕  🗗  🗖
        public ArticleGetException​(java.lang.String message,
                                   java.lang.Throwable cause)
        Creates a new ArticleGetException that may be thrown, having the given message, and a "previously thrown exception" (cause) - either from another thread, or caught and re-branded into an ArticleGetException
        Parameters:
        message - The explanation of the problem encountered when parsing an HTML page using the a user-defined, or factory-created ArticleGet instance.
        cause - This may be a "cause" exception. It can be caused, and facilitates a programmer catching a problem, and then re-naming it to ArticleGetException
      • ArticleGetException

        🡅  🡇     🗕  🗗  🗖
        public ArticleGetException​(java.lang.String message,
                                   java.net.URL url,
                                   java.util.Vector<HTMLNode> page)
        When this constructor is used, the URL and page-Vector will be preserved as final (constant) fields within this class instance for future reference and debugging.
        Parameters:
        message - The explanation of the problem encountered when parsing an HTML page using the a user-defined, or factory-created ArticleGet instance.
        url - The URL from which the original HTML page-Vector was retrieved
        page - The HTML page (as a Vector) that could not be resolved by the ArticleGet instance which threw this exception.
      • ArticleGetException

        🡅  🡇     🗕  🗗  🗖
        public ArticleGetException​(java.lang.String message,
                                   java.lang.Throwable cause,
                                   java.net.URL url,
                                   java.util.Vector<HTMLNode> page)
        When this constructor is used, the URL and page-Vector will be preserved as final (constant) fields within this class instance for future reference and debugging. If there was an underlying exception that caused the article-body retrieval to fail, that will be stored in the Java getCause(); method available.
        Parameters:
        message - The explanation of the problem encountered when parsing an HTML page using the a user-defined, or factory-created ArticleGet instance.
        cause - This may be a "cause" exception. It can be caused, and facilitates a programmer catching a problem, and then re-naming it to ArticleGetException
        url - The URL from which the original HTML page-Vector was retrieved
        page - The HTML page (as a Vector) that could not be resolved by the ArticleGet instance which threw this exception.
    • Method Detail

      • check

        🡅     🗕  🗗  🗖
        public static void check​(java.net.URL url,
                                 java.util.Vector<HTMLNode> page)
                          throws ArticleGetException
        When this constructor is used, the URL and page-Vector will be preserved as final (constant) fields within this class instance for future reference and debugging.
        Parameters:
        url - The URL from which the original HTML page-Vector was retrieved
        page - The HTML page (as a Vector) that could not be resolved by the ArticleGet instance which threw this exception.
        Throws:
        ArticleGetException
        Code:
        Exact Method Body:
         if (url == null) throw new ArticleGetException
             ("ArticleGet.apply(...) has been called with a null URL.", url, page);
        
         if (page == null) throw new ArticleGetException
             ("ArticleGet.apply(...) has been called with a null page-vector.", url, page);
        
         if (page.size() == 0) throw new ArticleGetException
             ("ArticleGet.apply(...) has been called with a zero-length page-vector.", url, page);