TransformerResourceType.java

  1. /*
  2.  *   Copyright (C) Christian Schulte <cs@schulte.it>, 2005-206
  3.  *   All rights reserved.
  4.  *
  5.  *   Redistribution and use in source and binary forms, with or without
  6.  *   modification, are permitted provided that the following conditions
  7.  *   are met:
  8.  *
  9.  *     o Redistributions of source code must retain the above copyright
  10.  *       notice, this list of conditions and the following disclaimer.
  11.  *
  12.  *     o Redistributions in binary form must reproduce the above copyright
  13.  *       notice, this list of conditions and the following disclaimer in
  14.  *       the documentation and/or other materials provided with the
  15.  *       distribution.
  16.  *
  17.  *   THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
  18.  *   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
  19.  *   AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
  20.  *   THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT,
  21.  *   INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  22.  *   NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  23.  *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  24.  *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  25.  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  26.  *   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27.  *
  28.  *   $JOMC: TransformerResourceType.java 5043 2015-05-27 07:03:39Z schulte $
  29.  *
  30.  */
  31. package org.jomc.ant.types;

  32. import java.util.ArrayList;
  33. import java.util.LinkedList;
  34. import java.util.List;
  35. import org.apache.commons.lang.builder.ToStringBuilder;

  36. /**
  37.  * Datatype describing a XSLT document resource.
  38.  *
  39.  * @author <a href="mailto:cs@schulte.it">Christian Schulte</a>
  40.  * @version $JOMC: TransformerResourceType.java 5043 2015-05-27 07:03:39Z schulte $
  41.  */
  42. public class TransformerResourceType extends ResourceType
  43. {

  44.     /**
  45.      * The transformation parameter resources to apply.
  46.      */
  47.     private List<PropertiesResourceType> transformationParameterResources;

  48.     /**
  49.      * The transformation parameters to apply.
  50.      */
  51.     private List<KeyValueType> transformationParameters;

  52.     /**
  53.      * The transformation output properties to apply.
  54.      */
  55.     private List<KeyValueType> transformationOutputProperties;

  56.     /**
  57.      * Creates a new {@code TransformerResourceType}.
  58.      */
  59.     public TransformerResourceType()
  60.     {
  61.         super();
  62.     }

  63.     /**
  64.      * Gets the transformation parameters to apply.
  65.      * <p>
  66.      * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make
  67.      * to the returned list will be present inside the object. This is why there is no {@code set} method for the
  68.      * transformation parameters property.
  69.      * </p>
  70.      *
  71.      * @return The transformation parameters to apply.
  72.      *
  73.      * @see #createTransformationParameter()
  74.      */
  75.     public final List<KeyValueType> getTransformationParameters()
  76.     {
  77.         if ( this.transformationParameters == null )
  78.         {
  79.             this.transformationParameters = new LinkedList<KeyValueType>();
  80.         }

  81.         return this.transformationParameters;
  82.     }

  83.     /**
  84.      * Creates a new {@code transformationParameter} element instance.
  85.      *
  86.      * @return A new {@code transformationParameter} element instance.
  87.      *
  88.      * @see #getTransformationParameters()
  89.      */
  90.     public KeyValueType createTransformationParameter()
  91.     {
  92.         final KeyValueType transformationParameter = new KeyValueType();
  93.         this.getTransformationParameters().add( transformationParameter );
  94.         return transformationParameter;
  95.     }

  96.     /**
  97.      * Gets the transformation parameter resources to apply.
  98.      * <p>
  99.      * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make
  100.      * to the returned list will be present inside the object. This is why there is no {@code set} method for the
  101.      * transformation parameter resources property.
  102.      * </p>
  103.      *
  104.      * @return The transformation parameter resources to apply.
  105.      *
  106.      * @see #createTransformationParameterResource()
  107.      */
  108.     public final List<PropertiesResourceType> getTransformationParameterResources()
  109.     {
  110.         if ( this.transformationParameterResources == null )
  111.         {
  112.             this.transformationParameterResources = new LinkedList<PropertiesResourceType>();
  113.         }

  114.         return this.transformationParameterResources;
  115.     }

  116.     /**
  117.      * Creates a new {@code transformationParameterResource} element instance.
  118.      *
  119.      * @return A new {@code transformationParameterResource} element instance.
  120.      *
  121.      * @see #getTransformationParameterResources()
  122.      */
  123.     public PropertiesResourceType createTransformationParameterResource()
  124.     {
  125.         final PropertiesResourceType transformationParameterResource = new PropertiesResourceType();
  126.         this.getTransformationParameterResources().add( transformationParameterResource );
  127.         return transformationParameterResource;
  128.     }

  129.     /**
  130.      * Gets the transformation output properties to apply.
  131.      * <p>
  132.      * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make
  133.      * to the returned list will be present inside the object. This is why there is no {@code set} method for the
  134.      * transformation output properties property.
  135.      * </p>
  136.      *
  137.      * @return The transformation output properties to apply.
  138.      *
  139.      * @see #createTransformationOutputProperty()
  140.      */
  141.     public final List<KeyValueType> getTransformationOutputProperties()
  142.     {
  143.         if ( this.transformationOutputProperties == null )
  144.         {
  145.             this.transformationOutputProperties = new LinkedList<KeyValueType>();
  146.         }

  147.         return this.transformationOutputProperties;
  148.     }

  149.     /**
  150.      * Creates a new {@code transformationOutputProperty} element instance.
  151.      *
  152.      * @return A new {@code transformationOutputProperty} element instance.
  153.      *
  154.      * @see #getTransformationOutputProperties()
  155.      */
  156.     public KeyValueType createTransformationOutputProperty()
  157.     {
  158.         final KeyValueType transformationOutputProperty = new KeyValueType();
  159.         this.getTransformationOutputProperties().add( transformationOutputProperty );
  160.         return transformationOutputProperty;
  161.     }

  162.     /**
  163.      * Creates and returns a copy of this object.
  164.      *
  165.      * @return A copy of this object.
  166.      */
  167.     @Override
  168.     public TransformerResourceType clone()
  169.     {
  170.         final TransformerResourceType clone = (TransformerResourceType) super.clone();

  171.         if ( this.transformationParameters != null )
  172.         {
  173.             clone.transformationParameters =
  174.                 new ArrayList<KeyValueType>( this.transformationParameters.size() );

  175.             for ( final KeyValueType e : this.transformationParameters )
  176.             {
  177.                 clone.transformationParameters.add( e.clone() );
  178.             }
  179.         }

  180.         if ( this.transformationParameterResources != null )
  181.         {
  182.             clone.transformationParameterResources =
  183.                 new ArrayList<PropertiesResourceType>( this.transformationParameterResources.size() );

  184.             for ( final PropertiesResourceType e : this.transformationParameterResources )
  185.             {
  186.                 clone.transformationParameterResources.add( e.clone() );
  187.             }
  188.         }

  189.         if ( this.transformationOutputProperties != null )
  190.         {
  191.             clone.transformationOutputProperties =
  192.                 new ArrayList<KeyValueType>( this.transformationOutputProperties.size() );

  193.             for ( final KeyValueType e : this.transformationOutputProperties )
  194.             {
  195.                 clone.transformationOutputProperties.add( e.clone() );
  196.             }
  197.         }

  198.         return clone;
  199.     }

  200.     /**
  201.      * Creates and returns a string representation of the object.
  202.      *
  203.      * @return A string representation of the object.
  204.      */
  205.     @Override
  206.     public String toString()
  207.     {
  208.         return ToStringBuilder.reflectionToString( this );
  209.     }

  210. }