gvsig-tools / org.gvsig.tools / library / trunk / org.gvsig.tools / org.gvsig.tools.util / org.gvsig.tools.util.impl / src / main / java / org / gvsig / htmlbuilder / impl / DefaultHTMLBuilder.java @ 1746
History | View | Annotate | Download (31.3 KB)
1 |
|
---|---|
2 |
package org.gvsig.htmlbuilder.impl; |
3 |
|
4 |
import java.awt.Color; |
5 |
import java.util.ArrayList; |
6 |
import java.util.Date; |
7 |
import java.util.LinkedHashMap; |
8 |
import java.util.List; |
9 |
import java.util.Map; |
10 |
import org.apache.commons.lang3.StringEscapeUtils; |
11 |
import org.apache.commons.lang3.StringUtils; |
12 |
import org.gvsig.htmlbuilder.HTMLBuilder; |
13 |
import org.gvsig.htmlbuilder.HTMLBuilder.HTMLColor; |
14 |
import org.gvsig.htmlbuilder.HTMLBuilder.HTMLComplexElement; |
15 |
import org.gvsig.htmlbuilder.HTMLBuilder.HTMLElement; |
16 |
import org.gvsig.htmlbuilder.HTMLBuilder.HTMLElementWithAttributes; |
17 |
import org.gvsig.htmlbuilder.HTMLBuilder.HTMLElementWithContents; |
18 |
|
19 |
/**
|
20 |
*
|
21 |
* @author jjdelcerro
|
22 |
*/
|
23 |
public class DefaultHTMLBuilder implements HTMLBuilder { |
24 |
|
25 |
public class CustomHTMLElement implements HTMLElement { |
26 |
|
27 |
private final String text; |
28 |
|
29 |
CustomHTMLElement(String text) {
|
30 |
this.text = text;
|
31 |
} |
32 |
|
33 |
@Override
|
34 |
public boolean allowContents() { |
35 |
return false; |
36 |
} |
37 |
|
38 |
@Override
|
39 |
public boolean allowAttributes() { |
40 |
return false; |
41 |
} |
42 |
|
43 |
@Override
|
44 |
public String toHTML() { |
45 |
return this.text; |
46 |
} |
47 |
|
48 |
@Override
|
49 |
public String toString() { |
50 |
return this.toHTML(); |
51 |
} |
52 |
|
53 |
} |
54 |
|
55 |
public class ContentsHTMLElement implements HTMLElementWithContents { |
56 |
private final List<HTMLElement>contents; |
57 |
|
58 |
public ContentsHTMLElement() {
|
59 |
this.contents = new ArrayList<>(); |
60 |
} |
61 |
|
62 |
@Override
|
63 |
public boolean allowContents() { |
64 |
return true; |
65 |
} |
66 |
|
67 |
@Override
|
68 |
public boolean allowAttributes() { |
69 |
return false; |
70 |
} |
71 |
|
72 |
@Override
|
73 |
public String toHTML() { |
74 |
StringBuilder builder = new StringBuilder(); |
75 |
for (HTMLElement content : this.contents) { |
76 |
builder.append(content.toHTML()); |
77 |
} |
78 |
return builder.toString();
|
79 |
} |
80 |
|
81 |
@Override
|
82 |
public String toString() { |
83 |
return this.toHTML(); |
84 |
} |
85 |
|
86 |
@Override
|
87 |
public HTMLElementWithContents contents(Object... values) { |
88 |
if( values == null ) { |
89 |
return this; |
90 |
} |
91 |
for (Object value : values) { |
92 |
if( value == null ) { |
93 |
continue;
|
94 |
} |
95 |
if( value instanceof HTMLElement ) { |
96 |
this.contents.add((HTMLElement) value);
|
97 |
} else {
|
98 |
this.contents.add(custom(value.toString()));
|
99 |
} |
100 |
} |
101 |
return this; |
102 |
} |
103 |
|
104 |
|
105 |
@Override
|
106 |
public List<HTMLElement> getContents() { |
107 |
return this.contents; |
108 |
} |
109 |
|
110 |
} |
111 |
|
112 |
public class DefaultHTMLElement implements HTMLComplexElement { |
113 |
|
114 |
private final String name; |
115 |
private final boolean allowContents; |
116 |
private final boolean allowAttributes; |
117 |
private Map<String,String> attributes; |
118 |
private Map<String,String> style; |
119 |
private ContentsHTMLElement contents;
|
120 |
|
121 |
@SuppressWarnings("OverridableMethodCallInConstructor") |
122 |
public DefaultHTMLElement(String name, |
123 |
boolean allowContents,
|
124 |
boolean allowAttributes,
|
125 |
Object... contents
|
126 |
) { |
127 |
this.name = name;
|
128 |
this.allowAttributes = allowAttributes;
|
129 |
this.allowContents = allowContents;
|
130 |
this.attributes = null; |
131 |
this.contents = null; |
132 |
if( this.allowContents ) { |
133 |
this.contents(contents);
|
134 |
} |
135 |
} |
136 |
|
137 |
@Override
|
138 |
public Map<String,String> getAttributes() { |
139 |
if( this.attributes==null ) { |
140 |
this.attributes = new LinkedHashMap<>(); |
141 |
} |
142 |
return this.attributes; |
143 |
} |
144 |
|
145 |
@Override
|
146 |
public Map<String,String> getStyle() { |
147 |
if( this.style==null ) { |
148 |
this.style = new LinkedHashMap<>(); |
149 |
} |
150 |
return this.style; |
151 |
} |
152 |
|
153 |
@Override
|
154 |
public List<HTMLElement> getContents() { |
155 |
if( this.contents==null ) { |
156 |
this.contents = new ContentsHTMLElement(); |
157 |
} |
158 |
return this.contents.getContents(); |
159 |
} |
160 |
|
161 |
@Override
|
162 |
public HTMLComplexElement set(String name, String value) { |
163 |
if( !this.allowAttributes()) { |
164 |
throw new RuntimeException("The element '"+this.name+"' don't allow attributes."); |
165 |
} |
166 |
this.getAttributes().put(name, value);
|
167 |
return this; |
168 |
} |
169 |
|
170 |
@Override
|
171 |
public HTMLComplexElement set(String name) { |
172 |
return set(name, (String)null); |
173 |
} |
174 |
|
175 |
@Override
|
176 |
public HTMLComplexElement set(String name, int value) { |
177 |
return set(name, String.valueOf(value)); |
178 |
} |
179 |
|
180 |
@Override
|
181 |
public HTMLComplexElement set(String name, double value) { |
182 |
return set(name, String.valueOf(value)); |
183 |
} |
184 |
|
185 |
@Override
|
186 |
public HTMLComplexElement set(String name, HTMLColor value) { |
187 |
return set(name, value.toHTML());
|
188 |
} |
189 |
|
190 |
@Override
|
191 |
public HTMLComplexElement style(String name, String value) { |
192 |
if( !this.allowAttributes()) { |
193 |
throw new RuntimeException("The element '"+this.name+"' don't allow attributes."); |
194 |
} |
195 |
this.getStyle().put(name, value);
|
196 |
return this; |
197 |
} |
198 |
|
199 |
@Override
|
200 |
public HTMLComplexElement style(String name, int value) { |
201 |
return style(name, String.valueOf(value)); |
202 |
} |
203 |
|
204 |
@Override
|
205 |
public HTMLComplexElement style(String name, double value) { |
206 |
return style(name, String.valueOf(value)); |
207 |
} |
208 |
|
209 |
@Override
|
210 |
public HTMLComplexElement style(String name, HTMLColor value) { |
211 |
return style(name, value.toHTML());
|
212 |
} |
213 |
|
214 |
@Override
|
215 |
public HTMLComplexElement contents(Object... values) { |
216 |
if( values == null ) { |
217 |
return this; |
218 |
} |
219 |
if( !this.allowContents() ) { |
220 |
throw new RuntimeException("The element '"+this.name+"' don't allow contents."); |
221 |
} |
222 |
for (Object value : values) { |
223 |
if( value == null ) { |
224 |
continue;
|
225 |
} |
226 |
if( value instanceof HTMLElement ) { |
227 |
this.getContents().add((HTMLElement) value);
|
228 |
} else {
|
229 |
this.getContents().add(custom(value.toString()));
|
230 |
} |
231 |
} |
232 |
return this; |
233 |
} |
234 |
|
235 |
@Override
|
236 |
public boolean allowContents() { |
237 |
return this.allowContents; |
238 |
} |
239 |
|
240 |
@Override
|
241 |
public boolean allowAttributes() { |
242 |
return this.allowAttributes; |
243 |
} |
244 |
|
245 |
@Override
|
246 |
public String toHTML() { |
247 |
StringBuilder builder = new StringBuilder(); |
248 |
builder.append("<");
|
249 |
builder.append(this.name);
|
250 |
if( this.attributes!=null ) { |
251 |
for (Map.Entry<String, String> entry : this.attributes.entrySet()) { |
252 |
builder.append(" ");
|
253 |
builder.append(entry.getKey()); |
254 |
if( entry.getValue()!=null ) { |
255 |
builder.append("=\"");
|
256 |
builder.append(StringEscapeUtils.escapeHtml4(entry.getValue())); |
257 |
builder.append("\"");
|
258 |
} |
259 |
} |
260 |
} |
261 |
if( this.style!=null ) { |
262 |
builder.append(" style=\"");
|
263 |
for (Map.Entry<String, String> entry : this.style.entrySet()) { |
264 |
builder.append(entry.getKey()); |
265 |
builder.append(":");
|
266 |
builder.append(StringEscapeUtils.escapeHtml4(entry.getValue())); |
267 |
builder.append(" ");
|
268 |
} |
269 |
builder.append("\"");
|
270 |
} |
271 |
if( this.contents!=null ) { |
272 |
builder.append(">\n");
|
273 |
builder.append(this.contents.toHTML());
|
274 |
builder.append("</");
|
275 |
builder.append(this.name);
|
276 |
builder.append(">\n");
|
277 |
} else {
|
278 |
builder.append("/>\n");
|
279 |
} |
280 |
return builder.toString();
|
281 |
} |
282 |
|
283 |
@Override
|
284 |
public String toString() { |
285 |
return this.toHTML(); |
286 |
} |
287 |
|
288 |
} |
289 |
|
290 |
public class DefaultHTMLColor implements HTMLColor { |
291 |
|
292 |
private String color = "white"; |
293 |
|
294 |
public DefaultHTMLColor(String color) { |
295 |
this.color = color;
|
296 |
} |
297 |
|
298 |
public DefaultHTMLColor(int r, int g, int b) { |
299 |
this("rgb("+r+","+g+","+b+")"); |
300 |
} |
301 |
|
302 |
public DefaultHTMLColor(Color color) { |
303 |
this(color.getRed(), color.getGreen(), color.getBlue());
|
304 |
} |
305 |
|
306 |
@Override
|
307 |
public boolean allowContents() { |
308 |
return false; |
309 |
} |
310 |
|
311 |
@Override
|
312 |
public boolean allowAttributes() { |
313 |
return false; |
314 |
} |
315 |
|
316 |
@Override
|
317 |
public String toHTML() { |
318 |
return this.color; |
319 |
} |
320 |
|
321 |
@Override
|
322 |
public String toString() { |
323 |
return this.color; |
324 |
} |
325 |
|
326 |
|
327 |
} |
328 |
|
329 |
@Override
|
330 |
public HTMLElement custom(String value) { |
331 |
return new CustomHTMLElement(value); |
332 |
} |
333 |
|
334 |
@Override
|
335 |
public HTMLElement plain(String value) { |
336 |
return new CustomHTMLElement(StringEscapeUtils.escapeHtml4(value)); |
337 |
} |
338 |
|
339 |
@Override
|
340 |
public HTMLElement plainWithNl(String value) { |
341 |
return new CustomHTMLElement(StringEscapeUtils.escapeHtml4(value).replace("\n", "<br>\n")); |
342 |
} |
343 |
|
344 |
@Override
|
345 |
public HTMLElement contents(HTMLElement... values) {
|
346 |
return new ContentsHTMLElement().contents((Object[]) values); |
347 |
} |
348 |
|
349 |
@Override
|
350 |
public HTMLColor color(Color color) { |
351 |
return new DefaultHTMLColor(color); |
352 |
} |
353 |
|
354 |
@Override
|
355 |
public HTMLColor color(int r, int g, int b) { |
356 |
return new DefaultHTMLColor(r, g, b); |
357 |
} |
358 |
|
359 |
@Override
|
360 |
public HTMLColor color(String color) { |
361 |
return new DefaultHTMLColor(color); |
362 |
} |
363 |
|
364 |
@Override
|
365 |
public HTMLComplexElement a(String link, Object... contents) { |
366 |
return new DefaultHTMLElement("a", true, true, contents); |
367 |
} |
368 |
|
369 |
@Override
|
370 |
public HTMLComplexElement a(Object... contents) { |
371 |
return new DefaultHTMLElement("a", true, true, contents); |
372 |
} |
373 |
|
374 |
@Override
|
375 |
public HTMLComplexElement abbr(Object... contents) { |
376 |
return new DefaultHTMLElement("abbr", true, true, contents); |
377 |
} |
378 |
|
379 |
@Override
|
380 |
public HTMLComplexElement acronym(Object... contents) { |
381 |
return new DefaultHTMLElement("acronym", true, true, contents); |
382 |
} |
383 |
|
384 |
@Override
|
385 |
public HTMLComplexElement address(Object... contents) { |
386 |
return new DefaultHTMLElement("address", true, true, contents); |
387 |
} |
388 |
|
389 |
@Override
|
390 |
public HTMLComplexElement area(Object... contents) { |
391 |
return new DefaultHTMLElement("area", true, true, contents); |
392 |
} |
393 |
|
394 |
@Override
|
395 |
public HTMLComplexElement article(Object... contents) { |
396 |
return new DefaultHTMLElement("article", true, true, contents); |
397 |
} |
398 |
|
399 |
@Override
|
400 |
public HTMLComplexElement aside(Object... contents) { |
401 |
return new DefaultHTMLElement("aside", true, true, contents); |
402 |
} |
403 |
|
404 |
@Override
|
405 |
public HTMLComplexElement b(Object... contents) { |
406 |
return new DefaultHTMLElement("b", true, true, contents); |
407 |
} |
408 |
|
409 |
@Override
|
410 |
public HTMLElementWithAttributes base() {
|
411 |
return new DefaultHTMLElement("base", false, true); |
412 |
} |
413 |
|
414 |
@Override
|
415 |
public HTMLElementWithAttributes basefont() {
|
416 |
return new DefaultHTMLElement("basefont", false, true); |
417 |
} |
418 |
|
419 |
@Override
|
420 |
public HTMLComplexElement bdi(Object... contents) { |
421 |
return new DefaultHTMLElement("bdi", true, true, contents); |
422 |
} |
423 |
|
424 |
@Override
|
425 |
public HTMLComplexElement bdo(Object... contents) { |
426 |
return new DefaultHTMLElement("bdo", true, true, contents); |
427 |
} |
428 |
|
429 |
@Deprecated
|
430 |
@Override
|
431 |
public HTMLElementWithContents big(Object... contents) { |
432 |
return new DefaultHTMLElement("big", true, false, contents); |
433 |
} |
434 |
|
435 |
@Override
|
436 |
public HTMLComplexElement blockquote(Object... contents) { |
437 |
return new DefaultHTMLElement("blockquote", true, true, contents); |
438 |
} |
439 |
|
440 |
@Override
|
441 |
public HTMLComplexElement body(Object... contents) { |
442 |
return new DefaultHTMLElement("body", true, true, contents); |
443 |
} |
444 |
|
445 |
@Override
|
446 |
public HTMLElement br() {
|
447 |
return new DefaultHTMLElement("br", false, false); |
448 |
} |
449 |
|
450 |
@Override
|
451 |
public HTMLComplexElement button(Object... contents) { |
452 |
return new DefaultHTMLElement("button", true, true, contents); |
453 |
} |
454 |
|
455 |
@Override
|
456 |
public HTMLComplexElement canvas(Object... contents) { |
457 |
return new DefaultHTMLElement("canvas", true, true, contents); |
458 |
} |
459 |
|
460 |
@Override
|
461 |
public HTMLComplexElement caption(Object... contents) { |
462 |
return new DefaultHTMLElement("caption", true, true, contents); |
463 |
} |
464 |
|
465 |
@Override
|
466 |
@Deprecated
|
467 |
public HTMLElementWithContents center(Object... contents) { |
468 |
return new DefaultHTMLElement("center", true, false, contents); |
469 |
} |
470 |
|
471 |
@Override
|
472 |
public HTMLComplexElement cite(Object... contents) { |
473 |
return new DefaultHTMLElement("cite", true, true, contents); |
474 |
} |
475 |
|
476 |
@Override
|
477 |
public HTMLComplexElement code(Object... contents) { |
478 |
return new DefaultHTMLElement("code", true, true, contents); |
479 |
} |
480 |
|
481 |
@Override
|
482 |
public HTMLElementWithAttributes col() {
|
483 |
return new DefaultHTMLElement("col", false, true); |
484 |
} |
485 |
|
486 |
@Override
|
487 |
public HTMLComplexElement colgroup(Object... contents) { |
488 |
return new DefaultHTMLElement("colgroup", true, true, contents); |
489 |
} |
490 |
|
491 |
@Override
|
492 |
public HTMLComplexElement data(Object... contents) { |
493 |
return new DefaultHTMLElement("data", true, true, contents); |
494 |
} |
495 |
|
496 |
@Override
|
497 |
public HTMLComplexElement datalist(Object... contents) { |
498 |
return new DefaultHTMLElement("datalist", true, true, contents); |
499 |
} |
500 |
|
501 |
@Override
|
502 |
public HTMLComplexElement dd(Object... contents) { |
503 |
return new DefaultHTMLElement("dd", true, true, contents); |
504 |
} |
505 |
|
506 |
@Override
|
507 |
public HTMLComplexElement del(Object... contents) { |
508 |
return new DefaultHTMLElement("del", true, true, contents); |
509 |
} |
510 |
|
511 |
@Override
|
512 |
public HTMLComplexElement details(Object... contents) { |
513 |
return new DefaultHTMLElement("details", true, true, contents); |
514 |
} |
515 |
|
516 |
@Override
|
517 |
public HTMLComplexElement dfn(Object... contents) { |
518 |
return new DefaultHTMLElement("dfn", true, true, contents); |
519 |
} |
520 |
|
521 |
@Override
|
522 |
public HTMLComplexElement dialog(Object... contents) { |
523 |
return new DefaultHTMLElement("dialog", true, true, contents); |
524 |
} |
525 |
|
526 |
@Override
|
527 |
public HTMLElementWithContents dir(Object... contents) { |
528 |
return new DefaultHTMLElement("dir", true, false, contents); |
529 |
} |
530 |
|
531 |
@Override
|
532 |
public HTMLComplexElement div(Object... contents) { |
533 |
return new DefaultHTMLElement("div", true, true, contents); |
534 |
} |
535 |
|
536 |
@Override
|
537 |
public HTMLComplexElement dl(Object... contents) { |
538 |
return new DefaultHTMLElement("dl", true, true, contents); |
539 |
} |
540 |
|
541 |
@Override
|
542 |
public HTMLComplexElement dt(Object... contents) { |
543 |
return new DefaultHTMLElement("dt", true, true, contents); |
544 |
} |
545 |
|
546 |
@Override
|
547 |
public HTMLComplexElement em(Object... contents) { |
548 |
return new DefaultHTMLElement("em", true, true, contents); |
549 |
} |
550 |
|
551 |
@Override
|
552 |
public HTMLElementWithAttributes embed() {
|
553 |
return new DefaultHTMLElement("embed", false, true); |
554 |
} |
555 |
|
556 |
@Override
|
557 |
public HTMLComplexElement fieldset(Object... contents) { |
558 |
return new DefaultHTMLElement("fieldset", true, true, contents); |
559 |
} |
560 |
|
561 |
@Override
|
562 |
public HTMLComplexElement figcaption(Object... contents) { |
563 |
return new DefaultHTMLElement("figcaption", true, true, contents); |
564 |
} |
565 |
|
566 |
@Override
|
567 |
public HTMLComplexElement figure(Object... contents) { |
568 |
return new DefaultHTMLElement("figure", true, true, contents); |
569 |
} |
570 |
|
571 |
@Override
|
572 |
public HTMLComplexElement font(Object... contents) { |
573 |
return new DefaultHTMLElement("font", true, true, contents); |
574 |
} |
575 |
|
576 |
@Override
|
577 |
public HTMLComplexElement font(int size, HTMLColor color) { |
578 |
return this.font() |
579 |
.set(HTMLBuilder.size, size) |
580 |
.set(HTMLBuilder.color, color); |
581 |
} |
582 |
|
583 |
@Override
|
584 |
public HTMLComplexElement font(int size, HTMLColor color, String face, Object... contents) { |
585 |
return this.font(size, color).set(HTMLBuilder.face, face); |
586 |
} |
587 |
|
588 |
@Override
|
589 |
public HTMLComplexElement footer(Object... contents) { |
590 |
return new DefaultHTMLElement("footer", true, true, contents); |
591 |
} |
592 |
|
593 |
@Override
|
594 |
public HTMLComplexElement form(Object... contents) { |
595 |
return new DefaultHTMLElement("form", true, true, contents); |
596 |
} |
597 |
|
598 |
@Override
|
599 |
public HTMLComplexElement frame(Object... contents) { |
600 |
return new DefaultHTMLElement("frame", true, true, contents); |
601 |
} |
602 |
|
603 |
@Override
|
604 |
public HTMLComplexElement frameset(Object... contents) { |
605 |
return new DefaultHTMLElement("frameset", true, true, contents); |
606 |
} |
607 |
|
608 |
@Override
|
609 |
public HTMLComplexElement h1(Object... contents) { |
610 |
return new DefaultHTMLElement("h1", true, true, contents); |
611 |
} |
612 |
|
613 |
@Override
|
614 |
public HTMLComplexElement h2(Object... contents) { |
615 |
return new DefaultHTMLElement("h2", true, true, contents); |
616 |
} |
617 |
|
618 |
@Override
|
619 |
public HTMLComplexElement h3(Object... contents) { |
620 |
return new DefaultHTMLElement("h3", true, true, contents); |
621 |
} |
622 |
|
623 |
@Override
|
624 |
public HTMLComplexElement h4(Object... contents) { |
625 |
return new DefaultHTMLElement("h4", true, true, contents); |
626 |
} |
627 |
|
628 |
@Override
|
629 |
public HTMLComplexElement h5(Object... contents) { |
630 |
return new DefaultHTMLElement("h5", true, true, contents); |
631 |
} |
632 |
|
633 |
@Override
|
634 |
public HTMLComplexElement h6(Object... contents) { |
635 |
return new DefaultHTMLElement("h6", true, true, contents); |
636 |
} |
637 |
|
638 |
@Override
|
639 |
public HTMLComplexElement head(Object... contents) { |
640 |
return new DefaultHTMLElement("head", true, true, contents); |
641 |
} |
642 |
|
643 |
@Override
|
644 |
public HTMLComplexElement header(Object... contents) { |
645 |
return new DefaultHTMLElement("header", true, true, contents); |
646 |
} |
647 |
|
648 |
@Override
|
649 |
public HTMLComplexElement hr(Object... contents) { |
650 |
return new DefaultHTMLElement("hr", true, true, contents); |
651 |
} |
652 |
|
653 |
@Override
|
654 |
public HTMLComplexElement html(Object... contents) { |
655 |
return new DefaultHTMLElement("html", true, true, contents); |
656 |
} |
657 |
|
658 |
@Override
|
659 |
public HTMLComplexElement i(Object... contents) { |
660 |
return new DefaultHTMLElement("i", true, true, contents); |
661 |
} |
662 |
|
663 |
@Override
|
664 |
public HTMLComplexElement iframe(Object... contents) { |
665 |
return new DefaultHTMLElement("iframe", true, true, contents); |
666 |
} |
667 |
|
668 |
@Override
|
669 |
public HTMLElementWithAttributes img() {
|
670 |
return new DefaultHTMLElement("img", false, true); |
671 |
} |
672 |
|
673 |
@Override
|
674 |
public HTMLElementWithAttributes input(Object... contents) { |
675 |
return new DefaultHTMLElement("input", true, true, contents); |
676 |
} |
677 |
|
678 |
@Override
|
679 |
public HTMLComplexElement ins(Object... contents) { |
680 |
return new DefaultHTMLElement("ins", true, true, contents); |
681 |
} |
682 |
|
683 |
@Override
|
684 |
public HTMLComplexElement kbd(Object... contents) { |
685 |
return new DefaultHTMLElement("kbd", true, true, contents); |
686 |
} |
687 |
|
688 |
@Override
|
689 |
public HTMLComplexElement label(Object... contents) { |
690 |
return new DefaultHTMLElement("label", true, true, contents); |
691 |
} |
692 |
|
693 |
@Override
|
694 |
public HTMLComplexElement legend(Object... contents) { |
695 |
return new DefaultHTMLElement("legend", true, true, contents); |
696 |
} |
697 |
|
698 |
@Override
|
699 |
public HTMLComplexElement li(Object... contents) { |
700 |
return new DefaultHTMLElement("li", true, true, contents); |
701 |
} |
702 |
|
703 |
@Override
|
704 |
public HTMLElementWithAttributes link() {
|
705 |
return new DefaultHTMLElement("ins", false, true); |
706 |
} |
707 |
|
708 |
@Override
|
709 |
public HTMLElementWithAttributes link(String rel, String type, String href) { |
710 |
return link()
|
711 |
.set(HTMLBuilder.rel, rel) |
712 |
.set(HTMLBuilder.type, type) |
713 |
.set(HTMLBuilder.href, href); |
714 |
} |
715 |
|
716 |
@Override
|
717 |
public HTMLComplexElement main(Object... contents) { |
718 |
return new DefaultHTMLElement("main", true, true, contents); |
719 |
} |
720 |
|
721 |
@Override
|
722 |
public HTMLComplexElement map(Object... contents) { |
723 |
return new DefaultHTMLElement("map", true, true, contents); |
724 |
} |
725 |
|
726 |
@Override
|
727 |
public HTMLComplexElement mark(Object... contents) { |
728 |
return new DefaultHTMLElement("mark", true, true, contents); |
729 |
} |
730 |
|
731 |
@Override
|
732 |
public HTMLElementWithAttributes meta() {
|
733 |
return new DefaultHTMLElement("meta", false, true); |
734 |
} |
735 |
|
736 |
@Override
|
737 |
public HTMLElementWithAttributes meta(String charset) { |
738 |
return mark().set(HTMLBuilder.charset, charset);
|
739 |
} |
740 |
|
741 |
@Override
|
742 |
public HTMLElementWithAttributes meta(String name, String content) { |
743 |
return mark()
|
744 |
.set(HTMLBuilder.name, name) |
745 |
.set(HTMLBuilder.content, content); |
746 |
} |
747 |
|
748 |
@Override
|
749 |
public HTMLComplexElement meter(Object... contents) { |
750 |
return new DefaultHTMLElement("meter", true, true, contents); |
751 |
} |
752 |
|
753 |
@Override
|
754 |
public HTMLComplexElement nav(Object... contents) { |
755 |
return new DefaultHTMLElement("nav", true, true, contents); |
756 |
} |
757 |
|
758 |
@Override
|
759 |
public HTMLElementWithContents noframes(Object... contents) { |
760 |
return new DefaultHTMLElement("noframes", true, false, contents); |
761 |
} |
762 |
|
763 |
@Override
|
764 |
public HTMLElementWithContents noscript(Object... contents) { |
765 |
return new DefaultHTMLElement("noscript", true, false, contents); |
766 |
} |
767 |
|
768 |
@Override
|
769 |
public HTMLComplexElement object(Object... contents) { |
770 |
return new DefaultHTMLElement("object", true, true, contents); |
771 |
} |
772 |
|
773 |
@Override
|
774 |
public HTMLComplexElement ol(Object... contents) { |
775 |
return new DefaultHTMLElement("ol", true, true, contents); |
776 |
} |
777 |
|
778 |
@Override
|
779 |
public HTMLComplexElement optgroup(Object... contents) { |
780 |
return new DefaultHTMLElement("optgroup", true, true, contents); |
781 |
} |
782 |
|
783 |
@Override
|
784 |
public HTMLComplexElement option(Object... contents) { |
785 |
return new DefaultHTMLElement("option", true, true, contents); |
786 |
} |
787 |
|
788 |
@Override
|
789 |
public HTMLComplexElement output(Object... contents) { |
790 |
return new DefaultHTMLElement("output", true, true, contents); |
791 |
} |
792 |
|
793 |
@Override
|
794 |
public HTMLComplexElement p(Object... contents) { |
795 |
return new DefaultHTMLElement("p", true, true, contents); |
796 |
} |
797 |
|
798 |
@Override
|
799 |
public HTMLElementWithAttributes param() {
|
800 |
return new DefaultHTMLElement("param", false, true); |
801 |
} |
802 |
|
803 |
@Override
|
804 |
public HTMLComplexElement pre(Object... contents) { |
805 |
return new DefaultHTMLElement("pre", true, true, contents); |
806 |
} |
807 |
|
808 |
@Override
|
809 |
public HTMLComplexElement progress(Object... contents) { |
810 |
return new DefaultHTMLElement("progress", true, true, contents); |
811 |
} |
812 |
|
813 |
@Override
|
814 |
public HTMLComplexElement q(Object... contents) { |
815 |
return new DefaultHTMLElement("q", true, true, contents); |
816 |
} |
817 |
|
818 |
@Override
|
819 |
public HTMLComplexElement rp(Object... contents) { |
820 |
return new DefaultHTMLElement("rp", true, true, contents); |
821 |
} |
822 |
|
823 |
@Override
|
824 |
public HTMLComplexElement rt(Object... contents) { |
825 |
return new DefaultHTMLElement("rt", true, true, contents); |
826 |
} |
827 |
|
828 |
@Override
|
829 |
public HTMLComplexElement ruby(Object... contents) { |
830 |
return new DefaultHTMLElement("ruby", true, true, contents); |
831 |
} |
832 |
|
833 |
@Override
|
834 |
public HTMLComplexElement s(Object... contents) { |
835 |
return new DefaultHTMLElement("s", true, true, contents); |
836 |
} |
837 |
|
838 |
@Override
|
839 |
public HTMLComplexElement samp(Object... contents) { |
840 |
return new DefaultHTMLElement("samp", true, true, contents); |
841 |
} |
842 |
|
843 |
@Override
|
844 |
public HTMLComplexElement script(Object... contents) { |
845 |
return new DefaultHTMLElement("script", true, true, contents); |
846 |
} |
847 |
|
848 |
@Override
|
849 |
public HTMLComplexElement section(Object... contents) { |
850 |
return new DefaultHTMLElement("section", true, true, contents); |
851 |
} |
852 |
|
853 |
@Override
|
854 |
public HTMLComplexElement select(Object... contents) { |
855 |
return new DefaultHTMLElement("select", true, true, contents); |
856 |
} |
857 |
|
858 |
@Override
|
859 |
public HTMLComplexElement small(Object... contents) { |
860 |
return new DefaultHTMLElement("small", true, true, contents); |
861 |
} |
862 |
|
863 |
@Override
|
864 |
public HTMLComplexElement source(Object... contents) { |
865 |
return new DefaultHTMLElement("source", true, true, contents); |
866 |
} |
867 |
|
868 |
@Override
|
869 |
public HTMLComplexElement span(Object... contents) { |
870 |
return new DefaultHTMLElement("span", true, true, contents); |
871 |
} |
872 |
|
873 |
@Override
|
874 |
public HTMLElementWithContents strike(Object... contents) { |
875 |
return new DefaultHTMLElement("strike", true, false); |
876 |
} |
877 |
|
878 |
@Override
|
879 |
public HTMLComplexElement strong(Object... contents) { |
880 |
return new DefaultHTMLElement("strong", true, true, contents); |
881 |
} |
882 |
|
883 |
@Override
|
884 |
public HTMLComplexElement style(Object... contents) { |
885 |
return new DefaultHTMLElement("style", true, true, contents); |
886 |
} |
887 |
|
888 |
@Override
|
889 |
public HTMLComplexElement sub(Object... contents) { |
890 |
return new DefaultHTMLElement("sub", true, true, contents); |
891 |
} |
892 |
|
893 |
@Override
|
894 |
public HTMLComplexElement summary(Object... contents) { |
895 |
return new DefaultHTMLElement("summary", true, true, contents); |
896 |
} |
897 |
|
898 |
@Override
|
899 |
public HTMLComplexElement sup(Object... contents) { |
900 |
return new DefaultHTMLElement("sup", true, true, contents); |
901 |
} |
902 |
|
903 |
@Override
|
904 |
public HTMLComplexElement svg(Object... contents) { |
905 |
return new DefaultHTMLElement("svg", true, true, contents); |
906 |
} |
907 |
|
908 |
@Override
|
909 |
public HTMLComplexElement table(Object... contents) { |
910 |
return new DefaultHTMLElement("table", true, true, contents); |
911 |
} |
912 |
|
913 |
@Override
|
914 |
public HTMLComplexElement table(int border, int cellpadding, int cellspacing) { |
915 |
return table()
|
916 |
.set(HTMLBuilder.border, border) |
917 |
.set(HTMLBuilder.cellpadding, cellpadding) |
918 |
.set(HTMLBuilder.cellspacing, cellspacing); |
919 |
} |
920 |
|
921 |
@Override
|
922 |
public HTMLComplexElement table(int border, int cellpadding, int cellspacing, int widthpercent) { |
923 |
return table(border, cellpadding, cellspacing)
|
924 |
.set(HTMLBuilder.width, String.valueOf(widthpercent)+"%"); |
925 |
} |
926 |
|
927 |
@Override
|
928 |
public HTMLComplexElement tbody(Object... contents) { |
929 |
return new DefaultHTMLElement("tbody", true, true, contents); |
930 |
} |
931 |
|
932 |
@Override
|
933 |
public HTMLComplexElement td(Object... contents) { |
934 |
return new DefaultHTMLElement("td", true, true, contents); |
935 |
} |
936 |
|
937 |
@Override
|
938 |
public HTMLComplexElement td(boolean wrap, int colspan) { |
939 |
return td(wrap,colspan, null); |
940 |
} |
941 |
|
942 |
@Override
|
943 |
public HTMLComplexElement td(boolean wrap, int colspan, String valign) { |
944 |
HTMLComplexElement x = td(); |
945 |
if( !wrap ) {
|
946 |
x.set(HTMLBuilder.nowrap); |
947 |
} |
948 |
if( colspan>1 ) { |
949 |
x.set(HTMLBuilder.colspan, colspan); |
950 |
} |
951 |
if( !StringUtils.isEmpty(valign) ) {
|
952 |
x.set(HTMLBuilder.valign, valign); |
953 |
} |
954 |
return x;
|
955 |
} |
956 |
|
957 |
@Override
|
958 |
public HTMLComplexElement template(Object... contents) { |
959 |
return new DefaultHTMLElement("template", true, true, contents); |
960 |
} |
961 |
|
962 |
@Override
|
963 |
public HTMLComplexElement textarea(Object... contents) { |
964 |
return new DefaultHTMLElement("textarea", true, true, contents); |
965 |
} |
966 |
|
967 |
@Override
|
968 |
public HTMLComplexElement textarea(int rows, int cols) { |
969 |
return textarea()
|
970 |
.set(HTMLBuilder.rows, rows) |
971 |
.set(HTMLBuilder.cols, cols) |
972 |
; |
973 |
} |
974 |
|
975 |
@Override
|
976 |
public HTMLComplexElement textarea(int rows, int cols, int maxlength) { |
977 |
return textarea(rows, cols)
|
978 |
.set(HTMLBuilder.maxlength, maxlength) |
979 |
; |
980 |
} |
981 |
|
982 |
@Override
|
983 |
public HTMLComplexElement tfoot(Object... contents) { |
984 |
return new DefaultHTMLElement("tfoot", true, true, contents); |
985 |
} |
986 |
|
987 |
@Override
|
988 |
public HTMLComplexElement th(Object... contents) { |
989 |
return new DefaultHTMLElement("th", true, true, contents); |
990 |
} |
991 |
|
992 |
@Override
|
993 |
public HTMLComplexElement thead(Object... contents) { |
994 |
return new DefaultHTMLElement("thead", true, true, contents); |
995 |
} |
996 |
|
997 |
@Override
|
998 |
public HTMLComplexElement time(Object... contents) { |
999 |
return new DefaultHTMLElement("time", true, true, contents); |
1000 |
} |
1001 |
|
1002 |
@Override
|
1003 |
public HTMLComplexElement time(String datetime) { |
1004 |
return time().set(HTMLBuilder.datetime, datetime);
|
1005 |
} |
1006 |
|
1007 |
@Override
|
1008 |
public HTMLComplexElement time(Date datetime) { |
1009 |
return time().set(HTMLBuilder.datetime,
|
1010 |
datetime.getYear() + "-" + datetime.getMonth() +"-" + datetime.getDay() + " " + |
1011 |
datetime.getHours() +":"+ datetime.getMinutes()
|
1012 |
); |
1013 |
} |
1014 |
|
1015 |
@Override
|
1016 |
public HTMLComplexElement title(Object... contents) { |
1017 |
return new DefaultHTMLElement("title", true, true, contents); |
1018 |
} |
1019 |
|
1020 |
@Override
|
1021 |
public HTMLComplexElement tr(Object... contents) { |
1022 |
return new DefaultHTMLElement("tr", true, true, contents); |
1023 |
} |
1024 |
|
1025 |
@Override
|
1026 |
public HTMLComplexElement tr(String valign) { |
1027 |
return tr().set(HTMLBuilder.valign, valign);
|
1028 |
} |
1029 |
|
1030 |
@Override
|
1031 |
public HTMLComplexElement tr(HTMLColor color){
|
1032 |
return tr().set(HTMLBuilder.bgcolor, color);
|
1033 |
} |
1034 |
|
1035 |
@Override
|
1036 |
public HTMLComplexElement tr(String valign, HTMLColor color) { |
1037 |
return tr(color).set(HTMLBuilder.valign, valign);
|
1038 |
} |
1039 |
|
1040 |
@Override
|
1041 |
public HTMLComplexElement track(Object... contents) { |
1042 |
return new DefaultHTMLElement("track", true, true, contents); |
1043 |
} |
1044 |
|
1045 |
@Override
|
1046 |
public HTMLElementWithContents tt(Object... contents) { |
1047 |
return new DefaultHTMLElement("tt", true, false, contents); |
1048 |
} |
1049 |
|
1050 |
@Override
|
1051 |
public HTMLComplexElement u(Object... contents) { |
1052 |
return new DefaultHTMLElement("u", true, true, contents); |
1053 |
} |
1054 |
|
1055 |
@Override
|
1056 |
public HTMLComplexElement ul(Object... contents) { |
1057 |
return new DefaultHTMLElement("ul", true, true, contents); |
1058 |
} |
1059 |
|
1060 |
@Override
|
1061 |
public HTMLComplexElement var(Object... contents) { |
1062 |
return new DefaultHTMLElement("var", true, true, contents); |
1063 |
} |
1064 |
|
1065 |
@Override
|
1066 |
public HTMLComplexElement video(Object... contents) { |
1067 |
return new DefaultHTMLElement("video", true, true, contents); |
1068 |
} |
1069 |
|
1070 |
@Override
|
1071 |
public HTMLComplexElement wbr(Object... contents) { |
1072 |
return new DefaultHTMLElement("wbr", true, true, contents); |
1073 |
} |
1074 |
|
1075 |
} |