protected static class

MSTRLayoutParser.ParserContentHandler

extends AbstractHandler
java.lang.Object
   ↳ org.xml.sax.helpers.DefaultHandler
     ↳ com.microstrategy.utils.xml.AbstractHandler
       ↳ com.microstrategy.web.transform.MSTRLayoutParser.ParserContentHandler

Class Overview

This is the default implementation of the ContentHandler to use parse the layout XML.

Summary

[Expand]
Inherited Fields
From class com.microstrategy.utils.xml.AbstractHandler
Public Constructors
MSTRLayoutParser.ParserContentHandler(String layoutLocation)
The constructor for this class.
MSTRLayoutParser.ParserContentHandler(String layoutLocation, LayoutSource layoutSource, LayoutParser layoutParser)
The constructor for this class.
Public Methods
void characters(char[] ch, int start, int length)
ContentHandler method to indicate that text content has been identified.
void doEndElement(String namespaceURI, String localName, String qName)
AbstractHandler method that identifies the closing of a tag.
void doStartElement(String namespaceURI, String localName, String qName, Attributes atts)
AbstracHandler method to process the start of an element.
void endDocument()
ContentHandler method to indicate the end of the document.
String generateErrorMessage(String msg)
Generate a standard error message which includes the layout location (the source of the layout), the line number and the innermost enclosing element.
LayoutTag getLayoutTag()
The generated LayoutTag object constructed during parsing.
LayoutParser.MessageListener getMessageListener()
Returns the LayoutParser.MessageListener object used by this parser instance.
void setDocumentLocator(Locator locator)
ContentHandler method that records the current Locator for this document.
void setMessageListener(LayoutParser.MessageListener msgListener)
Set the LayoutParser.MessageListener object to use with this parser instance.
void startDocument()
ContentHandler method that records the start of the XML document.
void validationError()
Increments the number of validation errors encountered in this parsing.
Protected Methods
StringBuffer generateErrorMessagePrefix()
Generate the prefix of a diagnostic message.
String generateInternalError(String msg)
Generate an error message to reflect an internal parser error.
void initParserDataStructures()
Initialize any parser specific data structures.
boolean isVersionValid(String version)
This checks whether the supplied version is valid for this parser implementation.
void releaseParserDataStructures()
Release any parser specific data structures.
void sendErrorMsg(String msg)
Send a message to the LayoutParser.MessageListener object's error(String) method.
[Expand]
Inherited Methods
From class com.microstrategy.utils.xml.AbstractHandler
From class org.xml.sax.helpers.DefaultHandler
From class java.lang.Object
From interface org.xml.sax.ContentHandler
From interface org.xml.sax.DTDHandler
From interface org.xml.sax.EntityResolver
From interface org.xml.sax.ErrorHandler

Public Constructors

public MSTRLayoutParser.ParserContentHandler (String layoutLocation)

The constructor for this class. It stores away the layout location so that it can a) use it for error and warning messages and b) store it in the generated LayoutTag object.

public MSTRLayoutParser.ParserContentHandler (String layoutLocation, LayoutSource layoutSource, LayoutParser layoutParser)

The constructor for this class. It stores away the layout location so that it can a) use it for error and warning messages and b) store it in the generated LayoutTag object. It also stores the layoutSource and layoutParser information so the include tag can use them to load the external layout files.

Public Methods

public void characters (char[] ch, int start, int length)

ContentHandler method to indicate that text content has been identified. This implementation adds it to the current tag (via addTextChild(String).

Parameters
ch The characters.
start The start position in the character array.
length The number of characters to use from the character array.
Throws
SAXException

public void doEndElement (String namespaceURI, String localName, String qName)

AbstractHandler method that identifies the closing of a tag. The current implementation pops the current tag off the stack.

Throws
SAXException

public void doStartElement (String namespaceURI, String localName, String qName, Attributes atts)

AbstracHandler method to process the start of an element. If this is the root element, the version number is checked and if successful, the LayoutTag is recorded. Otherwise, a new generic tag is created (based on the localName of the element). Any attributes associated with the tag are added to the Tag object. The line number of the tag is recorded also in the Tag and the current Tag is pushed on the stack (making it the new "current" tag.

Throws
SAXException

public void endDocument ()

ContentHandler method to indicate the end of the document. This implementation checks that there are no tags still open. If there were validation errors, then a SAXException is raised. Regardless of whether either of these occur, a call is made to release all parser data structures (releaseParserDataStructures()).

Throws
SAXException

public String generateErrorMessage (String msg)

Generate a standard error message which includes the layout location (the source of the layout), the line number and the innermost enclosing element.

Parameters
msg The message to include in the standard message.
Returns
  • A formatted string containing context information.

public LayoutTag getLayoutTag ()

The generated LayoutTag object constructed during parsing.

Returns

public LayoutParser.MessageListener getMessageListener ()

Returns the LayoutParser.MessageListener object used by this parser instance.

Returns

public void setDocumentLocator (Locator locator)

ContentHandler method that records the current Locator for this document. It is used by the generateErrorMessage(String) method to include line numbers.

public void setMessageListener (LayoutParser.MessageListener msgListener)

Set the LayoutParser.MessageListener object to use with this parser instance.

Parameters
msgListener The LayoutParser.MessageListener object.

public void startDocument ()

ContentHandler method that records the start of the XML document. This implementation calls the initParserDataStructures() method to initialize any data structures.

Throws
SAXException

public void validationError ()

Increments the number of validation errors encountered in this parsing.

Protected Methods

protected StringBuffer generateErrorMessagePrefix ()

Generate the prefix of a diagnostic message. The current message begins with context information such as the layout location (if present), line number information, and current enclosing tag.

Returns
  • error message prefix.

protected String generateInternalError (String msg)

Generate an error message to reflect an internal parser error.

Parameters
msg The message to send.
Returns
  • An appropriately formatted internal error message.

protected void initParserDataStructures ()

Initialize any parser specific data structures.

protected boolean isVersionValid (String version)

This checks whether the supplied version is valid for this parser implementation.

Parameters
version The version strinig on the layout tag.
Returns
  • True if the parser should continue.

protected void releaseParserDataStructures ()

Release any parser specific data structures.

protected void sendErrorMsg (String msg)

Send a message to the LayoutParser.MessageListener object's error(String) method.

Parameters
msg The message to send.