equal
deleted
inserted
replaced
97 * is considered as ending with new line. |
97 * is considered as ending with new line. |
98 * |
98 * |
99 * @param contentBuilder content to test for newline character at the end |
99 * @param contentBuilder content to test for newline character at the end |
100 * @return true if the content ends with newline. |
100 * @return true if the content ends with newline. |
101 */ |
101 */ |
102 public boolean endsWithNewLine(StringBuilder contentBuilder) { |
102 protected boolean endsWithNewLine(StringBuilder contentBuilder) { |
103 return ((contentBuilder.length() == 0) || |
103 int contentLength = contentBuilder.length(); |
104 (contentBuilder.toString().endsWith(DocletConstants.NL))); |
104 if (contentLength == 0) { |
|
105 return true; |
|
106 } |
|
107 int nlLength = DocletConstants.NL.length(); |
|
108 if (contentLength < nlLength) { |
|
109 return false; |
|
110 } |
|
111 int contentIndex = contentLength - 1; |
|
112 int nlIndex = nlLength - 1; |
|
113 while (nlIndex >= 0) { |
|
114 if (contentBuilder.charAt(contentIndex) != DocletConstants.NL.charAt(nlIndex)) { |
|
115 return false; |
|
116 } |
|
117 contentIndex--; |
|
118 nlIndex--; |
|
119 } |
|
120 return true; |
105 } |
121 } |
106 } |
122 } |