|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.xml.sax.helpers.XMLFilterImpl nbi.xmlsec.biocase.protocol.filter.ProtocolFilter
Base class to parse and filter protocol treeElements of the BioCASE protocol.
The class must be initialised with the protocolURI, the root element.
Furthermore, subfilters must be registered to declare the accepted
subelements of the filter
registerSubFilter()
/
unregisterSubFilter()
. Subfilters are
stored in a HashMap
where the element's local name serves as
key for the registered subfilter. If the registered subfilter for a local
name is null, then all incoming treeElements will be handled within the current
filter. If a real subfilter is set for a local name, all events including the
startElement event are redirected to the defined subfilter. Therefore, the
subfilter should be configured, before it will be registered! Note, that for
those subfilters, the protocol version URI is not checked, because this
should be controlled individually by the subfilter!
setFilterParameter(Object)
allows to set
special filter parameters. When the subfilter signals parse completion (
isParsingComplete()
) after the processing of
the corresponding endElement event, the subfilter will be unset. For all
incoming SAX events, the protocolURI and the validity of the incoming
treeElements according to the registered subfilters are checked. To support
filtering processes in subclasses, the following callback methods may be
overwritten:
parseInit(SAXElement)
startElement event
for filter's root element receivedfilterElement(SAXElement)
startElement event for registred subfilter element receivedfilterCharacters(SAXElement)
characters event for registred subfilter element receivedparseElement(SAXElement)
endElement
event for registred subfilter element receivedparseComplete(SAXElement)
endElement
event for filter's root element receivedisParsingComplete()
.
Field Summary | |
protected nbi.xml.sax.FilterStack |
elementStack
Stack storing all treeElements for this filter, if not redirected to subfilters |
private Map |
filterElements
Map of registered subfilters |
private boolean |
filterInitialised
|
protected int |
filterMode
The completion state of the parsing process |
static int |
FILTERMODE_FILTER
Filter mode filter of this protocol filter |
static int |
FILTERMODE_NONE
Filter mode unspecified of this protocol filter |
static int |
FILTERMODE_PARSER
Filter mode parser of this protocol filter |
private Object |
filterParameter
Parameter object for the current filter |
protected String |
filterRoot
The local name of the element to be parsed |
(package private) static Logger |
logger
|
private boolean |
parsingComplete
The completion state of the parsing process |
static String |
PROT_URI_13
ProtocolURI of the BioCASE protocol version 1.3 |
static String |
PROT_URI_20
ProtocolURI of the BioCASE protocol version 2.0 |
private String |
protocolURI
Namespace URI of the BioCASE protocol version |
private ProtocolFilter |
subFilter
Current active subfilter |
Fields inherited from class org.xml.sax.helpers.XMLFilterImpl |
|
Constructor Summary | |
ProtocolFilter(String protocolURI,
String filterRoot,
int trackMode,
int filterMode)
Inits the protocol filter. |
|
ProtocolFilter(XMLReader parent,
String protocolURI,
String filterRoot,
int trackMode,
int filterMode)
Inits the protocol filter with the specified parent. |
Method Summary | |
void |
characters(char[] ch,
int start,
int length)
Add the characters events to the characters stack and forwards it to the subfilter or content handler. |
private void |
checkElementParameters(boolean checkAtts,
String uri,
String localName,
String qName,
Attributes atts)
Checks the parameters of the start/endElement events against null parameters. |
protected void |
checkFilterParameter()
Checks, if a filter parameter is set. |
private void |
checkProtocolURI(String uri)
Checks the protocol URI against the protocolURI of this filter. |
void |
endElement(String uri,
String localName,
String qName)
Completes the processesing of data collection on the stacks, controls event forwarding and callback methods. |
protected nbi.xml.sax.SAXElement |
filterCharacters(nbi.xml.sax.SAXElement element)
This method is called when the characters event of any element for a registered subfilter was received, before it is forwarded to a registered subfilter or the content handler. |
protected nbi.xml.sax.SAXElement |
filterElement(nbi.xml.sax.SAXElement element)
This method is called when the startElement event of any element for a registered subfilter was received, before it is forwarded to a registered subfilter or the content handler. |
int |
getFilterMode()
Gets the filterMode. |
Object |
getFilterParameter()
Gets the parameter object of this filter |
String |
getProtocolURI()
Gets the protocol version URI. |
private void |
init(String protocolURI,
String filterRoot,
int trackMode,
int filterMode)
Inits the protocol filter. |
(package private) boolean |
isParsingComplete()
Return the completion state of parsing process. |
protected nbi.xml.sax.SAXElement |
parseComplete(nbi.xml.sax.SAXElement element)
This method is called when the endElement event of root element was received, before it is forwarded to the content handler |
protected nbi.xml.sax.SAXElement |
parseElement(nbi.xml.sax.SAXElement element)
This method is called when the endElement event of any element for a registered element was received, before it is forwarded to the content handler. |
protected nbi.xml.sax.SAXElement |
parseInit(nbi.xml.sax.SAXElement element)
This method is called when the startElement event of the root element was received, before it will be forwarded to the content handler. |
protected void |
registerSubFilter(String name,
ProtocolFilter filter)
Registers a subfilter. |
void |
setFilterParameter(Object parameter)
Sets the parameter object of this filter |
protected void |
setProtocolURI(String protocolURI)
Sets the protocol version URI. |
void |
startElement(String uri,
String localName,
String qName,
Attributes atts)
Prepares and processes the data collection on the stacks, controls event forwarding and callback methods. |
protected ProtocolFilter |
unregisterSubFilter(String name)
Unregisters a subfilter. |
Methods inherited from class org.xml.sax.helpers.XMLFilterImpl |
endDocument, endPrefixMapping, error, fatalError, getContentHandler, getDTDHandler, getEntityResolver, getErrorHandler, getFeature, getParent, getProperty, ignorableWhitespace, notationDecl, parse, parse, processingInstruction, resolveEntity, setContentHandler, setDocumentLocator, setDTDHandler, setEntityResolver, setErrorHandler, setFeature, setParent, setProperty, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
static Logger logger
public static final String PROT_URI_13
public static final String PROT_URI_20
public static final int FILTERMODE_NONE
public static final int FILTERMODE_FILTER
public static final int FILTERMODE_PARSER
private String protocolURI
protected nbi.xml.sax.FilterStack elementStack
protected int filterMode
private boolean parsingComplete
protected String filterRoot
private Map filterElements
private Object filterParameter
private ProtocolFilter subFilter
private boolean filterInitialised
Constructor Detail |
public ProtocolFilter(String protocolURI, String filterRoot, int trackMode, int filterMode)
protocolURI
- URI of the protocol version.filterRoot
- Local name of the root element.trackMode
- Define track mode for the internal
FilterStack
.filterMode
- Define filter mode for this filter FILTERMODE_FILTER(inkl. PDPFilter)
or FILTERMODE_PARSER(Parses all elements)
.public ProtocolFilter(XMLReader parent, String protocolURI, String filterRoot, int trackMode, int filterMode)
parent
- Parent reader.protocolURI
- URI of the protocol version.filterRoot
- Local name of the root element.trackMode
- Define track mode for the internal
FilterStack
.filterMode
- Define filter mode for this filter FILTERMODE_FILTER(inkl. PDPFilter)
or FILTERMODE_PARSER(Parses all elements)
.Method Detail |
private void init(String protocolURI, String filterRoot, int trackMode, int filterMode)
protocolURI
- URI of the protocol version.filterRoot
- Local name of the root element.trackMode
- Define track mode for the internal
FilterStack
.filterMode
- Define filter mode for this filter FILTERMODE_FILTER(inkl. PDPFilter)
or FILTERMODE_PARSER(Parses all elements)
.private void checkElementParameters(boolean checkAtts, String uri, String localName, String qName, Attributes atts) throws SAXException
checkAtts
- Signals, if attributes have to be checked or not.
SAXException
- if null parameter occurs.private void checkProtocolURI(String uri) throws SAXException
SAXException
- if incorrect protocol URI occurs.public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException
SAXException
ContentHandler.startElement(String,String,String,Attributes)
public void endElement(String uri, String localName, String qName) throws SAXException
SAXException
ContentHandler.endElement(String,String,String)
public void characters(char[] ch, int start, int length) throws SAXException
SAXException
ContentHandler.characters(char[], int, int)
public String getProtocolURI()
protected void setProtocolURI(String protocolURI)
protocolURI
- The protocol URI.boolean isParsingComplete()
protected nbi.xml.sax.SAXElement parseInit(nbi.xml.sax.SAXElement element) throws SAXException
element
- The element of the startElement event (contains no value).
SAXException
- If any parsing error occurs.protected nbi.xml.sax.SAXElement filterElement(nbi.xml.sax.SAXElement element) throws SAXException
element
- The element corresponding to the startElement event.
SAXException
- If any parsing error occurs.protected nbi.xml.sax.SAXElement filterCharacters(nbi.xml.sax.SAXElement element) throws SAXException
element
- The element corresponding to the startElement event.
SAXException
- If any parsing error occurs.protected nbi.xml.sax.SAXElement parseElement(nbi.xml.sax.SAXElement element) throws SAXException
isParsingComplete()
. But, the returned
element will not influence the event processing, because this has to be
done by the subfilter.
element
- The element corresponding to the endElement event.
SAXException
- If any parsing error occurs.protected nbi.xml.sax.SAXElement parseComplete(nbi.xml.sax.SAXElement element) throws SAXException
element
- The complete root element (including the value).
SAXException
- If any parsing error occurs.protected void registerSubFilter(String name, ProtocolFilter filter)
name
- local name for the subfilter to register.filter
- subfilter for this element or null.protected ProtocolFilter unregisterSubFilter(String name)
name
- local name for the subfilter to unregister.
public Object getFilterParameter()
public void setFilterParameter(Object parameter)
parameter
- Returns the filter parameter.protected void checkFilterParameter() throws SAXException
SAXException
- If no parameter is set (null)public int getFilterMode()
FILTERMODE_FILTER(inkl. PDPFilter)
FILTERMODE_PARSER(Parses all elements)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |