Example usage for java.lang String equalsIgnoreCase

List of usage examples for java.lang String equalsIgnoreCase

Introduction

In this page you can find the example usage for java.lang String equalsIgnoreCase.

Prototype

public boolean equalsIgnoreCase(String anotherString) 

Source Link

Document

Compares this String to another String , ignoring case considerations.

Usage

From source file:io.github.benas.jql.shell.Shell.java

public static void main(String[] args) {
    String databaseFile = "";
    if (args.length >= 1) {
        databaseFile = args[0];/*  ww  w .j  ava  2  s.c  o  m*/
    }

    DataSource dataSource = getDataSourceFrom(databaseFile);
    JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
    resultSetExtractor = new StringResultSetExtractor();
    queryExecutor = new QueryExecutor(jdbcTemplate);

    Console console = getConsole();

    String command;
    while (true) {
        System.out.print("$>");
        command = console.readLine();
        if (command.equalsIgnoreCase("quit")) {
            break;
        }
        process(command);
    }
    System.out.println("bye!");
}

From source file:edu.cuhk.hccl.cmd.AppQueryExpander.java

public static void main(String[] args) {

    try {/*w  ww.  jav  a  2  s  .  co m*/

        CommandLineParser parser = new BasicParser();
        Options options = createOptions();
        CommandLine line = parser.parse(options, args);

        // Get parameters
        String queryStr = line.getOptionValue('q');
        int topK = Integer.parseInt(line.getOptionValue('k'));
        String modelPath = line.getOptionValue('m');
        String queryType = line.getOptionValue('t');

        QueryExpander expander = null;
        if (queryType.equalsIgnoreCase("WordVector")) {
            // Load word vectors
            System.out.println("[INFO] Loading word vectors...");
            expander = new WordVectorExpander(modelPath);
        } else if (queryType.equalsIgnoreCase("WordNet")) {
            // Load WordNet
            System.out.println("[INFO] Loading WordNet...");
            expander = new WordNetExpander(modelPath);
        } else {
            System.out.println("Please choose a correct expander: WordNet or WordVector!");
            System.exit(-1);
        }

        // Expand query
        System.out.println("[INFO] Computing similar words...");
        List<String> terms = expander.expandQuery(queryStr, topK);

        System.out.println(String.format("\n[INFO] The top %d similar words are: ", topK));
        for (String term : terms) {
            System.out.println(term);
        }

    } catch (ParseException exp) {
        System.out.println("Error in parameters: \n" + exp.getMessage());
        System.exit(-1);

    }
}

From source file:com.aerospike.examples.Main.java

/**
 * Main entry point.//  w  w w  .  j a  v a2s  .c om
 */
public static void main(String[] args) {

    try {
        Options options = new Options();
        options.addOption("h", "host", true, "Server hostname (default: localhost)");
        options.addOption("p", "port", true, "Server port (default: 3000)");
        options.addOption("U", "user", true, "User name");
        options.addOption("P", "password", true, "Password");
        options.addOption("n", "namespace", true, "Namespace (default: test)");
        options.addOption("s", "set", true, "Set name. Use 'empty' for empty set (default: demoset)");
        options.addOption("g", "gui", false, "Invoke GUI to selectively run tests.");
        options.addOption("d", "debug", false, "Run in debug mode.");
        options.addOption("u", "usage", false, "Print usage.");

        CommandLineParser parser = new PosixParser();
        CommandLine cl = parser.parse(options, args, false);

        if (args.length == 0 || cl.hasOption("u")) {
            logUsage(options);
            return;
        }
        Parameters params = parseParameters(cl);
        String[] exampleNames = cl.getArgs();

        if ((exampleNames.length == 0) && (!cl.hasOption("g"))) {
            logUsage(options);
            return;
        }

        // Check for all.
        for (String exampleName : exampleNames) {
            if (exampleName.equalsIgnoreCase("all")) {
                exampleNames = ExampleNames;
                break;
            }
        }

        if (cl.hasOption("d")) {
            Log.setLevel(Level.DEBUG);
        }

        if (cl.hasOption("g")) {
            GuiDisplay.startGui(params);
        } else {
            Console console = new Console();
            runExamples(console, params, exampleNames);
        }
    } catch (Exception ex) {
        System.out.println(ex.getMessage());
        ex.printStackTrace();
    }
}

From source file:com.waku.mmdataextract.ComprehensiveSearch.java

