classUtils.javassist
Class ClassMap

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap
          extended by classUtils.javassist.ClassMap
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map

public class ClassMap
extends java.util.HashMap

A hashtable 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(Object), CompileTimeClass.replaceClassName(ClassMap), CtNewMethod.copy(CtMethod,String,CompileTimeClass,ClassMap), Serialized Form

Constructor Summary
ClassMap()
           
 
Method Summary
 void fix(CompileTimeClass clazz)
          Prevents a mapping from the specified class name to another name.
 void fix(java.lang.String name)
          Prevents a mapping from the specified class name to another name.
 java.lang.Object get(java.lang.Object jvmClassName)
          Returns the class name to wihch the given jvmClassName is mapped.
 void put(CompileTimeClass oldname, CompileTimeClass newname)
          Maps a class name to another name in this hashtable.
 void put(java.lang.String oldname, java.lang.String newname)
          Maps a class name to another name in this hashtable.
static java.lang.String toJavaName(java.lang.String classname)
          Converts a class name from the internal representation used in the JVM to the normal one used in Java.
static java.lang.String toJvmName(java.lang.String classname)
          Converts a class name into the internal representation used in the JVM.
 
Methods inherited from class java.util.HashMap
clear, clone, containsKey, containsValue, entrySet, isEmpty, keySet, put, putAll, remove, size, values
 
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

ClassMap

public ClassMap()
Method Detail

put

public void put(CompileTimeClass oldname,
                CompileTimeClass 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(java.lang.String oldname,
                java.lang.String newname)
Maps a class name to another name in this hashtable. 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.

get

public java.lang.Object get(java.lang.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.

Specified by:
get in interface java.util.Map
Overrides:
get in class java.util.HashMap
See Also:
toJvmName(String), toJavaName(String)

fix

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


fix

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


toJvmName

public static java.lang.String toJvmName(java.lang.String classname)
Converts a class name into the internal representation used in the JVM.


toJavaName

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