public class FastaSearchSAXParser extends Object implements SearchContentHandler
FastaSearchSAXParser is a SAX2 compliant parser for
 '-m 10' format output from the the Fasta search program (see the
 Fasta documentation for details of this format).
Versions of Fasta supported are as follows. Note that the compile time option -DM10_CONS should be used to allow correct reporting of the number of matches in HSPSummary elements
The SAX2 events produced are as if the input to the parser was an XML file validating against the BioJava BlastLikeDataSetCollection DTD. There is no requirement for an intermediate conversion of native output to XML format.
| Modifier and Type | Field and Description | 
|---|---|
protected int | 
iState  | 
protected String | 
oFullNamespacePrefix  | 
protected ContentHandler | 
oHandler  | 
protected String | 
oNamespacePrefix  | 
protected boolean | 
tNamespacePrefixes  | 
protected boolean | 
tNamespaces  | 
| Constructor and Description | 
|---|
FastaSearchSAXParser()
Creates a new  
FastaSearchSAXParser instance. | 
| Modifier and Type | Method and Description | 
|---|---|
void | 
addHitProperty(Object key,
                            Object value)
The  
addHitProperty method adds a key/value pair
 containing some property of a particular hit. | 
void | 
addPrefixMapping(String poPrefix,
                                String poURI)
Adds a namespace prefix to URI mapping as (key,value) pairs. 
 | 
void | 
addSearchProperty(Object key,
                                  Object value)
The  
addSearchProperty method adds a key/value pair
 containing some property of the overall search result. | 
void | 
addSubHitProperty(Object key,
                                  Object value)
The  
addSubHitProperty method adds a key/value pair
 containing some property of a particular subhit. | 
protected void | 
changeState(int piState)
Centralise chaining of iState field to help
 with debugging. 
 | 
protected void | 
characters(char[] ch,
                    int start,
                    int length)
Utility method to centralize the sending of a SAX characters
 message a document handler. 
 | 
protected void | 
endElement(org.biojava.bio.program.sax.QName poQName)
Utility method to centralize the sending of a SAX endElement
 message a document handler. 
 | 
void | 
endHeader()
The  
endHeader method indicates the end of a
 formatted header. | 
void | 
endHit()
The  
endHit method indicates the end of a formatted
 hit. | 
void | 
endSearch()
The  
endSearch method indicates the end of useful
 search information. | 
void | 
endSubHit()
The  
endSubHit method indicates the end of a
 formatted subhit. | 
ContentHandler | 
getContentHandler()
Return the content handler. 
 | 
protected BufferedReader | 
getContentStream(InputSource poSource)
Create a stream from an an InputSource, picking the
 correct stream according to order of precedance. 
 | 
DTDHandler | 
getDTDHandler()
Do-nothing implementation of interface method 
 | 
EntityResolver | 
getEntityResolver()
Do-nothing implementation of interface method 
 | 
ErrorHandler | 
getErrorHandler()
Do-nothing implementation of interface method 
 | 
boolean | 
getFeature(String poName)
Do-nothing implementation of interface method 
 | 
boolean | 
getMoreSearches()
getMoreSearches returns the state of the
 SearchContentHandler with respect to further
 searches from its data source. | 
String | 
getNamespacePrefix()
Describe  
getNamespacePrefix method here. | 
boolean | 
getNamespacePrefixes()
Support SAX2 configuration of namespace support of parser. 
 | 
boolean | 
getNamespaces()
Support SAX2 configuration of namespace support of parser. 
 | 
Object | 
getProperty(String name)
Do-nothing implementation of interface method 
 | 
String | 
getURIFromPrefix(String poPrefix)
Gets the URI for a namespace prefix, given that prefix,
 or null if the prefix is not recognised. 
 | 
void | 
parse(InputSource source)
Do-nothing implementation of interface method 
 | 
void | 
parse(String poSystemId)
Full implementation of interface method. 
 | 
String | 
prefix(String poElementName)
Given an unprefixed element name, returns
 a new element name with a namespace prefix 
 | 
void | 
setContentHandler(ContentHandler poHandler)
Allow an application to register a content event handler. 
 | 
void | 
setDatabaseID(String databaseID)
setDatabaseID identifies the database searched by
 a name, ID or URN. | 
