utils
Class TreeNode

java.lang.Object
  extended by utils.TreeNode

public class TreeNode
extends java.lang.Object

The TreeNode-class is made to simplify storing and searching for words that should be filtered away. Each instance of TreeNode contains its own methods for recursively storing and recursively checking if a word matches the description of a word that should be removed. Each node contains only one letter, but it also contains links to a number of new nodes. If one of those nodes contains the string "end" instead of a letter, it means that if a word that is being checked ends with the letter at the present node, then it is a word that should be removed. Each node has links to other nodes and those nodes will contain other valid letters to follow the allready established trail of letters. If the word that is being checked has a letter following the current node that doesn't exist, then the word is not to be removed, it is not an unwanted word.

Author:
Håvard Rykkelid

Field Summary
private  java.lang.String data
           
private  java.util.Vector<TreeNode> nodes
           
private static java.lang.String nodeSettings
           
private static java.util.Vector<java.lang.String> wordEnds
           
 
Constructor Summary
TreeNode(java.lang.String data)
          The constructor stores the first letter of the String received and sends the rest of the word to be stored in following nodes.
 
Method Summary
 java.lang.String getData()
          A standard getter method
 void insert(java.lang.String wordPart)
          This method is called for inserting a new word into this tree.
 boolean isStopWord(java.lang.String wordPart)
          This method recursively checks whether an input word is a word to be removed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

nodeSettings

private static final java.lang.String nodeSettings

wordEnds

private static java.util.Vector<java.lang.String> wordEnds

nodes

private java.util.Vector<TreeNode> nodes

data

private java.lang.String data
Constructor Detail

TreeNode

public TreeNode(java.lang.String data)
The constructor stores the first letter of the String received and sends the rest of the word to be stored in following nodes. If the String is empty, then the node will store "end".

Parameters:
data - - the received word or part-of-word
Method Detail

insert

public void insert(java.lang.String wordPart)
This method is called for inserting a new word into this tree. It will check the value in all the subsequent nodes and compare it to the first letter int the input-string. If it finds a match, it will call the insert()-method in that node and send in the input-string, minus the first letter.

Parameters:
wordPart - - the received word or part-of-word

isStopWord

public boolean isStopWord(java.lang.String wordPart)
This method recursively checks whether an input word is a word to be removed.

Parameters:
wordPart - - the received word or part-of-word
Returns:
true if the word is to be removed, false if it is not to be removed.

getData

public java.lang.String getData()
A standard getter method

Returns:
returns the letter of this node