1 package org.codehaus.xfire.service.object; 2 3 import javax.xml.namespace.QName; 4 5 import org.codehaus.xfire.MessageContext; 6 import org.codehaus.xfire.fault.XFireFault; 7 import org.codehaus.xfire.message.MessageReader; 8 import org.codehaus.xfire.message.MessageWriter; 9 import org.codehaus.xfire.type.Type; 10 11 /*** 12 * A parameter for an operation. 13 * 14 * @author <a href="mailto:dan@envoisolutions.com">Dan Diephouse</a> 15 * @since Nov 16, 2004 16 */ 17 public class Parameter 18 { 19 private QName name; 20 private Class typeClass; 21 22 public Parameter() 23 { 24 } 25 26 public Parameter(QName name, Class typeClass) 27 { 28 this.name = name; 29 this.typeClass = typeClass; 30 } 31 32 /*** 33 * @return Returns the name. 34 */ 35 public QName getName() 36 { 37 return name; 38 } 39 40 /*** 41 * @param name The name to set. 42 */ 43 public void setName(QName name) 44 { 45 this.name = name; 46 } 47 48 public Class getTypeClass() 49 { 50 return typeClass; 51 } 52 53 public void setTypeClass(Class typeClass) 54 { 55 this.typeClass = typeClass; 56 } 57 58 public Object read(MessageReader reader, MessageContext context) 59 throws XFireFault 60 { 61 Type type = ((ObjectService)context.getService()).getTypeMapping().getType(getTypeClass()); 62 63 return type.readObject(reader, context); 64 } 65 66 public void write(Object value, MessageWriter writer, MessageContext context) 67 throws XFireFault 68 { 69 Type type = ((ObjectService)context.getService()).getTypeMapping().getType(getTypeClass()); 70 71 MessageWriter childWriter = writer.getChildWriter(getName()); 72 73 type.writeObject(value, childWriter, context); 74 75 writer.close(); 76 } 77 }