1 package org.apache.soap.encoding.soapenc; 2 3 import java.io.*; 4 import org.w3c.dom.*; 5 import org.apache.soap.util.*; 6 import org.apache.soap.util.xml.*; 7 import org.apache.soap.*; 8 import org.apache.soap.rpc.*; 9 10 17 public class Base64Serializer implements Serializer, Deserializer 18 { 19 public void marshall(String inScopeEncStyle, Class javaType, Object src, 20 Object context, Writer sink, NSStack nsStack, 21 XMLJavaMappingRegistry xjmr, SOAPContext ctx) 22 throws IllegalArgumentException , IOException 23 { 24 nsStack.pushScope(); 25 26 byte[] bytes = (byte[])src; 27 28 if (bytes == null) 29 { 30 SoapEncUtils.generateNullStructure(inScopeEncStyle, 31 javaType, 32 context, 33 sink, 34 nsStack, 35 xjmr); 36 } 37 else 38 { 39 SoapEncUtils.generateStructureHeader(inScopeEncStyle, 40 javaType, 41 context, 42 sink, 43 nsStack, 44 xjmr); 45 46 sink.write(Base64.encode(bytes) + "</" + context + '>'); 47 } 48 49 nsStack.popScope(); 50 } 51 52 public Bean unmarshall(String inScopeEncStyle, QName elementType, Node src, 53 XMLJavaMappingRegistry xjmr, SOAPContext ctx) 54 throws IllegalArgumentException 55 { 56 Element root = (Element)src; 57 String value = DOMUtils.getChildCharacterData(root); 58 59 return new Bean(byte[].class, Base64.decode(value)); 60 } 61 } 62 | Popular Tags |