Top Description Fields Constructors Methods
org.jdom2

public Class SlimJDOMFactory

extends DefaultJDOMFactory
Class Inheritance
Imports
java.util.Map

This JDOMFactory instance reduces the amount of memory used by JDOM content. It does this by reusing String instances instead of using new (but equals()) instances. It uses the StringBin class to provide a String cache.
Author
Rolf Lear
See Also
StringBin

Field Summary

Modifier and TypeField and Description
private StringBin
private final boolean

Constructor Summary

AccessConstructor and Description
public
public
SlimJDOMFactory(final boolean
should be true if you want the content of CDATA, Text, Comment and Attribute values cached as well.
cachetext
)

Construct a SlimJDOMFactory which will optionally cache Text/CDATA/Comment/Attribute values.

Method Summary

Modifier and TypeMethod and Description
public Attribute
attribute(final String
String name of Attribute.
name
,
final String
String value for new attribute.
value
,
final Namespace
Namespace of the new Attribute
namespace
)

Overrides org.jdom2.DefaultJDOMFactory.attribute.

Implements org.jdom2.JDOMFactory.attribute.

This will create a new Attribute with the specified (local) name and value, and in the provided org.jdom2.Namespace.

public Attribute
attribute(final String
String name of Attribute.
name
,
final String
String value for new attribute.
value
,
final int
int type for new attribute.
type
,
final Namespace
Namespace namespace for new attribute.
namespace
)

Overrides org.jdom2.DefaultJDOMFactory.attribute.

Implements org.jdom2.JDOMFactory.attribute.

Deprecated
This will create a new Attribute with the specified (local) name, value, and type, and in the provided org.jdom2.Namespace.
public Attribute
attribute(final String
String name of Attribute.
name
,
final String
String value for new attribute.
value
,
final AttributeType
AttributeType type for new attribute.
type
,
Namespace
Namespace namespace for new attribute.
namespace
)

Overrides org.jdom2.DefaultJDOMFactory.attribute.

Implements org.jdom2.JDOMFactory.attribute.

This will create a new Attribute with the specified (local) name, value, and type, and in the provided org.jdom2.Namespace.
public Attribute
attribute(final String
String name of Attribute.
name
,
final String
String value for new attribute.
value
)

Overrides org.jdom2.DefaultJDOMFactory.attribute.

Implements org.jdom2.JDOMFactory.attribute.

This will create a new Attribute with the specified (local) name and value, and does not place the attribute in a org.jdom2.Namespace.
public Attribute
attribute(final String
String name of Attribute.
name
,
final String
String value for new attribute.
value
,
final int
int type for new attribute.
type
)

Overrides org.jdom2.DefaultJDOMFactory.attribute.

Implements org.jdom2.JDOMFactory.attribute.

Deprecated
This will create a new Attribute with the specified (local) name, value and type, and does not place the attribute in a org.jdom2.Namespace.
public Attribute
attribute(final String
String name of Attribute.
name
,
final String
String value for new attribute.
value
,
final AttributeType
AttributeType type for new attribute.
type
)

Overrides org.jdom2.DefaultJDOMFactory.attribute.

Implements org.jdom2.JDOMFactory.attribute.

This will create a new Attribute with the specified (local) name, value and type, and does not place the attribute in a org.jdom2.Namespace.
public CDATA
cdata(final int
The line on which this content begins.
line
,
final int
The column on the line at which this content begins.
col
,
final String
String content of CDATA.
str
)

Overrides org.jdom2.DefaultJDOMFactory.cdata.

Implements org.jdom2.JDOMFactory.cdata.

This creates the CDATA with the supplied text.
public void
clearCache()

Reset any Cached String instance data from this SlimJDOMFaxctory cache.

public Comment
comment(final int
The line on which this content begins.
line
,
final int
The column on the line at which this content begins.
col
,
final String
String content of comment.
text
)

Overrides org.jdom2.DefaultJDOMFactory.comment.

