List of usage examples for java.util TreeSet TreeSet
public TreeSet()
From source file:SortedListModel.java
public SortedListModel() { model = new TreeSet<Object>(); }
From source file:TreeHeap.java
/** * Creates a new tree heap of the specified size. * @param size The size of the new tree heap. */ public TreeHeap(int size) { tree = new TreeSet(); }
From source file:com.github.javarch.jsf.tags.security.SpringSecurityELLibrary.java
private static Set<String> parseAuthorities(String grantedRoles) { Set<String> parsedAuthorities = new TreeSet<String>(); if (grantedRoles == null || "".equals(grantedRoles.trim())) { return parsedAuthorities; }// w w w . j a v a 2s .c o m String[] parsedAuthoritiesArr; if (grantedRoles.contains(",")) { parsedAuthoritiesArr = grantedRoles.split(","); } else { parsedAuthoritiesArr = new String[] { grantedRoles }; } // adding authorities to set (could pssible be done better!) for (String auth : parsedAuthoritiesArr) parsedAuthorities.add(auth.trim()); return parsedAuthorities; }
From source file:storybook.ui.chart.jfreechart.ChartUtil.java
@SuppressWarnings("unchecked") public static TreeSet<Date> correctDates(TreeSet<Date> paramTreeSet) { TreeSet localTreeSet = new TreeSet(); Date localDate1 = (Date) paramTreeSet.first(); Calendar localCalendar1 = Calendar.getInstance(); localCalendar1.setTime(localDate1);/* w ww. j av a 2s . c o m*/ int i = localCalendar1.get(Calendar.YEAR); if (i > 1900) { return paramTreeSet; } for (Date localDate2 : paramTreeSet) { Calendar localCalendar2 = Calendar.getInstance(); localCalendar2.setTime(localDate2); int j = localCalendar2.get(Calendar.YEAR); localDate2 = DateUtils.addYears(localDate2, 1900 - j); localTreeSet.add(localDate2); } return localTreeSet; }
From source file:net.sf.sripathi.ws.mock.util.FileUtil.java
public static void createFilesAndFolder(String root, ZipFile zip) { @SuppressWarnings("unchecked") Enumeration<ZipEntry> entries = (Enumeration<ZipEntry>) zip.entries(); Set<String> files = new TreeSet<String>(); while (entries.hasMoreElements()) { ZipEntry entry = entries.nextElement(); if (entry.getName().toLowerCase().endsWith(".wsdl") || entry.getName().toLowerCase().endsWith(".xsd")) files.add(entry.getName());//from www. ja v a2s . c o m } File rootFolder = new File(root); if (!rootFolder.exists()) { throw new MockException("Unable to create file - " + root); } for (String fileStr : files) { String folder = root; String[] split = fileStr.split("/"); if (split.length > 1) { for (int i = 0; i < split.length - 1; i++) { folder = folder + "/" + split[i]; File f = new File(folder); if (!f.exists()) { f.mkdir(); } } } File file = new File(folder + "/" + split[split.length - 1]); FileOutputStream fos = null; InputStream zipStream = null; try { fos = new FileOutputStream(file); zipStream = zip.getInputStream(zip.getEntry(fileStr)); fos.write(IOUtils.toByteArray(zipStream)); } catch (Exception e) { throw new MockException("Unable to create file - " + fileStr); } finally { try { fos.close(); } catch (Exception e) { } try { zipStream.close(); } catch (Exception e) { } } } }
From source file:com.redhat.rhn.testing.ServletTestUtils.java
private static Set createQueryStringParameterSet(String queryString) { Set parameterSet = new TreeSet(); CollectionUtils.addAll(parameterSet, queryString.split("&")); return parameterSet; }
From source file:com.juhnowski.sanskrvar.Main.java
public Main() { this.sl = new TreeSet<>(); searchList = Collections.synchronizedSortedSet(new TreeSet(sl)); this.ts = new TreeSet<>(); entrySet = Collections.synchronizedSortedSet(new TreeSet(ts)); }
From source file:annis.WekaHelper.java
public static String exportAsArff(List<AnnotatedMatch> annotatedMatches) { StringBuilder sb = new StringBuilder(); // header: relation name (unused) sb.append("@relation name\n"); sb.append("\n"); // figure out what annotations are used at each match position SortedMap<Integer, SortedSet<String>> columnsByNodePos = new TreeMap<Integer, SortedSet<String>>(); for (int i = 0; i < annotatedMatches.size(); ++i) { AnnotatedMatch match = annotatedMatches.get(i); for (int j = 0; j < match.size(); ++j) { AnnotatedSpan span = match.get(j); if (columnsByNodePos.get(j) == null) { columnsByNodePos.put(j, new TreeSet<String>()); }//from w ww .j a v a2 s .c o m for (Annotation annotation : span.getAnnotations()) { columnsByNodePos.get(j).add("anno_" + annotation.getQualifiedName()); } for (Annotation meta : span.getMetadata()) { columnsByNodePos.get(j).add("meta_" + meta.getQualifiedName()); } } } // print column names and data types int count = columnsByNodePos.keySet().size(); for (int j = 0; j < count; ++j) { sb.append("@attribute ").append(fullColumnName(j + 1, "id")).append(" string\n"); sb.append("@attribute ").append(fullColumnName(j + 1, "span")).append(" string\n"); SortedSet<String> annotationNames = columnsByNodePos.get(j); for (String name : annotationNames) { sb.append("@attribute ").append(fullColumnName(j + 1, name)).append(" string\n"); } } sb.append("\n@data\n\n"); // print values for (AnnotatedMatch match : annotatedMatches) { List<String> line = new ArrayList<String>(); int k = 0; for (; k < match.size(); ++k) { AnnotatedSpan span = match.get(k); Map<String, String> valueByName = new HashMap<String, String>(); if (span != null) { if (span.getAnnotations() != null) { for (Annotation annotation : span.getAnnotations()) { valueByName.put("anno_" + annotation.getQualifiedName(), annotation.getValue()); } } if (span.getMetadata() != null) { for (Annotation meta : span.getMetadata()) { valueByName.put("meta_" + meta.getQualifiedName(), meta.getValue()); } } line.add("'" + span.getId() + "'"); line.add("'" + span.getCoveredText().replace("'", "\\'") + "'"); } for (String name : columnsByNodePos.get(k)) { if (valueByName.containsKey(name)) { line.add("'" + valueByName.get(name).replace("'", "\\'") + "'"); } else { line.add("'NULL'"); } } } for (int l = k; l < count; ++l) { line.add("'NULL'"); for (int m = 0; m <= columnsByNodePos.get(l).size(); ++m) { line.add("'NULL'"); } } sb.append(StringUtils.join(line, ",")); sb.append("\n"); } return sb.toString(); }
From source file:uk.ac.ebi.eva.test.utils.JobTestUtils.java
/** * reads the file and sorts it in memory to return the first ordered line. Don't use for big files! * @param file to be sorted/*ww w.ja v a 2 s . c om*/ * @return String, the first orderec line * @throws IOException */ public static String readFirstLine(File file) throws IOException { Set<String> lines = new TreeSet<>(); try (BufferedReader reader = new BufferedReader(new FileReader(file))) { String line = reader.readLine(); while (line != null) { lines.add(line); line = reader.readLine(); } } return lines.iterator().next(); }
From source file:de.jcup.egradle.core.text.JavaImportFinder.java
public Set<String> findImportedPackages(String text) { Set<String> set = new TreeSet<>(); if (text == null) { return set; }// w w w .j av a 2 s.c o m Matcher m = PATTERN.matcher(text); while (m.find()) { String fullImportName = m.group(1); String packageName = StringUtils.substringBeforeLast(fullImportName, "."); set.add(packageName); } return set; }