src/main/java/com/xceptance/neodymium/visual/ai/util/Helper.java
/**
     * Properties file reader for the ai.properties file. Read and convert all properties for the program.
     * 
     * @param path
     *            String path to the ai.properties file.
     * @throws IOException
     *             Error if the there is an IOException.
     */
Properties file reader for the ai.properties file. Read and convert all properties for the program.

@param path
String path to the ai.properties file.
@throws IOException
Error if the there is an IOException.
Properties file reader for the ai . properties file . Read and convert all properties for the program . @param path String path to the ai . properties file . @throws IOException Error if the there is an IOException .
public static void readProperties(String path) throws IOException
    {
        final String PREFIX = "neodymium.ai.";
        final String PROPERTY_ENABLED = PREFIX + "enabled";
        final String PROPERTY_TESTCASE_BOUND = PREFIX + "TESTCASE_BOUND";
        final String PROPERTY_TESTCASE_NAME = PREFIX + "TESTCASE_NAME";
        final String PROPERTY_MODE = PREFIX + "TRAINING";
        final String PROPERTY_USE_ORIGINAL_SIZE = PREFIX + "USE_ORIGINAL_SIZE";
        final String PROPERTY_USE_COLOR_FOR_COMPARISON = PREFIX + "USE_COLOR_FOR_COMPARISON";
        final String PROPERTY_LEARNING_RATE = PREFIX + "LEARNING_RATE";
        final String PROPERTY_INTENDED_PERCENTAGE_MATCH = PREFIX + "INTENDED_PERCENTAGE_MATCH";
        final String PROPERTY_PERCENTAGE_DIFFERENCE = PREFIX + "PERCENTAGE_DIFFERENCE";
        final String PROPERTY_IMAGE_HEIGHT = PREFIX + "IMAGE_HEIGHT";
        final String PROPERTY_IMAGE_WIDTH = PREFIX + "IMAGE_WIDTH";
        final String PROPERTY_FORMAT = PREFIX + "FORMAT";
        Properties props = new Properties();
        try
        {
            inputStream = new FileInputStream(path);
            if (inputStream != null)
            {
                props.load(inputStream);
            }
            else
            {
                throw new FileNotFoundException("could not load " + path);
            }
            final String enabled = props.getProperty(PROPERTY_ENABLED, "true");
            if (!enabled.contains("true"))
            {
                return;
            }
            Constants.TESTCASE_BOUND_NAME = props.getProperty(PROPERTY_TESTCASE_NAME, Constants.TESTCASE_BOUND_NAME);
            Constants.TESTCASE_BOUND = Boolean.parseBoolean(props.getProperty(PROPERTY_TESTCASE_BOUND, Boolean.toString(Constants.TESTCASE_BOUND)));
            Constants.NETWORK_MODE = Boolean.parseBoolean(props.getProperty(PROPERTY_MODE, Boolean.toString(Constants.NETWORK_MODE)));
            Constants.IMAGE_HEIGHT = Integer.parseInt(props.getProperty(PROPERTY_IMAGE_HEIGHT, Integer.toString(Constants.IMAGE_HEIGHT)));
            Constants.IMAGE_WIDTH = Integer.parseInt(props.getProperty(PROPERTY_IMAGE_WIDTH, Integer.toString(Constants.IMAGE_WIDTH)));
            Constants.FORMAT = props.getProperty(PROPERTY_FORMAT, Constants.FORMAT);
            Constants.USE_ORIGINAL_SIZE = Boolean.parseBoolean(props.getProperty(PROPERTY_USE_ORIGINAL_SIZE, Boolean.toString(Constants.USE_ORIGINAL_SIZE)));
            Constants.USE_COLOR_FOR_COMPARISON = Boolean.parseBoolean(props.getProperty(PROPERTY_USE_COLOR_FOR_COMPARISON,
                                                                                        Boolean.toString(Constants.USE_COLOR_FOR_COMPARISON)));
            Constants.LEARNING_RATE = Double.parseDouble(props.getProperty(PROPERTY_LEARNING_RATE, Double.toString(Constants.LEARNING_RATE)));
            Constants.INTENDED_PERCENTAGE_MATCH = Double.parseDouble(props.getProperty(PROPERTY_INTENDED_PERCENTAGE_MATCH,
                                                                                       Double.toString(Constants.INTENDED_PERCENTAGE_MATCH)));
            Constants.PERCENTAGE_DIFFERENCE = Double.parseDouble(props.getProperty(PROPERTY_PERCENTAGE_DIFFERENCE,
                                                                                   Double.toString(Constants.PERCENTAGE_DIFFERENCE)));
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
        finally
        {
            inputStream.close();
        }
    }
public static void readProperties ( String path ) throws IOException { final String PREFIX = "neodymium.ai." ; final String PROPERTY_ENABLED = PREFIX + "enabled" ; final String PROPERTY_TESTCASE_BOUND = PREFIX + "TESTCASE_BOUND" ; final String PROPERTY_TESTCASE_NAME = PREFIX + "TESTCASE_NAME" ; final String PROPERTY_MODE = PREFIX + "TRAINING" ; final String PROPERTY_USE_ORIGINAL_SIZE = PREFIX + "USE_ORIGINAL_SIZE" ; final String PROPERTY_USE_COLOR_FOR_COMPARISON = PREFIX + "USE_COLOR_FOR_COMPARISON" ; final String PROPERTY_LEARNING_RATE = PREFIX + "LEARNING_RATE" ; final String PROPERTY_INTENDED_PERCENTAGE_MATCH = PREFIX + "INTENDED_PERCENTAGE_MATCH" ; final String PROPERTY_PERCENTAGE_DIFFERENCE = PREFIX + "PERCENTAGE_DIFFERENCE" ; final String PROPERTY_IMAGE_HEIGHT = PREFIX + "IMAGE_HEIGHT" ; final String PROPERTY_IMAGE_WIDTH = PREFIX + "IMAGE_WIDTH" ; final String PROPERTY_FORMAT = PREFIX + "FORMAT" ; Properties props = new Properties ( ) ; try { inputStream = new FileInputStream ( path ) ; if ( inputStream != null ) { props . load ( inputStream ) ; } else { throw new FileNotFoundException ( "could not load " + path ) ; } final String enabled = props . getProperty ( PROPERTY_ENABLED , "true" ) ; if ( ! enabled . contains ( "true" ) ) { return ; } Constants . TESTCASE_BOUND_NAME = props . getProperty ( PROPERTY_TESTCASE_NAME , Constants . TESTCASE_BOUND_NAME ) ; Constants . TESTCASE_BOUND = Boolean . parseBoolean ( props . getProperty ( PROPERTY_TESTCASE_BOUND , Boolean . toString ( Constants . TESTCASE_BOUND ) ) ) ; Constants . NETWORK_MODE = Boolean . parseBoolean ( props . getProperty ( PROPERTY_MODE , Boolean . toString ( Constants . NETWORK_MODE ) ) ) ; Constants . IMAGE_HEIGHT = Integer . parseInt ( props . getProperty ( PROPERTY_IMAGE_HEIGHT , Integer . toString ( Constants . IMAGE_HEIGHT ) ) ) ; Constants . IMAGE_WIDTH = Integer . parseInt ( props . getProperty ( PROPERTY_IMAGE_WIDTH , Integer . toString ( Constants . IMAGE_WIDTH ) ) ) ; Constants . FORMAT = props . getProperty ( PROPERTY_FORMAT , Constants . FORMAT ) ; Constants . USE_ORIGINAL_SIZE = Boolean . parseBoolean ( props . getProperty ( PROPERTY_USE_ORIGINAL_SIZE , Boolean . toString ( Constants . USE_ORIGINAL_SIZE ) ) ) ; Constants . USE_COLOR_FOR_COMPARISON = Boolean . parseBoolean ( props . getProperty ( PROPERTY_USE_COLOR_FOR_COMPARISON , Boolean . toString ( Constants . USE_COLOR_FOR_COMPARISON ) ) ) ; Constants . LEARNING_RATE = Double . parseDouble ( props . getProperty ( PROPERTY_LEARNING_RATE , Double . toString ( Constants . LEARNING_RATE ) ) ) ; Constants . INTENDED_PERCENTAGE_MATCH = Double . parseDouble ( props . getProperty ( PROPERTY_INTENDED_PERCENTAGE_MATCH , Double . toString ( Constants . INTENDED_PERCENTAGE_MATCH ) ) ) ; Constants . PERCENTAGE_DIFFERENCE = Double . parseDouble ( props . getProperty ( PROPERTY_PERCENTAGE_DIFFERENCE , Double . toString ( Constants . PERCENTAGE_DIFFERENCE ) ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } finally { inputStream . close ( ) ; } }
Properties file reader for the ai.properties file.
Properties file reader for the ai . properties file .
// the property names // File file = new File(path); // skipped silently // parse all properties to the correct format.