Implements org.jdom2.JDOMFactory.comment.

This creates the comment with the supplied text.
public DocType
docType(final int
The line on which this content begins.
line
,
final int
The column on the line at which this content begins.
col
,
final String
String name of element being constrained.
elementName
,
final String
String public ID of referenced DTD
publicID
,
final String
String system ID of referenced DTD
systemID
)

Overrides org.jdom2.DefaultJDOMFactory.docType.

Implements org.jdom2.JDOMFactory.docType.

This will create the DocType with the specified element name and a reference to an external DTD.
public DocType
docType(final int
The line on which this content begins.
line
,
final int
The column on the line at which this content begins.
col
,
final String
String name of element being constrained.
elementName
,
final String
String system ID of referenced DTD
systemID
)

Overrides org.jdom2.DefaultJDOMFactory.docType.

Implements org.jdom2.JDOMFactory.docType.

This will create the DocType with the specified element name and reference to an external DTD.
public DocType
docType(final int
The line on which this content begins.
line
,
final int
The column on the line at which this content begins.
col
,
final String
String name of element being constrained.
elementName
)

Overrides org.jdom2.DefaultJDOMFactory.docType.

Implements org.jdom2.JDOMFactory.docType.

This will create the DocType with the specified element name
public Element
element(final int
The line on which this content begins.
line
,
final int
The column on the line at which this content begins.
col
,
final String
String name of element.
name
,
final Namespace
Namespace to put element in.
namespace
)

Overrides org.jdom2.DefaultJDOMFactory.element.

Implements org.jdom2.JDOMFactory.element.

This will create a new Element with the supplied (local) name, and define the org.jdom2.Namespace to be used.
public Element
element(final int
The line on which this content begins.
line
,
final int
The column on the line at which this content begins.
col
,
final String
String name of element.
name
)

Overrides org.jdom2.DefaultJDOMFactory.element.

Implements org.jdom2.JDOMFactory.element.

This will create an Element in no org.jdom2.Namespace.
public Element
element(final int
The line on which this content begins.
line
,
final int
The column on the line at which this content begins.
col
,
final String
String name of element.
name
,
final String
String URI for Namespace element should be in.
uri
)

Overrides org.jdom2.DefaultJDOMFactory.element.

Implements org.jdom2.JDOMFactory.element.

This will create a new Element with the supplied (local) name, and specifies the URI of the org.jdom2.Namespace the Element should be in, resulting it being unprefixed (in the default namespace).
public Element
element(final int
The line on which this content begins.
line
,
final int
The column on the line at which this content begins.
col
,
final String
String name of element.
name
,
final String
the NamespacePrefic to use for this Element
prefix
,
final String
String URI for Namespace element should be in.
uri
)

Overrides org.jdom2.DefaultJDOMFactory.element.

Implements org.jdom2.JDOMFactory.element.

This will create a new Element with the supplied (local) name, and specifies the prefix and URI of the org.jdom2.Namespace the Element should be in.
public EntityRef
entityRef(final int
The line on which this content begins.
line
,
final int
The column on the line at which this content begins.
col
,
final String
String name of element.
name
)

Overrides org.jdom2.DefaultJDOMFactory.entityRef.

Implements org.jdom2.JDOMFactory.entityRef.

This will create a new EntityRef with the supplied name.
public EntityRef
entityRef(final int
The line on which this content begins.
line
,
final int
The column on the line at which this content begins.
col
,
final String
String name of element.
name
,
final String
String public ID of element.
publicID
,
final String
String system ID of element.
systemID
)

Overrides org.jdom2.DefaultJDOMFactory.entityRef.

Implements org.jdom2.JDOMFactory.entityRef.

This will create a new EntityRef with the supplied name, public ID, and system ID.
public EntityRef
entityRef(final int
The line on which this content begins.
line
,
final int
The column on the line at which this content begins.
col
,
final String
String name of element.
name
,
final String
String system ID of element.
systemID
)

