Example usage for java.util Arrays asList

List of usage examples for java.util Arrays asList

Introduction

In this page you can find the example usage for java.util Arrays asList.

Prototype

@SafeVarargs
@SuppressWarnings("varargs")
public static <T> List<T> asList(T... a) 

Source Link

Document

Returns a fixed-size list backed by the specified array.

Usage

From source file:com.revo.deployr.client.example.data.io.auth.discrete.exec.ExternalDataInDataFileOut.java

public static void main(String args[]) throws Exception {

    RClient rClient = null;/*from w  w  w. j  a va  2 s . co m*/

    try {

        /*
         * Determine DeployR server endpoint.
         */
        String endpoint = System.getProperty("endpoint");
        log.info("[ CONFIGURATION  ] Using endpoint=" + endpoint);

        /*
         * Establish RClient connection to DeployR server.
         *
         * An RClient connection is the mandatory starting
         * point for any application using the client library.
         */
        rClient = RClientFactory.createClient(endpoint);

        log.info("[   CONNECTION   ] Established anonymous " + "connection [ RClient ].");

        /*
         * Build a basic authentication token.
         */
        RAuthentication rAuth = new RBasicAuthentication(System.getProperty("username"),
                System.getProperty("password"));

        /*
         * Establish an authenticated handle with the DeployR
         * server, rUser. Following this call the rClient 
         * connection is operating as an authenticated connection
         * and all calls on rClient inherit the access permissions
         * of the authenticated user, rUser.
         */
        RUser rUser = rClient.login(rAuth);
        log.info("[ AUTHENTICATION ] Upgraded to authenticated " + "connection [ RUser ].");

        /*
         * Create the AnonymousProjectExecutionOptions object
         * to specify data inputs and output to the script.
         *
         * This options object can be used to pass standard
         * execution model parameters on execution calls. All
         * fields are optional.
         *
         * See the Standard Execution Model chapter in the
         * Client Library Tutorial on the DeployR website for
         * further details.
         */
        AnonymousProjectExecutionOptions options = new AnonymousProjectExecutionOptions();

        /* 
         * Load an R object literal "hipStarUrl" into the
         * workspace prior to script execution.
         *
         * The R script checks for the existence of "hipStarUrl"
         * in the workspace and if present uses the URL path
         * to load the Hipparcos star dataset from the DAT file
         * at that location.
         */
        RData hipStarUrl = RDataFactory.createString("hipStarUrl", HIP_DAT_URL);
        List<RData> rinputs = Arrays.asList(hipStarUrl);
        options.rinputs = rinputs;

        log.info("[   DATA INPUT   ] External data source input "
                + "set on execution, [ ProjectExecutionOptions.rinputs ].");

        /*
         * Execute an analytics Web service as an authenticated
         * user based on a repository-managed R script:
         * /testuser/example-data-io/dataIO.R
         */
        RScriptExecution exec = rClient.executeScript("dataIO.R", "example-data-io", "testuser", null, options);

        log.info("[   EXECUTION    ] Discrete R script " + "execution completed [ RScriptExecution ].");

        /*
         * Retrieve the working directory file (artifact) called
         * hip.csv that was generated by the execution.
         *
         * Outputs generated by an execution can be used in any
         * number of ways by client applications, including:
         *
         * 1. Use output data to perform further calculations.
         * 2. Display output data to an end-user.
         * 3. Write output data to a database.
         * 4. Pass output data along to another Web service.
         * 5. etc.
         */
        List<RProjectFile> wdFiles = exec.about().artifacts;

        for (RProjectFile wdFile : wdFiles) {
            if (wdFile.about().filename.equals("hip.csv")) {
                log.info("[  DATA OUTPUT   ] Retrieved working directory " + "file output "
                        + wdFile.about().filename + " [ RProjectFile ].");
                InputStream fis = null;
                try {
                    fis = wdFile.download();
                } catch (Exception ex) {
                    log.warn("Working directory data file " + ex);
                } finally {
                    IOUtils.closeQuietly(fis);
                }
            }
        }

    } catch (Exception ex) {
        log.warn("Unexpected runtime exception=" + ex);
    } finally {
        try {
            if (rClient != null) {
                /*
                 * Release rClient connection before application exits.
                 */
                rClient.release();
            }
        } catch (Exception fex) {
        }
    }

}

From source file:TestDumpRecord.java

