View Javadoc

1   package org.apache.maven.changelog;
2   
3   /* ====================================================================
4    *   Licensed to the Apache Software Foundation (ASF) under one or more
5    *   contributor license agreements.  See the NOTICE file distributed with
6    *   this work for additional information regarding copyright ownership.
7    *   The ASF licenses this file to You under the Apache License, Version 2.0
8    *   (the "License"); you may not use this file except in compliance with
9    *   the License.  You may obtain a copy of the License at
10   *
11   *       http://www.apache.org/licenses/LICENSE-2.0
12   *
13   *   Unless required by applicable law or agreed to in writing, software
14   *   distributed under the License is distributed on an "AS IS" BASIS,
15   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   *   See the License for the specific language governing permissions and
17   *   limitations under the License.
18   * ====================================================================
19   */
20  
21  import java.util.Collection;
22  import java.util.Iterator;
23  
24  /**
25   * Change Log Set - holds details about a set of change log entries.
26   *
27   * @author <a href="mailto:david.jackman@fastsearch.com">David Jackman</a>
28   * @version $$
29   */
30  public class ChangeLogSet
31  {
32      private final Collection entries;
33      private final String start;
34      private final String end;
35  
36      /**
37       * Initializes a new instance of this class.
38       *
39       * @param entries  collection of {@link ChangeLogEntry} objects for this set.
40       * @param start  the start date/tag for this set.
41       * @param end  the end date/tag for this set, or <code>null</code> if this set goes to the present time.
42       */
43      public ChangeLogSet( Collection entries, String start, String end )
44      {
45          this.entries = entries;
46          this.start = start;
47          this.end = end;
48      }
49  
50      /**
51       * Returns the collection of entries for this set.
52       *
53       * @return  the collection of {@link ChangeLogEntry} objects for this set.
54       */
55      public Collection getEntries()
56      {
57          return entries;
58      }
59  
60      /**
61       * Returns the start date/tag for this set.
62       *
63       * @return  the start date/tag for this set.
64       */
65      public String getStart()
66      {
67          return start;
68      }
69  
70      /**
71       * Returns the end date/tag for this set.
72       *
73       * @return  the end date/tag for this set, or <code>null</code> if this set goes to the present time.
74       */
75      public String getEnd()
76      {
77          return end;
78      }
79  
80      /**
81       * Creates an XML representation of this change log set.
82       */
83      public String toXML()
84      {
85          StringBuffer buffer = new StringBuffer();
86  
87          buffer.append( "<changeset start=\"" ).append( start )
88                .append( "\" end=\"" ).append( end ).append( "\">\n" );
89  
90          //  Write out the entries
91          for ( Iterator i = getEntries().iterator(); i.hasNext(); )
92          {
93              buffer.append( ( (ChangeLogEntry) i.next() ).toXML() );
94          }
95  
96          buffer.append( "</changeset>\n" );
97  
98          return buffer.toString();
99      }
100 }