List of usage examples for java.util List contains
boolean contains(Object o);
From source file:com.amazonaws.mobileconnectors.s3.transferutility.TransferStatusUpdater.java
/** * Registers a {@link TransferListener} to a transfer. * * @param id id of the transfer//from ww w . j a va 2 s. c om * @param listener a listener object */ static void registerListener(int id, TransferListener listener) { if (listener == null) { throw new IllegalArgumentException("Listener can't be null"); } synchronized (LISTENERS) { List<TransferListener> list = LISTENERS.get(id); if (list == null) { list = new CopyOnWriteArrayList<TransferListener>(); list.add(listener); LISTENERS.put(id, list); } else { // don't add the same listener more than once if (!list.contains(listener)) { list.add(listener); } } } }
From source file:de.thingweb.typesystem.jsonschema.JsonSchemaType.java
private static boolean isOfType(String type, List<String> types) { boolean isOfType = false; try {/*from ww w . j ava2s . c o m*/ // TODO use JSON schema parser if (type != null) { ObjectMapper mapper = new ObjectMapper(); JsonNode valueType = mapper.readValue(new StringReader(type), JsonNode.class); if (valueType != null) { JsonNode value = valueType.findValue("type"); if (value != null) { isOfType = types.contains(value.asText()); } } } } catch (Exception e) { // failure --> no JSON schema } return isOfType; }
From source file:Main.java
public static void deletePersons(List<String> personIdsToDelete, String personGroupId, Context context) { SharedPreferences personIdNameMap = context.getSharedPreferences(personGroupId + "PersonIdNameMap", Context.MODE_PRIVATE); SharedPreferences.Editor personIdNameMapEditor = personIdNameMap.edit(); for (String personId : personIdsToDelete) { personIdNameMapEditor.remove(personId); }//from w w w . ja v a 2 s . c o m personIdNameMapEditor.commit(); Set<String> personIds = getAllPersonIds(personGroupId, context); Set<String> newPersonIds = new HashSet<>(); for (String personId : personIds) { if (!personIdsToDelete.contains(personId)) { newPersonIds.add(personId); } } SharedPreferences personIdSet = context.getSharedPreferences(personGroupId + "PersonIdSet", Context.MODE_PRIVATE); SharedPreferences.Editor personIdSetEditor = personIdSet.edit(); personIdSetEditor.putStringSet("PersonIdSet", newPersonIds); personIdSetEditor.commit(); }
From source file:fr.paris.lutece.plugins.mylutece.modules.wssodatabase.authentication.business.WssoUserHome.java
/** * Returns a collection of roles by profils for user * @param nWssoUserId the user id//w ww . j a v a2 s . co m * @param plugin The current plugin using this method * @return the list of roles for a user */ public static List<String> findRolesByProfilsForUser(int nWssoUserId, Plugin plugin) { List<String> listProfils = WssoProfilHome.findWssoProfilsForUser(nWssoUserId, plugin); List<String> listRoles = new ArrayList<String>(); if (CollectionUtils.isNotEmpty(listProfils)) { for (String codeProfil : listProfils) { List<String> profilRoleKeyList = IdxWSSODatabaseHome.findRolesFromProfil(codeProfil, plugin); if (CollectionUtils.isNotEmpty(profilRoleKeyList)) { for (String role : profilRoleKeyList) { if (StringUtils.isNotBlank(role) && !listRoles.contains(role)) { listRoles.add(role); } } } } } return listRoles; }
From source file:com.comcast.cqs.io.CQSMessagePopulator.java
private static StringBuffer fillAttributesInReturn(CQSMessage message, List<String> filterAttributes) { StringBuffer attributesXmlFragment = new StringBuffer(""); if (message.getAttributes() != null) { for (Map.Entry<String, String> entry : message.getAttributes().entrySet()) { if (entry.getKey() != null && entry.getKey().length() > 0 && !entry.getKey().equals(CQSConstants.DELAY_SECONDS) && (filterAttributes.isEmpty() || filterAttributes.contains("All") || filterAttributes.contains(entry.getKey()))) { attributesXmlFragment.append("\t\t\t<Attribute>").append("<Name>").append(entry.getKey()) .append("</Name>").append("<Value>").append(entry.getValue()).append("</Value>") .append("</Attribute>\n"); }/*from w w w.j av a 2 s.c om*/ } } return attributesXmlFragment; }
From source file:at.bestsolution.persistence.java.Util.java
public static <O> void syncLists(List<O> targetList, List<O> newList) { Iterator<O> it = targetList.iterator(); List<O> removeItems = new ArrayList<O>(); // remove items not found in new list // do not remove immediately because because then to many notifications // are regenerated while (it.hasNext()) { O next = it.next();// ww w . java 2s . co m if (!newList.contains(next)) { removeItems.add(next); } } targetList.removeAll(removeItems); // remove all items from the new list already contained it = newList.iterator(); while (it.hasNext()) { if (targetList.contains(it.next())) { it.remove(); } } targetList.addAll(newList); }
From source file:eu.europa.esig.dss.DSSASN1Utils.java
/** * Indicates that a X509Certificates corresponding private key is used by an authority to sign OCSP-Responses.<br> * http://www.ietf.org/rfc/rfc3280.txt <br> * http://tools.ietf.org/pdf/rfc6960.pdf 4.2.2.2<br> * {iso(1) identified-organization(3) dod(6) internet(1) security(5) mechanisms(5) pkix(7) keyPurpose(3) * ocspSigning(9)}<br>/* w w w .j av a2 s . c om*/ * OID: 1.3.6.1.5.5.7.3.9 * * @return */ public static boolean isOCSPSigning(CertificateToken certToken) { try { List<String> keyPurposes = certToken.getCertificate().getExtendedKeyUsage(); if ((keyPurposes != null) && keyPurposes.contains(OID.id_kp_OCSPSigning.getId())) { return true; } } catch (CertificateParsingException e) { LOG.warn(e.getMessage()); } // Responder's certificate not valid for signing OCSP responses. return false; }
From source file:edu.caltech.ipac.firefly.server.util.ipactable.DataGroupReader.java
public static DataGroup getEnumValues(File inf, int cutoffPoint) throws IOException { TableDef tableMeta = IpacTableUtil.getMetaInfo(inf); List<DataType> cols = tableMeta.getCols(); HashMap<DataType, List<String>> enums = new HashMap<DataType, List<String>>(); ArrayList<DataType> workList = new ArrayList<DataType>(); for (DataType dt : cols) { if (dt.getDataType().isAssignableFrom(Float.class) || dt.getDataType().isAssignableFrom(Double.class)) { continue; }//from w w w. j av a 2s . c o m enums.put(dt, new ArrayList<String>()); workList.add(dt); } DataGroup dg = new DataGroup(null, cols); BufferedReader reader = new BufferedReader(new FileReader(inf), IpacTableUtil.FILE_IO_BUFFER_SIZE); String line = null; int lineNum = 0; try { line = reader.readLine(); lineNum++; while (line != null) { DataObject row = IpacTableUtil.parseRow(dg, line, false); if (row != null) { List<DataType> ccols = new ArrayList<DataType>(workList); for (DataType dt : ccols) { String v = String.valueOf(row.getDataElement(dt)); List<String> l = enums.get(dt); if (l == null || l.size() >= cutoffPoint || (dt.getDataType().isAssignableFrom(String.class) && v.length() > 20)) { workList.remove(dt); enums.remove(dt); } else if (!l.contains(v)) { l.add(v); } } } line = reader.readLine(); lineNum++; if (enums.size() == 0) { break; } } } catch (Exception e) { String msg = e.getMessage() + "<br>on line " + lineNum + ": " + line; if (msg.length() > 128) msg = msg.substring(0, 128) + "..."; logger.error(e, "on line " + lineNum + ": " + line); throw new IOException(msg); } finally { reader.close(); } if (enums.size() > 0) { for (DataType dt : enums.keySet()) { List<String> values = enums.get(dt); Collections.sort(values, DataGroupUtil.getComparator(dt)); dg.addAttribute( TemplateGenerator.createAttributeKey(TemplateGenerator.Tag.ITEMS_TAG, dt.getKeyName()), StringUtils.toString(values, ",")); } } return dg; }
From source file:com.streak.logging.analysis.AnalysisUtility.java
public static void populateSchema(BigqueryFieldExporterSet exporterSet, List<String> fieldNames, List<String> fieldTypes, List<BigqueryFieldExporter> fieldExporters) { List<BigqueryFieldExporter> exporters = exporterSet.getExporters(); for (BigqueryFieldExporter exporter : exporters) { for (int i = 0; i < exporter.getFieldCount(); i++) { if (fieldNames.contains(exporter.getFieldName(i))) { throw new InvalidFieldException( "BigqueryFieldExporterSet " + exporterSet.getClass().getCanonicalName() + " defines multiple fields with name " + exporter.getFieldName(i)); }/*from ww w . j a v a2 s . c om*/ fieldNames.add(exporter.getFieldName(i)); fieldTypes.add(exporter.getFieldType(i).toLowerCase().intern()); fieldExporters.add(exporter); } } }
From source file:com.ikon.omr.OMRHelper.java
/** * storeMetadata/*from w ww . ja v a2 s. com*/ */ public static void storeMetadata(Map<String, String> results, String docPath) throws IOException, ParseException, PathNotFoundException, RepositoryException, DatabaseException, NoSuchGroupException, LockException, AccessDeniedException, ExtensionException, AutomationException, NoSuchPropertyException, OMRException { List<String> groups = new ArrayList<String>(); for (String key : results.keySet()) { if (key.contains(":")) { String grpName = key.substring(0, key.indexOf(".")); // convert to okg (group name always start with okg ) grpName = grpName.replace("okp", "okg"); if (!groups.contains(grpName)) { groups.add(grpName); } } } // Add missing groups for (PropertyGroup registeredGroup : OKMPropertyGroup.getInstance().getGroups(null, docPath)) { if (groups.contains(registeredGroup.getName())) { groups.remove(registeredGroup.getName()); } } // Add properties for (String grpName : groups) { OKMPropertyGroup.getInstance().addGroup(null, docPath, grpName); // convert okg to okp ( property format ) String propertyBeginning = grpName.replace("okg", "okp"); Map<String, String> properties = new HashMap<String, String>(); for (String key : results.keySet()) { if (key.startsWith(propertyBeginning)) { String value = results.get(key); // Evaluate select multiple otherside throw exception if (value.contains(" ")) { for (FormElement formElement : OKMPropertyGroup.getInstance().getPropertyGroupForm(null, grpName)) { if (formElement.getName().equals(key) && formElement instanceof Select) { if (!((Select) formElement).getType().equals(Select.TYPE_MULTIPLE)) { throw new OMRException( "Found multiple value in a non multiple select. White space indicates multiple value"); } else { // Change " " to ";" the way to pass // multiple values into setPropertiesSimple value = value.replaceAll(" ", ";"); } } } } properties.put(key, value); } } OKMPropertyGroup.getInstance().setPropertiesSimple(null, docPath, grpName, properties); } }