List of usage examples for java.util List contains
boolean contains(Object o);
From source file:dk.netarkivet.harvester.webinterface.DomainDefinition.java
/** * Returns the list of domain configurations which are either used in a concrete harvest or is a 'default * configuration'.//from w w w . java 2 s . c o m * <p> * The list is sorted alphabetically by name according to the supplied locale. * * @param domain The domain to find the used configurations for. * @param locale The locale to base the sorting on * @return A sorted list of used configurations for the supplied domain. */ public static List<DomainConfiguration> getUsedConfiguration(Domain domain, Locale locale) { List<Long> usedConfigurationIDs = DomainDAO.getInstance().findUsedConfigurations(domain.getID()); List<DomainConfiguration> usedConfigurations = new LinkedList<DomainConfiguration>(); for (DomainConfiguration configuration : domain.getAllConfigurationsAsSortedList(locale)) { if (usedConfigurationIDs.contains(new Long(configuration.getID())) || configuration.getID() == domain.getDefaultConfiguration().getID()) { usedConfigurations.add(configuration); } } NamedUtils.sortNamedObjectList(locale, usedConfigurations); return usedConfigurations; }
From source file:com.activecq.api.helpers.WCMHelper.java
/** * "Intelligently" determines the WCMEditType to use based on the * DropTarget./*from w w w .j a v a 2 s . c o m*/ * * Inspects the DropTarget's Groups and Accepts to make this determination. * * If no match can be found, defaults to TEXT * * @param dropTarget * @return */ protected static WCMEditType.Type getWCMEditType(DropTarget dropTarget) { if (dropTarget == null) { return WCMEditType.NONE; } List<String> groups = Arrays.asList(dropTarget.getGroups()); List<String> accepts = Arrays.asList(dropTarget.getAccept()); if (groups.isEmpty() && accepts.isEmpty()) { return WCMEditType.NONE; } if (groups.contains("media")) { if (matches(accepts, "image")) { return WCMEditType.IMAGE; } else if (matches(accepts, "video")) { return WCMEditType.VIDEO; } else if (matches(accepts, "flash")) { return WCMEditType.FLASH; } else if (accepts.size() == 1 && ".*".equals(accepts.get(0))) { return WCMEditType.FILE; } } else if (groups.contains("page")) { return WCMEditType.REFERENCE; } else if (groups.contains("paragraph")) { return WCMEditType.REFERENCE; } return WCMEditType.TEXT; }
From source file:com.sparkplatform.api.core.PropertyAsserter.java
/** * See {@link #assertBasicGetterSetterBehavior(Object,String)} method. Big difference here is that we try to * automatically introspect the target object, finding read/write properties, and automatically testing the getter * and setter. Note specifically that read-only properties are ignored, as there is no way for us to know how to set * the value (since there isn't a public setter). * <p/>//from www . j av a 2 s . c o m * Any property names contained in the blacklist will be skipped. * <p/> * * @param target the object on which to invoke the getter and setter * @param propertyNames the list of property names that should not be tested */ public static void assertBasicGetterSetterBehaviorWithBlacklist(Object target, String... propertyNames) { List<String> blacklist = Arrays.asList(propertyNames); try { BeanInfo beanInfo = Introspector.getBeanInfo(target.getClass()); PropertyDescriptor[] descriptors = beanInfo.getPropertyDescriptors(); for (PropertyDescriptor descriptor : descriptors) { if (descriptor.getWriteMethod() == null) { continue; } if (!blacklist.contains(descriptor.getDisplayName())) { assertBasicGetterSetterBehavior(target, descriptor.getDisplayName()); } } } catch (IntrospectionException e) { fail("Failed while introspecting target " + target.getClass()); } }
From source file:com.netcrest.pado.tools.pado.util.PadoShellUtil.java
/** * Returns an array of grid IDs found in the specified commandLine with the * -grid option.//from ww w . jav a2s .co m * * @param command * Commnand * @param commandLine * Command line with the -grid option. Grid IDs must be comma * separated with no spaces. * @param isGridAllBothRequired * true if both -grid and -all must present in the specified * commandLine. * @return */ @SuppressWarnings("unchecked") public final static String[] getGridIds(ICommand command, CommandLine commandLine, boolean isGridAllBothRequired) { boolean isAllPaths = commandLine.hasOption("all"); List<String> argList = (List<String>) commandLine.getArgList(); if (isAllPaths && argList.size() > 1) { PadoShell.printlnError(command, "Both '-all' and path not allowed."); return null; } String gridValue = commandLine.getOptionValue("grid"); if (isGridAllBothRequired) { if (gridValue != null && isAllPaths == false) { PadoShell.printlnError(command, "'-grid' requires '-all'"); return null; } } String gridIds[] = null; if (gridValue == null) { String gridId = SharedCache.getSharedCache().getPado().getGridId(); gridIds = new String[] { gridId }; } else { gridIds = gridValue.split(","); List<String> gridIdList = new ArrayList<String>(gridIds.length); for (String gridId : gridIds) { if (gridId.length() == 0) { continue; } if (SharedCache.getSharedCache().getGridInfo(gridId) == null) { PadoShell.printlnError(command, gridId + ": Undefined grid ID."); return null; } if (gridIdList.contains(gridId) == false) { gridIdList.add(gridId); } } gridIds = gridIdList.toArray(new String[gridIdList.size()]); } return gridIds; }
From source file:com.linkedin.pinot.perf.ForwardIndexReaderBenchmark.java
private static void benchmarkForwardIndex(String indexDir, List<String> includeColumns) throws Exception { SegmentMetadataImpl segmentMetadata = new SegmentMetadataImpl(new File(indexDir)); String segmentVersion = segmentMetadata.getVersion(); Set<String> columns = segmentMetadata.getAllColumns(); for (String column : columns) { if (includeColumns != null && !includeColumns.isEmpty()) { if (!includeColumns.contains(column)) { continue; }/* w w w .j a v a 2 s . c o m*/ } ColumnMetadata columnMetadata = segmentMetadata.getColumnMetadataFor(column); if (columnMetadata.isSingleValue()) { continue; } if (!columnMetadata.isSingleValue()) { String fwdIndexFileName = segmentMetadata.getForwardIndexFileName(column, segmentVersion); File fwdIndexFile = new File(indexDir, fwdIndexFileName); multiValuedReadBenchMark(segmentVersion, fwdIndexFile, segmentMetadata.getTotalDocs(), columnMetadata.getTotalNumberOfEntries(), columnMetadata.getMaxNumberOfMultiValues(), columnMetadata.getBitsPerElement()); } else if (columnMetadata.isSingleValue() && !columnMetadata.isSorted()) { String fwdIndexFileName = segmentMetadata.getForwardIndexFileName(column, segmentVersion); File fwdIndexFile = new File(indexDir, fwdIndexFileName); singleValuedReadBenchMark(segmentVersion, fwdIndexFile, segmentMetadata.getTotalDocs(), columnMetadata.getBitsPerElement()); } } }
From source file:canreg.client.analysis.Tools.java
public static double sumUpTheRest(LinkedList<CancerCasesCount> theRestList, List<Integer> dontCountIndexes) { double theRest = 0; for (CancerCasesCount count : theRestList) { if (!dontCountIndexes.contains((Integer) count.getIndex())) { theRest += count.getCount(); } else {//from w w w. j a va 2 s.c o m System.out.println("Found..."); } } return theRest; }
From source file:Main.java
public static void deletePersonGroups(List<String> personGroupIdsToDelete, Context context) { SharedPreferences personGroupIdNameMap = context.getSharedPreferences("PersonGroupIdNameMap", Context.MODE_PRIVATE); SharedPreferences.Editor personGroupIdNameMapEditor = personGroupIdNameMap.edit(); for (String personGroupId : personGroupIdsToDelete) { personGroupIdNameMapEditor.remove(personGroupId); }//from ww w. j a v a2s .c o m personGroupIdNameMapEditor.commit(); Set<String> personGroupIds = getAllPersonGroupIds(context); Set<String> newPersonGroupIds = new HashSet<>(); for (String personGroupId : personGroupIds) { if (!personGroupIdsToDelete.contains(personGroupId)) { newPersonGroupIds.add(personGroupId); } } SharedPreferences personGroupIdSet = context.getSharedPreferences("PersonGroupIdSet", Context.MODE_PRIVATE); SharedPreferences.Editor personGroupIdSetEditor = personGroupIdSet.edit(); personGroupIdSetEditor.putStringSet("PersonGroupIdSet", newPersonGroupIds); personGroupIdSetEditor.commit(); }
From source file:luceneindexdemo.LuceneIndexDemo.java
public static void searchIndex(String s) throws IOException, ParseException, SQLException, FileNotFoundException, org.json.simple.parser.ParseException { Directory directory = FSDirectory.getDirectory(INDEX_DIRECTORY); IndexReader reader = IndexReader.open(directory); IndexSearcher search = new IndexSearcher(reader); Analyzer analyzer = new StandardAnalyzer(); QueryParser queryparser = new QueryParser(FIELD_CONTENTS, analyzer); Query query = queryparser.parse(s); Hits hits = search.search(query);//from ww w . ja va 2 s. c o m Iterator<Hit> it = hits.iterator(); //System.out.println("hits:"+hits.length()); float f_score; List<String> names = new ArrayList<>(); while (it.hasNext()) { Hit hit = it.next(); f_score = hit.getScore(); //System.out.println(f_score); Document document = hit.getDocument(); Field f = document.getField(FIELD_PATH); //System.out.println(f.readerValue()); //System.out.println(document.getValues(FIELD_PATH)); String path = document.get(FIELD_PATH); System.out.println(document.getValues(path)); Field con = document.getField(FIELD_PATH); //System.out.println("hit:"+path+" "+hit.getId()+" "+con); names.add(new File(path).getName()); } //ProcessBuilder pb=new ProcessBuilder(); FileReader fReader = new FileReader("/home/rishav12/NetBeansProjects/LuceneIndexDemo/inntell.json"); JSONParser jsParser = new JSONParser(); //System.out.println("This is an assumption that you belong to US"); FileReader freReader = new FileReader("/home/rishav12/NetBeansProjects/LuceneIndexDemo/location.json"); Connection con = DriverManager.getConnection("jdbc:neo4j://localhost:7474/"); System.out.println(names); if (names.get(0).equals("miss")) { System.out.println(s); StringTokenizer stringTokenizer = new StringTokenizer(s); Connection con1 = DriverManager.getConnection("jdbc:neo4j://localhost:7474/"); String querySearch = "match ()-[r:KNOWS]-() where has(r.relType) return distinct r.relType"; ResultSet rSet = con.createStatement().executeQuery(querySearch); List<String> allRels = new ArrayList<>(); while (rSet.next()) { System.out.println(); allRels.add(rSet.getString("r.relType")); } //System.out.println(rSet); while (stringTokenizer.hasMoreTokens()) { String next = stringTokenizer.nextToken(); if (allRels.contains(next)) { missOperation(next); } //System.out.println(resSet.getString("r.relType")); } System.out.println(names.get(1)); //missOperation(names.get(1)); } else { try { JSONObject jsonObj = (JSONObject) jsParser.parse(fReader); System.out.println(names.get(0)); JSONObject jsObj = (JSONObject) jsonObj.get(names.get(0)); JSONObject results = new JSONObject(); System.out.println(jsObj.get("explaination")); results.put("explaination", jsObj.get("explaination")); JSONArray reqmts = (JSONArray) jsObj.get("true"); System.out.println("Let me look out for the places that contains "); List<String> lis = new ArrayList<>(); JSONObject locObj = (JSONObject) jsParser.parse(freReader); JSONArray jsArray = (JSONArray) locObj.get("CHENNAI"); Iterator<JSONArray> ite = reqmts.iterator(); int k = 0; String resQuery = "START n=node:restaurant('withinDistance:[" + jsArray.get(0) + "," + jsArray.get(1) + ",7.5]') where"; Iterator<JSONArray> ite1 = reqmts.iterator(); while (ite1.hasNext()) System.out.println(ite1.next()); while (ite.hasNext()) { lis.add("n.type=" + "'" + ite.next() + "'"); if (k == 0) resQuery += " " + lis.get(k); else resQuery += " or " + lis.get(k); //System.out.println(attrib); k++; } resQuery += " return n.name,n.place,n.type"; File writeTo = new File( "/home/rishav12/NetBeansProjects/LuceneIndexDemo/filestoIndex1/" + names.get(0)); FileOutputStream fop = new FileOutputStream(writeTo, true); String writeTOFile = s + "\n"; fop.write(writeTOFile.getBytes()); //System.out.println(resQuery); ResultSet res = con.createStatement().executeQuery(resQuery); JSONArray resSet = new JSONArray(); while (res.next()) { System.out.println(" name:" + res.getString("n.name") + " located:" + res.getString("n.place") + " type:" + res.getString("n.type")); JSONObject jsPart = new JSONObject(); jsPart.put("name", res.getString("n.name")); jsPart.put("located", res.getString("n.place")); jsPart.put("type", res.getString("n.type")); resSet.add(jsPart); } results.put("results", resSet); File resultFile = new File("result.json"); FileOutputStream fop1 = new FileOutputStream(resultFile); System.out.println(results); fop1.write(results.toJSONString().getBytes()); //String resQuery="START n=node:restaurant('withinDistance:[40.7305991, -73.9865812,10.0]') where n.coffee=true return n.name,n.address;"; //System.out.println("Sir these results are for some coffee shops nearby NEW YORK"); //ResultSet res=con.createStatement().executeQuery(resQuery); //while(res.next()) //System.out.println("name: "+res.getString("n.name")+" address: "+res.getString("n.address")); } catch (org.json.simple.parser.ParseException ex) { Logger.getLogger(LuceneIndexDemo.class.getName()).log(Level.SEVERE, null, ex); } } }
From source file:com.denimgroup.threadfix.importer.cli.CommandLineMigration.java
private static void convert(String inputScript, String outputScript) { File file = new File(inputScript); LOGGER.info("Converting threadfix script to mySql script " + outputScript + " ..."); File outputFile = new File(outputScript); FileOutputStream fos = null;//from w w w.j av a 2 s.c o m try { fos = new FileOutputStream(outputFile); OutputStreamWriter osw = new OutputStreamWriter(fos); List<String> lines = FileUtils.readLines(file); osw.write("SET FOREIGN_KEY_CHECKS=0;\n"); String table; for (String line : lines) { if (line != null && line.toUpperCase().startsWith("CREATE MEMORY TABLE ")) { table = RegexUtils.getRegexResult(line, TABLE_PATTERN); System.out.println("Create new table:" + table); String[] tableName = table.split("\\(", 2); if (tableName.length == 2) { List<String> fieldList = list(); String[] fields = tableName[1].trim().replace("(", "").replace(")", "").split(","); for (int i = 0; i < fields.length; i++) { if (!"CONSTRAINT".equalsIgnoreCase(fields[i].trim().split(" ")[0])) { String field = fields[i].trim().split(" ")[0].replace("\"", ""); if (!fieldList.contains(field)) fieldList.add(field); } } String fieldsStr = org.apache.commons.lang3.StringUtils.join(fieldList, ","); tableMap.put(tableName[0].toUpperCase(), "(" + fieldsStr + ")"); } } else if (line != null && line.toUpperCase().startsWith("INSERT INTO ")) { table = RegexUtils.getRegexResult(line, INSERT_PATTERN).toUpperCase(); if (tableMap.get(table) != null) { line = line.replaceFirst(" " + table + " ", " " + table + tableMap.get(table) + " "); if (line.contains(ACUNETIX_ESCAPE)) { line = line.replace(ACUNETIX_ESCAPE, ACUNETIX_ESCAPE_REPLACE); } line = escapeString(line) + ";\n"; osw.write(line); } } } osw.write("SET FOREIGN_KEY_CHECKS=1;\n"); osw.close(); } catch (Exception e) { e.printStackTrace(); } }
From source file:fr.xebia.management.statistics.ServiceStatistics.java
/** * Returns <code>true</code> if the given <code>throwable</code> or one of * its cause is an instance of one of the given <code>throwableTypes</code>. *///w ww .j a va 2 s . co m public static boolean containsThrowableOfType(Throwable throwable, Class<?>... throwableTypes) { List<Throwable> alreadyProcessedThrowables = new ArrayList<Throwable>(); while (true) { if (throwable == null) { // end of the list of causes return false; } else if (alreadyProcessedThrowables.contains(throwable)) { // infinite loop in causes return false; } else { for (Class<?> throwableType : throwableTypes) { if (throwableType.isAssignableFrom(throwable.getClass())) { return true; } } alreadyProcessedThrowables.add(throwable); throwable = throwable.getCause(); } } }