public static void main(String[] args) throws NITFException {
    List<String> argList = Arrays.asList(args);
    List<File> files = new LinkedList<File>();
    for (String arg : argList) {
        File f = new File(arg);
        if (f.isDirectory()) {
            File[] dirFiles = f.listFiles(new FilenameFilter() {
                public boolean accept(File dir, String name) {
                    String ext = FilenameUtils.getExtension(name).toLowerCase();
                    return ext.matches("nitf|nsf|ntf");
                }/*from  w  w  w .  j  ava2 s  . c  o m*/
            });
            files.addAll(Arrays.asList(dirFiles));
        } else
            files.add(f);
    }

    Reader reader = new Reader();
    for (File file : files) {
        PrintStream out = System.out;

        out.println("=== " + file.getAbsolutePath() + " ===");
        IOHandle handle = new IOHandle(file.getAbsolutePath());
        Record record = reader.read(handle);
        dumpRecord(record, reader, out);
        handle.close();

        record.destruct(); // tells the memory manager to decrement the ref
        // count
    }
}

From source file:cu.uci.uengine.amqp.SubmitsListener.java

public static final void main(String[] args) throws IOException {
    AnnotationConfigApplicationContext appCtx = new AnnotationConfigApplicationContext(Config.class);

    //TODO: @Lan refactorizar esto, sobre todo quitar la variable isDebuguin esttica y hacer un mecanismo ms prctico.
    if (args.length > 0) {
        isDebugging = Arrays.asList(args).contains("debug");
        if (isDebugging) {
            log.info("DEBUGGING IS ENABLED!!");
        }//w  w  w .j  av a  2 s  . com
    }
}

From source file:appmain.AppMain.java

public static void main(String[] args) {

    try {/*from  w ww. ja v  a  2  s  . co m*/
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        UIManager.put("OptionPane.yesButtonText", "Igen");
        UIManager.put("OptionPane.noButtonText", "Nem");
    } catch (Exception ex) {
        ex.printStackTrace();
    }

    try {

        AppMain app = new AppMain();
        app.init();

        File importFolder = new File(DEFAULT_IMPORT_FOLDER);
        if (!importFolder.isDirectory() || !importFolder.exists()) {
            JOptionPane.showMessageDialog(null,
                    "Az IMPORT mappa nem elrhet!\n"
                            + "Ellenrizze az elrsi utat s a jogosultsgokat!\n" + "Mappa: "
                            + importFolder.getAbsolutePath(),
                    "Informci", JOptionPane.INFORMATION_MESSAGE);
            return;
        }

        File exportFolder = new File(DEFAULT_EXPORT_FOLDER);
        if (!exportFolder.isDirectory() || !exportFolder.exists()) {
            JOptionPane.showMessageDialog(null,
                    "Az EXPORT mappa nem elrhet!\n"
                            + "Ellenrizze az elrsi utat s a jogosultsgokat!\n" + "Mappa: "
                            + exportFolder.getAbsolutePath(),
                    "Informci", JOptionPane.INFORMATION_MESSAGE);
            return;
        }

        List<File> xmlFiles = app.getXMLFiles(importFolder);
        if (xmlFiles == null || xmlFiles.isEmpty()) {
            JOptionPane.showMessageDialog(null,
                    "Nincs beolvasand XML fjl!\n" + "Mappa: " + importFolder.getAbsolutePath(),
                    "Informci", JOptionPane.INFORMATION_MESSAGE);
            return;
        }

        StringBuilder fileList = new StringBuilder();
        xmlFiles.stream().forEach(xml -> fileList.append("\n").append(xml.getName()));
        int ret = JOptionPane.showConfirmDialog(null,
                "Beolvassra elksztett fjlok:\n" + fileList + "\n\nIndulhat a feldolgozs?",
                "Megtallt XML fjlok", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);

        if (ret == JOptionPane.OK_OPTION) {
            String csvName = "tranzakcio_lista_" + df.format(new Date()) + "_" + System.currentTimeMillis()
                    + ".csv";
            File csv = new File(DEFAULT_EXPORT_FOLDER + "/" + csvName);
            app.writeCSV(csv, Arrays.asList(app.getHeaderLine()));
            xmlFiles.stream().forEach(xml -> {
                List<String> lines = app.readXMLData(xml);
                if (lines != null)
                    app.writeCSV(csv, lines);
            });
            if (csv.isFile() && csv.exists()) {
                JOptionPane.showMessageDialog(null,
                        "A CSV fjl sikeresen elllt!\n" + "Fjl: " + csv.getAbsolutePath(),
                        "Informci", JOptionPane.INFORMATION_MESSAGE);
                app.openFile(csv);
            }
        } else {
            JOptionPane.showMessageDialog(null, "Feldolgozs megszaktva!", "Informci",
                    JOptionPane.INFORMATION_MESSAGE);
        }

    } catch (Exception ex) {
        JOptionPane.showMessageDialog(null, "Nem kezelt kivtel!\n" + ExceptionUtils.getStackTrace(ex), "Hiba",
                JOptionPane.ERROR_MESSAGE);
    }

}

