Skip to main content
added 1067 characters in body
Source Link
Basil Bourque
  • 1.1k
  • 9
  • 12

Text Blocks

Java 1515+ gained the Text Blocks feature. This feature is a revamp of the Raw String Literals feature discussed below.

See also: Does Java have support for multiline strings?

I will leave intact the outmoded content below as history. And I’ll add a mention of making your IDE aware of your SQL-within-Java.

Language-savvy strings

The IntelliJ IDE provides for language injections. See this article and video by Helen Scott. You can flag the embedded language by using either annotation or a comment.

Language injection works well with Java text blocks.

@Language ("SQL") 
String sql = """
    SELECT *
    FROM product_
    ;
    """;

IntelliJ will colorize the embedded language. And you can open a dedicated editor section to provide for language-appropriate editing.

Language injection works for SQL, JSON, RegExp, and more.

Other IDEs may provide a similar feature.


[Outmoded content below left intact as history.]

Raw String Literals

Work is underway to introduce raw string literals into the Java language. Along with that comes the multi-line strings desired in this Question.

JEP 326

See JEP 326: Raw String Literals.

Excerpts:

Add raw string literals to the Java programming language. A raw string literal can span multiple lines of source code and does not interpret escape sequences, such as \n, or Unicode escapes, of the form \uXXXX …

supply strings targeted for grammars other than Java, …

supply strings that span several lines of source without supplying special indicators for new lines.

Nesting SQL is one of the example use-cases given in the JEP.

Status update by Brian Goetz

See Raw string literals -- where we are, how we got here by Brian Goetz, 2018-03-27.

They are leaning towards using any number of backticks as the raw-string-literal starting-stopping delimiters. A single backtick would be most common, but use a number of them if the text value happens to contain backticks. So no escaping needed at all.

Excerpts:

… things have largely stabilized with raw string literals …

    String ss = `a multi-
     line-string`;

By the way, you may find the article, New Methods on Java Strings With JDK 11 by Dustin Marx to be interesting. It covers some new Unicode-savvy string-trimming methods being added to Java 11. These may be related to the eventual raw string literals feature.

Text Blocks

Java 15 gained the Text Blocks feature. This feature is a revamp of the Raw String Literals feature discussed below.

See also: Does Java have support for multiline strings?

I will leave intact the outmoded content below as history. And I’ll add a mention of making your IDE aware of your SQL-within-Java.

Language-savvy strings

The IntelliJ IDE provides for language injections. See this article and video by Helen Scott. You can flag the embedded language by using either annotation or a comment.

Language injection works well with Java text blocks.

@Language ("SQL") 
String sql = """
    SELECT *
    FROM product_
    ;
    """;

IntelliJ will colorize the embedded language. And you can open a dedicated editor section to provide for language-appropriate editing.

Language injection works for SQL, JSON, RegExp, and more.

Other IDEs may provide a similar feature.


[Outmoded content below left intact as history.]

Raw String Literals

Work is underway to introduce raw string literals into the Java language. Along with that comes the multi-line strings desired in this Question.

JEP 326

See JEP 326: Raw String Literals.

Excerpts:

Add raw string literals to the Java programming language. A raw string literal can span multiple lines of source code and does not interpret escape sequences, such as \n, or Unicode escapes, of the form \uXXXX …

supply strings targeted for grammars other than Java, …

supply strings that span several lines of source without supplying special indicators for new lines.

Nesting SQL is one of the example use-cases given in the JEP.

Status update by Brian Goetz

See Raw string literals -- where we are, how we got here by Brian Goetz, 2018-03-27.

They are leaning towards using any number of backticks as the raw-string-literal starting-stopping delimiters. A single backtick would be most common, but use a number of them if the text value happens to contain backticks. So no escaping needed at all.

Excerpts:

… things have largely stabilized with raw string literals …

    String ss = `a multi-
     line-string`;

By the way, you may find the article, New Methods on Java Strings With JDK 11 by Dustin Marx to be interesting. It covers some new Unicode-savvy string-trimming methods being added to Java 11. These may be related to the eventual raw string literals feature.

Text Blocks

Java 15+ gained the Text Blocks feature. This feature is a revamp of the Raw String Literals feature discussed below.

See also: Does Java have support for multiline strings?

