APIdia Launch Partner
Top Description Fields Constructors Methods
com.sun.tools.javac.code

public abstract Class Printer

extends Object
implements Type.Visitor<String, Locale>, Symbol.Visitor<String, Locale>
Class Inheritance
All Implemented Interfaces
com.sun.tools.javac.code.Symbol.Visitor, com.sun.tools.javac.code.Type.Visitor
Known Direct Subclasses
com.sun.tools.javac.util.RichDiagnosticFormatter.RichPrinter
Imports
java.util.Locale, com.sun.tools.javac.api.Messages, com.sun.tools.javac.code.Type.ArrayType, com.sun.tools.javac.code.Symbol.*, com.sun.tools.javac.code.Type.*, com.sun.tools.javac.util.List, .ListBuffer, .Name, .Pair

A combined type/symbol visitor for generating non-trivial localized string representation of types and symbols.

This is NOT part of any supported API. If you write code that depends on this, you do so at your own risk. This code and its internal interfaces are subject to change or deletion without notice.

Field Summary

Modifier and TypeField and Description
pack-priv static final int
private boolean
pack-priv List<Type>

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
protected abstract String

Returns:

unique id representing this captured type
capturedVarId
(Type.CapturedType
the captured type for which an id is to be retrieved
t
,
Locale
locale settings
locale
)

Maps a captured type into an unique identifier.

protected String

Returns:

localized string representation
className
(Type.ClassType
the type of the class whose name is to be rendered
t
,
boolean
if set, the class' fullname is displayed - if unset the short name is chosen (w/o package)
longform
,
Locale
the locale in which the string is to be rendered
locale
)

Converts a class name into a (possibly localized) string.

public static Printer

Returns:

printer visitor instance
createStandardPrinter
(final Messages
Messages class to be used for i18n
messages
)

Create a printer with default i18n support provided by Messages.

protected abstract String

Returns:

localized string representation
localize
(Locale
the locale in which the string is to be rendered
locale
,
String
the key corresponding to the message to be displayed
key
,
Object...
a list of optional arguments
args
)

This method should be overridden in order to provide proper i18n support.

public String
private String
private String
printAnnotations(Type t, boolean prefix, Locale locale)

private void
private void
protected String

Returns:

localized string representation
printMethodArgs
(List<Type>
arguments to be rendered
args
,
boolean
if true, the last method argument is regarded as a vararg
varArgs
,
Locale
the locale in which the string is to be rendered
locale
)

Converts a set of method argument types into their corresponding localized string representation.

public String

Returns:

localized string representation
visit
(Type
type to be displayed
t
,
Locale
the locale in which the string is to be rendered
locale
)

Get a localized string representation for a given type.

public String

Returns:

localized string representation
visit
(Symbol
symbol to be displayed
s
,
Locale
the locale in which the string is to be rendered
locale
)

Get a localized string representation for a given symbol.

public String
public String
public String
public String
public String
public String
public String
public String
public String
public String
public String
public String
public String
public String

Returns:

localized string representation
visitSymbols
(List<Symbol>
symbols to be displayed
ts
,
Locale
the locale in which the string is to be rendered
locale
)

* Get a localized string representation for all the symbols in the input list.

public String
public String

Returns:

localized string representation
visitTypes
(List<Type>
types to be displayed
ts
,
Locale
the locale in which the string is to be rendered
locale
)

Get a localized string representation for all the types in the input list.

public String
public String
public String
public String
public String
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

PRIMEback to summary
pack-priv static final int PRIME
printingMethodArgsback to summary
private boolean printingMethodArgs
seenCapturedback to summary
pack-priv List<Type> seenCaptured

Constructor Detail

Printerback to summary
protected Printer()

Method Detail

capturedVarIdback to summary
protected abstract String capturedVarId(Type.CapturedType t, Locale locale)

Maps a captured type into an unique identifier.

Parameters
t:Type.CapturedType

the captured type for which an id is to be retrieved

locale:Locale

locale settings

Returns:String

unique id representing this captured type

classNameback to summary
protected String className(Type.ClassType t, boolean longform, Locale locale)

Converts a class name into a (possibly localized) string. Anonymous inner classes get converted into a localized string.

Parameters
t:Type.ClassType

the type of the class whose name is to be rendered

longform:boolean

if set, the class' fullname is displayed - if unset the short name is chosen (w/o package)

locale:Locale

the locale in which the string is to be rendered

Returns:String

localized string representation

createStandardPrinterback to summary
public static Printer createStandardPrinter(final Messages messages)

Create a printer with default i18n support provided by Messages. By default, captured types ids are generated using hashcode.

Parameters
messages:Messages

Messages class to be used for i18n

Returns:Printer

printer visitor instance

localizeback to summary
protected abstract String localize(Locale locale, String key, Object... args)

This method should be overridden in order to provide proper i18n support.

Parameters
locale:Locale

the locale in which the string is to be rendered

key:String

the key corresponding to the message to be displayed

args:Object[]

a list of optional arguments

Returns:String

localized string representation

printAnnotationback to summary
public String printAnnotation(Attribute.Compound a, Locale locale)
printAnnotationsback to summary
private String printAnnotations(Type t, Locale locale)
printAnnotationsback to summary
private String printAnnotations(Type t, boolean prefix, Locale locale)
printBaseElementTypeback to summary
private void printBaseElementType(Type t, StringBuilder sb, Locale locale)
printBracketsback to summary
private void printBrackets(Type t, StringBuilder sb, Locale locale)
printMethodArgsback to summary
protected String printMethodArgs(List<Type> args, boolean varArgs, Locale locale)

