View Javadoc

1   package org.apache.maven.release;
2   
3   /* ====================================================================
4    *   Copyright 2001-2004 The Apache Software Foundation.
5    *
6    *   Licensed under the Apache License, Version 2.0 (the "License");
7    *   you may not use this file except in compliance with the License.
8    *   You may obtain a copy of the License at
9    *
10   *       http://www.apache.org/licenses/LICENSE-2.0
11   *
12   *   Unless required by applicable law or agreed to in writing, software
13   *   distributed under the License is distributed on an "AS IS" BASIS,
14   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   *   See the License for the specific language governing permissions and
16   *   limitations under the License.
17   * ====================================================================
18   */
19  
20  import org.dom4j.Node;
21  
22  /**
23   *
24   *
25   * @author <a href="mailto:jason@zenplex.com">Jason van Zyl</a>
26   *
27   * @version $Id: Transformation.java 170200 2005-05-15 06:24:19Z brett $
28   */
29  public class Transformation
30  {
31      /** Pom Transformer associated with this transformation. */
32      private PomTransformer pomTransformer;
33  
34      /** Node to transform. */
35      private Node node;
36  
37      public Transformation( PomTransformer pomTransformer )
38      {
39          this.pomTransformer = pomTransformer;
40      }
41  
42      // ----------------------------------------------------------------------
43      // Accessors
44      // ----------------------------------------------------------------------
45  
46      /**
47       *
48       * @return
49       */
50      public Node getNode()
51      {
52          return node;
53      }
54  
55      /**
56       *
57       * @param node
58       */
59      public void setNode( Node node )
60      {
61          this.node = node;
62      }
63  
64      /**
65       *
66       * @throws Exception
67       */
68      public void transform()
69          throws Exception
70      {
71          pomTransformer.transformNode( node );
72      }
73  
74      /**
75       *
76       * @return
77       * @throws Exception
78       */
79      public String getBeforeTransformation()
80          throws Exception
81      {
82          return getNode().asXML();
83      }
84  
85      /**
86       *
87       * @return
88       * @throws Exception
89       */
90      public String getAfterTransformation()
91          throws Exception
92      {
93          return pomTransformer.getTransformedNode( getNode() ).asXML();
94      }
95  }