I will leave intact the outmoded content below as history. And I’ll add a mention of making your IDE aware of your SQL-within-Java.

Language-savvy strings

The IntelliJ IDE provides for language injections. See this article and video by Helen Scott. You can flag the embedded language by using either annotation or a comment.

Language injection works well with Java text blocks.

@Language ("SQL") 
String sql = """
    SELECT *
    FROM product_
    ;
    """;

IntelliJ will colorize the embedded language. And you can open a dedicated editor section to provide for language-appropriate editing.

Language injection works for SQL, JSON, RegExp, and more.

Other IDEs may provide a similar feature.


[Outmoded content below left intact as history.]

Raw String Literals

Work is underway to introduce raw string literals into the Java language. Along with that comes the multi-line strings desired in this Question.

JEP 326

See JEP 326: Raw String Literals.

Excerpts:

Add raw string literals to the Java programming language. A raw string literal can span multiple lines of source code and does not interpret escape sequences, such as \n, or Unicode escapes, of the form \uXXXX …

supply strings targeted for grammars other than Java, …

supply strings that span several lines of source without supplying special indicators for new lines.

Nesting SQL is one of the example use-cases given in the JEP.

Status update by Brian Goetz

See Raw string literals -- where we are, how we got here by Brian Goetz, 2018-03-27.

They are leaning towards using any number of backticks as the raw-string-literal starting-stopping delimiters. A single backtick would be most common, but use a number of them if the text value happens to contain backticks. So no escaping needed at all.

Excerpts:

… things have largely stabilized with raw string literals …

    String ss = `a multi-
     line-string`;

By the way, you may find the article, New Methods on Java Strings With JDK 11 by Dustin Marx to be interesting. It covers some new Unicode-savvy string-trimming methods being added to Java 11. These may be related to the eventual raw string literals feature.

added 1067 characters in body
Source Link
Basil Bourque
  • 1.1k
  • 9
  • 12

Text Blocks

Java 15 gained the Text Blocks feature. This feature is a revamp of the Raw String Literals feature discussed below.

See also: Does Java have support for multiline strings?

I will leave intact the outmoded content below as history. And I’ll add a mention of making your IDE aware of your SQL-within-Java.

Language-savvy strings

The IntelliJ IDE provides for language injections. See this article and video by Helen Scott. You can flag the embedded language by using either annotation or a comment.

Language injection works well with Java text blocks.

@Language ("SQL") 
String sql = """
    SELECT *
    FROM product_
    ;
    """;

IntelliJ will colorize the embedded language. And you can open a dedicated editor section to provide for language-appropriate editing.

Language injection works for SQL, JSON, RegExp, and more.

Other IDEs may provide a similar feature.


[Outmoded content below left intact as history.]

Raw String Literals

Work is underway to introduce raw string literals into the Java language. Along with that comes the multi-line strings desired in this Question.

JEP 326

See JEP 326: Raw String Literals.

Excerpts:

Add raw string literals to the Java programming language. A raw string literal can span multiple lines of source code and does not interpret escape sequences, such as \n, or Unicode escapes, of the form \uXXXX …

supply strings targeted for grammars other than Java, …

supply strings that span several lines of source without supplying special indicators for new lines.

Nesting SQL is one of the example use-cases given in the JEP.

Status update by Brian Goetz

See Raw string literals -- where we are, how we got here by Brian Goetz, 2018-03-27.

They are leaning towards using any number of backticks as the raw-string-literal starting-stopping delimiters. A single backtick would be most common, but use a number of them if the text value happens to contain backticks. So no escaping needed at all.

Excerpts:

… things have largely stabilized with raw string literals …

    String ss = `a multi-
     line-string`;

By the way, you may find the article, New Methods on Java Strings With JDK 11 by Dustin Marx to be interesting. It covers some new Unicode-savvy string-trimming methods being added to Java 11. These may be related to the eventual raw string literals feature.

Java 15 gained the Text Blocks feature. This feature is a revamp of the Raw String Literals feature discussed below.

See also: Does Java have support for multiline strings?

I will leave intact the outmoded content below as history. And I’ll add a mention of making your IDE aware of your SQL-within-Java.

Language-savvy strings

The IntelliJ IDE provides for language injections. See this article and video by Helen Scott. You can flag the embedded language by using either annotation or a comment.

