Top Description Fields Constructors Methods
com.google.inject.internal

pack-priv final Class PackageNameCompressor

extends Object
Class Inheritance
Static Imports
java.util.Comparator.comparing

Munges an error message to remove/shorten package names and adds a legend at the end.

Field Summary

Modifier and TypeField and Description
private static final Pattern
pack-priv static final String
pack-priv static final String
private static final Joiner
private static final Splitter
private static final ImmutableSet<String>
private static final Pattern

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private static String
pack-priv static String
compressPackagesInMessage(String input)

Compresses an error message by stripping the packages out of class names and adding them to a legend at the bottom of the error.

private static ImmutableSet<String>
replaceFullNames(String input, Map<String, String> replacementMap, StringBuilder output)

Replaces full class names in input and append the replaced content to output and then returns a set of short names that were used as replacement.

private static Map<String, String>
shortenNames(Collection<String> names)

Returns a map from short name to full name after resolving conflicts.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CLASSNAME_PATTERNback to summary
private static final Pattern CLASSNAME_PATTERN
LEGEND_HEADERback to summary
pack-priv static final String LEGEND_HEADER
PACKAGE_JOINERback to summary
private static final Joiner PACKAGE_JOINER
PACKAGE_SPLITTERback to summary
private static final Splitter PACKAGE_SPLITTER
PACKAGES_SKIPPED_IN_LEGENDback to summary
private static final ImmutableSet<String> PACKAGES_SKIPPED_IN_LEGEND
QUOTED_PATTERNback to summary
private static final Pattern QUOTED_PATTERN

Constructor Detail

PackageNameCompressorback to summary
private PackageNameCompressor()

Method Detail

buildClassNameLegendback to summary
private static String buildClassNameLegend(Map<String, String> replacementMap)
compressPackagesInMessageback to summary
pack-priv static String compressPackagesInMessage(String input)

Compresses an error message by stripping the packages out of class names and adding them to a legend at the bottom of the error.

replaceFullNamesback to summary
private static ImmutableSet<String> replaceFullNames(String input, Map<String, String> replacementMap, StringBuilder output)

Replaces full class names in input and append the replaced content to output and then returns a set of short names that were used as replacement.

String literals that are quoted in the input will be added to the output unchanged. So any full class name that only appear in the string literal will not be included in the returned short names set.

shortenNamesback to summary
private static Map<String, String> shortenNames(Collection<String> names)

Returns a map from short name to full name after resolving conflicts. This resolves conflicts by adding on segments of the package name until they are unique. For example, com.foo.Baz and com.bar.Baz will conflict on Baz and then resolve with foo.Baz and bar.Baz as replacements.