List of usage examples for java.util ArrayList clear
public void clear()
From source file:UserInterface.AdminWorkArea.InventoryUsageJPanel.java
public void findTopDevice() { int max = 0;// w w w . j a va 2 s. c o m int current = 0; String currentPName = "null"; ArrayList<String> currentPList = new ArrayList<>(); currentPList.add("null"); DefaultTableModel dtm = (DefaultTableModel) deviceUsageJTable.getModel(); for (int i = 0; i < dtm.getRowCount(); i++) { current = (int) dtm.getValueAt(i, 1); if (max < current) { max = current; IDeviceType dt = (IDeviceType) dtm.getValueAt(i, 0); currentPName = dt.getTypeOfDevice(); currentPList.clear(); currentPList.add(currentPName); } else if (max == current) { IDeviceType dt = (IDeviceType) dtm.getValueAt(i, 0); currentPName = dt.getTypeOfDevice(); currentPList.add(currentPName); } } mostUsedLabel.setText(currentPList.toString()); }
From source file:importer.filters.MarkupSet.java
/** * Print an array of queued end-tags (as ranges) in reverse order * @param tags the queued tags//from ww w .j av a 2s . com */ void printEndTags(ArrayList<Range> tags) { // first insert sort ranges Range[] ranges = new Range[tags.size()]; tags.toArray(ranges); for (int i = 1; i < ranges.length; i++) { Range key = ranges[i]; int j = i - 1; while (j >= 0 && ranges[j].offset < key.offset) { ranges[j + 1] = ranges[j]; j = j - 1; } ranges[j + 1] = key; } for (int i = 0; i < ranges.length; i++) { Range r = tags.get(i); System.out.print("</" + ranges[i].name + ">"); } tags.clear(); }
From source file:com.miz.service.TraktMoviesSyncService.java
private void updateWatchlist() { ArrayList<Movie> watchlistMovies = new ArrayList<Movie>(); int count = mMovies.size(); for (int i = 0; i < count; i++) if (!mWatchlist.contains(mMovies.get(i).getTmdbId()) && mMovies.get(i).toWatch()) watchlistMovies.add(mMovies.get(i)); if (watchlistMovies.size() > 0) Trakt.movieWatchlist(watchlistMovies, this); // Clean up/*from w ww . j a va 2 s . c o m*/ watchlistMovies.clear(); watchlistMovies = null; mWatchlist.clear(); mWatchlist = null; }
From source file:com.app.util.browser.BrowserSniffer.java
private ArrayList getMatches(Pattern pat, String str, int countGroups) { Matcher matcher = pat.matcher(str); ArrayList matches = new ArrayList(); try {//w ww. j a v a 2s . c o m ArrayList groups = new ArrayList(); while (matcher.find()) { groups.clear(); int nullCount = 0; for (int i = 0; i < countGroups; i++) { int start = matcher.start(i); int end = matcher.end(i); if (start >= 0 && end >= 0) { String sub = str.substring(start, end); if (StringUtils.isNotEmpty(sub)) groups.add(sub); else { groups.add(null); nullCount++; } } else { groups.add(null); nullCount++; } } if (groups.size() > 0 && nullCount != groups.size()) matches.add(groups.toArray(new String[groups.size()])); } } catch (Exception e) { log.error(e); } return matches; }
From source file:UserInterface.AdminWorkArea.InventoryUsageJPanel.java
public void findLeastUsedDevices() { int min = 0;/*from w w w . ja va 2s . c om*/ int current = 0; String currentPName = "null"; ArrayList<String> currentPList = new ArrayList<>(); currentPList.add("null"); DefaultTableModel dtm = (DefaultTableModel) deviceUsageJTable.getModel(); min = (int) dtm.getValueAt(0, 1); for (int i = 0; i < dtm.getRowCount(); i++) { current = (int) dtm.getValueAt(i, 1); if (min > current) { min = current; IDeviceType dt = (IDeviceType) dtm.getValueAt(i, 0); currentPName = dt.getTypeOfDevice(); currentPList.clear(); currentPList.add(currentPName); } else if (min == current) { IDeviceType dt = (IDeviceType) dtm.getValueAt(i, 0); currentPName = dt.getTypeOfDevice(); currentPList.add(currentPName); } } leastUsedLabel.setText(currentPList.toString()); }
From source file:com.intel.ssg.dcst.panthera.cli.PantheraCliDriver.java
int processLocalCmd(String cmd, CommandProcessor proc, CliSessionState ss) { int tryCount = 0; boolean needRetry; int ret = 0;/* w w w . j av a2 s .co m*/ do { try { needRetry = false; if (proc != null) { if (proc instanceof Driver) { SkinDriver qp = (SkinDriver) proc; PrintStream out = ss.out; long start = System.currentTimeMillis(); if (ss.getIsVerbose()) { out.println(cmd); } qp.setTryCount(tryCount); ret = qp.run(cmd).getResponseCode(); if (ret != 0) { qp.close(); return ret; } ArrayList<String> res = new ArrayList<String>(); printHeader(qp, out); int counter = 0; try { while (qp.getResults(res)) { for (String r : res) { out.println(r); } counter += res.size(); res.clear(); if (out.checkError()) { break; } } } catch (IOException e) { console.printError( "Failed with exception " + e.getClass().getName() + ":" + e.getMessage(), "\n" + org.apache.hadoop.util.StringUtils.stringifyException(e)); ret = 1; } int cret = qp.close(); if (ret == 0) { ret = cret; } long end = System.currentTimeMillis(); double timeTaken = (end - start) / 1000.0; console.printInfo("Time taken: " + timeTaken + " seconds" + (counter == 0 ? "" : ", Fetched: " + counter + " row(s)")); } else { String firstToken = tokenizeCmd(cmd.trim())[0]; String cmd_1 = getFirstCmd(cmd.trim(), firstToken.length()); if (ss.getIsVerbose()) { ss.out.println(firstToken + " " + cmd_1); } CommandProcessorResponse res = proc.run(cmd_1); if (res.getResponseCode() != 0) { ss.out.println("Query returned non-zero code: " + res.getResponseCode() + ", cause: " + res.getErrorMessage()); } ret = res.getResponseCode(); } } } catch (CommandNeedRetryException e) { console.printInfo("Retry query with a different approach..."); tryCount++; needRetry = true; } } while (needRetry); return ret; }
From source file:com.yoctopuce.YoctoAPI.YDataLogger.java
public ArrayList<YDataSet> parse_dataSets(byte[] json) throws YAPI_Exception { ArrayList<String> dslist = new ArrayList<String>(); ArrayList<YDataSet> res = new ArrayList<YDataSet>(); // may throw an exception dslist = _json_get_array(json);/*from w ww. jav a 2 s . c om*/ res.clear(); for (String ii : dslist) { res.add(new YDataSet(this, ii)); } return res; }
From source file:com.miz.service.TraktMoviesSyncService.java
private void updateMovieFavorites() { ArrayList<Movie> favs = new ArrayList<Movie>(); int count = mMovies.size(); for (int i = 0; i < count; i++) // Check that we're not uploading stuff that's already on Trakt if (!mMovieFavorites.contains(mMovies.get(i).getTmdbId()) && mMovies.get(i).isFavourite()) favs.add(mMovies.get(i));/*from w w w . j av a 2s. c o m*/ if (favs.size() > 0) Trakt.movieFavorite(favs, this); // Clean up favs.clear(); favs = null; mMovieFavorites.clear(); mMovieFavorites = null; }
From source file:edu.iu.incntre.flowscale.FlowscaleController.java
/** * called by the hot swapping bundle :flowscaleflowupdate , will have the * modified flows to swap from high loaded ports to low ones * /*from www . j av a 2 s . c om*/ * @param ofFlowMods * flows that are passed by the flowscaleflowupdate bundle * @param datapathId * id of concerned switch that we desire to hotswap flows */ public void injectFlows(ArrayList<OFFlowMod> ofFlowMods, long datapathId) { logger.info("injecting flows in controller"); IOFSwitch sw = this.ibeaconProvider.getSwitches().get(datapathId); if (sw == null) { logger.error("no switch {} exists", datapathId); return; } for (OFFlowMod ofFlowMod : ofFlowMods) { logger.info("injecting flow {}", ofFlowMod); for (Integer groupKey : groupList.keySet()) { Group group = groupList.get(groupKey); ArrayList<OFRule> groupRules = (ArrayList<OFRule>) group.getGroupRules(); for (OFRule rule : groupRules) { if (rule.getMatch().equals(ofFlowMod.getMatch()) && group.getOutputSwitchDatapathId() == datapathId) { logger.info("rule equal", rule.getMatch().toString(), ofFlowMod.getMatch().toString()); ofFlowMod.setPriority(rule.getPriority()); ArrayList<OFAction> aList = rule.getActions(); aList.clear(); short port = ((OFActionOutput) ofFlowMod.getActions().get(0)).getPort(); rule.setPort(port); Short mirrorPort = 0; if (switchFlowMirrorPortsHashMap.get(datapathId) != null) { mirrorPort = switchFlowMirrorPortsHashMap.get(datapathId).get(port); } if (mirrorPort != null) { rule.setMirrorPort(mirrorPort); } logger.info("new rule is {} and port is {}", rule.getMatch(), rule.getActions().get(0)); } } } try { sw.getOutputStream().write(ofFlowMod); } catch (IOException e) { // TODO Auto-generated catch block logger.error("{}", e); } } try { sw.getOutputStream().flush(); } catch (IOException e) { // TODO Auto-generated catch block logger.error("{}", e); } }
From source file:com.tecapro.inventory.common.util.FileLocalUtil.java
/** * get content of file and split per line * @param csvFile/* w w w . j a v a 2 s . co m*/ * @return * @throws IOException */ protected List<String[]> splitCSV(String csvFile) throws IOException { BufferedReader br = null; String line = ""; List<String[]> list = new ArrayList<String[]>(); try { br = new BufferedReader( new InputStreamReader(new FileInputStream(csvFile), Constants.Text.WINDOWS_31J)); if (br != null) { String match; ArrayList<String> allMatches = new ArrayList<String>(); final Pattern p = Pattern.compile("\"([^\"]*)\"|(?<=,|^)([^,]*)(?:,|$)"); while ((line = br.readLine()) != null) { if (line != null && !"".equals(line)) { int size; Matcher m = p.matcher(line); allMatches.clear(); while (m.find()) { match = m.group(1); if (match != null) { allMatches.add(match); } else { allMatches.add(m.group(2)); } } size = allMatches.size(); if (size > 0) { list.add(allMatches.toArray(new String[size])); } } } } } finally { if (br != null) { br.close(); } } return list; }