From 959cb5fd4f9586ec3bd265b452fe25fe1db82e3f Mon Sep 17 00:00:00 2001 From: jeff Date: Tue, 13 Jan 2015 23:25:04 -0500 Subject: source format change don't hate me too much if you were planning a big merge. =P --- src/cuchaz/enigma/mapping/SignatureUpdater.java | 88 +++++++++---------------- 1 file changed, 32 insertions(+), 56 deletions(-) (limited to 'src/cuchaz/enigma/mapping/SignatureUpdater.java') diff --git a/src/cuchaz/enigma/mapping/SignatureUpdater.java b/src/cuchaz/enigma/mapping/SignatureUpdater.java index 809473e..3477cd5 100644 --- a/src/cuchaz/enigma/mapping/SignatureUpdater.java +++ b/src/cuchaz/enigma/mapping/SignatureUpdater.java @@ -16,84 +16,63 @@ import java.util.List; import com.google.common.collect.Lists; -public class SignatureUpdater -{ - public interface ClassNameUpdater - { - String update( String className ); +public class SignatureUpdater { + + public interface ClassNameUpdater { + String update(String className); } - public static String update( String signature, ClassNameUpdater updater ) - { - try - { + public static String update(String signature, ClassNameUpdater updater) { + try { StringBuilder buf = new StringBuilder(); // read the signature character-by-character - StringReader reader = new StringReader( signature ); + StringReader reader = new StringReader(signature); int i = -1; - while( ( i = reader.read() ) != -1 ) - { + while ( (i = reader.read()) != -1) { char c = (char)i; // does this character start a class name? - if( c == 'L' ) - { + if (c == 'L') { // update the class name and add it to the buffer - buf.append( 'L' ); - String className = readClass( reader ); - if( className == null ) - { - throw new IllegalArgumentException( "Malformed signature: " + signature ); + buf.append('L'); + String className = readClass(reader); + if (className == null) { + throw new IllegalArgumentException("Malformed signature: " + signature); } - buf.append( updater.update( className ) ); - buf.append( ';' ); - } - else - { + buf.append(updater.update(className)); + buf.append(';'); + } else { // copy the character into the buffer - buf.append( c ); + buf.append(c); } } return buf.toString(); - } - catch( IOException ex ) - { + } catch (IOException ex) { // I'm pretty sure a StringReader will never throw one of these - throw new Error( ex ); + throw new Error(ex); } } - private static String readClass( StringReader reader ) - throws IOException - { + private static String readClass(StringReader reader) throws IOException { // read all the characters in the buffer until we hit a ';' // remember to treat generics correctly StringBuilder buf = new StringBuilder(); int depth = 0; int i = -1; - while( ( i = reader.read() ) != -1 ) - { + while ( (i = reader.read()) != -1) { char c = (char)i; - if( c == '<' ) - { + if (c == '<') { depth++; - } - else if( c == '>' ) - { + } else if (c == '>') { depth--; - } - else if( depth == 0 ) - { - if( c == ';' ) - { + } else if (depth == 0) { + if (c == ';') { return buf.toString(); - } - else - { - buf.append( c ); + } else { + buf.append(c); } } } @@ -101,18 +80,15 @@ public class SignatureUpdater return null; } - public static List getClasses( String signature ) - { + public static List getClasses(String signature) { final List classNames = Lists.newArrayList(); - update( signature, new ClassNameUpdater( ) - { + update(signature, new ClassNameUpdater() { @Override - public String update( String className ) - { - classNames.add( className ); + public String update(String className) { + classNames.add(className); return className; } - } ); + }); return classNames; } } -- cgit v1.2.3