<commit_before>/*******************************************************************************
 * Copyright (c) 2013 Oak Ridge National Laboratory.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 ******************************************************************************/
package org.csstudio.sns.pvnames;

import java.io.FileInputStream;
import java.util.Properties;

import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.preferences.IPreferencesService;

/** Preference settings
 *  @author <NAME>
 */
@SuppressWarnings("nls")
public class Preferences
{
    /** @return RDB URL */
    public static String getURL()
    {
        return get("url");
    }

    /** @return RDB user name */
    public static String getUser()
    {
        return get("user");
    }

    /** @return RDB password */
    public static String getPassword()
    {
        return get("password");
    }

    /** @return Minimum request length */
    public static int getMinRequestLength()
    {
        return Integer.parseInt(get("min_request"));
    }

    /** Locate setting from Eclipse preferences
     *  or directly read preferences.ini for Unit test
     *
     *  @param key Preference key
     *  @return Value
     */
    private static String get(final String key)
    {
        final IPreferencesService prefs = Platform.getPreferencesService();
        if (prefs == null)
        {
            final Properties props = new Properties();
            try
            {
                props.load(new FileInputStream("preferences.ini"));
            }
            catch (Exception ex)
            {
                // Ignore
            }
            return props.getProperty(key);
        }
        else
            return prefs.getString("org.csstudio.sns.pvnames", key, null, null);
    }
}<commit_msg>PV name lookup: Default for min length<commit_after>/*******************************************************************************
 * Copyright (c) 2013 Oak Ridge National Laboratory.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 ******************************************************************************/
package org.csstudio.sns.pvnames;

import java.io.FileInputStream;
import java.util.Properties;

import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.preferences.IPreferencesService;

/** Preference settings
 *  @author <NAME>
 */
@SuppressWarnings("nls")
public class Preferences
{
    /** @return RDB URL */
    public static String getURL()
    {
        return get("url", "");
    }

    /** @return RDB user name */
    public static String getUser()
    {
        return get("user", "");
    }

    /** @return RDB password */
    public static String getPassword()
    {
        return get("password", "");
    }

    /** @return Minimum request length */
    public static int getMinRequestLength()
    {
        return Integer.parseInt(get("min_request", "5"));
    }

    /** Locate setting from Eclipse preferences
     *  or directly read preferences.ini for Unit test
     *
     *  @param key Preference key
     *  @param default_value Default value
     *  @return Value
     */
    private static String get(final String key, final String default_value)
    {
        final IPreferencesService prefs = Platform.getPreferencesService();
        if (prefs == null)
        {
            final Properties props = new Properties();
            try
            {
                props.load(new FileInputStream("preferences.ini"));
            }
            catch (Exception ex)
            {
                // Ignore
            }
            return props.getProperty(key);
        }
        else
            return prefs.getString("org.csstudio.sns.pvnames", key, default_value, null);
    }
}
{'fraction_non_alphanumeric': 0.1701923076923077, 'fraction_numerical': 0.004086538461538462, 'mean_word_length': 2.523285351397121, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1921671', 'n_tokens_mistral': 1064, 'n_tokens_neox': 1026, 'n_words': 304}