templates.stub.ksoap.schema.bean.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)
#set( $className ="#getKname($sourceinfo.baseClass)")
#set( $copyMethodName="copy${className}")
$codewriter.setCurrentJavaFilename("$pkg", "${className}.java")
package $pkg;
#outputImports()
import org.ksoap2.serialization.KvmSerializable;
import org.ksoap2.serialization.PropertyInfo;
import java.util.Hashtable;
/**
*
* {@link #typeName($sourceinfo.baseClass)}的序列化反序列化实现
* $GENERAED_BY
* @author guyadong
*
*/
public class ${className} extends #typeName($sourceinfo.baseClass) implements KvmSerializable,$I_CONSTANT{
private static final long serialVersionUID = 1L;
public $className() {
}
#if($TOOL.isException($sourceinfo.baseClass))
public $className(String message,$className detail) {
#if($TOOL.hasMessageConstructor($sourceinfo.baseClass))
super(message);
#end
$copyMethodName(detail);
}
#end
public $className(#typeName($sourceinfo.baseClass) bean) {
$copyMethodName(bean);
}
private final $className $copyMethodName(#typeName($sourceinfo.baseClass) bean) {
#if($$fieldElements.size()>0)
if(null!=bean){
#foreach($property in $rwProperties.values())
this.${property.writeMethod.name}(bean.${property.readMethod.name}());
#end
}
#end ###if($$fieldElements.size()>0)
return this;
}
#if($$fieldElements.size()>0)
private static final PropertyInfo[] propertyInfo=new PropertyInfo[$fieldElements.size()];
static{
#foreach($element in $fieldElements)
#set($count=$velocityCount - 1)
#set ($type=${readableProperties[$element.name].readMethod.returnType})
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=${TOOL.toObjectType($type).simpleName}.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 = propertyInfo[$count].namespace;
propertyInfo[$count].elementType.type=#getKname($componentType).class;
#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="$element.name";
propertyInfo[$count].elementType.namespace = propertyInfo[$count].namespace;
propertyInfo[$count].elementType.type=#getKname($clazzArray[1]).class;
#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 ($property=$readableProperties[$element.name])
#set ($type=$property.readMethod.returnType)
#if($typeTable.getSimpleSchemaTypeName($type.name))
case $count:return ${property.readMethod.name}();
#elseif($typeTable.getComplexSchemaType($type.name))
case $count:#typeName($type) v$count=${property.readMethod.name}();return (v$count instanceof #getKname($type))?v$count:(v$count==null?null:new #getKname($type)(v$count));
#elseif($TOOL.isArrayOfbyte($type))
case $count:return ${property.readMethod.name}();
#elseif($type.array)
case $count:return ${C_UTILITS}.toVector((Object[])${property.readMethod.name}(),#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)${property.readMethod.name}(),#typeName($classArray[1]).class,#getKname($type.componentType).class);
#else
//不支持复杂集合类型 $genericType
#end
#else
case $count:return ${property.readMethod.name}();
#end
#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)
#if(${rwProperties[$element.name]})
#set ($property =${rwProperties[$element.name]})
#set ($type=$property.readMethod.returnType)
#if($typeTable.getSimpleSchemaTypeName($type.name))
case $count: ${property.writeMethod.name}((#typeName(${TOOL.toObjectType($type)}))value);return;
#elseif($typeTable.getComplexSchemaType($type.name))
case $count: ${property.writeMethod.name}((#typeName($type))value);return;
#elseif($TOOL.isArrayOfbyte($type))
case $count: ${property.writeMethod.name}((byte[])value);return;
#elseif($type.array)
case $count: ${property.writeMethod.name}(${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: ${property.writeMethod.name}((#typeName($type)<#typeName($clazzArray[1])>)${C_UTILITS}.fromVector((java.util.Vector>)value,#typeName($type).class));return;
#else
//不支持复杂集合类型 $genericType
#end
#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