001package org.hl7.fhir.r4.model; 002 003import java.io.IOException; 004import java.util.List; 005 006import org.hl7.fhir.exceptions.FHIRException; 007import org.hl7.fhir.r4.formats.FormatUtilities; 008import org.hl7.fhir.utilities.xhtml.NodeType; 009import org.hl7.fhir.utilities.xhtml.XhtmlComposer; 010import org.hl7.fhir.utilities.xhtml.XhtmlNode; 011 012public class XhtmlType extends Element { 013 014 private Narrative place; 015 016 public XhtmlType(Narrative place) { 017 super(); 018 this.place = place; 019 } 020 021 public XhtmlType() { 022 // "<div xmlns=\""+FormatUtilities.XHTML_NS+"\"></div>" 023 } 024 025 @Override 026 public String fhirType() { 027 return "xhtml"; 028 } 029 030 @Override 031 protected void listChildren(List<Property> result) { 032 } 033 034 @Override 035 public String getIdBase() { 036 return null; 037 } 038 039 @Override 040 public void setIdBase(String value) { 041 } 042 043 @Override 044 public Element copy() { 045 return null; 046 } 047 048 public XhtmlNode getValue() { 049 return place == null ? new XhtmlNode(NodeType.Element, "div") : place.getDiv(); 050 } 051 052 @Override 053 public Base setProperty(int hash, String name, Base value) throws FHIRException { 054 if ("value".equals(name)) { 055 place.setDiv(castToXhtml(value)); 056 return value; 057 } else 058 return super.setProperty(hash, name, value); 059 } 060 061 @Override 062 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 063 if ("value".equals(name)) 064 return new Base[] {this}; 065 return super.getProperty(hash, name, checkValid); 066 } 067 068 @Override 069 public String primitiveValue() { 070 try { 071 return new XhtmlComposer(false).compose(getValue()); 072 } catch (IOException e) { 073 } 074 return null; 075 } 076 077 @Override 078 public boolean isPrimitive() { 079 return true; 080 } 081 082 @Override 083 public boolean hasPrimitiveValue() { 084 return true; 085 } 086 087 088}