The duplication has been introduced when merging I08e1369e142bb19f42a8d7bbb5a7d062cc8533fc and I18adc63596f4657516ccc6d704a561924c79d445. The former should have been manually rebased. It also missed a copyright update in ApplyCommandTest. Change-Id: I18fe6108220f964524fb16b719604222aa7abee6tags/v2.0.0.201206130900-r
/* | /* | ||||
* Copyright (C) 2011, 2012, Tomasz Zarna <Tomasz.Zarna@pl.ibm.com> | |||||
* Copyright (C) 2011, 2012, IBM Corporation and others. | |||||
* and other copyright owners as documented in the project's IP log. | * and other copyright owners as documented in the project's IP log. | ||||
* | * | ||||
* This program and the accompanying materials are made available | * This program and the accompanying materials are made available |
StringBuilder sb = new StringBuilder(); | StringBuilder sb = new StringBuilder(); | ||||
final String eol = rt.size() == 0 | final String eol = rt.size() == 0 | ||||
|| (rt.size() == 1 && rt.isMissingNewlineAtEnd()) ? "\n" : rt | || (rt.size() == 1 && rt.isMissingNewlineAtEnd()) ? "\n" : rt | ||||
.getEOL(); | |||||
.getLineDelimiter(); | |||||
for (String l : newLines) { | for (String l : newLines) { | ||||
sb.append(l); | sb.append(l); | ||||
if (eol != null) | if (eol != null) |
else | else | ||||
return "\n"; | return "\n"; | ||||
} | } | ||||
/** | |||||
* Get the EOL chars for the first line. | |||||
* | |||||
* @since 2.0 | |||||
* @return the EOL chars or <code>null</code> | |||||
*/ | |||||
public String getEOL() { | |||||
int e = getEnd(0); | |||||
if (content.length > 1 && content[e - 2] == '\r' | |||||
&& content[e - 1] == '\n') | |||||
return "\r\n"; | |||||
if (content.length > 0 && content[e - 1] == '\n') | |||||
return "\n"; | |||||
if (content.length > 0 && content[e - 1] == '\r') | |||||
return "\r"; | |||||
return null; | |||||
} | |||||
} | } |