Class AutoFormatter
- java.lang.Object
-
- java.text.Format
-
- com.day.text.AutoFormatter
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable
public class AutoFormatter extends java.text.FormatTheAutoFormatterclass implements the automatic conversion of line endings to<br>HTML lists. This is the formatting subset of the UBM feature of the former Communiqué 2 system.This implementation only supports automatically converting bulleted and numbered lists as well as line breaking. Therefore these formatting options are not implemented here :
FORMAT_NOISODEC,FORMAT_ISOENC,FORMAT_AUTOLINK, andFORMAT_URLENC. For replacements, use theCodeISOand/orjava.net.URLEncoderclasses.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static AutoFormatterDEFAULT_FORMATTERThe system default formatter.static intFORMAT_AUTOBRCombination of line break handling and automatic lists.static intFORMAT_AUTOLINKDeprecated.this is not implemented and has no effectsstatic intFORMAT_AUTOLISTSAutomatically create ordered and unordered lists.static intFORMAT_BRAutomatically convert line breaks to <br> tagsstatic intFORMAT_ISOENCDeprecated.not implemented here, useCodeISOinstead.static intFORMAT_NOISODECDeprecated.not implemented here, useCodeISOinstead.static intFORMAT_URLENCDeprecated.not implemented here, useCodeISOorjava.net.URLEncoder#encode(String)instead.
-
Constructor Summary
Constructors Constructor Description AutoFormatter()Deprecated.as of echidna.AutoFormatter(java.util.Properties config)Creates a newAutoFormatterobject with the given configuration.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringBufferformat(java.lang.Object obj, java.lang.StringBuffer toAppendTo, java.text.FieldPosition pos)Formats the object according to the standard modifiers, which are automatic line breaks and list formatting.java.lang.Stringformat(java.lang.String str, int mods)Formats the string according to the modifier set.java.lang.StringBufferformat(java.lang.String str, java.lang.StringBuffer toAppendTo, int mods)Formats the string according to the modifier set.java.lang.ObjectparseObject(java.lang.String source, java.text.ParsePosition status)TheAutoFormatterclass does not support parsing, so anUnsupportedOperationExceptionis thrown when trying to parse.
-
-
-
Field Detail
-
FORMAT_NOISODEC
public static final int FORMAT_NOISODEC
Deprecated.not implemented here, useCodeISOinstead.ISO encodes the <, " and & characters.- See Also:
- Constant Field Values
-
FORMAT_ISOENC
public static final int FORMAT_ISOENC
Deprecated.not implemented here, useCodeISOinstead.ISO encode characters according to HTTP standard.- See Also:
- Constant Field Values
-
FORMAT_AUTOLISTS
public static final int FORMAT_AUTOLISTS
Automatically create ordered and unordered lists.- See Also:
- Constant Field Values
-
FORMAT_AUTOLINK
public static final int FORMAT_AUTOLINK
Deprecated.this is not implemented and has no effectsAutmatic link formatting (?).- See Also:
- Constant Field Values
-
FORMAT_BR
public static final int FORMAT_BR
Automatically convert line breaks to <br> tags- See Also:
- Constant Field Values
-
FORMAT_URLENC
public static final int FORMAT_URLENC
Deprecated.not implemented here, useCodeISOorjava.net.URLEncoder#encode(String)instead.Encodes characters illegal in URLs.- See Also:
- Constant Field Values
-
FORMAT_AUTOBR
public static final int FORMAT_AUTOBR
Combination of line break handling and automatic lists.- See Also:
- Constant Field Values
-
DEFAULT_FORMATTER
public static final AutoFormatter DEFAULT_FORMATTER
The system default formatter. Use this instance when formatting with no special configuration is needed.
-
-
Constructor Detail
-
AutoFormatter
public AutoFormatter()
Deprecated.as of echidna. To get an instance with default settings use theDEFAULT_FORMATTER.Creates a newAutoFormatterobject with the default configuration.
-
AutoFormatter
public AutoFormatter(java.util.Properties config)
Creates a newAutoFormatterobject with the given configuration.The configuration contained in the
configparameter is assumed to have the following structure, whereconfig.getName()would return auto orconfig.getChild("auto")is used as the configuration (this is the same structure as was used in Communiqué 2 to configure automatic formatting.
- " end="
All values are replaced as-is except for the ol.start attribute which gets the string %s replaced with the number which is used in the input to defined the ordered list. If the %s string is missing that number is of course not inserted.
- Parameters:
config- The configuration for the automatic formatting replacement. If this isnull, the defualt configuration is used.
-
-
Method Detail
-
format
public java.lang.StringBuffer format(java.lang.Object obj, java.lang.StringBuffer toAppendTo, java.text.FieldPosition pos)Formats the object according to the standard modifiers, which are automatic line breaks and list formatting. This implementation only supports strings and completely ignores the pos parameter.- Specified by:
formatin classjava.text.Format- Parameters:
obj- The object to format, which must be a String or aClassCastExceptionwill be thrown.toAppendTo- Where to append the formatted data. Ifnull, a new string buffer is allocated.pos- Formatting position information. Not used or obeyed.- Returns:
- a
StringBuffercontaining the formatted string. This is either the same astoAppendToor a newly allocatedStringBufferif the parameter isnull. - Throws:
java.lang.ClassCastException- if the object is not aString.
-
parseObject
public java.lang.Object parseObject(java.lang.String source, java.text.ParsePosition status)TheAutoFormatterclass does not support parsing, so anUnsupportedOperationExceptionis thrown when trying to parse.- Specified by:
parseObjectin classjava.text.Format- Parameters:
source- The source string to parse. Ignored.status- The position to define parsing. Ignored.- Throws:
java.lang.UnsupportedOperationException- as it is not yet implemented.
-
format
public java.lang.String format(java.lang.String str, int mods)Formats the string according to the modifier set. The modifier set may be any combination of the FORMAT constants defined.- Parameters:
str- The string to be formatted.mods- The modifier set controlling the format operation.- Returns:
- the formatted string.
-
format
public java.lang.StringBuffer format(java.lang.String str, java.lang.StringBuffer toAppendTo, int mods)Formats the string according to the modifier set. The modifier set may be any combination of the FORMAT constants defined.Implementation Note: Only line break processing and automatic lists are currently supported.
- Parameters:
str- The string to be formatted.toAppendTo- The string buffer to append the result to. If thisnulla new string buffer is created and returned, else the result of the method will be this string buffer.mods- The modifier set controlling the format operation.- Returns:
- the string buffer to which the formatted result has been appended. This is either the input string buffer or a newly created string buffer, if null has been supplied.
-
-