WebObjects 5.4.2

com.webobjects.appserver.parser.woml
Class WOMLTemplateParser

java.lang.Object
  extended by com.webobjects.appserver.parser.WOComponentTemplateParser
      extended by com.webobjects.appserver.parser.woml.WOMLTemplateParser
All Implemented Interfaces:
ContentHandler, LexicalHandler

public class WOMLTemplateParser
extends WOComponentTemplateParser
implements ContentHandler, LexicalHandler


Nested Class Summary
 
Nested classes/interfaces inherited from class com.webobjects.appserver.parser.WOComponentTemplateParser
WOComponentTemplateParser.Factory
 
Field Summary
static String CDATA_EMBED_PREFIX
           
static String CDATA_EMBED_SUFFIX
           
static String TEMPLATE_CANNED_PREFIX
           
static String TEMPLATE_CANNED_SUFFIX
           
static String TEMPLATE_WRAPPER_ELEMENT_NAME
           
 
Constructor Summary
WOMLTemplateParser(String referenceName, String HTMLString, String declarationString, NSArray languages, WOAssociationFactory associationFactory, WOMLNamespaceProvider namespaceProvider)
           
 
Method Summary
protected  void addWOElement(WOElement element, List elements)
          Adds the given WOElement to the list of WOElement objects.
protected  void appendEscapedText(CharSequence sequence, StringBuilder buffer)
           
 void characters(char[] ch, int start, int length)
           
 void comment(char[] ch, int start, int length)
           
protected  void createWOElements(List nodes, StringBuilder textBuffer, List childElements)
          Creates a list of WOElement objects from a list of WOMLNode objects.
 void endCDATA()
           
protected  void endCurrentTextNode()
           
 void endDocument()
           
 void endDTD()
           
 void endElement(String uri, String localName, String qName)
           
 void endEntity(String name)
           
 void endPrefixMapping(String prefix)
           
protected  void escapeInnerData(CharSequence sequence, String prefix, String suffix, StringBuilder buffer)
           
static String escapeRegex(String s)
           
protected  int getCurrentColumnNumber()
           
protected  int getCurrentLineNumber()
           
protected  WOMLParentNode getCurrentNode()
           
protected  WOMLPosition getCurrentPosition()
           
 DTDHandler getDTDHandler()
           
 EntityResolver getEntityResolver()
           
 ErrorHandler getErrorHandler()
           
 void ignorableWhitespace(char[] ch, int start, int length)
           
static boolean isCombinedTemplate(WOComponentDefinition definition)
           
 WOElement parse()
           
protected  String parseUntil(String prefix, StringBuilder buffer, String endToken, boolean includeLeadingWhitespace, boolean includeTrailingWhitespace)
          Parses the current buffer with the given prefix until the given suffix is found.
protected  String pathForComponentDef(WOComponentDefinition componentDef)
          Returns the path string for the component definition given.
protected  WOMLParentNode popNode()
           
protected  String preprocess(String templateString)
          This is unclean.
protected  WOElement process(String theTemplateString, String xmlProcessingInstruction, String prefixString)
           
 void processingInstruction(String target, String data)
           
protected  void pushNode(WOMLParentNode node)
           
 void setDocumentLocator(Locator locator)
           
 void setDTDHandler(DTDHandler dtdHandler)
           
 void setEntityResolver(EntityResolver entityResolver)
           
 void setErrorHandler(ErrorHandler handler)
           
 void skippedEntity(String name)
           
 void startCDATA()
           
 void startDocument()
           
 void startDTD(String name, String publicId, String systemId)
           
 void startElement(String uri, String localName, String qName, Attributes attributes)
           
 void startEntity(String name)
           
 void startPrefixMapping(String prefix, String uri)
           
static WOElement templateWithString(String referenceName, String templateString, NSArray languages, WOAssociationFactory associationFactory, WOMLNamespaceProvider namespaceProvider)
           
