Top Fields Constructors Methods
org.osgi.util.converter

pack-priv Class ConverterBuilderImpl

extends Object
implements ConverterBuilder
Class Inheritance
All Implemented Interfaces
org.osgi.util.converter.ConverterBuilder
Imports
java.lang.reflect.ParameterizedType, .Type, .WildcardType, java.util.ArrayList, .HashMap, .List, .Map

Author
$Id: 2d1145de942d2b638253bf7fc0ff735290b0b4b3 $

Field Summary

Modifier and TypeField and Description
private final List<ConverterFunction>
private final InternalConverter
private final List<ConverterFunction>
private final Map<Type, List<ConverterFunction>>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public InternalConverter
build()

Implements org.osgi.util.converter.ConverterBuilder.build.

Build the specified converter.

public ConverterBuilder
errorHandler(ConverterFunction
The function to be used to handle errors.
func
)

Implements org.osgi.util.converter.ConverterBuilder.errorHandler.

Register a custom error handler.

private List<ConverterFunction>
public ConverterBuilder
rule(ConverterFunction
The function that will handle the conversion.
func
)

Implements org.osgi.util.converter.ConverterBuilder.rule.

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

public ConverterBuilder
rule(Type
The type that this rule will produce.
t
,
ConverterFunction
The function that will handle the conversion.
func
)

Implements org.osgi.util.converter.ConverterBuilder.rule.

Register a conversion rule for this converter.

public ConverterBuilder
rule(TargetRule
A rule implementation.
rule
)

Implements org.osgi.util.converter.ConverterBuilder.rule.

Register a conversion rule for this converter.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

catchAllRulesback to summary
private final List<ConverterFunction> catchAllRules
converterback to summary
private final InternalConverter converter
errorHandlersback to summary
private final List<ConverterFunction> errorHandlers
rulesback to summary
private final Map<Type, List<ConverterFunction>> rules

Constructor Detail

ConverterBuilderImplback to summary
public ConverterBuilderImpl(InternalConverter c)

Method Detail

buildback to summary
public InternalConverter build()

Implements org.osgi.util.converter.ConverterBuilder.build.

Doc from org.osgi.util.converter.ConverterBuilder.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:InternalConverter

A new converter with the rules provided to the builder.

Annotations
@Override
errorHandlerback to summary
public ConverterBuilder errorHandler(ConverterFunction func)

Implements org.osgi.util.converter.ConverterBuilder.errorHandler.

Doc from org.osgi.util.converter.ConverterBuilder.errorHandler.

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.

Annotations
@Override
getRulesListback to summary
private List<ConverterFunction> getRulesList(Type type)
ruleback to summary
public ConverterBuilder rule(ConverterFunction func)

Implements org.osgi.util.converter.ConverterBuilder.rule.

Doc from org.osgi.util.converter.ConverterBuilder.rule.

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.

Annotations
@Override
ruleback to summary
public ConverterBuilder rule(Type t, ConverterFunction func)

Implements org.osgi.util.converter.ConverterBuilder.rule.

Doc from org.osgi.util.converter.ConverterBuilder.rule.

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
t: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.

Annotations
@Override
ruleback to summary
public ConverterBuilder rule(TargetRule rule)

Implements org.osgi.util.converter.ConverterBuilder.rule.

Doc from org.osgi.util.converter.ConverterBuilder.rule.

Register a conversion rule for this converter.

Parameters
rule:TargetRule

A rule implementation.

Returns:ConverterBuilder

This converter builder for further building.

Annotations
@Override