hudson.plugins.analysis.util
Class EncodingValidator

java.lang.Object
  extended by hudson.plugins.analysis.util.EncodingValidator
All Implemented Interfaces:
Validator

public class EncodingValidator
extends Object
implements Validator

Validates a file encoding. The encoding must be an encoding ID supported by the underlying Java platform.

Author:
Ulli Hafner

Constructor Summary
EncodingValidator()
           
 
Method Summary
 hudson.util.FormValidation check(String encoding)
          Validates a file encoding.
static Charset defaultCharset(String defaultEncoding)
          Returns the default charset for the specified encoding string.
static Set<String> getAvailableCharsets()
          Returns all available character set names.
static org.apache.commons.io.LineIterator readFile(String fileName, String encoding)
          Reads the specified file with the given encoding.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EncodingValidator

public EncodingValidator()
Method Detail

getAvailableCharsets

public static Set<String> getAvailableCharsets()
Returns all available character set names.

Returns:
all available character set names

defaultCharset

public static Charset defaultCharset(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(String fileName,
                                                          String encoding)
                                                   throws FileNotFoundException,
                                                          IOException
Reads the specified file with the given encoding.

Parameters:
fileName - the file name
encoding - the encoding of the file, if null or empty then the default encoding of the platform is used
Returns:
the line iterator
Throws:
FileNotFoundException - Indicates that the file is not found.
IOException - Signals that an I/O exception has occurred during reading of the file.

check

public hudson.util.FormValidation check(String encoding)
                                 throws hudson.util.FormValidation
Validates a file encoding. The encoding must be an encoding ID supported by the underlying Java platform.

Specified by:
check in interface Validator
Parameters:
encoding - the name of the encoding that will be checked
Returns:
a positive FormValidation object
Throws:
hudson.util.FormValidation - if the encoding is not valid


Copyright © 2004-2012 Hudson. All Rights Reserved.