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-methods
created by the classArticleGet
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 theArticleGet
instance 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'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 ofArticleGet
would perfectly retrieve the content body of every single newsArticle
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 ofArticleGetException
to 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,183 Bytes Line Count: 165 '\n' Characters Found
-
-
Field Summary
Serializable ID Modifier and Type Field static long
serialVersionUID
'final'
Exception Convenience FieldsModifier and Type Field Vector<HTMLNode>
page
URL
url
-
Constructor Summary
Constructors Constructor Description ArticleGetException(String message)
Creates a newArticleGetException
that may be thrown.ArticleGetException(String message, Throwable cause)
Creates a newArticleGetException
that may be thrown, having the given message, and a "previously thrown exception" (cause) - either from another thread, or caught and re-branded into anArticleGetException
ArticleGetException(String message, Throwable cause, URL url, Vector<HTMLNode> page)
When this constructor is used, theURL
and page-Vector
will be preserved asfinal
(constant) fields within this class instance for future reference and debugging.ArticleGetException(String message, URL url, Vector<HTMLNode> page)
When this constructor is used, theURL
and page-Vector
will be preserved asfinal
(constant) fields within this class instance for future reference and debugging.
-
Method Summary
'static'
Exception Check MethodsModifier and Type Method static void
check(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 theSerializable
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'sjava.lang.Exception
andjava.lang.Error
classes implement theSerializable 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 thispublic, final
parameter. Not all four of the provided constructor's for this exception require thepage
andurl
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 thispublic, 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 newArticleGetException
that may be thrown.- Parameters:
message
- An explanation of the problem encountered when using theArticleGet
consumer.
-
ArticleGetException
public ArticleGetException(java.lang.String message, java.lang.Throwable cause)
Creates a newArticleGetException
that may be thrown, having the given message, and a "previously thrown exception" (cause) - either from another thread, or caught and re-branded into anArticleGetException
- Parameters:
message
- The explanation of the problem encountered when parsing an HTML page using the a user-defined, or factory-createdArticleGet
instance.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, theURL
and page-Vector
will 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-createdArticleGet
instance.url
- TheURL
from which the original HTML page-Vector
was retrievedpage
- The HTML page (as aVector
) that could not be resolved by theArticleGet
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, theURL
and page-Vector
will 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-createdArticleGet
instance.cause
- This may be a "cause" exception. It can be caused, and facilitates a programmer catching a problem, and then re-naming it toArticleGetException
url
- TheURL
from which the original HTML page-Vector
was retrievedpage
- The HTML page (as aVector
) that could not be resolved by theArticleGet
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, theURL
and page-Vector
will be preserved asfinal
(constant) fields within this class instance for future reference and debugging.- Parameters:
url
- TheURL
from which the original HTML page-Vector
was retrievedpage
- The HTML page (as aVector
) that could not be resolved by theArticleGet
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);
-
-