001    /*
002     * Copyright 2005 The Apache Software Foundation.
003     * 
004     * Licensed under the Apache License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     * 
008     *      http://www.apache.org/licenses/LICENSE-2.0
009     * 
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    package org.vafer.jdeb.changes;
017    
018    import java.text.DateFormat;
019    import java.text.SimpleDateFormat;
020    import java.util.Date;
021    
022    
023    /**
024     * A ChangeSet basically reflect a release as defined in the changes file.
025     *  
026     * @author Torsten Curdt <tcurdt@vafer.org>
027     */
028    public final class ChangeSet {
029    
030            private final String packageName;
031            private final String version;
032            private final Date date;
033            private final String distribution;
034            private final String urgency;
035            private final String changedBy;
036            private final String[] changes;
037            
038            public ChangeSet( String pPackageName, String pVersion, Date pDate, String pDistribution, String pUrgency, String pChangedBy, final String[] pChanges ) {
039                    changes = pChanges;
040                    packageName = pPackageName;
041                    version = pVersion;
042                    date = pDate;
043                    distribution = pDistribution;
044                    urgency = pUrgency;
045                    changedBy = pChangedBy;
046            }
047            /*
048         package (version) distribution(s); urgency=urgency
049                [optional blank line(s), stripped]
050           * change details
051             more change details
052                [blank line(s), included in output of dpkg-parsechangelog]
053           * even more change details
054                [optional blank line(s), stripped]
055          -- maintainer name <email address>[two spaces]  date
056        */
057            
058            public static DateFormat createDateForma() {
059                    return new SimpleDateFormat("HH:mm dd.MM.yyyy");
060            }
061            
062            public String getPackage() {
063                    return packageName;
064            }
065            
066            public String getVersion() {
067                    return version;
068            }
069            
070            public Date getDate() {
071                    return date;
072            }
073            
074            public String getDistribution() {
075                    return distribution;
076            }
077            
078            public String getUrgency() {
079                    return urgency;
080            }
081            
082            public String getChangedBy() {
083                    return changedBy;
084            }
085            
086            public String[] getChanges() {
087                    return changes;
088            }
089            
090            public String toString() {
091                    final StringBuffer sb = new StringBuffer();
092    
093                    sb.append(" ").append(getPackage()).append(" (").append(getVersion()).append(") ");
094                    sb.append(getDistribution()).append("; urgency=").append(getUrgency());
095                    for (int i = 0; i < changes.length; i++) {
096                            sb.append('\n').append(" * ").append(changes[i]);
097                    }
098    
099                    return sb.toString();
100            }
101    }