List of usage examples for java.util TreeSet TreeSet
public TreeSet()
From source file:net.sf.jasperreports.engine.export.tabulator.DimensionEntries.java
public DimensionEntries(DimensionControl<T> control) { this.control = control; this.entries = new TreeSet<T>(); // TODO lucianc no index for column T univEntry = control.createEntry(DimensionEntry.MINUS_INF, DimensionEntry.PLUS_INF); this.entries.add(univEntry); }
From source file:com.qwarz.graph.model.GraphNode.java
private Set<String> getEdgeSet(String type) { if (type == null || type.isEmpty()) return null; type = type.intern();/*from w ww.ja v a 2 s. c om*/ if (edges == null) edges = new LinkedHashMap<String, Set<String>>(); Set<String> nodeIdSet = edges.get(type); if (nodeIdSet != null) return nodeIdSet; nodeIdSet = new TreeSet<String>(); edges.put(type, nodeIdSet); return nodeIdSet; }
From source file:de.textmining.nerdle.database.MVSingleton.java
private void config(String path) throws ConfigurationException { EtmPoint point = etmMonitor.createPoint("MVSingleton:config"); PropertiesConfiguration propertiesConfiguration = new PropertiesConfiguration(path); Set<String> mvIds = new TreeSet<>(); Iterator keys = propertiesConfiguration.getKeys("mv"); while (keys.hasNext()) { String key = (String) keys.next(); String[] split = key.split("\\."); mvIds.add(split[0] + "." + split[1]); }// ww w .j a v a 2 s . com connections = new HashMap<>(); for (String dbId : mvIds) { String mvName = propertiesConfiguration.getString(dbId + "." + "name"); String mvPath = propertiesConfiguration.getString(dbId + "." + "path"); MVStore s = new MVStore.Builder().fileName(mvPath).readOnly().open(); connections.put(mvName, new MVConnection(s)); } point.collect(); }
From source file:com.amalto.core.storage.hibernate.StorageTableResolver.java
public StorageTableResolver(Set<FieldMetadata> indexedFields, int maxLength) { this.indexedFields = indexedFields; this.maxLength = maxLength; // Loads reserved SQL keywords. synchronized (MappingGenerator.class) { if (reservedKeyWords == null) { reservedKeyWords = new TreeSet<String>(); InputStream reservedKeyWordsList = this.getClass().getResourceAsStream(RESERVED_SQL_KEYWORDS); try { if (reservedKeyWordsList == null) { throw new IllegalStateException("File '" + RESERVED_SQL_KEYWORDS + "' was not found."); }/*from w ww.ja v a 2 s.c om*/ List list = IOUtils.readLines(reservedKeyWordsList); for (Object o : list) { reservedKeyWords.add(String.valueOf(o)); } if (LOGGER.isDebugEnabled()) { LOGGER.debug("Loaded " + reservedKeyWords.size() + " reserved SQL key words."); } } catch (Exception e) { throw new RuntimeException(e); } finally { try { if (reservedKeyWordsList != null) { reservedKeyWordsList.close(); } } catch (IOException e) { LOGGER.error("Error occurred when closing reserved keyword list.", e); } } } } }
From source file:com.linkedin.pinot.operator.OrOperatorTest.java
@Test public void testIntersectionForTwoLists() { int[] list1 = new int[] { 2, 3, 10, 15, 16, 28 }; int[] list2 = new int[] { 3, 6, 8, 20, 28 }; ;// w ww .j av a2s .com List<Operator> operators = new ArrayList<Operator>(); operators.add(makeFilterOperator(list1)); operators.add(makeFilterOperator(list2)); final OrOperator orOperator = new OrOperator(operators); orOperator.open(); Block block; TreeSet<Integer> set = new TreeSet<Integer>(); set.addAll(Lists.newArrayList(ArrayUtils.toObject(list1))); set.addAll(Lists.newArrayList(ArrayUtils.toObject(list2))); Iterator<Integer> expectedIterator = set.iterator(); while ((block = orOperator.nextBlock()) != null) { final BlockDocIdSet blockDocIdSet = block.getBlockDocIdSet(); final BlockDocIdIterator iterator = blockDocIdSet.iterator(); int docId; while ((docId = iterator.next()) != Constants.EOF) { Assert.assertEquals(expectedIterator.next().intValue(), docId); } } orOperator.close(); }
From source file:de.bund.bva.pliscommon.serviceapi.core.serviceimpl.MappingHelper.java
/** * Bildet ein Objekt mithilfe von Dozer auf einen gewnschten Zieltyp ab. Im Gegensatz zu * {@link Mapper#map(Object, Class)} knnen als Zieltyp auch generische Collections, String und primitive * Typen bergeben werden./*from w w w . j av a2s .c o m*/ * * @param mapper * der Dozer-Mapper * @param source * das zu mappende Objekt * @param destinationType * der Zieltyp * @return das gemappte Objekt */ @SuppressWarnings("unchecked") public static Object map(Mapper mapper, Object source, Type destinationType) { if (source == null) { return null; } if (destinationType instanceof ParameterizedType) { ParameterizedType parDestinationType = (ParameterizedType) destinationType; Class<?> rawClass = (Class<?>) parDestinationType.getRawType(); if (List.class.isAssignableFrom(rawClass)) { return mapCollection(mapper, source, parDestinationType, new ArrayList<Object>()); } else if (SortedSet.class.isAssignableFrom(rawClass)) { return mapCollection(mapper, source, parDestinationType, new TreeSet<Object>()); } else if (Set.class.isAssignableFrom(rawClass)) { return mapCollection(mapper, source, parDestinationType, new HashSet<Object>()); } else if (SortedMap.class.isAssignableFrom(rawClass)) { return mapMap(mapper, source, parDestinationType, new TreeMap<Object, Object>()); } else if (Map.class.isAssignableFrom(rawClass)) { return mapMap(mapper, source, parDestinationType, new HashMap<Object, Object>()); } destinationType = parDestinationType.getRawType(); } if (destinationType instanceof GenericArrayType) { if (!source.getClass().isArray()) { throw new IllegalArgumentException("Ein Mapping auf den Array-Typ " + destinationType + " wird nicht untersttzt, wenn das Quellobjekt kein Array ist. Typ des Quellobjekts: " + source.getClass()); } // wir werden im Array Element pro Element mappen Type elementType = ((GenericArrayType) destinationType).getGenericComponentType(); Object[] sourceArray = (Object[]) source; Object[] destinationArray = (Object[]) Array.newInstance((Class<?>) elementType, sourceArray.length); for (int i = 0; i < sourceArray.length; i++) { destinationArray[i] = MappingHelper.map(mapper, sourceArray[i], elementType); } return destinationArray; } else if ((destinationType instanceof Class<?>) && ((Class<?>) destinationType).isArray()) { if (!source.getClass().isArray()) { throw new IllegalArgumentException("Ein Mapping auf den Array-Typ " + destinationType + " wird nicht untersttzt, wenn das Quellobjekt kein Array ist. Typ des Quellobjekts: " + source.getClass()); } Class<?> destinationTypeClass = (Class<?>) destinationType; // wir werden im Array Element pro Element mappen Type elementType = destinationTypeClass.getComponentType(); Object[] sourceArray = (Object[]) source; Object[] destinationArray = (Object[]) Array.newInstance((Class<?>) elementType, sourceArray.length); for (int i = 0; i < sourceArray.length; i++) { destinationArray[i] = MappingHelper.map(mapper, sourceArray[i], elementType); } return destinationArray; } if (!(destinationType instanceof Class<?>)) { throw new IllegalArgumentException( "Ein Mapping auf Typ " + destinationType + " wird nicht untersttzt"); } Class<?> destinationClass = (Class<?>) destinationType; if (ClassUtils.isPrimitiveOrWrapper(destinationClass) || MAPPING_BLACKLIST.contains(destinationClass)) { return source; } else if (destinationClass.isEnum()) { // wir mssen auf dieser Ebene Enums leider manuell mappen if (!(source instanceof Enum)) { throw new IllegalArgumentException("Ein Mapping auf ein Enum " + destinationClass + " wird nicht untersttzt, da das Quellobjekt kein Enumobjekt ist (Quellobjektstyp: " + source.getClass().toString() + ")."); } return Enum.valueOf((Class<Enum>) destinationClass, ((Enum<?>) source).name()); } else { return mapper.map(source, destinationClass); } }
From source file:com.alibaba.dubbo.governance.web.governance.module.screen.Addresses.java
public void index(Map<String, Object> context) { String application = (String) context.get("application"); String service = (String) context.get("service"); List<String> providerAddresses = null; List<String> consumerAddresses = null; if (application != null && application.length() > 0) { providerAddresses = providerService.findAddressesByApplication(application); consumerAddresses = consumerService.findAddressesByApplication(application); } else if (service != null && service.length() > 0) { providerAddresses = providerService.findAddressesByService(service); consumerAddresses = consumerService.findAddressesByService(service); } else {//from ww w . j av a 2 s . c o m providerAddresses = providerService.findAddresses(); consumerAddresses = consumerService.findAddresses(); } Set<String> addresses = new TreeSet<String>(); if (providerAddresses != null) { addresses.addAll(providerAddresses); } if (consumerAddresses != null) { addresses.addAll(consumerAddresses); } context.put("providerAddresses", providerAddresses); context.put("consumerAddresses", consumerAddresses); context.put("addresses", addresses); if (context.get("service") == null && context.get("application") == null && context.get("address") == null) { context.put("address", "*"); } String keyword = (String) context.get("keyword"); if (StringUtils.isNotEmpty(keyword)) { if ("*".equals(keyword)) return; keyword = keyword.toLowerCase(); Set<String> newList = new HashSet<String>(); Set<String> newProviders = new HashSet<String>(); Set<String> newConsumers = new HashSet<String>(); for (String o : addresses) { if (o.toLowerCase().indexOf(keyword) != -1) { newList.add(o); } } for (String o : providerAddresses) { if (o.toLowerCase().indexOf(keyword) != -1) { newProviders.add(o); } } for (String o : consumerAddresses) { if (o.toLowerCase().indexOf(keyword) != -1) { newConsumers.add(o); } } context.put("addresses", newList); context.put("providerAddresses", newProviders); context.put("consumerAddresses", newConsumers); } }
From source file:de.shadowhunt.sonar.plugins.ignorecode.model.CoveragePatternTest.java
@Test public void testAddLines() throws Exception { final SortedSet<Integer> lines = new TreeSet<>(); CoveragePattern.addLines(lines, 2, 2); CoveragePattern.addLines(lines, 4, 6); final CoveragePattern pattern = new CoveragePattern("resourcePattern", lines); final SortedSet<Integer> full = pattern.getLines(); Assert.assertNotNull("SortedSet must not be null", full); Assert.assertEquals("SortedSet must contain the exact number of entries", 4, full.size()); Assert.assertTrue("SortedSet must contain line 2", full.contains(2)); Assert.assertTrue("SortedSet must contain line 4", full.contains(4)); Assert.assertTrue("SortedSet must contain line 5", full.contains(5)); Assert.assertTrue("SortedSet must contain line 6", full.contains(6)); }
From source file:de.textmining.nerdle.database.DBSingleton.java
private void config(String path) throws ConfigurationException { EtmPoint point = etmMonitor.createPoint("DBSingleton:config"); PropertiesConfiguration propertiesConfiguration = new PropertiesConfiguration(path); String jdbc = propertiesConfiguration.getString("jdbc"); Set<String> dbIds = new TreeSet<>(); Iterator keys = propertiesConfiguration.getKeys("db"); while (keys.hasNext()) { String key = (String) keys.next(); String[] split = key.split("\\."); dbIds.add(split[0] + "." + split[1]); }/*from w w w . ja v a 2 s .c om*/ connections = new HashMap<>(); for (String dbId : dbIds) { String dbName = propertiesConfiguration.getString(dbId + "." + "name"); String dbPath = propertiesConfiguration.getString(dbId + "." + "path"); connections.put(dbName, new DBConnection(jdbc + dbPath + ";ACCESS_MODE_DATA=r")); } point.collect(); }
From source file:de.tudarmstadt.ukp.dkpro.core.ixa.internal.IxaLemmatizerTagsetDescriptionProvider.java
@Override public Set<String> listTags(String aLayer, String aTagsetName) { try {//from w w w . ja v a 2s. co m AbstractModel innerModel = (AbstractModel) FieldUtils.readField(model, "model", true); HashMap<String, Integer> pmap = (HashMap<String, Integer>) FieldUtils.readField(innerModel, "pmap", true); Set<String> tagSet = new TreeSet<String>(); String prefix = feature + separator; for (Object key : pmap.keySet()) { if (key instanceof String && ((String) key).startsWith(prefix)) { tagSet.add(StringUtils.substringAfter(((String) key), separator)); } } return tagSet; } catch (IllegalAccessException e) { throw new IllegalStateException(e); } }