@Language ("SQL") 
String sql = """
    SELECT * FROM product_ ;
    """;

IntelliJ will colorize the embedded language. And you can open a dedicated editor section to provide for language-appropriate editing.

Other IDEs may provide a similar feature.


Raw String Literals

Work is underway to introduce raw string literals into the Java language. Along with that comes the multi-line strings desired in this Question.

JEP 326

See JEP 326: Raw String Literals.

Excerpts:

Add raw string literals to the Java programming language. A raw string literal can span multiple lines of source code and does not interpret escape sequences, such as \n, or Unicode escapes, of the form \uXXXX …

supply strings targeted for grammars other than Java, …

supply strings that span several lines of source without supplying special indicators for new lines.

Nesting SQL is one of the example use-cases given in the JEP.

Status update by Brian Goetz

See Raw string literals -- where we are, how we got here by Brian Goetz, 2018-03-27.

They are leaning towards using any number of backticks as the raw-string-literal starting-stopping delimiters. A single backtick would be most common, but use a number of them if the text value happens to contain backticks. So no escaping needed at all.

Excerpts:

… things have largely stabilized with raw string literals …

    String ss = `a multi-
     line-string`;

By the way, you may find the article, New Methods on Java Strings With JDK 11 by Dustin Marx to be interesting. It covers some new Unicode-savvy string-trimming methods being added to Java 11. These may be related to the eventual raw string literals feature.

Text Blocks

Java 15 gained the Text Blocks feature. This feature is a revamp of the Raw String Literals feature discussed below.

See also: Does Java have support for multiline strings?

I will leave intact the outmoded content below as history. And I’ll add a mention of making your IDE aware of your SQL-within-Java.

Language-savvy strings

The IntelliJ IDE provides for language injections. See this article and video by Helen Scott. You can flag the embedded language by using either annotation or a comment.

Language injection works well with Java text blocks.

@Language ("SQL") 
String sql = """
    SELECT *
    FROM product_
    ;
    """;

IntelliJ will colorize the embedded language. And you can open a dedicated editor section to provide for language-appropriate editing.

Language injection works for SQL, JSON, RegExp, and more.

Other IDEs may provide a similar feature.


[Outmoded content below left intact as history.]

Raw String Literals

Work is underway to introduce raw string literals into the Java language. Along with that comes the multi-line strings desired in this Question.

JEP 326

See JEP 326: Raw String Literals.

Excerpts:

Add raw string literals to the Java programming language. A raw string literal can span multiple lines of source code and does not interpret escape sequences, such as \n, or Unicode escapes, of the form \uXXXX …

supply strings targeted for grammars other than Java, …

supply strings that span several lines of source without supplying special indicators for new lines.

Nesting SQL is one of the example use-cases given in the JEP.

Status update by Brian Goetz

See Raw string literals -- where we are, how we got here by Brian Goetz, 2018-03-27.

They are leaning towards using any number of backticks as the raw-string-literal starting-stopping delimiters. A single backtick would be most common, but use a number of them if the text value happens to contain backticks. So no escaping needed at all.

Excerpts:

… things have largely stabilized with raw string literals …

    String ss = `a multi-
     line-string`;

By the way, you may find the article, New Methods on Java Strings With JDK 11 by Dustin Marx to be interesting. It covers some new Unicode-savvy string-trimming methods being added to Java 11. These may be related to the eventual raw string literals feature.

added 1067 characters in body
Source Link
Basil Bourque
  • 1.1k
  • 9
  • 12
 

Update Java 15 gained the Text Blocks feature. This feature is a revamp of the Raw String Literals feature discussed below.

See also: https://stackoverflow.com/questions/878573/does-java-have-support-for-multiline-strings/50155171#50155171Does Java have support for multiline strings?

I will leave intact the outmoded content below as history. And I’ll add a mention of making your IDE aware of your SQL-within-Java.

Language-savvy strings

The IntelliJ IDE provides for language injections. See this article and video by Helen Scott. You can flag the embedded language by using either annotation or a comment.

@Language ("SQL") 
String sql = """
    SELECT * FROM product_ ;
    """;

IntelliJ will colorize the embedded language. And you can open a dedicated editor section to provide for language-appropriate editing.

Other IDEs may provide a similar feature.


Raw String Literals

