Class AutoFormatter
- All Implemented Interfaces:
Serializable,Cloneable
AutoFormatter class 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, and FORMAT_URLENC.
For replacements, use the
invalid reference
CodeISOjava.net.URLEncoder
classes.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.text.Format
Format.Field -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final AutoFormatterThe system default formatter.static final intCombination of line break handling and automatic lists.static final intDeprecated.this is not implemented and has no effectsstatic final intAutomatically create ordered and unordered lists.static final intAutomatically convert line breaks to <br> tagsstatic final intDeprecated.not implemented here, useinstead.invalid reference
CodeISOstatic final intDeprecated.not implemented here, useinstead.invalid reference
CodeISOstatic final intDeprecated.not implemented here, useorinvalid reference
CodeISOjava.net.URLEncoder#encode(String)instead. -
Constructor Summary
ConstructorsConstructorDescriptionDeprecated.as of echidna.AutoFormatter(Properties config) Creates a newAutoFormatterobject with the given configuration. -
Method Summary
Modifier and TypeMethodDescriptionformat(Object obj, StringBuffer toAppendTo, FieldPosition pos) Formats the object according to the standard modifiers, which are automatic line breaks and list formatting.Formats the string according to the modifier set.format(String str, StringBuffer toAppendTo, int mods) Formats the string according to the modifier set.parseObject(String source, ParsePosition status) TheAutoFormatterclass does not support parsing, so anUnsupportedOperationExceptionis thrown when trying to parse.Methods inherited from class java.text.Format
clone, format, formatToCharacterIterator, parseObject
-
Field Details
-
FORMAT_NOISODEC
public static final int FORMAT_NOISODECDeprecated.not implemented here, useinstead.invalid reference
CodeISOISO encodes the <, " and & characters.- See Also:
-
FORMAT_ISOENC
public static final int FORMAT_ISOENCDeprecated.not implemented here, useinstead.invalid reference
CodeISOISO encode characters according to HTTP standard.- See Also:
-
FORMAT_AUTOLISTS
public static final int FORMAT_AUTOLISTSAutomatically create ordered and unordered lists.- See Also:
-
FORMAT_AUTOLINK
public static final int FORMAT_AUTOLINKDeprecated.this is not implemented and has no effectsAutmatic link formatting (?).- See Also:
-
FORMAT_BR
public static final int FORMAT_BRAutomatically convert line breaks to <br> tags- See Also:
-
FORMAT_URLENC
public static final int FORMAT_URLENCDeprecated.not implemented here, useorinvalid reference
CodeISOjava.net.URLEncoder#encode(String)instead.Encodes characters illegal in URLs.- See Also:
-
FORMAT_AUTOBR
public static final int FORMAT_AUTOBRCombination of line break handling and automatic lists.- See Also:
-
DEFAULT_FORMATTER
The system default formatter. Use this instance when formatting with no special configuration is needed.
-
-
Constructor Details
-
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
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.
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 Details
-
format
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 classFormat- 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:
ClassCastException- if the object is not aString.
-
parseObject
TheAutoFormatterclass does not support parsing, so anUnsupportedOperationExceptionis thrown when trying to parse.- Specified by:
parseObjectin classFormat- Parameters:
source- The source string to parse. Ignored.status- The position to define parsing. Ignored.- Throws:
UnsupportedOperationException- as it is not yet implemented.
-
format
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
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.
-