View Javadoc
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.mojo;
32  
33  import java.util.ArrayList;
34  import java.util.LinkedList;
35  import java.util.List;
36  
37  /**
38   * Datatype describing a XSLT document resource.
39   *
40   * @author <a href="mailto:cs@schulte.it">Christian Schulte</a>
41   * @version $JOMC: TransformerResourceType.java 5043 2015-05-27 07:03:39Z schulte $
42   * @since 1.2
43   */
44  public class TransformerResourceType extends ResourceType
45  {
46  
47      /**
48       * Transformation parameter resources.
49       */
50      private List<TransformationParameterResource> transformationParameterResources;
51  
52      /**
53       * Transformation parameters.
54       */
55      private List<TransformationParameter> transformationParameters;
56  
57      /**
58       * Transformation output properties.
59       */
60      private List<TransformationOutputProperty> transformationOutputProperties;
61  
62      /**
63       * Creates a new {@code TransformerResourceType} instance.
64       */
65      public TransformerResourceType()
66      {
67          super();
68      }
69  
70      /**
71       * Gets the transformation parameter resource to apply.
72       * <p>
73       * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make
74       * to the returned list will be present inside the object. This is why there is no {@code set} method for the
75       * transformation parameter resources property.
76       * </p>
77       *
78       * @return The transformation parameter resources to apply.
79       */
80      public final List<TransformationParameterResource> getTransformationParameterResources()
81      {
82          if ( this.transformationParameterResources == null )
83          {
84              this.transformationParameterResources = new LinkedList<TransformationParameterResource>();
85          }
86  
87          return this.transformationParameterResources;
88      }
89  
90      /**
91       * Gets the transformation parameters to apply.
92       * <p>
93       * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make
94       * to the returned list will be present inside the object. This is why there is no {@code set} method for the
95       * transformation parameters property.
96       * </p>
97       *
98       * @return The transformation parameters to apply.
99       */
100     public final List<TransformationParameter> getTransformationParameters()
101     {
102         if ( this.transformationParameters == null )
103         {
104             this.transformationParameters = new LinkedList<TransformationParameter>();
105         }
106 
107         return this.transformationParameters;
108     }
109 
110     /**
111      * Gets the transformation output properties to apply.
112      * <p>
113      * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make
114      * to the returned list will be present inside the object. This is why there is no {@code set} method for the
115      * transformation output properties property.
116      * </p>
117      *
118      * @return The transformation output properties to apply.
119      */
120     public final List<TransformationOutputProperty> getTransformationOutputProperties()
121     {
122         if ( this.transformationOutputProperties == null )
123         {
124             this.transformationOutputProperties = new LinkedList<TransformationOutputProperty>();
125         }
126 
127         return this.transformationOutputProperties;
128     }
129 
130     /**
131      * Creates and returns a copy of this object.
132      *
133      * @return A copy of this object.
134      */
135     @Override
136     public TransformerResourceType clone()
137     {
138         final TransformerResourceType clone = (TransformerResourceType) super.clone();
139 
140         if ( this.transformationOutputProperties != null )
141         {
142             clone.transformationOutputProperties =
143                 new ArrayList<TransformationOutputProperty>( this.transformationOutputProperties.size() );
144 
145             for ( final TransformationOutputProperty e : this.transformationOutputProperties )
146             {
147                 clone.transformationOutputProperties.add( e.clone() );
148             }
149         }
150 
151         if ( this.transformationParameterResources != null )
152         {
153             clone.transformationParameterResources =
154                 new ArrayList<TransformationParameterResource>( this.transformationParameterResources.size() );
155 
156             for ( final TransformationParameterResource e : this.transformationParameterResources )
157             {
158                 clone.transformationParameterResources.add( e.clone() );
159             }
160         }
161 
162         if ( this.transformationParameters != null )
163         {
164             clone.transformationParameters =
165                 new ArrayList<TransformationParameter>( this.transformationParameters.size() );
166 
167             for ( final TransformationParameter e : this.transformationParameters )
168             {
169                 clone.transformationParameters.add( e.clone() );
170             }
171         }
172 
173         return clone;
174     }
175 
176 }