KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tools > ant > taskdefs > cvslib > CvsTagEntry


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */

18 package org.apache.tools.ant.taskdefs.cvslib;
19
20 /**
21  * Holds the information of a line of rdiff
22  */

23 public class CvsTagEntry {
24
25     /** the filename */
26     private String JavaDoc filename;
27
28     /** the previous revision */
29     private String JavaDoc prevRevision;
30
31     /** the revision */
32     private String JavaDoc revision;
33
34     /**
35      * Creates a new CvsTagEntry
36      * @param filename the filename to add
37      */

38     public CvsTagEntry(final String JavaDoc filename) {
39         this(filename, null, null);
40     }
41
42     /**
43      * Creates a new CvsTagEntry
44      * @param filename the filename to add
45      * @param revision the revision
46      */

47     public CvsTagEntry(final String JavaDoc filename, final String JavaDoc revision) {
48         this(filename, revision, null);
49     }
50
51     /**
52      * Creates a new CvsTagEntry
53      * @param filename the filename to add
54      * @param revision the revision
55      * @param prevRevision the previous revision
56      */

57     public CvsTagEntry(final String JavaDoc filename, final String JavaDoc revision,
58                        final String JavaDoc prevRevision) {
59         this.filename = filename;
60         this.revision = revision;
61         this.prevRevision = prevRevision;
62     }
63
64     /**
65      * Gets the filename for this CvsTagEntry
66      * @return the filename
67      */

68     public String JavaDoc getFile() {
69         return filename;
70     }
71
72     /**
73      * Gets the revision for this CvsTagEntry
74      * @return the revision
75      */

76     public String JavaDoc getRevision() {
77         return revision;
78     }
79
80     /**
81      * Gets the previous revision for this CvsTagEntry
82      * @return the previous revision
83      */

84     public String JavaDoc getPreviousRevision() {
85         return prevRevision;
86     }
87
88     /**
89      * Gets a String containing filename and difference from previous version
90      * @return a string representation of this CVSTagEntry
91      */

92     public String JavaDoc toString() {
93         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
94         buffer.append(filename);
95         if ((revision == null)) {
96             buffer.append(" was removed");
97             if (prevRevision != null) {
98                 buffer.append("; previous revision was ").append(prevRevision);
99             }
100         } else if (revision != null && prevRevision == null) {
101             buffer.append(" is new; current revision is ")
102                 .append(revision);
103         } else if (revision != null && prevRevision != null) {
104             buffer.append(" has changed from ")
105                 .append(prevRevision).append(" to ").append(revision);
106         }
107         return buffer.toString();
108     }
109 }
110
Popular Tags