<commit_before>package org.csstudio.utility.pv.simu;

import java.util.HashMap;
import java.util.Map;

import org.csstudio.utility.pv.IPVFactory;
import org.csstudio.utility.pv.PV;

/** PV Factory for simulated PVs
 *  @author <NAME>
 */
@SuppressWarnings("nls")
public class SystemPVFactory implements IPVFactory
{
    /** PV type prefix */
    public static final String PREFIX = "sys";

    /** All the 'simulated' PVs, mapped by name */
    private static Map<String, Value> values =
        new HashMap<String, Value>();

    /** Create a 'dynamic' PV.
     *  @param name Name of the PV
     */
    public PV createPV(final String name)
    {
        Value value = values.get(name);
        if (value == null)
        {
            if (name.equals("time"))
                value = new TimeValue(name);
            else if (name.equals("free_mb"))
                value = new FreeMemValue(name);
            else if (name.equals("used_mb"))
                value = new UsedMemValue(name);
            else if (name.equals("max_mb"))
                value = new MaxMemValue(name);
            else if (name.equals("user"))
                value = new TextValue(name, System.getProperty("user.name"));
            else
                value = new TextValue(name,
                        "Unknown system property '" + name + "'", false);
            values.put(name, value);<commit_msg>add some system properties<commit_after>package org.csstudio.utility.pv.simu;

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

import org.csstudio.utility.pv.IPVFactory;
import org.csstudio.utility.pv.PV;

/** PV Factory for simulated PVs
 *  @author <NAME>
 */
@SuppressWarnings("nls")
public class SystemPVFactory implements IPVFactory
{
    /** PV type prefix */
    public static final String PREFIX = "sys";

    /** All the 'simulated' PVs, mapped by name */
    private static Map<String, Value> values =
        new HashMap<String, Value>();

    /** Create a 'dynamic' PV.
     *  @param name Name of the PV
     */
    public PV createPV(final String name)
    {
        Value value = values.get(name);
        if (value == null)
        {
            if (name.equals("time"))
                value = new TimeValue(name);
            else if (name.equals("free_mb"))
                value = new FreeMemValue(name);
            else if (name.equals("used_mb"))
                value = new UsedMemValue(name);
            else if (name.equals("max_mb"))
                value = new MaxMemValue(name);
            else if (name.startsWith("system.")){
            	String prop = name.substring(7);
            	String prop_value = System.getProperty(prop);
            	if(prop_value != null)
            		value = new TextValue(name, prop_value);
            	else
            		value = new TextValue(name,
                        "Unknown system property '" + prop + "'", false);
            }                
            else if (name.equals("host_name"))
				try {
					value = new TextValue(name, InetAddress.getLocalHost().getHostName());
				} catch (UnknownHostException e) {
					value = new TextValue(name, "Unknown Host", false);
				}
			else if (name.equals("qualified_host_name"))
				try {
					value = new TextValue(name, InetAddress.getLocalHost().getCanonicalHostName());
				} catch (UnknownHostException e) {
					value = new TextValue(name, "Unknown Host", false);
				}
			else
                value = new TextValue(name,
                        "Unknown system property '" + name + "'", false);
            values.put(name, value);
{'fraction_non_alphanumeric': 0.12026541332596075, 'fraction_numerical': 0.0002764722145424385, 'mean_word_length': 2.116279069767442, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4235894', 'n_tokens_mistral': 1090, 'n_tokens_neox': 1015, 'n_words': 275}