PROPOSAL: Multiline strings
    rssh at gradsoft.com.ua 
    rssh at gradsoft.com.ua
       
    Sat Feb 28 19:46:05 PST 2009
    
    
  
AUTHOR(s): Ruslan Shevchenko
OVERVIEW:
 FEATURE SUMMARY:
   add multiline strings to java language.
 MAJOR ADVANTAGE:
   Possibility more elegant to write code part of codes in other languages,
  such as sql constructions or rendering of html components.
 MAJOR DISADVANTAGE
   I don't know
 ALTERNATIVES:
  use String "+=" operator.
  using groovy instead java in utility classes.
EXAMPLES
SIMPLE EXAMPLE:
  StringBuilder sb = new StringBuilder();
  sb.append("""select a from Area a, CountryCodes cc
                where
                   cc.isoCode='UA'
                  and
                   a.owner = cc.country
              """);
  if (question.getAreaName()!=null) {
     sb.append("""and
                  a.name like ?
               """);
     sqlParams.setString(++i,question.getAreaName());
  }
 instead:
  StringBuilder sb = new StringBuilder();
  sb.append("select a from Area a, CountryCodes cc\n");
  sb.append("where cc.isoCode='UA'\n");
  sb.append("and a.owner=cc.country'\n");
  if (question.getAreaName()!=null) {
     sb.append("and a.name like ?");
     sqlParams.setString(++i,question.getAreaName());
  }
DETAILS:
  Multiline strings are part of program text, which begin and ends
 by three double quotes. (as in groovy and scala) Text withing such
 brackets processed as multiline string with all rulles as normal Java
 string literals, except it can be multiline. After parsing multiline
 string is concatenation of lines with inserted value of system property
'line.separator' between thems.
COMPILATION:
 Multiline strings created and used in .class files exactly as ordinary
strings.
TESTING:
 Nothing special. add multiline strings to test-cases.
LIBRARY SUPPORT:
 None.
 (May be exists sence add simple template processing to standard library, but
  I think this is goal of next janguage iteration. Now exists many good
external
  frameworks, such as velocity: better wait and standartize support of
winner)
REFLECTIVE APIS: None
OTHER CHANGES: None
MIGRATION: None
COMPABILITY
 None
REFERENCES
 http://bugs.sun.com/view_bug.do?bug_id=4165111
    
    
More information about the coin-dev
mailing list