List of usage examples for java.util ArrayList contains
public boolean contains(Object o)
From source file:module.siadap.domain.wrappers.SiadapYearWrapper.java
public static SiadapYearWrapper getPreviousYearOrLatestAvailableWrapper() { Integer currentYear = new LocalDate().getYear(); SiadapYearWrapper siadapYearWrapper = null; ArrayList<Integer> yearsWithConfigs = SiadapYearsFromExistingSiadapConfigurations .getYearsWithExistingConfigs(); if (SiadapYearConfiguration.getSiadapYearConfiguration(currentYear) != null) { siadapYearWrapper = new SiadapYearWrapper(SiadapYearConfiguration .getSiadapYearConfiguration(currentYear).getPreviousSiadapYearConfiguration().getYear()); } else if (yearsWithConfigs.contains(new Integer(currentYear - 1))) { int year = new LocalDate().getYear() - 1; siadapYearWrapper = new SiadapYearWrapper(year); } else {// w w w.jav a2 s .c om siadapYearWrapper = getCurrentYearOrLatestAvailableWrapper(); } return siadapYearWrapper; }
From source file:com.icesoft.faces.facelets.D2DFaceletViewHandler.java
/** * Make a list of every UIComponent that has a duplicate id, as found * in the duplicateIds parameter.//from w ww.j a v a 2 s . c om * * @param comp UIComponent to recurse down through, searching for * duplicate ids. * @param duplicateIds2comps HashMap< String id, ArrayList<UIComponent> > * save every UIComponent with one of the * duplicate ids, so we can list them all * @param duplicateIds ArrayList<String id> duplicate ids encountered * before */ private static void compileDuplicateComponentIds(UIComponent comp, HashMap duplicateIds2comps, ArrayList duplicateIds) { String id = comp.getId(); if (id != null && duplicateIds.contains(id)) { ArrayList duplicateComps = (ArrayList) duplicateIds2comps.get(id); if (duplicateComps == null) { duplicateComps = new ArrayList(); duplicateIds2comps.put(id, duplicateComps); } duplicateComps.add(comp); } Iterator children = comp.getFacetsAndChildren(); while (children.hasNext()) { UIComponent child = (UIComponent) children.next(); compileDuplicateComponentIds(child, duplicateIds2comps, duplicateIds); } }
From source file:com.redhat.victims.VictimsConfig.java
/** * Returns a list of valid algorithms to be used when fingerprinting. If not * specified, or if all values are illegal, all available algorithms are * used.// w w w .j a va2 s . c om * * @return */ public static ArrayList<Algorithms> algorithms() { ArrayList<Algorithms> algorithms = new ArrayList<Algorithms>(); for (String alg : getPropertyValue(Key.ALGORITHMS).split(",")) { alg = alg.trim(); try { algorithms.add(Algorithms.valueOf(alg)); } catch (Exception e) { // skip } } if (!algorithms.contains(getDefaultAlgorithm())) { algorithms.add(getDefaultAlgorithm()); } return algorithms; }
From source file:de.suse.swamp.modules.screens.SWAMPScreen.java
/** * adding a workflowtemplate helplink//from w ww . j a v a 2 s . c om */ public static void addHelplink(WorkflowTemplate wfTemp, Context context, String uname) throws Exception { ArrayList helps = new ArrayList(); if (context.get("helps") != null) { helps = (ArrayList) context.get("helps"); } if (wfTemp.getHelpContext() != null) { ContextHelp help = null; DocumentationAPI docuapi = new DocumentationAPI(); String helppath = "workflows." + wfTemp.getName() + "." + wfTemp.getHelpContext(); help = docuapi.getContextHelp(helppath, uname); if (help != null && !helps.contains(help)) { helps.add(help); } else { Logger.ERROR("Did not find helpfile in path: " + helppath); } } context.put("helps", helps); }
From source file:com.twinsoft.convertigo.engine.util.CarUtils.java
public static ArrayList<File> deepListFiles(String sDir, String suffix) { final String _suffix = suffix; File[] all, files;//from w ww .j av a2 s . c om File f, dir; dir = new File(sDir); all = dir.listFiles(); files = dir.listFiles(new FilenameFilter() { public boolean accept(File dir, String name) { File file = new File(dir, name); return (file.getName().endsWith(_suffix)); } }); ArrayList<File> list = null, deep = null; if (files != null) { list = new ArrayList<File>(Arrays.asList(files)); } if ((list != null) && (all != null)) { for (int i = 0; i < all.length; i++) { f = all[i]; if (f.isDirectory() && !list.contains(f)) { deep = deepListFiles(f.getAbsolutePath(), suffix); if (deep != null) { list.addAll(deep); } } } } return list; }
From source file:gov.nist.appvet.properties.AppVetProperties.java
private static void setupTools() { File folder = new File(TOOLS_CONF_ROOT); File[] listOfFiles = folder.listFiles(); for (final File toolConfigFile : listOfFiles) { if (toolConfigFile.isFile()) { final String toolConfigFileName = toolConfigFile.getName(); if (toolConfigFileName.endsWith(".xml")) { final ToolServiceAdapter adapter = new ToolServiceAdapter(toolConfigFile); log.debug("Adding tool " + adapter.name); availableTools.add(adapter); }/*from ww w . j a va2s . c o m*/ } } listOfFiles = null; folder = null; // Check that all available tools have a column in the toolstatus table. ArrayList<String> tableColumnNames = Database.getTableColumnNames("toolstatus"); if (tableColumnNames == null) { log.error("Could not get table column names"); return; } for (int i = 0; i < availableTools.size(); i++) { final ToolServiceAdapter tool = availableTools.get(i); if (!tableColumnNames.contains(tool.id)) { // Add to table "toolstatus" tableColumnNames.add(tool.id); if (Database.addTableColumn("toolstatus", tool.id, "VARCHAR (120)")) { log.debug("Added tool '" + tool.id + "' to toolstatus table"); } else { log.error("Could not add tool '" + tool.id + "' to toolstatus table"); } } } tableColumnNames = null; }
From source file:com.concursive.connect.web.modules.wiki.utils.WikiUtils.java
private static Timestamp getLatestModifiedDate(Wiki wiki, Connection db, ArrayList children, Timestamp latest, ArrayList scanned) throws SQLException { Iterator i = children.iterator(); while (i.hasNext()) { String pageLink = (String) i.next(); LOG.debug("Checking getLatestModifiedDate: " + pageLink); if (!scanned.contains(pageLink)) { scanned.add(pageLink);//from w w w . jav a 2s . c o m Wiki thisWiki = WikiList.queryBySubject(db, pageLink, wiki.getProjectId()); if (thisWiki.getId() != -1) { if (thisWiki.getModified().after(latest)) { latest = thisWiki.getModified(); } latest = getLatestModifiedDate(thisWiki, db, getPageLinks(thisWiki), latest, scanned); } } } return latest; }
From source file:com.digitalgeneralists.assurance.Application.java
static void installDb(InputStream propertiesFileStream, InputStream dbScriptStream) throws IOException, SQLException { Logger logger = Logger.getLogger(Application.class); Connection dbConnection = null; ResultSet rs = null;/*from w w w .j a va2 s . c o m*/ try { Properties properties = new Properties(); if (propertiesFileStream != null) { properties.load(propertiesFileStream); } else { throw new FileNotFoundException("The database properties file could not be loaded."); } String dbUrl = (String) properties.get("jdbc.url"); String dbUser = (String) properties.get("jdbc.username"); String dbPassword = (String) properties.get("jdbc.password"); dbConnection = DriverManager.getConnection(dbUrl, dbUser, dbPassword); ArrayList<String> listOfDatabases = new ArrayList<String>(); DatabaseMetaData meta = dbConnection.getMetaData(); String[] tableTypes = { "TABLE" }; rs = meta.getTables(null, null, Application.verificationTableName, tableTypes); while (rs.next()) { String databaseName = rs.getString("TABLE_NAME"); listOfDatabases.add(databaseName.toUpperCase()); } if (listOfDatabases.contains(Application.verificationTableName)) { logger.info("Database already exists"); } else { ScriptRunner runner = new ScriptRunner(dbConnection, true, true); Reader dbScript = new InputStreamReader(dbScriptStream); runner.runScript(dbScript); logger.info("Database is created"); } } finally { if (rs != null) { try { rs.close(); rs = null; } catch (SQLException e) { // The ship is going down. Not much we can do. logger.fatal(e); } } if (dbConnection != null) { dbConnection.close(); dbConnection = null; } } logger = null; }
From source file:edu.du.penrose.systems.fedora.ResourceIndexUtils.java
/** * Return true an object exists in an collection, this object may or may not be another collection, A COLLECTION OBJECT is considered to * be a member of it's own Collection!!. This is needed for fedoraProxy. When fedoraProxy get's a request it always verifies that * the requested object is within a web-sites collection for security reasons. Therefore if we want to get a a datastream within * a collection object, it has to pass the isObjectInCollection() test. <br> * If the collection object or the object is null, return false. * /*from w ww . j ava 2 s.com*/ * The administrator is just used to get the host,port,user, and pwd info. * The call to the resource index is actually via httpClient and rest call. * * @see #isCollection(Administrator, String) * @see FedoraAppBatchIngestController#getAdministrator() * @param administrator The administrator is just used to get host,port,user,password info. * @param collectionPid * @param object * @return true if object is a child of the collection */ public static boolean isObjectInCollection(Administrator administrator, String collectionPid, String object) { if (collectionPid == null || object == null) { return false; } /* * If the collection and the object are the same return true, see description above. */ if (collectionPid.equalsIgnoreCase(object)) { return true; } try { String namespace = object.split(":")[0]; ArrayList allChidren = getChildObjects(administrator, collectionPid); if (allChidren.contains(object)) { return true; } else { return false; } } catch (Exception e) { return false; } }
From source file:javadepchecker.Main.java
private static boolean depsFound(Collection<String> pkgs, Collection<String> deps) throws IOException { boolean found = true; Collection<String> jars = new ArrayList<String>(); String[] bootClassPathJars = System.getProperty("sun.boot.class.path").split(":"); // Do we need "java-config -r" here? for (String jar : bootClassPathJars) { File jarFile = new File(jar); if (jarFile.exists()) { jars.add(jar);// w w w . j ava2 s .co m } } for (Iterator<String> pkg = pkgs.iterator(); pkg.hasNext();) { jars.addAll(getPackageJars(pkg.next())); } if (jars.size() == 0) { return false; } ArrayList<String> jarClasses = new ArrayList<String>(); for (String jarName : jars) { JarFile jar = new JarFile(jarName); for (Enumeration<JarEntry> e = jar.entries(); e.hasMoreElements();) { jarClasses.add(e.nextElement().getName()); } } for (String dep : deps) { if (!jarClasses.contains(dep)) { if (found) { System.out.println("Class files not found via DEPEND in package.env"); } System.out.println("\t" + dep); found = false; } } return found; }