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.DefaultHandler
A base class for content handlers- Since:
- MicroStrategy Web 7.3.1 or earlier
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.StringBuffer
buf
Deprecated.usegetText()
to acquire String of internal bufferprotected int
depth
The element depth count.protected SAXSupport
parser
A reference to the SAX parser to which the handler is attached
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractHandler()
Default constructor.protected
AbstractHandler(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 void
characters(char[] ch, int start, int length)
void
clearText()
protected abstract void
doEndElement(java.lang.String uri, java.lang.String local, java.lang.String qName)
Override this method insted ofendElement
to process end element event.protected void
doStartElement(java.lang.String uri, java.lang.String local, java.lang.String qName, AttributesXt attrsXt)
protected void
doStartElement(java.lang.String uri, java.lang.String local, java.lang.String qName, org.xml.sax.Attributes attrs)
Override this method insted ofstartElement
to process start element event.void
endDocument()
This is a safegurd against forgetting to pop out inner handlers.void
endElement(java.lang.String uri, java.lang.String local, java.lang.String qName)
The default implementation that callsdoEndElement
then reduces the depth count.float
getFloatValue()
int
getIntValue()
java.lang.String
getText()
protected void
popContentHandler(java.lang.String uri, java.lang.String local, java.lang.String qName)
protected void
setLogErrors(boolean value)
void
startElement(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.SAXException
The default implementation that simply increases the depth count. and then callsdoStartElement
method. 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
supper
or simply start your code withdepth++;
statement (which is faster).- Specified by:
startElement
in interfaceorg.xml.sax.ContentHandler
- Overrides:
startElement
in 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.Exception
Override this method insted ofstartElement
to 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.SAXException
The default implementation that callsdoEndElement
then 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
doEndElement
method 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:
endElement
in interfaceorg.xml.sax.ContentHandler
- Overrides:
endElement
in 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.Exception
Override this method insted ofendElement
to 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:
characters
in interfaceorg.xml.sax.ContentHandler
- Overrides:
characters
in 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.SAXException
This is a safegurd against forgetting to pop out inner handlers. It throws an exception when end document event happens for inner handlers.- Specified by:
endDocument
in interfaceorg.xml.sax.ContentHandler
- Overrides:
endDocument
in 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
-
-