56 * Constructor to construct StringContent object with some initial content. |
56 * Constructor to construct StringContent object with some initial content. |
57 * |
57 * |
58 * @param initialContent initial content for the object |
58 * @param initialContent initial content for the object |
59 */ |
59 */ |
60 public StringContent(String initialContent) { |
60 public StringContent(String initialContent) { |
61 stringContent = new StringBuilder( |
61 stringContent = new StringBuilder(); |
62 Util.escapeHtmlChars(nullCheck(initialContent))); |
62 appendChars(initialContent); |
63 } |
63 } |
64 |
64 |
65 /** |
65 /** |
66 * This method is not supported by the class. |
66 * This method is not supported by the class. |
67 * |
67 * |
109 public boolean write(Writer out, boolean atNewline) throws IOException { |
109 public boolean write(Writer out, boolean atNewline) throws IOException { |
110 String s = stringContent.toString(); |
110 String s = stringContent.toString(); |
111 out.write(s); |
111 out.write(s); |
112 return s.endsWith(DocletConstants.NL); |
112 return s.endsWith(DocletConstants.NL); |
113 } |
113 } |
|
114 |
|
115 private void appendChars(String s) { |
|
116 for (int i = 0; i < s.length(); i++) { |
|
117 char ch = s.charAt(i); |
|
118 switch (ch) { |
|
119 case '<': stringContent.append("<"); break; |
|
120 case '>': stringContent.append(">"); break; |
|
121 case '&': stringContent.append("&"); break; |
|
122 default: stringContent.append(ch); break; |
|
123 } |
|
124 } |
|
125 } |
114 } |
126 } |