List of usage examples for java.util List clear
void clear();
From source file:org.ala.util.PartialIndex.java
public void process(String args) throws Exception { int ctr = 0;/*from ww w . ja v a2 s .c o m*/ File file = new File(args); FileInputStream fstream = new FileInputStream(file); // Get the object of DataInputStream DataInputStream in = new DataInputStream(fstream); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String strLine; List<String> guidBatch = new java.util.ArrayList<String>(500); while ((strLine = br.readLine()) != null) { if (guidBatch.size() >= 500) { postIndexUpdate(guidBatch.toArray(new String[] {})); guidBatch.clear(); } guidBatch.add(strLine); } if (guidBatch.size() > 0) postIndexUpdate(guidBatch.toArray(new String[] {})); // BufferedReader br = new BufferedReader(new InputStreamReader(in)); //// loader.cleanIndex(); // ArrayBlockingQueue<String> queue = new ArrayBlockingQueue<String>(100); // IndexingThread[] threads = new IndexingThread[20]; // for(int i = 0; i<20;i++){ // IndexingThread t = new IndexingThread(i, queue); // threads[i]=t; // t.start(); // } // String strLine; // if(solrServer == null){ // solrServer = solrUtils.getSolrServer(); // } // //Read File Line By Line // while ((strLine = br.readLine()) != null) { // // Print the content on the console // strLine = strLine.trim(); // if(strLine.length() > 0){ // //doIndex(strLine); // while(!queue.offer(strLine)) // Thread.currentThread().sleep(50); // ctr++; // } // } // for(IndexingThread t : threads){ // t.setCanStop(); // t.join(); // } // //Close the input stream // in.close(); // // commitIndex(); // solrUtils.shutdownSolr(); logger.info("**** total count: " + ctr); }
From source file:com.comcast.cdn.traffic_control.traffic_monitor.wicket.components.EditConfigPanel.java
protected final void setCdnList(final List<String> cdnList, final String hostName) { final MonitorConfig config = ConfigHandler.getConfig(); if (config == null || !config.allowConfigEdit()) { return;//from w w w. ja v a2 s .com } cdnList.clear(); try { final File file = Fetcher.downloadTM("https://" + hostName + "/dataparameter", config.getAuthUrl(), config.getAuthUsername(), config.getAuthPassword(), 500); final String str = IOUtils.toString(new FileReader(file)); file.delete(); final JSONArray ja = new JSONArray(str); // LOGGER.warn(ja.toString(2)); for (int i = 0; i < ja.length(); i++) { // "name": "CDN_name", final JSONObject jo = ja.getJSONObject(i); if ("CDN_name".equals(jo.optString("name"))) { cdnList.add(jo.optString("value")); } } } catch (java.net.SocketTimeoutException e) { cdnList.add(ConfigHandler.getConfig().getBaseProps().get(CDN_NAME_KEY)); LOGGER.warn("TM timeout"); } catch (Exception e) { cdnList.add(ConfigHandler.getConfig().getBaseProps().get(CDN_NAME_KEY)); LOGGER.warn(e, e); } }
From source file:edu.ku.brc.stats.PieChartPanel.java
public synchronized void allResultsBack(final QueryResultsContainerIFace qrc) { // create a dataset... DefaultPieDataset dataset = new DefaultPieDataset(); java.util.List<Object> list = handler.getDataObjects(); for (int i = 0; i < list.size(); i++) { Object descObj = list.get(i++); Object valObj = list.get(i); dataset.setValue(getString(descObj), getInt(valObj)); }// w w w .jav a 2 s .c o m list.clear(); // create a chart... JFreeChart chart = ChartFactory.createPieChart(title, dataset, false, // legend? true, // tooltips? false // URLs? ); //chart.getCategoryPlot().setRenderer(new CustomColorBarChartRenderer()); // create and display a frame... chartPanel = new org.jfree.chart.ChartPanel(chart, true, true, true, true, true); //setBackground(Color.BLUE); removeAll(); // remove progress bar /* PanelBuilder builder = new PanelBuilder(new FormLayout("p:g,p,p:g", "f:p:g")); CellConstraints cc = new CellConstraints(); builder.add(panel, cc.xy(3,1)); add(builder.getPanel(), BorderLayout.CENTER); */ //add(chartPanel, BorderLayout.CENTER); setLayout(new ChartLayoutManager(this)); add(chartPanel); validate(); doLayout(); repaint(); // TODO This is a kludge for now to get the BarChart to Paint Correctly UIRegistry.forceTopFrameRepaint(); }
From source file:io.mapzone.arena.tracker.GoogleAnalyticsTracker.java
@EventHandler(delay = 100, scope = Scope.JVM) public void track(List<ServletRequestEvent> events) { // delay ensures that we run in an async background job List<NameValuePair> params = Lists.newArrayList(); for (EventObject event : events) { // add more types here if (event instanceof ServletRequestEvent) { extractParams(params, (ServletRequestEvent) event); }/*from w ww. j a v a 2 s. co m*/ send(params); params.clear(); } }
From source file:org.sakaiproject.metaobj.shared.control.XmlControllerBase.java
public void retrieveFileAttachments(Map request, Map session, ElementBean currentBean) { String fieldName = (String) session.get(FILE_ATTACHMENTS_FIELD); if (session.get(FilePickerHelper.FILE_PICKER_CANCEL) == null && session.get(FilePickerHelper.FILE_PICKER_ATTACHMENTS) != null) { List refs = (List) session.get(FilePickerHelper.FILE_PICKER_ATTACHMENTS); List ids = convertRefs(refs); // we may convert later, for now, leave backward compatible. // convertToGuidList(refs); if (List.class.isAssignableFrom(currentBean.getType(fieldName))) { List refList = (List) currentBean.get(fieldName); refList.clear();/*from ww w .ja v a2 s.co m*/ refList.addAll(ids); } else { if (refs.size() > 0) { currentBean.put(fieldName, ids.get(0)); } else { currentBean.put(fieldName, null); } } } session.remove(FilePickerHelper.FILE_PICKER_ATTACHMENTS); session.remove(FilePickerHelper.FILE_PICKER_CANCEL); }
From source file:com.exzogeni.dk.http.HttpTask.java
@NonNull public HttpTask<V> addHeader(@NonNull String key, @NonNull String... values) { List<String> headers = mHeaders.get(key); if (headers == null) { headers = new CopyOnWriteArrayList<>(); mHeaders.put(key, headers);//from w w w.j a v a 2 s .c o m } headers.clear(); Collections.addAll(headers, values); return this; }
From source file:com.inrista.loggliest.Loggly.java
private static synchronized void start() { if (mThread != null && mThread.isAlive()) return;/* ww w . j a v a2 s. c o m*/ mThread = new Thread(new Runnable() { @Override public void run() { Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND); mThread.setName(THREAD_NAME); List<JSONObject> logBatch = new ArrayList<JSONObject>(); while (true) { try { JSONObject msg = mLogQueue.poll(10, TimeUnit.SECONDS); if (msg != null) { logBatch.add(msg); while ((msg = mLogQueue.poll()) != null) logBatch.add(msg); } long now = SystemClock.elapsedRealtime() / 1000; if (!logBatch.isEmpty()) { mLastLog = now; mLogCounter += logBatch.size(); logToFile(logBatch); logBatch.clear(); } if ((now - mLastUpload) >= mUploadIntervalSecs || mLogCounter >= mUploadIntervalLogCount) { postLogs(); } if (((now - mLastLog) >= mIdleSecs) && mIdleSecs > 0 && mLastLog > 0) { mThread.interrupt(); } } catch (InterruptedException e) { mLogQueue.drainTo(logBatch); logToFile(logBatch); postLogs(); return; } } } }); mThread.start(); }
From source file:com.github.stagirs.docextractor.wiki.WikiDocProcessor.java
@Override public Document processDocument(String id, String str) { Document doc = new Document(); doc.setId(id);/* w ww .jav a 2 s . co m*/ List<Point> points = new ArrayList<Point>(); doc.setPoints(points); points.add(new Point(0, true, str.substring(str.indexOf("<title>") + "<title>".length(), str.indexOf("</title>")))); if (!str.contains("<text xml:space=\"preserve\">")) { return doc; } String text = str.substring( str.indexOf("<text xml:space=\"preserve\">") + "<text xml:space=\"preserve\">".length(), str.indexOf("</text>")); text = text.replace("<", "<").replace(">", ">")/*.replaceAll("<!--.*?->", "").replaceAll("<.*?>.*?</*?>", "")*/; try { Iterator elems = WikiParser.getElems(LemmaParser.getLems(text).iterator(), null).iterator(); List forPoint = new ArrayList(); int level = 0; while (elems.hasNext()) { Object elem = elems.next(); if (elem.equals("\t\t")) { if (!forPoint.isEmpty()) { level = fillPoints(points, level, forPoint); forPoint.clear(); } continue; } forPoint.add(elem); } if (!forPoint.isEmpty()) { fillPoints(points, level, forPoint); } return doc; } catch (Exception ex) { throw new RuntimeException(ex); } }
From source file:edu.ku.brc.af.tasks.subpane.PieChartPane.java
public synchronized void allResultsBack(final QueryResultsContainerIFace qrc) { // create a dataset... DefaultPieDataset dataset = new DefaultPieDataset(); java.util.List<Object> list = handler.getDataObjects(); for (int i = 0; i < list.size(); i++) { Object descObj = list.get(i++); Object valObj = list.get(i); dataset.setValue(getString(descObj), getInt(valObj)); }// w ww . j ava2s . c o m list.clear(); // create a chart... JFreeChart chart = ChartFactory.createPieChart(title, dataset, false, // legend? true, // tooltips? false // URLs? ); //chart.getCategoryPlot().setRenderer(new CustomColorBarChartRenderer()); PiePlot plot = (PiePlot) chart.getPlot(); plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 11)); //$NON-NLS-1$ /* PiePlot3D plot = (PiePlot3D) chart.getPlot(); //plot.setSectionOutlinesVisible(false); plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 11)); plot.setNoDataMessage("No data available"); plot.setCircular(true); plot.setLabelGap(0.02); //plot.setBackgroundAlpha(0.5f); plot.setForegroundAlpha(0.5f); plot.setDepthFactor(0.05); */ removeAll(); // remove progress bar ChartPanel panel = new ChartPanel(chart, true, true, true, true, true); add(panel, BorderLayout.CENTER); doLayout(); repaint(); }
From source file:de.thorstenberger.examServer.service.impl.ConfigManagerImpl.java
@Override public synchronized void setRadiusMailSuffixes(List<String> suffixes) { List<String> crntSuffixes = config.getRadiusEmailSuffixes(); crntSuffixes.clear(); crntSuffixes.addAll(suffixes);//from w ww.j av a 2 s .c o m save(); }