public class IndexUtil
extends Object
| Modifier and Type | Field and Description |
|---|---|
private static ConfigCache |
configCache |
private static SAXParserFactory |
saxParserFactory |
private static TransformerFactory |
transformerFactory |
| Constructor and Description |
|---|
IndexUtil() |
| Modifier and Type | Method and Description |
|---|---|
static void |
applyPreFilters(Templates[] prefilterStylesheets,
XMLReader reader,
InputSource xmlSource,
AttribList passThroughAttribs,
Result ultimateResult)
Apply one or more prefilter stylesheets to an XML input source.
|
static String |
calcDocKey(File xtfHome,
File idxConfigFile,
String idxName,
File srcTextFile)
Given an index within a config file and the path to the source XML text
of a document, this method infers the correct document key that should be
stored in the index.
|
static String |
calcDocKey(File xtfHomeFile,
IndexInfo idxInfo,
File srcTextFile)
Given an index within a config file and the path to the source XML text
of a document, this method infers the correct document key that should be
stored in the index.
|
static File |
calcLazyPath(File xtfHome,
File idxConfigFile,
String idxName,
File srcTextFile,
boolean createDir)
Given an index within a config file and the path to the source XML text
of a document, this method infers the correct path to the lazy version
of that source document.
|
static File |
calcLazyPath(File xtfHome,
IndexInfo idxInfo,
File srcTextFile,
boolean createDir)
Given an index within a config file and the path to the source XML text
of a document, this method infers the correct path to the lazy version
of that source document.
|
static SAXParser |
createSAXParser()
Create a SAX parser using the best implementation we can find.
|
static Transformer |
createTransformer()
Create a Saxon transformer.
|
static XMLReader |
createXMLReader()
Create an XML reader using the best implementation we can find.
|
static InputStream |
filterXMLDocument(InputStream inStream,
boolean applyCrimsonWorkaround,
boolean removeDoctypeDecl)
Applies the standard set of filters for an XML document.
|
static InputStream |
filterXMLDocument(InputStream inStream,
SAXParser saxParser,
boolean removeDoctypeDecl)
Applies the standard set of filters for an XML document.
|
static IndexInfo |
getIndexInfo(File idxConfigFile,
String idxName)
Given an index configuration file and the name of an index within that file,
fetch the configuration info.
|
private static TransformerFactory |
getTransformerFactory()
Get a TransformerFactory.
|
private static ConfigCache configCache
private static SAXParserFactory saxParserFactory
private static TransformerFactory transformerFactory
public static IndexInfo getIndexInfo(File idxConfigFile, String idxName) throws Exception
idxConfigFile - Index configuration file to readidxName - Name of the index within that fileException - If there is a problem reading the config file.public static File calcLazyPath(File xtfHome,
File idxConfigFile,
String idxName,
File srcTextFile,
boolean createDir)
throws IOException
idxConfigFile - File to load index configuration fromidxName - Index name within the configsrcTextFile - Source text file of interestcreateDir - true to create the directory for the lazy file
if it doesn't exist; false to never create the
directory.IOExceptionpublic static File calcLazyPath(File xtfHome,
IndexInfo idxInfo,
File srcTextFile,
boolean createDir)
throws IOException
xtfHome - File at the root of the XTF directory treeidxInfo - Configuration info for the index in question.srcTextFile - Source text file of interestcreateDir - true to create the directory for the lazy file
if it doesn't exist; false to never create the
directory.IOExceptionpublic static String calcDocKey(File xtfHome,
File idxConfigFile,
String idxName,
File srcTextFile)
throws IOException
idxConfigFile - File to load index configuration fromidxName - Index name within the configsrcTextFile - Source text file of interestIOExceptionpublic static String calcDocKey(File xtfHomeFile,
IndexInfo idxInfo,
File srcTextFile)
throws IOException
xtfHomeFile - The XTF_HOME directoryidxInfo - Configuration info for the index in question.srcTextFile - Source text file of interestIOExceptionpublic static SAXParser createSAXParser()
public static XMLReader createXMLReader()
private static TransformerFactory getTransformerFactory()
public static Transformer createTransformer()
public static InputStream filterXMLDocument(InputStream inStream,
boolean applyCrimsonWorkaround,
boolean removeDoctypeDecl)
inStream - Document stream to filterapplyCrimsonWorkaround - true to apply the workaround for the
8193-byte bug in the Crimson XML parser.removeDoctypeDecl - true to remove DOCTYPE declaration; false to
leave them alone.public static InputStream filterXMLDocument(InputStream inStream,
SAXParser saxParser,
boolean removeDoctypeDecl)
inStream - Document stream to filtersaxParser - Parser that will be used to parse the document; used
to determine whether or not to apply the Crimson
parser workaround.removeDoctypeDecl - true to remove DOCTYPE declaration; false to
leave them alone.public static void applyPreFilters(Templates[] prefilterStylesheets,
XMLReader reader,
InputSource xmlSource,
AttribList passThroughAttribs,
Result ultimateResult)
throws SAXException,
TransformerException,
TransformerConfigurationException
prefilterStylesheets - Stylesheets to processreader - Reader to use for parsing the input XMLxmlSource - Source of XML dataultimateResult - Where to send the outputSAXExceptionTransformerExceptionTransformerConfigurationException