public class HMLBuilder
extends java.lang.Object
HMLBuilder
supports the construction of a DOM
Document for a HML (HamNoSysML) element. It is primarily intended
for use by an ANTLR-generated tree-walker that generates an
HML element from the AST for a manual HNS string.Constructor and Description |
---|
HMLBuilder()
Constructs a new HML document builder.
|
HMLBuilder(javax.xml.parsers.DocumentBuilder bldr)
Constructs a new HML document builder using the given DOM
document builder.
|
Modifier and Type | Method and Description |
---|---|
static void |
appendChildList(org.w3c.dom.Element el,
org.w3c.dom.Element[] chl)
Appends the given sequence of child elements to the children of the
given element.
|
static void |
checkedAppendChild(org.w3c.dom.Element el,
org.w3c.dom.Element ch)
Appends the given child element to the children of the given
element, unless the child is null, in which case the putative parent
is unaltered.
|
static void |
checkedSetAttr(org.w3c.dom.Element el,
java.lang.String aname,
java.lang.String aval)
Attaches the attribute setting with the given name and value to
the given element, unless the attribute value is
null ,
in which case the element is not changed. |
static void |
checkedSetFlagAttr(org.w3c.dom.Element el,
java.lang.String aname,
boolean flagIsTrue)
For the given element and boolean attribute setting (name and
value), attaches the attribute setting to the element if its
value is true, but makes no change to the element if the attribute
value is false.
|
static void |
checkedStringSetFlagAttr(org.w3c.dom.Element el,
java.lang.String aname,
java.lang.String aval)
Similar to
checkedSetFlagAttr(org.w3c.dom.Element, java.lang.String, boolean) ,
but with a boolean string input value, that is, if the given value
string is non-null and equals "true" , then the given
attribute of the given element is set to this value; otherwise
the element is left unchanged. |
org.w3c.dom.Element |
elementFromList(java.util.ArrayList<org.w3c.dom.Element> al,
java.lang.String etag)
If the given list has exactly one element, then returns that
element (assumed to be of the given type);
otherwise, creates and returns a new element of the given type with
the given list of elements (in order) as its children.
|
org.w3c.dom.ls.LSSerializer |
getLSSerializer()
Returns a DOM level 3 LS serializer for this builder's document.
|
void |
insertNonManual(org.w3c.dom.Element signel,
org.w3c.dom.Element nmel)
Inserts the given HML non-manual element in the given HML sign
elment as its first child, unless the former is
null ,
in which case this method does nothing. |
org.w3c.dom.Attr |
newHMLAttr(java.lang.String aname)
Creates and returns a new DOM attribute of the given name.
|
org.w3c.dom.Comment |
newHMLComment(java.lang.String data)
Creates and returns a new DOM comment with the given content.
|
org.w3c.dom.Element |
newHMLElement(java.lang.String tag)
Creates and returns a new DOM element of the given type.
|
org.w3c.dom.Element |
parseElement(java.lang.String eltext)
Returns a new DOM element structure for the given element text,
unless the latter is the empty string, in which case this method
returns
null . |
void |
setDocRoot(org.w3c.dom.Element root)
Sets the given element as the document element for this builder's
document.
|
org.w3c.dom.Element |
stripParentIfNotNeeded(org.w3c.dom.Element el)
If the given element's first child has no attributes and has the
same type as the given one, then returns this first child;
otherwise returns the original element unchanged.
|
org.w3c.dom.Element |
wrapIfNeeded(java.lang.String tag,
org.w3c.dom.Element el)
If the given element is of the given type and has no attributes,
then returns the element unaltered; otherwise returns a new
element of the given type with the given element as its only child.
|
org.w3c.dom.Element |
wrapPair(java.lang.String tag,
org.w3c.dom.Element inner0,
org.w3c.dom.Element inner1)
Creates and returns a new DOM element of the given type with
the given pair of elements as its only children (in the given order).
|
org.w3c.dom.Element |
wrapperEl(java.lang.String tag,
org.w3c.dom.Element inner)
Creates and returns a new DOM element of the given type with
the given element as its only child.
|
public HMLBuilder() throws java.io.IOException, org.w3c.dom.DOMException, javax.xml.parsers.ParserConfigurationException
java.io.IOException
org.w3c.dom.DOMException
javax.xml.parsers.ParserConfigurationException
public HMLBuilder(javax.xml.parsers.DocumentBuilder bldr)
public org.w3c.dom.Element newHMLElement(java.lang.String tag)
public org.w3c.dom.Attr newHMLAttr(java.lang.String aname)
public org.w3c.dom.Comment newHMLComment(java.lang.String data)
public org.w3c.dom.Element wrapperEl(java.lang.String tag, org.w3c.dom.Element inner)
public org.w3c.dom.Element wrapPair(java.lang.String tag, org.w3c.dom.Element inner0, org.w3c.dom.Element inner1)
public org.w3c.dom.Element wrapIfNeeded(java.lang.String tag, org.w3c.dom.Element el)
public org.w3c.dom.Element stripParentIfNotNeeded(org.w3c.dom.Element el)
public org.w3c.dom.Element elementFromList(java.util.ArrayList<org.w3c.dom.Element> al, java.lang.String etag)
public void insertNonManual(org.w3c.dom.Element signel, org.w3c.dom.Element nmel)
null
,
in which case this method does nothing.public void setDocRoot(org.w3c.dom.Element root)
public org.w3c.dom.Element parseElement(java.lang.String eltext)
null
.public static void checkedAppendChild(org.w3c.dom.Element el, org.w3c.dom.Element ch)
public static void appendChildList(org.w3c.dom.Element el, org.w3c.dom.Element[] chl)
public static void checkedSetAttr(org.w3c.dom.Element el, java.lang.String aname, java.lang.String aval)
null
,
in which case the element is not changed.public static void checkedSetFlagAttr(org.w3c.dom.Element el, java.lang.String aname, boolean flagIsTrue)
public static void checkedStringSetFlagAttr(org.w3c.dom.Element el, java.lang.String aname, java.lang.String aval)
checkedSetFlagAttr(org.w3c.dom.Element, java.lang.String, boolean)
,
but with a boolean string input value, that is, if the given value
string is non-null and equals "true"
, then the given
attribute of the given element is set to this value; otherwise
the element is left unchanged.public org.w3c.dom.ls.LSSerializer getLSSerializer()