net.sf.mmm.util.text.api
Class TextColumnInfo

java.lang.Object
  extended by net.sf.mmm.util.text.api.TextColumnInfo

public class TextColumnInfo
extends Object

This is a Java-bean for the layout-configuration of a text column.
It contains the width, alignment, indent, and various other meta-information for the layout of a textual column.

Since:
2.0.0
Author:
Joerg Hohwiller (hohwille at users.sourceforge.net)
See Also:
LineWrapper

Nested Class Summary
static class TextColumnInfo.IndentationMode
          This enum contains the available modes how to deal with indentation after newlines.
 
Field Summary
private  HorizontalAlignment alignment
           
private  String borderLeft
           
private  String borderRight
           
private  char filler
           
private  String indent
           
private  TextColumnInfo.IndentationMode indentationMode
           
private  Locale locale
           
static int MINIMUM_WIDTH_FOR_INDENT_AND_HYPHEN
          The minimum width of a column in order that indentation and hyphenation will be active.
private  char[] omitChars
           
private  int width
           
static int WIDTH_AUTO_ADJUST
          The value used for width of a column in order to activate automatic adjustment of the width.
private  char[] wrapChars
           
 
Constructor Summary
TextColumnInfo()
          The constructor.
 
Method Summary
 HorizontalAlignment getAlignment()
          This method gets the alignment.
 String getBorderLeft()
          This method gets the string for the left border of this column.
 String getBorderRight()
          This method gets the string for the right border of this column.
 int getBorderWidth()
          This method gets the auto calculated width of the left and right border.
 char getFiller()
          This method gets the character used to fill up the column.
 String getIndent()
          This method gets the indent.
 TextColumnInfo.IndentationMode getIndentationMode()
          This method gets the TextColumnInfo.IndentationMode that defines when to add an indentation.
 Locale getLocale()
          This method gets the Locale to use for this column.
 char[] getOmitChars()
          This method gets the characters to omit at the beginning of each indented line.
 int getWidth()
          This method gets the width of this column in characters excluding the left and right border.
 char[] getWrapChars()
          This method gets the characters where a wrap of the line is preferred.
 void setAlignment(HorizontalAlignment alignment)
          This method sets the alignment.
 void setBorderLeft(String separator)
          This method sets the left border string.
 void setBorderRight(String separator)
          This method sets the right border string.
 void setFiller(char filler)
          This method sets the filler.
 void setIndent(String indent)
          This method sets the indent.
 void setIndentationMode(TextColumnInfo.IndentationMode indentationMode)
          This method sets the indentation-mode.
 void setLocale(Locale locale)
          This method sets the locale.
 void setOmitChars(char... omitChars)
          This method sets the characters to omit.
 void setWidth(int width)
           
 void setWrapChars(char... wrapChars)
          This method sets the wrap characters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MINIMUM_WIDTH_FOR_INDENT_AND_HYPHEN

public static final int MINIMUM_WIDTH_FOR_INDENT_AND_HYPHEN
The minimum width of a column in order that indentation and hyphenation will be active. The value is 4.

See Also:
Constant Field Values

WIDTH_AUTO_ADJUST

public static final int WIDTH_AUTO_ADJUST
The value used for width of a column in order to activate automatic adjustment of the width. The value is -1. Please note that automatic adjustment for multiple columns needs to pre-process the entire text of these columns what costs a little bit of additional performance.

See Also:
Constant Field Values

width

private int width
See Also:
getWidth()

borderLeft

private String borderLeft
See Also:
getBorderLeft()

borderRight

private String borderRight
See Also:
getBorderRight()

filler

private char filler
See Also:
getFiller()

indent

private String indent
See Also:
getIndent()

alignment

private HorizontalAlignment alignment
See Also:
getAlignment()

wrapChars

private char[] wrapChars
See Also:
getWrapChars()

omitChars

private char[] omitChars
See Also:
getOmitChars()

indentationMode

private TextColumnInfo.IndentationMode indentationMode
See Also:
getIndentationMode()

locale

private Locale locale
See Also:
getLocale()
Constructor Detail

