|
|
|
@ -1,9 +1,9 @@
|
|
|
|
|
package org.xbib.j2html.tags;
|
|
|
|
|
|
|
|
|
|
import org.xbib.j2html.attributes.Attr;
|
|
|
|
|
import org.xbib.j2html.attributes.Attribute;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Iterator;
|
|
|
|
|
import org.xbib.j2html.attributes.Attr;
|
|
|
|
|
import org.xbib.j2html.attributes.Attribute;
|
|
|
|
|
|
|
|
|
|
public abstract class Tag<T extends Tag<T>> extends DomContent implements IInstance<T> {
|
|
|
|
|
private final String tagName;
|
|
|
|
@ -32,7 +32,7 @@ public abstract class Tag<T extends Tag<T>> extends DomContent implements IInsta
|
|
|
|
|
* @param name the attribute
|
|
|
|
|
* @param value the attribute value
|
|
|
|
|
*/
|
|
|
|
|
boolean setAttribute(String name, String value) {
|
|
|
|
|
public boolean setAttribute(String name, String value) {
|
|
|
|
|
if (value == null) {
|
|
|
|
|
return attributes.add(new Attribute(name));
|
|
|
|
|
}
|
|
|
|
@ -146,68 +146,132 @@ public abstract class Tag<T extends Tag<T>> extends DomContent implements IInsta
|
|
|
|
|
translate
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
public T withAccesskey(String accesskey){ return attr(Attr.ACCESSKEY, accesskey); }
|
|
|
|
|
public T withAccesskey(String accesskey) {
|
|
|
|
|
return attr(Attr.ACCESSKEY, accesskey);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public T withClass(String className) { return attr(Attr.CLASS, className); }
|
|
|
|
|
public T withClass(String className) {
|
|
|
|
|
return attr(Attr.CLASS, className);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public T isContenteditable(){ return attr(Attr.CONTENTEDITABLE, "true"); }
|
|
|
|
|
public T isContenteditable() {
|
|
|
|
|
return attr(Attr.CONTENTEDITABLE, "true");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public T withData(String dataAttr, String value) { return attr(Attr.DATA + "-" + dataAttr, value); }
|
|
|
|
|
public T withData(String dataAttr, String value) {
|
|
|
|
|
return attr(Attr.DATA + "-" + dataAttr, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public T withDir(String dir) { return attr(Attr.DIR, dir); }
|
|
|
|
|
public T withDir(String dir) {
|
|
|
|
|
return attr(Attr.DIR, dir);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public T isDraggable(){ return attr(Attr.DRAGGABLE, "true"); }
|
|
|
|
|
public T isDraggable() {
|
|
|
|
|
return attr(Attr.DRAGGABLE, "true");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public T isHidden() { return attr(Attr.HIDDEN, null); }
|
|
|
|
|
public T isHidden() {
|
|
|
|
|
return attr(Attr.HIDDEN, null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public T withId(String id) { return attr(Attr.ID, id); }
|
|
|
|
|
public T withId(String id) {
|
|
|
|
|
return attr(Attr.ID, id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public T withIs(String element){ return attr(Attr.IS, element); }
|
|
|
|
|
public T withIs(String element) {
|
|
|
|
|
return attr(Attr.IS, element);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public T withLang(String lang) { return attr(Attr.LANG, lang); }
|
|
|
|
|
public T withLang(String lang) {
|
|
|
|
|
return attr(Attr.LANG, lang);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public T withSlot(String name){ return attr(Attr.SLOT, name); }
|
|
|
|
|
public T withSlot(String name) {
|
|
|
|
|
return attr(Attr.SLOT, name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public T isSpellcheck(){ return attr(Attr.SPELLCHECK, "true"); }
|
|
|
|
|
public T isSpellcheck() {
|
|
|
|
|
return attr(Attr.SPELLCHECK, "true");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public T withStyle(String style) { return attr(Attr.STYLE, style); }
|
|
|
|
|
public T withStyle(String style) {
|
|
|
|
|
return attr(Attr.STYLE, style);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public T withTabindex(int index){ return attr(Attr.TABINDEX, index); }
|
|
|
|
|
public T withTabindex(int index) {
|
|
|
|
|
return attr(Attr.TABINDEX, index);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public T withTitle(String title) { return attr(Attr.TITLE, title); }
|
|
|
|
|
public T withTitle(String title) {
|
|
|
|
|
return attr(Attr.TITLE, title);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public T isTranslate(){ return attr(Attr.TRANSLATE, "yes"); }
|
|
|
|
|
public T isTranslate() {
|
|
|
|
|
return attr(Attr.TRANSLATE, "yes");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ----- start of withCond$ATTR variants -----
|
|
|
|
|
public T withCondAccessKey(boolean condition, String accesskey){ return condAttr(condition, Attr.ACCESSKEY, accesskey); }
|
|
|
|
|
public T withCondAccessKey(boolean condition, String accesskey) {
|
|
|
|
|
return condAttr(condition, Attr.ACCESSKEY, accesskey);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public T withCondClass(boolean condition, String className) { return condAttr(condition, Attr.CLASS, className); }
|
|
|
|
|
public T withCondClass(boolean condition, String className) {
|
|
|
|
|
return condAttr(condition, Attr.CLASS, className);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public T withCondContenteditable(boolean condition){ return attr(Attr.CONTENTEDITABLE, (condition)?"true":"false");}
|
|
|
|
|
public T withCondContenteditable(boolean condition) {
|
|
|
|
|
return attr(Attr.CONTENTEDITABLE, (condition) ? "true" : "false");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public T withCondData(boolean condition, String dataAttr, String value) { return condAttr(condition, Attr.DATA + "-" + dataAttr, value); }
|
|
|
|
|
public T withCondData(boolean condition, String dataAttr, String value) {
|
|
|
|
|
return condAttr(condition, Attr.DATA + "-" + dataAttr, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public T withCondDir(boolean condition, String dir) { return condAttr(condition, Attr.DIR, dir); }
|
|
|
|
|
public T withCondDir(boolean condition, String dir) {
|
|
|
|
|
return condAttr(condition, Attr.DIR, dir);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public T withCondDraggable(boolean condition){ return attr(Attr.DRAGGABLE, (condition)?"true":"false"); }
|
|
|
|
|
public T withCondDraggable(boolean condition) {
|
|
|
|
|
return attr(Attr.DRAGGABLE, (condition) ? "true" : "false");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public T withCondHidden(boolean condition) { return condAttr(condition, Attr.HIDDEN, null); }
|
|
|
|
|
public T withCondHidden(boolean condition) {
|
|
|
|
|
return condAttr(condition, Attr.HIDDEN, null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public T withCondId(boolean condition, String id) { return condAttr(condition, Attr.ID, id); }
|
|
|
|
|
public T withCondId(boolean condition, String id) {
|
|
|
|
|
return condAttr(condition, Attr.ID, id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public T withCondIs(boolean condition, String element){ return condAttr(condition, Attr.IS, element); }
|
|
|
|
|
public T withCondIs(boolean condition, String element) {
|
|
|
|
|
return condAttr(condition, Attr.IS, element);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public T withCondLang(boolean condition, String lang) { return condAttr(condition, Attr.LANG, lang); }
|
|
|
|
|
public T withCondLang(boolean condition, String lang) {
|
|
|
|
|
return condAttr(condition, Attr.LANG, lang);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public T withCondSlot(boolean condition, String name){ return condAttr(condition, Attr.SLOT, name); }
|
|
|
|
|
public T withCondSlot(boolean condition, String name) {
|
|
|
|
|
return condAttr(condition, Attr.SLOT, name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public T withCondSpellcheck(boolean condition){ return attr(Attr.SPELLCHECK, (condition)?"true":"false"); }
|
|
|
|
|
public T withCondSpellcheck(boolean condition) {
|
|
|
|
|
return attr(Attr.SPELLCHECK, (condition) ? "true" : "false");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public T withCondStyle(boolean condition, String style) { return condAttr(condition, Attr.STYLE, style); }
|
|
|
|
|
public T withCondStyle(boolean condition, String style) {
|
|
|
|
|
return condAttr(condition, Attr.STYLE, style);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public T withCondTabindex(boolean condition, int index){ return condAttr(condition, Attr.TABINDEX, index+""); }
|
|
|
|
|
public T withCondTabindex(boolean condition, int index) {
|
|
|
|
|
return condAttr(condition, Attr.TABINDEX, index + "");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public T withCondTitle(boolean condition, String title) { return condAttr(condition, Attr.TITLE, title); }
|
|
|
|
|
public T withCondTitle(boolean condition, String title) {
|
|
|
|
|
return condAttr(condition, Attr.TITLE, title);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public T withCondTranslate(boolean condition){ return attr(Attr.TRANSLATE, (condition)?"yes":"no"); }
|
|
|
|
|
public T withCondTranslate(boolean condition) {
|
|
|
|
|
return attr(Attr.TRANSLATE, (condition) ? "yes" : "no");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|