From source file:com.yahoo.semsearch.fastlinking.DPSearch.java

@SuppressWarnings("unchecked")
public static void main(String[] args) {
    String[] A0 = new String[] { "Huma_Abedin", "Huma_bird", "Uniform_memory_access" };
    String[] A1 = new String[] { "Hillary_Clinton", "Bill_Clinton", "Edmund_Hillary",
            "Political_positions_of_Hillary_Clinton", "Clinton_Iowa", "Clinton_Massachusetts" };
    String[] A2 = new String[] { "Bill_Clinton", "Hillary_Clinton", "Clinton_Iowa", "Clinton_Massachusetts",
            "Clinton_Mississippi" };
    String[] A3 = new String[] { "Elijah_Cummings", "Elijah", "Jason_Cummings", "Bobby_Cummings" };
    String[] A4 = new String[] { "Huma_Abedin", "Minhajul_Abedin" };

    String[] A5 = new String[] { "Bill_Clinton", "Hillary_Clinton", "Clinton_Iowa", "Clinton_Massachusetts",
            "Clinton_Mississippi" };

    String[] surfaceStrings = new String[] { "Abedin", "Hillary Clinton", "Clinton", "Elijah Cummings",
            "Abedin", "Clinton" };

    CoherentEntityLinker coherentEntityLinker = new CoherentEntityLinker(args[0]);

    ArrayList<String> nBestList[] = new ArrayList[] { new ArrayList<String>(Arrays.asList(A0)),
            new ArrayList<String>(Arrays.asList(A1)), new ArrayList<String>(Arrays.asList(A2)),
            new ArrayList<String>(Arrays.asList(A3)), new ArrayList<String>(Arrays.asList(A4)),
            new ArrayList<String>(Arrays.asList(A5)) };

    ArrayList<String> nBestListReverse[] = new ArrayList[] { new ArrayList<String>(Arrays.asList(A5)),
            new ArrayList<String>(Arrays.asList(A4)), new ArrayList<String>(Arrays.asList(A3)),
            new ArrayList<String>(Arrays.asList(A2)), new ArrayList<String>(Arrays.asList(A1)),
            new ArrayList<String>(Arrays.asList(A0)) };

    /*//from   w ww.  j  a  v a2s. c  om
    // Print bestForwardPath and bestBackwardPath
    String bestForwardPath = coherentEntityLinker.bestForwardPath(nBestList, surfaceStrings);
    System.out.println("\nbestForwardPath: " + bestForwardPath);
            
    String bestBackwardPath = coherentEntityLinker.bestBackwardPath(nBestList, surfaceStrings);
    System.out.println("\nbestBackwardPath: " + bestBackwardPath);
    */

    DPSearch forwardPath = coherentEntityLinker.dynamicProgrammingSearch(nBestList, surfaceStrings);
    DPSearch backwardPath = coherentEntityLinker.dynamicProgrammingSearch(nBestListReverse,
            coherentEntityLinker.reverseArray(surfaceStrings));

    String bestPath = coherentEntityLinker.bestMergedPath(forwardPath.logSimilarity, backwardPath.logSimilarity,
            nBestList);
    System.out.println(bestPath);
}

From source file:EVT.java

/**
 * @param args/*from w  w w  .  j  a v a2s  .c o m*/
 */
