Package jadex.commons.transformation
Class BasicTypeConverter
- java.lang.Object
-
- jadex.commons.transformation.BasicTypeConverter
-
public class BasicTypeConverter extends java.lang.Object
Converter for basic types.
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.util.Map<java.lang.Class<?>,IStringObjectConverter>
basicconverters
The map of basic converters.static IStringObjectConverter
BOOLEAN_CONVERTER
String -> Boolean converter.static IStringObjectConverter
BYTE_CONVERTER
String -> Byte converter.static IStringObjectConverter
CHARACTER_CONVERTER
String -> Character converter.protected java.util.Map<java.lang.Class<?>,IStringObjectConverter>
converters
The map of instance converters.static BasicTypeConverter
CONVERTERS
static IStringObjectConverter
DATE_CONVERTER
String -> Date converter.static IStringObjectConverter
DOUBLE_CONVERTER
String -> Double converter.protected static java.util.Map<java.lang.Class<?>,IStringObjectConverter>
extconverters
The extended map of converters.static IStringObjectConverter
FLOAT_CONVERTER
String -> Float converter.static IStringObjectConverter
INTEGER_CONVERTER
String -> Integer converter.static IStringObjectConverter
LONG_CONVERTER
String -> Long converter.static IStringObjectConverter
SHORT_CONVERTER
String -> Short converter.static IStringObjectConverter
STRING_CONVERTER
String -> String converter.static IStringObjectConverter
URI_CONVERTER
String -> URI converter.static IStringObjectConverter
URL_CONVERTER
String -> URL converter.
-
Constructor Summary
Constructors Constructor Description BasicTypeConverter()
Create a new type converter.BasicTypeConverter(java.util.Map<java.lang.Class<?>,IStringObjectConverter> converters)
Create a new type converter.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addConverter(java.lang.Class<?> type, IStringObjectConverter converter)
Add a new converter.java.lang.String
convertObject(java.lang.Object val, java.lang.Class<?> type, java.lang.Object context)
Convert a string value.java.lang.Object
convertString(java.lang.String val, java.lang.Class<?> type, java.lang.Object context)
Convert a string value.static IObjectStringConverter
getBasicObjectConverter(java.lang.Class<?> clazz)
Get a X -> String converter for a source clazz.static IStringObjectConverter
getBasicStringConverter(java.lang.Class<?> clazz)
Get a String -> X converter for a target clazz.java.util.Map<java.lang.Class<?>,IStringObjectConverter>
getConverters()
Get converters copy.java.util.Map<java.lang.Class<?>,IStringObjectConverter>
getExtendedConverters()
Get extended converters copy.IObjectStringConverter
getObjectConverter(java.lang.Class<?> clazz)
Get a X -> String converter for a source clazz.IStringObjectConverter
getStringConverter(java.lang.Class<?> clazz)
Get a String -> X converter for a target clazz.static boolean
isBuiltInType(java.lang.Class<?> clazz)
Test if a clazz is a built-in type.boolean
isSupportedType(java.lang.Class<?> clazz)
Test if a clazz is a built-in type.void
removeConverter(java.lang.Class<?> type)
Remove a converter.
-
-
-
Field Detail
-
STRING_CONVERTER
public static final IStringObjectConverter STRING_CONVERTER
String -> String converter. (remove?)
-
INTEGER_CONVERTER
public static final IStringObjectConverter INTEGER_CONVERTER
String -> Integer converter.
-
LONG_CONVERTER
public static final IStringObjectConverter LONG_CONVERTER
String -> Long converter.
-
FLOAT_CONVERTER
public static final IStringObjectConverter FLOAT_CONVERTER
String -> Float converter.
-
DOUBLE_CONVERTER
public static final IStringObjectConverter DOUBLE_CONVERTER
String -> Double converter.
-
BOOLEAN_CONVERTER
public static final IStringObjectConverter BOOLEAN_CONVERTER
String -> Boolean converter.
-
SHORT_CONVERTER
public static final IStringObjectConverter SHORT_CONVERTER
String -> Short converter.
-
BYTE_CONVERTER
public static final IStringObjectConverter BYTE_CONVERTER
String -> Byte converter.
-
CHARACTER_CONVERTER
public static final IStringObjectConverter CHARACTER_CONVERTER
String -> Character converter. (remove?)
-
DATE_CONVERTER
public static final IStringObjectConverter DATE_CONVERTER
String -> Date converter.
-
URL_CONVERTER
public static final IStringObjectConverter URL_CONVERTER
String -> URL converter.
-
URI_CONVERTER
public static final IStringObjectConverter URI_CONVERTER
String -> URI converter.
-
basicconverters
protected static final java.util.Map<java.lang.Class<?>,IStringObjectConverter> basicconverters
The map of basic converters.
-
extconverters
protected static final java.util.Map<java.lang.Class<?>,IStringObjectConverter> extconverters
The extended map of converters.
-
CONVERTERS
public static final BasicTypeConverter CONVERTERS
-
converters
protected java.util.Map<java.lang.Class<?>,IStringObjectConverter> converters
The map of instance converters.
-
-
Constructor Detail
-
BasicTypeConverter
public BasicTypeConverter()
Create a new type converter.- Parameters:
converters
- The contained converters.
-
BasicTypeConverter
public BasicTypeConverter(java.util.Map<java.lang.Class<?>,IStringObjectConverter> converters)
Create a new type converter.- Parameters:
converters
- The contained converters.
-
-
Method Detail
-
convertString
public java.lang.Object convertString(java.lang.String val, java.lang.Class<?> type, java.lang.Object context) throws java.lang.Exception
Convert a string value.- Parameters:
val
- The string value.type
- The target class.context
- The conversion context.- Returns:
- The converted value.
- Throws:
java.lang.Exception
-
convertObject
public java.lang.String convertObject(java.lang.Object val, java.lang.Class<?> type, java.lang.Object context) throws java.lang.Exception
Convert a string value.- Parameters:
val
- The string value.type
- The target class.context
- The conversion context.- Returns:
- The converted value.
- Throws:
java.lang.Exception
-
addConverter
public void addConverter(java.lang.Class<?> type, IStringObjectConverter converter)
Add a new converter.- Parameters:
type
- The type.converter
- The converter.
-
removeConverter
public void removeConverter(java.lang.Class<?> type)
Remove a converter.- Parameters:
type
- The type.
-
isSupportedType
public boolean isSupportedType(java.lang.Class<?> clazz)
Test if a clazz is a built-in type.- Parameters:
clazz
- The clazz.- Returns:
- True, if built-in type.
-
getStringConverter
public IStringObjectConverter getStringConverter(java.lang.Class<?> clazz)
Get a String -> X converter for a target clazz.- Parameters:
clazz
- The clazz.- Returns:
- converter The converter.
-
getObjectConverter
public IObjectStringConverter getObjectConverter(java.lang.Class<?> clazz)
Get a X -> String converter for a source clazz.- Parameters:
clazz
- The clazz.- Returns:
- converter The converter.
-
isBuiltInType
public static boolean isBuiltInType(java.lang.Class<?> clazz)
Test if a clazz is a built-in type.- Parameters:
clazz
- The clazz.- Returns:
- True, if built-in type.
-
getBasicStringConverter
public static IStringObjectConverter getBasicStringConverter(java.lang.Class<?> clazz)
Get a String -> X converter for a target clazz.- Parameters:
clazz
- The clazz.- Returns:
- converter The converter.
-
getBasicObjectConverter
public static IObjectStringConverter getBasicObjectConverter(java.lang.Class<?> clazz)
Get a X -> String converter for a source clazz.- Parameters:
clazz
- The clazz.- Returns:
- converter The converter.
-
getConverters
public java.util.Map<java.lang.Class<?>,IStringObjectConverter> getConverters()
Get converters copy.- Returns:
- Get a copy of the converters.
-
getExtendedConverters
public java.util.Map<java.lang.Class<?>,IStringObjectConverter> getExtendedConverters()
Get extended converters copy.- Returns:
- Get a copy of the extended converters.
-
-