protected  void updateStartPosition()
           
 
Methods inherited from class com.webobjects.appserver.parser.WOComponentTemplateParser
associationFactory, declarationString, htmlString, languages, namespaceProvider, referenceName, setDeclarationString, setHtmlString, setLanguages, setWOHTMLTemplateParserClassName, shouldThrowException, templateWithHTMLAndDeclaration, templateWithHTMLAndDeclaration, templateWithHTMLAndDeclaration, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CDATA_EMBED_PREFIX

public static String CDATA_EMBED_PREFIX

CDATA_EMBED_SUFFIX

public static String CDATA_EMBED_SUFFIX

TEMPLATE_WRAPPER_ELEMENT_NAME

public static String TEMPLATE_WRAPPER_ELEMENT_NAME

TEMPLATE_CANNED_PREFIX

public static String TEMPLATE_CANNED_PREFIX

TEMPLATE_CANNED_SUFFIX

public static String TEMPLATE_CANNED_SUFFIX
Constructor Detail

WOMLTemplateParser

public WOMLTemplateParser(String referenceName,
                          String HTMLString,
                          String declarationString,
                          NSArray languages,
                          WOAssociationFactory associationFactory,
                          WOMLNamespaceProvider namespaceProvider)
Method Detail

templateWithString

public static WOElement templateWithString(String referenceName,
                                           String templateString,
                                           NSArray languages,
                                           WOAssociationFactory associationFactory,
                                           WOMLNamespaceProvider namespaceProvider)
                                    throws WODeclarationFormatException,
                                           WOHTMLFormatException,
                                           ClassNotFoundException
Throws:
WODeclarationFormatException
WOHTMLFormatException
ClassNotFoundException

escapeRegex

public static String escapeRegex(String s)

isCombinedTemplate

public static boolean isCombinedTemplate(WOComponentDefinition definition)

pathForComponentDef

protected String pathForComponentDef(WOComponentDefinition componentDef)
Returns the path string for the component definition given.

Parameters:
componentDef -
Returns:

getCurrentNode

protected WOMLParentNode getCurrentNode()

popNode

protected WOMLParentNode popNode()

pushNode

protected void pushNode(WOMLParentNode node)

escapeInnerData

protected void escapeInnerData(CharSequence sequence,
                               String prefix,
                               String suffix,
                               StringBuilder buffer)

appendEscapedText

protected void appendEscapedText(CharSequence sequence,
                                 StringBuilder buffer)

preprocess

protected String preprocess(String templateString)
This is unclean. This splits CDATA and comment sections into bits that have embedded elements. This also translates any non-comment and non-CDATA content ampersands to XML escape sequences (& -> &).

Parameters:
templateString -
Returns:

process

protected WOElement process(String theTemplateString,
                            String xmlProcessingInstruction,
                            String prefixString)
                     throws WOMLTemplateParserException
Throws:
WOMLTemplateParserException

getCurrentLineNumber

protected int getCurrentLineNumber()

getCurrentColumnNumber

protected int getCurrentColumnNumber()

getCurrentPosition

protected WOMLPosition getCurrentPosition()

updateStartPosition

protected void updateStartPosition()

endCurrentTextNode

protected void endCurrentTextNode()

addWOElement

protected void addWOElement(WOElement element,
                            List elements)
Adds the given WOElement to the list of WOElement objects. If the given element is a bare string and the last element in the list is also a bare string the elements will be combined.

Parameters:
element -
elements -

createWOElements

protected void createWOElements(List nodes,
                                StringBuilder textBuffer,
                                List childElements)
Creates a list of WOElement objects from a list of WOMLNode objects. The given textBuffer holds the current bare string that was present at the beginning of the element creation.

Parameters:
nodes -
childElements -
textBuffer -

getErrorHandler

public ErrorHandler getErrorHandler()

setErrorHandler

public void setErrorHandler(ErrorHandler handler)

getEntityResolver

public EntityResolver getEntityResolver()

