View Javadoc
1   package org.apache.maven.scm;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   * http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.io.Serializable;
23  
24  /**
25   * A set of information about revisions of a file as returned by CVS's log
26   * command
27   *
28   * @author <a href="mailto:dion@multitask.com.au">dIon Gillard </a>
29   * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
30   *
31   */
32  public class ChangeFile
33      implements Serializable
34  {
35      private static final long serialVersionUID = 6294855290542668753L;
36  
37      /**
38       * the name of the file relative to the project directory.
39       */
40      private String name;
41  
42      /**
43       * the latest revision of the file.
44       */
45      private String revision;
46  
47      /**
48       * edit type on the file
49       * note: perhaps we should use a different type, ideally enum? this one seems to target quite different usecases ...
50       * @since 1.7
51       */
52      private ScmFileStatus action;
53  
54      /**
55       * the name before copying or moving
56       * @since 1.7
57       */
58      private String originalName;
59  
60      /**
61       * the revision from which we {@link ScmFileStatus copied} or {@link ScmFileStatus moved} this file or directory
62       * @since 1.7
63       */
64      private String originalRevision;
65  
66      /**
67       * Constructor for the ChangeFile object without all details available
68       *
69       * @param name file name
70       */
71      public ChangeFile( String name )
72      {
73          setName( name );
74      }
75  
76      /**
77       * Constructor for the ChangeFile object
78       *
79       * @param name file name
80       * @param rev  latest revision of the file
81       */
82      public ChangeFile( String name, String rev )
83      {
84          setName( name );
85  
86          setRevision( rev );
87      }
88  
89      /**
90       * Gets the name attribute of the ChangeLogFile object.
91       *
92       * @return the file name
93       */
94      public String getName()
95      {
96          return name;
97      }
98  
99      /**
100      * Setter for property name.
101      *
102      * @param name New value of property name.
103      */
104     public void setName( String name )
105     {
106         this.name = name;
107     }
108 
109     public String getOriginalName()
110     {
111         return originalName;
112     }
113 
114     public void setOriginalName( String originalName )
115     {
116 
117         this.originalName = originalName;
118     }
119 
120     public String getOriginalRevision()
121     {
122         return originalRevision;
123     }
124 
125     public void setOriginalRevision( String originalRevision )
126     {
127         this.originalRevision = originalRevision;
128     }
129 
130     /**
131      * Gets the revision attribute of the ChangeLogFile object.
132      *
133      * @return the latest revision of the file
134      */
135     public String getRevision()
136     {
137         return revision;
138     }
139 
140     /**
141      * Setter for property revision.
142      *
143      * @param revision New value of property revision.
144      */
145     public void setRevision( String revision )
146     {
147         this.revision = revision;
148     }
149 
150     public ScmFileStatus getAction()
151     {
152         return action;
153     }
154 
155     public void setAction( ScmFileStatus action )
156     {
157         this.action = action;
158     }
159 
160     /**
161      * Provide a version of the object as a string for debugging purposes
162      *
163      * @return a {@link String}made up of the properties of the object
164      */
165     public String toString()
166     {
167         StringBuilder buffer = new StringBuilder(  );
168 
169         if ( getAction() != null )
170         {
171             buffer.append( "[" ).append( getAction() ).append( "]:" );
172         }
173 
174         buffer.append( getName() );
175         if ( getRevision() != null )
176         {
177             buffer.append( ", " ).append( getRevision() );
178         }
179 
180         if ( getOriginalName() != null )
181         {
182             buffer.append( ", originalName=" ).append( getOriginalName() );
183         }
184 
185         if ( getOriginalRevision() != null )
186         {
187             buffer.append( ", originalRevision=" ).append( getOriginalRevision() );
188         }
189 
190         return buffer.toString();
191     }
192 }