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

TransportHelperFilterTransparent

public class TransportHelperFilterTransparent extends Object implements TransportHelperFilter

Fields Summary
private TransportHelper
transport
private boolean
is_plain
private ByteBuffer
read_insert
Constructors Summary
public TransportHelperFilterTransparent(TransportHelper _transport, boolean _is_plain)

		transport	= _transport;
		is_plain	= _is_plain;
	
Methods Summary
public TransportHelpergetHelper()

		return( transport );
	
public java.lang.StringgetName()

		return((is_plain?"Plain":"None") + getHelper().getName());
	
public booleanhasBufferedRead()

		return( read_insert != null && read_insert.remaining() > 0 );
	
public booleanhasBufferedWrite()

		return( transport.hasDelayedWrite());
	
protected voidinsertRead(java.nio.ByteBuffer _read_insert)

		read_insert	= _read_insert;
	
public booleanisEncrypted()

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

		int	len = 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;
					}
				}
			}
			
			len	= read_insert.position() - pos_before;
			
			if ( read_insert.hasRemaining()){
				
				return( len );
				
			}else{
				
				read_insert	= null;
			}
		}
		
		return( len + transport.read( buffers, array_offset, length ));
	
public intread(java.nio.ByteBuffer buffer)


		if ( read_insert != null ){
			
			return((int)read( new ByteBuffer[]{ buffer }, 0, 1 ));
		}
		
		return( transport.read( buffer ));
	
public voidsetTrace(boolean on)

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

		return( transport.write( buffers, array_offset, length ));
	
public intwrite(java.nio.ByteBuffer buffer, boolean partial_write)

		return( transport.write( buffer, partial_write ));