List of usage examples for java.util List iterator
Iterator<E> iterator();
From source file:net.jradius.server.config.ConfigurationItem.java
public static HashMap getPropertiesFromConfig(XMLConfiguration config, HierarchicalConfiguration.Node root) { HashMap map = new HashMap(); List list = root.getChildren("property"); HierarchicalConfiguration.Node node; for (Iterator l = list.iterator(); l.hasNext();) { node = (HierarchicalConfiguration.Node) l.next(); config.setRoot(node);/*ww w .j a v a 2 s . c o m*/ String name = config.getConfigString("name"); String value = config.getConfigString("value"); map.put(name, value); } return map; }
From source file:net.kamhon.ieagle.util.StringUtil.java
public static String convertToStringWithSeparator(List<?> list, String separator, boolean withSpacing) { String result = ""; if (CollectionUtil.isEmpty(list)) { return ""; }/*from w w w . j ava 2s .c o m*/ for (Iterator<?> iterator = list.iterator(); iterator.hasNext();) { Object o = iterator.next(); String s = o.toString(); result += s; if (iterator.hasNext()) { if (withSpacing) result += ", "; else result += ","; } } return result; }
From source file:com.qubit.solution.fenixedu.integration.cgd.webservices.messages.CgdMessageUtils.java
public static Person readPersonByMemberCode(String populationCode, String memberCode) { Person requestedPerson = null;/*from w ww . ja v a 2 s.c om*/ if (!StringUtils.isEmpty(memberCode) && !StringUtils.isEmpty(populationCode)) { switch (populationCode.charAt(0)) { case 'A': Student student = null; try { int number = Integer.parseInt(memberCode); student = Student.readStudentByNumber(number); } catch (Exception e) { logger.warn(String.format("Invalid student number: [%s]", memberCode)); } if (student != null) { requestedPerson = student.getPerson(); } case 'E': // NOT YET IMPLEMENTED break; case 'D': List<Teacher> readByNumbers = Teacher.readByNumbers(Collections.singleton(memberCode)); Teacher teacher = readByNumbers.isEmpty() ? null : readByNumbers.iterator().next(); if (teacher != null) { requestedPerson = teacher.getPerson(); } } } return requestedPerson; }
From source file:com.redhat.rhn.frontend.graphing.GraphGenerator.java
/** * Format the RHN TimeSeriesData DTO into a JFree format. * @param List of DTO objects// ww w . j a va 2 s . c o m * @param labelMap a map containing the localized labels used * for the metrics. Contains simple "metricId" keys * with the localized Strings as the value. For example: * labelMap={"pctfree" -> "Percent Free", "memused" -> "Memory Used"} * @return JFree object collection of data and time values */ private static XYDataset createDataset(List dataIn, Map labelMap) { TimeSeriesCollection dataset = new TimeSeriesCollection(); Iterator itr = dataIn.iterator(); while (itr.hasNext()) { TimeSeriesData[] data = (TimeSeriesData[]) itr.next(); if (data.length > 0) { TimeSeries s1 = new TimeSeries((String) labelMap.get(data[0].getMetric()), Minute.class); for (int i = 0; i < data.length; i++) { Minute m1 = new Minute(data[i].getTime()); s1.addOrUpdate(m1, data[i].getData()); } dataset.addSeries(s1); } } dataset.setDomainIsPointsInTime(true); return dataset; }
From source file:Main.java
/** * Return an iterator for the subelements. * /*from w ww . j a v a2s.c om*/ * @return java.util.Iterator * @param element * org.w3c.dom.Element * @param name * java.lang.String */ public static Iterator<Node> getNodeIterator(Element element, String name) { List<Node> list = new ArrayList<Node>(); NodeList nodeList = element.getElementsByTagName(name); int length = nodeList.getLength(); for (int i = 0; i < length; i++) list.add(nodeList.item(i)); return list.iterator(); }
From source file:net.sourceforge.fenixedu.applicationTier.Servico.resourceAllocationManager.ReadExecutionDegreesByExecutionYearId.java
@Atomic public static List run(String executionYearId) { List<InfoExecutionDegree> infoExecutionDegreeList = null; ExecutionYear executionYear = null;/* w w w . j a v a 2s . c o m*/ if (StringUtils.isEmpty(executionYearId)) { executionYear = ExecutionYear.readCurrentExecutionYear(); } else { executionYear = FenixFramework.getDomainObject(executionYearId); } List<ExecutionDegree> executionDegrees = ExecutionDegree.getAllByExecutionYear(executionYear.getYear()); if (executionDegrees != null && executionDegrees.size() > 0) { Iterator iterator = executionDegrees.iterator(); infoExecutionDegreeList = new ArrayList<InfoExecutionDegree>(); while (iterator.hasNext()) { ExecutionDegree executionDegree = (ExecutionDegree) iterator.next(); InfoExecutionDegree infoExecutionDegree = InfoExecutionDegree.newInfoFromDomain(executionDegree); infoExecutionDegreeList.add(infoExecutionDegree); } } return infoExecutionDegreeList; }
From source file:com.github.lucapino.jira.helpers.IssuesReportHelper.java
/** * Print a list of values separated by commas. * * @param values The values to print//from w w w. j a va 2s .c om * @return A nicely formatted string of values. */ public static String printValues(List<String> values) { StringBuilder sb = new StringBuilder(); if (values != null) { Iterator<String> iterator = values.iterator(); while (iterator.hasNext()) { String value = iterator.next(); sb.append(value); if (iterator.hasNext()) { sb.append(", "); } } } return sb.toString(); }
From source file:com.tacitknowledge.util.discovery.ClasspathUtils.java
/** * Returns the classpath as a list of the names of archive files. Any * classpath component that is not an archive will be ignored. * * @return the classpath as a list of archive file names; if no archives can * be found then an empty list will be returned *//* w w w.j av a 2 s . c om*/ public static List getClasspathArchives() { List archives = new ArrayList(); List components = getClasspathComponents(); for (Iterator i = components.iterator(); i.hasNext();) { String possibleDir = (String) i.next(); File file = new File(possibleDir); if (file.isFile() && (file.getName().endsWith(".jar") || file.getName().endsWith(".zip"))) { archives.add(possibleDir); } } return archives; }
From source file:com.pureinfo.dolphin.script.param.ParameterMetadata.java
/** * Get the metadatas of the parameters from a dom4j <code>Element</code> * //from www . ja va 2 s . c o m * @param _element * a dom4j <code>Element</code> * @return @throws * Exception */ public static Map getParameterMetadatas(Element _element, boolean _bRequired) throws PureException { Map params = new HashMap(); if (_element == null) { if (_bRequired) { throw new PureException(PureException.INVALID_REQUEST, "_element can't be null."); } return params; } List paramEleList = _element.elements(ELEMENT_PARAMETER); for (Iterator iter = paramEleList.iterator(); iter.hasNext();) { Element paramEle = (Element) iter.next(); ParameterMetadata param = new ParameterMetadata(); param.fromXML(paramEle); params.put(param.getName(), param); } return params; }
From source file:net.sourceforge.fenixedu.applicationTier.Servico.publico.ReadStudentsAndGroupsByShiftID.java
@Atomic public static InfoSiteStudentsAndGroups run(String groupPropertiesId, String shiftId) throws FenixServiceException { InfoSiteStudentsAndGroups infoSiteStudentsAndGroups = new InfoSiteStudentsAndGroups(); Grouping groupProperties = FenixFramework.getDomainObject(groupPropertiesId); infoSiteStudentsAndGroups.setInfoGrouping(InfoGrouping.newInfoFromDomain(groupProperties)); Shift shift = FenixFramework.getDomainObject(shiftId); if (groupProperties == null) { throw new ExistingServiceException(); }//from ww w . ja v a2 s . c o m infoSiteStudentsAndGroups.setInfoShift(InfoShift.newInfoFromDomain(shift)); List infoSiteStudentsAndGroupsList = new ArrayList(); List studentGroups = getStudentGroupsByShiftAndGroupProperties(groupProperties, shift); Iterator iterStudentGroups = studentGroups.iterator(); while (iterStudentGroups.hasNext()) { Collection studentGroupAttendList; StudentGroup studentGroup = (StudentGroup) iterStudentGroups.next(); studentGroupAttendList = studentGroup.getAttendsSet(); Iterator iterStudentGroupAttendList = studentGroupAttendList.iterator(); InfoSiteStudentInformation infoSiteStudentInformation = null; InfoSiteStudentAndGroup infoSiteStudentAndGroup = null; Attends attend = null; while (iterStudentGroupAttendList.hasNext()) { infoSiteStudentInformation = new InfoSiteStudentInformation(); infoSiteStudentAndGroup = new InfoSiteStudentAndGroup(); attend = (Attends) iterStudentGroupAttendList.next(); infoSiteStudentAndGroup.setInfoStudentGroup(InfoStudentGroup.newInfoFromDomain(studentGroup)); infoSiteStudentInformation.setNumber(attend.getRegistration().getNumber()); infoSiteStudentInformation.setName(attend.getRegistration().getPerson().getName()); infoSiteStudentInformation.setUsername(attend.getRegistration().getPerson().getUsername()); infoSiteStudentInformation.setEmail(attend.getRegistration().getPerson().getEmail()); infoSiteStudentInformation.setPersonID(attend.getRegistration().getPerson().getExternalId()); infoSiteStudentAndGroup.setInfoSiteStudentInformation(infoSiteStudentInformation); infoSiteStudentsAndGroupsList.add(infoSiteStudentAndGroup); } } Collections.sort(infoSiteStudentsAndGroupsList, new BeanComparator("infoSiteStudentInformation.number")); infoSiteStudentsAndGroups.setInfoSiteStudentsAndGroupsList(infoSiteStudentsAndGroupsList); return infoSiteStudentsAndGroups; }