net.sf.mmm.util.text.base
Class DefaultLineWrapper.TextSegment

java.lang.Object
  extended by net.sf.mmm.util.text.base.DefaultLineWrapper.TextSegment
Enclosing class:
DefaultLineWrapper

protected static class DefaultLineWrapper.TextSegment
extends Object

This class represents a segment of some text. It acts as an event when iterating the text. It is classified by a type and caches a potential hyphenation for performance reasons.


Field Summary
private  int endIndex
           
private  Hyphenation hyphenatedWord
           
private  Hyphenator hyphenator
           
private  int startIndex
           
private  String text
           
private  DefaultLineWrapper.TextSegmentType type
           
 
Constructor Summary
protected DefaultLineWrapper.TextSegment(String text, Hyphenator hyphenator)
          The constructor.
 
Method Summary
 int getEndIndex()
          This method gets the index immediately after the last character of this DefaultLineWrapper.TextSegment.
 Hyphenation getHyphenatedWord()
          This method gets the Hyphenation if this DefaultLineWrapper.TextSegment has the type DefaultLineWrapper.TextSegmentType.WORD.
 int getLength()
          This method gets the length of this DefaultLineWrapper.TextSegment.
 int getStartIndex()
          This method gets the start index of this DefaultLineWrapper.TextSegment.
 String getText()
          This method gets the full text containing this segment.
 DefaultLineWrapper.TextSegmentType getType()
          This method determines if this DefaultLineWrapper.TextSegment represents a word.
 void initialize(int start, int end, DefaultLineWrapper.TextSegmentType textType)
          This method resets and initializes this object.
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

text

private final String text
See Also:
getText()

hyphenator

private final Hyphenator hyphenator
See Also:
getHyphenatedWord()

startIndex

private int startIndex
See Also:
getStartIndex()

endIndex

private int endIndex
See Also:
getEndIndex()

type

private DefaultLineWrapper.TextSegmentType type
See Also:
getType()

hyphenatedWord

private Hyphenation hyphenatedWord
See Also:
getHyphenatedWord()
Constructor Detail

DefaultLineWrapper.TextSegment

protected DefaultLineWrapper.TextSegment(String text,
                                         Hyphenator hyphenator)
The constructor.

Parameters:
text - is the getText().
hyphenator - is the Hyphenation used for getHyphenatedWord().
Method Detail

getLength

public int getLength()
This method gets the length of this DefaultLineWrapper.TextSegment.

Returns:
the result of endIndex - startIndex.

initialize

public void initialize(int start,
                       int end,
                       DefaultLineWrapper.TextSegmentType textType)
This method resets and initializes this object. This is NOT done at construction in order to reuse the object and save performance.

Parameters:
start - is the start-index.
end - is the end-index.
textType - is the type.

getStartIndex

public int getStartIndex()
This method gets the start index of this DefaultLineWrapper.TextSegment.

Returns:
the index of the first character of this DefaultLineWrapper.TextSegment.

getEndIndex

public int getEndIndex()
This method gets the index immediately after the last character of this DefaultLineWrapper.TextSegment.

Returns:
the end-index of this DefaultLineWrapper.TextSegment.

getText

public String getText()
This method gets the full text containing this segment.

Returns:
the entire text.

getType

public DefaultLineWrapper.TextSegmentType getType()
This method determines if this DefaultLineWrapper.TextSegment represents a word.

Returns:
true if segment is word, false otherwise (special characters, etc.)
See Also:
getHyphenatedWord()

getHyphenatedWord

public Hyphenation getHyphenatedWord()
This method gets the Hyphenation if this DefaultLineWrapper.TextSegment has the type DefaultLineWrapper.TextSegmentType.WORD. The Hyphenation will be build lazy on the first call of this method.

Returns:
the Hyphenation or null if this is no word.

toString

public String toString()

Overrides:
toString in class Object


Copyright © 2001-2010 mmm-Team. All Rights Reserved.