001package org.apache.maven.scm.provider.synergy.consumer; 002 003/* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022import org.apache.maven.scm.ChangeFile; 023import org.apache.maven.scm.log.ScmLogger; 024import org.apache.maven.scm.provider.synergy.util.SynergyUtil; 025import org.apache.maven.scm.util.AbstractConsumer; 026 027import java.util.ArrayList; 028import java.util.List; 029import java.util.StringTokenizer; 030 031/** 032 * Mainly inspired from CruiseControl 033 * 034 * @author <a href="julien.henry@capgemini.com">Julien Henry</a> 035 * @author Olivier Lamy 036 * 037 */ 038public class SynergyGetTaskObjectsConsumer 039 extends AbstractConsumer 040{ 041 042 private List<ChangeFile> entries = new ArrayList<ChangeFile>(); 043 044 public static final String OUTPUT_FORMAT = "%name" + SynergyUtil.SEPARATOR + // 0 045 "%version" + SynergyUtil.SEPARATOR; 046 047 /** 048 * @return the entries 049 */ 050 public List<ChangeFile> getFiles() 051 { 052 return entries; 053 } 054 055 public SynergyGetTaskObjectsConsumer( ScmLogger logger ) 056 { 057 super( logger ); 058 } 059 060 /** {@inheritDoc} */ 061 public void consumeLine( String line ) 062 { 063 if ( getLogger().isDebugEnabled() ) 064 { 065 getLogger().debug( "Consume: " + line ); 066 } 067 StringTokenizer tokenizer = new StringTokenizer( line.trim(), SynergyUtil.SEPARATOR ); 068 if ( tokenizer.countTokens() == 2 ) 069 { 070 ChangeFile f = new ChangeFile( tokenizer.nextToken() ); 071 f.setRevision( tokenizer.nextToken() ); 072 entries.add( f ); 073 } 074 else 075 { 076 if ( getLogger().isErrorEnabled() ) 077 { 078 getLogger().error( 079 "Invalid token count in SynergyGetTaskObjects [" + tokenizer.countTokens() 080 + "]" ); 081 } 082 } 083 } 084 085}