Top Description Inners Fields Constructors Methods
org.jdom2.output

public Class Format

extends Object
implements Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable
Imports
java.nio.charset.Charset, .CharsetEncoder, java.util.Locale, org.jdom2.IllegalDataException, .Verifier

Class to encapsulate XMLOutputter format options. Typically users adapt the standard format configurations obtained by getRawFormat (no whitespace changes), getPrettyFormat (whitespace beautification), and getCompactFormat (whitespace normalization).

Several modes are available to effect the way textual content is printed. See the documentation for TextMode for details.

Note about Line Separator:

By default JDOM will always use the CRNL sequence "\r\n" for output. This can be changed in a number of different ways. See the LineSeparator enumeration for more information.

Note about XML Character Escaping:

JDOM will escape characters in the output based on the EscapeStrategy that is specified by this Format. The Format will by default use a sensible EscapeStrategy that is based on the character encoding of the output. If the default escape mechanism is not producing the correct results you can change the EscapeStrategy on the format to suit your own needs.

Authors
Jason Hunter, Rolf Lear
See Also
LineSeparator

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class
Format.EscapeStrategy7Bits

An EscapeStrategy suitable for 7-bit charsets.

private static class
Format.EscapeStrategy8Bits

An EscapeStrategy suitable for 8-bit charsets.

private static class
Format.EscapeStrategyUTF

An EscapeStrategy suitable for UTF-8 an UTF-16.

public static enum
Format.TextMode

Class to signify how text should be handled on output.

Field Summary

Modifier and TypeField and Description
private static final EscapeStrategy
Bits7EscapeStrategy

An EscapeStrategy suitable for 7-bit charsets

private static final EscapeStrategy
Bits8EscapeStrategy

An EscapeStrategy suitable for 8-bit charsets

private static final EscapeStrategy
DefaultEscapeStrategy

An EscapeStrategy suitable for 'unknown' charsets

pack-priv String
encoding

The encoding format

pack-priv EscapeStrategy
escapeStrategy

entity escape logic

pack-priv boolean
expandEmptyElements

Whether or not to expand empty elements to <tagName></tagName> - default is false

pack-priv boolean
ignoreTrAXEscapingPIs

Whether TrAX output escaping disabling/enabling PIs are ignored or processed - default is false

pack-priv String
indent

The default indent is no spaces (as original document)

pack-priv String
lineSeparator

New line separator

pack-priv Format.TextMode
mode

text handling mode

pack-priv boolean
omitDeclaration

Whether or not to output the XML declaration - default is false

pack-priv boolean
omitEncoding

Whether or not to output the encoding in the XML declaration - default is false

pack-priv boolean
specifiedAttributesOnly

Whether Attributes that are defaulted from the DTD or Schema are output.

private static final String
STANDARD_ENCODING

standard encoding

private static final String
STANDARD_INDENT

standard value to indent by, if we are indenting

private static final String
STANDARD_LINE_SEPARATOR

standard string with which to end a line

private static final EscapeStrategy
UTFEscapeStrategy

An EscapeStrategy suitable for UTF-8 an UTF-16

Constructor Summary

AccessConstructor and Description
private
Format()

Creates a new Format instance with default (raw) behavior.

Method Summary

Modifier and TypeMethod and Description
private static final EscapeStrategy
public Format
clone()

Overrides java.lang.Object.clone.

Creates and returns a copy of this object.
public static final String

Returns:

The compacted value
compact
(String
The value to compact.
str
)

Use the XML Specification definition of whitespace to compact the input value.

public static final String

Returns:

The value appropriately escaped.
escapeAttribute
(final EscapeStrategy
The EscapeStrategy to query.
strategy
,
final String
String Attribute value to escape.
value
)

This will take the three pre-defined entities in XML 1.0 ('<', '>', and '&' - used specifically in XML elements) as well as CR/NL, tabs, and Quote characters which require escaping inside Attribute values and converts their character representation to the appropriate entity reference suitable for XML attribute content.

public static final String

Returns:

