/******************************************************************************* * Copyright (c) 2014 Jeff Martin. * All rights reserved. This program and the accompanying materials * are made available under the terms of the GNU Public License v3.0 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/gpl.html * * Contributors: * Jeff Martin - initial API and implementation ******************************************************************************/ package cuchaz.enigma.mapping; import java.io.BufferedReader; import java.io.IOException; import java.io.Reader; import java.util.Deque; import com.google.common.collect.Queues; import cuchaz.enigma.Constants; import cuchaz.enigma.mapping.SignatureUpdater.ClassNameUpdater; public class MappingsReader { public Mappings read( Reader in ) throws IOException, MappingParseException { return read( new BufferedReader( in ) ); } public Mappings read( BufferedReader in ) throws IOException, MappingParseException { Mappings mappings = new Mappings(); Deque mappingStack = Queues.newArrayDeque(); int lineNumber = 0; String line = null; while( ( line = in.readLine() ) != null ) { lineNumber++; // strip comments int commentPos = line.indexOf( '#' ); if( commentPos >= 0 ) { line = line.substring( 0, commentPos ); } // skip blank lines if( line.trim().length() <= 0 ) { continue; } // get the indent of this line int indent = 0; for( int i=0; i