Class WordTokenTable

java.lang.Object
  |
  +--WordTokenTable

public class WordTokenTable
extends java.lang.Object

Stores a list of highlighted words in amalgamations in a particular text. This class will serve as the basis for allowing an editable list of word parts. Given this table, it's simple to generate links to container parts, à la the termlist format.

Version:
$2004-05-30 21:49:56 mdh$
Author:
Malcolm D. Hyman

Constructor Summary
WordTokenTable()
           
 
Method Summary
 void add(Amalgamation amalg, int start, int end, java.lang.String lang, SuperAmalgamation samalg, java.lang.String displayText, java.util.List highlights)
          Adds an entry to the table if the passed-in highlight range corresponds to a word.
 Span getFirstInvalidSpan()
          Returns the first invalid range in the text.
 int getGroups()
          Returns the number of groups.
 java.util.List getTable()
          Returns the table.
 boolean isValid()
          Returns true if the WordTokenTable is valid.
 boolean isValidAndNonEmpty()
          Returns true if the WordTokenTable is valid and not empty.
 void markInvalid()
          Marks the WordTokenTable as invalid.
 void reset()
          Clears the table and resets it to its initial state.
 void setGroups(int groups)
          Sets the number of groups, which corresponds to the number of term instance parts, and to the number of regex groups - 1 for n > 1, or 1 when n = 1.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WordTokenTable

public WordTokenTable()
Method Detail

add

public void add(Amalgamation amalg,
                int start,
                int end,
                java.lang.String lang,
                SuperAmalgamation samalg,
                java.lang.String displayText,
                java.util.List highlights)
Adds an entry to the table if the passed-in highlight range corresponds to a word.
Parameters:
amalg - amalgamation on container or subcontainer
start - highlight start offset
end - highlight end offset
lang - language of amalgamation
samalg - SuperAmalgamation on amalgamation
displayText - filtered, normalized text for amalgamation
highlights - highlights from Highlighter

isValid

public boolean isValid()
Returns true if the WordTokenTable is valid.
Returns:
true if valid

markInvalid

public void markInvalid()
Marks the WordTokenTable as invalid.

isValidAndNonEmpty

public boolean isValidAndNonEmpty()
Returns true if the WordTokenTable is valid and not empty.
Returns:
true if valid

setGroups

public void setGroups(int groups)
Sets the number of groups, which corresponds to the number of term instance parts, and to the number of regex groups - 1 for n > 1, or 1 when n = 1.
Parameters:
groups - number of groups

getGroups

public int getGroups()
Returns the number of groups.
Returns:
number of groups

getTable

public java.util.List getTable()
Returns the table.
Returns:
table of WordTokens

getFirstInvalidSpan

public Span getFirstInvalidSpan()
Returns the first invalid range in the text.
Returns:
first range that doesn't correspond to a word

reset

public void reset()
Clears the table and resets it to its initial state.