ch.uzh.ifi.attempto.preditor.text
Class TextContainer

java.lang.Object
  extended by ch.uzh.ifi.attempto.preditor.text.TextContainer

public class TextContainer
extends java.lang.Object

This class represents a text container that stores a sequence of text elements that represent a (partial) text or sentence.

Author:
Tobias Kuhn

Constructor Summary
TextContainer()
          Creates a new text container.
TextContainer(ContextChecker contextChecker)
          Creates a new text container using the given context checker.
TextContainer(ContextChecker contextChecker, TextElement... elements)
          Creates a new text container that uses the given context checker and that contains the given text elements.
TextContainer(TextElement... elements)
          Creates a new text container that contains the given text elements.
 
Method Summary
 void addElement(TextElement el)
          Adds the text element to the end of the sequence.
 ContextChecker getContextChecker()
          Returns the context checker of this text container.
 int getIndexOf(TextElement textElement)
          Returns the position of the given text element within this text container or -1 if the text element is not contained by this text container.
 java.lang.String getText()
          Returns the text that is represented by the sequence of text element as a string.
 TextElement getTextElement(int index)
          Returns the text element with the given index.
 java.util.ArrayList<TextElement> getTextElements()
          Returns the sequence of text elements.
 int getTextElementsCount()
          Returns the number of text elements of this text container.
 void removeAllElements()
          Removes all text elements.
 void removeLastElement()
          Removes the last text element of the sequence if it is not empty.
 void setContextChecker(ContextChecker contextChecker)
          Sets the context checker.
 void setTextElements(java.util.List<TextElement> elements)
          Sets the text elements.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextContainer

public TextContainer()
Creates a new text container.


TextContainer

public TextContainer(ContextChecker contextChecker)
Creates a new text container using the given context checker.

Parameters:
contextChecker - The context checker to be used.

TextContainer

public TextContainer(TextElement... elements)
Creates a new text container that contains the given text elements.

Parameters:
elements - The elements to be added to the new text container.

TextContainer

public TextContainer(ContextChecker contextChecker,
                     TextElement... elements)
Creates a new text container that uses the given context checker and that contains the given text elements.

Parameters:
contextChecker - The context checker to be used.
elements - The elements to be added to the new text container.
Method Detail

getTextElementsCount

public int getTextElementsCount()
Returns the number of text elements of this text container.

Returns:
The number of text elements.

getTextElement

public TextElement getTextElement(int index)
Returns the text element with the given index.

Parameters:
index - The index of the text element to be returned.
Returns:
The text element.

getTextElements

public java.util.ArrayList<TextElement> getTextElements()
Returns the sequence of text elements.

Returns:
A list containing the text elements.

setTextElements

public void setTextElements(java.util.List<TextElement> elements)
Sets the text elements.

Parameters:
elements - A list of text elements.

addElement

public void addElement(TextElement el)
Adds the text element to the end of the sequence.

Parameters:
el - The text element to be added.

removeAllElements

public void removeAllElements()
Removes all text elements.


removeLastElement

public void removeLastElement()
Removes the last text element of the sequence if it is not empty.


getText

public java.lang.String getText()
Returns the text that is represented by the sequence of text element as a string.

Returns:
The text.

setContextChecker

public void setContextChecker(ContextChecker contextChecker)
Sets the context checker.

Parameters:
contextChecker - The new context checker.

getContextChecker

public ContextChecker getContextChecker()
Returns the context checker of this text container.

Returns:
The context checker.

getIndexOf

public int getIndexOf(TextElement textElement)
Returns the position of the given text element within this text container or -1 if the text element is not contained by this text container. Note that the elements are checked for identity, not for equality.

Parameters:
textElement - The text element.
Returns:
The index of the text element.


Copyright 2008-2009, Attempto Group, University of Zurich (see http://attempto.ifi.uzh.ch)