public static void main(final String[] args) throws MalformedURLException {
    try {
        URL url = new EVT().getClass().getClassLoader().getResource("general.properties");
        config = new PropertiesConfiguration(url);

    } catch (ConfigurationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        System.exit(1);
    }
    final Map parameters = parseParameters(args);

    if (parameters.containsKey("-v"))
        verboseMode = 1;
    if (parameters.containsKey("-V") || parameters.containsKey("-vv"))
        verboseMode = 2;
    //the from version and the to version must be put in property file
    String supportedVersions = PropertiesUtil.concatenatePropsValues(config, ALFRESCO_VERSION, ",");
    List<String> supportedVersionsList = Arrays.asList(supportedVersions.split(","));
    String alfrescoVersion = (String) parameters.get(ALFRESCO_VERSION);
    boolean supportedVersion = (alfrescoVersion != null) && supportedVersionsList.contains(alfrescoVersion);

    System.out.println(
            "\nAlfresco Environment Validation Tool (for Alfresco Enterprise " + supportedVersions + ")");
    System.out.println("------------------------------------------------------------------");

    if (parameters.isEmpty() || parameters.containsKey("-?") || parameters.containsKey("--help")
            || parameters.containsKey("/?") || !parameters.containsKey(DBValidator.PARAMETER_DATABASE_TYPE)
            || !parameters.containsKey(DBValidator.PARAMETER_DATABASE_HOSTNAME)
            || !parameters.containsKey(DBValidator.PARAMETER_DATABASE_LOGIN)
            || !parameters.containsKey(ALFRESCO_VERSION)
            || !parameters.containsKey(IndexDiskSpeedValidator.PARAMETER_DISK_LOCATION)) {
        System.out.println("");
        System.out.println("usage: evt[.sh|.cmd] [-?|--help] [-v] [-V|-vv]");
        System.out.println("            -a alfrescoversion -t databaseType -h databaseHost [-r databasePort]");
        System.out.println(
                "            [-d databaseName] -l databaseLogin [-p databasePassword] -i indexlocation");
        System.out.println("");
        System.out.println("where:      -?|--help        - display this help");
        System.out.println("            -v               - produce verbose output");
        System.out.println("            -V|-vv           - produce super-verbose output (stack traces)");
        System.out.println(
                "            alfrescoversion  - Version for which the verification is made .  May be one of:");
        System.out.println(
                "                               4.0.0,4.0.1,4.0.2,4.1.1,4.1.2,4.1.3,4.1.4,4.1.5,4.1.6,4.2");
        System.out.println("            databaseType     - the type of database.  May be one of:");
        System.out.println("                               mysql, postgresql, oracle, mssqlserver, db2");
        System.out.println("            databaseHost     - the hostname of the database server");
        System.out.println("            databasePort     - the port the database is listening on (optional -");
        System.out.println("                               defaults to default for the database type)");
        System.out.println("            databaseName     - the name of the Alfresco database (optional -");
        System.out.println("                               defaults to 'alfresco')");
        System.out.println("            databaseLogin    - the login Alfresco will use to connect to the");
        System.out.println("                               database");
        System.out.println("            databasePassword - the password for that user (optional)");
        System.out.println(
                "            indexlocation    - a path to a folder that will contain Alfresco indexes");
        System.out.println("");
        System.out.println("The tool must be run as the OS user that Alfreso will run as.  In particular");
        System.out.println("it will report erroneous results if run as \"root\" (or equivalent on other");
        System.out.println("OSes) if Alfresco is not intended to be run as that user.");
        System.out.println("");
    } else if (!supportedVersion) {
        System.out.println("");
        System.out.println("Version " + alfrescoVersion
                + " is not in the list of the Alfresco versions supported by this tool.");
        System.out.println("Please specify one of the following versions: " + supportedVersions);
    } else {
        final StdoutValidatorCallback callback = new StdoutValidatorCallback();

        (new AllValidators()).validate(parameters, callback);

        System.out.println("\n\n                         **** FINAL GRADE: "
                + TestResult.typeToString(callback.worstResult) + " ****\n");
    }
}

From source file:hadoopInstaller.Main.java

