public class FastaSearchSAXParser extends java.lang.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 java.lang.String |
oFullNamespacePrefix |
protected org.xml.sax.ContentHandler |
oHandler |
protected java.lang.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(java.lang.Object key,
java.lang.Object value)
The
addHitProperty method adds a key/value pair
containing some property of a particular hit. |
void |
addPrefixMapping(java.lang.String poPrefix,
java.lang.String poURI)
Adds a namespace prefix to URI mapping as (key,value) pairs.
|
void |
addSearchProperty(java.lang.Object key,
java.lang.Object value)
The
addSearchProperty method adds a key/value pair
containing some property of the overall search result. |
void |
addSubHitProperty(java.lang.Object key,
java.lang.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. |
org.xml.sax.ContentHandler |
getContentHandler()
Return the content handler.
|
protected java.io.BufferedReader |
getContentStream(org.xml.sax.InputSource poSource)
Create a stream from an an InputSource, picking the
correct stream according to order of precedance.
|
org.xml.sax.DTDHandler |
getDTDHandler()
Do-nothing implementation of interface method
|
org.xml.sax.EntityResolver |
getEntityResolver()
Do-nothing implementation of interface method
|
org.xml.sax.ErrorHandler |
getErrorHandler()
Do-nothing implementation of interface method
|
boolean |
getFeature(java.lang.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. |
java.lang.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.
|
java.lang.Object |
getProperty(java.lang.String name)
Do-nothing implementation of interface method
|
java.lang.String |
getURIFromPrefix(java.lang.String poPrefix)
Gets the URI for a namespace prefix, given that prefix,
or null if the prefix is not recognised.
|
void |
parse(org.xml.sax.InputSource source)
Do-nothing implementation of interface method
|
void |
parse(java.lang.String poSystemId)
Full implementation of interface method.
|
java.lang.String |
prefix(java.lang.String poElementName)
Given an unprefixed element name, returns
a new element name with a namespace prefix
|
void |
setContentHandler(org.xml.sax.ContentHandler poHandler)
Allow an application to register a content event handler.
|
void |
setDatabaseID(java.lang.String databaseID)
setDatabaseID identifies the database searched by
a name, ID or URN. |
void |
setDTDHandler(org.xml.sax.DTDHandler handler)
Do-nothing implementation of interface method
|
void |
setEntityResolver(org.xml.sax.EntityResolver resolver)
Do-nothing implementation of interface method
|
void |
setErrorHandler(org.xml.sax.ErrorHandler handler)
Do-nothing implementation of interface method
|
void |
setFeature(java.lang.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(java.lang.String poPrefix) |
void |
setProperty(java.lang.String name,
java.lang.Object value)
Do-nothing implementation of interface method
|
void |
setQueryID(java.lang.String queryID)
setQueryID identifies the query sequence by a
name, ID or URN. |
void |
setQuerySeq(java.lang.String identifier)
Deprecated.
use
setQueryID instead. |
void |
setSubjectDB(java.lang.String identifier)
Deprecated.
use
setDatabaseID instead. |
protected void |
startElement(org.biojava.bio.program.sax.QName poQName,
org.xml.sax.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 org.xml.sax.ContentHandler oHandler
protected boolean tNamespaces
protected boolean tNamespacePrefixes
protected java.lang.String oNamespacePrefix
protected java.lang.String oFullNamespacePrefix
protected int iState
public FastaSearchSAXParser()
FastaSearchSAXParser
instance.public void parse(org.xml.sax.InputSource source) throws java.io.IOException, org.xml.sax.SAXException
parse
in interface org.xml.sax.XMLReader
java.io.IOException
org.xml.sax.SAXException
public boolean getMoreSearches()
SearchContentHandler
getMoreSearches
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 SearchContentHandler
boolean
value.public void setMoreSearches(boolean value)
SearchContentHandler
setMoreSearches
sets the state of the
SearchContentHandler
's expectation of receiving
more results. Used for handling streams of search results.setMoreSearches
in interface SearchContentHandler
value
- a boolean
value.public void setQuerySeq(java.lang.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(java.lang.String queryID)
SearchContentHandler
setQueryID
identifies the query sequence by a
name, ID or URN.setQueryID
in interface SearchContentHandler
queryID
- a String
which should be an unique
identifer for the sequence.public void setSubjectDB(java.lang.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(java.lang.String databaseID)
SearchContentHandler
setDatabaseID
identifies the database searched by
a name, ID or URN.setDatabaseID
in interface SearchContentHandler
databaseID
- a String
which should be an unique
identifier for the database searched.public void startSearch()
SearchContentHandler
startSearch
method indicates the start of
useful search information.startSearch
in interface SearchContentHandler
public void addSearchProperty(java.lang.Object key, java.lang.Object value)
SearchContentHandler
addSearchProperty
method adds a key/value pair
containing some property of the overall search result.addSearchProperty
in interface SearchContentHandler
key
- an Object
.value
- an Object
.public void endSearch()
SearchContentHandler
endSearch
method indicates the end of useful
search information.endSearch
in interface SearchContentHandler
public void startHeader()
SearchContentHandler
startHeader
method indicates the start of a
formatted header. This usually contains information relevant to
the search as a whole.startHeader
in interface SearchContentHandler
public void endHeader()
SearchContentHandler
endHeader
method indicates the end of a
formatted header.endHeader
in interface SearchContentHandler
public void startHit()
SearchContentHandler
startHit
method indicates the start of a
formatted hit. This could be a single line, or a block of
lines.startHit
in interface SearchContentHandler
public void addHitProperty(java.lang.Object key, java.lang.Object value)
SearchContentHandler
addHitProperty
method adds a key/value pair
containing some property of a particular hit.addHitProperty
in interface SearchContentHandler
key
- an Object
.value
- an Object
.public void endHit()
SearchContentHandler
endHit
method indicates the end of a formatted
hit.endHit
in interface SearchContentHandler
public void startSubHit()
SearchContentHandler
startSubHit
method indicates the start of a
formatted subhit. There may be zero or more of these per hit.startSubHit
in interface SearchContentHandler
public void addSubHitProperty(java.lang.Object key, java.lang.Object value)
SearchContentHandler
addSubHitProperty
method adds a key/value pair
containing some property of a particular subhit.addSubHitProperty
in interface SearchContentHandler
key
- an Object
.value
- an Object
.public void endSubHit()
SearchContentHandler
endSubHit
method indicates the end of a
formatted subhit.endSubHit
in interface SearchContentHandler
public void setContentHandler(org.xml.sax.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 org.xml.sax.XMLReader
poHandler
- a ContentHandler
The XML content handlerjava.lang.NullPointerException
- If the handler argument is nullpublic org.xml.sax.ContentHandler getContentHandler()
getContentHandler
in interface org.xml.sax.XMLReader
ContentHandler
The current content handler,
or null if none has been registered.public void parse(java.lang.String poSystemId) throws java.io.IOException, org.xml.sax.SAXException
parse
in interface org.xml.sax.XMLReader
java.io.IOException
org.xml.sax.SAXException
public boolean getFeature(java.lang.String poName) throws org.xml.sax.SAXNotRecognizedException, org.xml.sax.SAXNotSupportedException
getFeature
in interface org.xml.sax.XMLReader
org.xml.sax.SAXNotRecognizedException
org.xml.sax.SAXNotSupportedException
public void setFeature(java.lang.String poName, boolean value) throws org.xml.sax.SAXNotRecognizedException, org.xml.sax.SAXNotSupportedException
setFeature
in interface org.xml.sax.XMLReader
org.xml.sax.SAXNotRecognizedException
org.xml.sax.SAXNotSupportedException
public java.lang.Object getProperty(java.lang.String name) throws org.xml.sax.SAXNotRecognizedException, org.xml.sax.SAXNotSupportedException
getProperty
in interface org.xml.sax.XMLReader
org.xml.sax.SAXNotRecognizedException
org.xml.sax.SAXNotSupportedException
public void setProperty(java.lang.String name, java.lang.Object value) throws org.xml.sax.SAXNotRecognizedException, org.xml.sax.SAXNotSupportedException
setProperty
in interface org.xml.sax.XMLReader
org.xml.sax.SAXNotRecognizedException
org.xml.sax.SAXNotSupportedException
public void setEntityResolver(org.xml.sax.EntityResolver resolver)
setEntityResolver
in interface org.xml.sax.XMLReader
public org.xml.sax.EntityResolver getEntityResolver()
getEntityResolver
in interface org.xml.sax.XMLReader
public void setDTDHandler(org.xml.sax.DTDHandler handler)
setDTDHandler
in interface org.xml.sax.XMLReader
public org.xml.sax.DTDHandler getDTDHandler()
getDTDHandler
in interface org.xml.sax.XMLReader
public void setErrorHandler(org.xml.sax.ErrorHandler handler)
setErrorHandler
in interface org.xml.sax.XMLReader
public org.xml.sax.ErrorHandler getErrorHandler()
getErrorHandler
in interface org.xml.sax.XMLReader
protected void startElement(org.biojava.bio.program.sax.QName poQName, org.xml.sax.Attributes atts) throws org.xml.sax.SAXException
poQName
- a QName
valueatts
- an Attributes
valueorg.xml.sax.SAXException
- if an error occursprotected void endElement(org.biojava.bio.program.sax.QName poQName) throws org.xml.sax.SAXException
poQName
- -org.xml.sax.SAXException
- thrown ifthrown
- ifprotected void characters(char[] ch, int start, int length) throws org.xml.sax.SAXException
ch
- -start
- -length
- -org.xml.sax.SAXException
- thrown ifthrown
- ifpublic boolean getNamespaces()
public boolean getNamespacePrefixes()
public void addPrefixMapping(java.lang.String poPrefix, java.lang.String poURI)
poPrefix
- a String
representation of the
namespace prefixpoURI
- a String
representation of the URI
for the namespace prefix.public java.lang.String getURIFromPrefix(java.lang.String poPrefix)
poPrefix
- a String
The namespace prefix.public void setNamespacePrefix(java.lang.String poPrefix)
poPrefix
- a String
valuepublic java.lang.String getNamespacePrefix()
getNamespacePrefix
method here.String
valuepublic java.lang.String prefix(java.lang.String poElementName)
String
valueprotected java.io.BufferedReader getContentStream(org.xml.sax.InputSource poSource)
poSource
- an InputSource
valueBufferedReader
valueprotected void changeState(int piState)
piState
- an int
value