List of usage examples for java.util Arrays asList
@SafeVarargs @SuppressWarnings("varargs") public static <T> List<T> asList(T... a)
From source file:cz.muni.fi.mir.mathmlunificator.MathMLUnificatorCommandLineTool.java
/** * Main (starting) method of the command line application. * * @param argv Array of command line arguments that are expected to be * filesystem paths to input XML documents with MathML to be unified. * @throws ParserConfigurationException If a XML DOM builder cannot be * created with the configuration requested. *///from w w w. j a va 2s .c o m public static void main(String argv[]) throws ParserConfigurationException { final Options options = new Options(); options.addOption("p", "operator-unification", false, "unify operator in addition to other types of nodes"); options.addOption("h", "help", false, "print help"); final CommandLineParser parser = new DefaultParser(); CommandLine line = null; try { line = parser.parse(options, argv); } catch (ParseException ex) { printHelp(options); System.exit(1); } if (line != null) { if (line.hasOption('h')) { printHelp(options); System.exit(0); } operatorUnification = line.hasOption('p'); final List<String> arguments = Arrays.asList(line.getArgs()); if (arguments.size() > 0) { Document outerDocument = DOMBuilder.getDocumentBuilder().newDocument(); Node rootNode = outerDocument.createElementNS(UNIFIED_MATHML_NS, UNIFIED_MATHML_NS_PREFIX + ":" + UNIFIED_MATHML_BATCH_OUTPUT_ROOT_ELEM); outerDocument.appendChild(rootNode); for (String filepath : arguments) { try { Document doc = DOMBuilder.buildDocFromFilepath(filepath); MathMLUnificator.unifyMathML(doc, operatorUnification); if (arguments.size() == 1) { xmlStdoutSerializer(doc); } else { Node itemNode = rootNode.getOwnerDocument().createElementNS(UNIFIED_MATHML_NS, UNIFIED_MATHML_NS_PREFIX + ":" + UNIFIED_MATHML_BATCH_OUTPUT_ITEM_ELEM); Attr filenameAttr = itemNode.getOwnerDocument().createAttributeNS(UNIFIED_MATHML_NS, UNIFIED_MATHML_NS_PREFIX + ":" + UNIFIED_MATHML_BATCH_OUTPUT_ITEM_FILEPATH_ATTR); filenameAttr.setTextContent(String.valueOf(filepath)); ((Element) itemNode).setAttributeNodeNS(filenameAttr); itemNode.appendChild( rootNode.getOwnerDocument().importNode(doc.getDocumentElement(), true)); rootNode.appendChild(itemNode); } } catch (SAXException | IOException ex) { Logger.getLogger(MathMLUnificatorCommandLineTool.class.getName()).log(Level.SEVERE, "Failed processing of file: " + filepath, ex); } } if (rootNode.getChildNodes().getLength() > 0) { xmlStdoutSerializer(rootNode.getOwnerDocument()); } } else { printHelp(options); System.exit(0); } } }
From source file:edu.scripps.fl.pubchem.app.AssayDownloader.java
public static void main(String[] args) throws Exception { CommandLineHandler clh = new CommandLineHandler() { public void configureOptions(Options options) { options.addOption(OptionBuilder.withLongOpt("data_url").withType("").withValueSeparator('=') .hasArg().create()); options.addOption(// ww w.j av a 2s .co m OptionBuilder.withLongOpt("days").withType(0).withValueSeparator('=').hasArg().create()); options.addOption(OptionBuilder.withLongOpt("mlpcn").withType(false).create()); options.addOption(OptionBuilder.withLongOpt("notInDb").withType(false).create()); } }; args = clh.handle(args); String data_url = clh.getCommandLine().getOptionValue("data_url"); if (null == data_url) data_url = "ftp://ftp.ncbi.nlm.nih.gov/pubchem/Bioassay/CSV/"; // data_url = "file:///C:/Home/temp/PubChemFTP/"; AssayDownloader main = new AssayDownloader(); main.dataUrl = new URL(data_url); if (clh.getCommandLine().hasOption("days")) main.days = Integer.parseInt(clh.getCommandLine().getOptionValue("days")); if (clh.getCommandLine().hasOption("mlpcn")) main.mlpcn = true; if (clh.getCommandLine().hasOption("notInDb")) main.notInDb = true; if (args.length == 0) main.process(); else { Long[] list = (Long[]) ConvertUtils.convert(args, Long[].class); List<Long> l = (List<Long>) Arrays.asList(list); log.info("AID to process: " + l); main.process(new HashSet<Long>(Arrays.asList(list))); } }
From source file:fr.ens.biologie.genomique.toullig.Main.java
/** * The main function parse the options of the command line */// w ww . java2s.c o m public static void main(String[] args) { // make options final Options options = makeOptions(); // make parser of the command line final CommandLineParser parser = new GnuParser(); try { // parse the command line arguments final CommandLine line = parser.parse(options, args, true); // test if no arguments is given if (args.length == 0) { showErrorMessageAndExit( "ERROR: Toullig need in the first argument the tool what you want use!\nSee the help with " + Globals.APP_NAME_LOWER_CASE + ".sh -h, --help\n"); } // display help if (line.hasOption("help")) { help(); } // About option if (line.hasOption("about")) { Common.showMessageAndExit(Globals.ABOUT_TXT); } // Version option if (line.hasOption("version")) { Common.showMessageAndExit(Globals.WELCOME_MSG); } // Licence option if (line.hasOption("license")) { Common.showMessageAndExit(Globals.LICENSE_TXT); } String mode = args[0]; switch (mode) { // process fast5tofastq module case "fast5tofastq": new Fast5tofastqAction().action(new ArrayList<>(Arrays.asList(args)).subList(1, args.length)); break; // display help default: showMessageAndExit("ERROR: The name of the tool is not correct!\nSee the help with " + Globals.APP_NAME_LOWER_CASE + ".sh -h, --help\n"); break; // process trim module case "trim": new TrimAction().action(new ArrayList<>(Arrays.asList(args)).subList(1, args.length)); break; // process gtftogpd module case "gtftogpd": new GtftogpdAction().action(new ArrayList<>(Arrays.asList(args)).subList(1, args.length)); break; // // process test module // case "test": // new SamDiffAnnot(); // break; } } catch (ParseException e) { e.printStackTrace(); } }
From source file:cn.webank.ecif.index.server.EcifIndexServer.java
/** * @param args//from ww w . jav a2 s .c o m */ public static void main(String[] args) { final EcifIndexServer server = new EcifIndexServer(); // start spring context; final ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(); context.getEnvironment().setActiveProfiles("product"); context.setConfigLocation("application.xml"); context.refresh(); context.start(); // thread pool construct ThreadPoolTaskExecutor taskThreadPool = context.getBean("taskExecutor", ThreadPoolTaskExecutor.class); server.setTaskThreadPool(taskThreadPool); ExecutorService fixedThreadPool = context.getBean("fixedTaskExecutor", ExecutorService.class); server.setSchedulerThreadPool(fixedThreadPool); EcifThreadFactory threadFactory = context.getBean("cn.webank.ecif.index.async.EcifThreadFactory", EcifThreadFactory.class); server.setThreadFactory(threadFactory); Properties props = context.getBean("ecifProperties", java.util.Properties.class); WeBankServiceDispatcher serviceDispatcher = context.getBean( "cn.webank.framework.biz.service.support.WeBankServiceDispatcher", WeBankServiceDispatcher.class); ReloadableResourceBundleMessageSource bundleMessageSource = context.getBean("messageSource", ReloadableResourceBundleMessageSource.class); String topics = props.getProperty("listener.topics"); String[] splits = topics.split(","); SolaceManager solaceManager = context.getBean("cn.webank.framework.message.SolaceManager", SolaceManager.class); MessageListener messageLisener = new MessageListener( // props.getProperty("listener.queue"), Arrays.asList(splits), Integer.parseInt(props.getProperty("listener.scanintervalseconds", "5")), taskThreadPool, Integer.parseInt(props.getProperty("listener.timeoutseconds", "5")), serviceDispatcher, solaceManager, bundleMessageSource); server.addListenerOnSchedule(messageLisener); // register shutdownhook Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { try { // close resource if (context != null) { context.close(); } } catch (Exception e) { LOG.error("shutdown error", e); } } }); // hold server try { LOG.info("ecif-index server start ok!"); server.start(); } catch (Exception e) { try { // close resource server.shutDown(); if (context != null) { context.close(); } } catch (Exception ex) { LOG.error("shutdown error", ex); } } LOG.info("ecif-index server stop !"); }
From source file:com.slothpetrochemical.bridgeprob.BridgeProblemApp.java
public static void main(final String[] args) throws ParseException { Options commandLineOptions = createOptions(); PosixParser clParser = new PosixParser(); CommandLine cl = clParser.parse(commandLineOptions, args); if (cl.getArgs().length == 0 || cl.hasOption("h")) { new HelpFormatter().printHelp("crossing_times...", commandLineOptions); } else {/*from w ww . j ava2s .com*/ String[] clArgs = cl.getArgs(); Integer[] times = new Integer[clArgs.length]; for (int i = 0; i < clArgs.length; ++i) { Integer intTime = Integer.parseInt(clArgs[i]); times[i] = intTime; } Arrays.sort(times); BridgeProblemApp app = new BridgeProblemApp(Arrays.asList(times)); app.run(); } }
From source file:org.hbz.oerworldmap.NtToEs.java
public static void main(String... args) throws FileNotFoundException, IOException { if (args.length != 1 && args.length != 2) { System.out.println("Pass the root directory to crawl. " + "Will recursively gather all content from *.nt " + "files with identical names, convert these to " + "compact JSON-LD and index it in ES. " + "If a second argument is passed it is processed " + "as a TSV file that maps file names (w/o " + "extensions) to IDs to be used for ES. Else the " + "file names (w/o extensions) are used."); args = new String[] { "output", "src/main/resources/internalId2uuid.tsv" }; System.out.println("Using defaults: " + Arrays.asList(args)); }//ww w . j a v a 2s . c o m if (args.length == 2) initMap(args[1]); TripleCrawler crawler = new TripleCrawler(); Files.walkFileTree(Paths.get(args[0]), crawler); createIndex(config(), INDEX); process(crawler.data); }
From source file:hydrograph.server.execution.tracking.client.main.HydrographMain.java
/** * The main method.//from w ww . ja v a 2 s. c o m * * @param args * the arguments * @throws Exception * the exception */ public static void main(String[] args) throws Exception { HydrographMain hydrographMain = new HydrographMain(); final Timer timer = new Timer(); final CountDownLatch latch = new CountDownLatch(1); try { Session session = null; boolean isExecutionTracking = false; String[] argsList = args; List<String> argumentList = new ArrayList<String>(Arrays.asList(args)); final String jobId = hydrographMain.getJobId(argumentList); getLogLevel(argumentList).ifPresent(x -> { if (!x.equalsIgnoreCase(String.valueOf(logger.getLevel()))) { setLoglevel(x); } else { Optional.empty(); } }); logger.info("Argument List: " + argumentList.toString()); String trackingClientSocketPort = hydrographMain.getTrackingClientSocketPort(argumentList); if (argumentList.contains(Constants.IS_TRACKING_ENABLE)) { int index = argumentList.indexOf(Constants.IS_TRACKING_ENABLE); isExecutionTracking = Boolean.valueOf(argsList[index + 1]); argumentList = removeItemFromIndex(index, argumentList); } if (argumentList.contains(Constants.TRACKING_CLIENT_SOCKET_PORT)) { int index = argumentList.indexOf(Constants.TRACKING_CLIENT_SOCKET_PORT); argumentList = removeItemFromIndex(index, argumentList); } argsList = argumentList.toArray(new String[argumentList.size()]); logger.debug("Execution tracking enabled - " + isExecutionTracking); logger.info("Tracking Client Port: " + trackingClientSocketPort); /** * Start new thread to run job */ final HydrographService execution = new HydrographService(); FutureTask task = hydrographMain.executeGraph(latch, jobId, argsList, execution, isExecutionTracking); hydrographMain.executorService = Executors.newSingleThreadExecutor(); hydrographMain.executorService.submit(task); if (isExecutionTracking) { //If tracking is enabled, start to post execution tracking status. final HydrographEngineCommunicatorSocket socket = new HydrographEngineCommunicatorSocket(execution); session = hydrographMain.connectToServer(socket, jobId, trackingClientSocketPort); hydrographMain.sendExecutionTrackingStatus(latch, session, jobId, timer, execution, socket); } //waiting for execute graph thread task.get(); } catch (Exception exp) { logger.info("Getting exception from HydrographMain"); throw new RuntimeException(exp); } finally { //cleanup threads --> executor thread and timer thread logger.info("HydrographMain releasing resources"); if (!hydrographMain.executorService.isShutdown() && !hydrographMain.executorService.isTerminated()) { hydrographMain.executorService.shutdown(); } timer.cancel(); } }
From source file:MailHandlerDemo.java
/** * Runs the demo.//w w w . ja v a 2s . c o m * * @param args the command line arguments * @throws IOException if there is a problem. */ public static void main(String[] args) throws IOException { List<String> l = Arrays.asList(args); if (l.contains("/?") || l.contains("-?") || l.contains("-help")) { LOGGER.info("Usage: java MailHandlerDemo " + "[[-all] | [-body] | [-custom] | [-debug] | [-low] " + "| [-simple] | [-pushlevel] | [-pushfilter] " + "| [-pushnormal] | [-pushonly]] " + "\n\n" + "-all\t\t: Execute all demos.\n" + "-body\t\t: An email with all records and only a body.\n" + "-custom\t\t: An email with attachments and dynamic names.\n" + "-debug\t\t: Output basic debug information about the JVM " + "and log configuration.\n" + "-low\t\t: Generates multiple emails due to low capacity." + "\n" + "-simple\t\t: An email with all records with body and " + "an attachment.\n" + "-pushlevel\t: Generates high priority emails when the" + " push level is triggered and normal priority when " + "flushed.\n" + "-pushFilter\t: Generates high priority emails when the " + "push level and the push filter is triggered and normal " + "priority emails when flushed.\n" + "-pushnormal\t: Generates multiple emails when the " + "MemoryHandler push level is triggered. All generated " + "email are sent as normal priority.\n" + "-pushonly\t: Generates multiple emails when the " + "MemoryHandler push level is triggered. Generates high " + "priority emails when the push level is triggered and " + "normal priority when flushed.\n"); } else { final boolean debug = init(l); //may create log messages. try { LOGGER.log(Level.FINEST, "This is the finest part of the demo.", new MessagingException("Fake JavaMail issue.")); LOGGER.log(Level.FINER, "This is the finer part of the demo.", new NullPointerException("Fake bug.")); LOGGER.log(Level.FINE, "This is the fine part of the demo."); LOGGER.log(Level.CONFIG, "Logging config file is {0}.", getConfigLocation()); LOGGER.log(Level.INFO, "Your temp directory is {0}, " + "please wait...", getTempDir()); try { //Waste some time for the custom formatter. Thread.sleep(3L * 1000L); } catch (InterruptedException ex) { Thread.currentThread().interrupt(); } LOGGER.log(Level.WARNING, "This is a warning.", new FileNotFoundException("Fake file chooser issue.")); LOGGER.log(Level.SEVERE, "The end of the demo.", new IOException("Fake access denied issue.")); } finally { closeHandlers(); } //Force parse errors. This does have side effects. if (debug && getConfigLocation() != null) { LogManager.getLogManager().readConfiguration(); } } }
From source file:org.dasein.cloud.google.HttpsConnection.java
public static void main(String[] args) throws Exception { JSONArray a = new JSONArray( Arrays.asList(getJSON("676516473943-jt3udkrj247hvsuh1nrfivr5cfn84uio@developer.gserviceaccount.com", "D:\\GCE-privatekey.p12"))); System.out.println("Array : " + a.toString()); }
From source file:com.dattack.dbcopy.cli.DbCopyCli.java
/** * The <code>main</code> method. * * @param args//ww w .j av a 2 s . c o m * the program arguments */ public static void main(final String[] args) { final Options options = createOptions(); try { final CommandLineParser parser = new DefaultParser(); final CommandLine cmd = parser.parse(options, args); final String[] filenames = cmd.getOptionValues(FILE_OPTION); final String[] jobNames = cmd.getOptionValues(JOB_NAME_OPTION); final String[] propertiesFiles = cmd.getOptionValues(PROPERTIES_OPTION); HashSet<String> jobNameSet = null; if (jobNames != null) { jobNameSet = new HashSet<>(Arrays.asList(jobNames)); } CompositeConfiguration configuration = new CompositeConfiguration(); if (propertiesFiles != null) { for (final String fileName : propertiesFiles) { configuration.addConfiguration(new PropertiesConfiguration(fileName)); } } final DbCopyEngine ping = new DbCopyEngine(); ping.execute(filenames, jobNameSet, configuration); } catch (@SuppressWarnings("unused") final ParseException e) { showUsage(options); } catch (final ConfigurationException | DattackParserException e) { System.err.println(e.getMessage()); } }