summaryrefslogtreecommitdiff
path: root/src/cuchaz/enigma/mapping/MethodIndex.java
diff options
context:
space:
mode:
authorGravatar jeff2014-07-27 22:33:21 -0400
committerGravatar jeff2014-07-27 22:33:21 -0400
commitd7321b5b0d38c575e54c770f7aa18dacbacab3c8 (patch)
treeef4b3e0f83b1fe89125c2674fec023871e70c0d8 /src/cuchaz/enigma/mapping/MethodIndex.java
parentmade gui responsive to caret position and show identifier info (diff)
downloadenigma-fork-d7321b5b0d38c575e54c770f7aa18dacbacab3c8.tar.gz
enigma-fork-d7321b5b0d38c575e54c770f7aa18dacbacab3c8.tar.xz
enigma-fork-d7321b5b0d38c575e54c770f7aa18dacbacab3c8.zip
added identifier renaming capability
copied some code over from M3L to handle the heavy bytecode magic. It's ok... M3L will eventually depend on Enigma. Completely restructured the mappings though. This way is better. =)
Diffstat (limited to 'src/cuchaz/enigma/mapping/MethodIndex.java')
-rw-r--r--src/cuchaz/enigma/mapping/MethodIndex.java125
1 files changed, 125 insertions, 0 deletions
diff --git a/src/cuchaz/enigma/mapping/MethodIndex.java b/src/cuchaz/enigma/mapping/MethodIndex.java
new file mode 100644
index 0000000..f965355
--- /dev/null
+++ b/src/cuchaz/enigma/mapping/MethodIndex.java
@@ -0,0 +1,125 @@
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.Serializable;
14import java.util.Map;
15import java.util.TreeMap;
16
17public class MethodIndex implements Serializable
18{
19 private static final long serialVersionUID = -4409570216084263978L;
20
21 private String m_obfName;
22 private String m_deobfName;
23 private String m_obfSignature;
24 private String m_deobfSignature;
25 private Map<Integer,ArgumentIndex> m_arguments;
26
27 public MethodIndex( String obfName, String obfSignature, String deobfName, String deobfSignature )
28 {
29 m_obfName = obfName;
30 m_deobfName = deobfName;
31 m_obfSignature = obfSignature;
32 m_deobfSignature = deobfSignature;
33 m_arguments = new TreeMap<Integer,ArgumentIndex>();
34 }
35
36 public String getObfName( )
37 {
38 return m_obfName;
39 }
40
41 public String getDeobfName( )
42 {
43 return m_deobfName;
44 }
45 public void setDeobfName( String val )
46 {
47 m_deobfName = val;
48 }
49
50 public String getObfSignature( )
51 {
52 return m_obfSignature;
53 }
54
55 public String getDeobfSignature( )
56 {
57 return m_deobfSignature;
58 }
59 public void setDeobfSignature( String val )
60 {
61 m_deobfSignature = val;
62 }
63
64 public String getObfArgumentName( int index )
65 {
66 ArgumentIndex argumentIndex = m_arguments.get( index );
67 if( argumentIndex != null )
68 {
69 return argumentIndex.getObfName();
70 }
71
72 return null;
73 }
74
75 public String getDeobfArgumentName( int index )
76 {
77 ArgumentIndex argumentIndex = m_arguments.get( index );
78 if( argumentIndex != null )
79 {
80 return argumentIndex.getDeobfName();
81 }
82
83 return null;
84 }
85
86 public void setArgumentName( int index, String obfName, String deobfName )
87 {
88 ArgumentIndex argumentIndex = m_arguments.get( index );
89 if( argumentIndex == null )
90 {
91 argumentIndex = new ArgumentIndex( obfName, deobfName );
92 m_arguments.put( index, argumentIndex );
93 }
94 else
95 {
96 argumentIndex.setDeobfName( deobfName );
97 }
98 }
99
100 @Override
101 public String toString( )
102 {
103 StringBuilder buf = new StringBuilder();
104 buf.append( "\t" );
105 buf.append( m_obfName );
106 buf.append( " <-> " );
107 buf.append( m_deobfName );
108 buf.append( "\n" );
109 buf.append( "\t" );
110 buf.append( m_obfSignature );
111 buf.append( " <-> " );
112 buf.append( m_deobfSignature );
113 buf.append( "\n" );
114 buf.append( "\tArguments:\n" );
115 for( ArgumentIndex argumentIndex : m_arguments.values() )
116 {
117 buf.append( "\t\t" );
118 buf.append( argumentIndex.getObfName() );
119 buf.append( " <-> " );
120 buf.append( argumentIndex.getDeobfName() );
121 buf.append( "\n" );
122 }
123 return buf.toString();
124 }
125}