001/*
002 *   Copyright (C) Christian Schulte, 2005-206
003 *   All rights reserved.
004 *
005 *   Redistribution and use in source and binary forms, with or without
006 *   modification, are permitted provided that the following conditions
007 *   are met:
008 *
009 *     o Redistributions of source code must retain the above copyright
010 *       notice, this list of conditions and the following disclaimer.
011 *
012 *     o Redistributions in binary form must reproduce the above copyright
013 *       notice, this list of conditions and the following disclaimer in
014 *       the documentation and/or other materials provided with the
015 *       distribution.
016 *
017 *   THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
018 *   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
019 *   AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
020 *   THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT,
021 *   INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
022 *   NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
023 *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
024 *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
025 *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
026 *   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
027 *
028 *   $JOMC: TransformerResourceType.java 4613 2012-09-22 10:07:08Z schulte $
029 *
030 */
031package org.jomc.mojo;
032
033import java.util.ArrayList;
034import java.util.LinkedList;
035import java.util.List;
036
037/**
038 * Datatype describing a XSLT document resource.
039 *
040 * @author <a href="mailto:cs@schulte.it">Christian Schulte</a>
041 * @version $JOMC: TransformerResourceType.java 4613 2012-09-22 10:07:08Z schulte $
042 * @since 1.2
043 */
044public class TransformerResourceType extends ResourceType
045{
046
047    /** Transformation parameter resources. */
048    private List<TransformationParameterResource> transformationParameterResources;
049
050    /** Transformation parameters. */
051    private List<TransformationParameter> transformationParameters;
052
053    /** Transformation output properties. */
054    private List<TransformationOutputProperty> transformationOutputProperties;
055
056    /** Creates a new {@code TransformerResourceType} instance. */
057    public TransformerResourceType()
058    {
059        super();
060    }
061
062    /**
063     * Gets the transformation parameter resource to apply.
064     * <p>This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make
065     * to the returned list will be present inside the object. This is why there is no {@code set} method for the
066     * transformation parameter resources property.</p>
067     *
068     * @return The transformation parameter resources to apply.
069     */
070    public final List<TransformationParameterResource> getTransformationParameterResources()
071    {
072        if ( this.transformationParameterResources == null )
073        {
074            this.transformationParameterResources = new LinkedList<TransformationParameterResource>();
075        }
076
077        return this.transformationParameterResources;
078    }
079
080    /**
081     * Gets the transformation parameters to apply.
082     * <p>This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make
083     * to the returned list will be present inside the object. This is why there is no {@code set} method for the
084     * transformation parameters property.</p>
085     *
086     * @return The transformation parameters to apply.
087     */
088    public final List<TransformationParameter> getTransformationParameters()
089    {
090        if ( this.transformationParameters == null )
091        {
092            this.transformationParameters = new LinkedList<TransformationParameter>();
093        }
094
095        return this.transformationParameters;
096    }
097
098    /**
099     * Gets the transformation output properties to apply.
100     * <p>This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make
101     * to the returned list will be present inside the object. This is why there is no {@code set} method for the
102     * transformation output properties property.</p>
103     *
104     * @return The transformation output properties to apply.
105     */
106    public final List<TransformationOutputProperty> getTransformationOutputProperties()
107    {
108        if ( this.transformationOutputProperties == null )
109        {
110            this.transformationOutputProperties = new LinkedList<TransformationOutputProperty>();
111        }
112
113        return this.transformationOutputProperties;
114    }
115
116    /**
117     * Creates and returns a copy of this object.
118     *
119     * @return A copy of this object.
120     */
121    @Override
122    public TransformerResourceType clone()
123    {
124        final TransformerResourceType clone = (TransformerResourceType) super.clone();
125
126        if ( this.transformationOutputProperties != null )
127        {
128            clone.transformationOutputProperties =
129                new ArrayList<TransformationOutputProperty>( this.transformationOutputProperties.size() );
130
131            for ( TransformationOutputProperty e : this.transformationOutputProperties )
132            {
133                clone.transformationOutputProperties.add( e.clone() );
134            }
135        }
136
137        if ( this.transformationParameterResources != null )
138        {
139            clone.transformationParameterResources =
140                new ArrayList<TransformationParameterResource>( this.transformationParameterResources.size() );
141
142            for ( TransformationParameterResource e : this.transformationParameterResources )
143            {
144                clone.transformationParameterResources.add( e.clone() );
145            }
146        }
147
148        if ( this.transformationParameters != null )
149        {
150            clone.transformationParameters =
151                new ArrayList<TransformationParameter>( this.transformationParameters.size() );
152
153            for ( TransformationParameter e : this.transformationParameters )
154            {
155                clone.transformationParameters.add( e.clone() );
156            }
157        }
158
159        return clone;
160    }
161
162}