diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/xhtml/XhtmlFluent.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/xhtml/XhtmlFluent.java index 3ae249226..b2e349b1b 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/xhtml/XhtmlFluent.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/xhtml/XhtmlFluent.java @@ -54,7 +54,8 @@ public abstract class XhtmlFluent { } public XhtmlNode td() { - return addTag("td"); + XhtmlNode x = addTag("td"); + return x; } public XhtmlNode td(String clss) { diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/xhtml/XhtmlNode.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/xhtml/XhtmlNode.java index 6731a0812..e13cdabec 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/xhtml/XhtmlNode.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/xhtml/XhtmlNode.java @@ -363,6 +363,10 @@ public class XhtmlNode extends XhtmlFluent implements IBaseXhtml { return hasAttributes() && getAttributes().containsKey(name); } + public boolean hasAttribute(String name, String value) { + return hasAttributes() && getAttributes().containsKey(name) && value.equals(getAttributes().get(name)); + } + public String getAttribute(String name) { return hasAttributes() ? getAttributes().get(name) : null; } @@ -569,18 +573,25 @@ public class XhtmlNode extends XhtmlFluent implements IBaseXhtml { throw new UnsupportedOperationException(); } - /** - * NOT SUPPORTED - Throws {@link UnsupportedOperationException} - */ + private Map userData; + public Object getUserData(String theName) { - throw new UnsupportedOperationException(); + if (hasUserData(theName)) { + return userData.get(theName); + } else { + return null; + } + } + + public boolean hasUserData(String theName) { + return userData != null && userData.containsKey(theName); } - /** - * NOT SUPPORTED - Throws {@link UnsupportedOperationException} - */ public void setUserData(String theName, Object theValue) { - throw new UnsupportedOperationException(); + if (userData == null) { + userData = new HashMap<>(); + } + userData.put(theName, theValue); } @@ -892,4 +903,23 @@ public class XhtmlNode extends XhtmlFluent implements IBaseXhtml { } } + public boolean isClass(String name) { + return hasAttribute("class", name); + } + + + public void styleCells(XhtmlNode x) { + setUserData("cells", x); + } + + + public XhtmlNode td() { + XhtmlNode x = addTag("td"); + XhtmlNode t = (XhtmlNode) getUserData("cells"); + if (t != null) { + x.copyAllContent(t); + } + return x; + } + } \ No newline at end of file