* Fixes after review:

- Fix Polish po file
    - Install as a service by default on Windows again
    - Change CPUID getters to package private
    - Split new jbigi install messages into two lines
    - Javadocs
This commit is contained in:
zzz
2011-06-26 19:07:01 +00:00
parent 4ec4013a44
commit 2f10cca40f
24 changed files with 155 additions and 81 deletions

View File

@ -1,5 +1,9 @@
package freenet.support.CPUInformation;
/**
* Moved out of CPUID.java
* @since 0.8.7
*/
class AMDInfoImpl extends CPUIDCPUInfo implements AMDCPUInfo
{
protected static boolean isK6Compatible = false;
@ -13,19 +17,18 @@ class AMDInfoImpl extends CPUIDCPUInfo implements AMDCPUInfo
// If modelString != null, the cpu is considered correctly identified.
protected static String modelString = null;
@Override
public boolean IsK6Compatible(){ return isK6Compatible; }
@Override
public boolean IsK6_2_Compatible(){ return isK6_2_Compatible; }
@Override
public boolean IsK6_3_Compatible(){ return isK6_3_Compatible; }
@Override
public boolean IsGeodeCompatible(){ return isGeodeCompatible; }
@Override
public boolean IsAthlonCompatible(){ return isAthlonCompatible; }
@Override
public boolean IsAthlon64Compatible(){ return isAthlon64Compatible; }
@Override
public boolean IsBobcatCompatible(){ return isBobcatCompatible; }
static
@ -33,7 +36,6 @@ class AMDInfoImpl extends CPUIDCPUInfo implements AMDCPUInfo
identifyCPU();
}
@Override
public String getCPUModelString() throws UnknownCPUException
{
if (modelString != null)
@ -348,7 +350,7 @@ class AMDInfoImpl extends CPUIDCPUInfo implements AMDCPUInfo
}
}
}
@Override
public boolean hasX64()
{
return isX64;

View File

@ -99,7 +99,7 @@ public class CPUID {
private static native CPUIDResult doCPUID(int iFunction);
public static String getCPUVendorID()
static String getCPUVendorID()
{
CPUIDResult c = doCPUID(0);
StringBuilder sb= new StringBuilder(13);
@ -120,68 +120,72 @@ public class CPUID {
return sb.toString();
}
public static int getCPUFamily()
static int getCPUFamily()
{
CPUIDResult c = doCPUID(1);
return (c.EAX >> 8) & 0xf;
}
public static int getCPUModel()
static int getCPUModel()
{
CPUIDResult c = doCPUID(1);
return (c.EAX >> 4) & 0xf;
}
public static int getCPUExtendedModel()
static int getCPUExtendedModel()
{
CPUIDResult c = doCPUID(1);
return (c.EAX >> 16) & 0xf;
}
public static int getCPUType()
static int getCPUType()
{
CPUIDResult c = doCPUID(1);
return (c.EAX >> 12) & 0xf;
}
public static int getCPUExtendedFamily()
static int getCPUExtendedFamily()
{
CPUIDResult c = doCPUID(1);
return (c.EAX >> 20) & 0xff;
}
public static int getCPUStepping()
static int getCPUStepping()
{
CPUIDResult c = doCPUID(1);
return c.EAX & 0xf;
}
public static int getEDXCPUFlags()
static int getEDXCPUFlags()
{
CPUIDResult c = doCPUID(1);
return c.EDX;
}
public static int getECXCPUFlags()
static int getECXCPUFlags()
{
CPUIDResult c = doCPUID(1);
return c.ECX;
}
public static int getExtendedEBXCPUFlags()
static int getExtendedEBXCPUFlags()
{
CPUIDResult c = doCPUID(0x80000001);
return c.EBX;
}
public static int getExtendedECXCPUFlags()
static int getExtendedECXCPUFlags()
{
CPUIDResult c = doCPUID(0x80000001);
return c.ECX;
}
public static int getExtendedEDXCPUFlags()
/** @since 0.8.7 */
static int getExtendedEDXCPUFlags()
{
CPUIDResult c = doCPUID(0x80000001);
return c.EDX;
}
//Returns a CPUInfo item for the current type of CPU
//If I could I would declare this method in a interface named
//CPUInfoProvider and implement that interface in this class.
//This would make it easier for other people to understand that there
//is nothing preventing them from coding up new providers, probably using
//other detection methods than the x86-only CPUID instruction
/**
* Returns a CPUInfo item for the current type of CPU
* If I could I would declare this method in a interface named
* CPUInfoProvider and implement that interface in this class.
* This would make it easier for other people to understand that there
* is nothing preventing them from coding up new providers, probably using
* other detection methods than the x86-only CPUID instruction
*/
public static CPUInfo getInfo() throws UnknownCPUException
{
if(!_nativeOk)

View File

@ -1,5 +1,9 @@
package freenet.support.CPUInformation;
/**
* Moved out of CPUID.java
* @since 0.8.7
*/
abstract class CPUIDCPUInfo
{
protected static boolean isX64 = false;

View File

@ -23,7 +23,7 @@ public interface CPUInfo
public String getVendor();
/**
* @return A string detailing what type of CPU that is present in the machine. I.e. 'Pentium IV' etc.
* @throws UnknownCPUException If for any reson the retrieval of the requested information
* @throws UnknownCPUException If for any reason the retrieval of the requested information
* failed. The message encapsulated in the execption indicates the
* cause of the failure.
*/

View File

@ -1,5 +1,9 @@
package freenet.support.CPUInformation;
/**
* Moved out of CPUID.java
* @since 0.8.7
*/
class IntelInfoImpl extends CPUIDCPUInfo implements IntelCPUInfo
{
protected static boolean isPentiumCompatible = false;
@ -15,23 +19,22 @@ class IntelInfoImpl extends CPUIDCPUInfo implements IntelCPUInfo
// If modelString != null, the cpu is considered correctly identified.
protected static String modelString = null;
@Override
public boolean IsPentiumCompatible(){ return isPentiumCompatible; }
@Override
public boolean IsPentiumMMXCompatible(){ return isPentiumMMXCompatible; }
@Override
public boolean IsPentium2Compatible(){ return isPentium2Compatible; }
@Override
public boolean IsPentium3Compatible(){ return isPentium3Compatible; }
@Override
public boolean IsPentium4Compatible(){ return isPentium4Compatible; }
@Override
public boolean IsPentiumMCompatible(){ return isPentiumMCompatible; }
@Override
public boolean IsAtomCompatible(){ return isAtomCompatible; }
@Override
public boolean IsCore2Compatible(){ return isCore2Compatible; }
@Override
public boolean IsCoreiCompatible(){ return isCoreiCompatible; }
static
@ -290,7 +293,7 @@ class IntelInfoImpl extends CPUIDCPUInfo implements IntelCPUInfo
}
}
}
@Override
public boolean hasX64() {
return isX64;
}

View File

@ -1,5 +1,9 @@
package freenet.support.CPUInformation;
/**
* Moved out of CPUID.java
* @since 0.8.7
*/
public interface VIACPUInfo extends CPUInfo{
/**
@ -13,4 +17,4 @@ public interface VIACPUInfo extends CPUInfo{
}
}

View File

@ -1,5 +1,9 @@
package freenet.support.CPUInformation;
/**
* Moved out of CPUID.java
* @since 0.8.7
*/
class VIAInfoImpl extends CPUIDCPUInfo implements VIACPUInfo {
protected static boolean isC3Compatible = false;
@ -9,9 +13,8 @@ class VIAInfoImpl extends CPUIDCPUInfo implements VIACPUInfo {
protected static String modelString = null;
@Override
public boolean IsC3Compatible(){ return isC3Compatible; }
@Override
public boolean IsNanoCompatible(){ return isNanoCompatible; }
static
@ -19,7 +22,6 @@ class VIAInfoImpl extends CPUIDCPUInfo implements VIACPUInfo {
identifyCPU();
}
@Override
public String getCPUModelString()
{
if (modelString != null)
@ -28,7 +30,6 @@ class VIAInfoImpl extends CPUIDCPUInfo implements VIACPUInfo {
}
@Override
public boolean hasX64()
{
return false;

View File

@ -69,7 +69,7 @@ public class SingleFileNamingService extends NamingService {
}
/**
* @return the base file name
* @return the file's absolute path
*/
@Override
public String getName() {

View File

@ -1362,6 +1362,12 @@ public class DataHelper {
return rv;
}
/**
* Same as orig.getBytes("UTF-8") but throws an unchecked RuntimeException
* instead of an UnsupportedEncodingException if no UTF-8, for ease of use.
*
* @throws RuntimeException
*/
public static byte[] getUTF8(String orig) {
if (orig == null) return null;
try {
@ -1370,10 +1376,26 @@ public class DataHelper {
throw new RuntimeException("no utf8!?");
}
}
/**
* Same as orig.getBytes("UTF-8") but throws an unchecked RuntimeException
* instead of an UnsupportedEncodingException if no UTF-8, for ease of use.
*
* @throws RuntimeException
* @deprecated unused
*/
public static byte[] getUTF8(StringBuffer orig) {
if (orig == null) return null;
return getUTF8(orig.toString());
}
/**
* Same as new String(orig, "UTF-8") but throws an unchecked RuntimeException
* instead of an UnsupportedEncodingException if no UTF-8, for ease of use.
*
* @throws RuntimeException
* @deprecated unused
*/
public static String getUTF8(byte orig[]) {
if (orig == null) return null;
try {
@ -1382,6 +1404,14 @@ public class DataHelper {
throw new RuntimeException("no utf8!?");
}
}
/**
* Same as new String(orig, "UTF-8") but throws an unchecked RuntimeException
* instead of an UnsupportedEncodingException if no UTF-8, for ease of use.
*
* @throws RuntimeException
* @deprecated unused
*/
public static String getUTF8(byte orig[], int offset, int len) {
if (orig == null) return null;
try {