/** * @return <code>true</code> if this Java version is supported by the current * Java Version. It is expected that all versions are backward * compatible. */ public boolean isSupportedVersion () { return m_dMinVersionIncl < getCurrentVersion ().m_dMaxVersionExcl; }
/** * @return <code>true</code> if the this OS is the current OS. */ public boolean isCurrentOS () { return this == getCurrentOS (); }
private EJVMVendor () { m_bIsIt = determineIfItIsCurrentJVMVendor (); }
/** * @return The name of the system charset. */ @Nonnull public static String getSystemCharsetName () { return getSystemCharset ().name (); }
@Nonnull public static EJavaVersion getFromVersionNumber (final double dVersion) { for (final EJavaVersion eVersion : values ()) if (eVersion.isMatchingVersion (dVersion)) return eVersion; return UNKNOWN; } }
/** * @return The name and version of the operating system we're running on. */ @Nonnull public static String getOperatingSystemName () { return EOperatingSystem.getCurrentOSName () + " [" + EOperatingSystem.getCurrentOSVersion () + "]"; }
/** * Get the processor architecture based on the passed number of bits. * * @param nBits * The number of bits to get the processor architecture from. * @return {@link #UNKNOWN} if no processor architecture could be determined. */ @Nonnull public static EProcessorArchitecture forBits (final int nBits) { for (final EProcessorArchitecture eArch : values ()) if (nBits == eArch.getBits ()) return eArch; return UNKNOWN; }
/** * @return The current processor architecture if running inside a Sun JVM. If * no processor architecture could be determined, {@link #UNKNOWN} is * returned and never <code>null</code>. */ @Nonnull static EProcessorArchitecture getCurrentArchitecture () { EProcessorArchitecture ret = s_aInstance; if (ret == null) { // Note: double initialization doesn't matter here ret = forBits (getCurrentArchitectureBits ()); s_aInstance = ret; } return ret; } }
/** * @return The current JVM vendor. If the vendor could not be determined, * {@link #UNKNOWN} is returned and never <code>null</code>. */ @Nonnull public static EJVMVendor getCurrentVendor () { EJVMVendor ret = s_aInstance; if (ret == null) { // Note: double initialization doesn't matter here // Check for (final EJVMVendor eVendor : values ()) if (eVendor.isJVMVendor ()) { ret = eVendor; break; } if (ret == null) ret = UNKNOWN; s_aInstance = ret; } return ret; } }
/** * @return The current OS. Never <code>null</code>. */ @Nonnull public static EOperatingSystem getCurrentOS () { EOperatingSystem ret = s_aInstance; if (ret == null) { // Note: double initialization doesn't matter here final String sCurrentOSName = getCurrentOSName (); ret = forName (sCurrentOSName); s_aInstance = ret; if (ret == UNKNOWN) LoggerFactory.getLogger (EOperatingSystem.class).error ("Failed to resolve operating system from name '" + sCurrentOSName + "'!!!"); } return ret; }
/** * @return The vendor of the Java Virtual Machine (JVM) that we're operating * on. */ @Nonnull public static EJVMVendor getJVMVendor () { return EJVMVendor.getCurrentVendor (); }
/** * @return The current processor architecture and never <code>null</code>. */ @Nonnull public static EProcessorArchitecture getProcessorArchitecture () { return EProcessorArchitecture.getCurrentArchitecture (); }
@Nullable public static ENewLineMode getFromTextOrNull (@Nullable final String sText) { return getFromTextOrDefault (sText, null); } }
/** * Default constructor. * * @param dMinVersionIncl * Minimum version (inclusive) * @param dMaxVersionExcl * Maximum version (exclusive) */ private EJavaVersion (@Nonnegative final double dMinVersionIncl, @Nonnegative final double dMaxVersionExcl) { m_dMinVersionIncl = dMinVersionIncl; m_dMaxVersionExcl = dMaxVersionExcl; m_bIsIt = isMatchingVersion (JavaVersionConstants.CLASS_VERSION); }
/** * @return The current Java version. If the Java version could not be * determined, {@link #UNKNOWN} is returned and never * <code>null</code>. */ @Nonnull public static EJavaVersion getCurrentVersion () { EJavaVersion ret = s_aInstance; if (ret == null) { // Note: double initialization doesn't matter here for (final EJavaVersion eVersion : values ()) if (eVersion.m_bIsIt) { ret = eVersion; break; } if (ret == null) ret = UNKNOWN; s_aInstance = ret; } return ret; }
@Nullable public static ENewLineMode getFromTextOrDefault (@Nullable final String sText, @Nullable final ENewLineMode eDefault) { if (sText != null && sText.length () > 0) for (final ENewLineMode e : values ()) if (e.m_sText.equals (sText)) return e; return eDefault; }
/** * Get the matching Java version from a class version. * * @param nMajor * Major version number * @param nMinor * Minor version number * @return {@link #UNKNOWN} if the version could not be determined. */ @Nonnull public static EJavaVersion getFromMajorAndMinor (final int nMajor, final int nMinor) { final double dVersion = StringParser.parseBigDecimal (nMajor + "." + nMinor).doubleValue (); return getFromVersionNumber (dVersion); }
@Nonnull public final XMLWriterSettings setNewlineString (@Nonnull @Nonempty final ENewLineMode eNewlineMode) { ValueEnforcer.notNull (eNewlineMode, "NewlineMode"); return setNewlineString (eNewlineMode.getText ()); }
/** * @return The current Java version that is running. Never <code>null</code>. */ @Nonnull public static EJavaVersion getJavaVersion () { return EJavaVersion.getCurrentVersion (); }
/** * @return The operating system we're running on. */ @Nonnull public static EOperatingSystem getOperatingSystem () { return EOperatingSystem.getCurrentOS (); }