Converts a set of method argument types into their corresponding localized string representation.

Parameters
args:List<Type>

arguments to be rendered

varArgs:boolean

if true, the last method argument is regarded as a vararg

locale:Locale

the locale in which the string is to be rendered

Returns:String

localized string representation

visitback to summary
public String visit(Type t, Locale locale)

Get a localized string representation for a given type.

Parameters
t:Type

type to be displayed

locale:Locale

the locale in which the string is to be rendered

Returns:String

localized string representation

visitback to summary
public String visit(Symbol s, Locale locale)

Get a localized string representation for a given symbol.

Parameters
s:Symbol

symbol to be displayed

locale:Locale

the locale in which the string is to be rendered

Returns:String

localized string representation

visitArrayTypeback to summary
public String visitArrayType(Type.ArrayType t, Locale locale)

Implements com.sun.tools.javac.code.Type.Visitor.visitArrayType.

Annotations
@Override
visitCapturedTypeback to summary
public String visitCapturedType(Type.CapturedType t, Locale locale)

Implements com.sun.tools.javac.code.Type.Visitor.visitCapturedType.

Annotations
@Override
visitClassSymbolback to summary
public String visitClassSymbol(Symbol.ClassSymbol sym, Locale locale)

Implements com.sun.tools.javac.code.Symbol.Visitor.visitClassSymbol.

Annotations
@Override
visitClassTypeback to summary
public String visitClassType(Type.ClassType t, Locale locale)

Implements com.sun.tools.javac.code.Type.Visitor.visitClassType.

Annotations
@Override
visitErrorTypeback to summary
public String visitErrorType(Type.ErrorType t, Locale locale)

Implements com.sun.tools.javac.code.Type.Visitor.visitErrorType.

Annotations
@Override
visitForAllback to summary
public String visitForAll(Type.ForAll t, Locale locale)

Implements com.sun.tools.javac.code.Type.Visitor.visitForAll.

Annotations
@Override
visitMethodSymbolback to summary
public String visitMethodSymbol(Symbol.MethodSymbol s, Locale locale)

Implements com.sun.tools.javac.code.Symbol.Visitor.visitMethodSymbol.

Annotations
@Override
visitMethodTypeback to summary
public String visitMethodType(Type.MethodType t, Locale locale)

Implements com.sun.tools.javac.code.Type.Visitor.visitMethodType.

Annotations
@Override
visitModuleTypeback to summary
public String visitModuleType(Type.ModuleType t, Locale locale)

Implements com.sun.tools.javac.code.Type.Visitor.visitModuleType.

Annotations
@Override
visitOperatorSymbolback to summary
public String visitOperatorSymbol(Symbol.OperatorSymbol s, Locale locale)

Implements com.sun.tools.javac.code.Symbol.Visitor.visitOperatorSymbol.

Annotations
@Override
visitPackageSymbolback to summary
public String visitPackageSymbol(Symbol.PackageSymbol s, Locale locale)

Implements com.sun.tools.javac.code.Symbol.Visitor.visitPackageSymbol.

Annotations
@Override
visitPackageTypeback to summary
public String visitPackageType(Type.PackageType t, Locale locale)

Implements com.sun.tools.javac.code.Type.Visitor.visitPackageType.

Annotations
@Override
visitSymbolback to summary
public String visitSymbol(Symbol s, Locale locale)

Implements com.sun.tools.javac.code.Symbol.Visitor.visitSymbol.

Annotations
@Override
visitSymbolsback to summary
public String visitSymbols(List<Symbol> ts, Locale locale)

* Get a localized string representation for all the symbols in the input list.

Parameters
ts:List<Symbol>

symbols to be displayed

locale:Locale

the locale in which the string is to be rendered

Returns:String

localized string representation

visitTypeback to summary
public String visitType(Type t, Locale locale)

Implements com.sun.tools.javac.code.Type.Visitor.visitType.

visitTypesback to summary
public String visitTypes(List<Type> ts, Locale locale)

Get a localized string representation for all the types in the input list.

Parameters
ts:List<Type>

types to be displayed

locale:Locale

the locale in which the string is to be rendered

Returns:String

localized string representation

visitTypeSymbolback to summary
public String visitTypeSymbol(Symbol.TypeSymbol s, Locale locale)

Implements com.sun.tools.javac.code.Symbol.Visitor.visitTypeSymbol.

Annotations
@Override
visitTypeVarback to summary
public String visitTypeVar(Type.TypeVar t, Locale locale)

Implements com.sun.tools.javac.code.Type.Visitor.visitTypeVar.

Annotations
@Override
visitUndetVarback to summary
public String visitUndetVar(Type.UndetVar t, Locale locale)

Implements com.sun.tools.javac.code.Type.Visitor.visitUndetVar.

Annotations
@Override
visitVarSymbolback to summary
public String visitVarSymbol(Symbol.VarSymbol s, Locale locale)

Implements com.sun.tools.javac.code.Symbol.Visitor.visitVarSymbol.

Annotations
@Override
visitWildcardTypeback to summary
public String visitWildcardType(Type.WildcardType t, Locale locale)

Implements com.sun.tools.javac.code.Type.Visitor.visitWildcardType.

Annotations
@Override