org.apache.commons.latka.xml
Class XMLPreprocessor

java.lang.Object
  |
  +--org.apache.commons.latka.xml.XMLPreprocessor

public class XMLPreprocessor
extends java.lang.Object

Methods for massaging the Latka XML. Includes methods for finding and substituting variables in the XML stream with Latka variables.

Author:
Morgan Delagrange
See Also:
LatkaProperties

Constructor Summary
XMLPreprocessor()
           
 
Method Summary
 java.util.Set findVariables(java.io.Reader reader)
          Given an XML suite contained in the reader, find the names of all variables that must be set in the LatkaProperties.
 java.util.Set findVariables(java.net.URL url)
          Given an XML suite contained in the file uri, find the names of all variables that must be set in the LatkaProperties.
 java.util.Set getLocalVariables(java.io.Reader reader)
          Read the text in the Reader and find the names of all variables that must be set in the LatkaProperties.
 java.io.Reader preprocessXml(java.io.Reader reader)
          Processes a Stream, preparing it for the final XML processing.
 java.io.Reader preprocessXml(java.net.URL url)
          Reads a file URI instead of a Reader, but otherwise similar to preprocessReader(Reader).
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLPreprocessor

public XMLPreprocessor()
Method Detail

findVariables

public java.util.Set findVariables(java.io.Reader reader)
                            throws java.io.IOException
Given an XML suite contained in the reader, find the names of all variables that must be set in the LatkaProperties. Will use SAX to recurse through external entities.
Parameters:
reader - Reader representing a Latka suite
Returns:
Array of variables that must be set. If no variables are present in the suite, a zero-length array is returned.
See Also:
LatkaProperties

findVariables

public java.util.Set findVariables(java.net.URL url)
                            throws java.io.IOException
Given an XML suite contained in the file uri, find the names of all variables that must be set in the LatkaProperties. Will use SAX to recurse through external entities.
Parameters:
reader - Reader representing a Latka suite
Returns:
Array of variables that must be set. If no variables are present in the suite, a zero-length array is returned.
See Also:
LatkaProperties

getLocalVariables

public java.util.Set getLocalVariables(java.io.Reader reader)
                                throws java.io.IOException
Read the text in the Reader and find the names of all variables that must be set in the LatkaProperties. This method does not recurse through entities like findVariables.
Parameters:
Reader - XML Reader containing a Latka suite fragment
Returns:
Array of variables that must be set. If no variables are present in the suite, a zero-length array is returned.
See Also:
LatkaProperties

preprocessXml

public java.io.Reader preprocessXml(java.io.Reader reader)
                             throws java.io.IOException
Processes a Stream, preparing it for the final XML processing. In essence, this consists of finding variables in the XML, looking for corresponding Latka properties, and performing the substitutions.
Parameters:
reader - XML stream to preprocess
Returns:
Stream containing the processed XML
Throws:
java.io.IOException - thrown if the stream could not be read, or if variables could not be substituted
See Also:
SuiteHandler.resolveEntity(String,String), Latka.runTests(Suite,LatkaEventInfo)

preprocessXml

public java.io.Reader preprocessXml(java.net.URL url)
                             throws java.io.IOException
Reads a file URI instead of a Reader, but otherwise similar to preprocessReader(Reader).
Parameters:
uri - File URI that will be processed
Returns:
Reader containing processed data
Throws:
java.io.IOException - If the URI could not be found, or if variables could not be substituted.
See Also:
#preprocessReader(Reader)


Copyright © 2001 Apache Software Foundation. Documenation generated September 13 2001.