001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 */ 019package org.apache.maven.scm.provider.svn.svnexe.command.mkdir; 020 021import java.util.ArrayList; 022import java.util.List; 023 024import org.apache.commons.lang3.StringUtils; 025import org.apache.maven.scm.ScmFile; 026import org.apache.maven.scm.ScmFileStatus; 027import org.apache.maven.scm.util.AbstractConsumer; 028 029/** 030 * @author <a href="mailto:oching@apache.org">Maria Odea Ching</a> 031 */ 032public class SvnMkdirConsumer extends AbstractConsumer { 033 private static final String COMMITTED_REVISION_TOKEN = "Committed revision"; 034 035 private int revision; 036 037 private final List<ScmFile> createdDirs = new ArrayList<>(); 038 039 /** 040 * {@inheritDoc} 041 */ 042 public void consumeLine(String line) { 043 if (StringUtils.isBlank(line)) { 044 return; 045 } 046 047 String statusString = line.substring(0, 1); 048 ScmFileStatus status; 049 050 if (line.startsWith(COMMITTED_REVISION_TOKEN)) { 051 String revisionString = line.substring(COMMITTED_REVISION_TOKEN.length() + 1, line.length() - 1); 052 053 revision = Integer.parseInt(revisionString); 054 } else if (statusString.equals("A")) { 055 String file = line.substring(3); 056 057 status = ScmFileStatus.ADDED; 058 059 createdDirs.add(new ScmFile(file, status)); 060 } else { 061 if (logger.isInfoEnabled()) { 062 logger.info("Unknown line: '" + line + "'"); 063 } 064 } 065 } 066 067 public int getRevision() { 068 return revision; 069 } 070 071 public List<ScmFile> getCreatedDirs() { 072 return createdDirs; 073 } 074}