|
|||||||||
| Home >> All >> org >> jdom >> [ output overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.jdom.output
Class Format

java.lang.Objectorg.jdom.output.Format
- All Implemented Interfaces:
- java.lang.Cloneable
- public class Format
- extends java.lang.Object
- implements java.lang.Cloneable
- extends java.lang.Object
Class to encapsulate XMLOutputter format options.
Typical users can use the standard format configurations obtained by
getRawFormat() 55 (no whitespace changes),
getPrettyFormat() 55 (whitespace beautification), and
getCompactFormat() 55 (whitespace normalization).
Several modes are available to effect the way textual content is printed. See the documentation for Format.TextMode for details.
- Version:
- $Revision: 1.10 $, $Date: 2004/09/07 06:37:20 $
| Nested Class Summary | |
(package private) class |
Format.DefaultEscapeStrategy
Handle common charsets quickly and easily. |
static class |
Format.TextMode
Class to signify how text should be handled on output. |
| Field Summary | |
private static java.lang.String |
CVS_ID
|
(package private) java.lang.String |
encoding
The encoding format |
(package private) EscapeStrategy |
escapeStrategy
entity escape logic |
(package private) boolean |
expandEmptyElements
Whether or not to expand empty elements to <tagName></tagName> - default is false |
(package private) boolean |
ignoreTrAXEscapingPIs
Whether TrAX output escaping disabling/enabling PIs are ignored or processed - default is false |
(package private) java.lang.String |
indent
The default indent is no spaces (as original document) |
(package private) java.lang.String |
lineSeparator
New line separator |
(package private) Format.TextMode |
mode
text handling mode |
(package private) boolean |
omitDeclaration
Whether or not to output the XML declaration - default is false |
(package private) boolean |
omitEncoding
Whether or not to output the encoding in the XML declaration - default is false |
private static java.lang.String |
STANDARD_ENCODING
standard encoding |
private static java.lang.String |
STANDARD_INDENT
standard value to indent by, if we are indenting |
private static java.lang.String |
STANDARD_LINE_SEPARATOR
standard string with which to end a line |
| Constructor Summary | |
private |
Format()
Creates a new Format instance with default (raw) behavior. |
| Method Summary | |
protected java.lang.Object |
clone()
This method may be called to create a new copy of the Object. |
static Format |
getCompactFormat()
Returns a new Format object that performs whitespace normalization, uses the UTF-8 encoding, doesn't expand empty elements, includes the declaration and encoding, and uses the default entity escape strategy. |
java.lang.String |
getEncoding()
Returns the configured output encoding. |
EscapeStrategy |
getEscapeStrategy()
Returns the current escape strategy |
boolean |
getExpandEmptyElements()
Returns whether empty elements are expanded. |
boolean |
getIgnoreTrAXEscapingPIs()
Returns whether JAXP TrAX processing instructions for disabling/enabling output escaping are ignored. |
java.lang.String |
getIndent()
Returns the indent string in use. |
java.lang.String |
getLineSeparator()
Returns the current line separator. |
boolean |
getOmitDeclaration()
Returns whether the XML declaration will be omitted. |
boolean |
getOmitEncoding()
Returns whether the XML declaration encoding will be omitted. |
static Format |
getPrettyFormat()
Returns a new Format object that performs whitespace beautification with 2-space indents, uses the UTF-8 encoding, doesn't expand empty elements, includes the declaration and encoding, and uses the default entity escape strategy. |
static Format |
getRawFormat()
Returns a new Format object that performs no whitespace changes, uses the UTF-8 encoding, doesn't expand empty elements, includes the declaration and encoding, and uses the default entity escape strategy. |
Format.TextMode |
getTextMode()
Returns the current text output style. |
Format |
setEncoding(java.lang.String encoding)
Sets the output encoding. |
Format |
setEscapeStrategy(EscapeStrategy strategy)
Sets the Format.DefaultEscapeStrategy to use for character escaping. |
Format |
setExpandEmptyElements(boolean expandEmptyElements)
This will set whether empty elements are expanded from <tagName/> to
<tagName></tagName>. |
void |
setIgnoreTrAXEscapingPIs(boolean ignoreTrAXEscapingPIs)
This will set whether JAXP TrAX processing instructions for disabling/enabling output escaping are ignored. |
Format |
setIndent(java.lang.String indent)
This will set the indent String to use; this
is usually a String of empty spaces. |
Format |
setLineSeparator(java.lang.String separator)
This will set the newline separator ( lineSeparator). |
Format |
setOmitDeclaration(boolean omitDeclaration)
This will set whether the XML declaration ( <?xml version="1.0"?gt;)
will be omitted or not. |
Format |
setOmitEncoding(boolean omitEncoding)
This will set whether the XML declaration ( <?xml version="1.0"
encoding="UTF-8"?>)
includes the encoding of the document. |
Format |
setTextMode(Format.TextMode mode)
This sets the text output style. |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
CVS_ID
private static final java.lang.String CVS_ID
- See Also:
- Constant Field Values
STANDARD_INDENT
private static final java.lang.String STANDARD_INDENT
- standard value to indent by, if we are indenting
- See Also:
- Constant Field Values
STANDARD_LINE_SEPARATOR
private static final java.lang.String STANDARD_LINE_SEPARATOR
- standard string with which to end a line
- See Also:
- Constant Field Values
STANDARD_ENCODING
private static final java.lang.String STANDARD_ENCODING
- standard encoding
- See Also:
- Constant Field Values
indent
java.lang.String indent
- The default indent is no spaces (as original document)
lineSeparator
java.lang.String lineSeparator
- New line separator
encoding
java.lang.String encoding
- The encoding format
omitDeclaration
boolean omitDeclaration
- Whether or not to output the XML declaration
- default is
false
omitEncoding
boolean omitEncoding
- Whether or not to output the encoding in the XML declaration
- default is
false
expandEmptyElements
boolean expandEmptyElements
- Whether or not to expand empty elements to
<tagName></tagName> - default is
false
ignoreTrAXEscapingPIs
boolean ignoreTrAXEscapingPIs
- Whether TrAX output escaping disabling/enabling PIs are ignored
or processed - default is
false
mode
Format.TextMode mode
- text handling mode
escapeStrategy
EscapeStrategy escapeStrategy
- entity escape logic
| Constructor Detail |
Format
private Format()
- Creates a new Format instance with default (raw) behavior.
| Method Detail |
getRawFormat
public static Format getRawFormat()
- Returns a new Format object that performs no whitespace changes, uses
the UTF-8 encoding, doesn't expand empty elements, includes the
declaration and encoding, and uses the default entity escape strategy.
Tweaks can be made to the returned Format instance without affecting
other instances.
getPrettyFormat
public static Format getPrettyFormat()
- Returns a new Format object that performs whitespace beautification with
2-space indents, uses the UTF-8 encoding, doesn't expand empty elements,
includes the declaration and encoding, and uses the default entity
escape strategy.
Tweaks can be made to the returned Format instance without affecting
other instances.
getCompactFormat
public static Format getCompactFormat()
- Returns a new Format object that performs whitespace normalization, uses
the UTF-8 encoding, doesn't expand empty elements, includes the
declaration and encoding, and uses the default entity escape strategy.
Tweaks can be made to the returned Format instance without affecting
other instances.
setEscapeStrategy
public Format setEscapeStrategy(EscapeStrategy strategy)
- Sets the Format.DefaultEscapeStrategy to use for character escaping.
getEscapeStrategy
public EscapeStrategy getEscapeStrategy()
- Returns the current escape strategy
setLineSeparator
public Format setLineSeparator(java.lang.String separator)
- This will set the newline separator (
lineSeparator). The default is\r\n. Note that if the "newlines" property is false, this value is irrelevant. To make it output the system default line ending string, callsetLineSeparator(System.getProperty("line.separator"))To output "UNIX-style" documents, call
setLineSeparator("\n"). To output "Mac-style" documents, callsetLineSeparator("\r"). DOS-style documents use CR-LF ("\r\n"), which is the default.Note that this only applies to newlines generated by the outputter. If you parse an XML document that contains newlines embedded inside a text node, and you do not set TextMode.NORMALIZE, then the newlines will be output verbatim, as "\n" which is how parsers normalize them.
getLineSeparator
public java.lang.String getLineSeparator()
- Returns the current line separator.
setOmitEncoding
public Format setOmitEncoding(boolean omitEncoding)
- This will set whether the XML declaration
(
<?xml version="1.0" encoding="UTF-8"?>) includes the encoding of the document. It is common to omit this in uses such as WML and other wireless device protocols.
getOmitEncoding
public boolean getOmitEncoding()
- Returns whether the XML declaration encoding will be omitted.
setOmitDeclaration
public Format setOmitDeclaration(boolean omitDeclaration)
- This will set whether the XML declaration
(
<?xml version="1.0"?gt;) will be omitted or not. It is common to omit this in uses such as SOAP and XML-RPC calls.
getOmitDeclaration
public boolean getOmitDeclaration()
- Returns whether the XML declaration will be omitted.
setExpandEmptyElements
public Format setExpandEmptyElements(boolean expandEmptyElements)
- This will set whether empty elements are expanded from
<tagName/>to<tagName></tagName>.
getExpandEmptyElements
public boolean getExpandEmptyElements()
- Returns whether empty elements are expanded.
setIgnoreTrAXEscapingPIs
public void setIgnoreTrAXEscapingPIs(boolean ignoreTrAXEscapingPIs)
- This will set whether JAXP TrAX processing instructions for
disabling/enabling output escaping are ignored. Disabling
output escaping allows using XML text as element content and
outputing it verbatim, i.e. as element children would be.
When processed, these processing instructions are removed from the generated XML text and control whether the element text content is output verbatim or with escaping of the pre-defined entities in XML 1.0. The text to be output verbatim shall be surrounded by the
<?javax.xml.transform.disable-output-escaping ?>and<?javax.xml.transform.enable-output-escaping ?>PIs.When ignored, the processing instructions are present in the generated XML text and the pre-defined entities in XML 1.0 are escaped.
Default:
false.
getIgnoreTrAXEscapingPIs
public boolean getIgnoreTrAXEscapingPIs()
- Returns whether JAXP TrAX processing instructions for
disabling/enabling output escaping are ignored.
setTextMode
public Format setTextMode(Format.TextMode mode)
- This sets the text output style. Options are available as static
Format.TextMode instances. The default is
Format.TextMode.PRESERVE55 .
getTextMode
public Format.TextMode getTextMode()
- Returns the current text output style.
setIndent
public Format setIndent(java.lang.String indent)
- This will set the indent
Stringto use; this is usually aStringof empty spaces. If you pass null, or the empty string (""), then no indentation will happen. Default: none (null)
getIndent
public java.lang.String getIndent()
- Returns the indent string in use.
setEncoding
public Format setEncoding(java.lang.String encoding)
- Sets the output encoding. The name should be an accepted XML
encoding.
getEncoding
public java.lang.String getEncoding()
- Returns the configured output encoding.
clone
protected java.lang.Object clone()
- Description copied from class:
java.lang.Object - This method may be called to create a new copy of the
Object. The typical behavior is as follows:
o == o.clone()is falseo.getClass() == o.clone().getClass()is trueo.equals(o)is true
However, these are not strict requirements, and may be violated if necessary. Of the three requirements, the last is the most commonly violated, particularly if the subclass does not override Object.equals(Object)>
Object.equals(Object)55 .If the Object you call clone() on does not implement java.lang.Cloneable (which is a placeholder interface), then a CloneNotSupportedException is thrown. Notice that Object does not implement Cloneable; this method exists as a convenience for subclasses that do.
Object's implementation of clone allocates space for the new Object using the correct class, without calling any constructors, and then fills in all of the new field values with the old field values. Thus, it is a shallow copy. However, subclasses are permitted to make a deep copy.
All array types implement Cloneable, and override this method as follows (it should never fail):
public Object clone() { try { super.clone(); } catch (CloneNotSupportedException e) { throw new InternalError(e.getMessage()); } }
|
|||||||||
| Home >> All >> org >> jdom >> [ output overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
org.jdom.output.Format