List of usage examples for java.util List remove
E remove(int index);
From source file:MailHandlerDemo.java
/** * Sets up the demos that will run.// w w w . j a v a 2 s.c o m * * @param l the list of arguments. * @return true if debug is on. */ private static boolean init(List<String> l) { l = new ArrayList<String>(l); Session session = Session.getInstance(System.getProperties()); boolean all = l.remove("-all") || l.isEmpty(); if (l.remove("-body") || all) { initBodyOnly(); } if (l.remove("-custom") || all) { initCustomAttachments(); } if (l.remove("-low") || all) { initLowCapacity(); } if (l.remove("-pushfilter") || all) { initWithPushFilter(); } if (l.remove("-pushlevel") || all) { initWithPushLevel(); } if (l.remove("-pushnormal") || all) { initPushNormal(); } if (l.remove("-pushonly") || all) { initPushOnly(); } if (l.remove("-simple") || all) { initSimpleAttachment(); } boolean fallback = applyFallbackSettings(); boolean debug = l.remove("-debug") || session.getDebug(); if (debug) { checkConfig(CLASS_NAME, session.getDebugOut()); } if (!l.isEmpty()) { LOGGER.log(Level.SEVERE, "Unknown commands: {0}", l); } if (fallback) { LOGGER.info("Check your user temp dir for output."); } return debug; }
From source file:net.sf.jabref.external.RegExpFileSearch.java
/** * The actual work-horse. Will find absolute filepaths starting from the * given directory using the given regular expression string for search. */// w ww . j a va 2 s .c o m private static List<File> findFile(BibEntry entry, File directory, String file, String extensionRegExp) { List<File> res = new ArrayList<>(); File actualDirectory; if (file.startsWith("/")) { actualDirectory = new File("."); file = file.substring(1); } else { actualDirectory = directory; } // Escape handling... Matcher m = ESCAPE_PATTERN.matcher(file); StringBuffer s = new StringBuffer(); while (m.find()) { m.appendReplacement(s, m.group(1) + '/' + m.group(2)); } m.appendTail(s); file = s.toString(); String[] fileParts = file.split("/"); if (fileParts.length == 0) { return res; } for (int i = 0; i < (fileParts.length - 1); i++) { String dirToProcess = fileParts[i]; dirToProcess = expandBrackets(dirToProcess, entry, null); if (dirToProcess.matches("^.:$")) { // Windows Drive Letter actualDirectory = new File(dirToProcess + '/'); continue; } if (".".equals(dirToProcess)) { // Stay in current directory continue; } if ("..".equals(dirToProcess)) { actualDirectory = new File(actualDirectory.getParent()); continue; } if ("*".equals(dirToProcess)) { // Do for all direct subdirs File[] subDirs = actualDirectory.listFiles(); if (subDirs != null) { String restOfFileString = StringUtil.join(fileParts, "/", i + 1, fileParts.length); for (File subDir : subDirs) { if (subDir.isDirectory()) { res.addAll(findFile(entry, subDir, restOfFileString, extensionRegExp)); } } } } // Do for all direct and indirect subdirs if ("**".equals(dirToProcess)) { List<File> toDo = new LinkedList<>(); toDo.add(actualDirectory); String restOfFileString = StringUtil.join(fileParts, "/", i + 1, fileParts.length); while (!toDo.isEmpty()) { // Get all subdirs of each of the elements found in toDo File[] subDirs = toDo.remove(0).listFiles(); if (subDirs == null) { continue; } toDo.addAll(Arrays.asList(subDirs)); for (File subDir : subDirs) { if (!subDir.isDirectory()) { continue; } res.addAll(findFile(entry, subDir, restOfFileString, extensionRegExp)); } } } // End process directory information } // Last step: check if the given file can be found in this directory String filePart = fileParts[fileParts.length - 1].replace("[extension]", EXT_MARKER); String filenameToLookFor = expandBrackets(filePart, entry, null).replaceAll(EXT_MARKER, extensionRegExp); final Pattern toMatch = Pattern.compile('^' + filenameToLookFor.replaceAll("\\\\\\\\", "\\\\") + '$', Pattern.CASE_INSENSITIVE); File[] matches = actualDirectory.listFiles((arg0, arg1) -> { return toMatch.matcher(arg1).matches(); }); if ((matches != null) && (matches.length > 0)) { Collections.addAll(res, matches); } return res; }
From source file:com.huateng.startup.init.MenuInfoUtil.java
/** * ??// w w w . j av a 2 s . com */ @SuppressWarnings("unchecked") public static void init() { String hql = "from com.huateng.po.TblFuncInf t where t.FuncType in ('0','1','2') order by t.FuncId"; ICommQueryDAO commQueryDAO = (ICommQueryDAO) ContextUtil.getBean("CommQueryDAO"); List<TblFuncInf> funcInfList = commQueryDAO.findByHQLQuery(hql); for (int i = 0, n = funcInfList.size(); i < n; i++) { TblFuncInf tblFuncInf = funcInfList.get(i); if (Constants.MENU_LVL_1.equals(tblFuncInf.getFuncType())) {//?? Map<String, Object> menuBean = new LinkedHashMap<String, Object>(); String menuId = tblFuncInf.getFuncId().toString().trim(); menuBean.put(Constants.MENU_ID, menuId); menuBean.put(Constants.MENU_TEXT, tblFuncInf.getFuncName().trim()); menuBean.put(Constants.MENU_CLS, Constants.MENU_FOLDER); allMenuBean.addJSONArrayElement(menuBean); } else if (Constants.MENU_LVL_2.equals(tblFuncInf.getFuncType())) {//?? Map<String, Object> menuBean = new LinkedHashMap<String, Object>(); menuBean.put(Constants.MENU_ID, tblFuncInf.getFuncId().toString().trim()); menuBean.put(Constants.MENU_TEXT, tblFuncInf.getFuncName().trim()); menuBean.put(Constants.MENU_PARENT_ID, tblFuncInf.getFuncParentId().toString().trim()); menuBean.put(Constants.MENU_CLS, Constants.MENU_FOLDER); addLvl2Menu(menuBean); } else if (Constants.MENU_LVL_3.equals(tblFuncInf.getFuncType())) { Map<String, Object> menuBean = new LinkedHashMap<String, Object>(); menuBean.put(Constants.MENU_ID, tblFuncInf.getFuncId().toString().trim()); menuBean.put(Constants.MENU_TEXT, tblFuncInf.getFuncName().trim()); menuBean.put(Constants.MENU_PARENT_ID, tblFuncInf.getFuncParentId().toString().trim()); menuBean.put(Constants.MENU_LEAF, true); menuBean.put(Constants.MENU_URL, tblFuncInf.getPageUrl().trim()); menuBean.put(Constants.MENU_CLS, Constants.MENU_FILE); if ("-".equals(tblFuncInf.getIconPath().trim())) { menuBean.put(Constants.TOOLBAR_ICON, Constants.TOOLBAR_ICON_MENUITEM); } else { menuBean.put(Constants.TOOLBAR_ICON, tblFuncInf.getIconPath().trim()); } addLvl3Menu(menuBean); } } //?? List<Object> menuLvl1List = allMenuBean.getDataList(); for (int i = 0; i < menuLvl1List.size(); i++) { Map<String, Object> menuLvl1Bean = (Map<String, Object>) menuLvl1List.get(i); if (!menuLvl1Bean.containsKey(Constants.MENU_CHILDREN)) { menuLvl1List.remove(i); i--; continue; } List<Object> menuLvl2List = (List<Object>) menuLvl1Bean.get(Constants.MENU_CHILDREN); for (int j = 0; j < menuLvl2List.size(); j++) { Map<String, Object> menuLvl2Bean = (Map<String, Object>) menuLvl2List.get(j); if (!menuLvl2Bean.containsKey(Constants.MENU_CHILDREN)) { menuLvl2List.remove(j); menuLvl1Bean.put(Constants.MENU_CHILDREN, menuLvl2List); menuLvl1List.set(i, menuLvl1Bean); allMenuBean.setDataList(menuLvl1List); j--; } } } }
From source file:com.cloudera.flume.conf.FlumeBuilder.java
/** * This method populates the id, argv,and kwargs into ctx needed to build * source/sink/deco name/* w w w . jav a2s. co m*/ * * @param t * @param ctx * @return * @throws FlumeSpecException */ @SuppressWarnings("unchecked") static Pair<String, List<String>> handleArgs(CommonTree t, Context ctx) throws FlumeSpecException { List<CommonTree> children = (List<CommonTree>) new ArrayList<CommonTree>(t.getChildren()); String sinkType = children.remove(0).getText(); List<String> args = new ArrayList<String>(); for (CommonTree tr : children) { String arg = buildSimpleArg(tr); if (arg != null) { args.add(arg); } else { Pair<String, CommonTree> kwarg = buildKWArg(tr); ctx.putValue(kwarg.getLeft(), buildSimpleArg(kwarg.getRight())); } } return new Pair<String, List<String>>(sinkType, args); }
From source file:com.limegroup.gnutella.gui.LanguageUtils.java
/** * Returns an array of supported language as a LanguageInfo[], always having * the English language as the first element. * /*from ww w . j a va 2s .co m*/ * This will only include languages that can be displayed using the given * font. If the font is null, all languages are returned. */ public static Locale[] getLocales(Font font) { final List<Locale> locales = new LinkedList<Locale>(); File jar = FileUtils.getJarFromClasspath(LanguageUtils.class.getClassLoader(), BUNDLE_MARKER); if (jar != null) { addLocalesFromJar(locales, jar); } else { LOG.warn("Could not find bundle jar to determine locales"); } Collections.sort(locales, new Comparator<Locale>() { public int compare(Locale o1, Locale o2) { return o1.getDisplayName(o1).compareToIgnoreCase(o2.getDisplayName(o2)); } }); locales.remove(Locale.ENGLISH); locales.add(0, Locale.ENGLISH); // remove languages that cannot be displayed using this font if (font != null && !OSUtils.isMacOSX()) { for (Iterator<Locale> it = locales.iterator(); it.hasNext();) { Locale locale = it.next(); if (!GUIUtils.canDisplay(font, locale.getDisplayName(locale))) { it.remove(); } } } return locales.toArray(new Locale[0]); }
From source file:org.dkpro.similarity.experiments.rte.util.Evaluator.java
@SuppressWarnings("unchecked") public static void runEvaluationMetric(EvaluationMetric metric, Dataset dataset) throws IOException { // Get all subdirectories (i.e. all classifiers) File outputDir = new File(OUTPUT_DIR + "/" + dataset.toString() + "/"); File[] dirsArray = outputDir.listFiles((FileFilter) FileFilterUtils.directoryFileFilter()); List<File> dirs = CollectionUtils.arrayToList(dirsArray); // Don't list hidden dirs (such as .svn) for (int i = dirs.size() - 1; i >= 0; i--) if (dirs.get(i).getName().startsWith(".")) dirs.remove(i); // Iteratively evaluate all classifiers' results for (File dir : dirs) runEvaluationMetric(WekaClassifier.valueOf(dir.getName()), metric, dataset); }
From source file:com.intellij.plugins.haxe.ide.annotator.HaxeSemanticAnnotator.java
static public void check(final HaxePackageStatement element, final AnnotationHolder holder) { final HaxeReferenceExpression expression = element.getReferenceExpression(); String packageName = (expression != null) ? expression.getText() : ""; PsiDirectory fileDirectory = element.getContainingFile().getParent(); List<PsiFileSystemItem> fileRange = PsiFileUtils.getRange(PsiFileUtils.findRoot(fileDirectory), fileDirectory);/*from www .j ava 2s . c o m*/ fileRange.remove(0); String actualPath = PsiFileUtils.getListPath(fileRange); final String actualPackage = actualPath.replace('/', '.'); final String actualPackage2 = HaxeResolveUtil.getPackageName(element.getContainingFile()); // @TODO: Should use HaxeResolveUtil for (String s : StringUtils.split(packageName, '.')) { if (!s.substring(0, 1).toLowerCase().equals(s.substring(0, 1))) { //HaxeSemanticError.addError(element, new HaxeSemanticError("Package name '" + s + "' must start with a lower case character")); // @TODO: Move to bundle holder.createErrorAnnotation(element, "Package name '" + s + "' must start with a lower case character"); } } if (!packageName.equals(actualPackage)) { holder.createErrorAnnotation(element, "Invalid package name! '" + packageName + "' should be '" + actualPackage + "'") .registerFix(new HaxeFixer("Fix package") { @Override public void run() { Document document = PsiDocumentManager.getInstance(element.getProject()) .getDocument(element.getContainingFile()); if (expression != null) { TextRange range = expression.getTextRange(); document.replaceString(range.getStartOffset(), range.getEndOffset(), actualPackage); } else { int offset = element.getNode().findChildByType(HaxeTokenTypes.OSEMI).getTextRange() .getStartOffset(); document.replaceString(offset, offset, actualPackage); } } }); } }
From source file:de.steilerdev.myVerein.server.model.Settings.java
static public Settings loadSettings(SettingsRepository settingsRepository) { logger.debug("Getting current settings"); List<Settings> currentSettings = settingsRepository.findAll(); Settings currentSetting;//from w w w. j a v a 2s . c o m if (currentSettings == null || currentSettings.isEmpty()) { logger.info("Unable to find settings in database, creating new object"); currentSetting = new Settings(); currentSetting.saveSettings(null, settingsRepository); } else { currentSetting = currentSettings.remove(0); if (!currentSettings.isEmpty()) { settingsRepository.delete(currentSettings); } } try { currentSetting.loadSettingsFromFile(); } catch (IOException e) { logger.error("Unable to load settings"); } return currentSetting; }
From source file:com.igormaznitsa.upom.UPomModel.java
private static void insideElementJanitor(final Log log, final Node node, final List<String> path) { path.add(node.getNodeName());/*from www . ja va 2s . com*/ Node element = findFirstElement(node); while (element != null) { duplicatedSiblingJanitor(log, element, path); element = nextSiblingElement(element); } path.remove(path.size() - 1); }
From source file:Main.java
public static String camelCaseToSnakeCase(String camelCase) { List<String> tokens = new ArrayList<>(); Matcher matcher = PATTERN.matcher(camelCase); String acronym = ""; while (matcher.find()) { String found = matcher.group(); if (found.matches("^[A-Z]$")) { acronym += found;// w w w . ja v a 2 s . c om } else { if (acronym.length() > 0) { // we have an acronym to add before we continue tokens.add(acronym); acronym = ""; } tokens.add(found.toLowerCase()); } } if (acronym.length() > 0) { tokens.add(acronym); } if (tokens.size() > 0) { StringBuilder sb = new StringBuilder(tokens.remove(0)); for (String s : tokens) { sb.append("_").append(s); } return sb.toString(); } else { return camelCase; } }