1 55 56 package org.jboss.axis.encoding.ser; 57 58 import org.jboss.axis.encoding.DeserializationContext; 59 import org.jboss.axis.encoding.Deserializer; 60 import org.jboss.axis.encoding.DeserializerImpl; 61 import org.jboss.axis.encoding.DeserializerTarget; 62 import org.jboss.axis.message.SOAPHandler; 63 import org.jboss.axis.utils.Messages; 64 import org.jboss.logging.Logger; 65 import org.xml.sax.Attributes ; 66 import org.xml.sax.SAXException ; 67 68 import javax.xml.namespace.QName ; 69 import java.util.Vector ; 70 71 77 public class VectorDeserializer extends DeserializerImpl 78 { 79 private static Logger log = Logger.getLogger(VectorDeserializer.class.getName()); 80 81 public int curIndex = 0; 82 83 95 public void onStartElement(String namespace, String localName, 96 String prefix, Attributes attributes, 97 DeserializationContext context) 98 throws SAXException 99 { 100 if (log.isDebugEnabled()) 101 { 102 log.debug("Enter: VectorDeserializer::startElement()"); 103 } 104 105 if (context.isNil(attributes)) 106 { 107 return; 108 } 109 110 setValue(new java.util.Vector ()); 112 113 if (log.isDebugEnabled()) 114 { 115 log.debug("Exit: VectorDeserializer::startElement()"); 116 } 117 } 118 119 131 public SOAPHandler onStartChild(String namespace, 132 String localName, 133 String prefix, 134 Attributes attributes, 135 DeserializationContext context) 136 throws SAXException 137 { 138 if (log.isDebugEnabled()) 139 { 140 log.debug("Enter: VectorDeserializer::onStartChild()"); 141 } 142 143 if (attributes == null) 144 throw new SAXException (Messages.getMessage("noType01")); 145 146 if (context.isNil(attributes)) 149 { 150 setChildValue(null, new Integer (curIndex++)); 151 return null; 152 } 153 154 QName itemType = context.getTypeFromAttributes(namespace, 156 localName, 157 attributes); 158 Deserializer dSer = null; 160 if (itemType != null) 161 { 162 dSer = context.getDeserializerForType(itemType); 163 } 164 if (dSer == null) 165 { 166 dSer = new DeserializerImpl(); 167 } 168 169 dSer.registerValueTarget(new DeserializerTarget(this, new Integer (curIndex))); 173 curIndex++; 174 175 if (log.isDebugEnabled()) 176 { 177 log.debug("Exit: VectorDeserializer::onStartChild()"); 178 } 179 180 addChildDeserializer(dSer); 183 184 return (SOAPHandler)dSer; 185 } 186 187 194 public void setChildValue(Object value, Object hint) throws SAXException 195 { 196 if (log.isDebugEnabled()) 197 { 198 log.debug(Messages.getMessage("gotValue00", "VectorDeserializer", "" + value)); 199 } 200 int offset = ((Integer )hint).intValue(); 201 Vector v = (Vector )this.value; 202 203 if (offset >= v.size()) 205 { 206 v.setSize(offset + 1); 207 } 208 v.setElementAt(value, offset); 209 } 210 } 211 | Popular Tags |