All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.json.XMLXsiTypeConverter Maven / Gradle / Ivy

Go to download

JSON is a light-weight, language independent, data interchange format. See http://www.JSON.org/ The files in this package implement JSON encoders/decoders in Java. It also includes the capability to convert between JSON and XML, HTTP headers, Cookies, and CDL. This is a reference implementation. There are a large number of JSON packages in Java. Perhaps someday the Java community will standardize on one. Until then, choose carefully.

The newest version!
package org.json;
/*
Public Domain.
*/

/**
 * Type conversion configuration interface to be used with xsi:type attributes.
 * 
 * XML Sample
 * {@code
 *      
 *          12345
 *          54321
 *      
 * }
 * JSON Output
 * {@code
 *     {
 *         "root" : {
 *             "asString" : "12345",
 *             "asInt": 54321
 *         }
 *     }
 * }
 *
 * Usage
 * {@code
 *      Map> xsiTypeMap = new HashMap>();
 *      xsiTypeMap.put("string", new XMLXsiTypeConverter() {
 *          @Override public String convert(final String value) {
 *              return value;
 *          }
 *      });
 *      xsiTypeMap.put("integer", new XMLXsiTypeConverter() {
 *          @Override public Integer convert(final String value) {
 *              return Integer.valueOf(value);
 *          }
 *      });
 * }
 * 
* @author kumar529 * @param return type of convert method */ public interface XMLXsiTypeConverter { /** * Converts an XML xsi:type attribute value to the specified type {@code T}. * * @param value The string representation of the XML xsi:type attribute value to be converted. * @return An object of type {@code T} representing the converted value. */ T convert(String value); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy