List of usage examples for java.util List clear
void clear();
From source file:com.googlecode.noweco.webmail.lotus.LotusWebmailConnection.java
public Set<String> tryDelete(final Set<String> messageUids) throws IOException { Set<String> deleted = new HashSet<String>(); final List<String> toDelete = new ArrayList<String>(); int page = 0; boolean maxMessage; do {//w w w .ja va 2s. c om int index = 1 + page * MAX_MESSAGE; String pageContent = loadPageContent(index); toDelete.clear(); Matcher matcherDelete = deleteDeletePattern.matcher(pageContent); if (!matcherDelete.find()) { throw new IOException("No DELETE/DELETE find"); } maxMessage = new MessageListener(pageContent) { @Override public void appendMessage(final String messageId, final int messageSize) { if (messageUids.contains(messageId)) { toDelete.add(messageId); } } }.isMaxMessage(); HttpPost httpPost = new HttpPost(pagePrefix + "&Start=" + index); List<NameValuePair> nvps = new ArrayList<NameValuePair>(); nvps.add(new BasicNameValuePair("__Click", matcherDelete.group(1))); nvps.add(new BasicNameValuePair("%%Surrogate_$$SelectDestFolder", "1")); nvps.add(new BasicNameValuePair("$$SelectDestFolder", "--Aucun dossier disponible--")); for (String doc : toDelete) { nvps.add(new BasicNameValuePair("$$SelectDoc", doc)); deleted.add(doc); } Matcher matcherRandNum = TEMP_RAND_NUM_PATTERN.matcher(pageContent); if (!matcherRandNum.find()) { throw new IOException("No rand num find"); } nvps.add(new BasicNameValuePair("tmpRandNum", matcherRandNum.group(1))); nvps.add(new BasicNameValuePair("viewName", "($Inbox)")); nvps.add(new BasicNameValuePair("folderError", "")); httpPost.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8)); HttpResponse rsp = httpclient.execute(host, httpPost); EntityUtils.consume(rsp.getEntity()); page++; } while (maxMessage); // inline clear garbage String pageContent = loadPageContent(1); Matcher matcherDeleteGarbage = deleteEmptyTrashPattern.matcher(pageContent); if (!matcherDeleteGarbage.find()) { throw new IOException("No DELETE/EMPTY_TRASH find"); } HttpPost httpPost = new HttpPost(pagePrefix); List<NameValuePair> nvps = new ArrayList<NameValuePair>(); nvps.add(new BasicNameValuePair("__Click", matcherDeleteGarbage.group(1))); nvps.add(new BasicNameValuePair("%%Surrogate_$$SelectDestFolder", "1")); nvps.add(new BasicNameValuePair("$$SelectDestFolder", "--Aucun dossier disponible--")); Matcher matcherRandNum = TEMP_RAND_NUM_PATTERN.matcher(pageContent); if (!matcherRandNum.find()) { throw new IOException("No rand num find"); } nvps.add(new BasicNameValuePair("tmpRandNum", matcherRandNum.group(1))); nvps.add(new BasicNameValuePair("viewName", "($Inbox)")); nvps.add(new BasicNameValuePair("folderError", "")); httpPost.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8)); HttpResponse rsp = httpclient.execute(host, httpPost); EntityUtils.consume(rsp.getEntity()); return deleted; }
From source file:com.employee.scheduler.common.swingui.SolverAndPersistenceFrame.java
private void refreshQuickOpenPanel(JPanel panel, List<Action> quickOpenActionList, List<File> fileList) { panel.removeAll();//from w w w . j a v a 2 s . co m quickOpenActionList.clear(); if (fileList.isEmpty()) { JLabel noneLabel = new JLabel("None"); noneLabel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); panel.add(noneLabel); } else { for (File file : fileList) { Action quickOpenAction = new QuickOpenAction(file); quickOpenActionList.add(quickOpenAction); JButton quickOpenButton = new JButton(quickOpenAction); quickOpenButton.setHorizontalAlignment(SwingConstants.LEFT); quickOpenButton.setMargin(new Insets(0, 0, 0, 0)); panel.add(quickOpenButton); } } }
From source file:com.cyclopsgroup.waterview.AbstractRuntimeData.java
/** * Override method getMessages in class AbstractRuntimeData * * @see com.cyclopsgroup.waterview.RuntimeData#getMessages() *//* w w w . j a v a 2 s. com*/ public String[] getMessages() { List messages = (List) getSessionContext().get(MESSAGES_NAME); if (messages == null) { return ArrayUtils.EMPTY_STRING_ARRAY; } String[] ret = (String[]) messages.toArray(ArrayUtils.EMPTY_STRING_ARRAY); messages.clear(); return ret; }
From source file:com.megahardcore.task.FallingLogsTask.java
@Override public void run() { if (block != null) { /* Prevent wooden structures near trees from being affected*/ if (blockModule.getBlocksInArea(block.getLocation(), 2, 1, Material.LEAVES).length > 3 || blockModule.getBlocksInArea(block.getLocation(), 2, 1, Material.LEAVES_2).length > 3) { //Clear the area below of leaves Block below = block;/*from w w w. j a v a2 s .com*/ List<Block> looseLogs = new ArrayList<>(); List<Block> tempBlocks = new ArrayList<>(); looseLogs.add(block); checkBelow: for (int i = 0; below.getY() > 0; i++) { below = below.getRelative(BlockFace.DOWN); switch (below.getType()) { case AIR: { //go one down //All blocks above this can fall now that there is an air block looseLogs.addAll(tempBlocks); tempBlocks.clear(); break; } case LEAVES: case LEAVES_2: { below.breakNaturally(); break; } case LOG: case LOG_2: { //Prevent Logs on adjacent sides (Jungle Tree) from turning to FallingBlocks and some of them turning into items switch (below.getRelative(BlockFace.DOWN).getType()) { case AIR: case LEAVES: tempBlocks.add(below); } break; } default: //we hit the block where the FallingBlock will land { if (blockModule.breaksFallingBlock(below.getType())) { below.breakNaturally(); } else { break checkBelow; } } } } for (int i = 0; i < looseLogs.size(); i++) { final Block looseLog = looseLogs.get(i); plugin.getServer().getScheduler().runTaskLater(plugin, () -> blockModule.applyPhysics(looseLog, true), i /*delay to prevent FallingBlock collision*/); } } } }
From source file:fr.certu.chouette.gui.command.ExportCommand.java
/** * export command : selected objects -c export -o line -format XXX * -outputFile YYYY -exportId ZZZ -id list_of_id_separated_by_commas ... all * objects -c export -o line -format XXX -outputFile YYYY -exportId ZZZ * dependency criteria : sample for all lines of one network -c export -o * network -format XXX -outputFile YYYY -exportId ZZZ -id * list_of_network_id_separated_by_commas * //from w ww .j a va2 s . c o m * @param manager * @param parameters * @return */ public int executeExport(EntityManager session, INeptuneManager<NeptuneIdentifiedObject> manager, Map<String, List<String>> parameters) { String format = getSimpleString(parameters, "format"); Long exportId = Long.valueOf(getSimpleString(parameters, "exportid")); if (!exportDao.exists(exportId)) { // error export not found logger.error("export not found " + exportId); return 1; } GuiExport guiExport = exportDao.get(exportId); logger.info("Export data for export id " + exportId); logger.info(" type : " + guiExport.getType()); logger.info(" options : " + guiExport.getOptions()); logger.info(" references type : " + guiExport.getReferencesType()); logger.info(" reference ids : " + guiExport.getReferenceIds()); startProcess(session, guiExport); Referential referential = guiExport.getReferential(); logger.info("Referential " + referential.getId()); logger.info(" name : " + referential.getName()); logger.info(" slug : " + referential.getSlug()); logger.info(" projection type : " + referential.getProjectionType()); String projectionType = null; if (referential.getProjectionType() != null && !referential.getProjectionType().isEmpty()) { logger.info(" projection type for export: " + referential.getProjectionType()); projectionType = referential.getProjectionType(); parameters.put("projectionType", new ArrayList<String>()); parameters.get("projectionType").add(projectionType); } // set projection for export (inactive if not set) geographicService.switchProjection(projectionType); List<Report> reports = new ArrayList<Report>(); String[] ids = new String[0]; if (parameters.containsKey("id")) ids = getSimpleString(parameters, "id").split(","); try { List<FormatDescription> formats = manager.getExportFormats(null); FormatDescription description = null; for (FormatDescription formatDescription : formats) { if (formatDescription.getName().equalsIgnoreCase(format)) { description = formatDescription; break; } } if (description == null) { String objectName = getActiveObject(parameters); List<String> objects = parameters.get("object"); objects.clear(); objects.add("line"); manager = getManager(parameters); parameters.remove("id"); List<String> filter = new ArrayList<String>(); if (objectName.equals("network")) { filter.add("ptNetwork.id"); } else if (objectName.equals("company")) { filter.add("company.id"); } else { throw new IllegalArgumentException("format " + format + " unavailable for " + objectName); } if (ids != null && ids.length > 0) { filter.add("in"); filter.addAll(Arrays.asList(ids)); parameters.put("filter", filter); } return executeExport(session, manager, parameters); } List<ParameterValue> values = populateParameters(description, parameters); ReportHolder holder = new ReportHolder(); List<NeptuneIdentifiedObject> beans = executeGet(manager, parameters); manager.doExport(null, beans, format, values, holder); if (holder.getReport() != null) { Report r = holder.getReport(); reports.add(r); } } catch (Exception e) { logger.error("export failed " + e.getMessage(), e); GuiReport errorReport = new GuiReport("EXPORT_ERROR", Report.STATE.ERROR); GuiReportItem item = new GuiReportItem(GuiReportItem.KEY.EXCEPTION, Report.STATE.ERROR, e.getMessage()); errorReport.addItem(item); reports.add(errorReport); saveExportReports(guiExport, format, reports); return 1; } return saveExportReports(guiExport, format, reports); }
From source file:graphene.util.fs.FileUtils.java
public static void deleteRecursively(final File directory) throws IOException { final Stack<File> stack = new Stack<>(); final List<File> temp = new LinkedList<>(); stack.push(directory.getAbsoluteFile()); while (!stack.isEmpty()) { final File top = stack.pop(); File[] files = top.listFiles(); if (files != null) { for (final File child : files) { if (child.isFile()) { if (!deleteFile(child)) { throw new IOException("Failed to delete " + child.getCanonicalPath()); }/*from w ww . j av a 2s.co m*/ } else { temp.add(child); } } } files = top.listFiles(); if ((files == null) || (files.length == 0)) { if (!deleteFile(top)) { throw new IOException("Failed to delete " + top.getCanonicalPath()); } } else { stack.push(top); for (final File f : temp) { stack.push(f); } } temp.clear(); } }
From source file:com.extrahardmode.task.FallingLogsTask.java
@Override public void run() { if (block != null) { /* Prevent wooden structures near trees from being affected*/ if (blockModule.getBlocksInArea(block.getLocation(), 2, 1, Material.LEAVES).length > 3) { //Clear the area below of leaves Block below = block;// www. ja v a 2 s . co m List<Block> looseLogs = new ArrayList<Block>(); List<Block> tempBlocks = new ArrayList<Block>(); looseLogs.add(block); checkBelow: for (int i = 0; below.getY() > 0; i++) { below = below.getRelative(BlockFace.DOWN); switch (below.getType()) { case AIR: { //go one down //All blocks above this can fall now that there is an air block looseLogs.addAll(tempBlocks); tempBlocks.clear(); break; } case LEAVES: { below.breakNaturally(); break; } case LOG: { //Prevent Logs on adjacent sides (Jungle Tree) from turning to FallingBlocks and some of them turning into items switch (below.getRelative(BlockFace.DOWN).getType()) { case AIR: case LEAVES: tempBlocks.add(below); } break; } default: //we hit the block where the FallingBlock will land { if (blockModule.breaksFallingBlock(below.getType())) { below.breakNaturally(); } else { break checkBelow; } } } } for (int i = 0; i < looseLogs.size(); i++) { final Block looseLog = looseLogs.get(i); plugin.getServer().getScheduler().runTaskLater(plugin, new Runnable() { @Override public void run() { blockModule.applyPhysics(looseLog, true); } }, i /*delay to prevent FallingBlock collision*/); } } } }
From source file:com.wabacus.system.fileupload.AbsFileUpload.java
private String generateUploadFilesAndImportItems(List<AbsDataImportConfigBean> lstDiBeans, Map<String, FileItem> mUploadFiles, Map<List<DataImportItem>, Map<File, FileItem>> mResults, String filepath) {//from ww w . j av a 2 s .co m List<DataImportItem> lstDataImportItems = new ArrayList<DataImportItem>(); Map<File, FileItem> mUploadFileItems = new HashMap<File, FileItem>();//? mResults.put(lstDataImportItems, mUploadFileItems); List<String> lstTmpFile = new ArrayList<String>(); File fTmp; Map<String, File> mFileTmp = new HashMap<String, File>(); String[] strArrTmp; for (AbsDataImportConfigBean dibeanTmp : lstDiBeans) { lstTmpFile.clear(); for (String filenameTmp : mUploadFiles.keySet()) { strArrTmp = DataImportAssistant.getInstance().getRealFileNameAndImportType(filenameTmp); if (dibeanTmp.isMatch(strArrTmp[0])) { String file = FilePathAssistant.getInstance() .standardFilePath(filepath + File.separator + filenameTmp); fTmp = mFileTmp.get(file); if (fTmp == null) { fTmp = new File(file); mFileTmp.put(file, fTmp); mUploadFileItems.put(fTmp, mUploadFiles.get(filenameTmp)); } DataImportItem diitem = new DataImportItem(dibeanTmp, fTmp); diitem.setRequest(request); diitem.setSession(request.getSession()); diitem.setDynimportype(strArrTmp[1]); lstDataImportItems.add(diitem); lstTmpFile.add(filenameTmp); } } if (lstTmpFile.size() == 0) { log.warn("?" + dibeanTmp.getReskey() + "??"); } else if (lstTmpFile.size() > 1) { log.warn("??" + dibeanTmp.getReskey() + "???" + lstTmpFile + "?"); return "?" + dibeanTmp.getFilename() + "??"; } } if (lstDataImportItems.size() == 0) { return "?"; } return null; }
From source file:edu.duke.cabig.c3pr.web.ajax.BookRandomizationAjaxFacade.java
private void parseBookRandomizationWithoutStratification(String bookRandomizations, Epoch tEpoch) throws Exception { try {/*w ww . j av a2s . c o m*/ // we do not create a new instance of bookRandomization, we use the existing instance // which was created in StudyDesignTab.java // based on the randomizationType selected on the study_details page. BookRandomization randomization = null; if (tEpoch.getRandomization() instanceof BookRandomization) { randomization = (BookRandomization) tEpoch.getRandomization(); } else { return; } List<BookRandomizationEntry> breList = randomization.getBookRandomizationEntry(); //clear existing bookEntries breList.clear(); clearStratumGroups(tEpoch); StringTokenizer outer = new StringTokenizer(bookRandomizations, "\n"); String entry; String[] entries; Arm arm; BookRandomizationEntry bookRandomizationEntry = null; while (outer.hasMoreElements()) { entry = outer.nextToken(); if (entry.trim().length() > 0) { entries = entry.split(","); bookRandomizationEntry = breList.get(breList.size()); // set the position Integer position = null; try { position = Integer.valueOf(entries[0].trim()); } catch (NumberFormatException nfe) { log.debug("Illegal Position Entered."); } bookRandomizationEntry.setPosition(position); // find the arm with this id and set it here even if its null // Empty stratum groups with negetive stratum Group Numbers and arms are checked // for while generating the table and replaced with the string // "Invalid Entry" so the user can see which entries are incorrect. arm = getArmByName(tEpoch, entries[1].trim()); bookRandomizationEntry.setArm(arm); } } } catch (Exception e) { log.error("parseBookRandomizationWithoutStratification Failed"); log.error(e.getMessage()); throw e; } }
From source file:ru.org.linux.user.UserTagDaoIntegrationTest.java
@Test public void getUserIdListByTagsTest() { prepareUserTags();/*from w w w . j a v a 2 s. c om*/ List<Integer> userIdList; List<String> tags = new ArrayList<>(); tags.add("UserTagDaoIntegrationTest_tag1"); userIdList = userTagDao.getUserIdListByTags(user1Id, tags); Assert.assertEquals("Wrong count of user ID's.", 1, userIdList.size()); tags.add("UserTagDaoIntegrationTest_tag2"); userIdList = userTagDao.getUserIdListByTags(user1Id, tags); Assert.assertEquals("Wrong count of user ID's.", 1, userIdList.size()); tags.clear(); userTagDao.deleteTag(user1Id, tag5Id, true); tags.add("UserTagDaoIntegrationTest_tag5"); userIdList = userTagDao.getUserIdListByTags(user1Id, tags); Assert.assertEquals("Wrong count of user ID's.", 1, userIdList.size()); }