The input value escaped.
escapeText
(final EscapeStrategy
The EscapeStrategy
strategy
,
final String
The End-Of-Line sequence to be used (may be null).
eol
,
final String
The String to escape
value
)

This will take the three pre-defined entities in XML 1.0 ('<', '>', and '&' - used specifically in XML elements) and convert their character representation to the appropriate entity reference, suitable for XML element content.

public static Format

Returns:

a Format with whitespace normalization
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.

public String

Returns:

the output encoding
getEncoding
()

Returns the configured output encoding.

public EscapeStrategy

Returns:

the current escape strategy
getEscapeStrategy
()

Returns the current escape strategy

public boolean

Returns:

whether empty elements are expanded
getExpandEmptyElements
()

Returns whether empty elements are expanded.

public boolean

Returns:

whether or not TrAX output escaping PIs are ignored.
getIgnoreTrAXEscapingPIs
()

Returns whether JAXP TrAX processing instructions for disabling/enabling output escaping are ignored.

public String

Returns:

the indent string in use
getIndent
()

Returns the indent string in use.

public String

Returns:

the current line separator
getLineSeparator
()

Returns the current line separator.

public boolean

Returns:

whether the XML declaration will be omitted
getOmitDeclaration
()

Returns whether the XML declaration will be omitted.

public boolean

Returns:

whether the XML declaration encoding will be omitted
getOmitEncoding
()

Returns whether the XML declaration encoding will be omitted.

public static Format

Returns:

a Format with whitespace beautification
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.

public static Format

Returns:

a Format with no whitespace changes
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.

public Format.TextMode

Returns:

the current text output style
getTextMode
()

Returns the current text output style.

public boolean

Returns:

true if the defaulted Attributes will be output
isSpecifiedAttributesOnly
()

Will Attributes defaulted from the DTD or XMLSchema be output

public Format

Returns:

a pointer to this Format for chaining
setEncoding
(String
the encoding format. Use XML-style names like "UTF-8" or "ISO-8859-1" or "US-ASCII"
encoding
)

Sets the output encoding.

public Format

Returns:

a pointer to this Format for chaining
setEscapeStrategy
(EscapeStrategy
the EscapeStrategy to use
strategy
)

Sets the EscapeStrategy to use for character escaping.

public Format

Returns:

a pointer to this Format for chaining
setExpandEmptyElements
(boolean
boolean indicating whether or not empty elements should be expanded.
expandEmptyElements
)

This will set whether empty elements are expanded from <tagName/> to <tagName></tagName>.

public void
setIgnoreTrAXEscapingPIs(boolean
boolean indicating whether or not TrAX output escaping PIs are ignored.
ignoreTrAXEscapingPIs
)

This will set whether JAXP TrAX processing instructions for disabling/enabling output escaping are ignored.

public Format

Returns:

a pointer to this Format for chaining
setIndent
(String
String to use for indentation.
indent
)

This will set the indent String to use; this is usually a String of empty spaces.

public Format

Returns:

a pointer to this Format for chaining
setLineSeparator
(String
String line separator to use.
separator
)

This will set the newline separator (LineSeparator).

public Format

Returns:

a pointer to this Format for chaining
setLineSeparator
(LineSeparator
LineSeparator line separator to us
separator
)

This will set the newline separator sequence.

public Format

Returns:

a pointer to this Format for chaining
setOmitDeclaration
(boolean
boolean indicating whether or not the XML declaration should be omitted.
omitDeclaration
)

This will set whether the XML declaration (<?xml version="1.0"?>) will be omitted or not.

public Format

Returns:

a pointer to this Format for chaining
setOmitEncoding
(boolean
boolean indicating whether or not the XML declaration should indicate the document encoding.
omitEncoding
)

This will set whether the XML declaration (<?xml version="1.0" encoding="UTF-8"?>) includes the encoding of the document.

public void
setSpecifiedAttributesOnly(boolean
true if the defaulted Attributes should be ignored, false if they should be output
specifiedAttributesOnly
)

Set whether only those Attributes specified in the input XML should be output.

public Format

Returns:

a pointer to this Format for chaining
setTextMode
(Format.TextMode
The TextMode to set.
mode
)