public static void main(String[] args) {
    // Disable VFS logging to console by default
    System.setProperty("org.apache.commons.logging.Log", //$NON-NLS-1$
            "org.apache.commons.logging.impl.NoOpLog"); //$NON-NLS-1$
    // Configure SimpleLog to show date and omit log name
    System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true"); //$NON-NLS-1$//$NON-NLS-2$
    System.setProperty("org.apache.commons.logging.simplelog.showlogname", "false"); //$NON-NLS-1$//$NON-NLS-2$
    System.setProperty("org.apache.commons.logging.simplelog.showShortLogname", "false"); //$NON-NLS-1$//$NON-NLS-2$
    try (PrintStream filePrintStream = new PrintStream(VFS.getManager()
            .resolveFile(MessageFormat.format("file://{0}/{1}", //$NON-NLS-1$
                    System.getProperty("user.dir"), Main.FILE_LOG_NAME)) //$NON-NLS-1$
            .getContent().getOutputStream(true))) {

        CompositeLog log = new CompositeLog();
        Integer logLevel = detectLogLevel(args);
        PrintStreamLog consoleLog = new PrintStreamLog(Installer.INSTALLER_NAME, System.out);
        consoleLog.setLevel(logLevel);/*from  ww  w .  j a  va 2s  .c om*/
        log.addLog(consoleLog);
        PrintStreamLog fileLog = new PrintStreamLog(Installer.INSTALLER_NAME, filePrintStream);
        fileLog.setLevel(logLevel);
        log.addLog(fileLog);
        boolean deploy = Arrays.asList(args).contains("-deploy"); //$NON-NLS-1$
        try {
            new Installer(log, deploy).run();
        } catch (InstallationFatalError e) {
            log.fatal(e.getLocalizedMessage());
            log.fatal(e.getCause().getLocalizedMessage());
            log.trace(e.getLocalizedMessage(), e);
        }
    } catch (FileSystemException e) {
        new PrintStreamLog(Installer.INSTALLER_NAME, System.err).fatal(e.getLocalizedMessage(), e);
        System.exit(1);
    }

    /*
     * TODO-- ssh-ask
     * 
     * Consider using a configuration that doesn't require password-less
     * authentication, but set's it up for the final cluster.
     */
}

From source file:com.uimirror.auth.StartApp.java

/**
 * Application entry point.// ww w  . j  a  v  a  2  s. com
 * @param args command line args
 */
public static void main(final String[] args) {
    LOG.info("CmdLine Args {}", Arrays.asList(args));
    try {
        SpringApplication sa = new SpringApplication(new Object[] { StartApp.class });
        sa.run(args);

    } catch (Exception e) {
        LOG.error("Unexpected error", e);
    }
}

From source file:com.example.bigtable.simplecli.HBaseCLI.java

/**
 * The main method for the CLI. This method takes the command line
 * arguments and runs the appropriate commands.
 *///from w w w  .  j a v  a 2 s.  c om
public static void main(String[] args) {
    // We use Apache commons-cli to check for a help option.
    Options options = new Options();
    Option help = new Option("help", "print this message");
    options.addOption(help);

    // create the parser
    CommandLineParser parser = new BasicParser();
    CommandLine line = null;
    try {
        // parse the command line arguments
        line = parser.parse(options, args);
    } catch (ParseException exp) {
        // oops, something went wrong
        System.err.println(exp.getMessage());
        usage();
        System.exit(1);
    }

    // Create a list of commands that are supported. Each
    // command defines a run method and some methods for
    // printing help.
    // See the definition of each command below.
    HashMap<String, Command> commands = new HashMap<String, Command>();
    commands.put("create", new CreateCommand("create"));
    commands.put("scan", new ScanCommand("scan"));
    commands.put("get", new GetCommand("get"));
    commands.put("put", new PutCommand("put"));
    commands.put("list", new ListCommand("list"));

    Command command = null;
    List<String> argsList = Arrays.asList(args);
    if (argsList.size() > 0) {
        command = commands.get(argsList.get(0));
    }

    // Check for the help option and if it's there
    // display the appropriate help.
    if (line.hasOption("help")) {
        // If there is a command listed (e.g. create -help)
        // then show the help for that command
        if (command == null) {
            help(commands.values());
        } else {
            help(command);
        }
        System.exit(0);
    } else if (command == null) {
        // No valid command was given so print the usage.
        usage();
        System.exit(0);
    }

    try {
        Connection connection = ConnectionFactory.createConnection();

        try {
            try {
                // Run the command with the arguments after the command name.
                command.run(connection, argsList.subList(1, argsList.size()));
            } catch (InvalidArgsException e) {
                System.out.println("ERROR: Invalid arguments");
                usage(command);
                System.exit(0);
            }
        } finally {
            // Make sure the connection is closed even if
            // an exception occurs.
            connection.close();
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:com.uimirror.image.StartApp.java

/**
 * Application entry point.//from   w  w  w.j  ava2 s.c om
 * @param args command line args
 */
public static void main(final String[] args) {
    LOG.info("CmdLine Args {}", Arrays.asList(args));
    try {
        SpringApplication sa = new SpringApplication(new Object[] { StartApp.class });
        sa.run(args);
    } catch (Exception e) {
        LOG.error("Unexpected error", e);
    }
}