List of usage examples for java.util Set iterator
Iterator<E> iterator();
From source file:com.elsevier.xml.XPathProcessor.java
/** * Set the namespaces in the XPathCompiler. * /*from w ww .j a v a2s. co m*/ * @param xpathCompiler */ private static void setPrefixNamespaceMappings(XPathCompiler xpathCompiler) { // Get the mappings Set<Entry<String, String>> mappings = NamespaceContextMappings.getMappings(); // If mappings exist, set the namespaces if (mappings != null) { Iterator<Entry<String, String>> it = mappings.iterator(); while (it.hasNext()) { Entry<String, String> entry = it.next(); xpathCompiler.declareNamespace(entry.getKey(), entry.getValue()); } } }
From source file:gov.wa.wsdot.android.wsdot.service.MountainPassesSyncService.java
private static Integer getWeatherImage(HashMap<Integer, String[]> weatherPhrases, String weather) { Integer image = R.drawable.weather_na; Set<Entry<Integer, String[]>> set = weatherPhrases.entrySet(); Iterator<Entry<Integer, String[]>> i = set.iterator(); if (weather.equals("")) return image; String s0 = weather.split("\\.")[0]; // Pattern match on first sentence only. while (i.hasNext()) { Entry<Integer, String[]> me = i.next(); for (String phrase : (String[]) me.getValue()) { if (s0.toLowerCase().startsWith(phrase)) { image = (Integer) me.getKey(); return image; }/*from w w w . j av a 2 s .c o m*/ } } return image; }
From source file:Main.java
public static Integer firstUnique(Collection<Integer> collection) { Map<Integer, Integer> linkedHashMap = new LinkedHashMap<Integer, Integer>(); java.util.Iterator<Integer> it = collection.iterator(); Integer currentInt;/*from ww w.ja va2 s. c o m*/ java.util.Iterator it1; Set entrySet; Map.Entry<Integer, Integer> me; while (it.hasNext()) { currentInt = it.next(); if (!linkedHashMap.containsKey(currentInt)) { linkedHashMap.put(currentInt, 1); } else { linkedHashMap.put(currentInt, linkedHashMap.get(currentInt) + 1); } } entrySet = linkedHashMap.entrySet(); it1 = entrySet.iterator(); while (it1.hasNext()) { me = (Entry) it1.next(); if (me.getValue().equals(1)) { return (Integer) me.getKey(); } } return null; }
From source file:hudson.plugins.trackplus.Updater.java
/** * @param pattern pattern to use to match issue ids *///from w w w. j a v a2 s. c om static void findIssues(AbstractBuild<?, ?> build, Set<Integer> ids, String issuePrefix, BuildListener listener) { for (Entry change : build.getChangeSet()) { LOGGER.fine("Looking for Track+ ID in " + change.getMsg()); Set<Integer> tmpIds = TrackplusSite.getWorkItemIDs(change.getMsg(), issuePrefix); if (tmpIds != null && tmpIds.size() > 0) { for (Iterator iterator = tmpIds.iterator(); iterator.hasNext();) { Integer id = (Integer) iterator.next(); ids.add(id); } } else { listener.getLogger().println("No issues found!"); } } }
From source file:org.fusesource.meshkeeper.util.internal.IntrospectionSupport.java
public static String toString(Object target, Class<?> stopClass, Map<String, Object> overrideFields) { LinkedHashMap<String, Object> map = new LinkedHashMap<String, Object>(); addFields(target, target.getClass(), stopClass, map); if (overrideFields != null) { for (String key : overrideFields.keySet()) { Object value = overrideFields.get(key); map.put(key, value);// w w w .j a v a 2 s .com } } StringBuffer buffer = new StringBuffer(simpleName(target.getClass())); buffer.append(" {"); Set<Entry<String, Object>> entrySet = map.entrySet(); boolean first = true; for (Iterator<Entry<String, Object>> iter = entrySet.iterator(); iter.hasNext();) { Entry<String, Object> entry = iter.next(); if (first) { first = false; } else { buffer.append(", "); } buffer.append(entry.getKey()); buffer.append(" = "); appendToString(buffer, entry.getValue()); } buffer.append("}"); return buffer.toString(); }
From source file:com.glaf.core.util.CalendarUtils.java
public static boolean saveCalendarProperties(Properties props) { try {//from w w w . ja v a 2 s. c om List<SystemParam> rows = new java.util.concurrent.CopyOnWriteArrayList<SystemParam>(); java.util.Set<Object> set = props.keySet(); java.util.Iterator<Object> iter = set.iterator(); while (iter.hasNext()) { String key = (String) iter.next(); String value = props.getProperty(key); SystemParam p = new SystemParam(); p.setBusinessKey("calendar"); p.setServiceKey("calendar"); p.setTypeCd("calendar"); p.setJavaType("String"); p.setKeyName(key); p.setStringVal(value); rows.add(p); } getSystemParamService().saveAll("calendar", "calendar", rows); return true; } catch (Exception e) { e.printStackTrace(); } return false; }
From source file:com.android.launcher4.InstallShortcutReceiver.java
public static void removeFromInstallQueue(SharedPreferences sharedPrefs, ArrayList<String> packageNames) { if (packageNames.isEmpty()) { return;//from w w w .java 2s.co m } synchronized (sLock) { Set<String> strings = sharedPrefs.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 json = newStringsIter.next(); try { JSONObject object = (JSONObject) new JSONTokener(json).nextValue(); Intent launchIntent = Intent.parseUri(object.getString(LAUNCH_INTENT_KEY), 0); String pn = launchIntent.getPackage(); if (pn == null) { pn = launchIntent.getComponent().getPackageName(); } if (packageNames.contains(pn)) { newStringsIter.remove(); } } catch (org.json.JSONException e) { Log.d(TAG, "Exception reading shortcut to remove: " + e); } catch (java.net.URISyntaxException e) { Log.d(TAG, "Exception reading shortcut to remove: " + e); } } sharedPrefs.edit().putStringSet(APPS_PENDING_INSTALL, new HashSet<String>(newStrings)).commit(); } } }
From source file:com.iisigroup.cap.mvc.i18n.MessageBundleScriptCreator.java
/** * filter ??/* www . ja v a 2 s. co m*/ * * @param filterList * filter list * @return String */ private static String generateFilterReg(Set<String> filterList) { if (filterList == null) { filterList = defaultFilter; } if (!filterList.isEmpty()) { StringBuffer regSb = new StringBuffer("^("); for (Iterator<String> it = filterList.iterator(); it.hasNext();) { regSb.append(it.next()).append(Constants.VALUES_SEPARATOR); } regSb.deleteCharAt(regSb.length() - 1).append(")"); return regSb.toString(); } else { return null; } }
From source file:ext.tmt.utils.LWCUtil.java
/** * // w ww. ja v a2s .c om * @param p * @return */ public static Map<String, Object> getAllAttribute(Persistable p, Locale loc) { log.info("$$$$$$$$ getAllAttribute Begin......."); TypeInstance typeInstance; Map<String, Object> dataMap = new HashMap<String, Object>(); try { LWCNormalizedObject lwcObject = new LWCNormalizedObject(p, null, loc, null); TypeInstanceIdentifier typeinstanceidentifier = ClientTypedUtility.getTypeInstanceIdentifier(p); typeInstance = TypeInstanceFactory.newTypeInstance(typeinstanceidentifier); TypeIdentifier typeidentifier = (TypeIdentifier) typeInstance.getIdentifier().getDefinitionIdentifier(); Set attrs = TypeHelper.getSoftAttributes(typeidentifier); Iterator attIt = attrs.iterator(); String attrFullName = ""; String attrName = ""; int idx = 0; while (attIt.hasNext()) { attrFullName = attIt.next().toString(); idx = attrFullName.lastIndexOf("|"); attrName = attrFullName.substring(idx + 1); lwcObject.load(attrName); dataMap.put(attrName, lwcObject.get(attrName)); } } catch (IllegalFormatException e) { e.printStackTrace(); } catch (WTException e) { e.printStackTrace(); } log.info("$$$$$$$$ getAllAttribute End.......>"); return dataMap; }
From source file:com.hubrick.vertx.rest.converter.JacksonJsonHttpMessageConverter.java
private static Method getMethodIfAvailable(Class<?> clazz, String methodName, Class<?>... paramTypes) { checkNotNull(clazz, "Class must not be null"); checkNotNull(methodName, "Method name must not be null"); if (paramTypes != null) { try {/*from w w w. j a va 2 s . c o m*/ return clazz.getMethod(methodName, paramTypes); } catch (NoSuchMethodException ex) { return null; } } else { Set<Method> candidates = new HashSet<>(1); Method[] methods = clazz.getMethods(); for (Method method : methods) { if (methodName.equals(method.getName())) { candidates.add(method); } } if (candidates.size() == 1) { return candidates.iterator().next(); } return null; } }