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 public class ChangeFile implements Serializable { 31 private static final long serialVersionUID = 6294855290542668753L; 32 33 /** 34 * The name of the file relative to the project directory. 35 */ 36 private String name; 37 38 /** 39 * The latest revision of the file. 40 */ 41 private String revision; 42 43 /** 44 * Edit type on the file 45 * note: perhaps we should use a different type, ideally enum? this one seems to target quite different usecases ... 46 * 47 * @since 1.7 48 */ 49 private ScmFileStatus action; 50 51 /** 52 * The name before copying or moving. 53 * 54 * @since 1.7 55 */ 56 private String originalName; 57 58 /** 59 * The revision from which we {@link ScmFileStatus copied} or {@link ScmFileStatus moved} this file or directory. 60 * 61 * @since 1.7 62 */ 63 private String originalRevision; 64 65 /** 66 * Constructor for the ChangeFile object without all details available. 67 * 68 * @param name file name 69 */ 70 public ChangeFile(String name) { 71 setName(name); 72 } 73 74 /** 75 * Constructor for the ChangeFile object. 76 * 77 * @param name file name 78 * @param rev latest revision of the file 79 */ 80 public ChangeFile(String name, String rev) { 81 setName(name); 82 83 setRevision(rev); 84 } 85 86 /** 87 * Gets the name attribute of the ChangeLogFile object. 88 * 89 * @return the file name 90 */ 91 public String getName() { 92 return name; 93 } 94 95 /** 96 * Setter for property name. 97 * 98 * @param name new value of property name 99 */ 100 public void setName(String name) { 101 this.name = name; 102 } 103 104 public String getOriginalName() { 105 return originalName; 106 } 107 108 public void setOriginalName(String originalName) { 109 110 this.originalName = originalName; 111 } 112 113 public String getOriginalRevision() { 114 return originalRevision; 115 } 116 117 public void setOriginalRevision(String originalRevision) { 118 this.originalRevision = originalRevision; 119 } 120 121 /** 122 * Gets the revision attribute of the ChangeLogFile object. 123 * 124 * @return the latest revision of the file 125 */ 126 public String getRevision() { 127 return revision; 128 } 129 130 /** 131 * Setter for property revision. 132 * 133 * @param revision new value of property revision 134 */ 135 public void setRevision(String revision) { 136 this.revision = revision; 137 } 138 139 public ScmFileStatus getAction() { 140 return action; 141 } 142 143 public void setAction(ScmFileStatus action) { 144 this.action = action; 145 } 146 147 /** 148 * Provide a version of the object as a string for debugging purposes. 149 * 150 * @return a {@link String}made up of the properties of the object 151 */ 152 public String toString() { 153 StringBuilder buffer = new StringBuilder(); 154 155 if (getAction() != null) { 156 buffer.append("[").append(getAction()).append("]:"); 157 } 158 159 buffer.append(getName()); 160 if (getRevision() != null) { 161 buffer.append(", ").append(getRevision()); 162 } 163 164 if (getOriginalName() != null) { 165 buffer.append(", originalName=").append(getOriginalName()); 166 } 167 168 if (getOriginalRevision() != null) { 169 buffer.append(", originalRevision=").append(getOriginalRevision()); 170 } 171 172 return buffer.toString(); 173 } 174 }