Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2003, 2010 Albert P?z and RoboRumble contributors
 * 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://robocode.sourceforge.net/license/epl-v10.html
 *
 * Contributors:
 *     Flemming N. Larsen
 *     - Initial API and implementation
 *******************************************************************************/

import java.util.Properties;

public class Main {
    private static String[] excludes;

    /**
     * Read and prepared exclude filters for robots that should not be downloaded or participate in battles.
     *
     * @param properties the properties to store.
     * @return a string array containing the excluded robots or null if no excludes are defined.
     */
    public static void setExcludes(Properties properties) {
        if (excludes != null) {
            return;
        }

        // Read and prepare exclude filters
        String exclude = properties.getProperty("EXCLUDE");

        if (exclude != null) {
            // Convert into regular expression

            // Dots must be dots, not "any character" in the regular expression
            exclude = exclude.replaceAll("\\.", "\\\\.");

            // The wildcard character ? corresponds to the regular expression .?
            exclude = exclude.replaceAll("\\?", ".?");

            // The wildcard character * corresponds to the regular expression .*
            exclude = exclude.replaceAll("\\*", ".*");

            // Split the exclude line into independent exclude filters that are trimmed for white-spaces
            excludes = exclude.split("[,;]+"); // white spaces are allowed in the filter due to robot version numbers
        }
    }
}