All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.agilejava.docbkx.maven.CachingTransformerBuilder Maven / Gradle / Ivy

Go to download

A number of base classes, providing the basic behaviour of objects / plugins transforming DocBook XML sources into some other format.

There is a newer version: 2.0.17
Show newest version
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