void | 
setDTDHandler(DTDHandler handler)
Do-nothing implementation of interface method 
 | 
void | 
setEntityResolver(EntityResolver resolver)
Do-nothing implementation of interface method 
 | 
void | 
setErrorHandler(ErrorHandler handler)
Do-nothing implementation of interface method 
 | 
void | 
setFeature(String poName,
                    boolean value)
Handles support for ReasoningDomain and Namespace-prefixes 
 | 
void | 
setMoreSearches(boolean value)
setMoreSearches sets the state of the
 SearchContentHandler's expectation of receiving
 more results. | 
void | 
setNamespacePrefix(String poPrefix)  | 
void | 
setProperty(String name,
                      Object value)
Do-nothing implementation of interface method 
 | 
void | 
setQueryID(String queryID)
setQueryID identifies the query sequence by a
 name, ID or URN. | 
void | 
setQuerySeq(String identifier)
Deprecated. 
 
use  
setQueryID instead. | 
void | 
setSubjectDB(String identifier)
Deprecated. 
 
use  
setDatabaseID instead. | 
protected void | 
startElement(org.biojava.bio.program.sax.QName poQName,
                        Attributes atts)
Utility method to centralize sending of a SAX
 startElement message to document handler 
 | 
void | 
startHeader()
The  
startHeader method indicates the start of a
 formatted header. | 
void | 
startHit()
The  
startHit method indicates the start of a
 formatted hit. | 
void | 
startSearch()
The  
startSearch method indicates the start of
 useful search information. | 
void | 
startSubHit()
The  
startSubHit method indicates the start of a
 formatted subhit. | 
protected ContentHandler oHandler
protected boolean tNamespaces
protected boolean tNamespacePrefixes
protected String oNamespacePrefix
protected String oFullNamespacePrefix
protected int iState
public FastaSearchSAXParser()
FastaSearchSAXParser instance.public void parse(InputSource source) throws IOException, SAXException
parse in interface XMLReaderIOExceptionSAXExceptionpublic boolean getMoreSearches()
SearchContentHandlergetMoreSearches returns the state of the
 SearchContentHandler with respect to further
 searches from its data source. Used for handling streams of
 search results.getMoreSearches in interface SearchContentHandlerboolean value.public void setMoreSearches(boolean value)
SearchContentHandlersetMoreSearches sets the state of the
 SearchContentHandler's expectation of receiving
 more results. Used for handling streams of search results.setMoreSearches in interface SearchContentHandlervalue - a boolean value.public void setQuerySeq(String identifier)
setQueryID instead.setQuerySeq identifies the query sequence by a
 name, ID or URN.identifier - a String which should be an
 unique identifer for the sequence.public void setQueryID(String queryID)
SearchContentHandlersetQueryID identifies the query sequence by a
 name, ID or URN.setQueryID in interface SearchContentHandlerqueryID - a String which should be an unique
 identifer for the sequence.public void setSubjectDB(String identifier)
setDatabaseID instead.setSubjectDB identifies the database searched by a
 name, ID or URN.identifier - a String which should be an unique
 identifier for the database searched.public void setDatabaseID(String databaseID)
SearchContentHandlersetDatabaseID identifies the database searched by
 a name, ID or URN.setDatabaseID in interface SearchContentHandlerdatabaseID - a String which should be an unique
 identifier for the database searched.public void startSearch()
SearchContentHandlerstartSearch method indicates the start of
 useful search information.startSearch in interface SearchContentHandlerpublic void addSearchProperty(Object key, Object value)
SearchContentHandleraddSearchProperty method adds a key/value pair
 containing some property of the overall search result.addSearchProperty in interface SearchContentHandlerkey - an Object.value - an Object.public void endSearch()
SearchContentHandlerendSearch method indicates the end of useful
 search information.endSearch in interface SearchContentHandlerpublic void startHeader()
SearchContentHandlerstartHeader method indicates the start of a
 formatted header. This usually contains information relevant to
 the search as a whole.startHeader in interface SearchContentHandlerpublic void endHeader()
SearchContentHandlerendHeader method indicates the end of a
 formatted header.endHeader in interface SearchContentHandlerpublic void startHit()
