Class Interpreter
- java.lang.Object
-
- ch.qos.logback.core.joran.spi.Interpreter
-
public class Interpreter extends java.lang.Object
Interpreter is Joran's main driving class. It extends SAXDefaultHandler
which invokes variousactions
according to predefined patterns.Patterns are kept in a
RuleStore
which is programmed to store and then later produce the applicable actions for a given pattern.The pattern corresponding to a top level <a> element is the string
"a" .The pattern corresponding to an element <b> embedded within a top level <a> element is the string
"a/b" .The pattern corresponding to an <b> and any level of nesting is "*/b. Thus, the * character placed at the beginning of a pattern serves as a wildcard for the level of nesting. Conceptually, this is very similar to the API of commons-digester. Joran offers several small advantages. First and foremost, it offers support for implicit actions which result in a significant leap in flexibility. Second, in our opinion better error reporting capability. Third, it is self-reliant. It does not depend on other APIs, in particular commons-logging which is too unreliable. Last but not least, Joran is quite tiny and is expected to remain so.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) java.util.Stack<java.util.List<Action>>
actionListStack
TheactionListStack contains a list of actions that are executing for the given XML element.private CAI_WithLocatorSupport
cai
private ElementPath
elementPath
private static java.util.List<Action>
EMPTY_LIST
(package private) EventPlayer
eventPlayer
private java.util.ArrayList<ImplicitAction>
implicitActions
private InterpretationContext
interpretationContext
(package private) org.xml.sax.Locator
locator
private RuleStore
ruleStore
(package private) ElementPath
skip
If the skip nested is set, then we skip all its nested elements until it is set back to null at when the element's end is reached.
-
Constructor Summary
Constructors Constructor Description Interpreter(Context context, RuleStore rs, ElementPath initialElementPath)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addImplicitAction(ImplicitAction ia)
(package private) void
callBeginAction(java.util.List<Action> applicableActionList, java.lang.String tagName, org.xml.sax.Attributes atts)
private void
callBodyAction(java.util.List<Action> applicableActionList, java.lang.String body)
private void
callEndAction(java.util.List<Action> applicableActionList, java.lang.String tagName)
void
characters(BodyEvent be)
void
endElement(EndEvent endEvent)
private void
endElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName)
(package private) java.util.List<Action>
getApplicableActionList(ElementPath elementPath, org.xml.sax.Attributes attributes)
Return the list of applicable patterns for thisEventPlayer
getEventPlayer()
InterpretationContext
getExecutionContext()
Deprecated.replaced bygetInterpretationContext()
InterpretationContext
getInterpretationContext()
org.xml.sax.Locator
getLocator()
RuleStore
getRuleStore()
(package private) java.lang.String
getTagName(java.lang.String localName, java.lang.String qName)
(package private) java.util.List<Action>
lookupImplicitAction(ElementPath elementPath, org.xml.sax.Attributes attributes, InterpretationContext ec)
Check if any implicit actions are applicable.private void
pushEmptyActionList()
This method is used tovoid
setDocumentLocator(org.xml.sax.Locator l)
void
setInterpretationContextPropertiesMap(java.util.Map<java.lang.String,java.lang.String> propertiesMap)
void
startDocument()
void
startElement(StartEvent se)
private void
startElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes atts)
-
-
-
Field Detail
-
EMPTY_LIST
private static java.util.List<Action> EMPTY_LIST
-
ruleStore
private final RuleStore ruleStore
-
interpretationContext
private final InterpretationContext interpretationContext
-
implicitActions
private final java.util.ArrayList<ImplicitAction> implicitActions
-
cai
private final CAI_WithLocatorSupport cai
-
elementPath
private ElementPath elementPath
-
locator
org.xml.sax.Locator locator
-
eventPlayer
EventPlayer eventPlayer
-
actionListStack
java.util.Stack<java.util.List<Action>> actionListStack
TheactionListStack contains a list of actions that are executing for the given XML element. A list of actions is pushed by the {link #startElement} and popped byendElement(ch.qos.logback.core.joran.event.EndEvent)
.
-
skip
ElementPath skip
If the skip nested is set, then we skip all its nested elements until it is set back to null at when the element's end is reached.
-
-
Constructor Detail
-
Interpreter
public Interpreter(Context context, RuleStore rs, ElementPath initialElementPath)
-
-
Method Detail
-
getEventPlayer
public EventPlayer getEventPlayer()
-
setInterpretationContextPropertiesMap
public void setInterpretationContextPropertiesMap(java.util.Map<java.lang.String,java.lang.String> propertiesMap)
-
getExecutionContext
public InterpretationContext getExecutionContext()
Deprecated.replaced bygetInterpretationContext()
-
getInterpretationContext
public InterpretationContext getInterpretationContext()
-
startDocument
public void startDocument()
-
startElement
public void startElement(StartEvent se)
-
startElement
private void startElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes atts)
-
pushEmptyActionList
private void pushEmptyActionList()
This method is used to
-
characters
public void characters(BodyEvent be)
-
endElement
public void endElement(EndEvent endEvent)
-
endElement
private void endElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName)
-
getLocator
public org.xml.sax.Locator getLocator()
-
setDocumentLocator
public void setDocumentLocator(org.xml.sax.Locator l)
-
getTagName
java.lang.String getTagName(java.lang.String localName, java.lang.String qName)
-
addImplicitAction
public void addImplicitAction(ImplicitAction ia)
-
lookupImplicitAction
java.util.List<Action> lookupImplicitAction(ElementPath elementPath, org.xml.sax.Attributes attributes, InterpretationContext ec)
Check if any implicit actions are applicable. As soon as an applicable action is found, it is returned. Thus, the returned list will have at most one element.
-
getApplicableActionList
java.util.List<Action> getApplicableActionList(ElementPath elementPath, org.xml.sax.Attributes attributes)
Return the list of applicable patterns for this
-
callBeginAction
void callBeginAction(java.util.List<Action> applicableActionList, java.lang.String tagName, org.xml.sax.Attributes atts)
-
callBodyAction
private void callBodyAction(java.util.List<Action> applicableActionList, java.lang.String body)
-
callEndAction
private void callEndAction(java.util.List<Action> applicableActionList, java.lang.String tagName)
-
getRuleStore
public RuleStore getRuleStore()
-
-