001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 */ 019package org.apache.maven.scm; 020 021import java.io.Serializable; 022 023/** 024 * A set of information about revisions of a file as returned by SCM's log 025 * command 026 * 027 * @author <a href="mailto:dion@multitask.com.au">dIon Gillard </a> 028 * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a> 029 * 030 */ 031public class ChangeFile implements Serializable { 032 private static final long serialVersionUID = 6294855290542668753L; 033 034 /** 035 * the name of the file relative to the project directory. 036 */ 037 private String name; 038 039 /** 040 * the latest revision of the file. 041 */ 042 private String revision; 043 044 /** 045 * edit type on the file 046 * note: perhaps we should use a different type, ideally enum? this one seems to target quite different usecases ... 047 * @since 1.7 048 */ 049 private ScmFileStatus action; 050 051 /** 052 * the name before copying or moving 053 * @since 1.7 054 */ 055 private String originalName; 056 057 /** 058 * the revision from which we {@link ScmFileStatus copied} or {@link ScmFileStatus moved} this file or directory 059 * @since 1.7 060 */ 061 private String originalRevision; 062 063 /** 064 * Constructor for the ChangeFile object without all details available 065 * 066 * @param name file name 067 */ 068 public ChangeFile(String name) { 069 setName(name); 070 } 071 072 /** 073 * Constructor for the ChangeFile object 074 * 075 * @param name file name 076 * @param rev latest revision of the file 077 */ 078 public ChangeFile(String name, String rev) { 079 setName(name); 080 081 setRevision(rev); 082 } 083 084 /** 085 * Gets the name attribute of the ChangeLogFile object. 086 * 087 * @return the file name 088 */ 089 public String getName() { 090 return name; 091 } 092 093 /** 094 * Setter for property name. 095 * 096 * @param name New value of property name. 097 */ 098 public void setName(String name) { 099 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}