Package Torello.HTML.Tools.NewsSite
Class ArticleGetException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- Torello.HTML.Tools.NewsSite.ArticleGetException
-
- All Implemented Interfaces:
java.io.Serializable
public class ArticleGetException extends java.lang.Exception
An exception that is thrown from inside thelambda-methodscreated by the classArticleGetmethods - 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 theArticleGetinstance provided by a user has failed to retrieve the news-article from the page. If calling theArticleGet.apply(...)on a News-Site Vectorized-HTML Web-Page produces null results, or an emptyVector, this exception shall throw immediately letting the user know he has to do further investigation into how to parseArticle'sfrom sites.
Generally, almost all news-Article'son 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 ofArticleGetwould perfectly retrieve the content body of every single newsArticleon, 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 ofArticleGetExceptionto throw.- See Also:
- Serialized Form
Hi-Lited Source-Code:- View Here: Torello/HTML/Tools/NewsSite/ArticleGetException.java
- Open New Browser-Tab: Torello/HTML/Tools/NewsSite/ArticleGetException.java
File Size: 7,402 Bytes Line Count: 170 '\n' Characters Found
-
-
Field Summary
Serializable ID Modifier and Type Field static longserialVersionUID'final'Exception Convenience FieldsModifier and Type Field Vector<HTMLNode>pageURLurl
-
Constructor Summary
Constructors Constructor ArticleGetException(String message)ArticleGetException(String message, Throwable cause)ArticleGetException(String message, Throwable cause, URL url, Vector<HTMLNode> page)ArticleGetException(String message, URL url, Vector<HTMLNode> page)
-
Method Summary
'static'Exception Check MethodsModifier and Type Method static voidcheck(URL url, Vector<HTMLNode> page)
-
-
-
Field Detail
-
serialVersionUID
public static final long serialVersionUID
This fulfils the SerialVersion UID requirement for all classes that implement Java'sinterface java.io.Serializable. Using theSerializableImplementation 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'sjava.lang.Exceptionandjava.lang.Errorclasses implement theSerializable interface, and a warning-free build expects this field be defined here.- See Also:
- Constant Field Values
-
page
public final java.util.Vector<HTMLNode> page
If the code that has generated this exception has decided to pass the HTML page-Vectoras a parameter to the constructor it has used, when this exception is thrown, that page will be retained in thispublic, finalparameter. Not all four of the provided constructor's for this exception require thepageandurlbe 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-URLas a parameter to the constructor it has used, when this exception is thrown, that page will be retained in thispublic, finalparameter. 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 newArticleGetExceptionthat may be thrown.- Parameters:
message- An explanation of the problem encountered when using theArticleGetconsumer.
-
ArticleGetException
public ArticleGetException(java.lang.String message, java.lang.Throwable cause)
Creates a newArticleGetExceptionthat may be thrown, having the given message, and a "previously thrown exception" (cause) - either from another thread, or caught and re-branded into anArticleGetExceptionNote: The detail message associated with cause is not automatically incorporated into this exception's detail message.- Parameters:
message- The explanation of the problem encountered when parsing an HTML page using the a user-defined, or factory-createdArticleGetinstance.cause- This may be a "cause" exception. It can be caused, and facilitates a programmer catching a problem, and then re-naming it toArticleGetException
-
ArticleGetException
public ArticleGetException(java.lang.String message, java.net.URL url, java.util.Vector<HTMLNode> page)
When this constructor is used, theURLand page-Vectorwill be preserved asfinal(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-createdArticleGetinstance.url- TheURLfrom which the original HTML page-Vectorwas retrievedpage- The HTML page (as aVector) that could not be resolved by theArticleGetinstance 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, theURLand page-Vectorwill be preserved asfinal(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 JavagetCause();method available.- Parameters:
message- The explanation of the problem encountered when parsing an HTML page using the a user-defined, or factory-createdArticleGetinstance.cause- This may be a "cause" exception. It can be caused, and facilitates a programmer catching a problem, and then re-naming it toArticleGetExceptionurl- TheURLfrom which the original HTML page-Vectorwas retrievedpage- The HTML page (as aVector) that could not be resolved by theArticleGetinstance 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, theURLand page-Vectorwill be preserved asfinal(constant) fields within this class instance for future reference and debugging.- Parameters:
url- TheURLfrom which the original HTML page-Vectorwas retrievedpage- The HTML page (as aVector) that could not be resolved by theArticleGetinstance 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);
-
-