summaryrefslogtreecommitdiff
path: root/src/main/java/cuchaz/enigma/convert/ClassIdentifier.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/cuchaz/enigma/convert/ClassIdentifier.java')
-rw-r--r--src/main/java/cuchaz/enigma/convert/ClassIdentifier.java54
1 files changed, 0 insertions, 54 deletions
diff --git a/src/main/java/cuchaz/enigma/convert/ClassIdentifier.java b/src/main/java/cuchaz/enigma/convert/ClassIdentifier.java
deleted file mode 100644
index 0a72073..0000000
--- a/src/main/java/cuchaz/enigma/convert/ClassIdentifier.java
+++ /dev/null
@@ -1,54 +0,0 @@
1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html
7 * <p>
8 * Contributors:
9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/
11
12package cuchaz.enigma.convert;
13
14import com.google.common.collect.Maps;
15import cuchaz.enigma.TranslatingTypeLoader;
16import cuchaz.enigma.analysis.JarIndex;
17import cuchaz.enigma.convert.ClassNamer.SidedClassNamer;
18import cuchaz.enigma.mapping.ClassEntry;
19import cuchaz.enigma.mapping.Translator;
20import javassist.CtClass;
21
22import java.util.Map;
23import java.util.jar.JarFile;
24
25public class ClassIdentifier {
26
27 private JarIndex index;
28 private SidedClassNamer namer;
29 private boolean useReferences;
30 private TranslatingTypeLoader loader;
31 private Map<ClassEntry, ClassIdentity> cache;
32
33 public ClassIdentifier(JarFile jar, JarIndex index, SidedClassNamer namer, boolean useReferences) {
34 this.index = index;
35 this.namer = namer;
36 this.useReferences = useReferences;
37 this.loader = new TranslatingTypeLoader(jar, index, new Translator(), new Translator());
38 this.cache = Maps.newHashMap();
39 }
40
41 public ClassIdentity identify(ClassEntry classEntry)
42 throws ClassNotFoundException {
43 ClassIdentity identity = this.cache.get(classEntry);
44 if (identity == null) {
45 CtClass c = this.loader.loadClass(classEntry.getName());
46 if (c == null) {
47 throw new ClassNotFoundException(classEntry.getName());
48 }
49 identity = new ClassIdentity(c, this.namer, this.index, this.useReferences);
50 this.cache.put(classEntry, identity);
51 }
52 return identity;
53 }
54}