| Method from groovy.xml.MarkupBuilder Detail: |
protected Object createNode(Object name) {
Object theName = getName(name);
toState(1, theName);
this.nodeIsEmpty = true;
return theName;
}
|
protected Object createNode(Object name,
Object value) {
Object theName = getName(name);
if (value == null){
return createNode(theName);
} else {
toState(2, theName);
this.nodeIsEmpty = false;
out.print(" >");
out.print(escapeElementContent(value.toString()));
return theName;
}
}
|
protected Object createNode(Object name,
Map attributes) {
return createNode(name, attributes, null);
}
|
protected Object createNode(Object name,
Map attributes,
Object value) {
Object theName = getName(name);
toState(1, theName);
for (Iterator iter = attributes.entrySet().iterator(); iter.hasNext();) {
Map.Entry entry = (Map.Entry) iter.next();
Object attributeValue = entry.getValue();
boolean skipNull = attributeValue == null && omitNullAttributes;
boolean skipEmpty = attributeValue != null && omitEmptyAttributes &&
attributeValue.toString().length() == 0;
if (!skipNull && !skipEmpty) {
out.print(" ");
// Output the attribute name,
print(entry.getKey().toString());
// Output the attribute value within quotes. Use whichever
// type of quotes are currently configured.
out.print(this.useDoubleQuotes ? "=\"" : "='");
print(attributeValue == null ? "" : escapeAttributeValue(attributeValue.toString()));
out.print(this.useDoubleQuotes ? "\"" : "'");
}
}
if (value != null) {
yield(value.toString());
} else {
nodeIsEmpty = true;
}
return theName;
}
|
public boolean getDoubleQuotes() {
return this.useDoubleQuotes;
}
Returns true if attribute values are output with
double quotes; false if single quotes are used.
By default, single quotes are used. |
public Object getMkp() {
return this;
}
|
protected Object getName(String methodName) {
return super.getName(methodName);
}
|
protected IndentPrinter getPrinter() {
return this.out;
}
|
public boolean isOmitEmptyAttributes() {
return omitEmptyAttributes;
}
Determine whether empty attributes will appear in the produced markup. |
public boolean isOmitNullAttributes() {
return omitNullAttributes;
}
Determine whether null attributes will appear in the produced markup. |
protected void nodeCompleted(Object parent,
Object node) {
toState(3, node);
out.flush();
}
|
protected void print(Object node) {
out.print(node == null ? "null" : node.toString());
}
|
public void setDoubleQuotes(boolean useDoubleQuotes) {
this.useDoubleQuotes = useDoubleQuotes;
}
Sets whether the builder outputs attribute values in double
quotes or single quotes. |
public void setOmitEmptyAttributes(boolean omitEmptyAttributes) {
this.omitEmptyAttributes = omitEmptyAttributes;
}
Allows empty attributes to be removed the produced markup. |
public void setOmitNullAttributes(boolean omitNullAttributes) {
this.omitNullAttributes = omitNullAttributes;
}
Allows null attributes to be removed the produced markup. |
protected void setParent(Object parent,
Object child) {
}
|
protected String transformValue(String value) {
// & has to be checked and replaced before others
if (value.matches(".*&.*")) {
value = value.replaceAll("&", "&");
}
if (value.matches(".*\\'.*")) {
value = value.replaceAll("\\'", "'");
}
if (value.matches(".*< .*")) {
value = value.replaceAll("< ", "<");
}
if (value.matches(".* >.*")) {
value = value.replaceAll(" >", ">");
}
return value;
} Deprecated!
Returns a String with special XML characters escaped as entities so that
output XML is valid. Escapes the following characters as corresponding
entities:
- \' as '
- & as &
- < as <
- > as >
|
public void yield(String value) {
yield(value, true);
}
|
public void yieldUnescaped(String value) {
yield(value, false);
}
|