public class LinkChecker extends Object
Constructor and Description |
---|
LinkChecker(URI context,
boolean attemptExternal)
Constructs a new LinkChecker with a given home context.
|
Modifier and Type | Method and Description |
---|---|
boolean |
checkLinks(Source xsltSrc,
Source xmlSrc)
Checks the result of an XML transformation to see if the links
in the result are OK or not.
|
boolean |
checkLinks(Source xsltSrc,
Source xmlSrc,
Map<String,String> params)
Checks the result of an XML transformation to see if the links
in the result are OK or not, with an optional list of parameters.
|
URLConnection |
followRedirectsWithTimeout(URLConnection conn)
Takes a URLConnection and repeatedly follows 303 redirects
until a non-303 status is achieved.
|
int |
getExternalFailures()
Returns the total number of external link resolution failures
this checker has come across.
|
int |
getLocalFailures()
Returns the total number of local link resolution failures this
checker has come across.
|
int |
getTimeout()
Returns the network timeout used for retrieving URLs.
|
protected void |
logMessage(String msg)
Interface through which short messages about progress can be
logged.
|
static void |
main(String[] args)
Checks the links of the result of a given transformation to XHTML
(or an HTML-like result).
|
void |
setTimeout(int timeoutSecs)
Sets the network timeout used for retrieving URLs.
|
public LinkChecker(URI context, boolean attemptExternal)
context
- document contextattemptExternal
- true if you want to check external (http)
links; if false, only local ones will be checkedpublic boolean checkLinks(Source xsltSrc, Source xmlSrc) throws TransformerException, MalformedURLException
xsltSrc
- source for the XSLT stylesheet which converts to
HTML or an HTML-like output formatxmlSrc
- source for the XML document which will be
transformed by xsltSrc
to produce the HTML to testTransformerException
MalformedURLException
public boolean checkLinks(Source xsltSrc, Source xmlSrc, Map<String,String> params) throws TransformerException, MalformedURLException
xsltSrc
- source for the XSLT stylesheet which converts to
HTML or an HTML-like output formatxmlSrc
- source for the XML document which will be
transformed by xsltSrc
to produce the HTML to testparams
- stylesheet parameter map (or null)TransformerException
MalformedURLException
public void setTimeout(int timeoutSecs)
timeoutSecs
- timeout in secondspublic int getTimeout()
public int getLocalFailures()
public int getExternalFailures()
getLocalFailures()
protected void logMessage(String msg)
msg
- message to logpublic URLConnection followRedirectsWithTimeout(URLConnection conn) throws IOException
conn
- initial URL connectionhconn
)IOException
public static void main(String[] args) throws MalformedURLException, TransformerException
Usage: LinkChecker stylesheet xmldoc
args
- argumentsMalformedURLException
TransformerException
Copyright © 2024 Central Laboratory of the Research Councils. All Rights Reserved.