Package org.eclipse.mat.hprof

## Class ExportHprof.Remap

- java.lang.Object
- - org.eclipse.mat.hprof.ExportHprof.Remap

Enclosing class:
  ExportHprof

    public static class ExportHprof.Remap
    extends java.lang.Object

Remaps class names. Separate class to isolate the generation of names from the actual contents of the snapshot.

### Constructor Summary

Constructors
`Remap​(java.util.regex.Pattern skipPattern, java.util.regex.Pattern avoidPattern, boolean matchFields, boolean undo)` Create a remapper

### Method Summary

All Methods Instance Methods Concrete Methods
`boolean` `isRemapped​(java.lang.String cn)` Is the class name one which should have a new name invented?
`void` `loadMapping​(java.io.File mapFile, boolean undo)` Load the existing mapping table from a mapping properties file.
`java.lang.String` `mapClass​(java.lang.String cn)` Return the renamed version of a class
`java.lang.String` `mapField​(java.lang.String cn)` Return the renamed version of a simple field/method
`java.lang.String` `mapSignature​(java.lang.String sig)` Return the renamed version of a method/type signature
`java.lang.String` `renameClassName​(java.lang.String classname)` Renames a class.
`java.lang.String` `renameFileName​(java.lang.String classname, java.lang.String filename)` Rename a file name based on a class name.
`java.lang.String` `renameMethodName​(java.lang.String className, java.lang.String method, boolean upper)` Generate a new method name.
`java.lang.String` `renameSignature​(java.lang.String signature)` Rename a method signature.
`void` `saveMapping​(java.io.File mapFile, boolean undo, java.lang.String comments)`

### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### Remap

    public Remap​(java.util.regex.Pattern skipPattern,
                 java.util.regex.Pattern avoidPattern,
                 boolean matchFields,
                 boolean undo)

Create a remapper

Parameters:
  `skipPattern` - Remap names unless they match this
  `avoidPattern` - Avoid remapping to names which match this
  `matchFields` - TODO
  `undo` - Just use existing remappings

### Method Detail

#### loadMapping

    public void loadMapping​(java.io.File mapFile,
                            boolean undo)
                     throws java.io.IOException

Load the existing mapping table from a mapping properties file. Properties file format: original.package.Classname=new.package.Classname

Parameters:
  `mapFile` - the Java format properties file
  `undo` - whether to reverse the mappings contained in the file
Throws:
  `java.io.IOException`

#### saveMapping

    public void saveMapping​(java.io.File mapFile,
                            boolean undo,
                            java.lang.String comments)
                     throws java.io.IOException

Throws:
  `java.io.IOException`

#### isRemapped

    public boolean isRemapped​(java.lang.String cn)

Is the class name one which should have a new name invented?

Parameters:
  `cn` -
Returns:
  true if the class name is to be changed

#### mapClass

    public java.lang.String mapClass​(java.lang.String cn)

Return the renamed version of a class

Parameters:
  `cn` -
Returns:
  null if not renamed

#### mapField

    public java.lang.String mapField​(java.lang.String cn)

Return the renamed version of a simple field/method

Parameters:
  `cn` -
Returns:
  null if not renamed

#### mapSignature

    public java.lang.String mapSignature​(java.lang.String sig)

Return the renamed version of a method/type signature

Parameters:
  `sig` -
Returns:
  null if not renamed

#### renameFileName

    public java.lang.String renameFileName​(java.lang.String classname,
                                           java.lang.String filename)

Rename a file name based on a class name.

Parameters:
  `classname` -
  `filename` -
Returns:
  the renamed file name

#### renameSignature

    public java.lang.String renameSignature​(java.lang.String signature)

Rename a method signature. Extract the class names from the Lpack1.class1;II)VLpack2.class2;

Parameters:
  `signature` -
Returns:
  renamed signature

#### renameMethodName

    public java.lang.String renameMethodName​(java.lang.String className,
                                             java.lang.String method,
                                             boolean upper)

Generate a new method name. Remember it as package.class^method - ? Some unusual Javac generated methods: HistogramQuery$Grouping.values() HistogramQuery.$SWITCH_TABLE$org$eclipse$mat$inspections$HistogramQuery$Grouping()

Parameters:
  `className` -
  `method` - method name or field name
  `upper` - static field in upper case, else all lower case.
Returns:
  the renamed method or field name

#### renameClassName

    public java.lang.String renameClassName​(java.lang.String classname)

Renames a class. Break into component parts, reusing existing mapping for package if already used. Removes array suffixes and uses base class name. Translates inner classes with '$' piece by piece, reusing existing mapping of outer class.

Parameters:
  `classname` -
Returns:
  the renamed class name, or the original name if no renaming is to be done for this class