List of usage examples for java.util List iterator
Iterator<E> iterator();
From source file:Main.java
static String getKSessionName(List<String> kSessions) { if (kSessions == null || kSessions.isEmpty()) { return null; } else {//from w ww .j av a 2 s . c om return kSessions.iterator().next(); } }
From source file:Main.java
public static void removeListPrefItems(ListPreference listPref, String[] labels, String[] values, List<String> items) { List<String> labelsList = new ArrayList<String>(Arrays.asList(labels)); List<String> valuesList = new ArrayList<String>(Arrays.asList(values)); Iterator<String> it = valuesList.iterator(); while (it.hasNext()) { String value = it.next(); if (items.contains(value)) { labelsList.remove(valuesList.indexOf(value)); it.remove();/*from www .j av a2 s . co m*/ } } listPref.setEntries(labelsList.toArray(new String[1])); listPref.setEntryValues(valuesList.toArray(new String[1])); }
From source file:Main.java
public static void markItemsAsPro(ListPreference listPref, String[] labels, String[] values, List<String> proItems, String proWord) { List<String> labelsList = new ArrayList<String>(Arrays.asList(labels)); List<String> valuesList = new ArrayList<String>(Arrays.asList(values)); Iterator<String> it = valuesList.iterator(); for (int i = 0; i < valuesList.size(); i++) { String value = valuesList.get(i); String label = labelsList.get(i); if (proItems.contains(value)) { labelsList.set(i, label + " " + proWord); }//from www . j av a2s . c o m } listPref.setEntries(labelsList.toArray(new String[1])); listPref.setEntryValues(valuesList.toArray(new String[1])); }
From source file:Main.java
/** * @return//from w w w.j a v a 2 s .com */ public static XPath getHtmlXPath() { XPathFactory factory = XPathFactory.newInstance(); XPath htmlPath = factory.newXPath(); htmlPath.setNamespaceContext(new NamespaceContext() { public String getNamespaceURI(String prefix) { return "http://www.w3.org/1999/xhtml"; } public String getPrefix(String namespaceURI) { return "h"; } public Iterator<?> getPrefixes(String namespaceURI) { List<String> prefixes = new ArrayList<String>(); prefixes.add("h"); return prefixes.iterator(); } }); return htmlPath; }
From source file:JDOMDemo.java
public static void demo(Document doc) { List children = doc.getContent(); Iterator iterator = children.iterator(); while (iterator.hasNext()) { Object o = iterator.next(); if (o instanceof Element) { demo((Element) o);//from w w w.j ava 2 s. c o m } else if (o instanceof Comment) doComment((Comment) o); else if (o instanceof ProcessingInstruction) doPI((ProcessingInstruction) o); } }
From source file:Main.java
private static boolean sparselyEqualLists(List expected, List actual) { if (expected.size() != actual.size()) { return false; }/*from w ww . j a v a 2s . c o m*/ Iterator actualIterator = actual.iterator(); for (Iterator expectedIterator = expected.iterator(); expectedIterator.hasNext();) { Object expectedItem = expectedIterator.next(); Object actualItem = actualIterator.next(); if (expectedItem != null && !expectedItem.equals(actualItem)) { return false; } } return true; }
From source file:com.qualogy.qafe.core.placeholder.PlaceHolderResolver.java
private static String implementPlaceholders(ApplicationContext context, ApplicationStoreIdentifier storeId, DataIdentifier dataId, String value, List placeHolders, String localStoreId) { for (Iterator iter = placeHolders.iterator(); iter.hasNext();) { PlaceHolder placeHolder = (PlaceHolder) iter.next(); if (placeHolder != null) { Object placeHolderValue = ParameterValueHandler.get(context, storeId, dataId, placeHolder, localStoreId);/* ww w .j av a2 s . c o m*/ if (placeHolderValue == null) placeHolderValue = ""; value = StringUtils.replace(value, placeHolder.getPlaceHolderKey(), placeHolderValue.toString()); } } return value; }
From source file:Main.java
/** * Convert list of properties to a string representation, based on the specified delimiter. * * @param toJoin object to serialize as a string * @param delimiter how to separate entries from each other * @return the properties as a string, delimited by the above *//*w w w.j a va2 s. c om*/ public static String joinOnDelimiter(List<String> toJoin, char delimiter) { StringBuilder buf = new StringBuilder(); for (Iterator<String> it = toJoin.iterator(); it.hasNext();) { String value = it.next(); buf.append(value); if (it.hasNext()) { buf.append(delimiter); } } return buf.toString(); }
From source file:Main.java
public static boolean isServiceRunning(Context ctx, String className) { boolean isRunning = false; ActivityManager activityManager = (ActivityManager) ctx.getSystemService(Context.ACTIVITY_SERVICE); List<RunningServiceInfo> servicesList = activityManager.getRunningServices(Integer.MAX_VALUE); Iterator<RunningServiceInfo> l = servicesList.iterator(); while (l.hasNext()) { RunningServiceInfo si = l.next(); if (className.equals(si.service.getClassName())) { isRunning = true;//from w w w . ja v a 2s .c o m } } return isRunning; }
From source file:Main.java
public static boolean isServiceRunning(Context context, String className) { boolean isRunning = false; ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); List<RunningServiceInfo> servicesList = activityManager.getRunningServices(Integer.MAX_VALUE); Iterator<RunningServiceInfo> l = servicesList.iterator(); while (l.hasNext()) { RunningServiceInfo si = (RunningServiceInfo) l.next(); if (className.equals(si.service.getClassName())) { isRunning = true;/* w w w .ja v a 2 s. c om*/ } } return isRunning; }