ch.qos.logback.classic.android
Class ASaxEventRecorder

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by ch.qos.logback.core.joran.event.SaxEventRecorder
          extended by ch.qos.logback.classic.android.ASaxEventRecorder
All Implemented Interfaces:
ContextAware, ContentHandler, DTDHandler, EntityResolver, ErrorHandler

public class ASaxEventRecorder
extends SaxEventRecorder

SAX event recorder for compressed Android XML resource files. Supports filtering to capture only the sub-events of an event of interest in order to conserve memory usage.

Author:
Anthony Trinh

Field Summary
 
Fields inherited from class ch.qos.logback.core.joran.event.SaxEventRecorder
saxEventList
 
Constructor Summary
ASaxEventRecorder()
          Constructor
 
Method Summary
 String getAttributeWatchValue()
          Gets the value of the attribute set by setAttributeWatch(String, String)
 List<SaxEvent> recordEvents(InputSource src)
          Parses SAX events from a compressed Android XML resource
 void setAttributeWatch(String elemName, String attrName)
          Sets a "watch" for an element's attribute, which can be retrieved with getAttributeWatchValue().
 void setFilter(String... names)
          Sets a filter so that only sub-elements of a specific element are captured
 
Methods inherited from class ch.qos.logback.core.joran.event.SaxEventRecorder
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, characters, endElement, error, fatalError, getContext, getLocator, getSaxEventList, recordEvents, setContext, setDocumentLocator, startDocument, startElement, warning
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, skippedEntity, startPrefixMapping, unparsedEntityDecl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ASaxEventRecorder

public ASaxEventRecorder()
Constructor

Method Detail

setFilter

public void setFilter(String... names)
Sets a filter so that only sub-elements of a specific element are captured

For example, if the desired elements were inside

<x><y>
and the input were
<x><y><a/><b/><c/></x></y>
the filter would pass
<a/><b/><c/>
The call in this example would be: setFilter("x", "y").

Parameters:
names - names of elements leading to the target elements; use null to disable filtering (capture all events)

setAttributeWatch

public void setAttributeWatch(String elemName,
                              String attrName)
Sets a "watch" for an element's attribute, which can be retrieved with getAttributeWatchValue(). During the parsing of the SAX events, the START-elements are searched for the target attribute. If found, the attribute's value is stored. This checks all START- elements, regardless of filtering.

Parameters:
elemName - name of the element that contains the attribute
attrName - name of the attribute

getAttributeWatchValue

public String getAttributeWatchValue()
Gets the value of the attribute set by setAttributeWatch(String, String)

Returns:
the string value of the attribute; if the attribute was not encountered, this returns null

recordEvents

public List<SaxEvent> recordEvents(InputSource src)
                            throws JoranException
Parses SAX events from a compressed Android XML resource

Overrides:
recordEvents in class SaxEventRecorder
Parameters:
src - input source pointing to a compressed Android XML resource
Throws:
JoranException


Copyright © 2005-2013 QOS.ch. All Rights Reserved.