org.jbpm.process.workitem.parser

## Class ParserWorkItemHandler

- java.lang.Object
- - org.jbpm.process.workitem.AbstractLogOrThrowWorkItemHandler
  - - org.jbpm.process.workitem.parser.ParserWorkItemHandler

- All Implemented Interfaces:
    org.kie.api.runtime.process.WorkItemHandler

      public class ParserWorkItemHandler
      extends AbstractLogOrThrowWorkItemHandler

  WorkItemHandler that is capable of parsing String to objects and vice-versa. Currently supports only two formats
  - XML
  - JSON
  Here is the list of supported parameters:
  - Input - The input data. If you provide a string, the parser will try to parse the string to an object of type Type and format Format (see below), if not, it will try to parse the object to a String of format Format. It is a required parameter;
  - Format - It is a required parameter that can have the values JSON or XML;
  - Result - The result is an output parameter that will be a string if you provide an Input object that is not of String type; and an object of type Type if you provide an Input object of type String.
  - Type - The FQN of the object type (for example com.acme.Customer)
  Providing these parameters correctly is enough to use the parser task. Please bear in mind that it uses JAXB to parse the object, so it must have the @XmlRootElement annotation.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `FORMAT` Only supports JSON or XML.
    `static String` | `INPUT` The input object of type TYPE or String (if you set toObject)
    `static String` | `JSON`
    `static String` | `RESULT` The resulting object or String (if toObject is false it will be a String).
    `static String` | `TYPE` The target object type full qualified name (com.acme.Customer)
    `static String` | `XML`

    - ### Fields inherited from class org.jbpm.process.workitem.AbstractLogOrThrowWorkItemHandler

      `logThrownException`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ParserWorkItemHandler()`
    `ParserWorkItemHandler(ClassLoader cl)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `abortWorkItem(org.kie.api.runtime.process.WorkItem wi, org.kie.api.runtime.process.WorkItemManager wim)`
    `protected Object` | `convertJSONToObject(String input, Class<?> type)`
    `protected Object` | `convertToJSON(Object input)`
    `protected String` | `convertToXML(Object input)`
    `protected Object` | `convertXMLToObject(String input, Class<?> type)`
    `void` | `executeWorkItem(org.kie.api.runtime.process.WorkItem wi, org.kie.api.runtime.process.WorkItemManager wim)`

    - ### Methods inherited from class org.jbpm.process.workitem.AbstractLogOrThrowWorkItemHandler

      `handleException, handleException, setLogThrownException`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### JSON

          public static final String JSON

      See Also:
        Constant Field Values

    - #### XML

          public static final String XML

      See Also:
        Constant Field Values

    - #### FORMAT

          public static final String FORMAT

      Only supports JSON or XML.
      See Also:
        Constant Field Values

    - #### TYPE

          public static final String TYPE

      The target object type full qualified name (com.acme.Customer)
      See Also:
        Constant Field Values

    - #### INPUT

          public static final String INPUT

      The input object of type TYPE or String (if you set toObject)
      See Also:
        Constant Field Values

    - #### RESULT

          public static final String RESULT

      The resulting object or String (if toObject is false it will be a String).
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### ParserWorkItemHandler

          public ParserWorkItemHandler()

    - #### ParserWorkItemHandler

          public ParserWorkItemHandler(ClassLoader cl)

  - ### Method Detail

    - #### abortWorkItem

          public void abortWorkItem(org.kie.api.runtime.process.WorkItem wi,
                           org.kie.api.runtime.process.WorkItemManager wim)

    - #### executeWorkItem

          public void executeWorkItem(org.kie.api.runtime.process.WorkItem wi,
                             org.kie.api.runtime.process.WorkItemManager wim)

    - #### convertXMLToObject

          protected Object convertXMLToObject(String input,
                                  Class<?> type)

    - #### convertToXML

          protected String convertToXML(Object input)
                                 throws JAXBException

      Throws:
        `JAXBException`

    - #### convertJSONToObject

          protected Object convertJSONToObject(String input,
                                   Class<?> type)
                                        throws com.fasterxml.jackson.databind.JsonMappingException,
                                               IOException

      Throws:
        `com.fasterxml.jackson.databind.JsonMappingException`
        `IOException`

    - #### convertToJSON

          protected Object convertToJSON(Object input)
                                  throws com.fasterxml.jackson.databind.JsonMappingException,
                                         IOException

      Throws:
        `com.fasterxml.jackson.databind.JsonMappingException`
        `IOException`

Copyright © 2001–2015 JBoss by Red Hat. All rights reserved.