| 
1 | 1 | package org.json;  | 
 | 2 | +/*  | 
 | 3 | +Copyright (c) 2002 JSON.org  | 
2 | 4 | 
  | 
 | 5 | +Permission is hereby granted, free of charge, to any person obtaining a copy  | 
 | 6 | +of this software and associated documentation files (the "Software"), to deal  | 
 | 7 | +in the Software without restriction, including without limitation the rights  | 
 | 8 | +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell  | 
 | 9 | +copies of the Software, and to permit persons to whom the Software is  | 
 | 10 | +furnished to do so, subject to the following conditions:  | 
 | 11 | +
  | 
 | 12 | +The above copyright notice and this permission notice shall be included in all  | 
 | 13 | +copies or substantial portions of the Software.  | 
 | 14 | +
  | 
 | 15 | +The Software shall be used for Good, not Evil.  | 
 | 16 | +
  | 
 | 17 | +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR  | 
 | 18 | +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,  | 
 | 19 | +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE  | 
 | 20 | +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER  | 
 | 21 | +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,  | 
 | 22 | +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE  | 
 | 23 | +SOFTWARE.  | 
 | 24 | +*/  | 
 | 25 | + | 
 | 26 | +/**  | 
 | 27 | + * Type conversion configuration interface to be used with xsi:type attributes.  | 
 | 28 | + * <pre>  | 
 | 29 | + * <h1>XML Sample</h1>  | 
 | 30 | + * {@code  | 
 | 31 | + *      <root>  | 
 | 32 | + *          <asString xsi:type="string">12345</asString>  | 
 | 33 | + *          <asInt xsi:type="integer">54321</asInt>  | 
 | 34 | + *      </root>  | 
 | 35 | + * }  | 
 | 36 | + * <h1>JSON Output</h1>  | 
 | 37 | + * {@code  | 
 | 38 | + *     {  | 
 | 39 | + *         "root" : {  | 
 | 40 | + *             "asString" : "12345",  | 
 | 41 | + *             "asInt": 54321  | 
 | 42 | + *         }  | 
 | 43 | + *     }  | 
 | 44 | + * }  | 
 | 45 | + *  | 
 | 46 | + * <h1>Usage</h1>  | 
 | 47 | + * {@code  | 
 | 48 | + *      Map<String, XMLXsiTypeConverter<?>> xsiTypeMap = new HashMap<String, XMLXsiTypeConverter<?>>();  | 
 | 49 | + *      xsiTypeMap.put("string", new XMLXsiTypeConverter<String>() {  | 
 | 50 | + *          @Override public String convert(final String value) {  | 
 | 51 | + *              return value;  | 
 | 52 | + *          }  | 
 | 53 | + *      });  | 
 | 54 | + *      xsiTypeMap.put("integer", new XMLXsiTypeConverter<Integer>() {  | 
 | 55 | + *          @Override public Integer convert(final String value) {  | 
 | 56 | + *              return Integer.valueOf(value);  | 
 | 57 | + *          }  | 
 | 58 | + *      });  | 
 | 59 | + * }  | 
 | 60 | + * </pre>  | 
 | 61 | + * @author kumar529  | 
 | 62 | + * @param <T>  | 
 | 63 | + */  | 
3 | 64 | public interface XMLXsiTypeConverter<T> {  | 
4 | 65 |     T convert(String value);  | 
5 | 66 | }  | 
0 commit comments