View Javadoc

1   /*
2   The MIT License
3   
4   Copyright (c) 2004, The Codehaus
5   
6   Permission is hereby granted, free of charge, to any person obtaining a copy of
7   this software and associated documentation files (the "Software"), to deal in
8   the Software without restriction, including without limitation the rights to
9   use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
10  of the Software, and to permit persons to whom the Software is furnished to do
11  so, subject to the following conditions:
12  
13  The above copyright notice and this permission notice shall be included in all
14  copies or substantial portions of the Software.
15  
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  SOFTWARE.
23   */
24  package org.codehaus.mojo.scmchangelog.changelog.log.grammar;
25  
26  import java.util.regex.Matcher;
27  import java.util.regex.Pattern;
28  
29  
30  /**
31   * Simple grammar which uses a <code>[type:id]comment</code> structure.
32   * @author ehsavoie
33   * @version $Id: RemyScmGrammar.java 10667 2009-09-11 08:26:43Z ehsavoie $
34   */
35  public class RemyScmGrammar
36      extends AbstractRegexpScmGrammar
37  {
38  
39    protected static final Pattern FIX_PATTERN = Pattern.compile( "[\\[][fF][iI][xX][\\s]*:[^\\]]*[\\]]" );
40    protected static final Pattern REMOVE_PATTERN = Pattern.compile( "[\\[][rR][eE][mM][oO][vV][eE][\\s]*:[^\\]]*[\\]]" );
41    protected static final Pattern ADD_PATTERN = Pattern.compile( "[\\[][aA][dD][dD][\\s]*:[^\\]]*[\\]]" );
42    protected static final Pattern UPDATE_PATTERN = Pattern.compile( "[\\[][uU][pP][dD][aA][tT][eE][\\s]*:[^\\]]*[\\]]" );
43    protected static final Pattern FIX_CLEANER_PATTERN = Pattern.compile( "[\\[][fF][iI][xX][\\s]*:" );
44    protected static final Pattern REMOVE_CLEANER_PATTERN = Pattern.compile( "[\\[][rR][eE][mM][oO][vV][eE][\\s]*:" );
45    protected static final Pattern ADD_CLEANER_PATTERN = Pattern.compile( "[\\[][aA][dD][dD][\\s]*:" );
46    protected static final Pattern UPDATE_CLEANER_PATTERN = Pattern.compile( "[\\[][uU][pP][dD][aA][tT][eE][\\s]*:" );
47  
48    public Matcher getFixCleaner( String expression )
49    {
50      return FIX_CLEANER_PATTERN.matcher( expression );
51    }
52  
53    public Matcher getUpdateCleaner( String expression )
54    {
55      return UPDATE_CLEANER_PATTERN.matcher( expression );
56    }
57  
58    public Matcher getAddCleaner( String expression )
59    {
60      return ADD_CLEANER_PATTERN.matcher( expression );
61    }
62  
63    public Matcher getRemoveCleaner( String expression )
64    {
65      return REMOVE_CLEANER_PATTERN.matcher( expression );
66    }
67  
68    public Matcher getFixMatcher( String expression )
69    {
70      return FIX_PATTERN.matcher( expression );
71    }
72  
73    public Matcher getAddMatcher( String expression )
74    {
75      return ADD_PATTERN.matcher( expression );
76    }
77  
78    public Matcher getRemoveMatcher( String expression )
79    {
80      return REMOVE_PATTERN.matcher( expression );
81    }
82  
83    public Matcher getUpdateMatcher( String expression )
84    {
85      return UPDATE_PATTERN.matcher( expression );
86    }
87  }