List of usage examples for java.util List iterator
Iterator<E> iterator();
From source file:edu.harvard.mcz.imagecapture.data.AllowedVersionLifeCycle.java
/** * Check to see if the allowed versions in the database include the version * of the current ImageCaptureApp. // ww w . ja v a 2 s .c o m * * @return true if an AllowedVersion.version in the database is found at the * beginning of ImageCaptureApp.APP_VERSION, otherwise false. */ public static boolean isCurrentAllowed() throws HibernateException { boolean result = false; AllowedVersionLifeCycle als = new AllowedVersionLifeCycle(); List<AllowedVersion> allowedVersions = als.findAll(); Iterator<AllowedVersion> i = allowedVersions.iterator(); while (i.hasNext()) { String version = i.next().getVersion(); String currentVersion = ImageCaptureApp.APP_VERSION; if (version != null && currentVersion != null && version.length() <= currentVersion.length() && currentVersion.startsWith(version)) { result = true; } } return result; }
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<ActivityManager.RunningServiceInfo> servicesList = activityManager .getRunningServices(Integer.MAX_VALUE); Iterator<ActivityManager.RunningServiceInfo> l = servicesList.iterator(); while (l.hasNext()) { ActivityManager.RunningServiceInfo si = (ActivityManager.RunningServiceInfo) l.next(); if (className.equals(si.service.getClassName())) { isRunning = true;/*from www . j av a 2 s . co m*/ } } return isRunning; }
From source file:edu.harvard.mcz.imagecapture.data.AllowedVersionLifeCycle.java
/** * Provide a human readable list of the allowed versions listed in the database. * //from w w w. j av a 2 s .c o m * @return string listing allowed versions according to database. */ public static String listAllowedVersions() { StringBuilder allowed = new StringBuilder(); AllowedVersionLifeCycle als = new AllowedVersionLifeCycle(); try { List<AllowedVersion> allowedVersions = als.findAll(); Iterator<AllowedVersion> i = allowedVersions.iterator(); String separator = ""; while (i.hasNext()) { allowed.append(separator).append(i.next().getVersion()); separator = ", "; } } catch (Exception e) { log.error(e.getMessage()); } return allowed.toString(); }
From source file:Main.java
public static <T> void resize(List<T> list, int size, Class<T> clazz) { if (size == list.size()) { return;// ww w . jav a 2s . c o m } if (size < list.size()) { Iterator<T> iter = list.iterator(); for (int i = 1; iter.hasNext(); i++) { iter.next(); if (i > size) { iter.remove(); } } } else { for (int i = 0; i <= size - list.size(); i++) { try { list.add(clazz != null ? clazz.newInstance() : null); } catch (InstantiationException e) { throw new RuntimeException(e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } } } }
From source file:net.sourceforge.fenixedu.applicationTier.Servico.publico.ReadStudentsAndGroupsByShiftID.java
private static List getStudentGroupsByShiftAndGroupProperties(Grouping groupProperties, Shift shift) { List result = new ArrayList(); List studentGroups = groupProperties.getStudentGroupsWithShift(); Iterator iter = studentGroups.iterator(); while (iter.hasNext()) { StudentGroup sg = (StudentGroup) iter.next(); if (sg.getShift().equals(shift)) { result.add(sg);/*w w w .j a va 2s .c om*/ } } return result; }
From source file:com.pureinfo.dolphin.script.param.Parameter.java
/** * // w w w.j a v a 2 s . co m * @param _element * @param _bRequired * @throws PureException */ public static void readParameters(Element _element, Map _container, boolean _bRequired) throws PureException { if (_element == null && _bRequired) { throw new PureException(PureException.INVALID_REQUEST, "_element can't be null."); } List paramEleList = _element.elements(ELEMENT_PARAMETER); for (Iterator iter = paramEleList.iterator(); iter.hasNext();) { Element paramEle = (Element) iter.next(); Parameter param = new Parameter(); param.fromXML(paramEle); _container.put(param.getName(), param.getValue()); } }
From source file:gobblin.metastore.util.DatabaseJobHistoryStoreSchemaManager.java
private static Properties getProperties(Configuration config) { Properties props = new Properties(); char delimiter = (config instanceof AbstractConfiguration) ? ((AbstractConfiguration) config).getListDelimiter() : ','; Iterator keys = config.getKeys(); while (keys.hasNext()) { String key = (String) keys.next(); List list = config.getList(key); props.setProperty("flyway." + key, StringUtils.join(list.iterator(), delimiter)); }/*from w w w . j a va2 s .com*/ return props; }
From source file:org.mobicents.servlet.restcomm.http.CustomHttpClientBuilder.java
private static HttpClient buildAllowallClient(RequestConfig requestConfig) { HttpConnectorList httpConnectorList = UriUtils.getHttpConnectorList(); HttpClient httpClient = null;/* w ww .j a va2s .c o m*/ //Enable SSL only if we have HTTPS connector List<HttpConnector> connectors = httpConnectorList.getConnectors(); Iterator<HttpConnector> iterator = connectors.iterator(); while (iterator.hasNext()) { HttpConnector connector = iterator.next(); if (connector.isSecure()) { SSLConnectionSocketFactory sslsf; try { SSLContextBuilder builder = new SSLContextBuilder(); builder.loadTrustMaterial(null, new TrustSelfSignedStrategy()); sslsf = new SSLConnectionSocketFactory(builder.build()); httpClient = HttpClients.custom().setDefaultRequestConfig(requestConfig) .setSSLSocketFactory(sslsf).build(); } catch (KeyManagementException | NoSuchAlgorithmException | KeyStoreException e) { throw new RuntimeException("Error creating HttpClient", e); } break; } } if (httpClient == null) { httpClient = HttpClients.custom().setDefaultRequestConfig(requestConfig).build(); } return httpClient; }
From source file:Main.java
/** * <p>Given a <code>List</code> of <code>Class</code> objects, this method converts * them into class names.</p>// w w w . ja va 2s . c o m * * <p>A new <code>List</code> is returned. <code>null</code> objects will be copied into * the returned list as <code>null</code>.</p> * * @param classes the classes to change * @return a <code>List</code> of class names corresponding to the Class objects, * <code>null</code> if null input * @throws ClassCastException if <code>classes</code> contains a non-<code>Class</code> entry */ public static List convertClassesToClassNames(List classes) { if (classes == null) { return null; } List classNames = new ArrayList(classes.size()); for (Iterator it = classes.iterator(); it.hasNext();) { Class cls = (Class) it.next(); if (cls == null) { classNames.add(null); } else { classNames.add(cls.getName()); } } return classNames; }
From source file:com.glaf.activiti.util.ExtensionUtils.java
public static List<Object> getValues(Map<String, Object> paramMap, ExtensionEntity extension) { java.util.Date now = new java.util.Date(); List<Object> values = new java.util.ArrayList<Object>(); List<ExtensionParamEntity> x_params = extension.getParams(); Iterator<ExtensionParamEntity> iterator = x_params.iterator(); while (iterator.hasNext()) { ExtensionParamEntity param = iterator.next(); String key = param.getValue(); Object value = param.getValue(); if (key != null && value != null) { String tmp = param.getValue(); if (StringUtils.isNotEmpty(tmp)) { if (tmp.equals("now()")) { value = new java.sql.Date(now.getTime()); } else if (tmp.equals("date()")) { value = new java.sql.Date(now.getTime()); } else if (tmp.equals("time()")) { value = new java.sql.Time(now.getTime()); } else if (tmp.equals("timestamp()")) { value = new java.sql.Timestamp(now.getTime()); } else if (tmp.equals("dateTime()")) { value = new java.sql.Timestamp(now.getTime()); } else if (tmp.equals("currentTimeMillis()")) { value = Long.valueOf(System.currentTimeMillis()); } else if (tmp.equals("#{businessKey}")) { value = ParamUtils.getString(paramMap, "businessKey"); } else if (tmp.equals("#{processInstanceId}")) { value = ParamUtils.getString(paramMap, "processInstanceId"); } else if (tmp.equals("#{processName}")) { value = ParamUtils.getString(paramMap, "processName"); } else if (tmp.equals("#{status}")) { value = paramMap.get("status"); } else if (tmp.startsWith("#P{") && tmp.endsWith("}")) { tmp = StringTools.replaceIgnoreCase(tmp, "#P{", ""); tmp = StringTools.replaceIgnoreCase(tmp, "}", ""); value = paramMap.get(tmp); } else if (tmp.startsWith("#{") && tmp.endsWith("}")) { value = Mvel2ExpressionEvaluator.evaluate(tmp, paramMap); }/*from w w w.j a v a 2 s .com*/ } } values.add(value); } return values; }