Top Description Methods
org.osgi.util.converter

public Interface ConverterBuilder

Known Direct Implementers
org.osgi.util.converter.ConverterBuilderImpl
Annotations
@ProviderType
Imports
java.lang.reflect.Type, org.osgi.annotation.versioning.ProviderType

A builder to create a new converter with modified behavior based on an existing converter. The modified behavior is specified by providing rules and/or conversion functions. If multiple rules match they will be visited in sequence of registration. If a rule's function returns null the next rule found will be visited. If none of the rules can handle the conversion, the original converter will be used to perform the conversion.
Author
$Id: bbdc41232244c9372378d02c45adaeea197267cf $

Method Summary

Modifier and TypeMethod and Description
public Converter

Returns:

A new converter with the rules provided to the builder.
build
()

Build the specified converter.

public ConverterBuilder

Returns:

This converter builder for further building.
errorHandler
(ConverterFunction
The function to be used to handle errors.
func
)

Register a custom error handler.

public ConverterBuilder

Returns:

This converter builder for further building.
rule
(Type
The type that this rule will produce.
type
,
ConverterFunction
The function that will handle the conversion.
func
)

Register a conversion rule for this converter.

public ConverterBuilder

Returns:

This converter builder for further building.
rule
(TargetRule
A rule implementation.
rule
)

Register a conversion rule for this converter.

public ConverterBuilder

Returns:

This converter builder for further building.
rule
(ConverterFunction
The function that will handle the conversion.
func
)

Register a catch-all rule, will be called of no other rule matches.

Method Detail

buildback to summary
public Converter build()

Build the specified converter. Each time this method is called a new custom converter is produced based on the rules registered with the builder.

Returns:Converter

A new converter with the rules provided to the builder.

errorHandlerback to summary
public ConverterBuilder errorHandler(ConverterFunction func)

Register a custom error handler. The custom error handler will be called when the conversion would otherwise throw an exception. The error handler can either throw a different exception or return a value to be used for the failed conversion.

Parameters
func:ConverterFunction

The function to be used to handle errors.

Returns:ConverterBuilder

This converter builder for further building.

ruleback to summary
public ConverterBuilder rule(Type type, ConverterFunction func)

Register a conversion rule for this converter. Note that only the target type is specified, so the rule will be visited for every conversion to the target type.

Parameters
type:Type

The type that this rule will produce.

func:ConverterFunction

The function that will handle the conversion.

Returns:ConverterBuilder

This converter builder for further building.

ruleback to summary
public ConverterBuilder rule(TargetRule rule)

Register a conversion rule for this converter.

Parameters
rule:TargetRule

A rule implementation.

Returns:ConverterBuilder

This converter builder for further building.

ruleback to summary
public ConverterBuilder rule(ConverterFunction func)

Register a catch-all rule, will be called of no other rule matches.

Parameters
func:ConverterFunction

The function that will handle the conversion.

Returns:ConverterBuilder

This converter builder for further building.