List of usage examples for java.util Collections unmodifiableSortedMap
public static <K, V> SortedMap<K, V> unmodifiableSortedMap(SortedMap<K, ? extends V> m)
From source file:net.pms.dlna.protocolinfo.ProtocolInfo.java
/** * Creates a new instance using the provided information. * * @param protocol the {@link Protocol} for the new instance. Use * {@code null} for "any".// w w w . ja v a 2s .co m * @param network the network for the new instance. Use {@code null} or * blank for "any". * @param contentFormat the content format for the new instance. Use * {@code null} or blank for "any". * @param additionalInfo the additional information for the new instance. */ public ProtocolInfo(Protocol protocol, String network, String contentFormat, String additionalInfo) { this.protocol = protocol == null ? Protocol.ALL : protocol; this.network = isBlank(network) ? WILDCARD : network; this.mimeType = createMimeType(contentFormat); this.additionalInfo = isBlank(additionalInfo) ? WILDCARD : additionalInfo; this.attributes = Collections.unmodifiableSortedMap(parseAdditionalInfo()); this.attributesString = generateAttributesString(); this.stringValue = generateStringValue(); }
From source file:net.pms.dlna.protocolinfo.ProtocolInfo.java
/** * Creates a new instance using the provided information. * * @param protocol the {@link Protocol} for the new instance. Use * {@code null} for "any"./*from w ww.j av a 2s . co m*/ * @param network the network for the new instance. Use {@code null} or * blank for "any". * @param mimeType the mime-type for the new instance. Use {@code null} or * {@link MimeType#ANYANY} for "any". * @param additionalInfo the additional information for the new instance. */ public ProtocolInfo(Protocol protocol, String network, MimeType mimeType, String additionalInfo) { this.protocol = protocol == null ? Protocol.ALL : protocol; this.network = isBlank(network) ? WILDCARD : network; this.mimeType = mimeType == null ? MimeType.ANYANY : mimeType; this.additionalInfo = isBlank(additionalInfo) ? WILDCARD : additionalInfo; this.attributes = Collections.unmodifiableSortedMap(parseAdditionalInfo()); this.attributesString = generateAttributesString(); this.stringValue = generateStringValue(); }
From source file:org.opennms.ng.services.databaseschemaconfig.JdbcFilterDao.java
/** * {@inheritDoc}/*from www . j a v a 2 s . c o m*/ * * This method returns a map of all nodeids and nodelabels that match * the rule that is passed in, sorted by nodeid. * @exception org.opennms.ng.services.databaseschemaconfig.FilterParseException * if a rule is syntactically incorrect or failed in * executing the SQL statement */ @Override public SortedMap<Integer, String> getNodeMap(final String rule) throws FilterParseException { final SortedMap<Integer, String> resultMap = new TreeMap<Integer, String>(); String sqlString; LOG.debug("Filter.getNodeMap({})", rule); // get the database connection Connection conn = null; final DBUtils d = new DBUtils(getClass()); try { conn = getDataSource().getConnection(); d.watch(conn); // parse the rule and get the sql select statement sqlString = getNodeMappingStatement(rule); LOG.debug("Filter.getNodeMap({}): SQL statement: {}", rule, sqlString); // execute query final Statement stmt = conn.createStatement(); d.watch(stmt); final ResultSet rset = stmt.executeQuery(sqlString); d.watch(rset); if (rset != null) { // Iterate through the result and build the map while (rset.next()) { resultMap.put(Integer.valueOf(rset.getInt(1)), rset.getString(2)); } } } catch (final FilterParseException e) { LOG.warn("Filter Parse Exception occurred getting node map.", e); throw new FilterParseException( "Filter Parse Exception occurred getting node map: " + e.getLocalizedMessage(), e); } catch (final SQLException e) { LOG.warn("SQL Exception occurred getting node map.", e); throw new FilterParseException("SQL Exception occurred getting node map: " + e.getLocalizedMessage(), e); } catch (final Throwable e) { LOG.error("Exception getting database connection.", e); throw new UndeclaredThrowableException(e); } finally { d.cleanUp(); } return Collections.unmodifiableSortedMap(resultMap); }
From source file:org.apache.drill.optiq.EnumerableDrill.java
private static SortedMap<String, Object> map(ObjectNode node) { // TreeMap makes the results deterministic. final TreeMap<String, Object> map = new TreeMap<>(); final Iterator<Map.Entry<String, JsonNode>> fields = node.fields(); while (fields.hasNext()) { Map.Entry<String, JsonNode> next = fields.next(); map.put(next.getKey(), wrapper(next.getValue())); }/*from w ww .j a v a 2s.c o m*/ return Collections.unmodifiableSortedMap(map); }
From source file:net.pms.dlna.protocolinfo.ProtocolInfo.java
/** * Creates a new instance using the provided information. * * @param protocol the {@link Protocol} for the new instance. Use * {@code null} for "any".//w w w. ja v a2s . c o m * @param network the network for the new instance. Use {@code null} or * blank for "any". * @param contentFormat the content format for the new instance. Use * {@code null} or blank for "any". * @param attributes a {@link Map} of {@link ProtocolInfoAttributeName} and * {@link ProtocolInfoAttribute} pairs for the new instance. */ public ProtocolInfo(Protocol protocol, String network, String contentFormat, Map<ProtocolInfoAttributeName, ProtocolInfoAttribute> attributes) { this.protocol = protocol == null ? Protocol.ALL : protocol; this.network = isBlank(network) ? WILDCARD : network; this.mimeType = createMimeType(contentFormat); TreeMap<ProtocolInfoAttributeName, ProtocolInfoAttribute> tmpAttributes = createEmptyAttributesMap(); tmpAttributes.putAll(attributes); this.attributes = Collections.unmodifiableSortedMap(tmpAttributes); this.attributesString = generateAttributesString(); this.additionalInfo = this.attributesString; this.stringValue = generateStringValue(); }
From source file:net.pms.dlna.protocolinfo.ProtocolInfo.java
/** * Creates a new instance using the provided information. * * @param protocol the {@link Protocol} for the new instance. Use * {@code null} for "any"./* w ww. j a va2s. c om*/ * @param network the network for the new instance. Use {@code null} or * blank for "any". * @param mimeType the mime-type for the new instance. Use {@code null} or * {@link MimeType#ANYANY} for "any". * @param attributes a {@link Map} of {@link ProtocolInfoAttributeName} and * {@link ProtocolInfoAttribute} pairs for the new instance. */ public ProtocolInfo(Protocol protocol, String network, MimeType mimeType, Map<ProtocolInfoAttributeName, ProtocolInfoAttribute> attributes) { this.protocol = protocol == null ? Protocol.ALL : protocol; this.network = isBlank(network) ? WILDCARD : network; this.mimeType = mimeType == null ? MimeType.ANYANY : mimeType; TreeMap<ProtocolInfoAttributeName, ProtocolInfoAttribute> tmpAttributes = createEmptyAttributesMap(); tmpAttributes.putAll(attributes); this.attributes = Collections.unmodifiableSortedMap(tmpAttributes); this.attributesString = generateAttributesString(); this.additionalInfo = this.attributesString; this.stringValue = generateStringValue(); }
From source file:com.michelin.cio.hudson.plugins.rolestrategy.RoleMap.java
/** * Get an unmodifiable sorted map containing {@link Role}s and their assigned sids. * @return An unmodifiable sorted map containing the {@link Role}s and their associated sids *///from w w w . ja v a 2s . c o m public SortedMap<Role, Set<String>> getGrantedRoles() { return Collections.unmodifiableSortedMap(this.grantedRoles); }
From source file:net.pms.dlna.protocolinfo.ProtocolInfo.java
/** * Creates a new instance using the provided information. * * @param protocol the {@link Protocol} for the new instance. Use * {@code null} for "any"./*from ww w. j a v a 2 s.c o m*/ * @param network the network for the new instance. Use {@code null} or * blank for "any". * @param contentFormat the content format for the new instance. Use * {@code null} or blank for "any". * @param attributes an {@link EnumMap} with {@link DLNAAttribute}s the new * instance. */ public ProtocolInfo(Protocol protocol, String network, String contentFormat, EnumMap<DLNAAttribute.Type, DLNAAttribute<?>> attributes) { this.protocol = protocol == null ? Protocol.ALL : protocol; this.network = isBlank(network) ? WILDCARD : network; this.mimeType = createMimeType(contentFormat); this.attributes = Collections.unmodifiableSortedMap(dlnaAttributesToAttributes(attributes)); this.attributesString = generateAttributesString(); this.additionalInfo = this.attributesString; this.stringValue = generateStringValue(); }
From source file:jenkins.model.lazy.AbstractLazyLoadRunMap.java
/** * Returns a read-only view of records that has already been loaded. *//*from w w w. ja va 2 s .c o m*/ public SortedMap<Integer, R> getLoadedBuilds() { return Collections.unmodifiableSortedMap(new BuildReferenceMapAdapter<R>(this, index.byNumber)); }
From source file:jenkins.model.lazy.AbstractLazyLoadRunMap.java
/** * @param fromKey/* w w w. ja v a 2s. co m*/ * Biggest build number to be in the returned set. * @param toKey * Smallest build number-1 to be in the returned set (-1 because this is exclusive) */ public SortedMap<Integer, R> subMap(Integer fromKey, Integer toKey) { // TODO: if this method can produce a lazy map, that'd be wonderful // because due to the lack of floor/ceil/higher/lower kind of methods // to look up keys in SortedMap, various places of Jenkins rely on // subMap+firstKey/lastKey combo. R start = search(fromKey, DESC); if (start == null) return EMPTY_SORTED_MAP; R end = search(toKey, ASC); if (end == null) return EMPTY_SORTED_MAP; for (R i = start; i != end;) { i = search(getNumberOf(i) - 1, DESC); assert i != null; } return Collections.unmodifiableSortedMap( new BuildReferenceMapAdapter<R>(this, index.byNumber.subMap(fromKey, toKey))); }