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