BrightSide Workbench Full Report + Source Code
org.turro.html.HTMLGenerator Class Reference
Inheritance diagram for org.turro.html.HTMLGenerator:
Collaboration diagram for org.turro.html.HTMLGenerator:

Public Member Functions

 HTMLGenerator ()
 
 HTMLGenerator (Writer out)
 
String toString ()
 
void setOut (Writer out)
 
void setExtraAttributes (String extraAttributes)
 
HTMLGenerator doTag (String tag)
 
HTMLGenerator doTag (String tag, String attributes)
 
HTMLGenerator doTag (String tag, String[] attributes)
 
HTMLGenerator startTag (String tag)
 
HTMLGenerator startTag (String tag, String attributes)
 
HTMLGenerator startTag (String tag, String[] attributes)
 
HTMLGenerator startExtAnchor (String url, String hint)
 
HTMLGenerator startTargetAnchor (String url, String target, String hint)
 
HTMLGenerator startAnchor (String url, String hint)
 
HTMLGenerator startAnchor (String url, String hint, String cssClass)
 
HTMLGenerator startAnchor (String url, String hint, String cssClass, String onClick)
 
HTMLGenerator startTable (String attributes)
 
HTMLGenerator startTable (String[] attributes)
 
HTMLGenerator endTable ()
 
HTMLGenerator startTableRow (String attributes)
 
HTMLGenerator startTableRow (String[] attributes)
 
HTMLGenerator endTableRow ()
 
HTMLGenerator startTableCol (String attributes)
 
HTMLGenerator startTableCol (String[] attributes)
 
HTMLGenerator endTableCol ()
 
HTMLGenerator endTag ()
 
HTMLGenerator endTag (String tag)
 
HTMLGenerator endBeforeTag (String tag)
 
HTMLGenerator endAllTags ()
 
boolean checkTag (String tag)
 
HTMLGenerator write (String value)
 
HTMLGenerator writeNewLine ()
 
HTMLGenerator writeSeparator ()
 
HTMLGenerator writeHorizontalStrut (int pixels)
 
HTMLGenerator startJavaScript ()
 
HTMLGenerator endJavaScript ()
 
HTMLGenerator startCSS ()
 
HTMLGenerator endCSS ()
 
HTMLGenerator addCSSLink (String cssFile)
 
HTMLGenerator addJavaScriptLink (String jsFile)
 

Protected Attributes

Stack tags = new Stack()
 
Writer out = null
 

Detailed Description

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 33 of file HTMLGenerator.java.

Constructor & Destructor Documentation

◆ HTMLGenerator() [1/2]

org.turro.html.HTMLGenerator.HTMLGenerator ( )

Creates a new instance of HTMLGenerator

Definition at line 40 of file HTMLGenerator.java.

40  {
41  this.out = new StringWriter();
42  }

◆ HTMLGenerator() [2/2]

org.turro.html.HTMLGenerator.HTMLGenerator ( Writer  out)

Creates a new instance of HTMLGenerator

Definition at line 45 of file HTMLGenerator.java.

45  {
46  this.out = out;
47  }

Member Function Documentation

◆ addCSSLink()

HTMLGenerator org.turro.html.HTMLGenerator.addCSSLink ( String  cssFile)

Definition at line 266 of file HTMLGenerator.java.

266  {
267  return write("<link rel=\"stylesheet\" type=\"text/css\" href=\"" +
268  cssFile +
269  "\">");
270  }
HTMLGenerator write(String value)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ addJavaScriptLink()

HTMLGenerator org.turro.html.HTMLGenerator.addJavaScriptLink ( String  jsFile)

Definition at line 272 of file HTMLGenerator.java.

