templates.includes.ksoap.message.vm Maven / Gradle / Ivy
#parse("${include}/generic.include.vm")
#parse("${include}/webclient.ksoap.include.vm")
#set( $rwProperties = $sourceinfo.rwProperties)
#set( $readableProperties = $sourceinfo.readableProperties)
#set( $fieldElements= $sourceinfo.fieldElements)
#set( $schemaObj= $sourceinfo.schemaObj)
#if($sourceinfo.request)
#set( $objectForPort=$sourceinfo.objectForPort)
#elseif($sourceinfo.response)
#set( $objectForPort=[$sourceinfo.objectForPort])
#elseif($sourceinfo.fault)
#set( $objectForPort=[$webServiceInfo.QNameToClassMap[$fieldElements[0].schemaTypeName]])
#elseif($sourceinfo.other)
#set($typename=$fieldElements[0].schemaTypeName)
#if($TOOL.isBase64Binary($typename))
#set( $objectForPort=[ $TOOL.getArrayOfByteClass()])
#elseif($typeTable.getComplexSchemaType($typename))
#set( $objectForPort=[$webServiceInfo.QNameToClassMap[$typename]])
#else
//不支持的数据类型
#end
#end
#set ( $className ="$TOOL.toClassName($schemaObj.name)")
$codewriter.setCurrentJavaFilename("$pkg", "${className}.java")
package $pkg;
#outputImports()
import org.ksoap2.serialization.KvmSerializable;
import org.ksoap2.serialization.PropertyInfo;
import java.util.Hashtable;
/**
#if($sourceinfo.request)
* $sourceinfo.operation.name.localPart 端口(port)请求对象实现
* @see ${webServiceInfo.ports[${sourceinfo.operation.name.localPart}].getDocSignature($imports)}
#elseif($sourceinfo.response)
* $sourceinfo.operation.name.localPart 端口(port)返回对象实现
* $GENERAED_BY
* @see ${webServiceInfo.ports[${sourceinfo.operation.name.localPart}].getDocSignature($imports)}
#elseif($sourceinfo.fault)
* $schemaObj.name 异常消息实现
* @see #typeName($objectForPort[0])
*
#elseif($sourceinfo.other)
#end
*
* @author guyadong
*
*/
public class ${className} implements KvmSerializable,$I_CONSTANT{
#macro(tnp $count)#set($c=$count - 1)#typeDefine($objectForPort[$c]) $e.name#end
public $className(){}
#if($sourceinfo.request)
public $className setParameters(#join($fieldElements '#tnp($velocityCount)' ',')) {
#foreach($element in $fieldElements)
#set($count=$velocityCount - 1)
parameters[$count]= $element.name;
#end
return this;
}
#end###if($sourceinfo.request)
#if($fieldElements.size()>0)
private final Object[] parameters=new Object[$fieldElements.size()];
#if($sourceinfo.response)
public #typeName($objectForPort[0]) get_return(){
return (#typeName(${TOOL.toObjectType($objectForPort[0])}))parameters[0];
}
#elseif($sourceinfo.request)
public $className(#join($fieldElements '#tnp($velocityCount)' ',')) {
setParameters(#join($fieldElements '$e.name' ','));
}
#elseif($sourceinfo.fault)
public #typeName($objectForPort[0]) getFault(){
return (#typeName($objectForPort[0]))parameters[0];
}
#end###if($sourceinfo.response)
private static final PropertyInfo[] propertyInfo=new PropertyInfo[$fieldElements.size()];
static{
#foreach($element in $fieldElements)
#set($count=$velocityCount - 1)
#set ($type=$objectForPort[ $count ])
#if($parentSchema.complexTypeOthers.containsKey($element.schemaTypeName))
#set ($otherType=$element.schemaTypeName)
#else
#set ($otherType=false)
#end
propertyInfo[$count]=new PropertyInfo();
propertyInfo[$count].name = "$element.name";
propertyInfo[$count].namespace = $I_NS.$webServiceInfo.getPrefix($schemaObj.QName);
#if($typeTable.getSimpleSchemaTypeName($type.name))
propertyInfo[$count].type=#typeName(${TOOL.toObjectType($type)}).class;
#elseif($typeTable.getComplexSchemaType($type.name))
propertyInfo[$count].type=#getKname($type).class;
#elseif($TOOL.isArrayOfbyte($type))
propertyInfo[$count].type=byte[].class;
#elseif($type.array)
#set($componentType=$type.componentType)
propertyInfo[$count].type=java.util.Vector.class;
propertyInfo[$count].elementType=new PropertyInfo();
propertyInfo[$count].elementType.name=propertyInfo[$count].name;
propertyInfo[$count].elementType.namespace = #if($otherType)$I_NS.$webServiceInfo.getPrefix($otherType)#{else}propertyInfo[$count].namespace#end;
propertyInfo[$count].elementType.type=#if($otherType)${otherType.localPart}.class#else#getKname(${TOOL.toObjectType($componentType)}).class#end;
#elseif($TOOL.isCollection($type))
#set($genericType=$readableProperties[$element.name].readMethod.genericReturnType.toString())
#set($classArray=$TOOL.getAllClassForGenericType(genericType))
#if($classArray.size()==2)
propertyInfo[$count].type=java.util.Vector.class;
propertyInfo[$count].elementType=new PropertyInfo();
propertyInfo[$count].elementType.name=propertyInfo[$count].name;
propertyInfo[$count].elementType.namespace = #if($otherType)$I_NS.$webServiceInfo.getPrefix($otherType)#{else}propertyInfo[$count].namespace#end;
propertyInfo[$count].elementType.type=#if($otherType)${otherType.localPart}.class#else#getKname($clazzArray[1]).class#end;
#else
//不支持复杂集合类型 $genericType
#end
#else
//不支持的数据类型 $type.name
#end
#end
}
#end###if($$fieldElements.size()>0)
@Override
public Object getProperty(int propertyIndex) {
#if($$fieldElements.size()>0)
switch(propertyIndex){
#foreach( $element in $fieldElements )
#set ($count=$velocityCount - 1)
#set ($type=$objectForPort[ $count ])
#if($typeTable.getSimpleSchemaTypeName($type.name))
case $count:return parameters[$count];
#elseif($typeTable.getComplexSchemaType($type.name))
case $count:return (parameters[$count] instanceof #getKname($type))?parameters[$count]:(parameters[$count]==null?null:new #getKname($type)((#typeName($type))parameters[$count]));
#elseif($TOOL.isArrayOfbyte($type))
case $count:return parameters[$count];
#elseif($type.array)
case $count:return ${C_UTILITS}.toVector((Object[])parameters[$count],#typeName($type.componentType).class,#getKname($type.componentType).class);
#elseif($TOOL.isCollection($type))
#set($genericType=$property.readMethod.genericReturnType.toString())
#set($classArray=$TOOL.getAllClassForGenericType(genericType))
#if($classArray.size()==2)
case $count:return ${C_UTILITS}.toVector((Collection)parameters[$count],#typeName($clazzArray[1]).class,#getKname($type.componentType).class);
#else
//不支持复杂集合类型 $genericType
#end###if($classArray.size()==2)
#else
case $count:return parameters[$count];
#end###if($typeTable.getSimpleSchemaTypeName($type.name))
#end
default:return null;
}
#else
return null;
#end
}
@Override
public int getPropertyCount() {
return $fieldElements.size();
}
@Override
public void getPropertyInfo(int propertyIndex, #[[@SuppressWarnings("rawtypes")]]#Hashtable hashTable, PropertyInfo info) {
#if($$fieldElements.size()>0)
if(propertyIndex=0){
info.name =propertyInfo[propertyIndex].name;
info.namespace =propertyInfo[propertyIndex].namespace;
info.type =propertyInfo[propertyIndex].type;
info.elementType=propertyInfo[propertyIndex].elementType;
}
#end###if($$fieldElements.size()>0)
}
@Override
public void setProperty(int propertyIndex, Object value) {
#if($fieldElements.size()>0)
switch(propertyIndex){
#foreach( $element in $fieldElements )
#set($count=$velocityCount - 1)
#set ($type=$objectForPort[ $count ])
#if($typeTable.getSimpleSchemaTypeName($type.name))
case $count: parameters[$count]=value;return;
#elseif($typeTable.getComplexSchemaType($type.name))
case $count: parameters[$count]=value;return;
#elseif($TOOL.isArrayOfbyte($type))
case $count: parameters[$count]=value;return;
#elseif($type.array||$TOOL.isCollection($type))
case $count: parameters[$count]=${C_UTILITS}.fromVector((java.util.Vector>)value,#typeName($type).class);return;
#elseif($TOOL.isCollection($type))
#set($genericType=$property.readMethod.genericReturnType.toString())
#set($classArray=$TOOL.getAllClassForGenericType(genericType))
#if($classArray.size()==2)
case $count: parameters[$count]=${C_UTILITS}.fromVector((java.util.Vector>)value,#typeName($type).class);return;
#else
//不支持复杂集合类型 $genericType
#end
#end
#end
default:return;
}
#end###if($$fieldElements.size()>0)
}
public void setInnerText(String arg0) {
}
public String getInnerText() {
return null;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy