public class AutoFormatter
extends java.text.Format
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 CodeISO
and/or java.net.URLEncoder
classes.
Modifier and Type | Field and Description |
---|---|
static AutoFormatter |
DEFAULT_FORMATTER
The system default formatter.
|
static int |
FORMAT_AUTOBR
Combination of line break handling and automatic lists.
|
static int |
FORMAT_AUTOLINK
Deprecated.
this is not implemented and has no effects
|
static int |
FORMAT_AUTOLISTS
Automatically create ordered and unordered lists.
|
static int |
FORMAT_BR
Automatically convert line breaks to <br> tags
|
static int |
FORMAT_ISOENC
Deprecated.
not implemented here, use
CodeISO instead. |
static int |
FORMAT_NOISODEC
Deprecated.
not implemented here, use
CodeISO instead. |
static int |
FORMAT_URLENC
Deprecated.
not implemented here, use
CodeISO or
java.net.URLEncoder#encode(String) instead. |
Constructor and Description |
---|
AutoFormatter()
Deprecated.
as of echidna. To get an instance with default settings use
the
DEFAULT_FORMATTER . |
AutoFormatter(java.util.Properties config)
Creates a new
AutoFormatter object with the given
configuration. |
Modifier and Type | Method and Description |
---|---|
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.
|
java.lang.String |
format(java.lang.String str,
int mods)
Formats the string according to the modifier set.
|
java.lang.StringBuffer |
format(java.lang.String str,
java.lang.StringBuffer toAppendTo,
int mods)
Formats the string according to the modifier set.
|
java.lang.Object |
parseObject(java.lang.String source,
java.text.ParsePosition status)
The
AutoFormatter class does not support parsing, so an
UnsupportedOperationException is thrown when trying to
parse. |
public static final int FORMAT_NOISODEC
CodeISO
instead.public static final int FORMAT_ISOENC
CodeISO
instead.public static final int FORMAT_AUTOLISTS
public static final int FORMAT_AUTOLINK
public static final int FORMAT_BR
public static final int FORMAT_URLENC
CodeISO
or
java.net.URLEncoder#encode(String)
instead.public static final int FORMAT_AUTOBR
public static final AutoFormatter DEFAULT_FORMATTER
public AutoFormatter()
DEFAULT_FORMATTER
.AutoFormatter
object with the default
configuration.public AutoFormatter(java.util.Properties config)
AutoFormatter
object with the given
configuration.
The configuration contained in the config
parameter is
assumed to have the following structure, where config.getName()
would return auto or config.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.
config
- The configuration for the automatic formatting replacement.
If this is null
, the defualt configuration is
used.public java.lang.StringBuffer format(java.lang.Object obj, java.lang.StringBuffer toAppendTo, java.text.FieldPosition pos)
format
in class java.text.Format
obj
- The object to format, which must be a String or a
ClassCastException
will be thrown.toAppendTo
- Where to append the formatted data. If null
,
a new string buffer is allocated.pos
- Formatting position information. Not used or obeyed.StringBuffer
containing the formatted string. This
is either the same as toAppendTo
or a newly
allocated StringBuffer
if the parameter is
null
.java.lang.ClassCastException
- if the object is not a String
.public java.lang.Object parseObject(java.lang.String source, java.text.ParsePosition status)
AutoFormatter
class does not support parsing, so an
UnsupportedOperationException
is thrown when trying to
parse.parseObject
in class java.text.Format
source
- The source string to parse. Ignored.status
- The position to define parsing. Ignored.java.lang.UnsupportedOperationException
- as it is not yet implemented.public java.lang.String format(java.lang.String str, int mods)
str
- The string to be formatted.mods
- The modifier set controlling the format operation.public java.lang.StringBuffer format(java.lang.String str, java.lang.StringBuffer toAppendTo, int mods)
Implementation Note: Only line break processing and automatic lists are currently supported.
str
- The string to be formatted.toAppendTo
- The string buffer to append the result to. If this
null
a 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.Copyright © 2010 - 2020 Adobe. All Rights Reserved