Package serp.bytecode

Class NameCache


  • public class NameCache
    extends java.lang.Object
    Caching and conversion of names in both internal and external form.
    • Constructor Summary

      Constructors 
      Constructor Description
      NameCache()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()
      Clear the cache.
      java.lang.String getComponentName​(java.lang.String name)
      Return the component type name for the given array type, or null if the given string does not represent an array type name.
      java.lang.String getDescriptor​(java.lang.String returnType, java.lang.String[] paramTypes)
      Construct a method descriptor from the given return and parameter types, which will be converted to internal form.
      java.lang.String[] getDescriptorParamNames​(java.lang.String descriptor)
      Return the parameter types, in internal form, for the given method descriptor string.
      java.lang.String getDescriptorReturnName​(java.lang.String descriptor)
      Return the return type, in internal form, for the given method descriptor string.
      java.lang.String getExternalForm​(java.lang.String internalName, boolean humanReadable)
      Given the internal name of the class, return the 'normal' java name.
      private java.lang.String getExternalFormInternal​(java.lang.String intern, boolean humanReadable)  
      java.lang.String getInternalForm​(java.lang.String className, boolean descriptor)
      Converts the given class name to its internal form.
      private java.lang.String getInternalFormInternal​(java.lang.String cls, boolean descriptor)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • _codes

        static final java.lang.Object[][] _codes
      • _internal

        private final java.util.Map _internal
      • _internalDescriptor

        private final java.util.Map _internalDescriptor
      • _external

        private final java.util.Map _external
      • _externalHuman

        private final java.util.Map _externalHuman
    • Constructor Detail

      • NameCache

        public NameCache()
    • Method Detail

      • getInternalForm

        public java.lang.String getInternalForm​(java.lang.String className,
                                                boolean descriptor)
        Converts the given class name to its internal form.
        Parameters:
        className - the name to convert
        descriptor - true if the name is to be used for a descriptor section -- the difference seems to be that for descriptors, non-primitives are prefixed with 'L' and ended with ';'
      • getExternalForm

        public java.lang.String getExternalForm​(java.lang.String internalName,
                                                boolean humanReadable)
        Given the internal name of the class, return the 'normal' java name.
        Parameters:
        internalName - the internal name being used
        humanReadable - if the returned name should be in human-readable form, rather than a form suitable for a Class.forName(java.lang.String) call -- the difference lies in the handling of arrays
      • getDescriptor

        public java.lang.String getDescriptor​(java.lang.String returnType,
                                              java.lang.String[] paramTypes)
        Construct a method descriptor from the given return and parameter types, which will be converted to internal form.
      • getDescriptorReturnName

        public java.lang.String getDescriptorReturnName​(java.lang.String descriptor)
        Return the return type, in internal form, for the given method descriptor string.
      • getDescriptorParamNames

        public java.lang.String[] getDescriptorParamNames​(java.lang.String descriptor)
        Return the parameter types, in internal form, for the given method descriptor string.
      • getComponentName

        public java.lang.String getComponentName​(java.lang.String name)
        Return the component type name for the given array type, or null if the given string does not represent an array type name. The name given should be in proper Class.forName(java.lang.String) form.
      • clear

        public void clear()
        Clear the cache.