com.oroad.stxx.xform
Class XMLFormFilter

java.lang.Object
  extended bycom.oroad.stxx.util.AbstractSAXFilter
      extended bycom.oroad.stxx.util.AbstractSAXTransformer
          extended bycom.oroad.stxx.xform.XMLFormFilter
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.ext.LexicalHandler, javax.xml.transform.sax.TransformerHandler, XMLConsumer

public class XMLFormFilter
extends AbstractSAXTransformer
implements javax.xml.transform.sax.TransformerHandler

This filter performs additional transformations to xmlforms like internationalization and optionally the encoding of viewstate

Author:
Don Brown

Field Summary
 
Fields inherited from class com.oroad.stxx.util.AbstractSAXTransformer
systemID, transformer
 
Fields inherited from class com.oroad.stxx.util.AbstractSAXFilter
contentHandler, lexicalHandler
 
Constructor Summary
XMLFormFilter(java.util.Locale locale, org.apache.struts.util.MessageResources mes, XMLForm form)
          Constructor
 
Method Summary
 void characters(char[] c, int start, int len)
          Receive notification of character data.
 void endElement(java.lang.String uri, java.lang.String loc, java.lang.String raw)
          Looks up the messages from the message keys in label and caption elements
protected  org.xml.sax.Attributes getAttributes(java.lang.String name, java.lang.String value)
          Gets an Attributes object that has the given attribute
protected  void insertViewState(java.lang.String rawForm)
          Inserts viewstate elements into the stream
 void startElement(java.lang.String uri, java.lang.String loc, java.lang.String raw, org.xml.sax.Attributes a)
          Inserts the viewstate, if applicable
 
Methods inherited from class com.oroad.stxx.util.AbstractSAXTransformer
getSystemId, getTransformer, notationDecl, setResult, setSystemId, unparsedEntityDecl
 
Methods inherited from class com.oroad.stxx.util.AbstractSAXFilter
comment, endCDATA, endDocument, endDTD, endEntity, endPrefixMapping, ignorableWhitespace, processingInstruction, setContentHandler, setDocumentLocator, setLexicalHandler, skippedEntity, startCDATA, startDocument, startDTD, startEntity, startPrefixMapping
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.xml.transform.sax.TransformerHandler
getSystemId, getTransformer, setResult, setSystemId
 
Methods inherited from interface org.xml.sax.ContentHandler
endDocument, endPrefixMapping, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping
 
Methods inherited from interface org.xml.sax.ext.LexicalHandler
comment, endCDATA, endDTD, endEntity, startCDATA, startDTD, startEntity
 
Methods inherited from interface org.xml.sax.DTDHandler
notationDecl, unparsedEntityDecl
 

Constructor Detail

XMLFormFilter

public XMLFormFilter(java.util.Locale locale,
                     org.apache.struts.util.MessageResources mes,
                     XMLForm form)
Constructor

Parameters:
locale - The current locale
mes - The message resources
form - The XMLForm
Method Detail

startElement

public void startElement(java.lang.String uri,
                         java.lang.String loc,
                         java.lang.String raw,
                         org.xml.sax.Attributes a)
                  throws org.xml.sax.SAXException
Inserts the viewstate, if applicable

Specified by:
startElement in interface org.xml.sax.ContentHandler
Overrides:
startElement in class AbstractSAXFilter
Parameters:
uri - The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed.
loc - The local name (without prefix), or the empty string if Namespace processing is not being performed.
raw - The raw XML 1.0 name (with prefix), or the empty string if raw names are not available.
a - The attributes attached to the element. If there are no attributes, it shall be an empty Attributes object.
Throws:
org.xml.sax.SAXException - If something goes wrong

characters

public void characters(char[] c,
                       int start,
                       int len)
                throws org.xml.sax.SAXException
Receive notification of character data.

Specified by:
characters in interface org.xml.sax.ContentHandler
Overrides:
characters in class AbstractSAXFilter
Parameters:
c - The characters from the XML document.
start - The start position in the array.
len - The number of characters to read from the array.
Throws:
org.xml.sax.SAXException - If something goes wrong

endElement

public void endElement(java.lang.String uri,
                       java.lang.String loc,
                       java.lang.String raw)
                throws org.xml.sax.SAXException
Looks up the messages from the message keys in label and caption elements

Specified by:
endElement in interface org.xml.sax.ContentHandler
Overrides:
endElement in class AbstractSAXFilter
Parameters:
uri - The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed.
loc - The local name (without prefix), or the empty string if Namespace processing is not being performed.
raw - The raw XML 1.0 name (with prefix), or the empty string if raw names are not available.
Throws:
org.xml.sax.SAXException - If something goes wrong

insertViewState

protected void insertViewState(java.lang.String rawForm)
                        throws org.xml.sax.SAXException
Inserts viewstate elements into the stream

Parameters:
rawForm - The raw name of the xforms form element used to extract the namespace prefix
Throws:
org.xml.sax.SAXException - If something goes wrong

getAttributes

protected org.xml.sax.Attributes getAttributes(java.lang.String name,
                                               java.lang.String value)
                                        throws org.xml.sax.SAXException
Gets an Attributes object that has the given attribute

Parameters:
name - The attribute name
value - The attribute value
Returns:
The attributes object
Throws:
org.xml.sax.SAXException - If something goes wrong