public class

MSTRLayoutParser

extends Object
implements LayoutParser
java.lang.Object
   ↳ com.microstrategy.web.transform.MSTRLayoutParser
Known Direct Subclasses

Class Overview

The MSTRLayoutParser class is default parser for all MicroStrategy-defined layout definitions. It provides many hooks for customization, for example:

All of the object methods can be overriden to provide a different implementation. Furthermore, the steps of the parseLayout(String, String, LayoutParser.MessageListener) method are themselves protected methods can be overriden.

Summary

Nested Classes
class MSTRLayoutParser.ParserContentHandler This is the default implementation of the ContentHandler to use parse the layout XML. 
class MSTRLayoutParser.ParserEntityResolver This is the default implementation of the EntityResolver object. 
class MSTRLayoutParser.ParserErrorHandler This is the defualt implementation for the ErrorHandler object used with the SAX Parser. 
Public Constructors
MSTRLayoutParser()
Standard no-args constructor for the layout parser.
MSTRLayoutParser(boolean debug)
Special version of the Parser that can enable more diagnostic messages.
Public Methods
String getDescription()
Gets the description of this layout parser object (to be read by someone wishing to use it).
LayoutTag parseLayout(String layout, String location, LayoutSource layoutSource, LayoutParser.MessageListener listener)
This method performs a parsing operation on a layout definition (supplied as a string).
LayoutTag parseLayout(String layout, String location, LayoutParser.MessageListener listener)
Protected Methods
MSTRLayoutParser.ParserContentHandler getContentHandler(String layoutLocation)
Returns a MSTRLayoutParser.ParserContentHandler object which performs the actual parsing of the layout text.
InputStream getEntityAsStream(String entityId)
Returns an InputStream for the specified entity file name.
EntityResolver getEntityResolver(String entitySearchDir)
Returns an EntityResolver object used by the parser to resolve references to external DTDs.
ErrorHandler getErrorHandler(LayoutParser.MessageListener listener, MSTRLayoutParser.ParserContentHandler pch)
Returns an ErrorHandler object used by the parser to route error and warning messages back to the caller.
InputSource getInputSource(String xmlText)
Returns an InputSource object for the supplied layout XML.
LayoutTag loadDocument(InputSource inputSource, String layoutLocation, String entitySearchDir, LayoutParser.MessageListener listener)
This method performs the actual SAX parsing of the layout definition.
void performStaticSemanticChecks(LayoutTag layoutTag, LayoutParser.MessageListener listener)
Perform any additional static semantic analyses on the generated LayoutTag object.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.microstrategy.web.transform.LayoutParser

Public Constructors

public MSTRLayoutParser ()

Standard no-args constructor for the layout parser.

public MSTRLayoutParser (boolean debug)

Special version of the Parser that can enable more diagnostic messages.

Parameters
debug Whether to enable more diagnostic messages. If enabled, the messages are sent to System.err.

Public Methods

public String getDescription ()

Gets the description of this layout parser object (to be read by someone wishing to use it). This description should include some reference to the type of special tags that understands.

Returns
  • A textual description of this layout parser object.

public LayoutTag parseLayout (String layout, String location, LayoutSource layoutSource, LayoutParser.MessageListener listener)

This method performs a parsing operation on a layout definition (supplied as a string). If the caller wants to be informed of warning and error conditions, he should create an instance of an object that implements the LayoutParser.MessageListener interface.

