|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.opensolaris.opengrok.analysis.AnalyzerGuru
public class AnalyzerGuru
Manages and porvides Analyzers as needed. Please see this page for a great description of the purpose of the AnalyzerGuru. Created on September 22, 2005
Constructor Summary | |
---|---|
AnalyzerGuru()
|
Method Summary | |
---|---|
static void |
addExtension(java.lang.String extension,
FileAnalyzerFactory factory)
Instruct the AnalyzerGuru to use a given analyzer for a given file extension. |
static FileAnalyzerFactory |
find(java.io.InputStream in)
Finds a suitable analyser class for the data in this stream |
static FileAnalyzerFactory |
find(java.io.InputStream in,
java.lang.String file)
Finds a suitable analyser class for file name. |
static FileAnalyzerFactory |
find(java.lang.String file)
Finds a suitable analyser class for file name. |
static FileAnalyzerFactory |
findFactory(java.lang.String factoryClassName)
Find a FileAnalyzerFactory with the specified class name. |
static FileAnalyzer |
getAnalyzer()
Get the default Analyzer. |
static FileAnalyzer |
getAnalyzer(java.io.InputStream in,
java.lang.String file)
Get an analyzer suited to analyze a file. |
static java.lang.String |
getContentType(java.io.InputStream in,
java.lang.String file)
Get the content type for a named file. |
org.apache.lucene.document.Document |
getDocument(java.io.File file,
java.io.InputStream in,
java.lang.String path,
FileAnalyzer fa)
Create a Lucene document and fill in the required fields |
static FileAnalyzer.Genre |
getGenre(FileAnalyzerFactory factory)
Get the genre for a named class (this is most likely an analyzer) |
static FileAnalyzer.Genre |
getGenre(java.io.InputStream in)
Get the genre of a bulk of data |
static FileAnalyzer.Genre |
getGenre(java.lang.String file)
Get the genre of a file |
static java.lang.String |
stripBOM(byte[] sig)
Strip away the byte-order marker from the string, if it has one. |
static void |
writeXref(FileAnalyzerFactory factory,
java.io.Reader in,
java.io.Writer out,
Annotation annotation,
Project project)
Write a browsable version of the file |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AnalyzerGuru()
Method Detail |
---|
public static void addExtension(java.lang.String extension, FileAnalyzerFactory factory)
extension
- the file-extension to addfactory
- a factory which creates
the analyzer to use for the given extension
(if you pass null as the analyzer, you will disable
the analyzer used for that extension)public static FileAnalyzer getAnalyzer()
public static FileAnalyzer getAnalyzer(java.io.InputStream in, java.lang.String file) throws java.io.IOException
in
- Input stream containing data to be analyzedfile
- Name of the file to be analyzed
java.io.IOException
- If an error occurs while accessing the
data in the input stream.public org.apache.lucene.document.Document getDocument(java.io.File file, java.io.InputStream in, java.lang.String path, FileAnalyzer fa) throws java.io.IOException
file
- The file to indexin
- The data to generate the index forpath
- Where the file is located (from source root)
java.io.IOException
- If an exception occurs while collecting the
dataspublic static java.lang.String getContentType(java.io.InputStream in, java.lang.String file) throws java.io.IOException
in
- The input stream we want to get the content type for (if
we cannot determine the content type by the filename)file
- The name of the file
java.io.IOException
- If an error occurs while accessing the input
stream.public static void writeXref(FileAnalyzerFactory factory, java.io.Reader in, java.io.Writer out, Annotation annotation, Project project) throws java.io.IOException
factory
- The analyzer factory for this filetypein
- The input stream containing the dataout
- Where to write the resultannotation
- Annotation information for the fileproject
- Project the file belongs to
java.io.IOException
- If an error occurs while creating the
outputpublic static FileAnalyzer.Genre getGenre(java.lang.String file)
file
- The file to inpect
public static FileAnalyzer.Genre getGenre(java.io.InputStream in) throws java.io.IOException
in
- A stream containing the data
java.io.IOException
- If an error occurs while getting the contentpublic static FileAnalyzer.Genre getGenre(FileAnalyzerFactory factory)
factory
- the analyzer factory to get the genre for
public static FileAnalyzerFactory findFactory(java.lang.String factoryClassName) throws java.lang.ClassNotFoundException, java.lang.IllegalAccessException, java.lang.InstantiationException
FileAnalyzerFactory
with the specified class name. If one
doesn't exist, create one and register it.
factoryClassName
- name of the factory class
java.lang.ClassNotFoundException
- if there is no class with that name
java.lang.ClassCastException
- if the class is not a subclass of FileAnalyzerFactory
java.lang.IllegalAccessException
- if the constructor cannot be accessed
java.lang.InstantiationException
- if the class cannot be instantiatedpublic static FileAnalyzerFactory find(java.io.InputStream in, java.lang.String file) throws java.io.IOException
in
- The input stream containing the datafile
- The file name to get the analyzer for
java.io.IOException
- If a problem occurs while reading the datapublic static FileAnalyzerFactory find(java.lang.String file)
file
- The file name to get the analyzer for
public static FileAnalyzerFactory find(java.io.InputStream in) throws java.io.IOException
in
- The stream containing the data to analyze
java.io.IOException
- if an error occurs while reading data from
the streampublic static java.lang.String stripBOM(byte[] sig) throws java.io.IOException
sig
- a sequence of bytes from which to remove the BOM
null
if
the string doesn't start with a BOM
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |