FileDocCategorySizeDatePackage
Constants.javaAPI DocAzureus 3.0.3.47765Wed Oct 03 20:23:36 BST 2007org.gudy.azureus2.core3.util

Constants

public class Constants extends Object
author
Olivier

Fields Summary
public static final String
SF_WEB_SITE
public static final String
AELITIS_WEB_SITE
public static final String
GETAZUREUS_WEB_SITE
public static final String
AELITIS_TORRENTS
public static final String
AELITIS_FILES
public static final String
AZUREUS_WIKI
public static final String
VERSION_SERVER_V4
public static final String
VERSION_SERVER_V6
public static final String
DHT_SEED_ADDRESS_V4
public static final String
DHT_SEED_ADDRESS_V6
public static final String
NAT_TEST_SERVER
public static final String
NAT_TEST_SERVER_HTTP
public static final String
SPEED_TEST_SERVER
public static final String[]
AZUREUS_DOMAINS
public static final String
DEFAULT_ENCODING
public static final String
BYTE_ENCODING
public static Charset
BYTE_CHARSET
public static Charset
DEFAULT_CHARSET
public static final String
INFINITY_STRING
public static final int
INFINITY_AS_INT
public static final long
INFINITE_AS_LONG
public static final String
AZUREUS_NAME
public static final String
AZUREUS_VERSION
public static final byte[]
VERSION_ID
public static final String
OSName
public static final boolean
isOSX
public static final boolean
isLinux
public static final boolean
isSolaris
public static final boolean
isFreeBSD
public static final boolean
isWindowsXP
public static final boolean
isWindowsVista
public static final boolean
isWindows95
public static final boolean
isWindows98
public static final boolean
isWindowsME
public static final boolean
isWindows9598ME
public static final boolean
isWindows
public static final boolean
isUnix
public static final String
JAVA_VERSION
public static final String
FILE_WILDCARD
Constructors Summary
Methods Summary
public static intcompareVersions(java.lang.String version_1, java.lang.String version_2)
compare two version strings of form n.n.n.n (e.g. 1.2.3.4)

param
version_1
param
version_2
return
-ve -> version_1 lower, 0 = same, +ve -> version_1 higher

	
		try{
			if ( version_1.startsWith("." )){
				version_1 = "0" + version_1;
			}
			if ( version_2.startsWith("." )){
				version_2 = "0" + version_2;
			}

			version_1 = version_1.replaceAll("[^0-9.]", ".");
			version_2 = version_2.replaceAll("[^0-9.]", ".");
			
			StringTokenizer	tok1 = new StringTokenizer(version_1,".");
			StringTokenizer	tok2 = new StringTokenizer(version_2,".");
			
			while( true ){
				if ( tok1.hasMoreTokens() && tok2.hasMoreTokens()){
				
					int	i1 = Integer.parseInt(tok1.nextToken());
					int	i2 = Integer.parseInt(tok2.nextToken());
				
					if ( i1 != i2 ){
						
						return( i1 - i2 );
					}
				}else if ( tok1.hasMoreTokens()){
					
					int	i1 = Integer.parseInt(tok1.nextToken());
	
					if ( i1 != 0 ){
						
						return( 1 );
					}
				}else if ( tok2.hasMoreTokens()){
					
					int	i2 = Integer.parseInt(tok2.nextToken());
	
					if ( i2 != 0 ){
						
						return( -1 );
					}
				}else{
					return( 0 );
				}
			}
		}catch( Throwable e ){
			
			Debug.printStackTrace(e);
			
			return( 0 );
		}
	
public static java.lang.StringgetBaseVersion()
Gets the current version, or if a CVS version, the one on which it is based

return

  
  	                    	 
  
    
  
  
  	return( getBaseVersion( AZUREUS_VERSION ));
  
public static java.lang.StringgetBaseVersion(java.lang.String version)

  	int	p1 = version.indexOf("_");	// _CVS or _Bnn
  	
  	if ( p1 == -1 ){
  		
  		return( version );
  	}
  	
  	return( version.substring(0,p1));
  
public static intgetIncrementalBuild()
For CVS builds this returns the incremental build number. For people running their own builds this returns -1

return

  	return( getIncrementalBuild( AZUREUS_VERSION ));
  
public static intgetIncrementalBuild(java.lang.String version)

  	if ( !isCVSVersion(version)){
  		
  		return( 0 );
  	}
  	
  	int	p1 = version.indexOf( "_B" );
  	
  	if ( p1 == -1 ){
  		
  		return( -1 );
  	}
  	
  	try{
  		return( Integer.parseInt( version.substring(p1+2)));
  		
  	}catch( Throwable e ){
  		
  		System.out.println("can't parse version");
  		
  		return( -1 );
  	}
  
public static booleanisCVSVersion()
is this a formal build or CVS/incremental

return

  	return( isCVSVersion( AZUREUS_VERSION )); 
  
public static booleanisCVSVersion(java.lang.String version)

  	return( version.indexOf("_") != -1 );  
  
public static voidmain(java.lang.String[] args)

		System.out.println(compareVersions("3.0.0.1", "3.0.0.0"));
		System.out.println(compareVersions("3.0.0.0_B1", "3.0.0.0"));
		System.out.println(compareVersions("3.0.0.0", "3.0.0.0_B1"));
		System.out.println(compareVersions("3.0.0.0_B1", "3.0.0.0_B4"));
		System.out.println(compareVersions("3.0.0.0..B1", "3.0.0.0_B4"));