Overrides org.jdom2.DefaultJDOMFactory.entityRef.

Implements org.jdom2.JDOMFactory.entityRef.

This will create a new EntityRef with the supplied name and system ID.
public ProcessingInstruction
processingInstruction(final int
The line on which this content begins.
line
,
final int
The column on the line at which this content begins.
col
,
final String
String target of PI.
target
,
final Map<String, String>
Map data for PI, in name/value pairs
data
)

Overrides org.jdom2.DefaultJDOMFactory.processingInstruction.

Implements org.jdom2.JDOMFactory.processingInstruction.

This will create a new ProcessingInstruction with the specified target and data.
public ProcessingInstruction
processingInstruction(final int
The line on which this content begins.
line
,
final int
The column on the line at which this content begins.
col
,
final String
String target of PI.
target
,
final String
String data for PI.
data
)

Overrides org.jdom2.DefaultJDOMFactory.processingInstruction.

Implements org.jdom2.JDOMFactory.processingInstruction.

This will create a new ProcessingInstruction with the specified target and data.
public ProcessingInstruction
processingInstruction(final int
The line on which this content begins.
line
,
final int
The column on the line at which this content begins.
col
,
final String
String target of PI.
target
)

Overrides org.jdom2.DefaultJDOMFactory.processingInstruction.

Implements org.jdom2.JDOMFactory.processingInstruction.

This will create a new ProcessingInstruction with the specified target and no data.
public Text
text(final int
The line on which this content begins.
line
,
final int
The column on the line at which this content begins.
col
,
final String
String content of Text.
str
)

Overrides org.jdom2.DefaultJDOMFactory.text.

Implements org.jdom2.JDOMFactory.text.

This creates the Text with the supplied text.
Inherited from org.jdom2.DefaultJDOMFactory:
addContentaddNamespaceDeclarationcdatacommentdocTypedocTypedocTypedocumentdocumentdocumentelementelementelementelemententityRefentityRefentityRefprocessingInstructionprocessingInstructionprocessingInstructionsetAttributesetRoottext

Field Detail

cacheback to summary
private StringBin cache
cachetextback to summary
private final boolean cachetext

Constructor Detail

SlimJDOMFactoryback to summary
public SlimJDOMFactory()
SlimJDOMFactoryback to summary
public SlimJDOMFactory(final boolean cachetext)

Construct a SlimJDOMFactory which will optionally cache Text/CDATA/Comment/Attribute values. Caching these values is recommended because often XML documents have many instances of the same Text values (especially whitespace sequences...)

Parameters
cachetext:boolean

should be true if you want the content of CDATA, Text, Comment and Attribute values cached as well.

Method Detail

attributeback to summary
public Attribute attribute(final String name, final String value, final Namespace namespace)

Overrides org.jdom2.DefaultJDOMFactory.attribute.

Implements org.jdom2.JDOMFactory.attribute.

Doc from org.jdom2.JDOMFactory.attribute.

This will create a new Attribute with the specified (local) name and value, and in the provided org.jdom2.Namespace.

Parameters
name:String

String name of Attribute.

value:String

String value for new attribute.

namespace:Namespace

Namespace of the new Attribute

Returns:Attribute

the created Attribute instance

Annotations
@Override
attributeback to summary
public Attribute attribute(final String name, final String value, final int type, final Namespace namespace)

Overrides org.jdom2.DefaultJDOMFactory.attribute.

Implements org.jdom2.JDOMFactory.attribute.

Doc from org.jdom2.JDOMFactory.attribute.

Deprecated

This will create a new Attribute with the specified (local) name, value, and type, and in the provided org.jdom2.Namespace.

Parameters
name:String

String name of Attribute.

value:String

String value for new attribute.

type:int

int type for new attribute.

namespace:Namespace

Namespace namespace for new attribute.

Returns:Attribute

the created Attribute instance

Annotations
@Override
@Deprecated
attributeback to summary
public Attribute attribute(final String name, final String value, final AttributeType type, Namespace namespace)

