23 * questions. |
23 * questions. |
24 */ |
24 */ |
25 |
25 |
26 package com.sun.tools.doclets.internal.toolkit; |
26 package com.sun.tools.doclets.internal.toolkit; |
27 |
27 |
|
28 import java.io.IOException; |
|
29 import java.io.StringWriter; |
|
30 import java.io.Writer; |
|
31 |
28 import com.sun.tools.doclets.internal.toolkit.util.*; |
32 import com.sun.tools.doclets.internal.toolkit.util.*; |
29 |
33 |
30 /** |
34 /** |
31 * A class to create content for javadoc output pages. |
35 * A class to create content for javadoc output pages. |
32 * |
36 * |
42 /** |
46 /** |
43 * Returns a string representation of the content. |
47 * Returns a string representation of the content. |
44 * |
48 * |
45 * @return string representation of the content |
49 * @return string representation of the content |
46 */ |
50 */ |
|
51 @Override |
47 public String toString() { |
52 public String toString() { |
48 StringBuilder contentBuilder = new StringBuilder(); |
53 StringWriter out = new StringWriter(); |
49 write(contentBuilder); |
54 try { |
50 return contentBuilder.toString(); |
55 write(out, true); |
|
56 } catch (IOException e) { |
|
57 // cannot happen from StringWriter |
|
58 throw new DocletAbortException(); |
|
59 } |
|
60 return out.toString(); |
51 } |
61 } |
52 |
62 |
53 /** |
63 /** |
54 * Adds content to the existing content. |
64 * Adds content to the existing content. |
55 * |
65 * |
63 * @param stringContent the string content to be added |
73 * @param stringContent the string content to be added |
64 */ |
74 */ |
65 public abstract void addContent(String stringContent); |
75 public abstract void addContent(String stringContent); |
66 |
76 |
67 /** |
77 /** |
68 * Writes content to a StringBuilder. |
78 * Writes content to a writer. |
69 * |
79 * |
70 */ |
80 */ |
71 public abstract void write(StringBuilder contentBuilder); |
81 public abstract boolean write(Writer writer, boolean atNewline) throws IOException ; |
72 |
82 |
73 /** |
83 /** |
74 * Returns true if the content is empty. |
84 * Returns true if the content is empty. |
75 * |
85 * |
76 * @return true if no content to be displayed else return false |
86 * @return true if no content to be displayed else return false |