org.apache.cocoon.transformation
Class SimpleFormTransformer

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.cocoon.xml.AbstractXMLProducer
          extended by org.apache.cocoon.xml.AbstractXMLPipe
              extended by org.apache.cocoon.transformation.AbstractTransformer
                  extended by org.apache.cocoon.transformation.AbstractSAXTransformer
                      extended by org.apache.cocoon.transformation.SimpleFormTransformer
All Implemented Interfaces:
Poolable, Recyclable, Disposable, Component, Configurable, LogEnabled, Serviceable, SitemapModelComponent, Transformer, XMLPipe, XMLProducer, XMLConsumer, ContentHandler, LexicalHandler

public class SimpleFormTransformer
extends AbstractSAXTransformer

Version:
$Id: SimpleFormTransformer.html 1304258 2012-03-23 10:09:27Z ilgrosso $
Author:
Christian Haul

Nested Class Summary
protected static class SimpleFormTransformer.RepeaterStatus
          Keep track of repeater status.
protected static class SimpleFormTransformer.ValueList
          Keep track of multiple values.
 
Field Summary
protected  Map formValues
          Map of SimpleFormTransformer.ValueList to track multiple parameters.
protected static String INPUT_MODULE_ROLE
           
protected static String INPUT_MODULE_SELECTOR
           
protected  int recordingCount
          Count nested repeat elements.
protected  List repeater
          List of SimpleFormTransformer.RepeaterStatus elements keeping track of nested repeat blocks.
protected  boolean skipChildrenOnly
          Skip element's content only.
protected  Map validationResults
          current request's validation results (all validated elements)
protected  Object[] values
          current element's request parameter values
 
Fields inherited from class org.apache.cocoon.transformation.AbstractSAXTransformer
context, defaultNamespaceURI, EMPTY_ATTRIBUTES, emptyAttributes, ignoreEmptyCharacters, ignoreEventsCount, ignoreHooksCount, ignoreWhitespaces, manager, namespaceURI, objectModel, parameters, recorderStack, request, resolver, response, source, stack
 
Fields inherited from class org.apache.cocoon.xml.AbstractXMLProducer
contentHandler, EMPTY_CONTENT_HANDLER, lexicalHandler, xmlConsumer
 
Fields inherited from interface org.apache.cocoon.transformation.Transformer
ROLE
 
Constructor Summary
SimpleFormTransformer()
           
 
Method Summary
 void configure(Configuration config)
          Avalon Configurable Interface
protected  void endRepeatElement(String uri, String name, String raw)
          Stop recording repeat contents and replay required number of times.
 void endTransformingElement(String uri, String name, String raw)
          Start processing elements of our namespace.
protected  String printAttributes(Attributes attr)
          Generate string representation of attributes.
 void recycle()
          Recycle this component.
protected  void relayEndElement(String uri, String name, String raw)
          Calls the super's method endTransformingElement and decrements the ignoreEventsCount if larger than zero.
protected  void relayStartElement(boolean skip, boolean skipChildrenOnly, String uri, String name, String raw, Attributes attr)
          Calls the super's method startTransformingElement and increments the ignoreEventsCount if skip is true.
protected  void relayStartElement(String uri, String name, String raw, Attributes attr)
          Calls the super's method startTransformingElement.
 void setup(SourceResolver resolver, Map objectModel, String src, Parameters par)
          Setup the next round.
protected  void startCheckableElement(String aName, String uri, String name, String raw, AttributesImpl attributes)
          Handle input elements that may have a "checked" attributes, i.e. checkbox and radio.
protected  void startErrorElement(String uri, String name, String raw, Attributes attr)
          Handle error elements.
protected  void startFormElement(String uri, String name, String raw, Attributes attr)
          Start processing a form element.
protected  void startInputElement(String uri, String name, String raw, Attributes attr)
          Handle input elements.
protected  void startNonCheckableElement(String aName, String uri, String name, String raw, AttributesImpl attributes)
          Handle input elements that may don't have a "checked" attributes, e.g. text, password, button.
protected  void startOptionElement(String uri, String name, String raw, Attributes attr)
          Handle option elements.
