Class TransformerDefinition

java.lang.Object
org.apache.camel.model.transformer.TransformerDefinition
Direct Known Subclasses:
CustomTransformerDefinition, DataFormatTransformerDefinition, EndpointTransformerDefinition, LoadTransformerDefinition

@Metadata(label="transformation") public abstract class TransformerDefinition extends Object
Represents a Transformer which declarative transforms message content according to the input type declared by InputTypeDefinition and/or output type declared by OutputTypeDefinition. If you specify from='java:com.example.ABC' and to='xml:XYZ', the transformer will be picked up when current message type is 'java:com.example.ABC' and expected message type is 'xml:XYZ'. If you specify from='java' to='xml', then it will be picked up for all of Java to xml transformation. Also, it's possible to specify a transformer name that identifies the transformer. Usually the name is a combination of a scheme and a name that represents the supported data type name. The declared InputTypeDefinition and/or OutputTypeDefinition can then reference the transformer by its name. In case the transformer name should represent a data type scheme such as name='xml' that specific transformer will also be picked up for all of Java to xml and xml to Java transformation as a fallback when no matching transformer is found.
  • Constructor Details

    • TransformerDefinition

      public TransformerDefinition()
  • Method Details

    • getScheme

      public String getScheme()
    • setScheme

      public void setScheme(String scheme)
      Set a scheme name supported by the transformer. If you specify 'csv', the transformer will be picked up for all of 'csv' from/to Java transformation. Note that the scheme matching is performed only when no exactly matched transformer exists.
      Parameters:
      scheme - the supported data type scheme
    • getName

      public String getName()
    • setName

      public void setName(String name)
      Set the transformer name under which the transformer gets referenced when specifying the input/output data type on routes. If you specify a transformer name that matches a data type scheme like 'csv' the transformer will be picked up for all of 'csv:*' from/to Java transformation. Note that the scheme matching is performed only when no exactly matched transformer exists.
      Parameters:
      name - transformer name
    • getFromType

      public String getFromType()
    • setFromType

      public void setFromType(String from)
      Set the 'from' data type name. If you specify 'xml:XYZ', the transformer will be picked up if source type is 'xml:XYZ'. If you specify just 'xml', the transformer matches with all of 'xml' source type like 'xml:ABC' or 'xml:DEF'.
      Parameters:
      from - 'from' data type name
    • setFromType

      public void setFromType(Class<?> clazz)
      Set the 'from' data type using Java class.
      Parameters:
      clazz - 'from' Java class
    • getToType

      public String getToType()
    • setToType

      public void setToType(String to)
      Set the 'to' data type name. If you specify 'json:XYZ', the transformer will be picked up if destination type is 'json:XYZ'. If you specify just 'json', the transformer matches with all of 'json' destination type like 'json:ABC' or 'json:DEF'.
      Parameters:
      to - 'to' data type name
    • setToType

      public void setToType(Class<?> clazz)
      Set the 'to' data type using Java class.
      Parameters:
      clazz - 'to' Java class