|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectubiware.core.visualizer.Formatter
final class Formatter
Default formatter used by the package in order to avoid creating many instances.
Warning: Methods making use of this class/instance should synchronize it, using the singletong instance as a monitor, for example:
...
Formatter f = Formatter.getSingleton();
synchronized(f) {
// do stuff...
// ...
}
Also this class provides a convenience method, format(java.lang.String, java.lang.Object...).
| Method Summary | |
|---|---|
static java.lang.String |
format(java.lang.String format,
java.lang.Object... args)
Convenience method to produce a formatted string on the fly. |
java.util.Formatter |
getFormatter()
Provided access to the actual Formatter. |
java.io.CharArrayWriter |
getOut()
Provides access to the destination CharArrayWriter so that it can be reset. |
(package private) static Formatter |
getSingleton()
Provides access to the only instance allowed to be of this class. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static java.lang.String format(java.lang.String format,
java.lang.Object... args)
Convenience method to produce a formatted string on the fly.
This method will delegate format and args to the underlying Formatter.format(String,Object...)
method. It will also do that in the adviced synchronized manner.
This method is completely independent from the rest of the class, it's build as a layer above it, and its effects can be reproduced by the following code:
final Formatter F = getSingleton();
synchronized (F) {
F.getOut().reset();
return F.getFormatter().format(format, args).toString();
}
format - delegated to Formatter.format(String,Object...)args -
static Formatter getSingleton()
Provides access to the only instance allowed to be of this class.
Warning:Methods making use of this class/instance should synchronize it, using the singletong instance as a monitor, for example:
...
Formatter f = Formatter.getSingleton();
synchronized(f) {
// do stuff...
// ...
}
public java.util.Formatter getFormatter()
Provided access to the actual Formatter.
The destination to which the formatter writes is a CharArrayWriter and should be cleared by invoking
CharArrayWriter.reset(). It is not done automatically but it is not ensured that the contents of the array will remain
untouched between invokations.
To obtain the destination char array without the need to cast anything, one can use getOut().
Formatter..public java.io.CharArrayWriter getOut()
Provides access to the destination CharArrayWriter so that it can be reset.
CharArrayWriter
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||