FileDocCategorySizeDatePackage
TransportHelperFilterInserter.javaAPI DocAzureus 3.0.3.43190Mon Mar 05 14:57:18 GMT 2007com.aelitis.azureus.core.networkmanager.impl

TransportHelperFilterInserter

public class TransportHelperFilterInserter extends Object implements TransportHelperFilter

Fields Summary
private TransportHelperFilter
target_filter
private ByteBuffer
read_insert
Constructors Summary
public TransportHelperFilterInserter(TransportHelperFilter _target_filter, ByteBuffer _read_insert)

		target_filter	= _target_filter;

		read_insert		= _read_insert;
	
Methods Summary
public TransportHelpergetHelper()

		return( target_filter.getHelper());
	
public java.lang.StringgetName()

		return( target_filter.getName());
	
public booleanhasBufferedRead()

		return( read_insert != null || target_filter.hasBufferedRead());
	
public booleanhasBufferedWrite()

		return( target_filter.hasBufferedWrite());
	
public booleanisEncrypted()

		return( target_filter.isEncrypted());
	
public longread(java.nio.ByteBuffer[] buffers, int array_offset, int length)

		long	total_read	= 0;
				
		if ( read_insert != null ){
		
			int	pos_before	= read_insert.position();
			
			for (int i=array_offset;i<array_offset+length;i++){
				
				ByteBuffer	buffer = buffers[i];
				
				int	space = buffer.remaining();
				
				if ( space > 0 ){
					
					if ( space < read_insert.remaining()){
						
						int	old_limit = read_insert.limit();
						
						read_insert.limit( read_insert.position() + space );
						
						buffer.put( read_insert );

						read_insert.limit( old_limit );
						
					}else{
						
						buffer.put( read_insert );
					}
					
					if ( !read_insert.hasRemaining()){
											
						break;
					}
				}
			}
			
			total_read	= read_insert.position() - pos_before;
			
			if ( read_insert.hasRemaining()){
				
				return( total_read );
				
			}else{
				
				read_insert	= null;
			}
		}
		
		total_read += target_filter.read( buffers, array_offset, length );
		
		return( total_read );		
	
public voidsetTrace(boolean on)

		target_filter.setTrace( on );
	
public longwrite(java.nio.ByteBuffer[] buffers, int array_offset, int length)

		return( target_filter.write( buffers, array_offset, length ));