hudson.plugins.warnings.parser
Class ParserRegistry

java.lang.Object
  extended by hudson.plugins.warnings.parser.ParserRegistry

public class ParserRegistry
extends java.lang.Object

Registry for the active parsers in this plug-in.

Author:
Ulli Hafner

Constructor Summary
ParserRegistry(java.util.List<WarningsParser> parsers, java.lang.String defaultEncoding)
          Creates a new instance of ParserRegistry.
ParserRegistry(java.util.List<WarningsParser> parsers, java.lang.String defaultEncoding, java.lang.String includePattern, java.lang.String excludePattern)
          Creates a new instance of ParserRegistry.
 
Method Summary
protected  java.io.Reader createReader(java.io.File file)
          Creates a reader from the specified file.
protected  java.io.Reader createReader(java.io.InputStream inputStream)
          Creates a reader from the specified input stream.
static java.util.List<java.lang.String> getAvailableParsers()
          Returns all available parser names.
protected  java.lang.Iterable<WarningsParser> getParsers()
          Returns all registers parsers.
static java.util.List<WarningsParser> getParsers(java.util.Set<java.lang.String> parserNames)
          Returns a list of parsers that match the specified names.
 java.util.Collection<FileAnnotation> parse(java.io.File file)
          Iterates over the available parsers and parses the specified file with each parser.
 java.util.Collection<FileAnnotation> parse(java.io.InputStream file)
          Iterates over the available parsers and parses the specified file with each parser.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ParserRegistry

public ParserRegistry(java.util.List<WarningsParser> parsers,
                      java.lang.String defaultEncoding)
Creates a new instance of ParserRegistry.

Parameters:
parsers - the parsers to use when scanning a file
defaultEncoding - the default encoding to be used when reading and parsing files

ParserRegistry

public ParserRegistry(java.util.List<WarningsParser> parsers,
                      java.lang.String defaultEncoding,
                      java.lang.String includePattern,
                      java.lang.String excludePattern)
Creates a new instance of ParserRegistry.

Parameters:
parsers - the parsers to use when scanning a file
includePattern - Ant file-set pattern of files to include in report, null or an empty string do not filter the output
excludePattern - Ant file-set pattern of files to exclude from report, null or an empty string do not filter the output
defaultEncoding - the default encoding to be used when reading and parsing files
Method Detail

getParsers

protected java.lang.Iterable<WarningsParser> getParsers()
Returns all registers parsers. Note that removal of elements is not supported.

Returns:
the registered parsers

parse

public java.util.Collection<FileAnnotation> parse(java.io.File file)
                                           throws java.io.IOException
Iterates over the available parsers and parses the specified file with each parser. Returns all found warnings.

Parameters:
file - the input stream
Returns:
all found warnings
Throws:
java.io.IOException - Signals that an I/O exception has occurred.

parse

public java.util.Collection<FileAnnotation> parse(java.io.InputStream file)
                                           throws java.io.IOException
Iterates over the available parsers and parses the specified file with each parser. Returns all found warnings.

Parameters:
file - the input stream
Returns:
all found warnings
Throws:
java.io.IOException - Signals that an I/O exception has occurred.

createReader

protected java.io.Reader createReader(java.io.File file)
                               throws java.io.FileNotFoundException
Creates a reader from the specified file. Uses the defined character set to read the content of the input stream.

Parameters:
file - the file
Returns:
the reader
Throws:
java.io.FileNotFoundException - if the file does not exist

createReader

protected java.io.Reader createReader(java.io.InputStream inputStream)
Creates a reader from the specified input stream. Uses the defined character set to read the content of the input stream.

Parameters:
inputStream - the input stream
Returns:
the reader

getAvailableParsers

public static java.util.List<java.lang.String> getAvailableParsers()
Returns all available parser names.

Returns:
all available parser names

getParsers

public static java.util.List<WarningsParser> getParsers(java.util.Set<java.lang.String> parserNames)
Returns a list of parsers that match the specified names. Note that the mapping of names to parsers is one to many.

Parameters:
parserNames - the parser names
Returns:
a list of parsers, might be modified by the receiver


Copyright © 2009. All Rights Reserved.