Class ValueHandler

java.lang.Object
com.x2j.converter.mgr.handlers.impl.ValueHandler
All Implemented Interfaces:
X2JStringHandler

public class ValueHandler extends Object implements X2JStringHandler
The handler for the X2JStringHandler interface for the VALUE keyword. As part of this:
  1. If the XPath defined in the schema is for an XML attribute, this will have the same behavior as that of XPathHandler i.e. return the attribute's value.
  2. If the XPATH defined in the schema is for an XML element, then,
    • This checks whether there is a text component for the element or not. For example,
       <ElementName>TextValue</Element>
       
    • If present, it returns the text value.
    • Otherwise, if there are one or multiple child elements, this will return the all of the child element in an encoded String format.
    • For everything else, it will return a blank String
  • Constructor Details

    • ValueHandler

      public ValueHandler()
  • Method Details

    • handleString

      public String handleString(String rawValueString, Element rootElement) throws X2JException
      Returns the value of the XPath which can be either the text component or child element(s) in String form.
      Specified by:
      handleString in interface X2JStringHandler
      Parameters:
      rawValueString - the JSON value string
      rootElement - the root element in the input XML
      Returns:
      the value of the XPath defined in the schema
      Throws:
      X2JException - X2JException