protected  void startRepeatElement(String uri, String name, String raw, Attributes attr)
          Start recording repeat element contents and push repeat expression and variable to repeater stack.
protected  void startSelectElement(String uri, String name, String raw, Attributes attr)
          Handle select elements.
protected  void startTextareaElement(String uri, String name, String raw, Attributes attributes)
          Handles textarea elements.
 void startTransformingElement(String uri, String name, String raw, Attributes attr)
          Start processing elements of our namespace.
 
Methods inherited from class org.apache.cocoon.transformation.AbstractSAXTransformer
addRecorder, characters, comment, dispose, endCDATA, endDocument, endDTD, endElement, endEntity, endParametersRecording, endParametersRecording, endPrefixMapping, endRecording, endSAXRecording, endSerializedXMLRecording, endTextRecording, findPrefixMapping, getMutableAttributes, ignorableWhitespace, processingInstruction, removeRecorder, sendEndElementEvent, sendEndElementEventNS, sendEndPrefixMapping, sendEvents, sendParametersEvents, sendStartElementEvent, sendStartElementEvent, sendStartElementEventNS, sendStartElementEventNS, sendStartPrefixMapping, sendTextEvent, service, setDocumentLocator, setupTransforming, skippedEntity, startCDATA, startDocument, startDTD, startElement, startEntity, startParametersRecording, startPrefixMapping, startRecording, startSAXRecording, startSerializedXMLRecording, startTextRecording
 
Methods inherited from class org.apache.cocoon.xml.AbstractXMLProducer
setConsumer, setContentHandler, setLexicalHandler
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.cocoon.xml.XMLProducer
setConsumer
 

Field Detail

INPUT_MODULE_ROLE

protected static final String INPUT_MODULE_ROLE

INPUT_MODULE_SELECTOR

protected static final String INPUT_MODULE_SELECTOR

values

protected Object[] values
current element's request parameter values


validationResults

protected Map validationResults
current request's validation results (all validated elements)


skipChildrenOnly

protected boolean skipChildrenOnly
Skip element's content only. Otherwise skip also surrounding element.


recordingCount

protected int recordingCount
Count nested repeat elements.


repeater

protected List repeater
List of SimpleFormTransformer.RepeaterStatus elements keeping track of nested repeat blocks.


formValues

protected Map formValues
Map of SimpleFormTransformer.ValueList to track multiple parameters.

Constructor Detail

SimpleFormTransformer

public SimpleFormTransformer()
Method Detail

configure

public void configure(Configuration config)
               throws ConfigurationException
Avalon Configurable Interface

Specified by:
configure in interface Configurable
Overrides:
configure in class AbstractSAXTransformer
Throws:
ConfigurationException

setup

public void setup(SourceResolver resolver,
                  Map objectModel,
                  String src,
                  Parameters par)
           throws ProcessingException,
                  SAXException,
                  IOException
Setup the next round. The instance variables are initialised.

Specified by:
setup in interface SitemapModelComponent
Overrides:
setup in class AbstractSAXTransformer
Parameters:
resolver - The current SourceResolver
objectModel - The objectModel of the environment.
src - The value of the src attribute in the sitemap.
par - The parameters from the sitemap.
Throws:
ProcessingException
SAXException
IOException

recycle

public void recycle()
Recycle this component.

Specified by:
recycle in interface Recyclable
Overrides:
recycle in class AbstractSAXTransformer

printAttributes

protected String printAttributes(Attributes attr)
Generate string representation of attributes. For debug only.


startCheckableElement

protected void startCheckableElement(String aName,
                                     String uri,
                                     String name,
                                     String raw,
                                     AttributesImpl attributes)
                              throws SAXException
Handle input elements that may have a "checked" attributes, i.e. checkbox and radio.

Throws:
SAXException

startNonCheckableElement

protected void startNonCheckableElement(String aName,
                                        String uri,
                                        String name,
                                        String raw,
                                        AttributesImpl attributes)
                                 throws SAXException
Handle input elements that may don't have a "checked" attributes, e.g. text, password, button.

Throws:
SAXException

startInputElement

protected void startInputElement(String uri,
                                 String name,
                                 String raw,
                                 Attributes attr)
                          throws SAXException
Handle input elements. Calls startCheckableElement or startNonCheckableElement.

