| #macro( UpperCamel $name ) | |
| #set( $name = "${name.substring(0,1).toUpperCase()}${name.substring(1)}" ) | |
| #end | |
| #macro( toUpperCamel $name )${name.substring(0,1).toUpperCase()}${name.substring(1)}#end | |
| #set( $amqp_ClassName = $amqpClass.Name) | |
| #UpperCamel( $amqp_ClassName ) | |
| #set( $amqp_MethodName = $amqpMethod.Name ) | |
| #UpperCamel( $amqp_MethodName ) | |
| #set( $javaClassName = "${amqp_ClassName}${amqp_MethodName}BodyImpl" ) | |
| #set( $interfaceName = "${amqp_ClassName}${amqp_MethodName}Body" ) | |
| #set( $amqpPackageName = "amqp_$version.getMajor()_$version.getMinor()" ) | |
| #set( $filename = "${amqpPackageName}/${javaClassName}.java") | |
| /* | |
| * | |
| * Licensed to the Apache Software Foundation (ASF) under one | |
| * or more contributor license agreements. See the NOTICE file | |
| * distributed with this work for additional information | |
| * regarding copyright ownership. The ASF licenses this file | |
| * to you under the Apache License, Version 2.0 (the | |
| * "License"); you may not use this file except in compliance | |
| * with the License. You may obtain a copy of the License at | |
| * | |
| * http://www.apache.org/licenses/LICENSE-2.0 | |
| * | |
| * Unless required by applicable law or agreed to in writing, | |
| * software distributed under the License is distributed on an | |
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
| * KIND, either express or implied. See the License for the | |
| * specific language governing permissions and limitations | |
| * under the License. | |
| * | |
| */ | |
| /* | |
| * This file is auto-generated by ${generator} - do not modify. | |
| * Supported AMQP version: | |
| * $version.getMajor()-$version.getMinor() | |
| */ | |
| #set( $clazz = $amqpClass.asSingleVersionClass( $version ) ) | |
| #set( $method = $amqpMethod.asSingleVersionMethod( $version ) ) | |
| package org.apache.qpid.framing.amqp_$version.getMajor()_$version.getMinor(); | |
| import java.util.HashMap; | |
| import org.apache.mina.common.ByteBuffer; | |
| import org.apache.qpid.framing.*; | |
| import org.apache.qpid.AMQException; | |
| public class ${javaClassName} extends AMQMethodBody_$version.getMajor()_$version.getMinor() implements $interfaceName | |
| { | |
| private static final AMQMethodBodyInstanceFactory FACTORY_INSTANCE = new AMQMethodBodyInstanceFactory() | |
| { | |
| public AMQMethodBody newInstance(ByteBuffer in, long size) throws AMQFrameDecodingException | |
| { | |
| return new ${javaClassName}(in); | |
| } | |
| }; | |
| public static AMQMethodBodyInstanceFactory getFactory() | |
| { | |
| return FACTORY_INSTANCE; | |
| } | |
| public static int CLASS_ID = $clazz.ClassId; | |
| public static int METHOD_ID = $method.MethodId; | |
| // Fields declared in specification | |
| #foreach( $field in $method.ConsolidatedFields ) | |
| private final $field.NativeType _$field.getName(); // $field.UnderlyingFields | |
| #end | |
| // Constructor | |
| public ${javaClassName}(ByteBuffer buffer) throws AMQFrameDecodingException | |
| { | |
| #foreach( $field in $method.ConsolidatedFields ) | |
| _$field.Name = read$field.getEncodingType()( buffer ); | |
| #end | |
| } | |
| public ${javaClassName}( | |
| #foreach( $field in $method.FieldList ) | |
| #if( $velocityCount == $method.getFieldList().size() ) | |
| $field.NativeType $field.Name | |
| #else | |
| $field.NativeType $field.Name, | |
| #end | |
| #end | |
| ) | |
| { | |
| #set( $consolidatedFieldName = "" ) | |
| #foreach( $field in $method.FieldList ) | |
| #if( $method.isConsolidated( $field.Name ) ) | |
| #if( !$method.getConsolidatedFieldName( $field.Name ).equals( $consolidatedFieldName ) ) | |
| #if( !$consolidatedFieldName.equals("") ) | |
| _$consolidatedFieldName = $consolidatedFieldName; // 1 | |
| #end | |
| #set( $consolidatedFieldName = $method.getConsolidatedFieldName( $field.Name ) ) | |
| byte $consolidatedFieldName = (byte)0; | |
| #end | |
| if( $field.Name ) | |
| { | |
| $consolidatedFieldName = (byte) (((int) $consolidatedFieldName) | (1 << $method.getPositionInBitField( $field.Name ))); | |
| } | |
| #if( $velocityCount == $method.getFieldList().size()) | |
| _$consolidatedFieldName = $consolidatedFieldName; | |
| #else | |
| #end | |
| #else | |
| #if( !$consolidatedFieldName.equals("") ) | |
| _$consolidatedFieldName = $consolidatedFieldName; | |
| #end | |
| #set( $consolidatedFieldName = "" ) | |
| _$field.Name = $field.Name; | |
| #end | |
| #end | |
| } | |
| public int getClazz() | |
| { | |
| return CLASS_ID; | |
| } | |
| public int getMethod() | |
| { | |
| return METHOD_ID; | |
| } | |
| #foreach( $field in $method.FieldList ) | |
| public final $field.NativeType get#toUpperCamel( ${field.Name} )() | |
| { | |
| #if( $method.isConsolidated( $field.Name ) ) | |
| return (((int)(_$method.getConsolidatedFieldName( $field.Name ))) & ( 1 << $method.getPositionInBitField( $field.Name ))) != 0; | |
| #else | |
| return _$field.Name; | |
| #end | |
| } | |
| #end | |
| protected int getBodySize() | |
| { | |
| #set( $fixedSize = 0 ) | |
| #foreach( $field in $method.ConsolidatedFields ) | |
| #if( $field.isFixedSize() ) | |
| #set( $fixedSize = $fixedSize + $field.Size ) | |
| #end | |
| #end | |
| int size = $fixedSize; | |
| #foreach( $field in $method.ConsolidatedFields ) | |
| #if( ! $field.isFixedSize() ) | |
| size += getSizeOf( _$field.Name ); | |
| #end | |
| #end | |
| return size; | |
| } | |
| public void writeMethodPayload(ByteBuffer buffer) | |
| { | |
| #foreach( $field in $method.ConsolidatedFields ) | |
| write$field.getEncodingType()( buffer, _$field.Name ); | |
| #end | |
| } | |
| public boolean execute(MethodDispatcher dispatcher, int channelId) throws AMQException | |
| { | |
| #set( $amqpMethodNameFirstChar = $amqpMethod.getName().substring(0,1) ) | |
| #set( $amqpMethodNameFirstCharU = $amqpMethodNameFirstChar.toUpperCase() ) | |
| #set( $amqpMethodNameUpperCamel = "$amqpMethodNameFirstCharU$amqpMethod.getName().substring(1)" ) | |
| #if( $amqpMethod.inAllVersions() ) | |
| return dispatcher.dispatch${amqpClassNameUpperCamel}${amqpMethodNameUpperCamel}(this, channelId); | |
| #else | |
| return ((MethodDispatcher_$version.getMajor()_$version.getMinor())dispatcher).dispatch${amqp_ClassName}${amqpMethodNameUpperCamel}(this, channelId); | |
| #end | |
| } | |
| public String toString() | |
| { | |
| StringBuilder buf = new StringBuilder("[$javaClassName: "); | |
| #foreach( $field in $method.FieldList ) | |
| buf.append( "$field.Name=" ); | |
| buf.append( get#toUpperCamel( $field.Name )() ); | |
| #if( $velocityCount != $method.FieldList.size() ) | |
| buf.append( ", " ); | |
| #end | |
| #end | |
| buf.append("]"); | |
| return buf.toString(); | |
| } | |
| } |