javassist

Class ClassMap

public class ClassMap extends HashMap

A hash table associating class names with different names.

This hashtable is used for replacing class names in a class definition or a method body. Define a subclass of this class if a more complex mapping algorithm is needed. For example,

This subclass maps java.lang.String to java2.lang.String. Note that get() receives and returns the internal representation of a class name. For example, the internal representation of java.lang.String is java/lang/String.

See Also: get replaceClassName copy

Constructor Summary
ClassMap()
Constructs a hash table.
Method Summary
voidfix(CtClass clazz)
Prevents a mapping from the specified class name to another name.
voidfix(String name)
Prevents a mapping from the specified class name to another name.
Objectget(Object jvmClassName)
Returns the class name to wihch the given jvmClassName is mapped.
voidput(CtClass oldname, CtClass newname)
Maps a class name to another name in this hashtable.
voidput(String oldname, String newname)
Maps a class name to another name in this hashtable.
static StringtoJavaName(String classname)
Converts a class name from the internal representation used in the JVM to the normal one used in Java.
static StringtoJvmName(String classname)
Converts a class name into the internal representation used in the JVM.

Constructor Detail

ClassMap

public ClassMap()
Constructs a hash table.

Method Detail

fix

public void fix(CtClass clazz)
Prevents a mapping from the specified class name to another name.

fix

public void fix(String name)
Prevents a mapping from the specified class name to another name.

get

public Object get(Object jvmClassName)
Returns the class name to wihch the given jvmClassName is mapped. A subclass of this class should override this method.

This method receives and returns the internal representation of class name used in the JVM.

See Also: toJvmName toJavaName

put

public void put(CtClass oldname, CtClass newname)
Maps a class name to another name in this hashtable. The names are obtained with calling Class.getName(). This method translates the given class names into the internal form used in the JVM before putting it in the hashtable.

Parameters: oldname the original class name newname the substituted class name.

put

public void put(String oldname, String newname)
Maps a class name to another name in this hashtable. If the hashtable contains another mapping from the same class name, the old mapping is replaced. This method translates the given class names into the internal form used in the JVM before putting it in the hashtable.

If oldname is equivalent to newname, then this method does not perform anything; it does not record the mapping from oldname to newname. See fix method.

Parameters: oldname the original class name newname the substituted class name.

See Also: fix

toJavaName

public static String toJavaName(String classname)
Converts a class name from the internal representation used in the JVM to the normal one used in Java.

toJvmName

public static String toJvmName(String classname)
Converts a class name into the internal representation used in the JVM.
Javassist, a Java-bytecode translator toolkit.
Copyright (C) 1999-2006 Shigeru Chiba. All Rights Reserved.