This commit is contained in:
tipsy
2015-05-17 13:52:38 +02:00
parent c0c5e4bf33
commit 2ebf7463ac
18 changed files with 104 additions and 155 deletions

View File

@@ -0,0 +1,37 @@
package j2html.attributes;
import static j2html.utils.SimpleHtmlEscaper.escape;
public class Attribute {
private String name;
private String value;
public Attribute(String name, String value) {
this.name = name;
this.value = escape(value);
}
public Attribute(String name) {
this.name = name;
this.value = null;
}
public String render() {
if (name == null) { return ""; }
if (value == null) { return " "+name; }
return(" "+name+"=\""+value+"\"");
}
@Override
public String toString() {
return this.render();
}
public String getName() {
return name;
}
public void setValue(String value) {
this.value = value;
}
}