This sets the text output style.

public static final String

Returns:

The value trimmed
trimBoth
(final String
The value to trim.
str
)

Use the XML Specification definition of whitespace to trim the input value.

public static final String

Returns:

The value left-trimmed
trimLeft
(final String
The value to trim.
str
)

Use the XML Specification definition of whitespace to Left-trim the input value.

public static final String

Returns:

The value right-trimmed
trimRight
(String
The value to trim.
str
)

Use the XML Specification definition of whitespace to Right-trim the input value.

Inherited from java.lang.Object:
equalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

Bits7EscapeStrategyback to summary
private static final EscapeStrategy Bits7EscapeStrategy

An EscapeStrategy suitable for 7-bit charsets

Bits8EscapeStrategyback to summary
private static final EscapeStrategy Bits8EscapeStrategy

An EscapeStrategy suitable for 8-bit charsets

DefaultEscapeStrategyback to summary
private static final EscapeStrategy DefaultEscapeStrategy

An EscapeStrategy suitable for 'unknown' charsets

encodingback to summary
pack-priv String encoding

The encoding format

escapeStrategyback to summary
pack-priv EscapeStrategy escapeStrategy

entity escape logic

expandEmptyElementsback to summary
pack-priv boolean expandEmptyElements

Whether or not to expand empty elements to <tagName></tagName> - default is false

ignoreTrAXEscapingPIsback to summary
pack-priv boolean ignoreTrAXEscapingPIs

Whether TrAX output escaping disabling/enabling PIs are ignored or processed - default is false

indentback to summary
pack-priv String indent

The default indent is no spaces (as original document)

lineSeparatorback to summary
pack-priv String lineSeparator

New line separator

modeback to summary
pack-priv Format.TextMode mode

text handling mode

omitDeclarationback to summary
pack-priv boolean omitDeclaration

Whether or not to output the XML declaration - default is false

omitEncodingback to summary
pack-priv boolean omitEncoding

Whether or not to output the encoding in the XML declaration - default is false

specifiedAttributesOnlyback to summary
pack-priv boolean specifiedAttributesOnly

Whether Attributes that are defaulted from the DTD or Schema are output.

STANDARD_ENCODINGback to summary
private static final String STANDARD_ENCODING

standard encoding

STANDARD_INDENTback to summary
private static final String STANDARD_INDENT

standard value to indent by, if we are indenting

STANDARD_LINE_SEPARATORback to summary
private static final String STANDARD_LINE_SEPARATOR

standard string with which to end a line

UTFEscapeStrategyback to summary
private static final EscapeStrategy UTFEscapeStrategy

An EscapeStrategy suitable for UTF-8 an UTF-16

Constructor Detail

Formatback to summary
private Format()

Creates a new Format instance with default (raw) behavior.

Method Detail

chooseStrategyback to summary
private static final EscapeStrategy chooseStrategy(String encoding)
cloneback to summary
public Format clone()

Overrides java.lang.Object.clone.

Doc from java.lang.Object.clone.

Creates and returns a copy of this object. The precise meaning of "copy" may depend on the class of the object. The general intent is that, for any object x, the expression:

x.clone() != x
will be true, and that the expression:
x.clone().getClass() == x.getClass()
will be true, but these are not absolute requirements. While it is typically the case that:
x.clone().equals(x)
will be true, this is not an absolute requirement.

By convention, the returned object should be obtained by calling super.clone. If a class and all of its superclasses (except Object) obey this convention, it will be the case that x.clone().getClass() == x.getClass().

By convention, the object returned by this method should be independent of this object (which is being cloned). To achieve this independence, it may be necessary to modify one or more fields of the object returned by super.clone before returning it. Typically, this means copying any mutable objects that comprise the internal "deep structure" of the object being cloned and replacing the references to these objects with references to the copies. If a class contains only primitive fields or references to immutable objects, then it is usually the case that no fields in the object returned by super.clone need to be modified.

Returns:Format

a clone of this instance.

Annotations
@Override
compactback to summary
public static final String compact(String str)