Work is underway to introduce raw string literals into the Java language. Along with that comes the multi-line strings desired in this Question.

JEP 326

See JEP 326: Raw String Literals.

Excerpts:

Add raw string literals to the Java programming language. A raw string literal can span multiple lines of source code and does not interpret escape sequences, such as \n, or Unicode escapes, of the form \uXXXX …

supply strings targeted for grammars other than Java, …

supply strings that span several lines of source without supplying special indicators for new lines.

Nesting SQL is one of the example use-cases given in the JEP.

Status update by Brian Goetz

See Raw string literals -- where we are, how we got here by Brian Goetz, 2018-03-27.

They are leaning towards using any number of backticks as the raw-string-literal starting-stopping delimiters. A single backtick would be most common, but use a number of them if the text value happens to contain backticks. So no escaping needed at all.

Excerpts:

… things have largely stabilized with raw string literals …

    String ss = `a multi-
     line-string`;

By the way, you may find the article, New Methods on Java Strings With JDK 11 by Dustin Marx to be interesting. It covers some new Unicode-savvy string-trimming methods being added to Java 11. These may be related to the eventual raw string literals feature.

Update: https://stackoverflow.com/questions/878573/does-java-have-support-for-multiline-strings/50155171#50155171


Raw String Literals

Work is underway to introduce raw string literals into the Java language. Along with that comes the multi-line strings desired in this Question.

JEP 326

See JEP 326: Raw String Literals.

Excerpts:

Add raw string literals to the Java programming language. A raw string literal can span multiple lines of source code and does not interpret escape sequences, such as \n, or Unicode escapes, of the form \uXXXX …

supply strings targeted for grammars other than Java, …

supply strings that span several lines of source without supplying special indicators for new lines.

Nesting SQL is one of the example use-cases given in the JEP.

Status update by Brian Goetz

See Raw string literals -- where we are, how we got here by Brian Goetz, 2018-03-27.

They are leaning towards using any number of backticks as the raw-string-literal starting-stopping delimiters. A single backtick would be most common, but use a number of them if the text value happens to contain backticks. So no escaping needed at all.

Excerpts:

… things have largely stabilized with raw string literals …

    String ss = `a multi-
     line-string`;

By the way, you may find the article, New Methods on Java Strings With JDK 11 by Dustin Marx to be interesting. It covers some new Unicode-savvy string-trimming methods being added to Java 11. These may be related to the eventual raw string literals feature.

 

Java 15 gained the Text Blocks feature. This feature is a revamp of the Raw String Literals feature discussed below.

See also: Does Java have support for multiline strings?

I will leave intact the outmoded content below as history. And I’ll add a mention of making your IDE aware of your SQL-within-Java.

Language-savvy strings

The IntelliJ IDE provides for language injections. See this article and video by Helen Scott. You can flag the embedded language by using either annotation or a comment.

@Language ("SQL") 
String sql = """
    SELECT * FROM product_ ;
    """;

IntelliJ will colorize the embedded language. And you can open a dedicated editor section to provide for language-appropriate editing.

Other IDEs may provide a similar feature.


Raw String Literals

Work is underway to introduce raw string literals into the Java language. Along with that comes the multi-line strings desired in this Question.

JEP 326

See JEP 326: Raw String Literals.

Excerpts:

Add raw string literals to the Java programming language. A raw string literal can span multiple lines of source code and does not interpret escape sequences, such as \n, or Unicode escapes, of the form \uXXXX …

supply strings targeted for grammars other than Java, …

supply strings that span several lines of source without supplying special indicators for new lines.

Nesting SQL is one of the example use-cases given in the JEP.

Status update by Brian Goetz

See Raw string literals -- where we are, how we got here by Brian Goetz, 2018-03-27.

They are leaning towards using any number of backticks as the raw-string-literal starting-stopping delimiters. A single backtick would be most common, but use a number of them if the text value happens to contain backticks. So no escaping needed at all.

Excerpts:

… things have largely stabilized with raw string literals …

    String ss = `a multi-
     line-string`;

By the way, you may find the article, New Methods on Java Strings With JDK 11 by Dustin Marx to be interesting. It covers some new Unicode-savvy string-trimming methods being added to Java 11. These may be related to the eventual raw string literals feature.

Source Link
Basil Bourque
  • 1.1k
  • 9
  • 12
Loading