|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.android.ide.common.xml.XmlPrettyPrinter
public class XmlPrettyPrinter
Visitor which walks over the subtree of the DOM to be formatted and pretty prints
the DOM into the given StringBuilder
Constructor Summary | |
---|---|
XmlPrettyPrinter(XmlFormatPreferences prefs,
XmlFormatStyle style,
java.lang.String lineSeparator)
Creates a new XmlPrettyPrinter |
Method Summary | |
---|---|
protected java.lang.String |
getSource(org.w3c.dom.Node node)
|
protected boolean |
isEmptyTag(org.w3c.dom.Element element)
Returns true if the given element should be an empty tag |
static void |
main(java.lang.String[] args)
Command line driver |
void |
prettyPrint(int rootDepth,
org.w3c.dom.Node root,
org.w3c.dom.Node startNode,
org.w3c.dom.Node endNode,
java.lang.StringBuilder out,
boolean openTagOnly)
Start pretty-printing at the given node, which must either be the startNode or contain it as a descendant. |
static java.lang.String |
prettyPrint(org.w3c.dom.Node node)
Deprecated. Use prettyPrint(org.w3c.dom.Node, boolean) instead |
static java.lang.String |
prettyPrint(org.w3c.dom.Node node,
boolean endWithNewline)
Pretty prints the given node using default styles |
static java.lang.String |
prettyPrint(org.w3c.dom.Node node,
XmlFormatPreferences prefs,
XmlFormatStyle style,
java.lang.String lineSeparator)
Deprecated. Use prettyPrint(org.w3c.dom.Node, XmlFormatPreferences,
XmlFormatStyle, String, boolean) instead |
static java.lang.String |
prettyPrint(org.w3c.dom.Node node,
XmlFormatPreferences prefs,
XmlFormatStyle style,
java.lang.String lineSeparator,
boolean endWithNewline)
Pretty prints the given node |
static java.lang.String |
prettyPrint(java.lang.String xml,
XmlFormatPreferences prefs,
XmlFormatStyle style,
java.lang.String lineSeparator)
Pretty-prints the given XML document, which must be well-formed. |
XmlPrettyPrinter |
setEndWithNewline(boolean endWithNewline)
Sets whether the document should end with a newline/ line separator |
void |
setIndentationLevels(java.lang.String[] indentationLevels)
Sets the indentation levels to use (indentation string to use for each depth, indexed by depth |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public XmlPrettyPrinter(XmlFormatPreferences prefs, XmlFormatStyle style, java.lang.String lineSeparator)
XmlPrettyPrinter
prefs
- the preferences to format withstyle
- the style to format withlineSeparator
- the line separator to use, such as "\n" (can be null, in which
case the system default is looked up via the line.separator property)Method Detail |
---|
public XmlPrettyPrinter setEndWithNewline(boolean endWithNewline)
endWithNewline
- if true, ensure that the document ends with a newline
public void setIndentationLevels(java.lang.String[] indentationLevels)
indentationLevels
- an array of strings to use for the various indentation
levels@NonNull public static java.lang.String prettyPrint(@NonNull java.lang.String xml, @NonNull XmlFormatPreferences prefs, @NonNull XmlFormatStyle style, @Nullable java.lang.String lineSeparator)
xml
- the XML content to formatprefs
- the preferences to format withstyle
- the style to format withlineSeparator
- the line separator to use, such as "\n" (can be null, in which
case the system default is looked up via the line.separator property)
@NonNull @Deprecated public static java.lang.String prettyPrint(@NonNull org.w3c.dom.Node node, @NonNull XmlFormatPreferences prefs, @NonNull XmlFormatStyle style, @Nullable java.lang.String lineSeparator)
prettyPrint(org.w3c.dom.Node, XmlFormatPreferences,
XmlFormatStyle, String, boolean)
instead
node
- the node, usually a document, to be printedprefs
- the formatting preferencesstyle
- the formatting style to uselineSeparator
- the line separator to use, or null to use the
default
@NonNull public static java.lang.String prettyPrint(@NonNull org.w3c.dom.Node node, @NonNull XmlFormatPreferences prefs, @NonNull XmlFormatStyle style, @Nullable java.lang.String lineSeparator, boolean endWithNewline)
node
- the node, usually a document, to be printedprefs
- the formatting preferencesstyle
- the formatting style to uselineSeparator
- the line separator to use, or null to use the
defaultendWithNewline
- if true, ensure that the printed output ends with a newline
@NonNull @Deprecated public static java.lang.String prettyPrint(@NonNull org.w3c.dom.Node node)
prettyPrint(org.w3c.dom.Node, boolean)
instead
node
- the node, usually a document, to be printed
@NonNull public static java.lang.String prettyPrint(@NonNull org.w3c.dom.Node node, boolean endWithNewline)
node
- the node, usually a document, to be printedendWithNewline
- if true, ensure that the printed output ends with a newline
public void prettyPrint(int rootDepth, org.w3c.dom.Node root, org.w3c.dom.Node startNode, org.w3c.dom.Node endNode, java.lang.StringBuilder out, boolean openTagOnly)
rootDepth
- the depth of the given node, used to determine indentationroot
- the node to start pretty printing from (which may not itself be
included in the start to end node range but should contain it)startNode
- the node to start formatting atendNode
- the node to end formatting atout
- the StringBuilder
to pretty print intoopenTagOnly
- if true, only format the open tag of the startNode (and nothing
else)@Nullable protected java.lang.String getSource(@NonNull org.w3c.dom.Node node)
protected boolean isEmptyTag(org.w3c.dom.Element element)
element
- the element to test
public static void main(java.lang.String[] args)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |