FileDocCategorySizeDatePackage
RuntimeVersion.javaAPI DocGlassfish v2 API5695Fri May 04 22:34:58 BST 2007com.sun.jdo.spi.persistence.support.sqlstore

RuntimeVersion

public class RuntimeVersion extends Object

Fields Summary
private static Properties
_properties
private static final ResourceBundle
vendor_info
private static String
product_version
private static String
build_time
private static String
runtime_version
private static String
vendor_name
private static String
version_number
private static String
vendor
Constructors Summary
public RuntimeVersion()
Constructor without parameters

    
public RuntimeVersion(String fileName)
Constructor without parameters

        loadProperties(fileName);
    
Methods Summary
public static java.util.PropertiesgetVendorProperties(java.lang.String fileName)
Return Vendor properties for a given file name

        loadProperties(fileName);
        return getVendorProperties();
    
public static java.util.PropertiesgetVendorProperties()
Return Vendor properties

        if (_properties == null)
            return null;

        Properties _vendorProperties = new Properties();
        _vendorProperties.setProperty(vendor_name, vendor);
        _vendorProperties.setProperty(version_number, parse_version());

        return _vendorProperties;
    
public static voidloadProperties(java.lang.String fileName)
Load properties file

        try {
            InputStream in = RuntimeVersion.class.getResourceAsStream(fileName);
            if (in == null)
                throw new FileNotFoundException(fileName);

            _properties.load(in);
            in.close();
        } catch (java.io.IOException e) {
            throw new JDOException(null, e);
        }
    
public static voidmain(java.lang.String[] args)

 // NOI18N

         
        if (args == null || args.length == 0 ||
                (args.length == 1 && args[0].equals("-version"))) // NOI18N
        {
            RuntimeVersion rt = new RuntimeVersion();
            rt.loadProperties("/com/sun/jdo/spi/persistence/support/sqlstore/sys.properties"); // NOI18N
            System.out.println(parse_version());
        }
        System.exit(0);
    
private static java.lang.Stringparse_version()
Parse the build date and create a localized version return version as String

        if (_properties == null)
            return null;

        String majorVersion = _properties.getProperty(product_version);
        String minorVersion = _properties.getProperty(runtime_version);
        String buildTime = _properties.getProperty(build_time);

        // Parse the build date and create a localized version
        String s = null;
        try {
            DateFormat dateFormatter = DateFormat.getDateTimeInstance();
            SimpleDateFormat propertyFormat = new SimpleDateFormat("MM/dd/yy hh:mm:ss"); // NOI18N
            s = dateFormatter.format(propertyFormat.parse(buildTime));
        } catch (Exception e) {
            s = ""; // NOI18N
        }

        return I18NHelper.getMessage(vendor_info, "fullVersion", majorVersion, minorVersion, s); // NOI18N