com.googlecode.lightest.core
Class CustomizedTransformer

java.lang.Object
  extended by com.googlecode.lightest.core.CustomizedTransformer
All Implemented Interfaces:
groovy.lang.GroovyObject
Direct Known Subclasses:
LightestTransformer

public abstract class CustomizedTransformer
extends Object
implements groovy.lang.GroovyObject

Applies an XSL transform, with customizations. This is a facade encapsulating the basic javax.xml.transform.Transformer functionality. The customize() method is called at most once, after which the customized stylesheet is cached inside the internal transformer variable. This implementation is NOT thread-safe.


Field Summary
static String DEFAULT_TRANSFORMER_FACTORY
           
protected  Transformer transformer
           
 
Constructor Summary
CustomizedTransformer()
           
 
Method Summary
abstract  void customize(Document doc)
          Customizes the XSL transform XML.
 groovy.lang.MetaClass getMetaClass()
           
 Object getProperty(String name)
           
abstract  InputStream getTransformAsStream()
          Returns the XSL transform source as an InputStream.
 Object invokeMethod(String name, Object args)
           
 void setMetaClass(groovy.lang.MetaClass metaClass)
           
 void setParameter(String name, Object value)
          Adds a parameter for the transformation.
 void setProperty(String name, Object value)
           
 void transform(InputStream is, OutputStream os)
          Transforms the given input stream XML with customizations, and writes the result to the given output stream.
 void transform(String s, OutputStream os)
          Transforms the given XML string with customizations, and writes the result to the given output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_TRANSFORMER_FACTORY

public static final String DEFAULT_TRANSFORMER_FACTORY

transformer

protected Transformer transformer
Constructor Detail

CustomizedTransformer

public CustomizedTransformer()
Method Detail

getTransformAsStream

public abstract InputStream getTransformAsStream()
Returns the XSL transform source as an InputStream.


setParameter

public void setParameter(String name,
                         Object value)
Adds a parameter for the transformation.

Parameters:
name -
value -

transform

public void transform(String s,
                      OutputStream os)
Transforms the given XML string with customizations, and writes the result to the given output stream. This version calls the version of transform() that taks an InputStream as its first parameter.

Parameters:
s - the XML string to transform. Assumed to be UTF-8 encoded.
os -

transform

public void transform(InputStream is,
                      OutputStream os)
Transforms the given input stream XML with customizations, and writes the result to the given output stream.

Parameters:
is -
os -

customize

public abstract void customize(Document doc)
Customizes the XSL transform XML. This will be invoked before the transform is applied to the source document.

Parameters:
doc - the document object of the XSLT document.

getMetaClass

public groovy.lang.MetaClass getMetaClass()
Specified by:
getMetaClass in interface groovy.lang.GroovyObject

setMetaClass

public void setMetaClass(groovy.lang.MetaClass metaClass)
Specified by:
setMetaClass in interface groovy.lang.GroovyObject

invokeMethod

public Object invokeMethod(String name,
                           Object args)
Specified by:
invokeMethod in interface groovy.lang.GroovyObject

getProperty

public Object getProperty(String name)
Specified by:
getProperty in interface groovy.lang.GroovyObject

setProperty

public void setProperty(String name,
                        Object value)
Specified by:
setProperty in interface groovy.lang.GroovyObject


Copyright © 2009. All Rights Reserved.