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.info; 020 021import java.util.ArrayList; 022import java.util.List; 023 024import org.apache.maven.scm.command.info.InfoItem; 025import org.apache.maven.scm.util.AbstractConsumer; 026 027/** 028 * @author <a href="mailto:kenney@apache.org">Kenney Westerhof</a> 029 * 030 */ 031public class SvnInfoConsumer extends AbstractConsumer { 032 private final List<InfoItem> infoItems = new ArrayList<>(); 033 034 private InfoItem currentItem = new InfoItem(); 035 036 /** {@inheritDoc} */ 037 public void consumeLine(String s) { 038 if (s.equals("")) { 039 if (currentItem != null) { 040 infoItems.add(currentItem); 041 } 042 043 currentItem = new InfoItem(); 044 } else if (s.startsWith("Path: ")) { 045 currentItem.setPath(getValue(s)); 046 } else if (s.startsWith("URL: ")) { 047 currentItem.setURL(getValue(s)); 048 } else if (s.startsWith("Repository Root: ")) { 049 currentItem.setRepositoryRoot(getValue(s)); 050 } else if (s.startsWith("Repository UUID: ")) { 051 currentItem.setRepositoryUUID(getValue(s)); 052 } else if (s.startsWith("Revision: ")) { 053 currentItem.setRevision(getValue(s)); 054 } else if (s.startsWith("Node Kind: ")) { 055 currentItem.setNodeKind(getValue(s)); 056 } else if (s.startsWith("Schedule: ")) { 057 currentItem.setSchedule(getValue(s)); 058 } else if (s.startsWith("Last Changed Author: ")) { 059 currentItem.setLastChangedAuthor(getValue(s)); 060 } else if (s.startsWith("Last Changed Rev: ")) { 061 currentItem.setLastChangedRevision(getValue(s)); 062 } else if (s.startsWith("Last Changed Date: ")) { 063 currentItem.setLastChangedDate(getValue(s)); 064 } 065 } 066 067 private static String getValue(String s) { 068 int idx = s.indexOf(": "); 069 070 if (idx < 0) { 071 // FIXME: Can't throw any exceptions in consumeLine.. 072 return null; 073 } else { 074 return s.substring(idx + 2); 075 } 076 } 077 078 public List<InfoItem> getInfoItems() { 079 return infoItems; 080 } 081}