Overrides org.jdom2.DefaultJDOMFactory.attribute.

Implements org.jdom2.JDOMFactory.attribute.

Doc from org.jdom2.JDOMFactory.attribute.

This will create a new Attribute with the specified (local) name, value, and type, and in the provided org.jdom2.Namespace.

Parameters
name:String

String name of Attribute.

value:String

String value for new attribute.

type:AttributeType

AttributeType type for new attribute.

namespace:Namespace

Namespace namespace for new attribute.

Returns:Attribute

the created Attribute instance

Annotations
@Override
attributeback to summary
public Attribute attribute(final String name, final String value)

Overrides org.jdom2.DefaultJDOMFactory.attribute.

Implements org.jdom2.JDOMFactory.attribute.

Doc from org.jdom2.JDOMFactory.attribute.

This will create a new Attribute with the specified (local) name and value, and does not place the attribute in a org.jdom2.Namespace.

Note

This actually explicitly puts the Attribute in the "empty" Namespace (org.jdom2.Namespace#NO_NAMESPACE).

Parameters
name:String

String name of Attribute.

value:String

String value for new attribute.

Returns:Attribute

the created Attribute instance

Annotations
@Override
attributeback to summary
public Attribute attribute(final String name, final String value, final int type)

Overrides org.jdom2.DefaultJDOMFactory.attribute.

Implements org.jdom2.JDOMFactory.attribute.

Doc from org.jdom2.JDOMFactory.attribute.

Deprecated

This will create a new Attribute with the specified (local) name, value and type, and does not place the attribute in a org.jdom2.Namespace.

Note

This actually explicitly puts the Attribute in the "empty" Namespace (org.jdom2.Namespace#NO_NAMESPACE).

Parameters
name:String

String name of Attribute.

value:String

String value for new attribute.

type:int

int type for new attribute.

Returns:Attribute

the created Attribute instance

Annotations
@Override
@Deprecated
attributeback to summary
public Attribute attribute(final String name, final String value, final AttributeType type)

Overrides org.jdom2.DefaultJDOMFactory.attribute.

Implements org.jdom2.JDOMFactory.attribute.

Doc from org.jdom2.JDOMFactory.attribute.

This will create a new Attribute with the specified (local) name, value and type, and does not place the attribute in a org.jdom2.Namespace.

Note

This actually explicitly puts the Attribute in the "empty" Namespace (org.jdom2.Namespace#NO_NAMESPACE).

Parameters
name:String

String name of Attribute.

value:String

String value for new attribute.

type:AttributeType

AttributeType type for new attribute.

Returns:Attribute

the created Attribute instance

Annotations
@Override
cdataback to summary
public CDATA cdata(final int line, final int col, final String str)

Overrides org.jdom2.DefaultJDOMFactory.cdata.

Implements org.jdom2.JDOMFactory.cdata.

Doc from org.jdom2.JDOMFactory.cdata.

This creates the CDATA with the supplied text.

Parameters
line:int

The line on which this content begins.

col:int

The column on the line at which this content begins.

str:String

String content of CDATA.

Returns:CDATA

the created CDATA instance

Annotations
@Override
clearCacheback to summary
public void clearCache()

Reset any Cached String instance data from this SlimJDOMFaxctory cache.

commentback to summary
public Comment comment(final int line, final int col, final String text)

Overrides org.jdom2.DefaultJDOMFactory.comment.

Implements org.jdom2.JDOMFactory.comment.

Doc from org.jdom2.JDOMFactory.comment.

This creates the comment with the supplied text.

Parameters
line:int

The line on which this content begins.

col:int

The column on the line at which this content begins.

text:String

String content of comment.

Returns:Comment

the created Comment instance

Annotations
@Override
docTypeback to summary
public DocType docType(final int line, final int col, final String elementName, final String publicID, final String systemID)

Overrides org.jdom2.DefaultJDOMFactory.docType.

Implements org.jdom2.JDOMFactory.docType.

Doc from org.jdom2.JDOMFactory.docType.

This will create the DocType with the specified element name and a reference to an external DTD.

Parameters
line:int

The line on which this content begins.

col:int

The column on the line at which this content begins.

elementName:String

String name of element being constrained.

publicID:String

String public ID of referenced DTD

systemID:String

String system ID of referenced DTD

Returns:DocType

the created DocType instance

Annotations
@Override
docTypeback to summary
public DocType docType(final int line, final int col, final String elementName, final String systemID)

Overrides org.jdom2.DefaultJDOMFactory.docType.

Implements org.jdom2.JDOMFactory.docType.

Doc from org.jdom2.JDOMFactory.docType.

This will create the DocType with the specified element name and reference to an external DTD.

Parameters
line:int

The line on which this content begins.

col:int

The column on the line at which this content begins.

elementName:String

String name of element being constrained.

systemID:String

String system ID of referenced DTD

Returns:DocType

the created DocType instance

Annotations
@Override
docTypeback to summary
public DocType docType(final int line, final int col, final String elementName)

Overrides org.jdom2.DefaultJDOMFactory.docType.

Implements org.jdom2.JDOMFactory.docType.

Doc from org.jdom2.JDOMFactory.docType.

This will create the DocType with the specified element name

Parameters
line:int

The line on which this content begins.

col:int

The column on the line at which this content begins.

elementName:String

String name of element being constrained.

Returns:DocType

the created DocType instance

Annotations
@Override
elementback to summary
public Element element(final int line, final int col, final String name, final Namespace namespace)

Overrides org.jdom2.DefaultJDOMFactory.element.

Implements org.jdom2.JDOMFactory.element.

Doc from org.jdom2.JDOMFactory.element.

This will create a new Element with the supplied (local) name, and define the org.jdom2.Namespace to be used.

Parameters
line:int

The line on which this content begins.

col:int

The column on the line at which this content begins.

name:String

String name of element.

namespace:Namespace

Namespace to put element in.

Returns:Element

the created Element instance

Annotations
@Override
elementback to summary
public Element element(final int line, final int col, final String name)

Overrides org.jdom2.DefaultJDOMFactory.element.

Implements org.jdom2.JDOMFactory.element.

Doc from org.jdom2.JDOMFactory.element.

This will create an Element in no org.jdom2.Namespace.

Parameters
line:int

The line on which this content begins.

col:int

The column on the line at which this content begins.

name:String

String name of element.

Returns:Element

the created Element instance

Annotations
@Override
elementback to summary
public Element element(final int line, final int col, final String name, final String uri)

Overrides org.jdom2.DefaultJDOMFactory.element.

Implements org.jdom2.JDOMFactory.element.

Doc from org.jdom2.JDOMFactory.element.

This will create a new Element with the supplied (local) name, and specifies the URI of the org.jdom2.Namespace the Element should be in, resulting it being unprefixed (in the default namespace).

Parameters
line:int

The line on which this content begins.

col:int

The column on the line at which this content begins.

name:String

String name of element.

uri:String

String URI for Namespace element should be in.

Returns:Element

the created Element instance

Annotations
@Override
elementback to summary
public Element element(final int line, final int col, final String name, final String prefix, final String uri)

Overrides org.jdom2.DefaultJDOMFactory.element.

Implements org.jdom2.JDOMFactory.element.

Doc from org.jdom2.JDOMFactory.element.

This will create a new Element with the supplied (local) name, and specifies the prefix and URI of the org.jdom2.Namespace the Element should be in.

Parameters
line:int

The line on which this content begins.

col:int

The column on the line at which this content begins.

name:String

String name of element.

prefix:String

the NamespacePrefic to use for this Element

uri:String

String URI for Namespace element should be in.

Returns:Element

the created Element instance

Annotations
@Override
entityRefback to summary
public EntityRef entityRef(final int line, final int col, final String name)

Overrides org.jdom2.DefaultJDOMFactory.entityRef.

Implements org.jdom2.JDOMFactory.entityRef.

Doc from org.jdom2.JDOMFactory.entityRef.

This will create a new EntityRef with the supplied name.

Parameters
line:int

The line on which this content begins.

col:int

The column on the line at which this content begins.

name:String

String name of element.

Returns:EntityRef

the created EntityRef instance

Annotations
@Override
entityRefback to summary
public EntityRef entityRef(final int line, final int col, final String name, final String publicID, final String systemID)

Overrides org.jdom2.DefaultJDOMFactory.entityRef.

Implements org.jdom2.JDOMFactory.entityRef.

Doc from org.jdom2.JDOMFactory.entityRef.

This will create a new EntityRef with the supplied name, public ID, and system ID.

Parameters
line:int

The line on which this content begins.

col:int

The column on the line at which this content begins.

name:String

String name of element.

publicID:String

String public ID of element.

systemID:String

String system ID of element.

Returns:EntityRef

the created EntityRef instance

Annotations
@Override
entityRefback to summary
public EntityRef entityRef(final int line, final int col, final String name, final String systemID)

Overrides org.jdom2.DefaultJDOMFactory.entityRef.

Implements org.jdom2.JDOMFactory.entityRef.

Doc from org.jdom2.JDOMFactory.entityRef.

This will create a new EntityRef with the supplied name and system ID.

Parameters
line:int

The line on which this content begins.

col:int

The column on the line at which this content begins.

name:String

String name of element.

systemID:String

String system ID of element.

Returns:EntityRef

the created EntityRef instance

Annotations
@Override
processingInstructionback to summary
public ProcessingInstruction processingInstruction(final int line, final int col, final String target, final Map<String, String> data)

Overrides org.jdom2.DefaultJDOMFactory.processingInstruction.

Implements org.jdom2.JDOMFactory.processingInstruction.

Doc from org.jdom2.JDOMFactory.processingInstruction.

This will create a new ProcessingInstruction with the specified target and data.

Parameters
line:int

The line on which this content begins.

col:int

The column on the line at which this content begins.

target:String

String target of PI.

data:Map<String, String>

Map data for PI, in name/value pairs

Returns:ProcessingInstruction

the created ProcessingInstruction instance

Annotations
@Override
processingInstructionback to summary
public ProcessingInstruction processingInstruction(final int line, final int col, final String target, final String data)

Overrides org.jdom2.DefaultJDOMFactory.processingInstruction.

Implements org.jdom2.JDOMFactory.processingInstruction.

Doc from org.jdom2.JDOMFactory.processingInstruction.

This will create a new ProcessingInstruction with the specified target and data.

Parameters
line:int

The line on which this content begins.

col:int

The column on the line at which this content begins.

target:String

String target of PI.

data:String

String data for PI.

Returns:ProcessingInstruction

the created ProcessingInstruction instance

Annotations
@Override
processingInstructionback to summary
public ProcessingInstruction processingInstruction(final int line, final int col, final String target)

Overrides org.jdom2.DefaultJDOMFactory.processingInstruction.

Implements org.jdom2.JDOMFactory.processingInstruction.

Doc from org.jdom2.JDOMFactory.processingInstruction.

This will create a new ProcessingInstruction with the specified target and no data.

Parameters
line:int

The line on which this content begins.

col:int

The column on the line at which this content begins.

target:String

String target of PI.

Returns:ProcessingInstruction

the created ProcessingInstruction instance

Annotations
@Override
textback to summary
public Text text(final int line, final int col, final String str)

Overrides org.jdom2.DefaultJDOMFactory.text.

Implements org.jdom2.JDOMFactory.text.

Doc from org.jdom2.JDOMFactory.text.

This creates the Text with the supplied text.

Parameters
line:int

The line on which this content begins.

col:int

The column on the line at which this content begins.

str:String

String content of Text.

Returns:Text

the created Text instance

Annotations
@Override