java_previews_430.java (1541B)
1 // VIM_TEST_SETUP let g:java_syntax_previews = [430] 2 3 4 5 class StringTemplateTests // JDK 21+ (--enable-preview --release 21). 6 { 7 static { 8 System.out.println(STR.""" 9 " 10 \{"\"\""} 11 \{"\"\""}\{"\u005c\u0022"} 12 \{"\"\""}\{"\u005c\u0022"}" 13 \{"\"\""}\"\{"\u005c\u0022\u005c\u0022"} 14 \{"\"\""}\"\{"\"\""}\{"\u005c\u0022"} 15 \{"\"\""}\"\{"\"\""}\"" 16 \{"\"\""}\"\{"\"\""}\""\""""); 17 18 String woof = "Woof", dog = "dog", fox = "fox"; 19 20 String s1 = STR 21 ."A quick brown \{fox} jumps over the lazy \{dog}"; 22 String s2 = STR.process(StringTemplate.RAW 23 ."\"\{woof}\s!\""); 24 String s3 = STR.""" 25 A\s\ 26 quick \ 27 brown\s\ 28 \{fox} \ 29 jumps\s\ 30 over \ 31 the\s\ 32 lazy \ 33 \{dog}"""; 34 String s4 = STR.process(StringTemplate.RAW 35 . 36 """ 37 "\{woof}\s!\""""); 38 String s5 = java.util.FormatProcessor.FMT 39 . "%-14s\{"A\s" + STR . "quick" + "brown"}%s\{fox} " 40 + java.util.FormatProcessor.FMT 41 . "%-20s\{"jumps\sover the\s" 42 + STR . "lazy"}%s\{dog}"; 43 String s6 = STR.""" 44 \"\{ // A nested comment. 45 (new java.util.function.Function<String, String>() { 46 public String apply(String bay) { return bay; }; 47 }).apply(woof) 48 }\s!\""""; 49 String s7 = java.util.FormatProcessor.FMT 50 .""" 51 %-14s\{STR.""" 52 A\s\ 53 \{ "quick" } \ 54 brown"""}\ 55 %s\{ fox } \ 56 %-20s\{STR.""" 57 jumps\s\ 58 over \ 59 the\s\ 60 \{ "lazy" } """}\ 61 %s\{ dog }"""; 62 String s8 = STR 63 ."\"\{ /* A nested comment. */ 64 ((java.util.function.Function<String, String>) bay -> bay) 65 .apply(woof) 66 }\s!\""; 67 } 68 }