View Javadoc

1   package org.apache.maven.scm.provider.perforce.command.blame;
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.command.blame.BlameLine;
23  import org.apache.maven.scm.log.ScmLogger;
24  import org.apache.maven.scm.util.AbstractConsumer;
25  import org.apache.regexp.RE;
26  
27  import java.util.ArrayList;
28  import java.util.List;
29  
30  /**
31   * @author Evgeny Mandrikov
32   * @author Olivier Lamy
33   * @since 1.4
34   */
35  public class PerforceBlameConsumer
36      extends AbstractConsumer
37  {
38  
39      /* 151: line */
40      private static final String LINE_PATTERN = "(\\d+):";
41  
42      /**
43       * @see #LINE_PATTERN
44       */
45      private RE lineRegexp;
46  
47      private List<BlameLine> lines = new ArrayList<BlameLine>();
48  
49      public PerforceBlameConsumer( ScmLogger logger )
50      {
51          super( logger );
52          lineRegexp = new RE( LINE_PATTERN );
53      }
54  
55      /** {@inheritDoc} */
56      public void consumeLine( String line )
57      {
58          if ( lineRegexp.match( line ) )
59          {
60              String revision = lineRegexp.getParen( 1 ).trim();
61  
62              lines.add( new BlameLine( null, revision, null ) );
63          }
64      }
65  
66      public List<BlameLine> getLines()
67      {
68          return lines;
69      }
70  }