setEntityResolver

public void setEntityResolver(EntityResolver entityResolver)

getDTDHandler

public DTDHandler getDTDHandler()

setDTDHandler

public void setDTDHandler(DTDHandler dtdHandler)

parseUntil

protected String parseUntil(String prefix,
                            StringBuilder buffer,
                            String endToken,
                            boolean includeLeadingWhitespace,
                            boolean includeTrailingWhitespace)
Parses the current buffer with the given prefix until the given suffix is found. If the prefix is not present then this method returns null and the buffer unmodified. If found characters are consumed into the result until the end token is found. If includeTrailingWhitespace is true this will add any trailing whitespace to the returned token. If includeLeadingWhitespace is specified then leading whitespace will be ignored for matching purposes, but still returned in the return value.


parse

public WOElement parse()
                throws ClassNotFoundException,
                       WODeclarationFormatException,
                       WOHTMLFormatException
Specified by:
parse in class WOComponentTemplateParser
Returns:
Parsed component
Throws:
ClassNotFoundException
WODeclarationFormatException
WOHTMLFormatException

setDocumentLocator

public void setDocumentLocator(Locator locator)
Specified by:
setDocumentLocator in interface ContentHandler

startDocument

public void startDocument()
                   throws SAXException
Specified by:
startDocument in interface ContentHandler
Throws:
SAXException

endDocument

public void endDocument()
                 throws SAXException
Specified by:
endDocument in interface ContentHandler
Throws:
SAXException

startPrefixMapping

public void startPrefixMapping(String prefix,
                               String uri)
                        throws SAXException
Specified by:
startPrefixMapping in interface ContentHandler
Throws:
SAXException

endPrefixMapping

public void endPrefixMapping(String prefix)
                      throws SAXException
Specified by:
endPrefixMapping in interface ContentHandler
Throws:
SAXException

processingInstruction

public void processingInstruction(String target,
                                  String data)
                           throws SAXException
Specified by:
processingInstruction in interface ContentHandler
Throws:
SAXException

startElement

public void startElement(String uri,
                         String localName,
                         String qName,
                         Attributes attributes)
                  throws SAXException
Specified by:
startElement in interface ContentHandler
Throws:
SAXException

endElement

public void endElement(String uri,
                       String localName,
                       String qName)
                throws SAXException
Specified by:
endElement in interface ContentHandler
Throws:
SAXException

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws SAXException
Specified by:
characters in interface ContentHandler
Throws:
SAXException

ignorableWhitespace

public void ignorableWhitespace(char[] ch,
                                int start,
                                int length)
                         throws SAXException
Specified by:
ignorableWhitespace in interface ContentHandler
Throws:
SAXException

skippedEntity

public void skippedEntity(String name)
                   throws SAXException
Specified by:
skippedEntity in interface ContentHandler
Throws:
SAXException

comment

public void comment(char[] ch,
                    int start,
                    int length)
             throws SAXException
Specified by:
comment in interface LexicalHandler
Throws:
SAXException

startCDATA

public void startCDATA()
                throws SAXException
Specified by:
startCDATA in interface LexicalHandler
Throws:
SAXException

endCDATA

public void endCDATA()
              throws SAXException
Specified by:
endCDATA in interface LexicalHandler
Throws:
SAXException

startDTD

public void startDTD(String name,
                     String publicId,
                     String systemId)
              throws SAXException
Specified by:
startDTD in interface LexicalHandler
Throws:
SAXException

endDTD

public void endDTD()
            throws SAXException
Specified by:
endDTD in interface LexicalHandler
Throws:
SAXException

startEntity

public void startEntity(String name)
                 throws SAXException
Specified by:
startEntity in interface LexicalHandler
Throws:
SAXException

endEntity

public void endEntity(String name)
               throws SAXException
Specified by:
endEntity in interface LexicalHandler
Throws:
SAXException

Last updated June 2008

Copyright © 2000-2008 Apple Inc.