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