SearchContentHandlerstartHit method indicates the start of a
 formatted hit. This could be a single line, or a block of
 lines.startHit in interface SearchContentHandlerpublic void addHitProperty(Object key, Object value)
SearchContentHandleraddHitProperty method adds a key/value pair
 containing some property of a particular hit.addHitProperty in interface SearchContentHandlerkey - an Object.value - an Object.public void endHit()
SearchContentHandlerendHit method indicates the end of a formatted
 hit.endHit in interface SearchContentHandlerpublic void startSubHit()
SearchContentHandlerstartSubHit method indicates the start of a
 formatted subhit. There may be zero or more of these per hit.startSubHit in interface SearchContentHandlerpublic void addSubHitProperty(Object key, Object value)
SearchContentHandleraddSubHitProperty method adds a key/value pair
 containing some property of a particular subhit.addSubHitProperty in interface SearchContentHandlerkey - an Object.value - an Object.public void endSubHit()
SearchContentHandlerendSubHit method indicates the end of a
 formatted subhit.endSubHit in interface SearchContentHandlerpublic void setContentHandler(ContentHandler poHandler)
Applications may register a new or different handler in the middle of a parse, and the SAX parser must begin using the new handler immediately.
setContentHandler in interface XMLReaderpoHandler - a ContentHandler The XML content handlerNullPointerException - If the handler argument is nullpublic ContentHandler getContentHandler()
getContentHandler in interface XMLReaderContentHandler The current content handler,
 or null if none has been registered.public void parse(String poSystemId) throws IOException, SAXException
parse in interface XMLReaderIOExceptionSAXExceptionpublic boolean getFeature(String poName) throws SAXNotRecognizedException, SAXNotSupportedException
getFeature in interface XMLReaderSAXNotRecognizedExceptionSAXNotSupportedExceptionpublic void setFeature(String poName, boolean value) throws SAXNotRecognizedException, SAXNotSupportedException
setFeature in interface XMLReaderSAXNotRecognizedExceptionSAXNotSupportedExceptionpublic Object getProperty(String name) throws SAXNotRecognizedException, SAXNotSupportedException
getProperty in interface XMLReaderSAXNotRecognizedExceptionSAXNotSupportedExceptionpublic void setProperty(String name, Object value) throws SAXNotRecognizedException, SAXNotSupportedException
setProperty in interface XMLReaderSAXNotRecognizedExceptionSAXNotSupportedExceptionpublic void setEntityResolver(EntityResolver resolver)
setEntityResolver in interface XMLReaderpublic EntityResolver getEntityResolver()
getEntityResolver in interface XMLReaderpublic void setDTDHandler(DTDHandler handler)
setDTDHandler in interface XMLReaderpublic DTDHandler getDTDHandler()
getDTDHandler in interface XMLReaderpublic void setErrorHandler(ErrorHandler handler)
setErrorHandler in interface XMLReaderpublic ErrorHandler getErrorHandler()
getErrorHandler in interface XMLReaderprotected void startElement(org.biojava.bio.program.sax.QName poQName, Attributes atts) throws SAXException
poQName - a QName valueatts - an Attributes valueSAXException - if an error occursprotected void endElement(org.biojava.bio.program.sax.QName poQName) throws SAXException
poQName - -SAXException - thrown ifthrown - ifprotected void characters(char[] ch, int start, int length) throws SAXException
ch - -start - -length - -SAXException - thrown ifthrown - ifpublic boolean getNamespaces()
public boolean getNamespacePrefixes()
public void addPrefixMapping(String poPrefix, String poURI)
poPrefix - a String representation of the
 namespace prefixpoURI - a String representation of the URI
 for the namespace prefix.public String getURIFromPrefix(String poPrefix)
poPrefix - a String The namespace prefix.public void setNamespacePrefix(String poPrefix)
poPrefix - a String valuepublic String getNamespacePrefix()
getNamespacePrefix method here.String valuepublic String prefix(String poElementName)
String valueprotected BufferedReader getContentStream(InputSource poSource)
poSource - an InputSource valueBufferedReader valueprotected void changeState(int piState)
piState - an int valueCopyright © 2014 BioJava. All rights reserved.