Use the XML Specification definition of whitespace to compact the input value. The value is trimmed, and any internal XML whitespace is replaced with a single ' ' space.

Parameters
str:String

The value to compact.

Returns:String

The compacted value

Since
JDOM2
escapeAttributeback to summary
public static final String escapeAttribute(final EscapeStrategy strategy, final String value)

This will take the three pre-defined entities in XML 1.0 ('<', '>', and '&' - used specifically in XML elements) as well as CR/NL, tabs, and Quote characters which require escaping inside Attribute values and converts their character representation to the appropriate entity reference suitable for XML attribute content. Further, some special characters (e.g. characters that are not valid in the current encoding) are converted to escaped representations.

Parameters
strategy:EscapeStrategy

The EscapeStrategy to query.

value:String

String Attribute value to escape.

Returns:String

The value appropriately escaped.

Exceptions
IllegalDataException:
if an entity can not be escaped
escapeTextback to summary
public static final String escapeText(final EscapeStrategy strategy, final String eol, final String value)

This will take the three pre-defined entities in XML 1.0 ('<', '>', and '&' - used specifically in XML elements) and convert their character representation to the appropriate entity reference, suitable for XML element content. Further, some special characters (e.g. characters that are not valid in the current encoding) are converted to escaped representations. If the eol parameter is not null, then any internal newlines will be replaced with the specified eol sequence.

Parameters
strategy:EscapeStrategy

The EscapeStrategy

eol:String

The End-Of-Line sequence to be used (may be null).

value:String

The String to escape

Returns:String

The input value escaped.

Exceptions
IllegalDataException:
if an entity can not be escaped
Since
JDOM2
getCompactFormatback to summary
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.

Returns:Format

a Format with whitespace normalization

getEncodingback to summary
public String getEncoding()

Returns the configured output encoding.

Returns:String

the output encoding

getEscapeStrategyback to summary
public EscapeStrategy getEscapeStrategy()

Returns the current escape strategy

Returns:EscapeStrategy

the current escape strategy

getExpandEmptyElementsback to summary
public boolean getExpandEmptyElements()

Returns whether empty elements are expanded.

Returns:boolean

whether empty elements are expanded

getIgnoreTrAXEscapingPIsback to summary
public boolean getIgnoreTrAXEscapingPIs()

Returns whether JAXP TrAX processing instructions for disabling/enabling output escaping are ignored.

Returns:boolean

whether or not TrAX output escaping PIs are ignored.

getIndentback to summary
public String getIndent()

Returns the indent string in use.

Returns:String

the indent string in use

getLineSeparatorback to summary
public String getLineSeparator()

Returns the current line separator.

Returns:String

the current line separator

getOmitDeclarationback to summary
public boolean getOmitDeclaration()

Returns whether the XML declaration will be omitted.

Returns:boolean

whether the XML declaration will be omitted

getOmitEncodingback to summary
public boolean getOmitEncoding()

Returns whether the XML declaration encoding will be omitted.

Returns:boolean

whether the XML declaration encoding will be omitted

getPrettyFormatback to summary
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.

Returns:Format

a Format with whitespace beautification

getRawFormatback to summary
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.

Returns:Format

a Format with no whitespace changes

getTextModeback to summary
public Format.TextMode getTextMode()

Returns the current text output style.

Returns:Format.TextMode

the current text output style

isSpecifiedAttributesOnlyback to summary
public boolean isSpecifiedAttributesOnly()

Will Attributes defaulted from the DTD or XMLSchema be output

Returns:boolean

true if the defaulted Attributes will be output

setEncodingback to summary
public Format setEncoding(String encoding)

Sets the output encoding. The name should be an accepted XML encoding.

Parameters
encoding:String

the encoding format. Use XML-style names like "UTF-8" or "ISO-8859-1" or "US-ASCII"

Returns:Format

a pointer to this Format for chaining

setEscapeStrategyback to summary
public Format setEscapeStrategy(EscapeStrategy strategy)

Sets the EscapeStrategy to use for character escaping.

Parameters
strategy:EscapeStrategy

the EscapeStrategy to use

Returns:Format

