Transmorph 2.0.0 released - An object converter library


News: Transmorph 2.0.0 released - An object converter library

  1. 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 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 improved
  2. This post is another proof that has deteriorated into a pretty lame Freshmeat competitor.
  3. ... 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.
  4. This post is another proof that has deteriorated into a pretty lame Freshmeat competitor.
    I agree - your kind of post makes this site much worse than FreshMeat.
  5. This post is another proof that has deteriorated into a pretty lame Freshmeat competitor.

    I agree - your kind of post makes this site much worse than FreshMeat.
    And your post proves that TSS is crowed mostly by lame people. QED. Time to move.
  6. 2 questions: - What are the DefaultConverters? - Are conversion errors reported with an exception or swallowed like in Commons/Beanutils?
  7. 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.
  8. How is it different from Dozer?[ Go to top ]

    What are conceptual differences with existing Dozer mapping framework? What was the reason building duplicate mapping framework instead of contributing directly to Dozer (
  9. 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 than to Dozer.