info.bliki.wiki.tags.util
Class AbstractNode

java.lang.Object
  extended by info.bliki.wiki.tags.util.AbstractNode
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
WikiTagNode

public abstract class AbstractNode
extends java.lang.Object
implements java.io.Serializable

The concrete base class for all types of nodes.

See Also:
Serialized Form

Field Summary
protected  int nodeBegin
          The beginning position of the tag in the line
protected  int nodeEnd
          The ending position of the tag in the line
 
Constructor Summary
AbstractNode(int start, int end)
          Create an abstract node with the page positions given.
 
Method Summary
 java.lang.Object clone()
          Clone this object.
 int getEndPosition()
          Gets the ending position of the node.
 int getStartPosition()
          Gets the starting position of the node.
 java.lang.String getText()
          Returns the text of the node.
 void setEndPosition(int position)
          Sets the ending position of the node.
 void setStartPosition(int position)
          Sets the starting position of the node.
 void setText(java.lang.String text)
          Sets the string contents of the node.
 java.lang.String toHtml()
          Return the HTML for this node.
abstract  java.lang.String toHtml(boolean verbatim)
          Return the HTML for this node.
abstract  java.lang.String toPlainTextString()
          Returns a string representation of the node.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

nodeBegin

protected int nodeBegin
The beginning position of the tag in the line


nodeEnd

protected int nodeEnd
The ending position of the tag in the line

Constructor Detail

AbstractNode

public AbstractNode(int start,
                    int end)
Create an abstract node with the page positions given. Remember the page and start & end cursor positions.

Parameters:
page - The page this tag was read from.
start - The starting offset of this node within the page.
end - The ending offset of this node within the page.
Method Detail

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Clone this object. Exposes java.lang.Object clone as a public method.

Overrides:
clone in class java.lang.Object
Returns:
A clone of this object.
Throws:
java.lang.CloneNotSupportedException

toPlainTextString

public abstract java.lang.String toPlainTextString()
Returns a string representation of the node. It allows a simple string transformation of a web page, regardless of node type.
Typical application code (for extracting only the text from a web page) would then be simplified to:
 Node node;
 for (Enumeration e = parser.elements(); e.hasMoreElements();) {
        node = (Node) e.nextElement();
        System.out.println(node.toPlainTextString());
        // or do whatever processing you wish with the plain text string
 }
 

Returns:
The 'browser' content of this node.

toHtml

public java.lang.String toHtml()
Return the HTML for this node. This should be the sequence of characters that were encountered by the parser that caused this node to be created. Where this breaks down is where broken nodes (tags and remarks) have been encountered and fixed. Applications reproducing html can use this method on nodes which are to be used or transferred as they were received or created.

Returns:
The sequence of characters that would cause this node to be returned by the parser or lexer.

toHtml

public abstract java.lang.String toHtml(boolean verbatim)
Return the HTML for this node. This should be the exact sequence of characters that were encountered by the parser that caused this node to be created. Where this breaks down is where broken nodes (tags and remarks) have been encountered and fixed. Applications reproducing html can use this method on nodes which are to be used or transferred as they were received or created.

Parameters:
verbatim - If true return as close to the original page text as possible.
Returns:
The (exact) sequence of characters that would cause this node to be returned by the parser or lexer.

getStartPosition

public int getStartPosition()
Gets the starting position of the node.

Returns:
The start position.

setStartPosition

public void setStartPosition(int position)
Sets the starting position of the node.

Parameters:
position - The new start position.

getEndPosition

public int getEndPosition()
Gets the ending position of the node.

Returns:
The end position.

setEndPosition

public void setEndPosition(int position)
Sets the ending position of the node.

Parameters:
position - The new end position.

getText

public java.lang.String getText()
Returns the text of the node.

Returns:
The text of this node. The default is null.

setText

public void setText(java.lang.String text)
Sets the string contents of the node.

Parameters:
text - The new text for the node.


Copyright © 2012 Java Wikipedia API (Bliki engine). All Rights Reserved.