Package hudson.util
Class FormValidation.URLCheck
- java.lang.Object
-
- hudson.util.FormValidation.URLCheck
-
- Enclosing class:
- FormValidation
public abstract static class FormValidation.URLCheck extends Object
Convenient base class for checking the validity of URLs.This allows the check method to call various utility methods in a concise syntax.
-
-
Constructor Summary
Constructors Constructor Description URLCheck()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected abstract FormValidation
check()
Implement the actual form validation logic, by using other convenience methods defined in this class.protected boolean
findText(BufferedReader in, String literal)
Deprecated.protected boolean
findText(Stream<String> in, String literal)
Find the string literal from the given stream of lines.protected FormValidation
handleIOException(String url, IOException e)
Calls theFormValidation.error(String)
method with a reasonable error message.protected Stream<String>
open(URI uri)
Open the given URI and read text content from it.protected BufferedReader
open(URL url)
Deprecated.useopen(URI)
-
-
-
Method Detail
-
open
protected Stream<String> open(URI uri) throws IOException
Open the given URI and read text content from it. This method honors the Content-type header.- Throws:
IOException
- if the URI scheme is not supported, the connection was interrupted, or the response was an error- Since:
- 2.382
-
open
@Deprecated protected BufferedReader open(URL url) throws IOException
Deprecated.useopen(URI)
Opens the given URL and reads text content from it. This method honors Content-type header.- Throws:
IOException
-
findText
protected boolean findText(Stream<String> in, String literal)
Find the string literal from the given stream of lines.- Returns:
- true if found, false otherwise
- Since:
- 2.382
-
findText
@Deprecated protected boolean findText(BufferedReader in, String literal) throws IOException
Deprecated.Finds the string literal from the given reader.- Returns:
- true if found, false otherwise.
- Throws:
IOException
-
handleIOException
protected FormValidation handleIOException(String url, IOException e) throws IOException, javax.servlet.ServletException
Calls theFormValidation.error(String)
method with a reasonable error message. Use this method when theopen(URL)
orfindText(BufferedReader, String)
fails.- Parameters:
url
- Pass in the URL that was connected. Used for error diagnosis.- Throws:
IOException
javax.servlet.ServletException
-
check
protected abstract FormValidation check() throws IOException, javax.servlet.ServletException
Implement the actual form validation logic, by using other convenience methods defined in this class. If you are not using any of those, you don't need to extend from this class.- Throws:
IOException
javax.servlet.ServletException
-
-