org.apache.tapestry.parse
Class SpecificationParser

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by org.apache.hivemind.parse.AbstractParser
          extended by org.apache.tapestry.parse.SpecificationParser
All Implemented Interfaces:
ISpecificationParser, org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

public class SpecificationParser
extends org.apache.hivemind.parse.AbstractParser
implements ISpecificationParser

Parses the different types of Tapestry specifications.

Not threadsafe; it is the callers responsibility to ensure thread safety.

Author:
Howard Lewis Ship

Field Summary
static java.lang.String ASSET_NAME_PATTERN
          Perl5 pattern for asset names.
static java.lang.String BEAN_NAME_PATTERN
          Perl5 pattern for helper bean names.
static java.lang.String COMPONENT_ALIAS_PATTERN
          Perl5 pattern for component type (which was known as an "alias" in earlier versions of Tapestry).
static java.lang.String COMPONENT_ID_PATTERN
          Perl5 pattern for component ids.
static java.lang.String COMPONENT_TYPE_PATTERN
          Perl5 pattern for component types (i.e., the type attribute of the <component> element).
static java.lang.String EXTENDED_PROPERTY_NAME_PATTERN
          Extended version of Tapestry.SIMPLE_PROPERTY_NAME_PATTERN, but allows a series of individual property names, seperated by periods.
static java.lang.String EXTENSION_NAME_PATTERN
          Per5 pattern for extension names.
static java.lang.String LIBRARY_ID_PATTERN
          Perl5 pattern for library ids.
static java.lang.String PAGE_NAME_PATTERN
          Perl5 pattern for page names.
static java.lang.String PARAMETER_NAME_PATTERN
          Perl5 pattern that parameter names must conform to.
static java.lang.String PROPERTY_NAME_PATTERN
          Perl5 pattern that property names (that can be connected to parameters) must conform to.
static java.lang.String SERVICE_NAME_PATTERN
          Deprecated. As of release 4.0, the <service> element (in 3.0 DTDs) is no longer supported.
static java.lang.String TAPESTRY_DTD_3_0_PUBLIC_ID
           
static java.lang.String TAPESTRY_DTD_4_0_PUBLIC_ID
           
 
Constructor Summary
SpecificationParser(org.apache.hivemind.ClassResolver resolver)
          This constructor is a convienience used by some tests.
SpecificationParser(org.apache.hivemind.ClassResolver resolver, SpecFactory factory)
          Deprecated. to be removed in release 4.1
SpecificationParser(org.apache.hivemind.ErrorHandler errorHandler, org.apache.commons.logging.Log log, org.apache.hivemind.ClassResolver resolver, SpecFactory factory)
          The full constructor, used within Tapestry.
 
Method Summary
protected  void begin(java.lang.String elementName, java.util.Map attributes)
           
protected  void end(java.lang.String elementName)
           
protected  void initializeParser(org.apache.hivemind.Resource resource, int startState)
           
 IApplicationSpecification parseApplicationSpecification(org.apache.hivemind.Resource resource)
          Parses an application specification from the provided Resource.
 IComponentSpecification parseComponentSpecification(org.apache.hivemind.Resource resource)
           
 ILibrarySpecification parseLibrarySpecification(org.apache.hivemind.Resource resource)
           
 IComponentSpecification parsePageSpecification(org.apache.hivemind.Resource resource)
           
protected  java.lang.String peekContent()
           
protected  void resetParser()
           
 org.xml.sax.InputSource resolveEntity(java.lang.String publicId, java.lang.String systemId)
          Resolved an external entity, which is assumed to be the doctype.
 void setBindingSource(BindingSource bindingSource)
           
 void setValueConverter(ValueConverter valueConverter)
           
 
Methods inherited from class org.apache.hivemind.parse.AbstractParser
characters, endElement, error, fatalError, getElementPath, getLocation, getResource, getState, peekElementName, peekObject, pop, push, push, setDocumentLocator, setState, startElement, unexpectedElement, updateObject, warning
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, ignorableWhitespace, notationDecl, processingInstruction, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ASSET_NAME_PATTERN

public static final java.lang.String ASSET_NAME_PATTERN
Perl5 pattern for asset names. Letter, followed by letter, number or underscore. Also allows the special "$template" value.

Since:
2.2
See Also:
Constant Field Values

BEAN_NAME_PATTERN

public static final java.lang.String BEAN_NAME_PATTERN
Perl5 pattern for helper bean names. Letter, followed by letter, number or underscore.

Since:
2.2
See Also:
Constant Field Values

COMPONENT_ALIAS_PATTERN

public static final java.lang.String COMPONENT_ALIAS_PATTERN
Perl5 pattern for component type (which was known as an "alias" in earlier versions of Tapestry). This is either a simple property name, or a series of property names seperated by slashes (the latter being new in Tapestry 4.0). This defines a literal that can appear in a library or application specification.

Since:
2.2
See Also:
Constant Field Values

COMPONENT_ID_PATTERN

public static final java.lang.String COMPONENT_ID_PATTERN
Perl5 pattern for component ids. Letter, followed by letter, number or underscore.

Since:
2.2
See Also:
Constant Field Values

COMPONENT_TYPE_PATTERN

public static final java.lang.String COMPONENT_TYPE_PATTERN
Perl5 pattern for component types (i.e., the type attribute of the <component> element). Component types are an optional namespace prefix followed by a component type (within the library defined by the namespace). Starting in 4.0, the type portion is actually a series of identifiers seperated by slashes.