272  {
273  return write("<script type=\"text/javascript\" src=\"" +
274  jsFile +
275  "\"></script>");
276  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ checkTag()

boolean org.turro.html.HTMLGenerator.checkTag ( String  tag)

Definition at line 220 of file HTMLGenerator.java.

220  {
221  return tags.contains(tag);
222  }
Here is the caller graph for this function:

◆ doTag() [1/3]

HTMLGenerator org.turro.html.HTMLGenerator.doTag ( String  tag)

Definition at line 62 of file HTMLGenerator.java.

62  {
63  return doTag(tag, (String[]) null);
64  }
HTMLGenerator doTag(String tag)
Here is the caller graph for this function:

◆ doTag() [2/3]

HTMLGenerator org.turro.html.HTMLGenerator.doTag ( String  tag,
String  attributes 
)

Definition at line 66 of file HTMLGenerator.java.

66  {
67  return doTag(tag, new String[] { attributes });
68  }
Here is the call graph for this function:

◆ doTag() [3/3]

HTMLGenerator org.turro.html.HTMLGenerator.doTag ( String  tag,
String[]  attributes 
)

Definition at line 70 of file HTMLGenerator.java.

70  {
71  if(attributes != null) {
72  write("<" + tag);
73  for(int i = 0; i < attributes.length; i++) {
74  if(!Strings.isBlank(attributes[i])) {
75  write(" " + attributes[i]);
76  }
77  }
78  return write(" />");
79  }
80  else {
81  return write("<" + tag + " />");
82  }
83  }
Here is the call graph for this function:

◆ endAllTags()

HTMLGenerator org.turro.html.HTMLGenerator.endAllTags ( )

Definition at line 213 of file HTMLGenerator.java.

213  {
214  while(!tags.empty()) {
215  endTag();
216  }
217  return write("\n");
218  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ endBeforeTag()

HTMLGenerator org.turro.html.HTMLGenerator.endBeforeTag ( String  tag)

Definition at line 203 of file HTMLGenerator.java.

203  {
204  if(!checkTag(tag)) return this;
205  String tmp = null;
206  while(!tag.equals(tags.peek())) {
207  tmp = (String) tags.pop();
208  write("</" + tmp + ">");
209  }
210  return this;
211  }
boolean checkTag(String tag)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ endCSS()

HTMLGenerator org.turro.html.HTMLGenerator.endCSS ( )

Definition at line 262 of file HTMLGenerator.java.

262  {
263  return write("\n</style>\n");
264  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ endJavaScript()

HTMLGenerator org.turro.html.HTMLGenerator.endJavaScript ( )

Definition at line 254 of file HTMLGenerator.java.

254  {
255  return write("\n</script>\n");
256  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ endTable()

HTMLGenerator org.turro.html.HTMLGenerator.endTable ( )

Definition at line 154 of file HTMLGenerator.java.

154  {
155  return endTag("table");
156  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ endTableCol()

HTMLGenerator org.turro.html.HTMLGenerator.endTableCol ( )

Definition at line 184 of file HTMLGenerator.java.

184  {
185  return endTag("td");
186  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ endTableRow()

HTMLGenerator org.turro.html.HTMLGenerator.endTableRow ( )

Definition at line 169 of file HTMLGenerator.java.

169  {
170  return endTag("tr");
171  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ endTag() [1/2]

HTMLGenerator org.turro.html.HTMLGenerator.endTag ( )

Definition at line 188 of file HTMLGenerator.java.

188  {
189  String tag = (String) tags.pop();
190  return write("</" + tag + ">");
191  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ endTag() [2/2]

HTMLGenerator org.turro.html.HTMLGenerator.endTag ( String  tag)

Definition at line 193 of file HTMLGenerator.java.

193  {
194  if(!checkTag(tag)) return this;
195  String tmp = null;
196  while(!tag.equals(tmp)) {
197  tmp = (String) tags.pop();
198  write("</" + tmp + ">");
199  }
200  return this;
201  }
Here is the call graph for this function:

◆ setExtraAttributes()

void org.turro.html.HTMLGenerator.setExtraAttributes ( String  extraAttributes)

Definition at line 58 of file HTMLGenerator.java.

58  {
59  this.extraAttributes = extraAttributes;
60  }
Here is the caller graph for this function:

◆ setOut()

void org.turro.html.HTMLGenerator.setOut ( Writer  out)

Definition at line 54 of file HTMLGenerator.java.

54  {
55  this.out = out;
56  }
Here is the caller graph for this function:

◆ startAnchor() [1/3]

HTMLGenerator org.turro.html.HTMLGenerator.startAnchor ( String  url,
String  hint 
)

Definition at line 128 of file HTMLGenerator.java.

128  {
129  return startAnchor(url, hint, null, null);
130  }
HTMLGenerator startAnchor(String url, String hint)
Here is the caller graph for this function:

◆ startAnchor() [2/3]

HTMLGenerator org.turro.html.HTMLGenerator.startAnchor ( String  url,
String  hint,
String  cssClass 
)

Definition at line 132 of file HTMLGenerator.java.

132  {
133  return startAnchor(url, hint, cssClass, null);
134  }
Here is the call graph for this function:

◆ startAnchor() [3/3]

HTMLGenerator org.turro.html.HTMLGenerator.startAnchor ( String  url,
String  hint,
String  cssClass,
String  onClick 
)

Definition at line 136 of file HTMLGenerator.java.

136  {
137  return startTag("a", new String[] {
138  "href='" + url + "'",
139  (hint != null ? "title=\"" + hint + "\"" : ""),
140  (hint != null ? "alt=\"" + hint + "\"" : ""),
141  (cssClass != null ? "class='" + cssClass + "'" : ""),
142  (onClick != null ? "onclick=\"" + onClick + "\"" : "")
143  });
144  }
HTMLGenerator startTag(String tag)
Here is the call graph for this function:

◆ startCSS()

HTMLGenerator org.turro.html.HTMLGenerator.startCSS ( )

Definition at line 258 of file HTMLGenerator.java.

258  {
259  return write("\n<style type='text/css'>\n");
260  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ startExtAnchor()

HTMLGenerator org.turro.html.HTMLGenerator.startExtAnchor ( String  url,
String  hint 
)

Definition at line 113 of file HTMLGenerator.java.

113  {
114  return startTargetAnchor(url, "_blank", hint);
115  }
HTMLGenerator startTargetAnchor(String url, String target, String hint)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ startJavaScript()

HTMLGenerator org.turro.html.HTMLGenerator.startJavaScript ( )

Definition at line 250 of file HTMLGenerator.java.

250  {
251  return write("\n<script language='JavaScript' type='text/javascript'>\n");
252  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ startTable() [1/2]

HTMLGenerator org.turro.html.HTMLGenerator.startTable ( String  attributes)

Definition at line 146 of file HTMLGenerator.java.

146  {
147  return startTable(new String[] { attributes });
148  }
HTMLGenerator startTable(String attributes)
Here is the caller graph for this function:

◆ startTable() [2/2]

HTMLGenerator org.turro.html.HTMLGenerator.startTable ( String[]  attributes)

Definition at line 150 of file HTMLGenerator.java.

150  {
151  return startTag("table", attributes);
152  }
Here is the call graph for this function:

◆ startTableCol() [1/2]

HTMLGenerator org.turro.html.HTMLGenerator.startTableCol ( String  attributes)

Definition at line 173 of file HTMLGenerator.java.

173  {
174  return startTableCol(new String[] { attributes });
175  }
HTMLGenerator startTableCol(String attributes)
Here is the caller graph for this function:

◆ startTableCol() [2/2]

HTMLGenerator org.turro.html.HTMLGenerator.startTableCol ( String[]  attributes)

Definition at line 177 of file HTMLGenerator.java.

177  {
178  if(!checkTag("tr")) {
179  startTableRow("");
180  }
181  return startTag("td", attributes);
182  }
HTMLGenerator startTableRow(String attributes)
Here is the call graph for this function:

◆ startTableRow() [1/2]

HTMLGenerator org.turro.html.HTMLGenerator.startTableRow ( String  attributes)

Definition at line 158 of file HTMLGenerator.java.

158  {
159  return startTableRow(new String[] { attributes });
160  }
Here is the caller graph for this function:

◆ startTableRow() [2/2]

HTMLGenerator org.turro.html.HTMLGenerator.startTableRow ( String[]  attributes)

Definition at line 162 of file HTMLGenerator.java.

162  {
163  if(!checkTag("table")) {
164  startTable("");
165  }
166  return startTag("tr", attributes);
167  }
Here is the call graph for this function:

◆ startTag() [1/3]

HTMLGenerator org.turro.html.HTMLGenerator.startTag ( String  tag)

Definition at line 85 of file HTMLGenerator.java.

85  {
86  return startTag(tag, (String[]) null);
87  }
Here is the caller graph for this function:

◆ startTag() [2/3]

HTMLGenerator org.turro.html.HTMLGenerator.startTag ( String  tag,
String  attributes 
)

Definition at line 89 of file HTMLGenerator.java.

89  {
90  return startTag(tag, new String[] { attributes });
91  }
Here is the call graph for this function:

◆ startTag() [3/3]

HTMLGenerator org.turro.html.HTMLGenerator.startTag ( String  tag,
String[]  attributes 
)

Definition at line 93 of file HTMLGenerator.java.

93  {
94  tags.push(tag);
95  if(attributes != null) {
96  write("<" + tag);
97  for(int i = 0; i < attributes.length; i++) {
98  if(!Strings.isBlank(attributes[i])) {
99  write(" " + attributes[i]);
100  }
101  }
102  if(!Strings.isBlank(extraAttributes)) {
103  write(" " + extraAttributes);
104  extraAttributes = null;
105  }
106  return write(">");
107  }
108  else {
109  return write("<" + tag + ">");
110  }
111  }
Here is the call graph for this function:

◆ startTargetAnchor()

HTMLGenerator org.turro.html.HTMLGenerator.startTargetAnchor ( String  url,
String  target,
String  hint 
)

Definition at line 117 of file HTMLGenerator.java.

117  {
118  return startTag("a", new String[] {
119  "href='" + url + "'",
120  (hint != null ? "title=\"" + hint + "\"" : ""),
121  (hint != null ? "alt=\"" + hint + "\"" : ""),
122  "target='" + target + "'",
123  "onclick='event.stopPropagation();'",
124  "class='newwindow'"
125  });
126  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ toString()

String org.turro.html.HTMLGenerator.toString ( )

Reimplemented in org.turro.html.HTMLComponent.

Definition at line 50 of file HTMLGenerator.java.

50  {
51  return out.toString().replaceAll("&(?![a-z]+;)", "&amp;");
52  }
Here is the caller graph for this function:

◆ write()

HTMLGenerator org.turro.html.HTMLGenerator.write ( String  value)

Reimplemented in org.turro.html.HTMLHelper.

Definition at line 224 of file HTMLGenerator.java.

224  {
225  try {
226  if (value == null) {
227  return this;
228  }
229  out.write(value);
230  } catch (IOException ex) {
231  Logger.getLogger(HTMLGenerator.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
232  }
233  return this;
234  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeHorizontalStrut()

HTMLGenerator org.turro.html.HTMLGenerator.writeHorizontalStrut ( int  pixels)

Definition at line 244 of file HTMLGenerator.java.

244  {
245  startTag("div", "style='height:" + pixels + "px'");
246  write("&nbsp;");
247  return endTag();
248  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeNewLine()

HTMLGenerator org.turro.html.HTMLGenerator.writeNewLine ( )

Definition at line 236 of file HTMLGenerator.java.

236  {
237  return doTag("br");
238  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeSeparator()

HTMLGenerator org.turro.html.HTMLGenerator.writeSeparator ( )

Definition at line 240 of file HTMLGenerator.java.

240  {
241  return doTag("hr");
242  }
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ out

Writer org.turro.html.HTMLGenerator.out = null
protected

Definition at line 35 of file HTMLGenerator.java.

◆ tags

Stack org.turro.html.HTMLGenerator.tags = new Stack()
protected

Definition at line 34 of file HTMLGenerator.java.


The documentation for this class was generated from the following file: