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       */
67      public void setStartDate( Date startDate )
68          throws ScmException
69      {
70          parameters.setDate( CommandParameter.START_DATE, startDate );
71      }
72  
73      public Date getEndDate()
74          throws ScmException
75      {
76          return parameters.getDate( CommandParameter.END_DATE );
77      }
78  
79      /**
80       * @param endDate the end date of the period
81       */
82      public void setEndDate( Date endDate )
83          throws ScmException
84      {
85          parameters.setDate( CommandParameter.END_DATE, endDate );
86      }
87  
88      public int getNumDays()
89          throws ScmException
90      {
91          return parameters.getInt( CommandParameter.START_DATE );
92      }
93  
94      /**
95       * @param numDays the number days before the current time if startdate and enddate are null
96       */
97      public void setNumDays( int numDays )
98          throws ScmException
99      {
100         parameters.setInt( CommandParameter.NUM_DAYS, numDays );
101     }
102 
103     public ScmVersion getStartRevision()
104         throws ScmException
105     {
106         return parameters.getScmVersion( CommandParameter.START_SCM_VERSION, null );
107     }
108 
109     /**
110      * @param startRevision the start branch/tag/revision
111      */
112     public void setStartRevision( ScmVersion startRevision )
113         throws ScmException
114     {
115         parameters.setScmVersion( CommandParameter.START_SCM_VERSION, startRevision );
116     }
117 
118     public ScmVersion getEndRevision()
119         throws ScmException
120     {
121         return parameters.getScmVersion( CommandParameter.END_SCM_VERSION, null );
122     }
123 
124     /**
125      * @param endRevision the end branch/tag/revision
126      */
127     public void setEndRevision( ScmVersion endRevision )
128         throws ScmException
129     {
130         parameters.setScmVersion( CommandParameter.END_SCM_VERSION, endRevision );
131     }
132 
133     public String getDatePattern()
134         throws ScmException
135     {
136         return parameters.getString( CommandParameter.CHANGELOG_DATE_PATTERN, null );
137     }
138 
139     /**
140      * @param datePattern the date pattern used in changelog output returned by scm tool
141      */
142     public void setDatePattern( String datePattern )
143         throws ScmException
144     {
145         parameters.setString( CommandParameter.CHANGELOG_DATE_PATTERN, datePattern );
146     }
147 
148     public Integer getLimit()
149         throws ScmException
150     {
151         final int limit = parameters.getInt( CommandParameter.LIMIT, -1 );
152         return limit > 0 ? limit : null;
153     }
154 
155     /**
156      * @param limit the maximal count of returned changesets
157      */
158     public void setLimit( Integer limit )
159         throws ScmException
160     {
161         if ( limit != null )
162         {
163             parameters.setInt( CommandParameter.LIMIT, limit );
164         }
165         else
166         {
167             parameters.remove( CommandParameter.LIMIT );
168         }
169     }
170 
171     public void setDateRange( Date startDate, Date endDate )
172         throws ScmException
173     {
174         setStartDate( startDate );
175         setEndDate( endDate );
176     }
177 
178 }