View Javadoc
1   package org.apache.maven.scm.command.changelog;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   * http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import org.apache.maven.scm.CommandParameter;
23  import org.apache.maven.scm.ScmBranch;
24  import org.apache.maven.scm.ScmException;
25  import org.apache.maven.scm.ScmFileSet;
26  import org.apache.maven.scm.ScmRequest;
27  import org.apache.maven.scm.ScmVersion;
28  import org.apache.maven.scm.repository.ScmRepository;
29  
30  import java.util.Date;
31  
32  /**
33   * @author Petr Kozelka
34   * @since 1.8
35   */
36  public class ChangeLogScmRequest
37      extends ScmRequest
38  {
39      private static final long serialVersionUID = 20120620L;
40  
41      public ChangeLogScmRequest( ScmRepository scmRepository, ScmFileSet scmFileSet )
42      {
43          super( scmRepository, scmFileSet );
44      }
45  
46      public ScmBranch getScmBranch()
47          throws ScmException
48      {
49          return (ScmBranch) parameters.getScmVersion( CommandParameter.BRANCH, null );
50      }
51  
52      public void setScmBranch( ScmBranch scmBranch )
53          throws ScmException
54      {
55          parameters.setScmVersion( CommandParameter.BRANCH, scmBranch );
56      }
57  
58      public Date getStartDate()
59          throws ScmException
60      {
61          return parameters.getDate( CommandParameter.START_DATE );
62      }
63  
64      /**
65       * @param startDate the start date of the period
66  	 * @throws ScmException if any
67       */
68      public void setStartDate( Date startDate )
69          throws ScmException
70      {
71          parameters.setDate( CommandParameter.START_DATE, startDate );
72      }
73  
74      public Date getEndDate()
75          throws ScmException
76      {
77          return parameters.getDate( CommandParameter.END_DATE );
78      }
79  
80      /**
81       * @param endDate the end date of the period
82  	 * @throws ScmException if any
83       */
84      public void setEndDate( Date endDate )
85          throws ScmException
86      {
87          parameters.setDate( CommandParameter.END_DATE, endDate );
88      }
89  
90      public int getNumDays()
91          throws ScmException
92      {
93          return parameters.getInt( CommandParameter.START_DATE );
94      }
95  
96      /**
97       * @param numDays the number days before the current time if startdate and enddate are null
98  	 * @throws ScmException if any
99       */
100     public void setNumDays( int numDays )
101         throws ScmException
102     {
103         parameters.setInt( CommandParameter.NUM_DAYS, numDays );
104     }
105 
106     public ScmVersion getStartRevision()
107         throws ScmException
108     {
109         return parameters.getScmVersion( CommandParameter.START_SCM_VERSION, null );
110     }
111 
112     /**
113      * @param startRevision the start branch/tag/revision
114 	 * @throws ScmException if any
115      */
116     public void setStartRevision( ScmVersion startRevision )
117         throws ScmException
118     {
119         parameters.setScmVersion( CommandParameter.START_SCM_VERSION, startRevision );
120     }
121 
122     public ScmVersion getEndRevision()
123         throws ScmException
124     {
125         return parameters.getScmVersion( CommandParameter.END_SCM_VERSION, null );
126     }
127 
128     /**
129      * @param endRevision the end branch/tag/revision
130 	 * @throws ScmException if any
131      */
132     public void setEndRevision( ScmVersion endRevision )
133         throws ScmException
134     {
135         parameters.setScmVersion( CommandParameter.END_SCM_VERSION, endRevision );
136     }
137 
138     public String getDatePattern()
139         throws ScmException
140     {
141         return parameters.getString( CommandParameter.CHANGELOG_DATE_PATTERN, null );
142     }
143 
144     /**
145      * @param datePattern the date pattern used in changelog output returned by scm tool
146 	 * @throws ScmException if any
147      */
148     public void setDatePattern( String datePattern )
149         throws ScmException
150     {
151         parameters.setString( CommandParameter.CHANGELOG_DATE_PATTERN, datePattern );
152     }
153 
154     public Integer getLimit()
155         throws ScmException
156     {
157         final int limit = parameters.getInt( CommandParameter.LIMIT, -1 );
158         return limit > 0 ? limit : null;
159     }
160 
161     /**
162      * @param limit the maximal count of returned changesets
163 	 * @throws ScmException if any
164      */
165     public void setLimit( Integer limit )
166         throws ScmException
167     {
168         if ( limit != null )
169         {
170             parameters.setInt( CommandParameter.LIMIT, limit );
171         }
172         else
173         {
174             parameters.remove( CommandParameter.LIMIT );
175         }
176     }
177 
178     public void setDateRange( Date startDate, Date endDate )
179         throws ScmException
180     {
181         setStartDate( startDate );
182         setEndDate( endDate );
183     }
184 
185     public void setRevision( ScmVersion revision )
186         throws ScmException
187     {
188         parameters.setScmVersion( CommandParameter.SCM_VERSION, revision );
189     }
190 
191     public ScmVersion getRevision()
192         throws ScmException
193     {
194         return parameters.getScmVersion( CommandParameter.SCM_VERSION, null );
195     }
196 }