This particular implentation is broken up into three steps:

  1. Create an InputSource object (see getInputSource(String) using the supplied layout text.
  2. Load the document into memory using the InputSource computed in the previous step. (See loadDocument(InputSource, String, String, LayoutParser.MessageListener))
  3. Perform any additional static semantic by calling performStaticSemanticChecks(LayoutTag, LayoutParser.MessageListener).
Any of these methods can be overridden in a subclass to modify the behavior of the parser.

Parameters
layout The Layout Definition as a string.
location The source location for this layout. It is only used for diagnostic purposes. If omitted, then no source location is mentioned any error or warning messages.
layoutSource The layout source is for loading the external file when IncludeTag is used
listener An instance of a MessageListener object that the parser uses to indicate warning and error conditions.
Returns
  • If successful, a LayoutTag that represents the Layout Definition in-memory.
Throws
LayoutParsingException If parsing fails (due to an error condition), this exception is raised.

public LayoutTag parseLayout (String layout, String location, LayoutParser.MessageListener listener)

This method is deprecated.
- use parseLayout(String, String, LayoutSource, MessageListener)

This method performs a parsing operation on a layout definition (supplied as a string). If the caller wants to be informed of warning and error conditions, he should create an instance of an object that implements the LayoutParser.MessageListener interface.

This particular implentation is broken up into three steps:

  1. Create an InputSource object (see getInputSource(String) using the supplied layout text.
  2. Load the document into memory using the InputSource computed in the previous step. (See loadDocument(InputSource, String, String, LayoutParser.MessageListener))
  3. Perform any additional static semantic by calling performStaticSemanticChecks(LayoutTag, LayoutParser.MessageListener).
Any of these methods can be overridden in a subclass to modify the behavior of the parser.

Parameters
layout The Layout Definition as a string.
location The source location for this layout. It is only used for diagnostic purposes. If omitted, then no source location is mentioned any error or warning messages.
listener An instance of a MessageListener object that the parser uses to indicate warning and error conditions.
Returns
  • If successful, a LayoutTag that represents the Layout Definition in-memory.
Throws
LayoutParsingException If parsing fails (due to an error condition), this exception is raised.

Protected Methods

protected MSTRLayoutParser.ParserContentHandler getContentHandler (String layoutLocation)

Returns a MSTRLayoutParser.ParserContentHandler object which performs the actual parsing of the layout text.

Parameters
layoutLocation The location of the original layout definition. It is only used in diagnostic messages.

protected InputStream getEntityAsStream (String entityId)

Returns an InputStream for the specified entity file name.

Parameters
entityId The file name containing XML entities
Returns
  • InputStream the input stream for reading the entity file, or null if the entity file can not be found.
Throws
IOException thrown if there is any error reading the entity file.

protected EntityResolver getEntityResolver (String entitySearchDir)

Returns an EntityResolver object used by the parser to resolve references to external DTDs.

Parameters
entitySearchDir The location to use to search for all DTDs.
Returns
  • An EntityResolver implementation that resolves the location of specific DTDs.

protected ErrorHandler getErrorHandler (LayoutParser.MessageListener listener, MSTRLayoutParser.ParserContentHandler pch)

Returns an ErrorHandler object used by the parser to route error and warning messages back to the caller.

Parameters
listener An LayoutParser.MessageListener object to use.
pch A reference to the MSTRLayoutParser.ParserContentHandler object instance.
Returns

protected InputSource getInputSource (String xmlText)

Returns an InputSource object for the supplied layout XML.

Parameters
xmlText The layout definition to parse.
Returns

protected LayoutTag loadDocument (InputSource inputSource, String layoutLocation, String entitySearchDir, LayoutParser.MessageListener listener)

This method performs the actual SAX parsing of the layout definition.

Parameters
inputSource The InputSource object which contains a reference to the the layout defintion being parsed.
layoutLocation The source location of the layout definition. It is used for generate meaningful error messages.
entitySearchDir This is the directory where the Parser may find the referenced DTDs.
listener This is an instance of LayoutParser.MessageListener object used to communicate warning and error messages back to the caller.
Returns
  • The generated LayoutTag, if parsing was successful.
Throws
LayoutParsingException If parsing fails, this is thrown.

protected void performStaticSemanticChecks (LayoutTag layoutTag, LayoutParser.MessageListener listener)

Perform any additional static semantic analyses on the generated LayoutTag object. The current implementation does not perform any additional checks at this time.

Parameters
layoutTag The generated layout, in the form of a LayoutTag.
listener The LayoutParser.MessageListener object to pass messages through.
Throws
LayoutParsingException An exception is through if any sematic checks fail.