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

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

protected static class DefaultLineWrapper.ColumnState
extends TextColumn

This class represents the state of a text-column. It contains the text of the column and its metadata. Further it holds the current text-index and acts as some sort of iterator of text-segments.


Field Summary
private  BreakIterator breakIterator
           
private  int breakIteratorIndex
           
private  DefaultLineWrapper.TextSegment currentSegment
           
private  Hyphenator hyphenator
          The Hyphenator to use.
private  boolean indent
           
private  DefaultLineWrapper.TextSegment nextSegment
           
private  int segmentIndex
           
private  int subsequentNewlineCount
           
private  int textIndex
           
private  int width
           
 
Constructor Summary
DefaultLineWrapper.ColumnState(String text, TextColumnInfo columnInfo, HyphenatorBuilder hyphenatorBuilder)
          The constructor.
 
Method Summary
private static DefaultLineWrapper.TextSegmentType getCharacterType(char c)
          This method gets the DefaultLineWrapper.TextSegmentType corresponding to the given character.
 DefaultLineWrapper.TextSegment getCurrentSegment()
          This method gets the current DefaultLineWrapper.TextSegment.
 DefaultLineWrapper.TextSegment getNextSegment()
          This method gets the next DefaultLineWrapper.TextSegment after the current.
 int getSubsequentNewlineCount()
          This method gets the current number of subsequent newlines.
 int getTextIndex()
           
 int getWidth()
          This method gets the physical width.
 boolean isComplete()
          This method determines if this column is complete (all text is appended).
 boolean isIndent()
           
private  DefaultLineWrapper.TextSegment next(DefaultLineWrapper.TextSegment textSegment)
          This method initializes the given DefaultLineWrapper.TextSegment with the next segment-data from the text.
 boolean proceedTextSegment()
          This method steps on to the next DefaultLineWrapper.TextSegment.
 void setIndent(boolean indent)
           
 void setTextIndex(int textIndex)
           
 void setWidth(int width)
           
 
Methods inherited from class net.sf.mmm.util.text.api.TextColumn
getColumnInfo, getText
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

hyphenator

private final Hyphenator hyphenator
The Hyphenator to use.


breakIterator

private final BreakIterator breakIterator
See Also:
#next(TextSegment)

breakIteratorIndex

private int breakIteratorIndex
See Also:
#next(TextSegment)

segmentIndex

private int segmentIndex
See Also:
#next(TextSegment)

textIndex

private int textIndex
See Also:
getTextIndex()

width

private int width
See Also:
getWidth()

indent

private boolean indent
See Also:
isIndent()

currentSegment

private DefaultLineWrapper.TextSegment currentSegment
See Also:
getCurrentSegment()

nextSegment

private DefaultLineWrapper.TextSegment nextSegment
See Also:
getNextSegment()

subsequentNewlineCount

private int subsequentNewlineCount
See Also:
getSubsequentNewlineCount()
Constructor Detail

DefaultLineWrapper.ColumnState

public DefaultLineWrapper.ColumnState(String text,
                                      TextColumnInfo columnInfo,
                                      HyphenatorBuilder hyphenatorBuilder)
The constructor.

Parameters:
text - is the text.
columnInfo - is the column-info.
hyphenatorBuilder - is the HyphenatorBuilder.
Method Detail

getCurrentSegment

public DefaultLineWrapper.TextSegment getCurrentSegment()
This method gets the current DefaultLineWrapper.TextSegment. Initially this is the first DefaultLineWrapper.TextSegment available.

Returns:
the current DefaultLineWrapper.TextSegment or null if all DefaultLineWrapper.TextSegments are proceeded.
See Also:
proceedTextSegment()

getNextSegment

public DefaultLineWrapper.TextSegment getNextSegment()
This method gets the next DefaultLineWrapper.TextSegment after the current. This method exists for lookahead decisions.

Returns:
the next DefaultLineWrapper.TextSegment or null if NOT available (current segment is the last segment or also null).

getSubsequentNewlineCount

public int getSubsequentNewlineCount()
This method gets the current number of subsequent newlines. If current segment is a DefaultLineWrapper.TextSegmentType.NEWLINE, this method will return the number of DefaultLineWrapper.TextSegmentType.NEWLINE segments (including the current) that occurred since the last other segment. Otherwise it will always return 0.

Returns:
the subsequentNewlineCount the number of subsequent DefaultLineWrapper.TextSegmentType.NEWLINE segments including the current segment or 0 if the current segment is no DefaultLineWrapper.TextSegmentType.NEWLINE.

proceedTextSegment

public boolean proceedTextSegment()
This method steps on to the next DefaultLineWrapper.TextSegment. The current segment is set to the next segment and the next segment is set to the next determined segment.

Returns:
true if a new current segment is available, false if the entire text has been proceeded.

next

private DefaultLineWrapper.TextSegment next(DefaultLineWrapper.TextSegment textSegment)
This method initializes the given DefaultLineWrapper.TextSegment with the next segment-data from the text.

Parameters:
textSegment - a previous DefaultLineWrapper.TextSegment that can be reused.
Returns:
the DefaultLineWrapper.TextSegment with the next segment-data or null if the text is completed.

getCharacterType

private static DefaultLineWrapper.TextSegmentType getCharacterType(char c)
This method gets the DefaultLineWrapper.TextSegmentType corresponding to the given character.

Parameters:
c - is the character to check.
Returns:
the corresponding DefaultLineWrapper.TextSegmentType.

getTextIndex

public int getTextIndex()
Returns:
the textIndex

setTextIndex

public void setTextIndex(int textIndex)
Parameters:
textIndex - is the textIndex to set

isIndent

public boolean isIndent()
Returns:
the indent

setIndent

public void setIndent(boolean indent)
Parameters:
indent - is the indent to set

getWidth

public int getWidth()
This method gets the physical width. A value of TextColumnInfo.WIDTH_AUTO_ADJUST is replaced with a physical value.

Returns:
the physical width.

setWidth

public void setWidth(int width)
Parameters:
width - is the width to set

isComplete

public boolean isComplete()
This method determines if this column is complete (all text is appended).

Returns:
true if complete, false otherwise.


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