-
Transmorph 2.0.0 released - An object converter library (8 messages)
- Posted by: C??dric Chabanois
- Posted on: February 09 2009 07:10 EST
About : Transmorph is a free java library used to convert a Java object of one type into an object of another type (with another signature, possibly parameterized). Transmorph strong points are : * support conversion for primitives and objects * support conversion to multidimensional arrays * support conversion to parameterized collections and types * support conversion for beans that contain bi-directional relationships * you can choose exactly which converters you want to use * jars for JDK 1.4 and JDK 1.5 * no dependencies * 40 converters included * easy to add more converters * objects can be modified after conversion using modifiers * can convert to a type given either its java type (Class) or signature * easy to use Samples Transmorph converter = new Transmorph(ConverterTest.class .getClassLoader(), new DefaultConverters()); // int[][] => String[][] int[][] arrayOfArrayOfInts = new int[][] { { 11, 12, 13 }, { 21, 22, 23 }, { 31 } }; String[][] arrayOfArrayOfStrings = (String[][]) converter.convert( arrayOfArrayOfInts, (new String[0][0]).getClass()); // Map[String, String[]] => Map> Map map = new HashMap(); map.put("key1", new String[] { "value1-1", "value1-2" }); map.put("key2", new String[] { "value2-1", "value2-2" }); map.put("key3", null); map.put("key4", new String[] { null, null }); map.put(null, new String[] { "value5-1", "value5-2" }); Map> converted = (Map>) converter .convert(map, "Ljava.util.Map;>;"); // int[] => Set (ArrayToSetConverter) int[] arrayOfInts = new int[] { 0, 1, 2, 3, 4, 5 }; Set setOfInts = (Set) converter.convert(arrayOfInts, Set.class, new Class[] { Integer.class }); Find more samples at http://transmorph.sourceforge.net Features added in version 2.0.0 * support for dotted style signatures (Ljava.util.Map;>;) * new conversion context. It contains a pool of created objects to support data objects that contain bi-directionalrelationships. It also contains the used converter (useful for debugging) * new converters (BeanToBean, EnumToEnum, ImmutableIdentityConverter, StringToQName, StringToTimeZone) * added the notion of modifiers than can be applied after conversion : CanonicalizeFile, LowerCaseString, ResolveFile, TrimString, UppercaseString * many converters improvedThreaded Messages (8)
- Re: Transmorph 2.0.0 released - An object converter library by han theman on February 09 2009 09:12 EST
- Re: Transmorph 2.0.0 released - An object converter library by Thomas Mueller on February 09 2009 10:31 EST
- Re: Transmorph 2.0.0 released - An object converter library by Alessandro Santini on February 10 2009 06:57 EST
- Re: Transmorph 2.0.0 released - An object converter library by han theman on February 10 2009 12:26 EST
- Re: Transmorph 2.0.0 released - An object converter library by Casual Visitor on February 09 2009 14:13 EST
- Re: Transmorph 2.0.0 released - An object converter library by C??dric Chabanois on February 09 2009 16:06 EST
- How is it different from Dozer? by Ruslan Zenin on February 09 2009 20:13 EST
- Re: How is it different from Dozer? by C??dric Chabanois on February 10 2009 01:44 EST
-
Re: Transmorph 2.0.0 released - An object converter library[ Go to top ]
- Posted by: han theman
- Posted on: February 09 2009 09:12 EST
- in response to C??dric Chabanois
This post is another proof that TheServerSide.com has deteriorated into a pretty lame Freshmeat competitor. -
Re: Transmorph 2.0.0 released - An object converter library[ Go to top ]
- Posted by: Thomas Mueller
- Posted on: February 09 2009 10:31 EST
- in response to han theman
... there is less spam on Freshmeat ... :-) What are the 'good' Java newsfeeds nowadays? I have subscribed to: Javalobby, JavaWorld, TheServerSide, Artima Developer Spotlight, The Java(tm) Specialists' Newsletter. -
Re: Transmorph 2.0.0 released - An object converter library[ Go to top ]
- Posted by: Alessandro Santini
- Posted on: February 10 2009 06:57 EST
- in response to han theman
This post is another proof that TheServerSide.com has deteriorated into a pretty lame Freshmeat competitor.
I agree - your kind of post makes this site much worse than FreshMeat. -
Re: Transmorph 2.0.0 released - An object converter library[ Go to top ]
- Posted by: han theman
- Posted on: February 10 2009 12:26 EST
- in response to Alessandro Santini
And your post proves that TSS is crowed mostly by lame people. QED. Time to move.This post is another proof that TheServerSide.com has deteriorated into a pretty lame Freshmeat competitor.
I agree - your kind of post makes this site much worse than FreshMeat. -
Re: Transmorph 2.0.0 released - An object converter library[ Go to top ]
- Posted by: Casual Visitor
- Posted on: February 09 2009 14:13 EST
- in response to C??dric Chabanois
2 questions: - What are the DefaultConverters? - Are conversion errors reported with an exception or swallowed like in Commons/Beanutils? -
Re: Transmorph 2.0.0 released - An object converter library[ Go to top ]
- Posted by: C??dric Chabanois
- Posted on: February 09 2009 16:06 EST
- in response to Casual Visitor
1) DefaultConverters is a default set of converters (33 converters). In DefaultConverters, you have for example : numberToNumber, stringToNumber, stringToBoolean, stringToEnum, stringToClass, mapToMap, arrayToCollection, collectionToCollection, collectionToArray ... Of course, you can use other converters than the default ones. Some converters have some parameters. 2) Conversions errors are reported with an exception. You can also get which converters have been used for a given conversion if you wish. -
How is it different from Dozer?[ Go to top ]
- Posted by: Ruslan Zenin
- Posted on: February 09 2009 20:13 EST
- in response to C??dric Chabanois
What are conceptual differences with existing Dozer mapping framework? What was the reason building duplicate mapping framework instead of contributing directly to Dozer (http://dozer.sourceforge.net)? -
Re: How is it different from Dozer?[ Go to top ]
- Posted by: C??dric Chabanois
- Posted on: February 10 2009 01:44 EST
- in response to Ruslan Zenin
Because Dozer did not meet my needs. Dozer supports type conversion but it seems to do it only in the context of a bean and its properties, not just on a single property. I needed to convert an object to a destination type (which does not have to be a bean) given its parameterized signature. Dozer is a Java Bean to Java Bean mapper. I don't think you can convert from a Map<String, String[]> to a Map> for example. So, here are the differences between Transmorph and Doze * Transmorph is more generic than Dozer, you can convert from any object to any (parameterized) destination type. * no xml configuration * there are no "custom" converters in Transmorph but only converters. What I mean is that converters you write are not different from other converters already included in Transmorph. So all what is done in already existing converters, you can do it in your own converters. * converters can be more configurable than in dozer because they can take any objects as parameters * with transmorph, you can configure which converters you want to use at each step. For example, you can set which converter(s) to use to convert the keys of a Map and which converter(s) to use for the values However, if you only need to convert from bean to bean, dozer may be a better choice than transmorph. A BeanToBean converter has been added to transmorph in 2.0.0 but dozer has the following features that BeanToBean converter in transmorph does not have : * Custom Bean Factories * mapping POJOs to XMLBeans and JAXB * mapping for field with no get() or set() methods and probably some other features Of course, BeanToBean converter will be improved in next versions. Transmorph is probably more similar to EZMorph http://ezmorph.sourceforge.net/ than to Dozer.