Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jdom
Class Comment

    java.lang.Object
      |
      +--org.jdom.Comment

public class Comment
extends Object
implements Serializable, Cloneable

`Comment` defines behavior for an XML comment, modeled in Java. Methods allow the user to obtain the text of the comment.

Version:
  1.0
Author:
  Brett McLaughlin, Jason Hunter
See Also:
  Serialized Form

Field Summary
`protected Document` | `document` Document node if comment is outside the root element, or null if none
`protected Element` | `parent` Parent node, or null if none
`protected String` | `text` Text of the `Comment`

Constructor Summary
`protected` | `Comment()` Default, no-args constructor for implementations to use if needed.
`` | `Comment(String text)` This creates the comment with the supplied text.

Method Summary
`Object` | `clone()` This will return a clone of this `Comment`.
`Comment` | `detach()` This detaches the `Comment` from its parent, or does nothing if the `Comment` has no parent.
`boolean` | `equals(Object ob)` This tests for equality of this `Comment` to the supplied `Object`.
`Document` | `getDocument()` This retrieves the owning ``Document`` for this Comment, or null if not a currently a member of a ``Document``.
`Element` | `getParent()` This will return the parent of this `Comment`.
`String` | `getSerializedForm()` Deprecated. Deprecated in beta7, use XMLOutputter.outputString(Comment) instead
`String` | `getText()` This returns the textual data within the `Comment`.
`int` | `hashCode()` This returns the hash code for this `Comment`.
`protected Comment` | `setDocument(Document document)` This sets the ``Document`` parent of this comment.
`protected Comment` | `setParent(Element parent)` This will set the parent of this `Comment`.
`Comment` | `setText(String text)` This will set the value of the `Comment`.
`String` | `toString()` This returns a `String` representation of the `Comment`, suitable for debugging.

Methods inherited from class java.lang.Object
`finalize, getClass, notify, notifyAll, wait, wait, wait`

Field Detail

### text

    protected String text

  Text of the `Comment`

### parent

    protected Element parent

  Parent node, or null if none

### document

    protected Document document

  Document node if comment is outside the root element, or null if none

Constructor Detail

### Comment

    protected Comment()

  Default, no-args constructor for implementations to use if needed.

### Comment

    public Comment(String text)

  This creates the comment with the supplied text.

  Parameters:
    `text` - `String` content of comment.

Method Detail

### getParent

    public Element getParent()

  This will return the parent of this `Comment`. If there is no parent, then this returns `null`.

  Returns:
    parent of this `Comment`

### setParent

    protected Comment setParent(Element parent)

  This will set the parent of this `Comment`.

  Parameters:
    `parent` - `Element` to be new parent.
  Returns:
    this `Comment` modified.

### detach

    public Comment detach()

  This detaches the `Comment` from its parent, or does nothing if the `Comment` has no parent.

  Returns:
    `Comment` - this `Comment` modified.

### getDocument

    public Document getDocument()

  This retrieves the owning ``Document`` for this Comment, or null if not a currently a member of a ``Document``.

  Returns:
    `Document` owning this Element, or null.

### setDocument

    protected Comment setDocument(Document document)

  This sets the ``Document`` parent of this comment.

  Parameters:
    `document` - `Document` parent
  Returns:
    this `Comment` modified

### getText

    public String getText()

  This returns the textual data within the `Comment`.

  Returns:
    `String` - text of comment.

### setText

    public Comment setText(String text)

  This will set the value of the `Comment`.

  Parameters:
    `text` - `String` text for comment.
  Returns:
    `Comment` - this Comment modified.
  Throws:
    IllegalDataException - if the given text is invalid for a Comment.

### toString

    public String toString()

  This returns a `String` representation of the `Comment`, suitable for debugging. If the XML representation of the `Comment` is desired, `XMLOutputter.outputString(Comment)` should be used.

  Overrides:
    toString in class Object
  Returns:
    `String` - information about the `Attribute`

### equals

    public final boolean equals(Object ob)

  This tests for equality of this `Comment` to the supplied `Object`.

  Overrides:
    equals in class Object
  Parameters:
    `ob` - `Object` to compare to.
  Returns:
    `boolean` - whether the `Comment` is equal to the supplied `Object`.

### hashCode

    public final int hashCode()

  This returns the hash code for this `Comment`.

  Overrides:
    hashCode in class Object
  Returns:
    `int` - hash code.

### clone

    public Object clone()

  This will return a clone of this `Comment`.

  Overrides:
    clone in class Object
  Returns:
    `Object` - clone of this `Comment`.

### getSerializedForm

    public final String getSerializedForm()

  Deprecated. Deprecated in beta7, use XMLOutputter.outputString(Comment) instead

  This will return the `Comment` in XML format, usable in an XML document.

  Returns:
    `String` - the serialized form of the `Comment`.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001 Jason Hunter, Brett McLaughlin. All Rights Reserved.