Package org.json

Interface XMLXsiTypeConverter<T>

Type Parameters:
T - return type of convert method

public interface XMLXsiTypeConverter<T>
Type conversion configuration interface to be used with xsi:type attributes.
 XML Sample
 
      <root>
          <asString xsi:type="string">12345</asString>
          <asInt xsi:type="integer">54321</asInt>
      </root>
 
 JSON Output
 
     {
         "root" : {
             "asString" : "12345",
             "asInt": 54321
         }
     }
 

 Usage
 
      Map<String, XMLXsiTypeConverter<?>> xsiTypeMap = new HashMap<String, XMLXsiTypeConverter<?>>();
      xsiTypeMap.put("string", new XMLXsiTypeConverter<String>() {
          &#64;Override public String convert(final String value) {
              return value;
          }
      });
      xsiTypeMap.put("integer", new XMLXsiTypeConverter<Integer>() {
          &#64;Override public Integer convert(final String value) {
              return Integer.valueOf(value);
          }
      });
 
 
  • Method Summary

    Modifier and Type
    Method
    Description
    convert(String value)
    Converts an XML xsi:type attribute value to the specified type T.
  • Method Details

    • convert

      T convert(String value)
      Converts an XML xsi:type attribute value to the specified type T.
      Parameters:
      value - The string representation of the XML xsi:type attribute value to be converted.
      Returns:
      An object of type T representing the converted value.