View Javadoc
1   package org.apache.maven.scm.provider.synergy.consumer;
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.ChangeFile;
23  import org.apache.maven.scm.log.ScmLogger;
24  import org.apache.maven.scm.provider.synergy.util.SynergyUtil;
25  import org.apache.maven.scm.util.AbstractConsumer;
26  
27  import java.util.ArrayList;
28  import java.util.List;
29  import java.util.StringTokenizer;
30  
31  /**
32   * Mainly inspired from CruiseControl
33   *
34   * @author <a href="julien.henry@capgemini.com">Julien Henry</a>
35   * @author Olivier Lamy
36   *
37   */
38  public class SynergyGetTaskObjectsConsumer
39      extends AbstractConsumer
40  {
41  
42      private List<ChangeFile> entries = new ArrayList<ChangeFile>();
43  
44      public static final String OUTPUT_FORMAT = "%name" + SynergyUtil.SEPARATOR + // 0
45          "%version" + SynergyUtil.SEPARATOR;
46  
47      /**
48       * @return the entries
49       */
50      public List<ChangeFile> getFiles()
51      {
52          return entries;
53      }
54  
55      public SynergyGetTaskObjectsConsumer( ScmLogger logger )
56      {
57          super( logger );
58      }
59  
60      /** {@inheritDoc} */
61      public void consumeLine( String line )
62      {
63          if ( getLogger().isDebugEnabled() )
64          {
65              getLogger().debug( "Consume: " + line );
66          }
67          StringTokenizer tokenizer = new StringTokenizer( line.trim(), SynergyUtil.SEPARATOR );
68          if ( tokenizer.countTokens() == 2 )
69          {
70              ChangeFile f = new ChangeFile( tokenizer.nextToken() );
71              f.setRevision( tokenizer.nextToken() );
72              entries.add( f );
73          }
74          else
75          {
76              if ( getLogger().isErrorEnabled() )
77              {
78                  getLogger().error(
79                                     "Invalid token count in SynergyGetTaskObjects [" + tokenizer.countTokens()
80                                         + "]" );
81              }
82          }
83      }
84  
85  }