Class StatisticsFormat
- All Implemented Interfaces:
Serializable, Cloneable, Localized
Formats a
Statistics object.
By default, newly created StatisticsFormat instances will format statistical values
in a tabular format using spaces as the column separator.
Example
Number of values: 8726
Minimum value: 6.853
Maximum value: 8.259
Mean value: 7.421
Root Mean Square: 7.846
Standard deviation: 6.489
Limitations
- The current implementation can only format features — parsing is not yet implemented.
StatisticsFormat, like mostjava.text.Formatsubclasses, is not thread-safe.
- Since:
- 0.3
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class Format
Format.Field -
Field Summary
Fields inherited from class TabularFormat
beforeFill, columnSeparator, fillCharacter, lineSeparator, omitTrailingNullsModifier and TypeFieldDescriptionprotected StringThe string to write before theTabularFormat.fillCharacter, or an empty string if none.protected StringThe string to write after theTabularFormat.fillCharacter, or an empty string if none.protected charThe character to repeat after the content of a cell for alignment with the next column.protected StringThe line separator to use for formatting the tree.protected booleantrueif the trailingnullvalues shall be omitted at formatting time. -
Constructor Summary
ConstructorsConstructorDescriptionStatisticsFormat(Locale locale, Locale headerLocale, TimeZone timezone) Constructs a new format for the given numeric and header locales. -
Method Summary
Modifier and TypeMethodDescriptionclone()Returns a clone of this format.voidformat(Statistics[] stats, Appendable toAppendTo) Formats the given statistics in a tabular format.voidformat(Statistics stats, Appendable toAppendTo) Formats a localized string representation of the given statistics.voidformatObject(Object object, Appendable toAppendTo) Formats the given statistics.intReturns the "width" of the border to drawn around the table, in number of lines.static StatisticsFormatReturns an instance for the current system default locale.static StatisticsFormatgetInstance(Locale locale) Returns an instance for the given locale.getLocale(Locale.Category category) Returns the locale for the given category.final Class<Statistics> Returns the type of objects formatted by this class.booleanReturnstrueif this formatter shall consider that the statistics where computed using the totality of the populations under study.parse(CharSequence text, ParsePosition pos) Not yet supported.voidsetBorderWidth(int borderWidth) Sets the "width" of the border to drawn around the table, in number of lines.voidsetForAllPopulation(boolean allPopulation) Sets whether this formatter shall consider that the statistics where computed using the totality of the populations under study.Methods inherited from class TabularFormat
getColumnSeparatorMatcher, getColumnSeparatorPattern, getLineSeparator, setColumnSeparatorPattern, setLineSeparatorModifier and TypeMethodDescriptionprotected MatcherReturns a matcher for the column separators in the given text.Returns the pattern of characters used in column separators.Returns the current line separator.voidsetColumnSeparatorPattern(String pattern) Sets the pattern of the characters to insert between the columns.voidsetLineSeparator(String separator) Sets the line separator.Methods inherited from class CompoundFormat
createFormat, format, format, getFormat, getLocale, getTemporalStyle, getTimeZone, parseObject, parseObjectModifier and TypeMethodDescriptionprotected FormatcreateFormat(Class<?> valueType) Creates a new format to use for parsing and formatting values of the given type.format(Object object, StringBuffer toAppendTo, FieldPosition pos) Writes a textual representation of the specified object in the given buffer.voidformat(Statistics object, StringBuilder toAppendTo) Writes a textual representation of the given object in the given buffer.protected FormatgetFormat(Class<?> valueType) Returns the format to use for parsing and formatting values of the given type.Returns the locale used by this format.protected FormatStylegetTemporalStyle(boolean dates) Returns the style to use for formatting dates or times.Returns the timezone used by this format.parseObject(String text) Creates an object from the given string representation.parseObject(String text, ParsePosition pos) Creates an object from the given string representation, or returnsnullif an error occurred while parsing.Methods inherited from class Format
format, formatToCharacterIterator
-
Constructor Details
-
StatisticsFormat
Constructs a new format for the given numeric and header locales. The timezone is used only if the values added to theStatisticsare dates.- Parameters:
locale- the locale to use for numbers, dates and angles formatting, ornullfor the root locale.headerLocale- the locale for row and column headers. Usually same aslocale.timezone- the timezone, ornullfor UTC.
-
-
Method Details
-
getInstance
Returns an instance for the current system default locale.- Returns:
- a statistics format instance for the current default locale.
-
getInstance
Returns an instance for the given locale.- Parameters:
locale- the locale for which to get aStatisticsFormatinstance.- Returns:
- a statistics format instance for the given locale.
-
getLocale
Returns the locale for the given category. This method implements the following mapping:Locale.Category.DISPLAY— theheaderLocalegiven at construction time.Locale.Category.FORMAT— thelocalegiven at construction time, used for all values below the header row.
- Overrides:
getLocalein classCompoundFormat<Statistics>- Parameters:
category- the category for which a locale is desired.- Returns:
- the locale for the given category (never
null). - Since:
- 0.4
-
getValueType
Returns the type of objects formatted by this class.- Specified by:
getValueTypein classCompoundFormat<Statistics>- Returns:
Statistics.class
-
isForAllPopulation
public boolean isForAllPopulation()Returnstrueif this formatter shall consider that the statistics where computed using the totality of the populations under study. This information impacts the standard deviation values to be formatted.- Returns:
trueif the statistics to format where computed using the totality of the populations under study.- See Also:
-
setForAllPopulation
public void setForAllPopulation(boolean allPopulation) Sets whether this formatter shall consider that the statistics where computed using the totality of the populations under study. The default value isfalse.- Parameters:
allPopulation-trueif the statistics to format where computed using the totality of the populations under study.- See Also:
-
getBorderWidth
public int getBorderWidth()Returns the "width" of the border to drawn around the table, in number of lines. The default width is 0, which stands for no border.- Returns:
- the border "width" in number of lines.
-
setBorderWidth
public void setBorderWidth(int borderWidth) Sets the "width" of the border to drawn around the table, in number of lines. The value can be any of the following:- 0 (the default) for no border
- 1 for single line (
│,─) - 2 for double lines (
║,═)
- Parameters:
borderWidth- the border width, in number of lines.
-
parse
Not yet supported.- Specified by:
parsein classCompoundFormat<Statistics>- Parameters:
text- the character sequence for the object to parse.pos- the position where to start the parsing. On return, the position where the parsing stopped or where an error occurred.- Returns:
- currently never return.
- Throws:
ParseException- currently always thrown.
-
formatObject
Formats the given statistics. This method will delegates to one of the following methods, depending on the type of the given object:- Overrides:
formatObjectin classCompoundFormat<Statistics>- Parameters:
object- the object to format.toAppendTo- where to format the object.- Throws:
IllegalArgumentException- if the given object is not an instance of one of the above-cited types.IOException- if an error occurred while writing to the given appendable.
-
format
Formats a localized string representation of the given statistics. If statistics on differences are associated with the given object, they will be formatted too.- Specified by:
formatin classCompoundFormat<Statistics>- Parameters:
stats- the statistics to format.toAppendTo- where to format the statistics.- Throws:
IOException- if an error occurred while writing to the given appendable.
-
format
Formats the given statistics in a tabular format. This method does not check for the statistics on differences - if such statistics are wanted, they must be included in the given array.- Parameters:
stats- the statistics to format.toAppendTo- where to format the statistics.- Throws:
IOException- if an error occurred while writing to the given appendable.
-
clone
Returns a clone of this format.- Overrides:
clonein classTabularFormat<Statistics>- Returns:
- a clone of this format.
-