Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
PerforceHaveConsumer |
|
| 2.0;2 |
1 | package org.apache.maven.scm.provider.perforce.command.update; | |
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.ScmException; | |
23 | import org.apache.maven.scm.log.ScmLogger; | |
24 | import org.apache.maven.scm.util.AbstractConsumer; | |
25 | import org.apache.regexp.RE; | |
26 | import org.apache.regexp.RESyntaxException; | |
27 | ||
28 | /** | |
29 | * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a> | |
30 | * @version $Id: PerforceHaveConsumer.java 1057019 2011-01-09 20:13:07Z olamy $ | |
31 | */ | |
32 | public class PerforceHaveConsumer | |
33 | extends AbstractConsumer | |
34 | { | |
35 | private String have; | |
36 | ||
37 | /** | |
38 | * The regular expression used to match header lines | |
39 | */ | |
40 | private RE revisionRegexp; | |
41 | ||
42 | private static final String PATTERN = "^Change (\\d+) " + // changelist number | |
43 | "on (.*) " + // date | |
44 | "by (.*)@"; // author | |
45 | ||
46 | public PerforceHaveConsumer( ScmLogger logger ) | |
47 | { | |
48 | 0 | super( logger ); |
49 | ||
50 | try | |
51 | { | |
52 | 0 | revisionRegexp = new RE( PATTERN ); |
53 | } | |
54 | 0 | catch ( RESyntaxException ignored ) |
55 | { | |
56 | 0 | if ( getLogger().isErrorEnabled() ) |
57 | { | |
58 | 0 | getLogger().error( "Could not create regexp to parse perforce log file", ignored ); |
59 | } | |
60 | 0 | } |
61 | 0 | } |
62 | ||
63 | public String getHave() throws ScmException | |
64 | { | |
65 | 0 | return have; |
66 | } | |
67 | ||
68 | // ---------------------------------------------------------------------- | |
69 | // StreamConsumer Implementation | |
70 | // ---------------------------------------------------------------------- | |
71 | ||
72 | /** {@inheritDoc} */ | |
73 | public void consumeLine( String line ) | |
74 | { | |
75 | 0 | if( revisionRegexp.match( line ) ) |
76 | { | |
77 | 0 | have = revisionRegexp.getParen( 1 ); |
78 | } | |
79 | 0 | } |
80 | } |