List of usage examples for java.util ArrayList contains
public boolean contains(Object o)
From source file:org.obiba.mica.micaConfig.service.EntityConfigService.java
private void mergeRequiredFields(JsonNode baseNode, JsonNode overrideNode) { ArrayList<JsonNode> baseRequiredItems = Lists.newArrayList(baseNode.get("required")); for (JsonNode overrideRequiredItem : overrideNode.get("required")) { if (!baseRequiredItems.contains(overrideRequiredItem)) { ((ArrayNode) baseNode.get("required")).add(overrideRequiredItem); }// w w w . j ava 2s .c om } }
From source file:com.android.applications.todoist.containers.Tasks.java
public ArrayList<Date> getDates() { ArrayList<Date> list = new ArrayList<Date>(); Date tempDate;//from w w w . j a v a 2 s . co m int size = this.tasks.size(); for (int i = 0; i < size; i++) { tempDate = this.tasks.get(i).getDueDate(); if (!list.contains(tempDate)) { list.add(tempDate); } } return list; }
From source file:jeplus.TRNSYSWinTools.java
/** * Update the line in the DCK template file where ASSIGN call is used. This function copies the "assigned" file into the work folder * and strip off any paths/*from w w w .j a va2s .c o m*/ * * @param line Assign line * @param DCKDir The directory of template DCK * @param WorkDir The working directory in which the new DCK file will be saved * @param searchstrings The list of search strings to be looked up * @param newvals The list of new values to be used to replace the search strings * @param Printers The printers in the dck model * @return Assign line modified */ public static String TRNSYSUpdateAssign2(String line, String DCKDir, String WorkDir, String[] searchstrings, String[] newvals, ArrayList<String> Printers) { // Parse Assign statement - file name should reside in a pair of " " or immediately after "ASSIGN" String[] args = new String[0]; if (line.contains("\"")) { args = line.trim().split("\\s*\"\\s*"); } else { args = line.trim().split("\\s* \\s*"); } // Check if file name in the output file list String assigname = new File(args[1].trim()).getName(); String fullpath = RelativeDirUtil.checkAbsolutePath(args[1].trim(), DCKDir); if (!Printers.contains(assigname.toLowerCase())) { if (new File(fullpath).exists()) { boolean ok = true; try (BufferedReader insassign = new BufferedReader( new InputStreamReader(new FileInputStream(fullpath), "ISO-8859-1")); PrintWriter outsassign = new PrintWriter( new OutputStreamWriter(new FileOutputStream(WorkDir + assigname), "ISO-8859-1"))) { String line2 = insassign.readLine(); while (line2 != null) { for (int j = 0; j < searchstrings.length; j++) { line2 = line2.replaceAll(searchstrings[j], newvals[j]); } outsassign.println(line2); line2 = insassign.readLine(); } outsassign.flush(); } catch (Exception ex) { logger.error("Error updating file " + fullpath + " to " + WorkDir + assigname, ex); ok = false; } if (ok) { line = args[0].trim() + " \"" + assigname + "\" " + args[2].trim(); TRNSYSTask.setjeplusfile(assigname); } else { line = args[0].trim() + " \"" + fullpath + "\" " + args[2].trim(); new File(WorkDir + assigname).delete(); } } else { line = args[0].trim() + " \"" + fullpath + "\" " + args[2].trim(); } } else { line = args[0].trim() + " \"" + assigname + "\" " + args[2].trim(); } return line; }
From source file:models.Indexer.java
private void downloadAndIndex(ArrayList<String> all_files_on_ftp) { FtpFileDownloader indexer = new FtpFileDownloader(ftp_address, all_files_on_ftp); indexer.start();/*from www.j a v a 2s . c om*/ File directory = new File(installation_directory_path + "\\downloads"); if (!directory.exists()) directory.mkdir(); ArrayList<String> completed = new ArrayList<>(); while (!all_files_downloaded_status) { for (File cur_file : directory.listFiles()) { if (cur_file.isFile() && !completed.contains(cur_file.getName())) { try { performIndexing(cur_file.getName()); completed.add(cur_file.getName()); } catch (IOException ex) { System.out.println("can not perform indexing on the file: " + cur_file.getName()); Logger.getLogger(Indexer.class.getName()).log(Level.SEVERE, null, ex); } } } } }
From source file:models.LocalIndexer.java
private void downloadAndIndex(ArrayList<String> all_files_on_ftp) { FtpFileDownloader indexer = new FtpFileDownloader(ftp_address, all_files_on_ftp); indexer.start();/* www . ja va 2 s. com*/ File directory = new File(installation_directory_path + "\\downloads"); if (!directory.exists()) directory.mkdir(); ArrayList<String> completed = new ArrayList<>(); while (!all_files_downloaded_status) { for (File cur_file : directory.listFiles()) { if (cur_file.isFile() && !completed.contains(cur_file.getName())) { try { performIndexing(cur_file.getName()); completed.add(cur_file.getName()); } catch (IOException ex) { System.out.println("can not perform indexing on the file: " + cur_file.getName()); Logger.getLogger(LocalIndexer.class.getName()).log(Level.SEVERE, null, ex); } } } } }
From source file:com.hygenics.parser.ExistanceChecker.java
public void run() { if (globsExists != null && globsExists.size() > 0) { ArrayList<Boolean> matches = checkFilesExist(globsExists, directories, true); if (matches.contains(false)) { try { throw new FileNotFoundException("A Required File was Not Found"); } catch (FileNotFoundException e) { e.printStackTrace();/* w w w . j a va 2 s.co m*/ System.exit(-1); } } } if (globsNotExists != null && globsNotExists.size() > 0) { ArrayList<Boolean> matches = checkFilesExist(globsNotExists, directories, false); if (matches.contains(false)) { try { throw new Exception("A File That Cannot Be Present Was Found"); } catch (Exception e) { e.printStackTrace(); System.exit(-1); } } } if (schemaExists != null && schemaExists.size() > 0) { ArrayList<Boolean> matches = checkSchemasExist(schemaExists, true); if (matches.contains(false)) { try { throw new SchemaMissingException("A Required Schema was Not Found."); } catch (Exception e) { e.printStackTrace(); System.exit(-1); } } } if (schemaNotExists != null && schemaNotExists.size() > 0) { ArrayList<Boolean> matches = checkSchemasExist(schemaNotExists, false); if (matches.contains(false)) { try { throw new Exception("A Schema was Found that Cannot Be Present"); } catch (Exception e) { e.printStackTrace(); System.exit(-1); } } } if (tableExists != null && tableExists.size() > 0) { ArrayList<Boolean> matches = checkTablesExist(tableExists, true); if (matches.contains(false)) { try { throw new TableMissingException("A Required Table Was Missing"); } catch (TableMissingException e) { e.printStackTrace(); System.exit(-1); } } } if (tableNotExists != null && tableNotExists.size() > 0) { ArrayList<Boolean> matches = checkTablesExist(tableExists, false); if (matches.contains(false)) { try { throw new Exception("A Table WasFound that Cannot Exist"); } catch (Exception e) { e.printStackTrace(); System.exit(-1); } } } }
From source file:com.android.launcher3.InstallShortcutReceiver.java
public static void removeFromInstallQueue(Context context, ArrayList<String> packageNames, UserHandleCompat user) {/*from www.ja v a 2 s. com*/ if (packageNames.isEmpty()) { return; } String spKey = LauncherAppState.getSharedPreferencesKey(); SharedPreferences sp = context.getSharedPreferences(spKey, Context.MODE_PRIVATE); synchronized (sLock) { Set<String> strings = sp.getStringSet(APPS_PENDING_INSTALL, null); if (DBG) { Log.d(TAG, "APPS_PENDING_INSTALL: " + strings + ", removing packages: " + packageNames); } if (strings != null) { Set<String> newStrings = new HashSet<String>(strings); Iterator<String> newStringsIter = newStrings.iterator(); while (newStringsIter.hasNext()) { String encoded = newStringsIter.next(); PendingInstallShortcutInfo info = decode(encoded, context); if (info == null || (packageNames.contains(info.getTargetPackage()) && user.equals(info.user))) { newStringsIter.remove(); } } sp.edit().putStringSet(APPS_PENDING_INSTALL, newStrings).commit(); } } }
From source file:com.stv.launcher.receiver.InstallShortcutReceiver.java
public static void removeFromInstallQueue(Context context, ArrayList<String> packageNames, UserHandleCompat user) {/* w w w .j a v a 2 s . c o m*/ if (packageNames.isEmpty()) { return; } String spKey = LauncherState.getSharedPreferencesKey(); SharedPreferences sp = context.getSharedPreferences(spKey, Context.MODE_PRIVATE); synchronized (sLock) { Set<String> strings = sp.getStringSet(APPS_PENDING_INSTALL, null); if (DBG) { Log.d(TAG, "APPS_PENDING_INSTALL: " + strings + ", removing packages: " + packageNames); } if (strings != null) { Set<String> newStrings = new HashSet<String>(strings); Iterator<String> newStringsIter = newStrings.iterator(); while (newStringsIter.hasNext()) { String encoded = newStringsIter.next(); PendingInstallShortcutInfo info = decode(encoded, context); if (info == null || (packageNames.contains(info.getTargetPackage()) && user.equals(info.user))) { newStringsIter.remove(); } } sp.edit().putStringSet(APPS_PENDING_INSTALL, newStrings).commit(); } } }
From source file:org.cloudfoundry.identity.uaa.user.UaaUser.java
public UaaUser authorities(Collection<? extends GrantedAuthority> authorities) { ArrayList<GrantedAuthority> values = new ArrayList<GrantedAuthority>(authorities); for (int i = 0; i < values.size(); i++) { GrantedAuthority authority = values.get(i); values.set(i, UaaAuthority.authority(authority.toString())); }/*www . j a v a 2 s . co m*/ if (!values.contains(UaaAuthority.UAA_USER)) { values.add(UaaAuthority.UAA_USER); } UaaUser user = new UaaUser(id, username, password, email, values, givenName, familyName, created, modified); return user; }
From source file:com.baobao121.baby.common.SimpleUploaderServlet.java
/** * Helper function to verify if a file extension is allowed or not allowed. */// ww w . ja v a 2 s . c om private boolean extIsAllowed(String fileType, String ext) { ext = ext.toLowerCase(); ArrayList allowList = (ArrayList) allowedExtensions.get(fileType); if (allowList.contains(ext)) return true; else return false; }