< prev index next >

src/jdk.compiler/share/classes/com/sun/tools/javac/code/Printer.java

Print this page




  40 import static com.sun.tools.javac.code.TypeTag.CLASS;
  41 import static com.sun.tools.javac.code.TypeTag.FORALL;
  42 
  43 /**
  44  * A combined type/symbol visitor for generating non-trivial localized string
  45  * representation of types and symbols.
  46  *
  47  * <p><b>This is NOT part of any supported API.
  48  * If you write code that depends on this, you do so at your own risk.
  49  * This code and its internal interfaces are subject to change or
  50  * deletion without notice.</b>
  51  */
  52 public abstract class Printer implements Type.Visitor<String, Locale>, Symbol.Visitor<String, Locale> {
  53 
  54     List<Type> seenCaptured = List.nil();
  55     static final int PRIME = 997;  // largest prime less than 1000
  56 
  57     protected Printer() { }
  58 
  59     /**
  60      * This method should be overriden in order to provide proper i18n support.
  61      *
  62      * @param locale the locale in which the string is to be rendered
  63      * @param key the key corresponding to the message to be displayed
  64      * @param args a list of optional arguments
  65      * @return localized string representation
  66      */
  67     protected abstract String localize(Locale locale, String key, Object... args);
  68 
  69     /**
  70      * Maps a captured type into an unique identifier.
  71      *
  72      * @param t the captured type for which an id is to be retrieved
  73      * @param locale locale settings
  74      * @return unique id representing this captured type
  75      */
  76     protected abstract String capturedVarId(CapturedType t, Locale locale);
  77 
  78     /**
  79      * Create a printer with default i18n support provided by Messages. By default,
  80      * captured types ids are generated using hashcode.




  40 import static com.sun.tools.javac.code.TypeTag.CLASS;
  41 import static com.sun.tools.javac.code.TypeTag.FORALL;
  42 
  43 /**
  44  * A combined type/symbol visitor for generating non-trivial localized string
  45  * representation of types and symbols.
  46  *
  47  * <p><b>This is NOT part of any supported API.
  48  * If you write code that depends on this, you do so at your own risk.
  49  * This code and its internal interfaces are subject to change or
  50  * deletion without notice.</b>
  51  */
  52 public abstract class Printer implements Type.Visitor<String, Locale>, Symbol.Visitor<String, Locale> {
  53 
  54     List<Type> seenCaptured = List.nil();
  55     static final int PRIME = 997;  // largest prime less than 1000
  56 
  57     protected Printer() { }
  58 
  59     /**
  60      * This method should be overridden in order to provide proper i18n support.
  61      *
  62      * @param locale the locale in which the string is to be rendered
  63      * @param key the key corresponding to the message to be displayed
  64      * @param args a list of optional arguments
  65      * @return localized string representation
  66      */
  67     protected abstract String localize(Locale locale, String key, Object... args);
  68 
  69     /**
  70      * Maps a captured type into an unique identifier.
  71      *
  72      * @param t the captured type for which an id is to be retrieved
  73      * @param locale locale settings
  74      * @return unique id representing this captured type
  75      */
  76     protected abstract String capturedVarId(CapturedType t, Locale locale);
  77 
  78     /**
  79      * Create a printer with default i18n support provided by Messages. By default,
  80      * captured types ids are generated using hashcode.


< prev index next >