Since:
2.2
See Also:
Constant Field Values

EXTENDED_PROPERTY_NAME_PATTERN

public static final java.lang.String EXTENDED_PROPERTY_NAME_PATTERN
Extended version of Tapestry.SIMPLE_PROPERTY_NAME_PATTERN, but allows a series of individual property names, seperated by periods. In addition, each name within the dotted sequence is allowed to contain dashes.

Since:
2.2
See Also:
Constant Field Values

EXTENSION_NAME_PATTERN

public static final java.lang.String EXTENSION_NAME_PATTERN
Per5 pattern for extension names. Letter followed by letter, number, dash, period or underscore.

Since:
2.2
See Also:
Constant Field Values

LIBRARY_ID_PATTERN

public static final java.lang.String LIBRARY_ID_PATTERN
Perl5 pattern for library ids. Letter followed by letter, number or underscore.

Since:
2.2
See Also:
Constant Field Values

PAGE_NAME_PATTERN

public static final java.lang.String PAGE_NAME_PATTERN
Perl5 pattern for page names. Page names appear in library and application specifications, in the <page> element. Starting with 4.0, the page name may look more like a path name, consisting of a number of ids seperated by slashes. This is used to determine the folder which contains the page specification or the page's template.

Since:
2.2
See Also:
Constant Field Values

PARAMETER_NAME_PATTERN

public static final java.lang.String PARAMETER_NAME_PATTERN
Perl5 pattern that parameter names must conform to. Letter, followed by letter, number or underscore.

Since:
2.2
See Also:
Constant Field Values

PROPERTY_NAME_PATTERN

public static final java.lang.String PROPERTY_NAME_PATTERN
Perl5 pattern that property names (that can be connected to parameters) must conform to. Letter, followed by letter, number or underscore.

Since:
2.2
See Also:
Constant Field Values

SERVICE_NAME_PATTERN

public static final java.lang.String SERVICE_NAME_PATTERN
Deprecated. As of release 4.0, the <service> element (in 3.0 DTDs) is no longer supported.
Perl5 pattern for service names. Letter followed by letter, number, dash, underscore or period.

Since:
2.2
See Also:
Constant Field Values

TAPESTRY_DTD_3_0_PUBLIC_ID

public static final java.lang.String TAPESTRY_DTD_3_0_PUBLIC_ID
Since:
3.0
See Also:
Constant Field Values

TAPESTRY_DTD_4_0_PUBLIC_ID

public static final java.lang.String TAPESTRY_DTD_4_0_PUBLIC_ID
Since:
4.0
See Also:
Constant Field Values
Constructor Detail

SpecificationParser

public SpecificationParser(org.apache.hivemind.ClassResolver resolver)
This constructor is a convienience used by some tests.


SpecificationParser

public SpecificationParser(org.apache.hivemind.ClassResolver resolver,
                           SpecFactory factory)
Deprecated. to be removed in release 4.1

Create a new instance with resolver and a provided SpecFactory (used by Spindle).


SpecificationParser

public SpecificationParser(org.apache.hivemind.ErrorHandler errorHandler,
                           org.apache.commons.logging.Log log,
                           org.apache.hivemind.ClassResolver resolver,
                           SpecFactory factory)
The full constructor, used within Tapestry.

Method Detail

begin

protected void begin(java.lang.String elementName,
                     java.util.Map attributes)
Specified by:
begin in class org.apache.hivemind.parse.AbstractParser

end

protected void end(java.lang.String elementName)
Specified by:
end in class org.apache.hivemind.parse.AbstractParser

initializeParser

protected void initializeParser(org.apache.hivemind.Resource resource,
                                int startState)
Overrides:
initializeParser in class org.apache.hivemind.parse.AbstractParser

parseApplicationSpecification

public IApplicationSpecification parseApplicationSpecification(org.apache.hivemind.Resource resource)
Description copied from interface: ISpecificationParser
Parses an application specification from the provided Resource.

Specified by:
parseApplicationSpecification in interface ISpecificationParser

parseComponentSpecification

public IComponentSpecification parseComponentSpecification(org.apache.hivemind.Resource resource)
Specified by:
parseComponentSpecification in interface ISpecificationParser

parseLibrarySpecification

public ILibrarySpecification parseLibrarySpecification(org.apache.hivemind.Resource resource)
Specified by:
parseLibrarySpecification in interface ISpecificationParser

parsePageSpecification

public IComponentSpecification parsePageSpecification(org.apache.hivemind.Resource resource)
Specified by:
parsePageSpecification in interface ISpecificationParser

peekContent

protected java.lang.String peekContent()
Overrides:
peekContent in class org.apache.hivemind.parse.AbstractParser

resetParser

protected void resetParser()
Overrides:
resetParser in class org.apache.hivemind.parse.AbstractParser

resolveEntity

public org.xml.sax.InputSource resolveEntity(java.lang.String publicId,
                                             java.lang.String systemId)
                                      throws org.xml.sax.SAXException
Resolved an external entity, which is assumed to be the doctype. Might need a check to ensure that specs without a doctype fail.

Specified by:
resolveEntity in interface org.xml.sax.EntityResolver
Overrides:
resolveEntity in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException

setBindingSource

public void setBindingSource(BindingSource bindingSource)
Since:
4.0

setValueConverter

public void setValueConverter(ValueConverter valueConverter)
Since:
4.0