org.java.plugin.extension.util
Class PluginTypeConverter

java.lang.Object
  extended by org.java.plugin.extension.util.PluginTypeConverter
All Implemented Interfaces:
com.google.inject.spi.TypeConverter

public class PluginTypeConverter
extends java.lang.Object
implements com.google.inject.spi.TypeConverter

Extend this class to provide costom type convertion from within a plugin. The loader will be set to the plugins class loader and you can use it in your convert method.

Author:
Thasso Griebel (thasso.griebel@gmail.com)
See Also:
TypeConverter

Constructor Summary
PluginTypeConverter(java.lang.ClassLoader loader, ConverterGraph converters)
          Create a new PluginTypeConverter with given loader
 
Method Summary
 java.lang.Object convert(java.lang.String value, com.google.inject.TypeLiteral<?> toType)
          Convert given String to Object.
protected  java.lang.ClassLoader getLoader()
          Get the plugin classloader
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PluginTypeConverter

public PluginTypeConverter(java.lang.ClassLoader loader,
                           ConverterGraph converters)
Create a new PluginTypeConverter with given loader

Parameters:
loader - the classloader used to resolve resources
Method Detail

convert

public java.lang.Object convert(java.lang.String value,
                                com.google.inject.TypeLiteral<?> toType)
Convert given String to Object. You can use getLoader() to resolve resources from within the current plugin.

Specified by:
convert in interface com.google.inject.spi.TypeConverter
Parameters:
value - the string to be converted
toType - the target type
Returns:
object convefrted from given string

getLoader

protected java.lang.ClassLoader getLoader()
Get the plugin classloader

Returns:
classloader the plugin classloader


Copyright © 2010. All Rights Reserved.