summaryrefslogtreecommitdiff
path: root/src/cuchaz/enigma/mapping/MappingsWriter.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/cuchaz/enigma/mapping/MappingsWriter.java')
-rw-r--r--src/cuchaz/enigma/mapping/MappingsWriter.java75
1 files changed, 75 insertions, 0 deletions
diff --git a/src/cuchaz/enigma/mapping/MappingsWriter.java b/src/cuchaz/enigma/mapping/MappingsWriter.java
new file mode 100644
index 0000000..2086368
--- /dev/null
+++ b/src/cuchaz/enigma/mapping/MappingsWriter.java
@@ -0,0 +1,75 @@
1/*******************************************************************************
2 * Copyright (c) 2014 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Public License v3.0
5 * which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/gpl.html
7 *
8 * Contributors:
9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/
11package cuchaz.enigma.mapping;
12
13import java.io.IOException;
14import java.io.PrintWriter;
15import java.io.Writer;
16
17public class MappingsWriter
18{
19 public void write( Writer out, Mappings mappings )
20 throws IOException
21 {
22 write( new PrintWriter( out ), mappings );
23 }
24
25 public void write( PrintWriter out, Mappings mappings )
26 throws IOException
27 {
28 for( ClassMapping classMapping : mappings.classes() )
29 {
30 write( out, classMapping );
31 }
32 }
33
34 public void write( PrintWriter out, ClassMapping classMapping )
35 throws IOException
36 {
37 out.format( "CLASS %s %s\n", classMapping.getObfName(), classMapping.getDeobfName() );
38
39 for( FieldMapping fieldMapping : classMapping.fields() )
40 {
41 write( out, fieldMapping );
42 }
43
44 for( MethodMapping methodMapping : classMapping.methods() )
45 {
46 write( out, methodMapping );
47 }
48 }
49
50 public void write( PrintWriter out, FieldMapping fieldMapping )
51 throws IOException
52 {
53 out.format( "\tFIELD %s %s\n", fieldMapping.getObfName(), fieldMapping.getDeobfName() );
54 }
55
56 public void write( PrintWriter out, MethodMapping methodMapping )
57 throws IOException
58 {
59 out.format( "\tMETHOD %s %s %s %s\n",
60 methodMapping.getObfName(), methodMapping.getDeobfName(),
61 methodMapping.getObfSignature(), methodMapping.getDeobfSignature()
62 );
63
64 for( ArgumentMapping argumentMapping : methodMapping.arguments() )
65 {
66 write( out, argumentMapping );
67 }
68 }
69
70 public void write( PrintWriter out, ArgumentMapping argumentMapping )
71 throws IOException
72 {
73 out.format( "\t\tARG %d %s\n", argumentMapping.getIndex(), argumentMapping.getName() );
74 }
75}