a pointer to this Format for chaining

setExpandEmptyElementsback to summary
public Format setExpandEmptyElements(boolean expandEmptyElements)

This will set whether empty elements are expanded from <tagName/> to <tagName></tagName>.

Parameters
expandEmptyElements:boolean

boolean indicating whether or not empty elements should be expanded.

Returns:Format

a pointer to this Format for chaining

setIgnoreTrAXEscapingPIsback to summary
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 outputting 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.

Parameters
ignoreTrAXEscapingPIs:boolean

boolean indicating whether or not TrAX output escaping PIs are ignored.

See Also
javax.xml.transform.Result#PI_ENABLE_OUTPUT_ESCAPING, javax.xml.transform.Result#PI_DISABLE_OUTPUT_ESCAPING
setIndentback to summary
public Format setIndent(String indent)

This will set the indent String to use; this is usually a String of empty spaces. If you pass the empty string (""), then no indentation will happen but newlines will still be generated. Passing null will result in no indentation and no newlines generated. Default: none (null)

Parameters
indent:String

String to use for indentation.

Returns:Format

a pointer to this Format for chaining

setLineSeparatorback to summary
public Format setLineSeparator(String separator)

This will set the newline separator (LineSeparator). The default is \r\n.

Use the setLineSeparator(LineSeparator) method to set standard separators in an easier way.

To make it output the system default line ending string, call setLineSeparator(System.getProperty("line.separator")).

To output "UNIX-style" documents, call setLineSeparator("\n"). To output "Mac-style" documents, call setLineSeparator("\r"). DOS-style documents use CR-LF ("\r\n"), which is the default.

Note that this only applies to newlines generated by the outputter. All XML parsers are required to 'normalize' all the combinations of line separators to just '\n'. As a result, if any JDOM component has an end-of-line-like value (e.g. '\r') in it then that value must be the result of an escaped value in the XML source document &#xD; or a value explicitly set with one of the Text value setters. Values in JDOM content that were explicitly set to be '\r' will always be escaped on XML Output.

The actual newline separator itself though can be set with this method. Any internal newlines in Text output will be represented by this end-of-line sequence. For example, the following code:

  Text txt = new Text("\r\n");
  XMLOutputter xout = new XMLOutputter();
  String result = xout.outputString(txt);
will produce the literal String sequence "&#xD;\r\n" because the original \r is escaped to be &#xD; and the original \n is replaced with the JDOM default Line Separator "\r\n".

If the format's "indent" property is null (as is the default for the Raw and Compact formats), then this value only effects the newlines written after the declaration and doctype, as well as any newlines embedded within existing text content.

Setting the indent to be null will disable end-of-line processing for any formatting, but will not affect substitution of embedded \n. Setting this value to null or the empty string will disable all end-of-line modifications.
Parameters
separator:String

String line separator to use.

Returns:Format

a pointer to this Format for chaining

See Also
setTextMode, setLineSeparator(LineSeparator)
setLineSeparatorback to summary
public Format setLineSeparator(LineSeparator separator)

This will set the newline separator sequence.

This method differs from setLineSeparator(String) slightly in that, to disable end-of-line processing you should call:

Format.setLinewSeparator(LineSeparator.NONE);
Parameters
separator:LineSeparator

LineSeparator line separator to us

Returns:Format

a pointer to this Format for chaining

Since
JDOM2
See Also
for comprehensive notes.
setOmitDeclarationback to summary
public Format setOmitDeclaration(boolean omitDeclaration)

This will set whether the XML declaration (<?xml version="1.0"?>) will be omitted or not. It is common to omit this in uses such as SOAP and XML-RPC calls.

Parameters
omitDeclaration:boolean

boolean indicating whether or not the XML declaration should be omitted.

Returns:Format

a pointer to this Format for chaining

setOmitEncodingback to summary
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.

Parameters
omitEncoding:boolean

boolean indicating whether or not the XML declaration should indicate the document encoding.

Returns:Format

a pointer to this Format for chaining

setSpecifiedAttributesOnlyback to summary
public void setSpecifiedAttributesOnly(boolean specifiedAttributesOnly)

