View Javadoc

1   /*
2    * Copyright 2005 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.vafer.jdeb.changes;
17  
18  import java.text.DateFormat;
19  import java.text.SimpleDateFormat;
20  import java.util.Date;
21  
22  
23  /**
24   * A ChangeSet basically reflect a release as defined in the changes file.
25   *  
26   * @author Torsten Curdt <tcurdt@vafer.org>
27   */
28  public final class ChangeSet {
29  
30  	private final String packageName;
31  	private final String version;
32  	private final Date date;
33  	private final String distribution;
34  	private final String urgency;
35  	private final String changedBy;
36  	private final String[] changes;
37  	
38  	public ChangeSet( String pPackageName, String pVersion, Date pDate, String pDistribution, String pUrgency, String pChangedBy, final String[] pChanges ) {
39  		changes = pChanges;
40  		packageName = pPackageName;
41  		version = pVersion;
42  		date = pDate;
43  		distribution = pDistribution;
44  		urgency = pUrgency;
45  		changedBy = pChangedBy;
46  	}
47  	/*
48       package (version) distribution(s); urgency=urgency
49       	    [optional blank line(s), stripped]
50         * change details
51           more change details
52       	    [blank line(s), included in output of dpkg-parsechangelog]
53         * even more change details
54       	    [optional blank line(s), stripped]
55        -- maintainer name <email address>[two spaces]  date
56      */
57  	
58  	public static DateFormat createDateForma() {
59  		return new SimpleDateFormat("HH:mm dd.MM.yyyy");
60  	}
61  	
62  	public String getPackage() {
63  		return packageName;
64  	}
65  	
66  	public String getVersion() {
67  		return version;
68  	}
69  	
70  	public Date getDate() {
71  		return date;
72  	}
73  	
74  	public String getDistribution() {
75  		return distribution;
76  	}
77  	
78  	public String getUrgency() {
79  		return urgency;
80  	}
81  	
82  	public String getChangedBy() {
83  		return changedBy;
84  	}
85  	
86  	public String[] getChanges() {
87  		return changes;
88  	}
89  	
90  	public String toString() {
91  		final StringBuffer sb = new StringBuffer();
92  
93  		sb.append(" ").append(getPackage()).append(" (").append(getVersion()).append(") ");
94  		sb.append(getDistribution()).append("; urgency=").append(getUrgency());
95  		for (int i = 0; i < changes.length; i++) {
96  			sb.append('\n').append(" * ").append(changes[i]);
97  		}
98  
99  		return sb.toString();
100 	}
101 }