public abstract class Printer extends Object implements Type.Visitor<String,Locale>, Symbol.Visitor<String,Locale>
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.
Modifier | Constructor and Description |
---|---|
protected |
Printer() |
Modifier and Type | Method and Description |
---|---|
protected abstract String |
capturedVarId(Type.CapturedType t,
Locale locale)
Maps a captured type into an unique identifier.
|
protected String |
className(Type.ClassType t,
boolean longform,
Locale locale)
Converts a class name into a (possibly localized) string.
|
static Printer |
createStandardPrinter(Messages messages)
Create a printer with default i18n support provided by Messages.
|
protected abstract String |
localize(Locale locale,
String key,
Object... args)
This method should be overriden in order to provide proper i18n support.
|
protected String |
printMethodArgs(List<Type> args,
boolean varArgs,
Locale locale)
Converts a set of method argument types into their corresponding
localized string representation.
|
String |
visit(Symbol s,
Locale locale)
Get a localized string representation for a given symbol.
|
String |
visit(Type t,
Locale locale)
Get a localized string representation for a given type.
|
String |
visitAnnotatedType(Type.AnnotatedType t,
Locale locale) |
String |
visitArrayType(Type.ArrayType t,
Locale locale) |
String |
visitCapturedType(Type.CapturedType t,
Locale locale) |
String |
visitClassSymbol(Symbol.ClassSymbol sym,
Locale locale) |
String |
visitClassType(Type.ClassType t,
Locale locale) |
String |
visitErrorType(Type.ErrorType t,
Locale locale) |
String |
visitForAll(Type.ForAll t,
Locale locale) |
String |
visitMethodSymbol(Symbol.MethodSymbol s,
Locale locale) |
String |
visitMethodType(Type.MethodType t,
Locale locale) |
String |
visitOperatorSymbol(Symbol.OperatorSymbol s,
Locale locale) |
String |
visitPackageSymbol(Symbol.PackageSymbol s,
Locale locale) |
String |
visitPackageType(Type.PackageType t,
Locale locale) |
String |
visitSymbol(Symbol s,
Locale locale) |
String |
visitSymbols(List<Symbol> ts,
Locale locale)
* Get a localized string representation for all the symbols in the input list.
|
String |
visitType(Type t,
Locale locale) |
String |
visitTypes(List<Type> ts,
Locale locale)
Get a localized string representation for all the types in the input list.
|
String |
visitTypeSymbol(Symbol.TypeSymbol s,
Locale locale) |
String |
visitTypeVar(Type.TypeVar t,
Locale locale) |
String |
visitUndetVar(Type.UndetVar t,
Locale locale) |
String |
visitVarSymbol(Symbol.VarSymbol s,
Locale locale) |
String |
visitWildcardType(Type.WildcardType t,
Locale locale) |
protected abstract String localize(Locale locale, String key, Object... args)
locale
- the locale in which the string is to be renderedkey
- the key corresponding to the message to be displayedargs
- a list of optional argumentsprotected abstract String capturedVarId(Type.CapturedType t, Locale locale)
t
- the captured type for which an id is to be retrievedlocale
- locale settingspublic static Printer createStandardPrinter(Messages messages)
messages
- Messages class to be used for i18npublic String visitTypes(List<Type> ts, Locale locale)
ts
- types to be displayedlocale
- the locale in which the string is to be renderedpublic String visitSymbols(List<Symbol> ts, Locale locale)
ts
- symbols to be displayedlocale
- the locale in which the string is to be renderedpublic String visit(Type t, Locale locale)
t
- type to be displayedlocale
- the locale in which the string is to be renderedpublic String visit(Symbol s, Locale locale)
s
- symbol to be displayedlocale
- the locale in which the string is to be renderedpublic String visitCapturedType(Type.CapturedType t, Locale locale)
visitCapturedType
in interface Type.Visitor<String,Locale>
public String visitForAll(Type.ForAll t, Locale locale)
visitForAll
in interface Type.Visitor<String,Locale>
public String visitUndetVar(Type.UndetVar t, Locale locale)
visitUndetVar
in interface Type.Visitor<String,Locale>
public String visitArrayType(Type.ArrayType t, Locale locale)
visitArrayType
in interface Type.Visitor<String,Locale>
public String visitClassType(Type.ClassType t, Locale locale)
visitClassType
in interface Type.Visitor<String,Locale>
public String visitMethodType(Type.MethodType t, Locale locale)
visitMethodType
in interface Type.Visitor<String,Locale>
public String visitPackageType(Type.PackageType t, Locale locale)
visitPackageType
in interface Type.Visitor<String,Locale>
public String visitWildcardType(Type.WildcardType t, Locale locale)
visitWildcardType
in interface Type.Visitor<String,Locale>
public String visitErrorType(Type.ErrorType t, Locale locale)
visitErrorType
in interface Type.Visitor<String,Locale>
public String visitTypeVar(Type.TypeVar t, Locale locale)
visitTypeVar
in interface Type.Visitor<String,Locale>
public String visitAnnotatedType(Type.AnnotatedType t, Locale locale)
visitAnnotatedType
in interface Type.Visitor<String,Locale>
public String visitType(Type t, Locale locale)
visitType
in interface Type.Visitor<String,Locale>
protected String className(Type.ClassType t, boolean longform, Locale locale)
t
- the type of the class whose name is to be renderedlongform
- if set, the class' fullname is displayed - if unset the
short name is chosen (w/o package)locale
- the locale in which the string is to be renderedprotected String printMethodArgs(List<Type> args, boolean varArgs, Locale locale)
args
- arguments to be renderedvarArgs
- if true, the last method argument is regarded as a vararglocale
- the locale in which the string is to be renderedpublic String visitClassSymbol(Symbol.ClassSymbol sym, Locale locale)
visitClassSymbol
in interface Symbol.Visitor<String,Locale>
public String visitMethodSymbol(Symbol.MethodSymbol s, Locale locale)
visitMethodSymbol
in interface Symbol.Visitor<String,Locale>
public String visitOperatorSymbol(Symbol.OperatorSymbol s, Locale locale)
visitOperatorSymbol
in interface Symbol.Visitor<String,Locale>
public String visitPackageSymbol(Symbol.PackageSymbol s, Locale locale)
visitPackageSymbol
in interface Symbol.Visitor<String,Locale>
public String visitTypeSymbol(Symbol.TypeSymbol s, Locale locale)
visitTypeSymbol
in interface Symbol.Visitor<String,Locale>
public String visitVarSymbol(Symbol.VarSymbol s, Locale locale)
visitVarSymbol
in interface Symbol.Visitor<String,Locale>
public String visitSymbol(Symbol s, Locale locale)
visitSymbol
in interface Symbol.Visitor<String,Locale>
Copyright © 2015. All rights reserved.