| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sf.morph.transform.transformers.BaseTransformer
net.sf.morph.transform.converters.ArbitraryObjectMappingConverter
public class ArbitraryObjectMappingConverter
A transformer which transforms defined arbitrary objects to other defined
 arbitrary objects based on this class' mapping property.  For
 example, an arbitrary mapping might specify that the Integer 1 be converted
 to the String "one".  As many mappings as are needed may be specified.  By
 default, mappings are assumed to be bidirectional.  Continuing with the
 example above, this means that in addition to the Integer 1 being mapped
 transformed to the String "one", the String "one" will be transformed to the
 Integer 1.
| Field Summary | 
|---|
| Fields inherited from class net.sf.morph.transform.transformers.BaseTransformer | 
|---|
| destinationClasses, log, sourceClasses | 
| Fields inherited from interface net.sf.morph.transform.Transformer | 
|---|
| TRANSFORMATION_TYPE_CONVERT, TRANSFORMATION_TYPE_COPY | 
| Fields inherited from interface net.sf.morph.transform.Transformer | 
|---|
| TRANSFORMATION_TYPE_CONVERT, TRANSFORMATION_TYPE_COPY | 
| Constructor Summary | |
|---|---|
| ArbitraryObjectMappingConverter() | |
| Method Summary | |
|---|---|
| protected  void | addContainedClasses(java.util.Set classes,
                    java.util.Collection objects)Add the classes of the contents of objectstoclasses. | 
| protected  java.lang.Object | convertImpl(java.lang.Class destinationClass,
            java.lang.Object source,
            java.util.Locale locale)The implementation of the convertmethod, which may omit
 the invalid argument checks already performed by this base class. | 
| protected  java.lang.Class[] | getClasses(java.util.Collection forwardMappingKeys,
           java.util.Collection backwardMappingKeys)Get the forward classes, plus backward classes if this converter is bidi. | 
| protected  java.lang.Class[] | getDestinationClassesImpl()Transformer.getDestinationClasses()implementation template method. | 
|  java.util.Map | getMapping()Get the object mapping. | 
| protected  java.lang.Class[] | getSourceClassesImpl()Transformer.getSourceClasses()implementation template method. | 
|  java.util.Map | getVisitedSourceToDestinationMap()Deprecated. | 
|  boolean | isBidirectional()Learn whether this ArbitraryObjectMappingConverter is bidirectional. | 
| protected  boolean | isWrappingRuntimeExceptions()Indicates whether runtime exceptions should be wrapped as TransformationExceptions. | 
|  void | setBidirectional(boolean bidirectional)Set whether this ArbitraryObjectMappingConverter is bidirectional. | 
|  void | setMapping(java.util.Map mapping)Set the mapping. | 
|  void | setVisitedSourceToDestinationMap(java.util.Map visitedSourceToDestinationMap)Deprecated. | 
| Methods inherited from class java.lang.Object | 
|---|
| equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait | 
| Methods inherited from interface net.sf.morph.transform.DecoratedConverter | 
|---|
| convert, equals, equals | 
| Methods inherited from interface net.sf.morph.transform.Converter | 
|---|
| convert | 
| Methods inherited from interface net.sf.morph.transform.Transformer | 
|---|
| getDestinationClasses, getSourceClasses | 
| Methods inherited from interface net.sf.morph.transform.Transformer | 
|---|
| getDestinationClasses, getSourceClasses | 
| Methods inherited from interface net.sf.morph.transform.ExplicitTransformer | 
|---|
| isTransformable | 
| Constructor Detail | 
|---|
public ArbitraryObjectMappingConverter()
| Method Detail | 
|---|
protected java.lang.Object convertImpl(java.lang.Class destinationClass,
                                       java.lang.Object source,
                                       java.util.Locale locale)
                                throws java.lang.Exception
convert method, which may omit
 the invalid argument checks already performed by this base class. By
 default, this method creates a new instance of the destinationClass and
 copies information from the source to the destination. This
 implementation should be fine as-is for Copiers, but Converters will need
 to implement this method since they will not be implementing the copy
 method.
convertImpl in class BaseTransformerlocale - the locale in which the conversion should take place. for
            converters that are not locale-aware, the local argument can
            simply be ignored
java.lang.Exception
protected java.lang.Class[] getClasses(java.util.Collection forwardMappingKeys,
                                       java.util.Collection backwardMappingKeys)
                                throws java.lang.Exception
forwardMappingKeys - backwardMappingKeys - 
java.lang.Exception - not likely
protected void addContainedClasses(java.util.Set classes,
                                   java.util.Collection objects)
objects to classes.
classes - objects - 
protected java.lang.Class[] getSourceClassesImpl()
                                          throws java.lang.Exception
Transformer.getSourceClasses() implementation template method.
getSourceClassesImpl in class BaseTransformerjava.lang.Exception
protected java.lang.Class[] getDestinationClassesImpl()
                                               throws java.lang.Exception
Transformer.getDestinationClasses() implementation template method.
getDestinationClassesImpl in class BaseTransformerjava.lang.Exceptionprotected boolean isWrappingRuntimeExceptions()
TransformationExceptions. By default, this method returns
 true.
 
 
 Simple transformers in Morph that operate on JDK types like Numbers and
 Strings will usually set this value to true so that they
 throw TransformationExceptions if problems occur. More complex
 transformers that operate on graphs of objects are encouraged to set this
 value to false so that runtime exceptions are not wrapped.
 This way, problems accessing data will be expressed by the native API of
 a user's domain objects and avoid the need to catch Morph-specific
 exceptions (assuming the use of runtime exceptions in said domain
 objects).
isWrappingRuntimeExceptions in class BaseTransformertruepublic boolean isBidirectional()
public void setBidirectional(boolean bidirectional)
bidirectional - public java.util.Map getMapping()
public void setMapping(java.util.Map mapping)
mapping - the mapping
java.lang.IllegalArgumentException - if bidirectional is true and
             there is some value which is mapped to more than one key. In
             this case, it is impossible to construct a bidirectional map
             because there is no way to determine to which key the value
             is mapped.public java.util.Map getVisitedSourceToDestinationMap()
public void setVisitedSourceToDestinationMap(java.util.Map visitedSourceToDestinationMap)
visitedSourceToDestinationMap - | 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||