hudson.util
Class FormValidation.URLCheck

java.lang.Object
  extended by 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
FormValidation.URLCheck()
           
 
Method Summary
protected abstract  FormValidation check()
          Implement the actual form validation logic, by using other convenience methosd defined in this class.
protected  boolean findText(BufferedReader in, String literal)
          Finds the string literal from the given reader.
protected  FormValidation handleIOException(String url, IOException e)
          Calls the FormValidation.error(String) method with a reasonable error message.
protected  BufferedReader open(URL url)
          Opens the given URL and reads text content from it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FormValidation.URLCheck

public FormValidation.URLCheck()
Method Detail

open

protected BufferedReader open(URL url)
                       throws IOException
Opens the given URL and reads text content from it. This method honors Content-type header.

Throws:
IOException

findText

protected boolean findText(BufferedReader in,
                           String literal)
                    throws IOException
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 the FormValidation.error(String) method with a reasonable error message. Use this method when the open(URL) or findText(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 methosd 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


Copyright © 2004-2013. All Rights Reserved.