Beispiel #1
0
 public void visitLiteral(JCLiteral tree) {
   try {
     switch (tree.typetag) {
       case TypeTags.INT:
         print(tree.value.toString());
         break;
       case TypeTags.LONG:
         print(tree.value + "L");
         break;
       case TypeTags.FLOAT:
         print(tree.value + "F");
         break;
       case TypeTags.DOUBLE:
         print(tree.value.toString());
         break;
       case TypeTags.CHAR:
         print(
             "\'" + Convert.quote(String.valueOf((char) ((Number) tree.value).intValue())) + "\'");
         break;
       case TypeTags.BOOLEAN:
         print(((Number) tree.value).intValue() == 1 ? "true" : "false");
         break;
       case TypeTags.BOT:
         print("null");
         break;
       default:
         print("\"" + Convert.quote(tree.value.toString()) + "\"");
         break;
     }
   } catch (IOException e) {
     throw new UncheckedIOException(e);
   }
 }
Beispiel #2
0
 /** Print string, replacing all non-ascii character with unicode escapes. */
 public void print(Object s) throws IOException {
   out.write(Convert.escapeUnicode(s.toString()));
 }