Class IdentifierNormalizer


  • public class IdentifierNormalizer
    extends Object
    Rewriter of identifiers per the configured mode: raw, unicode-escaped, or semantically renamed.
    • Constructor Detail

      • IdentifierNormalizer

        public IdentifierNormalizer​(IdentifierMode mode)
        Creates a normalizer applying the given mode.
        Parameters:
        mode - the normalization strategy
    • Method Detail

      • normalize

        public String normalize​(String identifier,
                                IdentifierNormalizer.IdentifierType type)
        Normalizes an identifier according to the configured mode.
        Parameters:
        identifier - the identifier to normalize; null or empty is returned unchanged
        type - the identifier kind, selecting the semantic-rename prefix
        Returns:
        the normalized identifier
      • normalizeClassName

        public String normalizeClassName​(String internalName)
        Normalizes a class name in internal (slashed) or source (dotted) form.
        Parameters:
        internalName - the class name; null or empty is returned unchanged
        Returns:
        the normalized name with separators preserved
      • escapeToUnicode

        public String escapeToUnicode​(String s)
        Escapes characters not valid in Java identifiers to unicode escape sequences.
        Parameters:
        s - the string to escape, may be null
        Returns:
        the escaped string, or null if s is null
      • isValidJavaIdentifier

        public boolean isValidJavaIdentifier​(String s)
        Parameters:
        s - the string to test
        Returns:
        true if s is a well-formed Java identifier and not a keyword
      • reset

        public void reset()
        Resets all counters and rename caches for a fresh per-class run.