FileDocCategorySizeDatePackage
PRHelpers.javaAPI DocAzureus 3.0.3.42890Fri Nov 24 11:06:42 GMT 2006org.gudy.azureus2.core3.tracker.protocol

PRHelpers

public class PRHelpers extends Object
author
parg

Fields Summary
Constructors Summary
Methods Summary
public static java.lang.StringDNSToIPAddress(java.lang.String dns_name)

		return( HostNameToIPResolver.syncResolve(dns_name).getHostAddress());
	
public static voidaddressTo4ByteArray(java.lang.String address, byte[] buffer, int offset)

		InetAddress i_address = HostNameToIPResolver.syncResolve(address);
		
		byte[]	bytes = i_address.getAddress();
	
		System.arraycopy( bytes, 0, buffer, offset, 4 );
	
public static intaddressToInt(java.lang.String address)

		InetAddress i_address = HostNameToIPResolver.syncResolve(address);
		
		byte[]	bytes = i_address.getAddress();
		
		int	resp = (bytes[0]<<24)&0xff000000 | (bytes[1] << 16)&0x00ff0000 | (bytes[2] << 8)&0x0000ff00 | bytes[3]&0x000000ff;
	
		// System.out.println( "addressToInt: " + address + " -> " + Integer.toHexString(resp));
		
		return( resp );
	
public static intaddressToInt(java.net.InetAddress i_address)

		byte[]	bytes = i_address.getAddress();
		
		int	resp = (bytes[0]<<24)&0xff000000 | (bytes[1] << 16)&0x00ff0000 | (bytes[2] << 8)&0x0000ff00 | bytes[3]&0x000000ff;
	
		// System.out.println( "addressToInt: " + address + " -> " + Integer.toHexString(resp));
		
		return( resp );
	
public static longaddressToLong(java.net.InetAddress i_address)

		return(((long)addressToInt( i_address ))&0xffffffffL);
	
public static java.lang.StringintToAddress(int value)

		byte[]	bytes = { (byte)(value>>24), (byte)(value>>16),(byte)(value>>8),(byte)value };
		
		try{
			String	res = InetAddress.getByAddress(bytes).getHostAddress();
			
			// System.out.println( "intToAddress: " + Integer.toHexString(value) + " -> " + res );
			
			return( res );
			
		}catch( UnknownHostException e ){
			
				// should never get here as always valid byte array (4 long)
			
			Debug.printStackTrace(e);
			
			return( null );
		}