Top Description Fields Constructors Methods
org.jboss.logmanager.formatters

public final Class TextBannerFormatter

extends Delegating
Class Inheritance
Imports
java.io.IOException, .InputStream, java.net.URL, java.nio.charset.StandardCharsets, java.nio.file.Files, .Path, java.security.AccessController, .PrivilegedAction, java.util.Objects, java.util.function.Supplier, java.util.logging.Handler, org.jboss.logmanager.ExtFormatter

A formatter which prints a text banner ahead of the normal formatter header. The text banner is acquired from a Supplier which is passed in to the constructor. Several utility methods are also present which allow easy creation of Supplier instances.

Field Summary

Modifier and TypeField and Description
private final Supplier<String>
private static final Supplier<String>
private static final StackWalker
Inherited from org.jboss.logmanager.ExtFormatter.Delegating:
delegate

Constructor Summary

AccessConstructor and Description
public
TextBannerFormatter(final Supplier<String>
the supplier for the banner (must not be null)
bannerSupplier
,
final ExtFormatter
the delegate formatter (must not be null)
delegate
)

Construct a new instance.

Method Summary

Modifier and TypeMethod and Description
public static Supplier<String>

Returns:

the supplier (not null)
createFileSupplier
(Path
the path to load from (must not be null)
path
,
Supplier<String>
the fallback supplier (must not be null)
fallback
)

Create a supplier which loads the banner from the given file path, falling back to the given fallback supplier on error.

public static Supplier<String>

Returns:

the supplier (not null)
createResourceSupplier
(String
the resource name (must not be null)
resource
,
ClassLoader
the class loader to load from (must not be null)
classLoader
,
Supplier<String>
the fallback supplier (must not be null)
fallback
)

Create a supplier which loads the banner from a resource in the given class loader, falling back to the given fallback supplier on error.

public static Supplier<String>

Returns:

the supplier (not null)
createResourceSupplier
(String
the resource name (must not be null)
resource
,
Supplier<String>
the fallback supplier (must not be null)
fallback
)

Create a supplier which loads the banner from a resource in the caller's class loader, falling back to the given fallback supplier on error.

public static Supplier<String>

Returns:

a supplier which returns the given string (not null)
createStringSupplier
(String
the string (must not be null)
string
)

Create a supplier which always returns the given string.

public static Supplier<String>

Returns:

the supplier (not null)
createUrlSupplier
(URL
the URL to load from (must not be null)
url
,
Supplier<String>
the fallback supplier (must not be null)
fallback
)

Create a supplier which loads the banner from the given URL, falling back to the given fallback supplier on error.

private static ClassLoader
public static Supplier<String>

Returns:

the empty supplier (not null)
getEmptySupplier
()

Get the empty supplier which always returns an empty string.

public String
getHead(final Handler
The target handler (can be null)
h
)

Overrides org.jboss.logmanager.ExtFormatter.Delegating.getHead.

Return the header string for a set of formatted records.

private static String
Inherited from org.jboss.logmanager.ExtFormatter.Delegating:
formatformatMessagegetTailisCallerCalculationRequired

Field Detail

bannerSupplierback to summary
private final Supplier<String> bannerSupplier
EMPTYback to summary
private static final Supplier<String> EMPTY
STACK_WALKERback to summary
private static final StackWalker STACK_WALKER

Constructor Detail

TextBannerFormatterback to summary
public TextBannerFormatter(final Supplier<String> bannerSupplier, final ExtFormatter delegate)

Construct a new instance.

Parameters
bannerSupplier:Supplier<String>

the supplier for the banner (must not be null)

delegate:ExtFormatter

the delegate formatter (must not be null)

Method Detail

createFileSupplierback to summary
public static Supplier<String> createFileSupplier(Path path, Supplier<String> fallback)

Create a supplier which loads the banner from the given file path, falling back to the given fallback supplier on error.

Parameters
path:Path

the path to load from (must not be null)

fallback:Supplier<String>

the fallback supplier (must not be null)

Returns:Supplier<String>

the supplier (not null)

createResourceSupplierback to summary
public static Supplier<String> createResourceSupplier(String resource, ClassLoader classLoader, Supplier<String> fallback)

Create a supplier which loads the banner from a resource in the given class loader, falling back to the given fallback supplier on error.

Parameters
resource:String

the resource name (must not be null)

classLoader:ClassLoader

the class loader to load from (must not be null)

fallback:Supplier<String>

the fallback supplier (must not be null)

Returns:Supplier<String>

the supplier (not null)

createResourceSupplierback to summary
public static Supplier<String> createResourceSupplier(String resource, Supplier<String> fallback)

Create a supplier which loads the banner from a resource in the caller's class loader, falling back to the given fallback supplier on error.

Parameters
resource:String

the resource name (must not be null)

fallback:Supplier<String>

the fallback supplier (must not be null)

Returns:Supplier<String>

the supplier (not null)

createStringSupplierback to summary
public static Supplier<String> createStringSupplier(String string)

Create a supplier which always returns the given string.

Parameters
string:String

the string (must not be null)

Returns:Supplier<String>

a supplier which returns the given string (not null)

createUrlSupplierback to summary
public static Supplier<String> createUrlSupplier(URL url, Supplier<String> fallback)

Create a supplier which loads the banner from the given URL, falling back to the given fallback supplier on error.

Parameters
url:URL

the URL to load from (must not be null)

fallback:Supplier<String>

the fallback supplier (must not be null)

Returns:Supplier<String>

the supplier (not null)

getClassLoaderback to summary
private static ClassLoader getClassLoader(Class<?> clazz)
getEmptySupplierback to summary
public static Supplier<String> getEmptySupplier()

Get the empty supplier which always returns an empty string.

Returns:Supplier<String>

the empty supplier (not null)

getHeadback to summary
public String getHead(final Handler h)

Overrides org.jboss.logmanager.ExtFormatter.Delegating.getHead.

Doc from java.util.logging.Formatter.getHead.

Return the header string for a set of formatted records.

This base class returns an empty string, but this may be overridden by subclasses.

Parameters
h:Handler

The target handler (can be null)

Returns:String

header string

loadStringFromStreamback to summary
private static String loadStringFromStream(final InputStream is) throws IOException