TextColumnInfo

public TextColumnInfo()
The constructor.

Method Detail

getWidth

public int getWidth()
This method gets the width of this column in characters excluding the left and right border.
The value has to be positive or may have the value of WIDTH_AUTO_ADJUST (the default). A reasonable value is at least 5, typically more than 10. However you may use a very low values (<5) for rendering a small column of a large table, but then do NOT expect nice results if text is really wrapped.

Returns:
the width of this column or WIDTH_AUTO_ADJUST for automatic calculation of the width.
See Also:
MINIMUM_WIDTH_FOR_INDENT_AND_HYPHEN

setWidth

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

getBorderWidth

public int getBorderWidth()
This method gets the auto calculated width of the left and right border.

Returns:
getBorderLeft().length() + getBorderRight() .length()

getBorderRight

public String getBorderRight()
This method gets the string for the right border of this column. It is appended to the end of the column text in each line. The default value is the empty string. For multi-column-layouts this should typically be changed for all columns except the last one.

Returns:
the right border separator.

setBorderRight

public void setBorderRight(String separator)
This method sets the right border string. This is typically a single character (e.g. ' ' or '|'). However it is also possible to use the empty string or a sequence of characters.

Parameters:
separator - is the right border.

getBorderLeft

public String getBorderLeft()
This method gets the string for the left border of this column. It is appended before the column text in each line. The default value is the empty string.

Returns:
the left border separator.

setBorderLeft

public void setBorderLeft(String separator)
This method sets the left border string. This is typically a single character (e.g. '|'). However it is also possible to use a sequence of characters.

Parameters:
separator - is the right border.

getIndent

public String getIndent()
This method gets the indent. This string is added after the left border and before the text of the column in each line except the first one. The exact behavior depends on getIndentationMode(). The default is the empty string.
ATTENTION:

Returns:
the indent
See Also:
getIndentationMode()

setIndent

public void setIndent(String indent)
This method sets the indent.

Parameters:
indent - is the indent to set

getAlignment

public HorizontalAlignment getAlignment()
This method gets the alignment.

Returns:
the alignment.

setAlignment

public void setAlignment(HorizontalAlignment alignment)
This method sets the alignment.

Parameters:
alignment - is the HorizontalAlignment to use.

getFiller

public char getFiller()
This method gets the character used to fill up the column. The default value is a whitespace (' ').

Returns:
the fill-character.

setFiller

public void setFiller(char filler)
This method sets the filler.

Parameters:
filler - is character used to fill up the column.

getWrapChars

public char[] getWrapChars()
This method gets the characters where a wrap of the line is preferred. Typical characters are space (' ') or hyphen ('-').

Returns:
the characters where to wrap the text.

setWrapChars

public void setWrapChars(char... wrapChars)
This method sets the wrap characters.

Parameters:
wrapChars - are the wrap characters.

getOmitChars

public char[] getOmitChars()
This method gets the characters to omit at the beginning of each indented line. E.g. if space (' ') is contained in getWrapChars() you can add it to omit chars to prevent the space to occur at the beginning of the next line.

Returns:
the omitChars

setOmitChars

public void setOmitChars(char... omitChars)
This method sets the characters to omit.

Parameters:
omitChars - are the characters that shall be omitted from the column text.

getIndentationMode

public TextColumnInfo.IndentationMode getIndentationMode()
This method gets the TextColumnInfo.IndentationMode that defines when to add an indentation. To turn indentation off, simply set indent to the empty string.
The default is TextColumnInfo.IndentationMode.NO_INDENT_AFTER_DOUBLE_NEWLINE.

Returns:
the indentationMode
See Also:
getIndent()

setIndentationMode

public void setIndentationMode(TextColumnInfo.IndentationMode indentationMode)
This method sets the indentation-mode.

Parameters:
indentationMode - is the indentationMode to set

getLocale

public Locale getLocale()
This method gets the Locale to use for this column. It is used for line wrapping including hyphenation.

Returns:
the columns locale.

setLocale

public void setLocale(Locale locale)
This method sets the locale.

Parameters:
locale - is the Locale to set.


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