1 16 17 package org.apache.axis.encoding.ser; 18 19 import org.apache.axis.components.logger.LogFactory; 20 import org.apache.axis.encoding.DeserializationContext; 21 import org.apache.axis.encoding.Deserializer; 22 import org.apache.axis.encoding.DeserializerImpl; 23 import org.apache.axis.encoding.DeserializerTarget; 24 import org.apache.axis.message.SOAPHandler; 25 import org.apache.axis.utils.Messages; 26 import org.apache.commons.logging.Log; 27 import org.xml.sax.Attributes ; 28 import org.xml.sax.SAXException ; 29 30 import javax.xml.namespace.QName ; 31 import java.util.Vector ; 32 33 39 public class VectorDeserializer extends DeserializerImpl 40 { 41 protected static Log log = 42 LogFactory.getLog(VectorDeserializer.class.getName()); 43 44 public int curIndex = 0; 45 46 57 public void onStartElement(String namespace, String localName, 58 String prefix, Attributes attributes, 59 DeserializationContext context) 60 throws SAXException { 61 if (log.isDebugEnabled()) { 62 log.debug("Enter: VectorDeserializer::startElement()"); 63 } 64 65 if (context.isNil(attributes)) { 66 return; 67 } 68 69 setValue(new java.util.Vector ()); 71 72 if (log.isDebugEnabled()) { 73 log.debug("Exit: VectorDeserializer::startElement()"); 74 } 75 } 76 77 89 public SOAPHandler onStartChild(String namespace, 90 String localName, 91 String prefix, 92 Attributes attributes, 93 DeserializationContext context) 94 throws SAXException { 95 if (log.isDebugEnabled()) { 96 log.debug("Enter: VectorDeserializer::onStartChild()"); 97 } 98 99 if (attributes == null) 100 throw new SAXException (Messages.getMessage("noType01")); 101 102 if (context.isNil(attributes)) { 105 setChildValue(null, new Integer (curIndex++)); 106 return null; 107 } 108 109 QName itemType = context.getTypeFromAttributes(namespace, 111 localName, 112 attributes); 113 Deserializer dSer = null; 115 if (itemType != null) { 116 dSer = context.getDeserializerForType(itemType); 117 } 118 if (dSer == null) { 119 dSer = new DeserializerImpl(); 120 } 121 122 dSer.registerValueTarget(new DeserializerTarget(this, new Integer (curIndex))); 126 curIndex++; 127 128 if (log.isDebugEnabled()) { 129 log.debug("Exit: VectorDeserializer::onStartChild()"); 130 } 131 132 addChildDeserializer(dSer); 135 136 return (SOAPHandler)dSer; 137 } 138 139 145 public void setChildValue(Object value, Object hint) throws SAXException 146 { 147 if (log.isDebugEnabled()) { 148 log.debug(Messages.getMessage("gotValue00", "VectorDeserializer", "" + value)); 149 } 150 int offset = ((Integer )hint).intValue(); 151 Vector v = (Vector )this.value; 152 153 if (offset >= v.size()) { 155 v.setSize(offset+1); 156 } 157 v.setElementAt(value, offset); 158 } 159 } 160 | Popular Tags |