@SuppressWarnings("unchecked")
public static void main(String[] args) {
    FileWriter fw = null;/*  w w w. j  a va2 s  .  c o m*/
    try {
        fw = new FileWriter(new File("output/ComprehensiveSearch.csv"));
        fw.write(
                ",??,?,?,,?,??,,?,1,2,3,\n");
    } catch (IOException e) {
        e.printStackTrace();
    }
    Document firstPage = MyHttpClient.getAsDom4jDoc(START_ACTION);
    // System.out.println(doc.asXML());
    List<Element> brandOptions = firstPage.selectNodes("//select[@name='brandId']/option");
    for (Element brandOption : brandOptions) {
        String brandId = brandOption.attributeValue("value");
        if (!brandId.equalsIgnoreCase("0")) {
            for (int i = 1; true; i++) {
                logger.info("Get brandId/page -> " + brandId + "/" + i);
                if (searchDone(fw, brandId, i)) {
                    break;
                }
            }
        }
    }
    try {
        fw.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
    logger.info("----> Done!");

    logger.info("----> Start to compare production search ... ");
    CompareProductions.start(prodIdList, 0);
}

From source file:edu.asu.bscs.csiebler.calculatorrpc.CalcJavaClient.java

public static void main(String args[]) {
    try {//from   ww w  .j  a va  2  s  . c  om
        String url = "http://127.0.0.1:8080/";
        if (args.length > 0) {
            url = args[0];
        }
        CalcJavaClient cjc = new CalcJavaClient(url);
        BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
        System.out.print("Enter end or {+|-|*|/} double double eg + 3 5 >");
        String inStr = stdin.readLine();
        StringTokenizer st = new StringTokenizer(inStr);
        String opn = st.nextToken();
        while (!opn.equalsIgnoreCase("end")) {
            if (opn.equalsIgnoreCase("+")) {
                double result = cjc.add(Double.parseDouble(st.nextToken()), Double.parseDouble(st.nextToken()));
                System.out.println("response: " + result);
            } else if (opn.equalsIgnoreCase("-")) {
                double result = cjc.subtract(Double.parseDouble(st.nextToken()),
                        Double.parseDouble(st.nextToken()));
                System.out.println("response: " + result);
            } else if (opn.equalsIgnoreCase("*")) {
                double result = cjc.multiply(Double.parseDouble(st.nextToken()),
                        Double.parseDouble(st.nextToken()));
                System.out.println("response: " + result);
            } else if (opn.equalsIgnoreCase("/")) {
                double result = cjc.divide(Double.parseDouble(st.nextToken()),
                        Double.parseDouble(st.nextToken()));
                System.out.println("response: " + result);
            }
            System.out.print("Enter end or {+|-|*|/} double double eg + 3 5 >");
            inStr = stdin.readLine();
            st = new StringTokenizer(inStr);
            opn = st.nextToken();
        }
    } catch (Exception e) {
        System.out.println("Oops, you didn't enter the right stuff");
    }
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    DatagramSocket udpSocket = new DatagramSocket();
    String msg = null;
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    System.out.print("Please enter a  message  (Bye  to quit):");
    while ((msg = br.readLine()) != null) {
        if (msg.equalsIgnoreCase("bye")) {
            break;
        }//w ww  . j  av  a 2  s  . c om
        DatagramPacket packet = Main.getPacket(msg);
        udpSocket.send(packet);
        udpSocket.receive(packet);
        displayPacketDetails(packet);
        System.out.print("Please enter a  message  (Bye  to quit):");
    }
    udpSocket.close();
}

From source file:de.ee.hezel.PDFCompareMain.java

/**
 * Args[]/*  w  w w  .j  a va2 s  .  c  o m*/
 *       [1. path]
 *       [2. path]
 *       -output [true/false]
 *       -visualise [output path] 
 * 
 * return value
 *       1 = not enough parameters
 *       2 = 
 * 
 * @param args 
 * @return int 
 */
public static void main(String[] args) {
    // not enough parameters
    if (args.length < 1) {
        System.out.println("usage: java -jar PDFCompare.jar "
                + "<path 1> <path 2> [-output <true/false>] [-visualise <path 3>] [-log <path 4>] [-compare <compare type>] [-prefix <pdf prefix>]"
                + newline + newline + "<path 1> = path with PDF documents from old version" + newline
                + "<path 2> = path with PDF documents from new version" + newline + "[output] = console output"
                + newline + "[visualise] = output folder for visualizing differnces " + newline
                + "[log] = path for log files and differnce images" + newline
                + "[compare type] = type of comparison <\"SIMPLE\" | \"STRUCTURAL\" | \"VISUAL\">" + newline
                + "[prefix] = compare only pdfs where the name starts with this prefix" + newline);
        return;
    }

    boolean output = false;
    File targetPath = null, logPath = null;
    int compareType = 1; // simple (Modes: SIMPLE/STRUCTURAL/VISUAL)
    String prefix = null;

    // read the incoming arguments
    for (int i = 2; i < args.length; i++) {
        if (args[i].equals("-output")) {
            output = Boolean.parseBoolean(args[++i]);
        } else if (args[i].equals("-visualise")) {
            targetPath = new File(args[++i]);
        } else if (args[i].equals("-log")) {
            logPath = new File(args[++i]);
        } else if (args[i].equals("-compare")) {
            String nextArg = args[++i];
            if (nextArg.equalsIgnoreCase("STRUCTURAL"))
                compareType = 2;
            else if (nextArg.equalsIgnoreCase("VISUAL"))
                compareType = 3;
        } else if ((args[i]).equals("-prefix")) {
            prefix = args[++i];
        }
    }

    // create or clear the output path
    checkOutputPath(targetPath);

    // configure log4j
    Properties props = getLog4jProperties(output, logPath);
    LogManager.resetConfiguration();
    PropertyConfigurator.configure(props);

    // check the output paths
    File path1 = new File(args[0]);
    File path2 = new File(args[1]);
    if (!path1.isDirectory() || !path2.isDirectory()) {
        if (!path1.isDirectory())
            log.error("[Path 1] does not exist");
        if (!path2.isDirectory())
            log.error("[Path 2] does not exist");
    }

    // compare the files in path 1 with the files in path 2 and 
    // save the results in path 3 (if given)
    PDFComparator pdfComparer = new PDFComparator(logPath, compareType);
    boolean foundDifference = pdfComparer.run(path1, path2, targetPath, prefix);

    // exit parameter (interesting for jenkins)
    System.exit(foundDifference ? 1 : 0);
}

From source file:esg.node.connection.ESGConnectorTester.java

public static void main(String[] args) {
    for (String arg : args)
        System.out.println(arg);/*from w  ww .j a v  a2s  .co m*/
    if (args.length < 1 || args.length > 2) {
        System.out.println(" Usage requries args: [\"prune\" | \"ping\"]");
        System.exit(1);
    }

    System.out.println("Running ESGConnector...");
    String function = args[0];
    String host = "localhost";
    if (args.length == 2)
        host = args[1];
    try {
        if (function.equalsIgnoreCase("prune")) {
            System.out.println("prune -> " + host);
            if (ESGConnector.getInstance().setSecured(false).setEndpoint(host, true).prune()) {
                System.out.println("Pruned dead peer connections from " + host);
            } else {
                System.out.println("There were no dead peer connections detected on " + host
                        + " (or host itself is dead)");
            }
        }

        if (function.equalsIgnoreCase("ping")) {
            System.out.println("ping -> " + host);
            if (ESGConnector.getInstance().setSecured(false).setEndpoint(host, true).ping()) {
                System.out.println("Successfully pinged " + host);
            } else {
                System.out.println("Unable to ping " + host);
            }
        }
    } catch (Throwable t) {
        log.error("Oops there was a problem... is the node manager running on "
                + ESGConnector.getInstance().getEndpoint() + "?");
        log.error(t);
        t.printStackTrace();
        ESGConnector.getInstance().clearCache();
    }
    System.out.println("bye");
}

From source file:net.doubledoordev.backend.Main.java

public static void main(String[] args) throws Exception {
    System.setProperty("file.encoding", "UTF-8");
    Field charset = Charset.class.getDeclaredField("defaultCharset");
    charset.setAccessible(true);//from  ww  w.  j a va 2  s  .  c o  m
    charset.set(null, null);

    for (String arg : args) {
        if (arg.equalsIgnoreCase("debug"))
            debug = true;
    }

    LOGGER.info("\n\n    D3Backend  Copyright (C) 2015  Dries007 & Double Door Development\n"
            + "    This program comes with ABSOLUTELY NO WARRANTY;\n"
            + "    This is free software, and you are welcome to redistribute it under certain conditions;\n"
            + "    Type `license' for details.\n\n");

    LOGGER.info("Making necessary folders...");
    mkdirs();
    LOGGER.info("Starting webserver...");

    final HttpServer webserver = new HttpServer();
    final ServerConfiguration config = webserver.getServerConfiguration();

    // Html stuff
    freemarkerHandler = new FreemarkerHandler(Main.class, TEMPLATES_PATH);
    config.addHttpHandler(freemarkerHandler);
    config.setDefaultErrorPageGenerator(freemarkerHandler);
    config.addHttpHandler(new CLStaticHttpHandler(Main.class.getClassLoader(), STATIC_PATH), STATIC_PATH);
    config.addHttpHandler(new ServerFileHandler(P2S_PATH), P2S_PATH);
    config.addHttpHandler(new ServerFileHandler(), RAW_PATH);

    // Socket stuff
    ServerMonitorSocketApplication.register();
    ServerControlSocketApplication.register();
    ServerPropertiesSocketApplication.register();
    FileManagerSocketApplication.register();
    ServerconsoleSocketApplication.register();
    ConsoleSocketApplication.register();
    AdvancedSettingsSocketApplication.register();
    UsersSocketApplication.register();

    final NetworkListener networkListener = new NetworkListener("listener",
            Strings.isBlank(SETTINGS.hostname) ? NetworkListener.DEFAULT_NETWORK_HOST : SETTINGS.hostname,
            Strings.isNotBlank(SETTINGS.certificatePath) ? SETTINGS.portHTTPS : SETTINGS.portHTTP);
    if (Strings.isNotBlank(SETTINGS.certificatePath)) {
        networkListener.setSecure(true);
        networkListener.setSSLEngineConfig(createSslConfiguration());
        webserver.addListener(new NetworkListener("redirect-listener",
                Strings.isBlank(SETTINGS.hostname) ? NetworkListener.DEFAULT_NETWORK_HOST : SETTINGS.hostname,
                SETTINGS.portHTTP));
    }
    webserver.addListener(networkListener);
    networkListener.registerAddOn(new WebSocketAddOn());
    webserver.start();

    LOGGER.info("Setting up caching...");
    Cache.init();

    if (SETTINGS.users.isEmpty()) {
        adminKey = UUID.randomUUID().toString();
        LOGGER.warn("Your userlist is empty.");
        LOGGER.warn("Make a new account and use the special admin token in the '2 + 2 = ?' field.");
        LOGGER.warn(
                "You can only use this key once. It will be regenerated if the userlist is empty when the backend starts.");
        LOGGER.warn("Admin token: " + adminKey);
    }

    LOGGER.info("Use the help command for help.");

    CommandHandler.init();
    for (Server server : SETTINGS.servers.values()) {
        server.init();
        if (server.getRestartingInfo().autoStart) {
            try {
                server.startServer();
            } catch (Exception ignored) {
                ignored.printStackTrace();
            }
        }
    }
}

From source file:uk.ac.kcl.Main.java

public static void main(String[] args) {
    File folder = new File(args[0]);
    File[] listOfFiles = folder.listFiles();
    assert listOfFiles != null;
    for (File listOfFile : listOfFiles) {
        if (listOfFile.isFile()) {
            if (listOfFile.getName().endsWith(".properties")) {
                System.out.println("Properties sile found:" + listOfFile.getName()
                        + ". Attempting to launch application context");
                Properties properties = new Properties();
                InputStream input;
                try {
                    input = new FileInputStream(listOfFile);
                    properties.load(input);
                    if (properties.getProperty("globalSocketTimeout") != null) {
                        TcpHelper.setSocketTimeout(
                                Integer.valueOf(properties.getProperty("globalSocketTimeout")));
                    }/*w w  w.j a  va 2 s. c  om*/
                    Map<String, Object> map = new HashMap<>();
                    properties.forEach((k, v) -> {
                        map.put(k.toString(), v);
                    });
                    ConfigurableEnvironment environment = new StandardEnvironment();
                    MutablePropertySources propertySources = environment.getPropertySources();
                    propertySources.addFirst(new MapPropertySource(listOfFile.getName(), map));
                    @SuppressWarnings("resource")
                    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
                    ctx.registerShutdownHook();
                    ctx.setEnvironment(environment);
                    String scheduling;
                    try {
                        scheduling = properties.getProperty("scheduler.useScheduling");
                        if (scheduling.equalsIgnoreCase("true")) {
                            ctx.register(ScheduledJobLauncher.class);
                            ctx.refresh();
                        } else if (scheduling.equalsIgnoreCase("false")) {
                            ctx.register(SingleJobLauncher.class);
                            ctx.refresh();
                            SingleJobLauncher launcher = ctx.getBean(SingleJobLauncher.class);
                            launcher.launchJob();
                        } else if (scheduling.equalsIgnoreCase("slave")) {
                            ctx.register(JobConfiguration.class);
                            ctx.refresh();
                        } else {
                            throw new RuntimeException(
                                    "useScheduling not configured. Must be true, false or slave");
                        }
                    } catch (NullPointerException ex) {
                        throw new RuntimeException(
                                "useScheduling not configured. Must be true, false or slave");
                    }
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}