List of usage examples for java.util List iterator
Iterator<E> iterator();
From source file:Main.java
public static String[] getPerformInfo(String procName) { String[] result = new String[] { "", "", "" }; String tempString = ""; List<String[]> PMUList = Collections.synchronizedList(new ArrayList<String[]>()); int INDEX_FIRST = -1; int INDEX_CPU = INDEX_FIRST + 3; int INDEX_VSS = INDEX_FIRST + 6; int INDEX_RSS = INDEX_FIRST + 7; int INDEX_NAME = INDEX_FIRST + 10; synchronized (PMUList) { for (Iterator<String[]> iterator = PMUList.iterator(); iterator.hasNext();) { String[] item = (String[]) iterator.next(); tempString = item[INDEX_NAME]; if (tempString != null && tempString.equals(procName)) { // result = "CPU:" + item[INDEX_CPU] // + " Mem:" + item[INDEX_RSS]; result[0] = item[INDEX_RSS]; result[1] = item[INDEX_VSS]; result[2] = item[INDEX_CPU]; break; }/*from w w w . j av a 2s .c o m*/ } } return result; }
From source file:cec.easyshop.cockpits.cmscockpit.sitewizard.CMSSiteUtils.java
public static void createHomepage(final String uid, final String label, final CatalogVersionModel catVersion, final ContentCatalogModel contentCatalog, final CMSSiteModel cmsSiteModel, final List<PageTemplateModel> clonedTemplates) { final PageTemplateModel firstTemplate = clonedTemplates.iterator().next(); final ModelService modelService = UISessionUtils.getCurrentSession().getModelService(); final ContentPageModel contentPage = modelService.create(CONTENT_PAGE); contentPage.setUid(uid);/* ww w.j a va 2 s . c om*/ contentPage.setName(uid); contentPage.setLabel(label); contentPage.setHomepage(true); contentPage.setCatalogVersion(catVersion); contentPage.setMasterTemplate(firstTemplate); contentPage.setDefaultPage(Boolean.TRUE); cmsSiteModel.setStartingPage(contentPage); adjustHomePageTemplate(contentPage, clonedTemplates); modelService.save(contentPage); }
From source file:cn.fql.utility.CollectionUtility.java
/** * Sort collection with order, each group is a arraylist * * @param source source list/*from w ww .java2 s . c o m*/ * @param key specified key which is used to be compared * @return <code>MapListAdapter</code> */ public static ListOrderedMap sortCollectionWithOrder(List source, Object key) { ListOrderedMap lstOrderedMap = new ListOrderedMap(); for (Iterator it = source.iterator(); it.hasNext();) { Map rowMap = (Map) it.next(); Object keyValue = rowMap.get(key); List groupList = (List) lstOrderedMap.get(keyValue); if (groupList == null) { groupList = new ArrayList(); lstOrderedMap.put(keyValue, groupList); } groupList.add(rowMap); } return lstOrderedMap; }
From source file:com.projity.pm.graphic.spreadsheet.common.transfer.NodeListTransferable.java
public static String nodeListToString(List nodeList, SpreadSheet spreadsheet, List fields) { StringBuffer sb = new StringBuffer(); for (Iterator i = nodeList.iterator(); i.hasNext();) { nodeToString((Node) i.next(), sb, spreadsheet, fields); }// w w w. ja va2 s .com return sb.toString(); }
From source file:com.pureinfo.srm.RequestUtils.java
public static PureProperties parse(HttpServletRequest _request) throws PureException { logger.debug("enti"); PureProperties props = new PureProperties(); Enumeration names = _request.getParameterNames(); logger.debug("enti11111111111#" + names.hasMoreElements()); while (names.hasMoreElements()) { String sName = (String) names.nextElement(); String[] values = _request.getParameterValues(sName); if (values.length == 1) { props.setProperty(sName, values[0]); } else {/*from ww w. j a v a 2 s. c o m*/ props.setProperty(sName, values); } } String sContentType = _request.getContentType(); if (sContentType != null && sContentType.startsWith("multipart/form-data")) { logger.debug("enti111"); DiskFileUpload upload = new DiskFileUpload(); List items; try { items = upload.parseRequest(_request); } catch (FileUploadException ex) { throw new PureException(PureException.UNKNOWN, "upload error", ex); } logger.debug("enti111111111111" + items.size()); for (Iterator iter = items.iterator(); iter.hasNext();) { FileItem item = (FileItem) iter.next(); if (item.getName() == null) { props.setProperty(item.getFieldName(), item.getString()); } else { props.setProperty(item.getFieldName(), item); } logger.debug("name:" + item.getFieldName() + "-value:" + props.getProperty(item.getFieldName())); } } return props; }
From source file:dk.moerks.ratebeermobile.io.NetBroker.java
private static void signin(Context context, DefaultHttpClient httpclient) throws NetworkException, LoginException { HttpPost httppost = new HttpPost("http://www.ratebeer.com/signin/"); Log.d(LOGTAG, "Before Try"); try {/*from ww w . j a v a 2 s . co m*/ SharedPreferences settings = context.getSharedPreferences(Settings.PREFERENCETAG, 0); String username = settings.getString("rb_username", ""); String password = settings.getString("rb_password", ""); if (username != null && password != null && username.length() > 0 && password.length() > 0) { Log.d(LOGTAG, "Building Login Request"); // Add your data List<NameValuePair> parameters = new ArrayList<NameValuePair>(); parameters.add(new BasicNameValuePair("SaveInfo", "on")); parameters.add(new BasicNameValuePair("username", username)); parameters.add(new BasicNameValuePair("pwd", password)); httppost.setEntity(new UrlEncodedFormEntity(parameters)); //Check to see if we are already logged in List<Cookie> beforeCookies = httpclient.getCookieStore().getCookies(); for (Iterator<Cookie> iterator = beforeCookies.iterator(); iterator.hasNext();) { Cookie cookie = iterator.next(); if (cookie.getName().equalsIgnoreCase("SessionCode")) { return; } } Log.d(LOGTAG, "Executing Login Request"); // Execute HTTP Post Request HttpResponse result = httpclient.execute(httppost); int statusCode = result.getStatusLine().getStatusCode(); Log.d(LOGTAG, "Validating we got the right status from server: " + statusCode); if (statusCode == 200) { List<Cookie> cookies = httpclient.getCookieStore().getCookies(); Log.d(LOGTAG, "Start Validating Cookies. List length: " + cookies.size()); for (Iterator<Cookie> iterator = cookies.iterator(); iterator.hasNext();) { Cookie cookie = iterator.next(); Log.d(LOGTAG, "Matching Cookie: " + cookie.getName()); if (cookie.getName().equalsIgnoreCase("SessionCode")) { result.getEntity().consumeContent(); return; } } throw new LoginException(LOGTAG, "Login to ratebeer.com failed. Check your credentials"); } else { throw new LoginException(LOGTAG, "Login to ratebeer.com failed. Check your credentials"); } } else { throw new LoginException(LOGTAG, "Login to ratebeer.com failed. Check your credentials"); } } catch (ClientProtocolException e) { } catch (IOException e) { throw new NetworkException(context, LOGTAG, "Network Error - Do you have a network connection?", e); } }
From source file:com.aurel.track.persist.TGeneralSettingsPeer.java
/** * Converts a list of TGeneralSettings torque objects to a list of TGeneralSettingsBean objects * @param torqueList/*from w ww. ja v a2 s . co m*/ * @return */ private static List convertTorqueListToBeanList(List torqueList) { List beanList = new ArrayList(); TGeneralSettings generalSettings; if (torqueList != null) { Iterator itrTorqueList = torqueList.iterator(); while (itrTorqueList.hasNext()) { generalSettings = (TGeneralSettings) itrTorqueList.next(); beanList.add(generalSettings.getBean()); } } return beanList; }
From source file:com.ctrip.infosec.rule.resource.DataProxyTest.java
private static Map parseProfileResult(Map result) { if (result != null) { if (result.get("tagName") != null) { return parseResult(result); } else if (result.get("tagNames") != null) { Object tagValues = result.get("tagNames"); List oldResults = Utils.JSON.parseObject(Utils.JSON.toJSONString(tagValues), List.class); Map newResults = new HashMap(); Iterator iterator = oldResults.iterator(); while (iterator.hasNext()) { Map oneResult = (Map) iterator.next(); newResults.putAll(parseResult(oneResult)); }/*w ww. j a v a 2 s . co m*/ return newResults; } else { return result; } } return null; }
From source file:ca.sfu.federation.utils.IContextUtils.java
/** * Get the list of independant elements. * @return List of elements // w w w .j av a2 s . c o m */ public static List<INamed> getIndependantElements(List<INamed> Elements) { ArrayList<INamed> independant = new ArrayList<INamed>(); // get list of elements Iterator<INamed> e = Elements.iterator(); while (e.hasNext()) { INamed named = e.next(); // if the object can have dependancies if (named instanceof IGraphable) { IGraphable graphobject = (IGraphable) named; LinkedHashMap dep = (LinkedHashMap) graphobject.getDependancies(); // if the elements has no dependancies, then it is an independant elements if (dep.size() == 0) { independant.add(named); } } } // return results return independant; }
From source file:Main.java
public static void filterIterables() { List<String> literals = Arrays.asList("1", "2", "3"); Iterable<String> filtered = Iterables.filter(literals, new Predicate<String>() { @Override/*w w w. j av a 2 s. c o m*/ public boolean apply(String input) { return input.equals("1"); } }); System.out.println(Iterables.toString(filtered)); Iterator<String> filtered2 = Iterators.filter(literals.iterator(), new Predicate<String>() { @Override public boolean apply(String input) { return input.equals("1"); } }); System.out.println(Iterators.toString(filtered2)); }