コード例 #1
0
ファイル: Printer.java プロジェクト: karianna/jdk8_tl
 /**
  * Converts a class name into a (possibly localized) string. Anonymous inner classes gets
  * converted into a localized string.
  *
  * @param t the type of the class whose name is to be rendered
  * @param longform if set, the class' fullname is displayed - if unset the short name is chosen
  *     (w/o package)
  * @param locale the locale in which the string is to be rendered
  * @return localized string representation
  */
 protected String className(ClassType t, boolean longform, Locale locale) {
   Symbol sym = t.tsym;
   if (sym.name.length() == 0 && (sym.flags() & COMPOUND) != 0) {
     StringBuilder s = new StringBuilder(visit(t.supertype_field, locale));
     for (List<Type> is = t.interfaces_field; is.nonEmpty(); is = is.tail) {
       s.append("&");
       s.append(visit(is.head, locale));
     }
     return s.toString();
   } else if (sym.name.length() == 0) {
     String s;
     ClassType norm = (ClassType) t.tsym.type;
     if (norm == null) {
       s = localize(locale, "compiler.misc.anonymous.class", (Object) null);
     } else if (norm.interfaces_field != null && norm.interfaces_field.nonEmpty()) {
       s =
           localize(
               locale, "compiler.misc.anonymous.class", visit(norm.interfaces_field.head, locale));
     } else {
       s = localize(locale, "compiler.misc.anonymous.class", visit(norm.supertype_field, locale));
     }
     return s;
   } else if (longform) {
     return sym.getQualifiedName().toString();
   } else {
     return sym.name.toString();
   }
 }