public class TextBlockUtils {
// Basic text block
public static String getMultiLineText() {
return """
This is a
multi-line
text block
""";
}
// SQL query as text block
public static String getSelectQuery() {
return """
SELECT id, name, email
FROM users
WHERE status = 'ACTIVE'
ORDER BY name
""";
}
// JSON as text block
public static String getJsonExample() {
return """
{
"name": "John Doe",
"age": 30,
"city": "New York"
}
""";
}
// HTML template as text block
public static String getHtmlTemplate(String title, String content) {
return """
<html>
<head>
<title>%s</title>
</head>
<body>
<h1>%s</h1>
<p>%s</p>
</body>
</html>
""".formatted(title, title, content);
}
// Text block with escape sequences
public static String getTextWithEscapes() {
return """
Line 1
Line 2 with "quotes"
Line 3 with \n newline
""";
}
// Text block preserving formatting
public static String getFormattedCode() {
return """
public class Example {
public static void main(String[] args) {
System.out.println("Hello");
}
}
""";
}
}