FileDocCategorySizeDatePackage
AZHave.javaAPI DocAzureus 3.0.3.43412Mon Jun 25 16:48:32 BST 2007com.aelitis.azureus.core.peermanager.messaging.azureus

AZHave

public class AZHave extends Object implements AZMessage

Fields Summary
private final byte
version
private org.gudy.azureus2.core3.util.DirectByteBuffer
buffer
private int[]
piece_numbers
Constructors Summary
public AZHave(int[] _piece_numbers, byte _version)

	
	 
	
			
			 
	
		piece_numbers	= _piece_numbers;
		version			= _version;
	
Methods Summary
public com.aelitis.azureus.core.peermanager.messaging.Messagedeserialize(org.gudy.azureus2.core3.util.DirectByteBuffer data, byte version)

		Map payload = MessagingUtil.convertBencodedByteStreamToPayload( data, 1, getID() );
					
		List	l	= (List)payload.get( "pieces");

		int[]	pieces = new int[l.size()];
		
		for (int i=0;i<pieces.length;i++){
			
			pieces[i] = ((Long)l.get(i)).intValue();
		}
		
		AZHave message =  new AZHave( pieces, version );
				
		return( message );
	
public voiddestroy()

	
		if ( buffer != null ){
			
			buffer.returnToPool();
		}
	
public org.gudy.azureus2.core3.util.DirectByteBuffer[]getData()

		if ( buffer == null ){
			
			Map	map = new HashMap();
			
			List l = new ArrayList( piece_numbers.length );
			
			for (int i=0;i<piece_numbers.length;i++){
			
				l.add( new Long( piece_numbers[i] ));
			}
			
			map.put( "pieces", l );
			
			buffer = MessagingUtil.convertPayloadToBencodedByteStream( map, DirectByteBuffer.AL_MSG );
		} 
		
		return new DirectByteBuffer[]{ buffer };
	
public java.lang.StringgetDescription()

   
		StringBuffer	str = new StringBuffer(piece_numbers.length*10);
		
		for (int i=0;i<piece_numbers.length;i++){
		
			if ( i > 0 ){
				str.append(",");
			}
			
			str.append( piece_numbers[i] );
		}
		
		return( getID() + " " + str );
	
public java.lang.StringgetFeatureID()

		return( AZMessage.AZ_FEATURE_ID );
	
public intgetFeatureSubID()

		return( AZMessage.SUBID_ID_AZ_HAVE );		
	
public java.lang.StringgetID()

		return( AZMessage.ID_AZ_HAVE );
	
public byte[]getIDBytes()

		return( AZMessage.ID_AZ_HAVE_BYTES );		
	
public int[]getPieceNumbers()

		return( piece_numbers );
	
public intgetType()

		return( Message.TYPE_PROTOCOL_PAYLOAD );
	
public bytegetVersion()

 return version;