Java Code Examples for java.util.TreeSet
The following examples show how to use
java.util.TreeSet. These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: binnavi Source File: ForwardRegisterTrackingTransformationProviderTest.java License: Apache License 2.0 | 6 votes |
@Test public void testTransformUndef() { final RegisterTrackingTransformationProvider transformationProvider = new RegisterTrackingTransformationProvider(new RegisterTrackingOptions(false, new TreeSet<String>(), false, AnalysisDirection.DOWN)); final ReilInstruction instruction = ReilHelpers.createUndef(0, OperandSize.DWORD, "eax"); final Pair<RegisterSetLatticeElement, RegisterSetLatticeElement> transformationResult = transformationProvider.transformUndef(instruction, createTaintedState("eax")); Assert.assertNull(transformationResult.second()); transformationResult.first().onInstructionExit(); Assert.assertTrue(transformationResult.first().getNewlyTaintedRegisters().isEmpty()); Assert.assertTrue(transformationResult.first().getReadRegisters().isEmpty()); Assert.assertTrue(transformationResult.first().getTaintedRegisters().isEmpty()); Assert.assertTrue(transformationResult.first().getUntaintedRegisters().contains("eax")); Assert.assertTrue(transformationResult.first().getUpdatedRegisters().isEmpty()); }
Example 2
Source Project: pinpoint Source File: LauncherLaunchInterceptor.java License: Apache License 2.0 | 6 votes |
private Set<String> extractLibJarNamesFromURLs(URL[] urls) { if (urls == null) { return Collections.emptySet(); } Set<String> libJarNames = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER); for (URL url : urls) { try { String libJarName = extractLibJarName(url); if (libJarName.length() > 0) { libJarNames.add(libJarName); } } catch (Exception e) { // safety net logger.warn("Error extracting library name", e); } } return libJarNames; }
Example 3
Source Project: qpid-broker-j Source File: HttpManagementUtil.java License: Apache License 2.0 | 6 votes |
public static String getRequestPrincipals(HttpServletRequest httpRequest) { HttpSession session = httpRequest.getSession(false); if (session != null) { Subject subject = HttpManagementUtil.getAuthorisedSubject(httpRequest); if (subject != null) { Set<Principal> principalSet = subject.getPrincipals(); if (!principalSet.isEmpty()) { TreeSet<String> principalNames = new TreeSet<>(); for (Principal principal : principalSet) { principalNames.add(principal.getName()); } return principalNames.toString(); } } } return null; }
Example 4
Source Project: january Source File: FloatDataset.java License: Eclipse Public License 1.0 | 6 votes |
@Override public FloatDataset getUniqueItems() { Set<Float> set = new TreeSet<Float>(); // CLASS_TYPE IndexIterator it = getIterator(); while (it.hasNext()) { set.add(data[it.index]); } FloatDataset u = new FloatDataset(set.size()); // CLASS_TYPE int i = 0; float[] udata = u.getData(); // PRIM_TYPE for (Float v : set) { // CLASS_TYPE udata[i++] = v; } return u; }
Example 5
Source Project: Android-Keyboard Source File: UserDictionaryList.java License: Apache License 2.0 | 6 votes |
/** * Creates the entries that allow the user to go into the user dictionary for each locale. * @param userDictGroup The group to put the settings in. */ protected void createUserDictSettings(final PreferenceGroup userDictGroup) { final Activity activity = getActivity(); userDictGroup.removeAll(); final TreeSet<String> localeSet = UserDictionaryList.getUserDictionaryLocalesSet(activity); if (localeSet.size() > 1) { // Have an "All languages" entry in the languages list if there are two or more active // languages localeSet.add(""); } if (localeSet.isEmpty()) { userDictGroup.addPreference(createUserDictionaryPreference(null)); } else { for (String locale : localeSet) { userDictGroup.addPreference(createUserDictionaryPreference(locale)); } } }
Example 6
Source Project: openshift-ping Source File: GetServicePort.java License: Apache License 2.0 | 6 votes |
private Set<DnsRecord> getDnsRecords(String serviceName) throws Exception { Set<DnsRecord> dnsRecords = new TreeSet<DnsRecord>(); Hashtable<String, String> env = new Hashtable<String, String>(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.dns.DnsContextFactory"); env.put(Context.PROVIDER_URL, "dns:"); env.put("com.sun.jndi.dns.recursion", "false"); // default is one second, but os skydns can be slow env.put("com.sun.jndi.dns.timeout.initial", "2000"); // retries handled by DnsPing //env.put("com.sun.jndi.dns.timeout.retries", "4"); DirContext ctx = new InitialDirContext(env); Attributes attrs = ctx.getAttributes("_tcp." + serviceName, new String[]{"SRV"}); if (attrs == null) { return dnsRecords; } NamingEnumeration<?> servers = attrs.get("SRV").getAll(); while (servers.hasMore()) { DnsRecord record = DnsRecord.fromString((String)servers.next()); dnsRecords.add(record); } return dnsRecords; }
Example 7
Source Project: freehealth-connector Source File: MapperFactory.java License: GNU Affero General Public License v3.0 | 6 votes |
public static Mapper getMapper(String... mappingFiles) { Set<String> mappingSet = new TreeSet(); mappingSet.addAll(Arrays.asList(mappingFiles)); MessageDigest complete = DigestUtils.getMd5Digest(); Iterator i$ = mappingSet.iterator(); while(i$.hasNext()) { String mapping = (String)i$.next(); complete.update(mapping.getBytes()); } String key = new String(Base64.encode(complete.digest())); if (!cache.containsKey(key)) { Map<String, Object> options = new HashMap(); options.put("be.ehealth.technicalconnector.mapper.configfiles", mappingFiles); try { cache.put(key, helper.getImplementation(options)); } catch (TechnicalConnectorException var6) { throw new IllegalArgumentException(var6); } } return (Mapper)cache.get(key); }
Example 8
Source Project: fnlp Source File: Anaphora.java License: GNU Lesser General Public License v3.0 | 6 votes |
private void init(String[][][]stringTag,String str) throws Exception{ ts = new TreeSet<Entity>(); llis = new LinkedList<Instance>(); fc = new FormChanger(); test = new InstanceSet(cl.getPipe()); test.loadThruPipes(new AR_Reader(stringTag,str)); for(int i=0;i<test.size();i++){ String ss = cl.getStringLabel(test.getInstance(i)); if(ss.equals("1")){ llis.add(test.getInstance(i)); } } fc.groupToList(llis); fc.getLlsb(); ts = fc.getTs(); }
Example 9
Source Project: mzmine2 Source File: ShoulderPeaksFilter.java License: GNU General Public License v2.0 | 6 votes |
/** * This function remove peaks encountered in the lateral of a main peak (currentCandidate) that * are considered as garbage, for example FTMS shoulder peaks. * * First calculates a peak model (Gauss, Lorenzian, etc) defined by peakModelName parameter, with * the same position (m/z) and height (intensity) of the currentCandidate, and the defined * resolution (resolution parameter). Second search and remove all the lateral peaks that are * under the curve of the modeled peak. * */ private static void removeLateralPeaks(DataPoint currentCandidate, TreeSet<DataPoint> candidates, PeakModel peakModel, double resolution) { // We set our peak model with same position(m/z), height(intensity) and // resolution of the current peak peakModel.setParameters(currentCandidate.getMZ(), currentCandidate.getIntensity(), resolution); // We search over all peak candidates and remove all of them that are // under the curve defined by our peak model Iterator<DataPoint> candidatesIterator = candidates.iterator(); while (candidatesIterator.hasNext()) { DataPoint lateralCandidate = candidatesIterator.next(); // Condition in x domain (m/z) if ((lateralCandidate.getIntensity() < peakModel.getIntensity(lateralCandidate.getMZ()))) { candidatesIterator.remove(); } } }
Example 10
Source Project: unitime Source File: Class_.java License: Apache License 2.0 | 6 votes |
public String instructorText(String instructorNameFormat, String separator){ if (getClassInstructors() == null) return ""; TreeSet sortedInstructors = new TreeSet(new InstructorComparator()); sortedInstructors.addAll(this.getClassInstructors()); StringBuffer sb = new StringBuffer(); for (Iterator it = sortedInstructors.iterator(); it.hasNext();) { ClassInstructor ci = (ClassInstructor) it.next(); sb.append(ci.getInstructor().getName(instructorNameFormat)); if (it.hasNext()) sb.append(separator); } return sb.toString(); }
Example 11
Source Project: vanillacore Source File: Percentiles.java License: Apache License 2.0 | 6 votes |
/** * Returns a new instance that keeps only the percentiles with values * falling within the specified range. All new percentiles are adjusted such * that the last value has the 100% percentage. * * @param range * the range within which the percentiles will be preserved * @return a new instance that keeps only the percentiles falling within the * specified range; or <code>null</code> if no such a percentile */ public Percentiles percentiles(ConstantRange range) { SortedSet<Constant> sorted = values(); SortedSet<Constant> contained = new TreeSet<Constant>(); Constant prev = null; for (Constant pct : sorted) { if (range.contains(pct)) { contained.add(pct); } else if (contained.isEmpty()) prev = pct; } if (contained.isEmpty()) return null; double prevPercent = prev == null ? 0.0 : pcts.get(prev); double totalPercent = pcts.get(contained.last()) - prevPercent; Map<Constant, Double> newPcts = new HashMap<Constant, Double>(); for (Constant p : contained) newPcts.put(p, (pcts.get(p) - prevPercent) / totalPercent); return new Percentiles(newPcts); }
Example 12
Source Project: AnimatedGridView Source File: MainActivity.java License: Apache License 2.0 | 6 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); if (id == R.id.action_remove) { if (agv.getCount() >= 6) { TreeSet<Integer> row = new TreeSet<Integer>(); row.add(0); agv.animateDeleteRow(row, 200); } return true; } else if (id == R.id.action_add) { LinkedList<Object> items = new LinkedList<Object>(); items.add(1); items.add(2); items.add(3); items.add(4); items.add(5); items.add(6); agv.animateAddCells(items, 200); } return super.onOptionsItemSelected(item); }
Example 13
Source Project: tracker Source File: NumberFormatDialog.java License: GNU General Public License v3.0 | 6 votes |
/** * Gets an array of unit dimensions for all currently selected variables. * * @return array of unit dimensions */ private String[] getCurrentDimensions() { TTrack track = TTrack.getTrack(trackID); if (track==null) return new String[0]; Class<? extends TTrack> trackType = getTrackType(track); TreeSet<String> dimensions = new TreeSet<String>(); int[] indices = variableList.getSelectedIndices(); Object[] selected = new Object[indices.length]; for (int j=0; j<indices.length; j++) { selected[j] = displayedNames[indices[j]]; } for (Object displayedName : selected) { String name = realNames.get(displayedName.toString()); String dim = getVariableDimensions(trackType, name); if (dim!=null) { dimensions.add(dim); } } return dimensions.toArray(new String[dimensions.size()]); }
Example 14
Source Project: datawave Source File: DateFolderFlagDistributor.java License: Apache License 2.0 | 6 votes |
@Override public boolean addInputFile(InputFile inputFile) throws UnusableFileException { String path = inputFile.getDirectory(); long slice = util.getBucket(grouping, path); // we should never use default... String folder = "default"; for (String string : folders) { if (path.contains(string)) { folder = string; break; } } DFKey bucket = new DFKey(slice, folder); Set<InputFile> bucketList = buckets.get(bucket); if (bucketList == null) { bucketList = new TreeSet<>(fc.isLifo() ? InputFile.LIFO : InputFile.FIFO); buckets.put(bucket, bucketList); } return bucketList.add(inputFile); }
Example 15
Source Project: depgraph-maven-plugin Source File: DependencyNode.java License: Apache License 2.0 | 6 votes |
private DependencyNode(Artifact artifact, NodeResolution resolution, String effectiveVersion) { if (artifact == null) { throw new NullPointerException("Artifact must not be null"); } this.effectiveVersion = effectiveVersion; this.scopes = new TreeSet<>(); this.classifiers = new TreeSet<>(); this.types = new TreeSet<>(); this.artifact = artifact; this.resolution = resolution; if (artifact.getScope() != null) { this.scopes.add(artifact.getScope()); } this.types.add(artifact.getType()); if (!isNullOrEmpty(artifact.getClassifier())) { this.classifiers.add(artifact.getClassifier()); } }
Example 16
Source Project: booties Source File: PostgreSqlRule.java License: Apache License 2.0 | 6 votes |
/** * Finds all the resource names contained in this file system folder. * * @param scanRootLocation * The root location of the scan on disk. * @param folder * The folder to look for resources under on disk. * @return The resource names; * @throws IOException * when the folder could not be read. */ private Set<String> findResourceNamesFromFileSystem(String scanRootLocation, File folder) throws IOException { LOG.debug("Scanning for resources in path: " + folder.getPath() + " (" + scanRootLocation + ")"); Set<String> resourceNames = new TreeSet<String>(); File[] files = folder.listFiles(); for (File file : files) { if (file.canRead()) { if (file.isDirectory()) { resourceNames.addAll(findResourceNamesFromFileSystem(scanRootLocation, file)); } else { resourceNames.add(file.getPath()); } } } return resourceNames; }
Example 17
Source Project: binnavi Source File: ForwardRegisterTrackingTransformationProviderTest.java License: Apache License 2.0 | 6 votes |
@Test public void testTransformSubIdenticalInput() { final RegisterTrackingTransformationProvider transformationProvider = new RegisterTrackingTransformationProvider(new RegisterTrackingOptions(false, new TreeSet<String>(), false, AnalysisDirection.DOWN)); final ReilInstruction instruction = ReilHelpers.createSub(0, OperandSize.DWORD, "ecx", OperandSize.DWORD, "ecx", OperandSize.DWORD, "eax"); final Pair<RegisterSetLatticeElement, RegisterSetLatticeElement> transformationResult = transformationProvider.transformSub(instruction, createTaintedState("ecx", "eax")); Assert.assertNull(transformationResult.second()); transformationResult.first().onInstructionExit(); Assert.assertTrue(transformationResult.first().getNewlyTaintedRegisters().isEmpty()); Assert.assertTrue(transformationResult.first().getReadRegisters().isEmpty()); Assert.assertFalse(transformationResult.first().getTaintedRegisters().contains("eax")); Assert.assertTrue(transformationResult.first().getTaintedRegisters().contains("ecx")); Assert.assertTrue(transformationResult.first().getUntaintedRegisters().contains("eax")); Assert.assertTrue(transformationResult.first().getUpdatedRegisters().isEmpty()); }
Example 18
Source Project: terracotta-platform Source File: CommonProxyFactory.java License: Apache License 2.0 | 6 votes |
private static SortedSet<MethodDescriptor> getSortedMethods(final Class<?> type) { SortedSet<MethodDescriptor> methods = new TreeSet<MethodDescriptor>(METHOD_COMPARATOR); if (type == null) { return methods; } final Method[] declaredMethods = type.getDeclaredMethods(); if (declaredMethods.length > 256) { throw new IllegalArgumentException("Can't proxy that many methods on a single instance!"); } for (Method declaredMethod : declaredMethods) { methods.add(MethodDescriptor.of(declaredMethod)); } if (methods.size() != declaredMethods.length) { throw new AssertionError("Ouch... looks like that didn't work!"); } return methods; }
Example 19
Source Project: blip Source File: IndependenceScorer.java License: GNU Lesser General Public License v3.0 | 6 votes |
@Override protected void prepare() { super.prepare(); // Initialize everything closed = new TCustomHashSet<int[]>(new ArrayHashingStrategy()); // Parent set already seen open = new TreeSet<OpenParentSet>(); // Parent set to evaluate if (max_pset_size <= 1) { return; } // Consider all two-parent set for evaluation for (int i = 0; i < parents.length; i++) { for (int j = i + 1; j < parents.length; j++) { addParentSetToEvaluate(new int[] { parents[i]}, parents[j], null); } } }
Example 20
Source Project: GDH Source File: GroupNodeTest.java License: MIT License | 6 votes |
@Test public void testDifferentGroup() { Node n1 = new Node(ip1, port1); Node n2 = new Node(ip1, port2); Node n3 = new Node(ip1, port1); Node n4 = new Node(ip1, "3002"); TreeSet<Node> set = new TreeSet<>(); TreeSet<Node> set2 = new TreeSet<>(); set.add(n1); set.add(n2); set2.add(n3); set2.add(n4); Group g1 = new Group(new Configuration(), n1, n2); Group g2 = new Group(new Configuration(), n3, n4); Assert.assertTrue(n1.equals(n3)); Assert.assertTrue(g1.hashCode() != g2.hashCode()); Assert.assertTrue(!g1.equals(g2)); }
Example 21
Source Project: clust4j Source File: MeanShift.java License: Apache License 2.0 | 5 votes |
SerialCenterIntensity(RadiusNeighbors nbrs) { LogTimer timer; // Now get single seed members MeanShiftSeed sd; this.computedSeeds = new TreeSet<>(); final double[][] X = data.getData(); int idx = 0; for(double[] seed: seeds) { idx++; timer = new LogTimer(); sd = singleSeed(seed, nbrs, X, maxIter); if(null == sd) continue; computedSeeds.add(sd); itrz = FastMath.max(itrz, sd.iterations); // If it actually converged, add the summary summaries.add(new SummaryLite( "Kernel "+(idx - 1), sd.iterations, timer.formatTime(), timer.wallTime() )); } }
Example 22
Source Project: browserprint Source File: FontCSSServlet.java License: MIT License | 5 votes |
/** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = ((HttpServletRequest)request).getSession(true); synchronized (session) { session.setMaxInactiveInterval(300); String url = ((HttpServletRequest)request).getRequestURL().toString(); String font = url.substring(url.lastIndexOf("/") + 1).replace('_', ' '); int substr_end= font.indexOf(";jsessionid", 0); if(substr_end > -1){ //Trim off jsessionid if present font = font.substring(0, substr_end); } if(expectedFonts.contains(font)){ //System.out.println("Requested: " + font); TreeSet<String> fontsNotRequested = (TreeSet<String>)session.getAttribute("fontsNotRequested"); if(fontsNotRequested == null){ fontsNotRequested = new TreeSet<String>(expectedFonts); session.setAttribute("fontsNotRequested", fontsNotRequested); } fontsNotRequested.remove(font); } response.sendError(404); } }
Example 23
Source Project: pcgen Source File: FilteredReference.java License: GNU Lesser General Public License v2.1 | 5 votes |
@Override public String getLSTformat(boolean useAny) { Set<PrimitiveCollection<? super T>> sortSet = new TreeSet<>(PrimitiveUtilities.COLLECTION_SORTER); sortSet.addAll(filterSet); return "ALL|!" + PrimitiveUtilities.joinLstFormat(sortSet, "|!", useAny); }
Example 24
Source Project: biojava Source File: RemoteDomainProvider.java License: GNU Lesser General Public License v2.1 | 5 votes |
/** Requests the domain assignments for the current PDB IDs from the PDB. * @throws IOException if the server cannot be reached * */ private void loadRepresentativeDomainAssignments() throws IOException { AssignmentXMLSerializer results = null; try { URL u = new URL(url + "getRepresentativeDomains"); logger.info("Fetching {}",u); InputStream response = URLConnectionTools.getInputStream(u); String xml = JFatCatClient.convertStreamToString(response); results = AssignmentXMLSerializer.fromXML(xml); Map<String,String> data = results.getAssignments(); logger.info("got {} ranges from server.",data.size()); for (String key: data.keySet()){ String range = data.get(key); // work around list in results; String[] spl = range.split(","); SortedSet<String> value = new TreeSet<String>(); for (String s : spl){ value.add(s); } serializedCache.put(key, value); } } catch (MalformedURLException e){ logger.error("Malformed Domain server: "+url,e); throw new IllegalArgumentException("Invalid Server: "+url, e); } }
Example 25
Source Project: Bats Source File: SqlAbstractParserImpl.java License: Apache License 2.0 | 5 votes |
/** * Creates a MetadataImpl. * * @param sqlParser Parser */ public MetadataImpl(SqlAbstractParserImpl sqlParser) { initList(sqlParser, reservedFunctionNames, "ReservedFunctionName"); initList(sqlParser, contextVariableNames, "ContextVariable"); initList(sqlParser, nonReservedKeyWordSet, "NonReservedKeyWord"); tokenList = ImmutableList.copyOf(tokenSet); sql92ReservedWords = constructSql92ReservedWordList(); Set<String> reservedWordSet = new TreeSet<>(); reservedWordSet.addAll(tokenSet); reservedWordSet.removeAll(nonReservedKeyWordSet); reservedWords.addAll(reservedWordSet); }
Example 26
Source Project: eagle Source File: TimeSeriesPostFlatAggregateSort.java License: Apache License 2.0 | 5 votes |
private static SortedSet<Map.Entry<List<String>, List<Double>>> sortByValue( Map<List<String>, List<Double>> mapForSort, List<SortOption> sortOptions) { SortedSet<Map.Entry<List<String>, List<Double>>> sortedEntries = new TreeSet<Map.Entry<List<String>, List<Double>>>( new MapEntryComparator(sortOptions)); sortedEntries.addAll(mapForSort.entrySet()); return sortedEntries; }
Example 27
Source Project: cpsolver Source File: ExamRoomSplit.java License: GNU Lesser General Public License v3.0 | 5 votes |
/** * generate report * @param assignment current assignment * @return resultant report */ public CSVFile report(Assignment<Exam, ExamPlacement> assignment) { CSVFile csv = new CSVFile(); csv.setHeader(new CSVField[] { new CSVField("Exam"), new CSVField("Enrl"), new CSVField("Period"), new CSVField("Date"), new CSVField("Time"), new CSVField("Room 1"), new CSVField("Cap 1"), new CSVField("Room 2"), new CSVField("Cap 2"), new CSVField("Room 3"), new CSVField("Cap 3"), new CSVField("Room 4"), new CSVField("Cap 4") }); for (Exam exam : iModel.variables()) { ExamPlacement placement = assignment.getValue(exam); if (placement == null || placement.getRoomPlacements().size() <= 1) continue; List<CSVField> fields = new ArrayList<CSVField>(); fields.add(new CSVField(exam.getName())); fields.add(new CSVField(exam.getStudents().size())); fields.add(new CSVField(placement.getPeriod().getIndex() + 1)); fields.add(new CSVField(placement.getPeriod().getDayStr())); fields.add(new CSVField(placement.getPeriod().getTimeStr())); TreeSet<ExamRoomPlacement> rooms = new TreeSet<ExamRoomPlacement>(new ExamRoomComparator(exam, false)); rooms.addAll(placement.getRoomPlacements()); for (ExamRoomPlacement room : rooms) { fields.add(new CSVField(room.getName())); fields.add(new CSVField(room.getSize(exam.hasAltSeating()))); } csv.addLine(fields); } return csv; }
Example 28
Source Project: unitime Source File: InstructorExamReport.java License: Apache License 2.0 | 5 votes |
public void printReport(ExamInstructorInfo instructor) throws DocumentException { TreeSet<ExamAssignmentInfo> exams = new TreeSet(); for (ExamAssignmentInfo exam:getExams()) { if (exam.getPeriod()==null) continue; if (exam.getInstructors().contains(instructor)); } if (exams.isEmpty()) return; printHeader(); printReport(instructor, exams); lastPage(); }
Example 29
Source Project: kylin Source File: TableACL.java License: Apache License 2.0 | 5 votes |
public Set<String> getTableBlackList(String username, Set<String> groups) { Set<String> tableBlackList = new TreeSet<>(String.CASE_INSENSITIVE_ORDER); tableBlackList.addAll(userTableBlackList.getTableBlackList(username)); //if user is in group, add group's black list for (String group : groups) { tableBlackList.addAll(groupTableBlackList.getTableBlackList(group)); } return tableBlackList; }
Example 30
Source Project: sakai Source File: FCKConnectorServlet.java License: Educational Community License v2.0 | 5 votes |
private void getTestsOnly(String dir, Node root, Document doc, String type, ConnectorHelper ch) { List myTests = null; String siteId = null; String[] f = dir.split("/"); siteId = f[2]; SortedSet<Element> sortedItems = new TreeSet<Element>(new SortElementsForDisplay()); Element assessments=doc.createElement("Assessments"); root.appendChild(assessments); myTests = ch.getPublishedAssements(siteId); Iterator assessmentIterator = myTests.iterator(); while(assessmentIterator.hasNext()){ String[] thisAssessmentReference = (String[]) assessmentIterator.next(); Element element=doc.createElement("Assessment"); element.setAttribute("name",thisAssessmentReference[0]); element.setAttribute("url",serverUrlPrefix + thisAssessmentReference[1]); element.setAttribute("size", "0"); sortedItems.add(element); } for (Element item: sortedItems) { assessments.appendChild(item); } }