Package com.microstrategy.utils.xml
Class AbstractHandler
- java.lang.Object
-
- org.xml.sax.helpers.DefaultHandler
-
- com.microstrategy.utils.xml.AbstractHandler
-
- All Implemented Interfaces:
org.xml.sax.ContentHandler,org.xml.sax.DTDHandler,org.xml.sax.EntityResolver,org.xml.sax.ErrorHandler
- Direct Known Subclasses:
AbstractHandlerWithText,ImportSaveRWDTask.ImportDashboardResultHandler,MSTRCheckedException.ExceptionXMLHandler,MSTRLayoutParser.ParserContentHandler,RWUnitInfoImpl.UnitInfoHandler,SaveDBRoleTask.DBObjectsHandler,SaxToDomHandler,SAXXMLStringDumper,WebExpressionParser.AttributeElementListHandler,WebExpressionParser.AttributeFormExpressionHandler,WebExpressionParser.AttributeFormQualHandler,WebExpressionParser.ConstantHandler,WebExpressionParser.MetricExpressionHandler,WebExpressionParser.MetricQualHandler
public abstract class AbstractHandler extends org.xml.sax.helpers.DefaultHandlerA base class for content handlers- Since:
- MicroStrategy Web 7.3.1 or earlier
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.StringBufferbufDeprecated.usegetText()to acquire String of internal bufferprotected intdepthThe element depth count.protected SAXSupportparserA reference to the SAX parser to which the handler is attached
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractHandler()Default constructor.protectedAbstractHandler(SAXSupport pParser)Initializes the handler and attaches it to the parser.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidcharacters(char[] ch, int start, int length)voidclearText()protected abstract voiddoEndElement(java.lang.String uri, java.lang.String local, java.lang.String qName)Override this method insted ofendElementto process end element event.protected voiddoStartElement(java.lang.String uri, java.lang.String local, java.lang.String qName, AttributesXt attrsXt)protected voiddoStartElement(java.lang.String uri, java.lang.String local, java.lang.String qName, org.xml.sax.Attributes attrs)Override this method insted ofstartElementto process start element event.voidendDocument()This is a safegurd against forgetting to pop out inner handlers.voidendElement(java.lang.String uri, java.lang.String local, java.lang.String qName)The default implementation that callsdoEndElementthen reduces the depth count.floatgetFloatValue()intgetIntValue()java.lang.StringgetText()protected voidpopContentHandler(java.lang.String uri, java.lang.String local, java.lang.String qName)protected voidsetLogErrors(boolean value)voidstartElement(java.lang.String uri, java.lang.String local, java.lang.String qName, org.xml.sax.Attributes attrs)The default implementation that simply increases the depth count.
-
-
-
Field Detail
-
buf
protected java.lang.StringBuffer buf
Deprecated.usegetText()to acquire String of internal bufferA buffer to accumulate element text.- Since:
- MicroStrategy Web 8.0.0
-
depth
protected int depth
The element depth count. It is relative to the handler's root element, an element at which this handler was attached to the parser. Whenever a handler receives the startElement event it increases this counter. Whenever the handler receives the endElement event it decreases the counter. When the counter becomes zero the handler pops itself from the handler stack. Real handler shall use this variable to optimize content handlers. They shall first check the depth and then check for tag names that are expected at this depth.
-
parser
protected SAXSupport parser
A reference to the SAX parser to which the handler is attached
-
-
Constructor Detail
-
AbstractHandler
protected AbstractHandler()
Default constructor.
-
AbstractHandler
protected AbstractHandler(SAXSupport pParser)
Initializes the handler and attaches it to the parser.- Parameters:
pParser- - a SAX parser to which this handler needs to be attached
-
-
Method Detail
-
setLogErrors
protected void setLogErrors(boolean value)
- Since:
- MicroStrategy Web 8.0.0
-
startElement
public void startElement(java.lang.String uri, java.lang.String local, java.lang.String qName, org.xml.sax.Attributes attrs) throws org.xml.sax.SAXExceptionThe default implementation that simply increases the depth count. and then callsdoStartElementmethod. Override the doStartElement method insted of this one to process start element event. This way you will not have problems with depth counter while subclassing your event handlers.When overriding this method you shall either call
supperor simply start your code withdepth++;statement (which is faster).- Specified by:
startElementin interfaceorg.xml.sax.ContentHandler- Overrides:
startElementin classorg.xml.sax.helpers.DefaultHandler- Parameters:
uri- The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed.local- The local name (without prefix), or the empty string if Namespace processing is not being performed.qName- The qualified name (with prefix), or the empty string if qualified names are not available.attrs- The attributes attached to the element. If there are no attributes, it shall be an empty Attributes object- Throws:
org.xml.sax.SAXException- Any SAX exception, possibly wrapping another exception
-
doStartElement
protected void doStartElement(java.lang.String uri, java.lang.String local, java.lang.String qName, AttributesXt attrsXt) throws java.lang.Exception- Throws:
java.lang.Exception- Since:
- MicroStrategy Web 8.0.0
-
doStartElement
protected void doStartElement(java.lang.String uri, java.lang.String local, java.lang.String qName, org.xml.sax.Attributes attrs) throws java.lang.ExceptionOverride this method insted ofstartElementto process start element event. This way you will not have problems with depth counter while subclassing your event handlers.- Throws:
org.xml.sax.SAXException- Any SAX exception, possibly wrapping another exceptionjava.lang.Exception
-
endElement
public void endElement(java.lang.String uri, java.lang.String local, java.lang.String qName) throws org.xml.sax.SAXExceptionThe default implementation that callsdoEndElementthen reduces the depth count. If this is an event for the handler's root element (depth count goes to zero), then the handlers is detached from (popped out of) the parser.Override the
doEndElementmethod insted of this one to process end element event. This way you will not have problems with depth counter while subclassing your event handlers.When overriding this method always call
super at the end of your code.- Specified by:
endElementin interfaceorg.xml.sax.ContentHandler- Overrides:
endElementin classorg.xml.sax.helpers.DefaultHandler- Parameters:
uri- The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed.local- The local name (without prefix), or the empty string if Namespace processing is not being performed.qName- The qualified name (with prefix), or the empty string if qualified names are not available.- Throws:
org.xml.sax.SAXException- Any SAX exception, possibly wrapping another exception
-
popContentHandler
protected void popContentHandler(java.lang.String uri, java.lang.String local, java.lang.String qName) throws org.xml.sax.SAXException- Throws:
org.xml.sax.SAXException- Since:
- MicroStrategy Web 8.0.0
-
doEndElement
protected abstract void doEndElement(java.lang.String uri, java.lang.String local, java.lang.String qName) throws java.lang.ExceptionOverride this method insted ofendElementto process end element event. This way you will not have problems with depth counter while subclassing your event handlers.- Throws:
org.xml.sax.SAXException- Any SAX exception, possibly wrapping another exceptionjava.lang.Exception
-
characters
public void characters(char[] ch, int start, int length) throws org.xml.sax.SAXException- Specified by:
charactersin interfaceorg.xml.sax.ContentHandler- Overrides:
charactersin classorg.xml.sax.helpers.DefaultHandler- Parameters:
ch- The characters.start- The start position in the character array.length- The number of characters to use from the character array.- Throws:
org.xml.sax.SAXException- Any SAX exception, possibly wrapping another exception.- Since:
- MicroStrategy Web 8.0.0
- See Also:
ContentHandler.characters(char[], int, int)
-
endDocument
public void endDocument() throws org.xml.sax.SAXExceptionThis is a safegurd against forgetting to pop out inner handlers. It throws an exception when end document event happens for inner handlers.- Specified by:
endDocumentin interfaceorg.xml.sax.ContentHandler- Overrides:
endDocumentin classorg.xml.sax.helpers.DefaultHandler- Throws:
java.lang.IllegalStateException- when called for inner handlerorg.xml.sax.SAXException- Any SAX exception, possibly wrapping another exception.- See Also:
ContentHandler.endDocument()
-
getIntValue
public int getIntValue()
- Since:
- MicroStrategy Web 9.0.0
-
getFloatValue
public float getFloatValue()
-
getText
public java.lang.String getText()
- Since:
- MicroStrategy Web 9.0.0
-
clearText
public void clearText()
- Since:
- MicroStrategy Web 9.0.0
-
-