List of usage examples for java.util List toString
public String toString()
From source file:com.elasticgrid.platforms.ec2.StartInstanceTask.java
public List<String> call() throws RemoteException { String securityGroupNameForCluster = "elastic-grid-cluster-" + clusterName; // start the agent node List<String> groups = null; switch (profile) { case MONITOR: groups = Arrays.asList(securityGroupNameForCluster, Discovery.MONITOR.getGroupName(), "elastic-grid"); break;//from ww w . jav a2 s .c om case AGENT: groups = Arrays.asList(securityGroupNameForCluster, Discovery.AGENT.getGroupName(), "elastic-grid"); break; case MONITOR_AND_AGENT: groups = Arrays.asList(securityGroupNameForCluster, Discovery.MONITOR.getGroupName(), Discovery.AGENT.getGroupName(), "elastic-grid"); break; } logger.log(Level.FINE, "Starting 1 Amazon EC2 instance from AMI {0} using groups {1} and user data {2}...", new Object[] { ami, groups.toString(), userData }); return nodeInstantiator.startInstances(ami, 1, 1, groups, userData, keypair, true, instanceType); }
From source file:fi.vm.sade.organisaatio.resource.IndexerResource.java
public void index(List<Organisaatio> organisaatiot) { final List<SolrInputDocument> docs = Lists.newArrayList(); final List<String> delete = Lists.newArrayList(); for (Organisaatio org : organisaatiot) { // Ei indeksoida ryhmi if (OrganisaatioUtil.isRyhma(org)) { continue; }/* ww w. ja va 2 s . co m*/ if (org.isOrganisaatioPoistettu()) { delete.add(org.getOid()); } else { docs.add(OrganisaatioToSolrInputDocumentUtil.apply(org)); } } if (docs.size() > 0) { try { LOG.info("Indexing {} docs.", docs.size()); LOG.info("Indexing following organisations {}.", docs.toString()); solr.add(docs); LOG.info("Committing changes to index.", docs.size()); solr.commit(true, true, false); LOG.info("Done."); } catch (SolrServerException | IOException e) { LOG.error("Indexing failed", e); } } deleteDocs(delete); }
From source file:coolmap.application.widget.impl.WidgetUserGroup.java
private void updateTable() { ArrayList<String> keys = new ArrayList<>(nodeGroups.keySet()); Collections.sort(keys);//from w ww .j a v a 2 s . c om Object[][] data = new Object[keys.size()][4]; for (int i = 0; i < keys.size(); i++) { String key = keys.get(i); List<VNode> nodes = nodeGroups.get(key); data[i][0] = key; data[i][1] = " "; data[i][2] = nodes.size(); data[i][3] = nodes.toString(); } final DefaultTableModel model = new DefaultTableModel(data, colLabels) { @Override public boolean isCellEditable(int row, int column) { return false; } }; SwingUtilities.invokeLater(new Runnable() { @Override public void run() { table.setModel(model); } }); }
From source file:com.baynote.kafka.hadoop.KafkaInputFormat.java
/** * Gets all of the input splits for the {@code topic}, filtering out any {@link InputSplit}s already consumed by the * {@code group}.// w w w. j a va 2s.c o m * * @param conf * the job configuration. * @param topic * the topic. * @param group * the consumer group. * @return input splits for the job. * @throws IOException */ List<InputSplit> getInputSplits(final Configuration conf, final String topic, final String group) throws IOException { final List<InputSplit> splits = Lists.newArrayList(); final ZkUtils zk = getZk(conf); final Map<Broker, SimpleConsumer> consumers = Maps.newHashMap(); try { for (final Partition partition : zk.getPartitions(topic)) { // cache the consumer connections - each partition will make use of each broker consumer final Broker broker = partition.getBroker(); if (!consumers.containsKey(broker)) { consumers.put(broker, getConsumer(broker, conf)); } // grab all valid offsets final List<Long> offsets = getOffsets(consumers.get(broker), topic, partition.getPartId(), zk.getLastCommit(group, partition), getIncludeOffsetsAfterTimestamp(conf), getMaxSplitsPerPartition(conf), conf); LOG.info("Topic Offsets: " + offsets.toString()); for (int i = 0; i < offsets.size() - 1; i++) { // ( offsets in descending order ) final long start = offsets.get(i + 1); final long end = offsets.get(i); // since the offsets are in descending order, the first offset in the list is the largest offset for // the current partition. This split will be in charge of committing the offset for this partition. final boolean partitionCommitter = (i == 0); final InputSplit split = new KafkaInputSplit(partition, start, end, partitionCommitter); LOG.debug("Created input split: " + split); splits.add(split); } } } finally { // close resources IOUtils.closeQuietly(zk); for (final SimpleConsumer consumer : consumers.values()) { consumer.close(); } } return splits; }
From source file:com.basho.riak.presto.CoverageRecordCursor.java
public CoverageRecordCursor(String schemaName, String tableName, List<RiakColumnHandle> columnHandles, //, InputSupplier<InputStream> inputStreamSupplier) List<HostAddress> addresses, SplitTask splitTask, TupleDomain tupleDomain, RiakConfig riakConfig, DirectConnection directConnection) { this.schemaName = checkNotNull(schemaName); this.tableName = checkNotNull(tableName); checkNotNull(addresses);//from w w w. j a v a2 s. co m checkState(!addresses.isEmpty()); // TODO: if (*) selected, columnHandles gets really empty... log.debug(columnHandles.toString()); checkState(!columnHandles.isEmpty(), "Queries just with (*) cannot run anywhere"); this.splitTask = checkNotNull(splitTask, "splitTask is null"); this.tupleDomain = checkNotNull(tupleDomain, "tupleDomain is null"); this.directConnection = checkNotNull(directConnection); buffer = new Vector<InternalRiakObject>(); cursor = null; fields = new String[columnHandles.size()]; slices = new Slice[columnHandles.size()]; has2i = new boolean[columnHandles.size()]; this.columnHandles = columnHandles; // fieldToColumnIndex = new int[columnHandles.size()]; log.debug(columnHandles.toString()); log.debug(tupleDomain.toString()); for (int i = 0; i < columnHandles.size(); i++) { // log.debug("%d, %s", i, columnHandles.get(i)); RiakColumnHandle columnHandle = columnHandles.get(i); fields[i] = columnHandle.getColumn().getName(); has2i[i] = columnHandle.getColumn().getIndex(); // fieldToColumnIndex[i] = columnHandle.getOrdinalPosition(); } fetchData(); }
From source file:eu.europa.esig.dss.validation.policy.EtsiValidationPolicy.java
@Override public SignaturePolicyConstraint getSignaturePolicyConstraint() { final String level = getValue("/ConstraintsParameters/MainSignature/AcceptablePolicies/@Level"); if (StringUtils.isNotBlank(level)) { final SignaturePolicyConstraint constraint = new SignaturePolicyConstraint(level); final List<XmlDom> policyList = getElements( "/ConstraintsParameters/MainSignature/AcceptablePolicies/Id"); final List<String> identifierList = XmlDom.convertToStringList(policyList); constraint.setIdentifiers(identifierList); constraint.setExpectedValue(identifierList.toString()); return constraint; }/* w w w. j a v a2 s . c o m*/ return null; }
From source file:com.gargoylesoftware.htmlunit.WebTestCase.java
/** * Facility method to avoid having to create explicitly a list from * a String[] (for example when testing received alerts). * Transforms the String[] to a List before calling * {@link org.junit.Assert#assertEquals(java.lang.String, java.lang.Object, java.lang.Object)}. * @param message the message to display if assertion fails * @param expected the expected strings/*from w w w . j a v a 2s . c om*/ * @param actual the collection of strings to test */ protected void assertEquals(final String message, final String[] expected, final List<String> actual) { Assert.assertEquals(message, Arrays.asList(expected).toString(), actual.toString()); }
From source file:de.tudarmstadt.lt.lm.web.servlet.LanguageModelProviderServlet.java
private void show(String inputtype, String lm_key, String plaintext, String crawluri, boolean show_all_ngrams, PrintWriter w) throws Exception { if ("uri".equals(inputtype)) plaintext = null;//from ww w . j a va 2s . c o m if ("text".equals(inputtype)) crawluri = null; if (plaintext == null && crawluri == null) // no parameter set plaintext = _test_text; w.write(_html_header); final Integer lm_index = _lm_keys.get(lm_key); if (lm_index == null) { LOG.error("Language model '{}' unknown.", lm_key); w.format("<p>Language model '%s' unknown. Please go to <a href='?'>main page</a>.</p>", lm_key); return; } StringProviderMXBean s = _lm_provider.get(lm_index); if (s == null) { if (!connectToLanguageModel(lm_key)) { w.format("<p>Language Model is loading. Please try again later.</p>", lm_key); w.write(_html_footer); w.flush(); return; } s = _lm_provider.get(lm_index); } w.format("<h3>%s</h3>%n", lm_key); double crawl_perp = -1d; if (crawluri != null) { Object[] triple = crawl_and_extract_plaintext(crawluri, lm_key, lm_index); plaintext = (String) triple[0]; crawl_perp = (Double) triple[1]; } else crawluri = ""; w.format( "<p>Crawl URI:</p>%n<p><form action='' method='get'><input type='text' name='crawluri' value='%s' size='100' /> <input type='submit' value='Submit'><input type='hidden' name='inputtype' value='uri'><input type='hidden' name='lm' value='%s'><input type='hidden' name='action' value='show'></form></p>%n", crawluri, lm_key); w.format("<p>Crawler Perplexity = %012g</p>%n", crawl_perp); w.format("<p>Bytes Plaintext = %d</p>%n", plaintext.getBytes().length); w.format("<br />%n"); w.format( "<p>Plaintext:</p>%n<p><form action='' method='get'><textarea rows='20' cols='150' name='plaintext'>%s</textarea><p><input type='submit' value='Submit'></p><input type='hidden' name='inputtype' value='text'><input type='hidden' name='lm' value='%s'><input type='hidden' name='action' value='show'></form></p>%n", plaintext, lm_key); w.format("<p>Perplexity = %012g</p>%n", s.getPerplexity(plaintext, false)); w.format("<br />%n"); w.format("<tt>%n"); List<String>[] ngram_sequence = s.getNgrams(plaintext); w.format("+++ #ngrams= %d +++ <br /><br />%n", ngram_sequence.length); // TODO: provide ngrams for (int i = 0; i < ngram_sequence.length && (i <= 500 || show_all_ngrams); i++) { List<String> ngram = ngram_sequence[i]; double log10_prob = s.getNgramLog10Probability(ngram); double prob10 = Math.pow(10, log10_prob); double log2_prob = log10_prob / Math.log10(2); int[] ngram_ids = s.getNgramAsIds(ngram); List<String> ngram_lm = s.getNgramAsWords(ngram_ids); w.format("%s <br />%n => %s <br />%n = %012g (log_2 = %012g)<br /><br />%n", StringEscapeUtils.escapeHtml(ngram.toString()), StringEscapeUtils.escapeHtml(ngram_lm.toString()), prob10, log2_prob); } if (ngram_sequence.length > 500 && !show_all_ngrams) w.format("...%n"); w.format("<br />%n"); w.format("</tt>%n"); w.write(_html_footer); }
From source file:de.iteratec.iteraplan.businesslogic.service.legacyExcel.ExcelAttributesImportServiceImpl.java
/** * Creates a string with the values in the list, and removes the brackets. * @param strings the list to convert//from ww w . jav a 2s . c o m * @return one string representing the list */ private String listToString(List<?> strings) { String listString = strings.toString(); listString = listString.substring(1, listString.length() - 1); return listString; }
From source file:gtu._work.ui.RegexCatchReplacer.java
private void initGUI() { try {//from w ww . j a va 2 s . c o m { } BorderLayout thisLayout = new BorderLayout(); getContentPane().setLayout(thisLayout); this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); { jTabbedPane1 = new JTabbedPane(); getContentPane().add(jTabbedPane1, BorderLayout.CENTER); { jPanel1 = new JPanel(); BorderLayout jPanel1Layout = new BorderLayout(); jPanel1.setLayout(jPanel1Layout); jTabbedPane1.addTab("source", null, jPanel1, null); { jScrollPane1 = new JScrollPane(); jPanel1.add(jScrollPane1, BorderLayout.CENTER); { replaceArea = new JTextArea(); jScrollPane1.setViewportView(replaceArea); replaceArea.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { JPopupMenuUtil.newInstance(replaceArea).applyEvent(evt) .addJMenuItem("load from file", true, new ActionListener() { Thread newThread; public void actionPerformed(ActionEvent arg0) { if (newThread != null && newThread.getState() != Thread.State.TERMINATED) { JCommonUtil._jOptionPane_showMessageDialog_error( "file is loading!"); return; } final File file = JCommonUtil._jFileChooser_selectFileOnly(); if (file == null) { JCommonUtil._jOptionPane_showMessageDialog_error( "file is not correct!"); return; } String defaultCharset = Charset.defaultCharset().displayName(); String chst = (String) JCommonUtil._jOptionPane_showInputDialog( "input your charset!", defaultCharset); final Charset charset2 = Charset.forName( StringUtils.defaultIfEmpty(chst, defaultCharset)); newThread = new Thread(Thread.currentThread().getThreadGroup(), new Runnable() { public void run() { try { loadFromFileSb = new StringBuilder(); BufferedReader reader = new BufferedReader( new InputStreamReader( new FileInputStream(file), charset2)); for (String line = null; (line = reader .readLine()) != null;) { loadFromFileSb.append(line + "\n"); } reader.close(); replaceArea .setText(loadFromFileSb.toString()); JCommonUtil ._jOptionPane_showMessageDialog_info( "load completed!"); } catch (Exception e) { JCommonUtil.handleException(e); } } }, "" + System.currentTimeMillis()); newThread.setDaemon(true); newThread.start(); } }).show(); } }); } } } { jPanel2 = new JPanel(); BorderLayout jPanel2Layout = new BorderLayout(); jPanel2.setLayout(jPanel2Layout); jTabbedPane1.addTab("param", null, jPanel2, null); { exeucte = new JButton(); jPanel2.add(exeucte, BorderLayout.SOUTH); exeucte.setText("exeucte"); exeucte.setPreferredSize(new java.awt.Dimension(491, 125)); exeucte.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { exeucteActionPerformed(evt); } }); } { jPanel3 = new JPanel(); GroupLayout jPanel3Layout = new GroupLayout((JComponent) jPanel3); jPanel3.setLayout(jPanel3Layout); jPanel2.add(jPanel3, BorderLayout.CENTER); { repFromText = new JTextField(); } { repToText = new JTextField(); } jPanel3Layout.setHorizontalGroup(jPanel3Layout.createSequentialGroup() .addContainerGap(25, 25) .addGroup(jPanel3Layout.createParallelGroup() .addGroup(jPanel3Layout.createSequentialGroup().addComponent(repFromText, GroupLayout.PREFERRED_SIZE, 446, GroupLayout.PREFERRED_SIZE)) .addGroup(jPanel3Layout.createSequentialGroup().addComponent(repToText, GroupLayout.PREFERRED_SIZE, 446, GroupLayout.PREFERRED_SIZE))) .addContainerGap(20, Short.MAX_VALUE)); jPanel3Layout.setVerticalGroup(jPanel3Layout.createSequentialGroup().addContainerGap() .addComponent(repFromText, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(repToText, GroupLayout.PREFERRED_SIZE, 24, GroupLayout.PREFERRED_SIZE) .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)); } { addToTemplate = new JButton(); jPanel2.add(addToTemplate, BorderLayout.NORTH); addToTemplate.setText("add to template"); addToTemplate.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { prop.put(repFromText.getText(), repToText.getText()); reloadTemplateList(); } }); } } { jPanel4 = new JPanel(); BorderLayout jPanel4Layout = new BorderLayout(); jPanel4.setLayout(jPanel4Layout); jTabbedPane1.addTab("result", null, jPanel4, null); { jScrollPane2 = new JScrollPane(); jPanel4.add(jScrollPane2, BorderLayout.CENTER); jScrollPane2.setPreferredSize(new java.awt.Dimension(491, 283)); { DefaultTableModel resultAreaModel = JTableUtil.createModel(true, "match", "count"); resultArea = new JTable(); jScrollPane2.setViewportView(resultArea); JTableUtil.defaultSetting(resultArea); resultArea.setModel(resultAreaModel); } } } { jPanel5 = new JPanel(); BorderLayout jPanel5Layout = new BorderLayout(); jPanel5.setLayout(jPanel5Layout); jTabbedPane1.addTab("template", null, jPanel5, null); { jScrollPane3 = new JScrollPane(); jPanel5.add(jScrollPane3, BorderLayout.CENTER); { templateList = new JList(); jScrollPane3.setViewportView(templateList); reloadTemplateList(); } templateList.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { if (templateList.getLeadSelectionIndex() == -1) { return; } Entry<Object, Object> entry = (Entry<Object, Object>) JListUtil .getLeadSelectionObject(templateList); repFromText.setText((String) entry.getKey()); repToText.setText((String) entry.getValue()); } }); templateList.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent evt) { JListUtil.newInstance(templateList).defaultJListKeyPressed(evt); } }); } } { jPanel6 = new JPanel(); FlowLayout jPanel6Layout = new FlowLayout(); jPanel6.setLayout(jPanel6Layout); jTabbedPane1.addTab("result1", null, jPanel6, null); { resultBtn1 = new JButton(); jPanel6.add(resultBtn1); resultBtn1.setText("to String[]"); resultBtn1.setPreferredSize(new java.awt.Dimension(105, 32)); resultBtn1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { JTableUtil tableUtil = JTableUtil.newInstance(resultArea); int[] rowPoss = tableUtil.getSelectedRows(); DefaultTableModel model = tableUtil.getModel(); List<Object> valueList = new ArrayList<Object>(); for (int ii = 0; ii < rowPoss.length; ii++) { valueList.add(model.getValueAt(rowPoss[ii], 0)); } String reult = valueList.toString().replaceAll("[\\s]", "") .replaceAll("[\\,]", "\",\"").replaceAll("[\\[\\]]", "\""); ClipboardUtil.getInstance().setContents(reult); } }); } { resultBtn2 = new JButton(); jPanel6.add(resultBtn2); resultBtn2.setText("TODO"); resultBtn2.setPreferredSize(new java.awt.Dimension(105, 32)); resultBtn2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { System.out.println("resultBtn1.actionPerformed, event=" + evt); //TODO add your code for resultBtn1.actionPerformed JCommonUtil._jOptionPane_showMessageDialog_info("TODO"); } }); } } } this.setSize(512, 350); JCommonUtil.setFont(repToText, repFromText, replaceArea, templateList); JCommonUtil.frameCloseDo(this, new WindowAdapter() { public void windowClosing(WindowEvent paramWindowEvent) { if (StringUtils.isNotBlank(repFromText.getText())) { prop.put(repFromText.getText(), repToText.getText()); } try { prop.store(new FileOutputStream(propFile), "regexText"); } catch (Exception e) { JCommonUtil.handleException("properties store error!", e); } setVisible(false); dispose(); } }); } catch (Exception e) { e.printStackTrace(); } }