List of usage examples for org.dom4j Element getTextTrim
String getTextTrim();
From source file:org.springframework.extensions.webscripts.ResourceDescription.java
License:Apache License
public void parse(Element elem) { if (this.validateRootElement(elem, ROOT_ELEMENT_NAME)) { super.parse(elem); Element webscriptElement = elem.element(WEBSCRIPTS_ELEMENT_NAME); if (webscriptElement != null) { String[] webscriptIds = webscriptElement.getTextTrim().split(","); this.setScriptIds(webscriptIds); }/*from www . j av a2 s.c om*/ } }
From source file:org.springframework.extensions.webscripts.TypeDescription.java
License:Apache License
public void parse(Element elem) { if (this.validateRootElement(elem, ROOT_ELEMENT_NAME)) { super.parse(elem); Element formatElement = elem.element(FORMAT_ELEMENT_NAME); if (formatElement != null) { this.setFormat(formatElement.getTextTrim()); }/* www . j a v a 2 s . c om*/ Element definitionElement = elem.element(DEFINITION_ELEMENT_NAME); if (definitionElement != null) { this.setDefinition(definitionElement.getText()); } Element urlElement = elem.element(DEFINITION_ELEMENT_URL); if (urlElement != null) { this.setUrl(urlElement.getText()); } } }
From source file:org.talend.core.model.utils.SQLFormatUtil.java
License:Open Source License
private Collection<String> findSQLKeyWords() { SAXReader saxReader = new SAXReader(); Document document = null;// w w w .ja va 2 s . c o m try { document = saxReader.read(CommonsPlugin.class.getClassLoader().getResourceAsStream("/modes/tsql.xml")); //$NON-NLS-1$ List list = document.selectNodes("//MODE/RULES/KEYWORDS/KEYWORD1"); //$NON-NLS-1$ Iterator iter = list.iterator(); Collection<String> res = new HashSet<String>(); while (iter.hasNext()) { Element element = (Element) iter.next(); String key = element.getTextTrim(); if (key != null && !key.equals("")) { //$NON-NLS-1$ res.add(key.toUpperCase()); } } return res; } catch (DocumentException e) { ExceptionHandler.process(e); return null; } }
From source file:org.unitime.banner.onlinesectioning.BannerStudentUpdates.java
License:Apache License
@SuppressWarnings("unchecked") public void processMessage(org.hibernate.Session hibSession, Element rootElement) { if (!"studentUpdates".equalsIgnoreCase(rootElement.getName())) return;/* w w w. j a va 2 s. c o m*/ long maxElementTime = 0, minElementTime = 0; int elementCount = 0; boolean trimLeadingZerosFromExternalId = ApplicationProperty.DataExchangeTrimLeadingZerosFromExternalIds .isTrue(); Map<String, List<Long>> session2ids = new HashMap<String, List<Long>>(); Set<String> failedStudents = new HashSet<String>(); Set<String> problemStudents = new HashSet<String>(); Set<String> updatedStudents = new HashSet<String>(); Map<Long, Set<Long>> session2studentIds = new HashMap<Long, Set<Long>>(); long start = System.currentTimeMillis(); for (Iterator<?> i = rootElement.elementIterator("student"); i.hasNext();) { Element studentElement = (Element) i.next(); long t0 = System.currentTimeMillis(); try { String externalId = studentElement.attributeValue("externalId"); if (externalId == null) { error("No externalId was given for a student."); continue; } while (trimLeadingZerosFromExternalId && externalId.startsWith("0")) externalId = externalId.substring(1); String bannerSession = studentElement.attributeValue("session"); if (bannerSession == null) { error("No session was given for a student."); continue; } List<Long> sessionIds = session2ids.get(bannerSession); if (sessionIds == null) { sessionIds = (List<Long>) hibSession.createQuery( "select bs.session.uniqueId from BannerSession bs where bs.bannerTermCode = :termCode") .setString("termCode", bannerSession).list(); session2ids.put(bannerSession, sessionIds); } BannerUpdateStudentAction update = new BannerUpdateStudentAction(); update.forStudent(externalId, bannerSession); update.withName(studentElement.attributeValue("firstName"), studentElement.attributeValue("middleName"), studentElement.attributeValue("lastName")); update.withEmail(studentElement.attributeValue("email")); Element studentMajorsElement = studentElement.element("studentMajors"); Element studentAcadAreaClassElement = studentElement.element("studentAcadAreaClass"); if (studentMajorsElement != null) { // Student XML format update.updateAcadAreaClassificationMajors(true); for (Iterator<?> j = studentMajorsElement.elementIterator("major"); j.hasNext();) { Element majorElement = (Element) j.next(); if (majorElement.attributeValue("academicClass") == null && studentAcadAreaClassElement != null) { for (Iterator<?> k = studentAcadAreaClassElement.elementIterator("acadAreaClass"); k .hasNext();) { Element areaClassElement = (Element) k.next(); if (majorElement.attributeValue("academicArea") .equals(areaClassElement.attributeValue("academicArea"))) update.withAcadAreaClassificationMajor( majorElement.attributeValue("academicArea"), areaClassElement.attributeValue("academicClass"), majorElement.attributeValue("code"), majorElement.attributeValue("campus")); } } else { update.withAcadAreaClassificationMajor(majorElement.attributeValue("academicArea"), majorElement.attributeValue("academicClass"), majorElement.attributeValue("code"), majorElement.attributeValue("campus")); } } } else { // Old banner update message format update.withAcadAreaClassificationMajor(studentElement.attributeValue("academicArea"), studentElement.attributeValue("classification"), studentElement.attributeValue("major"), studentElement.attributeValue("campus")); } Element studentGroupsElement = studentElement.element("studentGroups"); if (studentGroupsElement != null) { // Student XML format for (Iterator<?> j = studentGroupsElement.elementIterator("studentGroup"); j.hasNext();) { Element studentGroupElement = (Element) j.next(); update.withGroup( studentGroupElement.attributeValue("externalId", studentGroupElement.attributeValue("group")), studentGroupElement.attributeValue("campus"), studentGroupElement.attributeValue("abbreviation", studentGroupElement.attributeValue("group")), studentGroupElement.attributeValue("name")); } } else { // Old banner upadte message format for (Iterator<?> j = studentElement.elementIterator("studentGroup"); j.hasNext();) { Element studentGroupElement = (Element) j.next(); update.withGroup(studentGroupElement.attributeValue("externalId"), studentGroupElement.attributeValue("campus"), studentGroupElement.attributeValue("abbreviation"), studentGroupElement.attributeValue("name")); } } // Old banner update message format for (Iterator<?> j = studentElement.elementIterator("crn"); j.hasNext();) { Element crnElement = (Element) j.next(); try { update.withCRN(Integer.valueOf(crnElement.getTextTrim())); } catch (Exception e) { error("An integer value is required for a crn element (student " + externalId + ")."); problemStudents.add(externalId); } } // Student enrollment XML format for (Iterator<?> j = studentElement.elementIterator("class"); j.hasNext();) { Element classElement = (Element) j.next(); try { update.withCRN(Integer.valueOf(classElement.attributeValue("externalId"))); } catch (Exception e) { error("An integer value is required as external id of a class element (student " + externalId + ")."); problemStudents.add(externalId); } } // Overrides for (Iterator<?> j = studentElement.elementIterator("override"); j.hasNext();) { Element overrideElement = (Element) j.next(); update.withOverride(overrideElement.attributeValue("type"), overrideElement.attributeValue("subject"), overrideElement.attributeValue("course", overrideElement.attributeValue("courseNbr")), overrideElement.attributeValue("crn")); } // Student advisors for (Iterator<?> j = studentElement.elementIterator("advisor"); j.hasNext();) { Element advisorElement = (Element) j.next(); String advisorExternalId = advisorElement.attributeValue("advisorId"); if (advisorExternalId == null) { error("No externalId was given for an advisor."); continue; } while (trimLeadingZerosFromExternalId && advisorExternalId.startsWith("0")) advisorExternalId = advisorExternalId.substring(1); update.withAdvisor(advisorExternalId, advisorElement.attributeValue("advisorType")); } // Sports for (Iterator<?> j = studentElement.elementIterator("sport"); j.hasNext();) { Element sportElement = (Element) j.next(); update.withGroup( sportElement.attributeValue("externalId", sportElement.attributeValue("group")), sportElement.attributeValue("campus"), sportElement.attributeValue("group"), sportElement.attributeValue("groupname", sportElement.attributeValue("group")), "SPORT"); } // Cohorts for (Iterator<?> j = studentElement.elementIterator("cohort"); j.hasNext();) { Element sportElement = (Element) j.next(); update.withGroup( sportElement.attributeValue("externalId", sportElement.attributeValue("group")), sportElement.attributeValue("campus"), sportElement.attributeValue("group"), sportElement.attributeValue("groupname", sportElement.attributeValue("group")), "COHORT"); } for (Long sessionId : sessionIds) { try { OnlineSectioningServer server = (iContainer == null ? null : iContainer.getSolver(sessionId.toString())); if (server != null && server.isReady()) { try { switch (server.execute(update, user())) { case OK: updatedStudents.add(externalId); break; case FAILURE: failedStudents.add(externalId); break; case PROBLEM: problemStudents.add(externalId); break; case NO_CHANGE: } } finally { _RootDAO.closeCurrentThreadSessions(); } } else { OnlineSectioningHelper h = new OnlineSectioningHelper( QueueInDAO.getInstance().createNewSession(), user(), CacheMode.REFRESH); try { h.addMessageHandler(this); UpdateResult result = update.execute(sessionId, h); switch (result) { case OK: updatedStudents.add(externalId); break; case FAILURE: failedStudents.add(externalId); break; case PROBLEM: problemStudents.add(externalId); break; case NO_CHANGE: } if (update.getStudentId() != null && (result == UpdateResult.OK || result == UpdateResult.PROBLEM)) { Set<Long> ids = session2studentIds.get(sessionId); if (ids == null) { ids = new HashSet<Long>(); session2studentIds.put(sessionId, ids); } ids.add(update.getStudentId()); } } finally { h.getHibSession().close(); } } } catch (Exception e) { error("Failed to update student " + externalId + ": " + e.getMessage()); failedStudents.add(externalId); } } } finally { long time = (System.currentTimeMillis() - t0); if (elementCount == 0 || time < minElementTime) { minElementTime = time; } if (elementCount == 0 || time > maxElementTime) { maxElementTime = time; } elementCount++; } } long end = System.currentTimeMillis(); info(updatedStudents.size() + " student records updated in " + (end - start) + " milliseconds."); info(failedStudents.size() + " student records failed to update."); info(problemStudents.size() + " student records were updated, but had problems."); if (elementCount > 0) { info("Minimum milliseconds required to process a record = " + minElementTime); info("Maximum milliseconds required to process a record = " + maxElementTime); info("Average milliseconds required to process a record = " + ((end - start) / elementCount)); } if (!failedStudents.isEmpty()) { error("The following student ids were not successfully processed: "); for (String studentId : failedStudents) error("\t" + studentId); } if (!problemStudents.isEmpty()) { error("The following student ids were successfully processed, but may have had problems finding all classes the student was enrolled in: "); for (String studentId : problemStudents) error("\t" + studentId); } for (Map.Entry<Long, Set<Long>> entry : session2studentIds.entrySet()) { StudentSectioningQueue.studentChanged(hibSession, null, entry.getKey(), entry.getValue()); } hibSession.flush(); }
From source file:org.unitime.colleague.onlinesectioning.ColleagueStudentUpdates.java
License:Apache License
@SuppressWarnings("unchecked") public void processMessage(org.hibernate.Session hibSession, Element rootElement) { if (!"studentUpdates".equalsIgnoreCase(rootElement.getName())) return;//from ww w. ja v a2 s . c o m long maxElementTime = 0, minElementTime = 0; int elementCount = 0; boolean trimLeadingZerosFromExternalId = ApplicationProperty.DataExchangeTrimLeadingZerosFromExternalIds .isTrue(); Map<String, List<Long>> session2ids = new HashMap<String, List<Long>>(); Set<String> failedStudents = new HashSet<String>(); Set<String> problemStudents = new HashSet<String>(); Set<String> updatedStudents = new HashSet<String>(); Map<Long, Set<Long>> session2studentIds = new HashMap<Long, Set<Long>>(); long start = System.currentTimeMillis(); for (Iterator<?> i = rootElement.elementIterator("student"); i.hasNext();) { Element studentElement = (Element) i.next(); long t0 = System.currentTimeMillis(); try { String externalId = studentElement.attributeValue("externalId"); if (externalId == null) { error("No externalId was given for a student."); continue; } while (trimLeadingZerosFromExternalId && externalId.startsWith("0")) externalId = externalId.substring(1); String colleagueSession = studentElement.attributeValue("session"); if (colleagueSession == null) { error("No session was given for a student."); continue; } List<Long> sessionIds = session2ids.get(colleagueSession); if (sessionIds == null) { sessionIds = (List<Long>) hibSession.createQuery( "select cs.session.uniqueId from ColleagueSession cs where cs.colleagueTermCode = :termCode") .setString("termCode", colleagueSession).list(); session2ids.put(colleagueSession, sessionIds); } ColleagueUpdateStudentAction update = new ColleagueUpdateStudentAction(); update.forStudent(externalId, colleagueSession); update.withName(studentElement.attributeValue("firstName"), studentElement.attributeValue("middleName"), studentElement.attributeValue("lastName")); update.withEmail(studentElement.attributeValue("email")); Element studentMajorsElement = studentElement.element("studentMajors"); Element studentAcadAreaClassElement = studentElement.element("studentAcadAreaClass"); if (studentMajorsElement != null) { // Student XML format update.updateAcadAreaClassificationMajors(true); for (Iterator<?> j = studentMajorsElement.elementIterator("major"); j.hasNext();) { Element majorElement = (Element) j.next(); if (majorElement.attributeValue("academicClass") == null && studentAcadAreaClassElement != null) { for (Iterator<?> k = studentAcadAreaClassElement.elementIterator("acadAreaClass"); k .hasNext();) { Element areaClassElement = (Element) k.next(); if (majorElement.attributeValue("academicArea") .equals(areaClassElement.attributeValue("academicArea"))) update.withAcadAreaClassificationMajor( majorElement.attributeValue("academicArea"), areaClassElement.attributeValue("academicClass"), majorElement.attributeValue("code")); } } else { update.withAcadAreaClassificationMajor(majorElement.attributeValue("academicArea"), majorElement.attributeValue("academicClass"), majorElement.attributeValue("code")); } } } else { // Old banner update message format update.withAcadAreaClassificationMajor(studentElement.attributeValue("academicArea"), studentElement.attributeValue("classification"), studentElement.attributeValue("major")); } Element studentGroupsElement = studentElement.element("studentGroups"); if (studentGroupsElement != null) { // Student XML format for (Iterator<?> j = studentGroupsElement.elementIterator("studentGroup"); j.hasNext();) { Element studentGroupElement = (Element) j.next(); update.withGroup( studentGroupElement.attributeValue("externalId", studentGroupElement.attributeValue("group")), studentGroupElement.attributeValue("campus"), studentGroupElement.attributeValue("abbreviation", studentGroupElement.attributeValue("group")), studentGroupElement.attributeValue("name")); } } else { // Old colleague update message format for (Iterator<?> j = studentElement.elementIterator("studentGroup"); j.hasNext();) { Element studentGroupElement = (Element) j.next(); update.withGroup(studentGroupElement.attributeValue("externalId"), studentGroupElement.attributeValue("campus"), studentGroupElement.attributeValue("abbreviation"), studentGroupElement.attributeValue("name")); } } // Old colleague update message format for (Iterator<?> j = studentElement.elementIterator("colleagueSectionId"); j.hasNext();) { Element colleagueSectionIdElement = (Element) j.next(); try { update.withColleagueSectionId(Integer.valueOf(colleagueSectionIdElement.getTextTrim())); } catch (Exception e) { error("An integer value is required for a colleagueSectionId element (student " + externalId + ")."); problemStudents.add(externalId); } } // Student enrollment XML format for (Iterator<?> j = studentElement.elementIterator("class"); j.hasNext();) { Element classElement = (Element) j.next(); try { update.withColleagueSectionId(Integer.valueOf(classElement.attributeValue("externalId"))); } catch (Exception e) { error("An integer value is required as external id of a class element (student " + externalId + ")."); problemStudents.add(externalId); } } // Overrides for (Iterator<?> j = studentElement.elementIterator("override"); j.hasNext();) { Element overrideElement = (Element) j.next(); update.withOverride(overrideElement.attributeValue("type"), overrideElement.attributeValue("subject"), overrideElement.attributeValue("course", overrideElement.attributeValue("courseNbr")), overrideElement.attributeValue("colleagueSectionId")); } for (Long sessionId : sessionIds) { try { OnlineSectioningServer server = (iContainer == null ? null : iContainer.getSolver(sessionId.toString())); if (server != null && server.isReady()) { try { switch (server.execute(update, user())) { case OK: updatedStudents.add(externalId); break; case FAILURE: failedStudents.add(externalId); break; case PROBLEM: problemStudents.add(externalId); break; case NO_CHANGE: } } finally { _RootDAO.closeCurrentThreadSessions(); } } else { OnlineSectioningHelper h = new OnlineSectioningHelper( QueueInDAO.getInstance().createNewSession(), user(), CacheMode.REFRESH); try { h.addMessageHandler(this); UpdateResult result = update.execute(sessionId, h); switch (result) { case OK: updatedStudents.add(externalId); break; case FAILURE: failedStudents.add(externalId); break; case PROBLEM: problemStudents.add(externalId); break; case NO_CHANGE: } if (update.getStudentId() != null && (result == UpdateResult.OK || result == UpdateResult.PROBLEM)) { Set<Long> ids = session2studentIds.get(sessionId); if (ids == null) { ids = new HashSet<Long>(); session2studentIds.put(sessionId, ids); } ids.add(update.getStudentId()); } } finally { h.getHibSession().close(); } } } catch (Exception e) { error("Failed to update student " + externalId + ": " + e.getMessage()); failedStudents.add(externalId); } } } finally { long time = (System.currentTimeMillis() - t0); if (elementCount == 0 || time < minElementTime) { minElementTime = time; } if (elementCount == 0 || time > maxElementTime) { maxElementTime = time; } elementCount++; } } long end = System.currentTimeMillis(); info(updatedStudents.size() + " student records updated in " + (end - start) + " milliseconds."); info(failedStudents.size() + " student records failed to update."); info(problemStudents.size() + " student records were updated, but had problems."); if (elementCount > 0) { info("Minimum milliseconds required to process a record = " + minElementTime); info("Maximum milliseconds required to process a record = " + maxElementTime); info("Average milliseconds required to process a record = " + ((end - start) / elementCount)); } if (!failedStudents.isEmpty()) { error("The following student ids were not successfully processed: "); for (String studentId : failedStudents) error("\t" + studentId); } if (!problemStudents.isEmpty()) { error("The following student ids were successfully processed, but may have had problems finding all classes the student was enrolled in: "); for (String studentId : problemStudents) error("\t" + studentId); } for (Map.Entry<Long, Set<Long>> entry : session2studentIds.entrySet()) { StudentSectioningQueue.studentChanged(hibSession, null, entry.getKey(), entry.getValue()); } hibSession.flush(); }
From source file:org.unitime.commons.hibernate.util.DatabaseUpdate.java
License:Open Source License
public void performUpdate() { sLog.info("Current " + updateName() + " database version: " + getVersion()); String dialect = _RootDAO.getConfiguration().getProperty("dialect"); for (Iterator i = iRoot.elementIterator("dialect"); i.hasNext();) { Element dialectElement = (Element) i.next(); if (dialect.equals(dialectElement.getTextTrim())) iDialectSQL = dialectElement.attributeValue("type"); }/* w ww . ja v a 2 s . c o m*/ for (Iterator i = iRoot.elementIterator("update"); i.hasNext();) { Element updateElement = (Element) i.next(); int updateVersion = Integer.parseInt(updateElement.attributeValue("version")); if (updateVersion > getVersion() && !performUpdate(updateElement)) break; } sLog.info("New " + updateName() + " database version: " + getVersion()); }
From source file:org.unitime.timetable.dataexchange.HQLImport.java
License:Apache License
protected void importReport(Element reportEl) { String name = reportEl.attributeValue("name"); if (name == null) { error("Attribute name is not provided."); return;//from w w w . ja v a2 s. c om } SavedHQL report = (SavedHQL) getHibSession().createQuery("from SavedHQL where name = :name") .setString("name", name).setMaxResults(1).uniqueResult(); if (report == null) { report = new SavedHQL(); report.setName(name); } report.setType(0); Element flags = reportEl.element("flags"); for (Iterator i = (flags == null ? reportEl : flags).elementIterator("flag"); i.hasNext();) { Element e = (Element) i.next(); SavedHQL.Flag flag = SavedHQL.Flag.valueOf(e.getTextTrim()); if (flag != null) report.set(flag); } Element queryEl = reportEl.element("query"); if (queryEl != null) report.setQuery(queryEl.getText()); else report.setQuery(null); Element descriptionEl = reportEl.element("description"); if (descriptionEl != null) report.setDescription(descriptionEl.getText()); else report.setDescription(null); getHibSession().saveOrUpdate(report); }
From source file:org.unitime.timetable.dataexchange.TravelTimesImport.java
License:Open Source License
public void loadXml(Element root) throws Exception { if (!root.getName().equalsIgnoreCase("traveltimes")) { throw new Exception("Given XML file is not a Travel Times load file."); }/*ww w. j a va 2 s. co m*/ try { beginTransaction(); String campus = root.attributeValue("campus"); String year = root.attributeValue("year"); String term = root.attributeValue("term"); Session session = Session.getSessionUsingInitiativeYearTerm(campus, year, term); if (session == null) { throw new Exception("No session found for the given campus, year, and term."); } info("Deleting existing travel times..."); getHibSession().createQuery("delete from TravelTime where session.uniqueId = :sessionId") .setLong("sessionId", session.getUniqueId()).executeUpdate(); info("Importing travel times..."); for (Iterator i = root.elementIterator("from"); i.hasNext();) { Element fromEl = (Element) i.next(); Location from = findLocation(session.getUniqueId(), fromEl); if (from == null) continue; for (Iterator j = fromEl.elementIterator("to"); j.hasNext();) { Element toEl = (Element) j.next(); Location to = findLocation(session.getUniqueId(), toEl); if (to == null) continue; TravelTime time = new TravelTime(); time.setSession(session); time.setLocation1Id(Math.min(from.getUniqueId(), to.getUniqueId())); time.setLocation2Id(Math.max(from.getUniqueId(), to.getUniqueId())); time.setDistance(Integer.parseInt(toEl.getTextTrim())); getHibSession().saveOrUpdate(time); } } info("All done."); commitTransaction(); } catch (Exception e) { fatal("Exception: " + e.getMessage(), e); rollbackTransaction(); throw e; } }
From source file:org.unitime.timetable.test.UpdateSequencesFromXml.java
License:Apache License
@SuppressWarnings("unchecked") private void checkSequences(Element classEl, String parentTable, String parentIdColumn, String parentSequence) throws IOException { String table = classEl.attributeValue("table"); if (table == null) table = parentTable;// w ww .ja v a 2 s . c om String sequence = null, idColumn = null; for (Iterator<Element> i = classEl.elementIterator("id"); i.hasNext();) { Element el = i.next(); idColumn = el.attributeValue("column").toLowerCase(); if (el.element("generator") != null) for (Iterator<Element> j = el.element("generator").elementIterator("param"); j.hasNext();) { Element p = j.next(); if ("sequence".equals(p.attributeValue("name"))) sequence = p.getTextTrim(); } } if (sequence == null) sequence = parentSequence; if (idColumn == null) idColumn = parentIdColumn; if (sequence != null && table != null) { info(" " + table + "." + idColumn + ": " + sequence); TreeSet<String> tables = iSequences.get(sequence); if (tables == null) { tables = new TreeSet<String>(); iSequences.put(sequence, tables); } tables.add(table); iIdColumns.put(table, idColumn); } for (Iterator<Element> i = classEl.elementIterator("union-subclass"); i.hasNext();) { checkSequences(i.next(), table, idColumn, sequence); } for (Iterator<Element> i = classEl.elementIterator("subclass"); i.hasNext();) { checkSequences(i.next(), table, idColumn, sequence); } }
From source file:org.xmpp.packet.Roster.java
License:Open Source License
/** * Returns an unmodifiable copy of the {@link Item Items} in the roster packet. * * @return an unmodifable copy of the {@link Item Items} in the roster packet. *//*w ww . ja v a 2 s . c o m*/ public Collection<Item> getItems() { Collection<Item> items = new ArrayList<Item>(); Element query = element.element(new QName("query", Namespace.get("jabber:iq:roster"))); if (query != null) { for (Iterator i = query.elementIterator("item"); i.hasNext();) { Element item = (Element) i.next(); String jid = item.attributeValue("jid"); String name = item.attributeValue("name"); String ask = item.attributeValue("ask"); String subscription = item.attributeValue("subscription"); Collection<String> groups = new ArrayList<String>(); for (Iterator j = item.elementIterator("group"); j.hasNext();) { Element group = (Element) j.next(); groups.add(group.getTextTrim()); } Ask askStatus = ask == null ? null : Ask.valueOf(ask); Subscription subStatus = subscription == null ? null : Subscription.valueOf(subscription); items.add(new Item(new JID(jid), name, askStatus, subStatus, groups)); } } return Collections.unmodifiableCollection(items); }