Package org.jdom2

Class SlimJDOMFactory

All Implemented Interfaces:
JDOMFactory

public class SlimJDOMFactory extends DefaultJDOMFactory
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
  • Constructor Details

    • SlimJDOMFactory

      public SlimJDOMFactory()
    • SlimJDOMFactory

      public SlimJDOMFactory(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 - should be true if you want the content of CDATA, Text, Comment and Attribute values cached as well.
  • Method Details

    • clearCache

      public void clearCache()
      Reset any Cached String instance data from this SlimJDOMFaxctory cache.
    • attribute

      public Attribute attribute(String name, String value, Namespace namespace)
      Description copied from interface: JDOMFactory

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

      Specified by:
      attribute in interface JDOMFactory
      Overrides:
      attribute in class DefaultJDOMFactory
      Parameters:
      name - String name of Attribute.
      value - String value for new attribute.
      namespace - Namespace of the new Attribute
      Returns:
      the created Attribute instance
    • attribute

      @Deprecated public Attribute attribute(String name, String value, int type, Namespace namespace)
      Deprecated.
      Description copied from interface: JDOMFactory
      This will create a new Attribute with the specified (local) name, value, and type, and in the provided Namespace.
      Specified by:
      attribute in interface JDOMFactory
      Overrides:
      attribute in class DefaultJDOMFactory
      Parameters:
      name - String name of Attribute.
      value - String value for new attribute.
      type - int type for new attribute.
      namespace - Namespace namespace for new attribute.
      Returns:
      the created Attribute instance
    • attribute

      public Attribute attribute(String name, String value, AttributeType type, Namespace namespace)
      Description copied from interface: JDOMFactory
      This will create a new Attribute with the specified (local) name, value, and type, and in the provided Namespace.
      Specified by:
      attribute in interface JDOMFactory
      Overrides:
      attribute in class DefaultJDOMFactory
      Parameters:
      name - String name of Attribute.
      value - String value for new attribute.
      type - AttributeType type for new attribute.
      namespace - Namespace namespace for new attribute.
      Returns:
      the created Attribute instance
    • attribute

      public Attribute attribute(String name, String value)
      Description copied from interface: JDOMFactory
      This will create a new Attribute with the specified (local) name and value, and does not place the attribute in a Namespace.

      Note: This actually explicitly puts the Attribute in the "empty" Namespace (Namespace.NO_NAMESPACE).

      Specified by:
      attribute in interface JDOMFactory
      Overrides:
      attribute in class DefaultJDOMFactory
      Parameters:
      name - String name of Attribute.
      value - String value for new attribute.
      Returns:
      the created Attribute instance
    • attribute

      @Deprecated public Attribute attribute(String name, String value, int type)
      Deprecated.
      Description copied from interface: JDOMFactory
      This will create a new Attribute with the specified (local) name, value and type, and does not place the attribute in a Namespace.

      Note: This actually explicitly puts the Attribute in the "empty" Namespace (Namespace.NO_NAMESPACE).

      Specified by:
      attribute in interface JDOMFactory
      Overrides:
      attribute in class DefaultJDOMFactory
      Parameters:
      name - String name of Attribute.
      value - String value for new attribute.
      type - int type for new attribute.
      Returns:
      the created Attribute instance
    • attribute

      public Attribute attribute(String name, String value, AttributeType type)
      Description copied from interface: JDOMFactory
      This will create a new Attribute with the specified (local) name, value and type, and does not place the attribute in a Namespace.

      Note: This actually explicitly puts the Attribute in the "empty" Namespace (Namespace.NO_NAMESPACE).

      Specified by:
      attribute in interface JDOMFactory
      Overrides:
      attribute in class DefaultJDOMFactory
      Parameters:
      name - String name of Attribute.
      value - String value for new attribute.
      type - AttributeType type for new attribute.
      Returns:
      the created Attribute instance
    • cdata

      public CDATA cdata(int line, int col, String str)
      Description copied from interface: JDOMFactory
      This creates the CDATA with the supplied text.
      Specified by:
      cdata in interface JDOMFactory
      Overrides:
      cdata in class DefaultJDOMFactory
      Parameters:
      line - The line on which this content begins.
      col - The column on the line at which this content begins.
      str - String content of CDATA.
      Returns:
      the created CDATA instance
    • text

      public Text text(int line, int col, String str)
      Description copied from interface: JDOMFactory
      This creates the Text with the supplied text.
      Specified by:
      text in interface JDOMFactory
      Overrides:
      text in class DefaultJDOMFactory
      Parameters:
      line - The line on which this content begins.
      col - The column on the line at which this content begins.
      str - String content of Text.
      Returns:
      the created Text instance
    • comment

      public Comment comment(int line, int col, String text)
      Description copied from interface: JDOMFactory
      This creates the comment with the supplied text.
      Specified by:
      comment in interface JDOMFactory
      Overrides:
      comment in class DefaultJDOMFactory
      Parameters:
      line - The line on which this content begins.
      col - The column on the line at which this content begins.
      text - String content of comment.
      Returns:
      the created Comment instance
    • docType

      public DocType docType(int line, int col, String elementName, String publicID, String systemID)
      Description copied from interface: JDOMFactory
      This will create the DocType with the specified element name and a reference to an external DTD.
      Specified by:
      docType in interface JDOMFactory
      Overrides:
      docType in class DefaultJDOMFactory
      Parameters:
      line - The line on which this content begins.
      col - The column on the line at which this content begins.
      elementName - String name of element being constrained.
      publicID - String public ID of referenced DTD
      systemID - String system ID of referenced DTD
      Returns:
      the created DocType instance
    • docType

      public DocType docType(int line, int col, String elementName, String systemID)
      Description copied from interface: JDOMFactory
      This will create the DocType with the specified element name and reference to an external DTD.
      Specified by:
      docType in interface JDOMFactory
      Overrides:
      docType in class DefaultJDOMFactory
      Parameters:
      line - The line on which this content begins.
      col - The column on the line at which this content begins.
      elementName - String name of element being constrained.
      systemID - String system ID of referenced DTD
      Returns:
      the created DocType instance
    • docType

      public DocType docType(int line, int col, String elementName)
      Description copied from interface: JDOMFactory
      This will create the DocType with the specified element name
      Specified by:
      docType in interface JDOMFactory
      Overrides:
      docType in class DefaultJDOMFactory
      Parameters:
      line - The line on which this content begins.
      col - The column on the line at which this content begins.
      elementName - String name of element being constrained.
      Returns:
      the created DocType instance
    • element

      public Element element(int line, int col, String name, Namespace namespace)
      Description copied from interface: JDOMFactory
      This will create a new Element with the supplied (local) name, and define the Namespace to be used.
      Specified by:
      element in interface JDOMFactory
      Overrides:
      element in class DefaultJDOMFactory
      Parameters:
      line - The line on which this content begins.
      col - The column on the line at which this content begins.
      name - String name of element.
      namespace - Namespace to put element in.
      Returns:
      the created Element instance
    • element

      public Element element(int line, int col, String name)
      Description copied from interface: JDOMFactory
      This will create an Element in no Namespace.
      Specified by:
      element in interface JDOMFactory
      Overrides:
      element in class DefaultJDOMFactory
      Parameters:
      line - The line on which this content begins.
      col - The column on the line at which this content begins.
      name - String name of element.
      Returns:
      the created Element instance
    • element

      public Element element(int line, int col, String name, String uri)
      Description copied from interface: JDOMFactory
      This will create a new Element with the supplied (local) name, and specifies the URI of the Namespace the Element should be in, resulting it being unprefixed (in the default namespace).
      Specified by:
      element in interface JDOMFactory
      Overrides:
      element in class DefaultJDOMFactory
      Parameters:
      line - The line on which this content begins.
      col - The column on the line at which this content begins.
      name - String name of element.
      uri - String URI for Namespace element should be in.
      Returns:
      the created Element instance
    • element

      public Element element(int line, int col, String name, String prefix, String uri)
      Description copied from interface: JDOMFactory
      This will create a new Element with the supplied (local) name, and specifies the prefix and URI of the Namespace the Element should be in.
      Specified by:
      element in interface JDOMFactory
      Overrides:
      element in class DefaultJDOMFactory
      Parameters:
      line - The line on which this content begins.
      col - The column on the line at which this content begins.
      name - String name of element.
      prefix - the NamespacePrefic to use for this Element
      uri - String URI for Namespace element should be in.
      Returns:
      the created Element instance
    • processingInstruction

      public ProcessingInstruction processingInstruction(int line, int col, String target, Map<String,String> data)
      Description copied from interface: JDOMFactory
      This will create a new ProcessingInstruction with the specified target and data.
      Specified by:
      processingInstruction in interface JDOMFactory
      Overrides:
      processingInstruction in class DefaultJDOMFactory
      Parameters:
      line - The line on which this content begins.
      col - The column on the line at which this content begins.
      target - String target of PI.
      data - Map data for PI, in name/value pairs
      Returns:
      the created ProcessingInstruction instance
    • processingInstruction

      public ProcessingInstruction processingInstruction(int line, int col, String target, String data)
      Description copied from interface: JDOMFactory
      This will create a new ProcessingInstruction with the specified target and data.
      Specified by:
      processingInstruction in interface JDOMFactory
      Overrides:
      processingInstruction in class DefaultJDOMFactory
      Parameters:
      line - The line on which this content begins.
      col - The column on the line at which this content begins.
      target - String target of PI.
      data - String data for PI.
      Returns:
      the created ProcessingInstruction instance
    • processingInstruction

      public ProcessingInstruction processingInstruction(int line, int col, String target)
      Description copied from interface: JDOMFactory
      This will create a new ProcessingInstruction with the specified target and no data.
      Specified by:
      processingInstruction in interface JDOMFactory
      Overrides:
      processingInstruction in class DefaultJDOMFactory
      Parameters:
      line - The line on which this content begins.
      col - The column on the line at which this content begins.
      target - String target of PI.
      Returns:
      the created ProcessingInstruction instance
    • entityRef

      public EntityRef entityRef(int line, int col, String name)
      Description copied from interface: JDOMFactory
      This will create a new EntityRef with the supplied name.
      Specified by:
      entityRef in interface JDOMFactory
      Overrides:
      entityRef in class DefaultJDOMFactory
      Parameters:
      line - The line on which this content begins.
      col - The column on the line at which this content begins.
      name - String name of element.
      Returns:
      the created EntityRef instance
    • entityRef

      public EntityRef entityRef(int line, int col, String name, String publicID, String systemID)
      Description copied from interface: JDOMFactory
      This will create a new EntityRef with the supplied name, public ID, and system ID.
      Specified by:
      entityRef in interface JDOMFactory
      Overrides:
      entityRef in class DefaultJDOMFactory
      Parameters:
      line - The line on which this content begins.
      col - The column on the line at which this content begins.
      name - String name of element.
      publicID - String public ID of element.
      systemID - String system ID of element.
      Returns:
      the created EntityRef instance
    • entityRef

      public EntityRef entityRef(int line, int col, String name, String systemID)
      Description copied from interface: JDOMFactory
      This will create a new EntityRef with the supplied name and system ID.
      Specified by:
      entityRef in interface JDOMFactory
      Overrides:
      entityRef in class DefaultJDOMFactory
      Parameters:
      line - The line on which this content begins.
      col - The column on the line at which this content begins.
      name - String name of element.
      systemID - String system ID of element.
      Returns:
      the created EntityRef instance