diff options
Diffstat (limited to 'src/main/java/cuchaz/enigma/bytecode/accessors/StringInfoAccessor.java')
| -rw-r--r-- | src/main/java/cuchaz/enigma/bytecode/accessors/StringInfoAccessor.java | 56 |
1 files changed, 0 insertions, 56 deletions
diff --git a/src/main/java/cuchaz/enigma/bytecode/accessors/StringInfoAccessor.java b/src/main/java/cuchaz/enigma/bytecode/accessors/StringInfoAccessor.java deleted file mode 100644 index 5c68d4af..00000000 --- a/src/main/java/cuchaz/enigma/bytecode/accessors/StringInfoAccessor.java +++ /dev/null | |||
| @@ -1,56 +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 | |||
| 12 | package cuchaz.enigma.bytecode.accessors; | ||
| 13 | |||
| 14 | import java.lang.reflect.Field; | ||
| 15 | |||
| 16 | public class StringInfoAccessor { | ||
| 17 | |||
| 18 | private static Class<?> clazz; | ||
| 19 | private static Field stringIndex; | ||
| 20 | |||
| 21 | static { | ||
| 22 | try { | ||
| 23 | clazz = Class.forName("javassist.bytecode.StringInfo"); | ||
| 24 | stringIndex = clazz.getDeclaredField("string"); | ||
| 25 | stringIndex.setAccessible(true); | ||
| 26 | } catch (Exception ex) { | ||
| 27 | throw new Error(ex); | ||
| 28 | } | ||
| 29 | } | ||
| 30 | |||
| 31 | private Object item; | ||
| 32 | |||
| 33 | public StringInfoAccessor(Object item) { | ||
| 34 | this.item = item; | ||
| 35 | } | ||
| 36 | |||
| 37 | public static boolean isType(ConstInfoAccessor accessor) { | ||
| 38 | return clazz.isAssignableFrom(accessor.getItem().getClass()); | ||
| 39 | } | ||
| 40 | |||
| 41 | public int getStringIndex() { | ||
| 42 | try { | ||
| 43 | return (Integer) stringIndex.get(this.item); | ||
| 44 | } catch (Exception ex) { | ||
| 45 | throw new Error(ex); | ||
| 46 | } | ||
| 47 | } | ||
| 48 | |||
| 49 | public void setStringIndex(int val) { | ||
| 50 | try { | ||
| 51 | stringIndex.set(this.item, val); | ||
| 52 | } catch (Exception ex) { | ||
| 53 | throw new Error(ex); | ||
| 54 | } | ||
| 55 | } | ||
| 56 | } | ||