1 16 17 package org.apache.axis.message; 18 19 import javax.xml.soap.MimeHeader ; 20 import java.io.IOException ; 21 import java.io.ObjectInput ; 22 import java.io.ObjectOutput ; 23 import java.util.Iterator ; 24 25 28 public class MimeHeaders extends javax.xml.soap.MimeHeaders 29 implements java.io.Externalizable { 30 public MimeHeaders() { 31 } 32 33 public MimeHeaders(javax.xml.soap.MimeHeaders h) { 34 Iterator iterator = h.getAllHeaders(); 35 while (iterator.hasNext()) { 36 MimeHeader hdr = (MimeHeader ) iterator.next(); 37 addHeader(hdr.getName(), hdr.getValue()); 38 } 39 } 40 41 public void readExternal(ObjectInput in) throws IOException , ClassNotFoundException { 42 int size = in.readInt(); 43 for (int i = 0; i < size; i++) { 44 Object key = in.readObject(); 45 Object value = in.readObject(); 46 addHeader((String )key, (String )value); 47 } 48 } 49 50 public void writeExternal(ObjectOutput out) throws IOException { 51 out.writeInt(getHeaderSize()); 52 Iterator iterator = getAllHeaders(); 53 while (iterator.hasNext()) { 54 MimeHeader hdr = (MimeHeader ) iterator.next(); 55 out.writeObject(hdr.getName()); 56 out.writeObject(hdr.getValue()); 57 } 58 } 59 60 private int getHeaderSize() { 61 int size = 0; 62 Iterator iterator = getAllHeaders(); 63 while (iterator.hasNext()) { 64 iterator.next(); 65 size++; 66 } 67 return size; 68 } 69 } 70 | Popular Tags |