Project JXTA

net.jxta.impl.document
Class PlainTextElement

java.lang.Object
  extended by net.jxta.impl.document.TextElementCommon
      extended by net.jxta.impl.document.PlainTextElement
All Implemented Interfaces:
Attributable, Element, TextElement
Direct Known Subclasses:
PlainTextDocument

public class PlainTextElement
extends TextElementCommon
implements Attributable

This class is an implementation of the StructuredDocument interface using simple text


Field Summary
protected  PlainTextDocument doc
           
protected  String name
           
protected  Element parent
           
protected  String val
           
 
Constructor Summary
protected PlainTextElement(PlainTextDocument doc, String name)
          Creates new PlainTextElement
protected PlainTextElement(PlainTextDocument doc, String name, String val)
          Creates new PlainTextElement
 
Method Summary
 String addAttribute(Attribute newAttrib)
          Adds an attribute with the given name and value.
 String addAttribute(String name, String value)
          
 void appendChild(TextElement element)
          
 boolean equals(Object element)
          
 Attribute getAttribute(String name)
          
 Enumeration getAttributes()
          
 Enumeration getChildren()
          
 Enumeration getChildren(String name)
          
 String getName()
          
 Element getParent()
          
 StructuredDocument getRoot()
          
 String getTextValue()
          
protected  void printNice(Writer into, int indent, boolean recurse)
          Write the contents of this element and optionally its children.
 
Methods inherited from class net.jxta.impl.document.TextElementCommon
appendChild, getChildren, getKey, getValue
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

doc

protected PlainTextDocument doc

parent

protected Element parent

name

protected final String name

val

protected final String val
Constructor Detail

PlainTextElement

protected PlainTextElement(PlainTextDocument doc,
                           String name)
Creates new PlainTextElement


PlainTextElement

protected PlainTextElement(PlainTextDocument doc,
                           String name,
                           String val)
Creates new PlainTextElement

Method Detail

equals

public boolean equals(Object element)

Overrides:
equals in class Object

getRoot

public StructuredDocument getRoot()

Specified by:
getRoot in interface Element

getParent

public Element getParent()

Specified by:
getParent in interface Element

getChildren

public Enumeration getChildren()

Specified by:
getChildren in interface Element

getName

public String getName()

Specified by:
getName in interface TextElement

getTextValue

public String getTextValue()

Specified by:
getTextValue in interface TextElement

appendChild

public void appendChild(TextElement element)

Specified by:
appendChild in interface TextElement

getChildren

public Enumeration getChildren(String name)

Specified by:
getChildren in interface TextElement

printNice

protected void printNice(Writer into,
                         int indent,
                         boolean recurse)
                  throws IOException
Write the contents of this element and optionally its children. The writing is done to a provided java.io.Writer. The writing can optionally be indented

Parameters:
into - The java.io.Writer that the output will be sent to.
indent - the number of tabs which will be inserted before each line.
recurse - if true then also print the children of this element.
Throws:
IOException

addAttribute

public String addAttribute(String name,
                           String value)

Specified by:
addAttribute in interface Attributable

addAttribute

public String addAttribute(Attribute newAttrib)
Adds an attribute with the given name and value. Some implementations may support only a single value for each distinct name. Others may support multiple values for each name. If the value being provided replaces some other value then that value is returned otherwise null is returned.

Specified by:
addAttribute in interface Attributable
Parameters:
newAttrib - new attribute.
Returns:
String containing previous value for this name if the value is being replaced otherwise null.

getAttributes

public Enumeration getAttributes()

Specified by:
getAttributes in interface Attributable

getAttribute

public Attribute getAttribute(String name)

Specified by:
getAttribute in interface Attributable

JXTA J2SE