Set whether only those Attributes specified in the input XML should be output. Other Attributes (those defaulted or 'fixed' in the DTD or XMLSchema) should be ignored.

Parameters
specifiedAttributesOnly:boolean

true if the defaulted Attributes should be ignored, false if they should be output

setTextModeback to summary
public Format setTextMode(Format.TextMode mode)

This sets the text output style. Options are available as static TextMode instances. The default is TextMode#PRESERVE.

Parameters
mode:Format.TextMode

The TextMode to set.

Returns:Format

a pointer to this Format for chaining

trimBothback to summary
public static final String trimBoth(final String str)

Use the XML Specification definition of whitespace to trim the input value.

Parameters
str:String

The value to trim.

Returns:String

The value trimmed

Since
JDOM2
trimLeftback to summary
public static final String trimLeft(final String str)

Use the XML Specification definition of whitespace to Left-trim the input value.

Parameters
str:String

The value to trim.

Returns:String

The value left-trimmed

Since
JDOM2
trimRightback to summary
public static final String trimRight(String str)

Use the XML Specification definition of whitespace to Right-trim the input value.

Parameters
str:String

The value to trim.

Returns:String

The value right-trimmed

Since
JDOM2
org.jdom2.output back to summary

private final Class Format.DefaultCharsetEscapeStrategy

extends Object
implements EscapeStrategy
Class Inheritance
All Implemented Interfaces
org.jdom2.output.EscapeStrategy

Handles Charsets.

Field Summary

Modifier and TypeField and Description
private final CharsetEncoder

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public boolean
shouldEscape(final char
The char to test to determine whether it should be escaped.
ch
)

Implements org.jdom2.output.EscapeStrategy.shouldEscape.

Test whether the supplied character should be formatted literally or as a character entity.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

encoderback to summary
private final CharsetEncoder encoder

Constructor Detail

DefaultCharsetEscapeStrategyback to summary
public DefaultCharsetEscapeStrategy(CharsetEncoder cse)

Method Detail

shouldEscapeback to summary
public boolean shouldEscape(final char ch)

Implements org.jdom2.output.EscapeStrategy.shouldEscape.

Doc from org.jdom2.output.EscapeStrategy.shouldEscape.

Test whether the supplied character should be formatted literally or as a character entity.

Parameters
ch:char

The char to test to determine whether it should be escaped.

Returns:boolean

true if ch should be escaped.

Annotations
@Override
org.jdom2.output back to summary

private final Class Format.EscapeStrategy7Bits

extends Object
implements EscapeStrategy
Class Inheritance
All Implemented Interfaces
org.jdom2.output.EscapeStrategy

An EscapeStrategy suitable for 7-bit charsets. We want the class to have its own name.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public boolean
shouldEscape(final char
The char to test to determine whether it should be escaped.
ch
)

Implements org.jdom2.output.EscapeStrategy.shouldEscape.

Test whether the supplied character should be formatted literally or as a character entity.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

EscapeStrategy7Bitsback to summary
private EscapeStrategy7Bits()

Method Detail

shouldEscapeback to summary
public boolean shouldEscape(final char ch)

Implements org.jdom2.output.EscapeStrategy.shouldEscape.

Doc from org.jdom2.output.EscapeStrategy.shouldEscape.

Test whether the supplied character should be formatted literally or as a character entity.

Parameters
ch:char

The char to test to determine whether it should be escaped.

Returns:boolean

true if ch should be escaped.

Annotations
@Override
org.jdom2.output back to summary

private final Class Format.EscapeStrategy8Bits

extends Object
implements EscapeStrategy
Class Inheritance
All Implemented Interfaces
org.jdom2.output.EscapeStrategy

An EscapeStrategy suitable for 8-bit charsets. We want the class to have its own name.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public boolean
shouldEscape(final char
The char to test to determine whether it should be escaped.
ch
)

Implements org.jdom2.output.EscapeStrategy.shouldEscape.

Test whether the supplied character should be formatted literally or as a character entity.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

EscapeStrategy8Bitsback to summary
private EscapeStrategy8Bits()

