com.agilejava.docbkx.maven.CachingTransformerBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of docbkx-maven-base Show documentation
Show all versions of docbkx-maven-base Show documentation
A number of base classes, providing the basic behaviour
of objects / plugins transforming DocBook XML sources into some
other format.
package com.agilejava.docbkx.maven;
import javax.xml.transform.Transformer;
/**
* A caching {@link TransformerBuilder}, holding on to the Transformer it created. Note that
* this class is thread-safe.
*
* @author Wilfred Springer
*/
public class CachingTransformerBuilder implements TransformerBuilder {
private Transformer transformer;
private TransformerBuilder builder;
/**
* Constructs a new instance.
*
* @param builder
* The {@link TransformerBuilder} creating the actual instance of
* the Transformer.
*/
public CachingTransformerBuilder(TransformerBuilder builder) {
if (builder == null)
throw new IllegalArgumentException("TransformerBuilder should not be null.");
this.builder = builder;
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*
* @throws TransformerBuilderException DOCUMENT ME!
*/
public synchronized Transformer build() throws TransformerBuilderException {
if (transformer == null) {
transformer = builder.build();
}
return transformer;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy