hudson.plugins.tasks.util
Class EncodingValidator
java.lang.Object
hudson.util.FormFieldValidator
hudson.plugins.tasks.util.SingleFieldValidator
hudson.plugins.tasks.util.EncodingValidator
public class EncodingValidator
- extends SingleFieldValidator
Validates a file encoding. The encoding must be an encoding ID supported by
the underlying Java platform.
- Author:
- Ulli Hafner
| Nested classes/interfaces inherited from class hudson.util.FormFieldValidator |
hudson.util.FormFieldValidator.Base64, hudson.util.FormFieldValidator.Executable, hudson.util.FormFieldValidator.HudsonURL, hudson.util.FormFieldValidator.NonNegativeInteger, hudson.util.FormFieldValidator.URLCheck, hudson.util.FormFieldValidator.WorkspaceDirectory, hudson.util.FormFieldValidator.WorkspaceFileMask, hudson.util.FormFieldValidator.WorkspaceFilePath |
| Fields inherited from class hudson.util.FormFieldValidator |
CHECK, permission, request, response, subject |
|
Constructor Summary |
EncodingValidator(org.kohsuke.stapler.StaplerRequest request,
org.kohsuke.stapler.StaplerResponse response)
Creates a new instance of EncodingValidator. |
|
Method Summary |
void |
check(java.lang.String encoding)
Checks the input value. |
static java.nio.charset.Charset |
defaultCharset(java.lang.String defaultEncoding)
Returns the default charset for the specified encoding string. |
static java.util.Set<java.lang.String> |
getAvailableCharsets()
Returns all available character set names. |
static org.apache.commons.io.LineIterator |
readFile(java.lang.String fileName,
java.lang.String encoding)
Reads the specified file with the given encoding. |
| Methods inherited from class hudson.util.FormFieldValidator |
error, error, errorWithMarkup, getFileParameter, ok, ok, ok, okWithMarkup, process, respond, warning, warning, warningWithMarkup |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
EncodingValidator
public EncodingValidator(org.kohsuke.stapler.StaplerRequest request,
org.kohsuke.stapler.StaplerResponse response)
- Creates a new instance of
EncodingValidator.
- Parameters:
request - Stapler requestresponse - Stapler response
getAvailableCharsets
public static java.util.Set<java.lang.String> getAvailableCharsets()
- Returns all available character set names.
- Returns:
- all available character set names
defaultCharset
public static java.nio.charset.Charset defaultCharset(java.lang.String defaultEncoding)
- Returns the default charset for the specified encoding string. If the
default encoding is empty or
null, or if the charset is not
valid then the default encoding of the platform is returned.
- Parameters:
defaultEncoding - identifier of the character set
- Returns:
- the default charset for the specified encoding string
readFile
public static org.apache.commons.io.LineIterator readFile(java.lang.String fileName,
java.lang.String encoding)
throws java.io.FileNotFoundException,
java.io.IOException
- Reads the specified file with the given encoding.
- Parameters:
fileName - the file nameencoding - the encoding of the file, if null or empty then
the default encoding of the platform is used
- Returns:
- the line iterator
- Throws:
java.io.FileNotFoundException - Indicates that the file is not found.
java.io.IOException - Signals that an I/O exception has occurred during reading of
the file.
check
public void check(java.lang.String encoding)
throws java.io.IOException,
javax.servlet.ServletException
- Checks the input value.
- Specified by:
check in class SingleFieldValidator
- Parameters:
encoding - the value to check
- Throws:
java.io.IOException - Signals that an I/O exception has occurred.
javax.servlet.ServletException - the servlet exception
Copyright © 2009. All Rights Reserved.