Method Detail

shouldEscapeback to summary
public boolean shouldEscape(final char ch)

Implements org.jdom2.output.EscapeStrategy.shouldEscape.

Doc from org.jdom2.output.EscapeStrategy.shouldEscape.

Test whether the supplied character should be formatted literally or as a character entity.

Parameters
ch:char

The char to test to determine whether it should be escaped.

Returns:boolean

true if ch should be escaped.

Annotations
@Override
org.jdom2.output back to summary

private final Class Format.EscapeStrategyUTF

extends Object
implements EscapeStrategy
Class Inheritance
All Implemented Interfaces
org.jdom2.output.EscapeStrategy

An EscapeStrategy suitable for UTF-8 an UTF-16. We want the class to have its own name.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public final boolean
shouldEscape(char
The char to test to determine whether it should be escaped.
ch
)

Implements org.jdom2.output.EscapeStrategy.shouldEscape.

Test whether the supplied character should be formatted literally or as a character entity.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

EscapeStrategyUTFback to summary
private EscapeStrategyUTF()

Method Detail

shouldEscapeback to summary
public final boolean shouldEscape(char ch)

Implements org.jdom2.output.EscapeStrategy.shouldEscape.

Doc from org.jdom2.output.EscapeStrategy.shouldEscape.

Test whether the supplied character should be formatted literally or as a character entity.

Parameters
ch:char

The char to test to determine whether it should be escaped.

Returns:boolean

true if ch should be escaped.

Annotations
@Override
org.jdom2.output back to summary

public final Enum Format.TextMode

extends Enum<Format.TextMode>
Class Inheritance

Class to signify how text should be handled on output. The following table provides details.
Text Mode Resulting behavior.
PRESERVE (Default) All content is printed in the format it was created, no whitespace or line separators are are added or removed.
TRIM_FULL_WHITE Content between tags consisting of all whitespace is not printed. If the content contains even one non-whitespace character, it is all printed verbatim, whitespace and all.
TRIM All leading and trailing whitespace is trimmed.
NORMALIZE Leading and trailing whitespace is trimmed, and any 'internal' whitespace is compressed to a single space.
In most cases textual content is aligned with the surrounding tags (after the appropriate text mode is applied). In the case where the only content between the start and end tags is textual, the start tag, text, and end tag are all printed on the same line. If the document being output already has whitespace, it's wise to turn on TRIM mode so the pre-existing whitespace can be trimmed before adding new whitespace.

When an element has a xml:space attribute with the value of "preserve", all formatting is turned off (actually, the TextMode is set to PRESERVE until the element and its contents have been printed. If a nested element contains another xml:space with the value "default" formatting is turned back on for the child element and then off for the remainder of the parent element.

Since
JDOM2

Field Summary

Modifier and TypeField and Description
public static final Format.TextMode
NORMALIZE

Mode for text normalization (left and right trim plus internal whitespace is normalized to a single space.

public static final Format.TextMode
PRESERVE

Mode for literal text preservation.

public static final Format.TextMode
TRIM

Mode for text trimming (left and right trim).

public static final Format.TextMode
TRIM_FULL_WHITE

Mode for text trimming of content consisting of nothing but whitespace but otherwise not changing output.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static Format.TextMode
public static Format.TextMode[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

NORMALIZEback to summary
public static final Format.TextMode NORMALIZE

Mode for text normalization (left and right trim plus internal whitespace is normalized to a single space.

See Also
org.jdom2.Element#getTextNormalize
PRESERVEback to summary
public static final Format.TextMode PRESERVE

Mode for literal text preservation.

TRIMback to summary
public static final Format.TextMode TRIM

Mode for text trimming (left and right trim).

TRIM_FULL_WHITEback to summary
public static final Format.TextMode TRIM_FULL_WHITE

Mode for text trimming of content consisting of nothing but whitespace but otherwise not changing output.

Constructor Detail

TextModeback to summary
private TextMode()

Method Detail

valueOfback to summary
public static Format.TextMode valueOf(String name)
valuesback to summary
public static Format.TextMode[] values()