1 34 35 36 package com.micronova.util.codec; 37 38 import java.util.*; 39 import com.micronova.util.*; 40 import org.w3c.dom.*; 41 import javax.xml.parsers.*; 42 import org.xml.sax.*; 43 import java.io.*; 44 import java.net.*; 45 import javax.xml.transform.*; 46 import javax.xml.transform.dom.*; 47 import javax.xml.transform.sax.*; 48 import javax.xml.transform.stream.*; 49 50 51 52 public class CodecXMLMap extends Codec 53 { 54 55 56 public static final Object encode(Object object, Object control) throws Exception 57 { 58 if (object != null) 59 { 60 object = XMLMap.encode(object, new NestedMap(control)); 61 } 62 63 return object; 64 } 65 66 67 68 public static final Object encode(Object object) throws Exception 69 { 70 if (object != null) 71 { 72 object = XMLMap.encode(object, null); 73 } 74 75 return object; 76 } 77 78 79 80 public static final Object decode(Object object) throws Exception 81 { 82 return decode(object, null); 83 } 84 85 86 87 public static final Object decode(Object object, Object control) throws Exception 88 { 89 if (object != null) 90 { 91 NestedMap controlMap = TypeUtil.isNestedMap(control); 92 93 if (!(object instanceof Node)) 94 { 95 object = XMLUtil.parse(object, controlMap); 96 } 97 98 object = XMLMap.decode((Node)object, controlMap); 99 } 100 101 return object; 102 } 103 } 104 105 | Popular Tags |