org.opensolaris.opengrok.analysis
Class FileAnalyzerFactory

java.lang.Object
  extended by org.opensolaris.opengrok.analysis.FileAnalyzerFactory
Direct Known Subclasses:
BZip2AnalyzerFactory, CAnalyzerFactory, CxxAnalyzerFactory, ELFAnalyzerFactory, FortranAnalyzerFactory, GZIPAnalyzerFactory, IgnorantAnalyzerFactory, ImageAnalyzerFactory, JarAnalyzerFactory, JavaAnalyzerFactory, JavaClassAnalyzerFactory, LispAnalyzerFactory, PlainAnalyzerFactory, ShAnalyzerFactory, SQLAnalyzerFactory, TarAnalyzerFactory, TclAnalyzerFactory, TroffAnalyzerFactory, XMLAnalyzerFactory, ZipAnalyzerFactory

public class FileAnalyzerFactory
extends java.lang.Object

Factory class which creates a FileAnalyzer object and provides information about this type of analyzers.


Nested Class Summary
protected static interface FileAnalyzerFactory.Matcher
          Interface for matchers which map file contents to analyzer factories.
 
Constructor Summary
protected FileAnalyzerFactory(java.lang.String[] names, java.lang.String[] suffixes, java.lang.String[] magics, FileAnalyzerFactory.Matcher matcher, java.lang.String contentType, FileAnalyzer.Genre genre)
          Construct an instance of FileAnalyzerFactory.
 
Method Summary
 FileAnalyzer getAnalyzer()
          Get an analyzer.
 FileAnalyzer.Genre getGenre()
          The genre this analyzer factory belongs to.
protected  FileAnalyzer newAnalyzer()
          Create a new analyzer.
 void writeXref(java.io.Reader in, java.io.Writer out, Annotation annotation, Project project)
          Write a cross referenced HTML file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileAnalyzerFactory

protected FileAnalyzerFactory(java.lang.String[] names,
                              java.lang.String[] suffixes,
                              java.lang.String[] magics,
                              FileAnalyzerFactory.Matcher matcher,
                              java.lang.String contentType,
                              FileAnalyzer.Genre genre)
Construct an instance of FileAnalyzerFactory. This constructor should be used by subclasses to override default values.

Parameters:
names - list of file names to recognize (possibly null)
suffixes - list of suffixes to recognize (possibly null)
magics - list of magic strings to recognize (possibly null)
matcher - a matcher for this analyzer (possibly null)
contentType - content type for this analyzer (possibly null)
genre - the genre for this analyzer (if null, Genre.DATA is used)
Method Detail

getGenre

public final FileAnalyzer.Genre getGenre()
The genre this analyzer factory belongs to.

Returns:
a genre

getAnalyzer

public final FileAnalyzer getAnalyzer()
Get an analyzer. If the same thread calls this method multiple times on the same factory object, the exact same analyzer object will be returned each time. Subclasses should not override this method, but instead override the newAnalyzer() method.

Returns:
a FileAnalyzer instance
See Also:
newAnalyzer()

newAnalyzer

protected FileAnalyzer newAnalyzer()
Create a new analyzer.

Returns:
an analyzer

writeXref

public void writeXref(java.io.Reader in,
                      java.io.Writer out,
                      Annotation annotation,
                      Project project)
               throws java.io.IOException
Write a cross referenced HTML file. Reads the source from in.

Parameters:
in - input source
out - output xref writer
annotation - annotation for the file (could be null)
project - project the file belongs to (could be null)
Throws:
java.io.IOException - if an error occurs