FileDocCategorySizeDatePackage
DHTDBValueImpl.javaAPI DocAzureus 3.0.3.44555Fri Mar 17 09:34:16 GMT 2006com.aelitis.azureus.core.dht.db.impl

DHTDBValueImpl

public class DHTDBValueImpl extends Object implements com.aelitis.azureus.core.dht.db.DHTDBValue
author
parg

Fields Summary
private long
creation_time
private byte[]
value
private com.aelitis.azureus.core.dht.transport.DHTTransportContact
originator
private com.aelitis.azureus.core.dht.transport.DHTTransportContact
sender
private boolean
local
private int
flags
private int
version
private long
store_time
Constructors Summary
protected DHTDBValueImpl(long _creation_time, byte[] _value, int _version, com.aelitis.azureus.core.dht.transport.DHTTransportContact _originator, com.aelitis.azureus.core.dht.transport.DHTTransportContact _sender, boolean _local, int _flags)
constructor for the originator of values only

param
_creation_time
param
_value
param
_originator
param
_sender
param
_distance
param
_flags

		creation_time	= _creation_time;
		value			= _value;
		version			= _version;
		originator		= _originator;
		sender			= _sender;
		local			= _local;
		flags			= _flags;
		
		reset();
	
protected DHTDBValueImpl(com.aelitis.azureus.core.dht.transport.DHTTransportContact _sender, com.aelitis.azureus.core.dht.transport.DHTTransportValue _other, boolean _local)
Constructor used to generate values for relaying to other contacts or receiving a value from another contact - adjusts the sender Originator, creation time, flags and value are fixed.

param
_sender
param
_other

		this( 	_other.getCreationTime(), 
				_other.getValue(),
				_other.getVersion(),
				_other.getOriginator(),
				_sender,
				_local,
				_other.getFlags());
	
Methods Summary
public longgetCreationTime()

		return( creation_time );
	
public intgetFlags()

		return( flags );
	
public com.aelitis.azureus.core.dht.transport.DHTTransportContactgetOriginator()

		return( originator);
	
public com.aelitis.azureus.core.dht.transport.DHTTransportContactgetSender()

		return( sender );
	
protected longgetStoreTime()

		return( store_time );
	
public java.lang.StringgetString()

		long	now = SystemTime.getCurrentTime();
		
		return( DHTLog.getString( value ) + " - " + new String(value) + "{v=" + version + ",f=" + 
				Integer.toHexString(flags) +",ca=" + (now - creation_time ) + ",sa=" + (now-store_time)+
				",se=" + sender.getString() + ",or=" + originator.getString() +"}" );
	
public byte[]getValue()

		return( value );
	
public com.aelitis.azureus.core.dht.db.DHTDBValuegetValueForDeletion(int _version)

		DHTDBValueImpl	res = new DHTDBValueImpl( originator, this, local );
		
		res.value = new byte[0];	// delete -> 0 length value
		
		res.setCreationTime();
		
		res.version = _version;
		
		return( res );
	
public com.aelitis.azureus.core.dht.db.DHTDBValuegetValueForRelay(com.aelitis.azureus.core.dht.transport.DHTTransportContact _sender)

		return( new DHTDBValueImpl( _sender, this, local ));
	
public intgetVersion()

		return( version );
	
public booleanisLocal()

		return( local );
	
protected voidreset()

		store_time	= SystemTime.getCurrentTime();
		
			// make sure someone hasn't sent us a stupid creation time
		
		if ( creation_time > store_time ){
			
			creation_time	= store_time;
		}	
	
protected voidsetCreationTime()

		creation_time = SystemTime.getCurrentTime();
	
public voidsetFlags(byte _flags)

		flags = _flags;
	
protected voidsetOriginatorAndSender(com.aelitis.azureus.core.dht.transport.DHTTransportContact _originator)

		originator	= _originator;
		sender		= _originator;
	
protected voidsetStoreTime(long l)

		store_time	= l;