Throws:
SAXException

startSelectElement

protected void startSelectElement(String uri,
                                  String name,
                                  String raw,
                                  Attributes attr)
                           throws SAXException
Handle select elements. Sets up some instance variables for following option elements.

Throws:
SAXException

startOptionElement

protected void startOptionElement(String uri,
                                  String name,
                                  String raw,
                                  Attributes attr)
                           throws SAXException
Handle option elements. Uses instance variables set up by startSelectElement. Relies on option having a "value" attribute, i.e. does not check following characters if "value" is not present.

Throws:
SAXException

startTextareaElement

protected void startTextareaElement(String uri,
                                    String name,
                                    String raw,
                                    Attributes attributes)
                             throws SAXException
Handles textarea elements. Skips nested events if request parameter with same name exists.

Throws:
SAXException

startErrorElement

protected void startErrorElement(String uri,
                                 String name,
                                 String raw,
                                 Attributes attr)
                          throws SAXException
Handle error elements. If validation results are available, compares validation result for parameter with the same name as the "name" attribute with the result names is "when" and "when-ge". Drops element and all nested events when error condition is not met.

Throws:
SAXException

startFormElement

protected void startFormElement(String uri,
                                String name,
                                String raw,
                                Attributes attr)
                         throws SAXException
Start processing a form element. Sets protection indicator if attribute "fixed" is present and either "true" or "yes". Removes attribute "fixed" if present.

Parameters:
uri - The namespace of the element.
name - The local name of the element.
raw - The qualified name of the element.
attr - The attributes of the element.
Throws:
SAXException

startRepeatElement

protected void startRepeatElement(String uri,
                                  String name,
                                  String raw,
                                  Attributes attr)
                           throws SAXException
Start recording repeat element contents and push repeat expression and variable to repeater stack. Only start recording, if no other recorder is currently running.

Parameters:
uri -
name -
raw -
attr -
Throws:
SAXException

endRepeatElement

protected void endRepeatElement(String uri,
                                String name,
                                String raw)
                         throws SAXException
Stop recording repeat contents and replay required number of times. Stop only if outmost repeat element is ending.

Parameters:
uri -
name -
raw -
Throws:
SAXException

startTransformingElement

public void startTransformingElement(String uri,
                                     String name,
                                     String raw,
                                     Attributes attr)
                              throws SAXException
Start processing elements of our namespace. This hook is invoked for each sax event with our namespace.

Overrides:
startTransformingElement in class AbstractSAXTransformer
Parameters:
uri - The namespace of the element.
name - The local name of the element.
raw - The qualified name of the element.
attr - The attributes of the element.
Throws:
SAXException

endTransformingElement

public void endTransformingElement(String uri,
                                   String name,
                                   String raw)
                            throws SAXException
Start processing elements of our namespace. This hook is invoked for each sax event with our namespace.

Overrides:
endTransformingElement in class AbstractSAXTransformer
Parameters:
uri - The namespace of the element.
name - The local name of the element.
raw - The qualified name of the element.
Throws:
SAXException

relayStartElement

protected void relayStartElement(String uri,
                                 String name,
                                 String raw,
                                 Attributes attr)
                          throws SAXException
Calls the super's method startTransformingElement.

Parameters:
uri -
name -
raw -
attr -
Throws:
SAXException

relayStartElement

protected void relayStartElement(boolean skip,
                                 boolean skipChildrenOnly,
                                 String uri,
                                 String name,
                                 String raw,
                                 Attributes attr)
                          throws SAXException
Calls the super's method startTransformingElement and increments the ignoreEventsCount if skip is true. Increment can be done either before invoking super's method, so that the element itself is skipped, or afterwards, so that only the children are skipped.

Parameters:
skip -
skipChildrenOnly -
uri -
name -
raw -
attr -
Throws:
SAXException

relayEndElement

protected void relayEndElement(String uri,
                               String name,
                               String raw)
                        throws SAXException
Calls the super's method endTransformingElement and decrements the ignoreEventsCount if larger than zero.

Parameters:
uri -
name -
raw -
Throws:
SAXException


Copyright © 1999-2010 The Apache Software Foundation. All Rights Reserved.