List of usage examples for java.lang String equals
public boolean equals(Object anObject)
From source file:TopicRequestor.java
/** Main program entry point. */ public static void main(String argv[]) { // Values to be read from parameters String broker = DEFAULT_BROKER_NAME; String username = DEFAULT_USER_NAME; String password = DEFAULT_PASSWORD; // Check parameters for (int i = 0; i < argv.length; i++) { String arg = argv[i]; if (arg.equals("-b")) { if (i == argv.length - 1 || argv[i + 1].startsWith("-")) { System.err.println("error: missing broker name:port"); System.exit(1);//www. ja va2 s . c om } broker = argv[++i]; continue; } if (arg.equals("-u")) { if (i == argv.length - 1 || argv[i + 1].startsWith("-")) { System.err.println("error: missing user name"); System.exit(1); } username = argv[++i]; continue; } if (arg.equals("-p")) { if (i == argv.length - 1 || argv[i + 1].startsWith("-")) { System.err.println("error: missing password"); System.exit(1); } password = argv[++i]; continue; } if (arg.equals("-h")) { printUsage(); System.exit(1); } // Invalid argument System.err.println("error: unexpected argument: " + arg); printUsage(); System.exit(1); } // Start the JMS client for the "chat". TopicRequestor requestor = new TopicRequestor(); requestor.start(broker, username, password); }
From source file:isc_415_practica_1.ISC_415_Practica_1.java
/** * @param args the command line arguments *//*w w w . j a v a2s . co m*/ public static void main(String[] args) { String urlString; Scanner input = new Scanner(System.in); Document doc; try { urlString = input.next(); if (urlString.equals("servlet")) { urlString = "http://localhost:8084/ISC_415_Practica1_Servlet/client"; } urlString = urlString.contains("http://") || urlString.contains("https://") ? urlString : "http://" + urlString; doc = Jsoup.connect(urlString).get(); } catch (Exception ex) { System.out.println("El URL ingresado no es valido."); return; } ArrayList<NameValuePair> formInputParams; formInputParams = new ArrayList<>(); String[] plainTextDoc = new TextNode(doc.html(), "").getWholeText().split("\n"); System.out.println(String.format("Nmero de lineas del documento: %d", plainTextDoc.length)); System.out.println(String.format("Nmero de p tags: %d", doc.select("p").size())); System.out.println(String.format("Nmero de img tags: %d", doc.select("img").size())); System.out.println(String.format("Nmero de form tags: %d", doc.select("form").size())); Integer index = 1; ArrayList<NameValuePair> urlParameters = new ArrayList<>(); for (Element e : doc.select("form")) { System.out.println(String.format("Form %d: Nmero de Input tags %d", index, e.select("input").size())); System.out.println(e.select("input")); for (Element formInput : e.select("input")) { if (formInput.attr("id") != null && formInput.attr("id") != "") { urlParameters.add(new BasicNameValuePair(formInput.attr("id"), "PRACTICA1")); } else if (formInput.attr("name") != null && formInput.attr("name") != "") { urlParameters.add(new BasicNameValuePair(formInput.attr("name"), "PRACTICA1")); } } index++; } if (!urlParameters.isEmpty()) { try { CloseableHttpClient httpclient = HttpClients.createDefault(); UrlEncodedFormEntity entity = new UrlEncodedFormEntity(urlParameters, Consts.UTF_8); HttpPost httpPost = new HttpPost(urlString); httpPost.setHeader("User-Agent", USER_AGENT); httpPost.setEntity(entity); HttpResponse response = httpclient.execute(httpPost); System.out.println(response.getStatusLine()); } catch (IOException ex) { Logger.getLogger(ISC_415_Practica_1.class.getName()).log(Level.SEVERE, null, ex); } } }
From source file:com.joliciel.talismane.TalismaneMain.java
public static void main(String[] args) throws Exception { Map<String, String> argsMap = StringUtils.convertArgs(args); OtherCommand otherCommand = null;//from w ww.j a va 2s. c om if (argsMap.containsKey("command")) { try { otherCommand = OtherCommand.valueOf(argsMap.get("command")); argsMap.remove("command"); } catch (IllegalArgumentException e) { // not anotherCommand } } String sessionId = ""; TalismaneServiceLocator locator = TalismaneServiceLocator.getInstance(sessionId); TalismaneService talismaneService = locator.getTalismaneService(); TalismaneSession talismaneSession = talismaneService.getTalismaneSession(); if (otherCommand == null) { // regular command TalismaneConfig config = talismaneService.getTalismaneConfig(argsMap, sessionId); if (config.getCommand() == null) return; Talismane talismane = config.getTalismane(); talismane.process(); } else { // other command String logConfigPath = argsMap.get("logConfigFile"); if (logConfigPath != null) { argsMap.remove("logConfigFile"); Properties props = new Properties(); props.load(new FileInputStream(logConfigPath)); PropertyConfigurator.configure(props); } switch (otherCommand) { case serializeLexicon: { LexiconSerializer serializer = new LexiconSerializer(); serializer.serializeLexicons(argsMap); break; } case testLexicon: { String lexiconFilePath = null; String[] wordList = null; for (String argName : argsMap.keySet()) { String argValue = argsMap.get(argName); if (argName.equals("lexicon")) { lexiconFilePath = argValue; } else if (argName.equals("words")) { wordList = argValue.split(","); } else { throw new TalismaneException("Unknown argument: " + argName); } } File lexiconFile = new File(lexiconFilePath); LexiconDeserializer lexiconDeserializer = new LexiconDeserializer(talismaneSession); List<PosTaggerLexicon> lexicons = lexiconDeserializer.deserializeLexicons(lexiconFile); for (PosTaggerLexicon lexicon : lexicons) talismaneSession.addLexicon(lexicon); PosTaggerLexicon mergedLexicon = talismaneSession.getMergedLexicon(); for (String word : wordList) { LOG.info("################"); LOG.info("Word: " + word); List<LexicalEntry> entries = mergedLexicon.getEntries(word); for (LexicalEntry entry : entries) { LOG.info(entry + ", Full morph: " + entry.getMorphologyForCoNLL()); } } break; } } } }
From source file:BringUpBrowser.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 3;//from www . j a v a 2 s . c o m shell.setLayout(gridLayout); ToolBar toolbar = new ToolBar(shell, SWT.NONE); ToolItem itemBack = new ToolItem(toolbar, SWT.PUSH); itemBack.setText("Back"); ToolItem itemForward = new ToolItem(toolbar, SWT.PUSH); itemForward.setText("Forward"); ToolItem itemStop = new ToolItem(toolbar, SWT.PUSH); itemStop.setText("Stop"); ToolItem itemRefresh = new ToolItem(toolbar, SWT.PUSH); itemRefresh.setText("Refresh"); ToolItem itemGo = new ToolItem(toolbar, SWT.PUSH); itemGo.setText("Go"); GridData data = new GridData(); data.horizontalSpan = 3; toolbar.setLayoutData(data); Label labelAddress = new Label(shell, SWT.NONE); labelAddress.setText("Address"); final Text location = new Text(shell, SWT.BORDER); data = new GridData(); data.horizontalAlignment = GridData.FILL; data.horizontalSpan = 2; data.grabExcessHorizontalSpace = true; location.setLayoutData(data); final Browser browser = new Browser(shell, SWT.NONE); data = new GridData(); data.horizontalAlignment = GridData.FILL; data.verticalAlignment = GridData.FILL; data.horizontalSpan = 3; data.grabExcessHorizontalSpace = true; data.grabExcessVerticalSpace = true; browser.setLayoutData(data); final Label status = new Label(shell, SWT.NONE); data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalSpan = 2; status.setLayoutData(data); final ProgressBar progressBar = new ProgressBar(shell, SWT.NONE); data = new GridData(); data.horizontalAlignment = GridData.END; progressBar.setLayoutData(data); /* event handling */ Listener listener = new Listener() { public void handleEvent(Event event) { ToolItem item = (ToolItem) event.widget; String string = item.getText(); if (string.equals("Back")) browser.back(); else if (string.equals("Forward")) browser.forward(); else if (string.equals("Stop")) browser.stop(); else if (string.equals("Refresh")) browser.refresh(); else if (string.equals("Go")) browser.setUrl(location.getText()); } }; browser.addProgressListener(new ProgressListener() { public void changed(ProgressEvent event) { if (event.total == 0) return; int ratio = event.current * 100 / event.total; progressBar.setSelection(ratio); } public void completed(ProgressEvent event) { progressBar.setSelection(0); } }); browser.addStatusTextListener(new StatusTextListener() { public void changed(StatusTextEvent event) { status.setText(event.text); } }); browser.addLocationListener(new LocationListener() { public void changed(LocationEvent event) { if (event.top) location.setText(event.location); } public void changing(LocationEvent event) { } }); itemBack.addListener(SWT.Selection, listener); itemForward.addListener(SWT.Selection, listener); itemStop.addListener(SWT.Selection, listener); itemRefresh.addListener(SWT.Selection, listener); itemGo.addListener(SWT.Selection, listener); location.addListener(SWT.DefaultSelection, new Listener() { public void handleEvent(Event e) { browser.setUrl(location.getText()); } }); shell.open(); browser.setUrl("http://eclipse.org"); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:com.qatickets.domain.Version.java
public static void main(String[] a) { // DD, dd MM yyyy // Wednesday, 14 May 2014 String d = new SimpleDateFormat("EEEE, dd MMM yyyy").format(new Date()); System.out.println(d);/*from ww w . j av a 2 s. c o m*/ System.out.println(d.equals("Wednesday, 14 May 2014")); }
From source file:joshelser.as2015.query.Query.java
public static void main(String[] args) throws Exception { JCommander commander = new JCommander(); final Opts options = new Opts(); commander.addObject(options);// w w w . j a v a 2 s . com commander.setProgramName("Query"); try { commander.parse(args); } catch (ParameterException ex) { commander.usage(); System.err.println(ex.getMessage()); System.exit(1); } ClientConfiguration conf = ClientConfiguration.loadDefault(); if (null != options.clientConfFile) { conf = new ClientConfiguration(new PropertiesConfiguration(options.clientConfFile)); } conf.withInstance(options.instanceName).withZkHosts(options.zookeepers); ZooKeeperInstance inst = new ZooKeeperInstance(conf); Connector conn = inst.getConnector(options.user, new PasswordToken(options.password)); BatchScanner bs = conn.createBatchScanner(options.table, Authorizations.EMPTY, 16); try { bs.setRanges(Collections.singleton(new Range())); final Text categoryText = new Text("category"); bs.fetchColumn(categoryText, new Text("name")); bs.fetchColumn(new Text("review"), new Text("score")); bs.fetchColumn(new Text("review"), new Text("userId")); bs.addScanIterator(new IteratorSetting(50, "wri", WholeRowIterator.class)); final Text colf = new Text(); Map<String, List<Integer>> scoresByUser = new HashMap<>(); for (Entry<Key, Value> entry : bs) { SortedMap<Key, Value> row = WholeRowIterator.decodeRow(entry.getKey(), entry.getValue()); Iterator<Entry<Key, Value>> iter = row.entrySet().iterator(); if (!iter.hasNext()) { // row was empty continue; } Entry<Key, Value> categoryEntry = iter.next(); categoryEntry.getKey().getColumnFamily(colf); if (!colf.equals(categoryText)) { throw new IllegalArgumentException("Unknown!"); } if (!categoryEntry.getValue().toString().equals("books")) { // not a book review continue; } if (!iter.hasNext()) { continue; } Entry<Key, Value> reviewScore = iter.next(); if (!iter.hasNext()) { continue; } Entry<Key, Value> reviewUserId = iter.next(); String userId = reviewUserId.getValue().toString(); if (userId.equals("unknown")) { // filter unknow user id continue; } List<Integer> scores = scoresByUser.get(userId); if (null == scores) { scores = new ArrayList<>(); scoresByUser.put(userId, scores); } scores.add(Float.valueOf(reviewScore.getValue().toString()).intValue()); } for (Entry<String, List<Integer>> entry : scoresByUser.entrySet()) { int sum = 0; for (Integer val : entry.getValue()) { sum += val; } System.out.println(entry.getKey() + " => " + new Float(sum) / entry.getValue().size()); } } finally { bs.close(); } }
From source file:Main.java
public static void main(String[] args) { String str1 = "Hello"; String str2 = "HELLO"; if (str1.equalsIgnoreCase(str2)) { System.out.println("Ignoring case str1 and str2 are equal"); } else {//from w w w .j a v a 2 s. co m System.out.println("Ignoring case str1 and str2 are not equal"); } if (str1.equals(str2)) { System.out.println("str1 and str2 are equal"); } else { System.out.println("str1 and str2 are not equal"); } }
From source file:br.com.asisprojetos.mailreport.Main.java
public static void main(String args[]) { logger.debug("Testando debug"); if (args.length < 2) { logger.error("Erro : Numero de parametros errados."); System.exit(1);// ww w . j a va 2 s.c om } String dataIniProc = String.format("%s 00:00:00", args[0]); String dataFimProc = String.format("%s 23:59:59", args[1]); logger.debug("Data Inicial: {} , Data Final: {}", dataIniProc, dataFimProc); String mes = String.format("%s/%s", args[0].substring(5, 7), args[0].substring(0, 4)); ApplicationContext context = new ClassPathXmlApplicationContext("Spring-Datasource.xml"); TBRelatorioEmailDAO tbRelatorioEmailDAO = (TBRelatorioEmailDAO) context.getBean("TBRelatorioEmailDAO"); List<TBRelatorioEmail> listaRelatorioEmail = tbRelatorioEmailDAO.getAll(); for (TBRelatorioEmail tbRelatorioEmail : listaRelatorioEmail) { logger.debug(" CodContrato: {}, CodProduto: {}", tbRelatorioEmail.getCodContrato(), tbRelatorioEmail.getCodProduto()); List<String> listaEmails = tbRelatorioEmailDAO.getListaEmails(tbRelatorioEmail.getCodContrato()); if (!listaEmails.isEmpty()) { logger.debug("Lista de Emails obtida : [{}] ", listaEmails); //List<String> listaCodProduto = Arrays.asList( StringUtils.split(tbRelatorioEmail.getCodProduto(), ';') ) ; List<String> listaCodProduto = new ArrayList<String>(); listaCodProduto.add("1");//Sped Fiscal logger.debug("Gerando Relatorio Geral de Consumo por Produto..."); List<String> fileNames = new ArrayList<String>(); String fileName; BarChartDemo barChartDemo = (BarChartDemo) context.getBean("BarChartDemo"); //fileName = barChartDemo.generateBarChartGraph(tbRelatorioEmail.getCodContrato()); //fileNames.add(fileName); fileNames = barChartDemo.generateBarChartGraph2(tbRelatorioEmail.getCodContrato()); String templateFile = null; for (String codProduto : listaCodProduto) { if (codProduto.equals(Produto.SPED_FISCAL.getCodProduto())) { logger.debug("Produto Codigo : {} ", codProduto); templateFile = "index6.html"; //grafico de diagnostico fileName = barChartDemo.generateDiagnosticGraph(tbRelatorioEmail.getCodContrato(), dataIniProc, dataFimProc); fileNames.add(fileName); //grafico de auditoria recorrente fileName = barChartDemo.generateRecurrentGraph(tbRelatorioEmail.getCodContrato(), dataIniProc, dataFimProc); fileNames.add(fileName); } else { logger.debug("Produto Codigo : {} no aceito para gerar grafico ", codProduto); } logger.debug("Enviando Email.............Produto Codigo : {}", codProduto); SendEmail sendEmail = (SendEmail) context.getBean("SendEmail"); sendEmail.enviar(listaEmails.toArray(new String[listaEmails.size()]), "Relatrio Mensal de Riscos Fiscais", templateFile, fileNames, mes, tbRelatorioEmail.getCodContrato()); //sendEmail.enviar( new String[]{"leandro.prates@asisprojetos.com.br","leandro.prates@gmail.com"} , // "Relatrio Mensal de Riscos Fiscais", templateFile, fileNames, mes, tbRelatorioEmail.getCodContrato() ); } //Remover todos os arquivos png gerado para o cliente Config config = (Config) context.getBean("Config"); for (String f : fileNames) { try { File file = new File(String.format("%s/%s", config.getOutDirectory(), f)); if (file.delete()) { logger.debug("Arquivo: [{}/{}] deletado com sucesso.", config.getOutDirectory(), f); } else { logger.error("Erro ao deletar o arquivo: [{}/{}]", config.getOutDirectory(), f); } } catch (Exception ex) { logger.error("Erro ao deletar o arquivo: [{}/{}] . Message {}", config.getOutDirectory(), f, ex); } } } } }
From source file:com.mongodb.hadoop.examples.wordcount.split.WordCountSplitTest.java
public static void main(String[] args) throws Exception { boolean useQuery = false; boolean testSlaveOk = false; for (int i = 0; i < args.length; i++) { final String argi = args[i]; if (argi.equals("--use-query")) useQuery = true;/* w w w . j a va2 s. co m*/ else if (argi.equals("--test-slave-ok")) testSlaveOk = true; else { System.err.println("Unknown argument: " + argi); System.exit(1); } } boolean[] tf = { false, true }; Boolean[] ntf = { null }; if (testSlaveOk) ntf = new Boolean[] { null, Boolean.TRUE, Boolean.FALSE }; for (boolean use_shards : tf) for (boolean use_chunks : tf) for (Boolean slaveok : ntf) test(use_shards, use_chunks, slaveok, useQuery); }
From source file:com.hurence.logisland.utils.avro.eventgenerator.DataGenerator.java
public static void main(String[] args) throws IOException, UnknownTypeException { // load and verify the options CommandLineParser parser = new PosixParser(); Options opts = loadOptions();/*from ww w. java2 s . c o m*/ CommandLine cmd = null; try { cmd = parser.parse(opts, args); } catch (org.apache.commons.cli.ParseException parseEx) { LOG.error("Invalid option"); printHelp(opts); return; } // check for necessary options String fileLoc = cmd.getOptionValue("schemaLocation"); if (fileLoc == null) { LOG.error("schemaLocation not specified"); printHelp(opts); } //get string length and check if min is greater than 0 // Generate the record File schemaFile = new File(fileLoc); DataGenerator dataGenerator = new DataGenerator(schemaFile); GenericRecord record = dataGenerator.generateRandomRecord(); if (cmd.hasOption(PRINT_AVRO_JSON_OPTNAME)) { String outname = cmd.getOptionValue(PRINT_AVRO_JSON_OPTNAME); OutputStream outs = System.out; if (!outname.equals("-")) { outs = new FileOutputStream(outname); } printAvroJson(record, outs); if (!outname.equals("-")) { outs.close(); } } else { DataGenerator.prettyPrint(record); } }