All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.relevantcodes.extentreports.SystemInfo Maven / Gradle / Ivy

There is a newer version: 2.41.2
Show newest version
/*
* Copyright (c) 2015, Anshoo Arora (Relevant Codes).  All rights reserved.
* 
* Copyrights licensed under the New BSD License.
* 
* See the accompanying LICENSE file for terms.
*/

package com.relevantcodes.extentreports;

import java.net.InetAddress;
import java.util.Map;

import com.relevantcodes.extentreports.model.SystemProperties;

class SystemInfo {
    private SystemProperties systemProperties;
    
    public void clear() {
        systemProperties.info.clear();
    }
    
    public Map getInfo() {
        if (systemProperties == null) {
            return null;            
        }
        
        return systemProperties.info;
    }
    
    public void setInfo(Map info) {
        for (Map.Entry entry : info.entrySet()) {
            systemProperties.info.put(entry.getKey(), entry.getValue());
        }
    }
    
    public void setInfo(String param, String value) {
        systemProperties.info.put(param, value);
    }
    
    private void setInfo() {
        if (systemProperties == null) {
            systemProperties = new SystemProperties();
        }
        
        systemProperties.info.put("User Name", System.getProperty("user.name"));
        systemProperties.info.put("OS", System.getProperty("os.name"));
        systemProperties.info.put("Java Version", System.getProperty("java.version"));
        
        try {
            systemProperties.info.put("Host Name", InetAddress.getLocalHost().getHostName());
        } 
        catch(Exception e) { }
    }
    
    public SystemInfo() { 
        setInfo();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy