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:Main.java
public static void main(String[] s) { // create sorted map SortedMap<String, String> map = new TreeMap<String, String>(); // populate the set map.put("1", "New"); map.put("2", "to"); map.put("3", "java2s.com"); System.out.println("Initial sorted map value: " + map); // create unmodifiable sorted map Map<String, String> unmodsortmap = Collections.unmodifiableSortedMap(map); // try to modify the sorted map unmodsortmap.put("4", "Modify"); }
From source file:Main.java
public static Map narrowUnmodifiableMap(Map m) { if (m instanceof SortedMap) return Collections.unmodifiableSortedMap((SortedMap) m); else//from www. j a va2 s . c o m return Collections.unmodifiableMap(m); }
From source file:net.krotscheck.stk.stream.Schema.java
/** * Please use the builder instead.//from w ww .ja va 2 s . com * * @param schema The schema map to wrap. */ private Schema(final Map<String, Type> schema) { this.internalSchema = Collections.unmodifiableSortedMap(new TreeMap<>(schema)); }
From source file:ca.tnt.ldaputils.impl.LdapOrganization.java
public SortedMap<String, ? extends ILdapGroup> getBusinessCategories() { logger.debug("categories: " + businessCategories); return businessCategories == null ? new TreeMap<String, LdapGroup>() : Collections.unmodifiableSortedMap(businessCategories); }
From source file:gov.nih.nci.cabig.ctms.web.WebTools.java
private static SortedMap<String, Object> emptySortedMap() { return Collections.unmodifiableSortedMap(new TreeMap<String, Object>()); }
From source file:net.pms.dlna.protocolinfo.MimeType.java
/** * Creates a new {@link MimeType} instance using the given values. * * @param type the first part of the mime-type. * @param subtype the second part of the mime-type. * @param parameters a {@link Map} of additional parameters for this * mime-type.//from www . j a v a2 s . c om */ public MimeType(String type, String subtype, Map<String, String> parameters) { this.type = type == null ? ANY : type; this.subtype = subtype == null ? ANY : subtype; if (parameters == null) { this.parameters = Collections.EMPTY_MAP; } else { TreeMap<String, String> map = new TreeMap<String, String>(new Comparator<String>() { @Override public int compare(String o1, String o2) { return o1.compareToIgnoreCase(o2); } }); for (Entry<String, String> entry : parameters.entrySet()) { map.put(entry.getKey(), entry.getValue()); } this.parameters = Collections.unmodifiableSortedMap(map); } this.stringValue = generateStringValue(); }
From source file:com.enonic.cms.core.RequestParameters.java
public SortedMap<String, Param> getAsMap() { return Collections.unmodifiableSortedMap(parameters); }
From source file:gov.nih.nci.cabig.ctms.web.WebTools.java
private static <T> SortedMap<String, T> namedAttributesToMap(Enumeration<String> names, AttributeAccessor<T> accessor) { SortedMap<String, T> map = new TreeMap<String, T>(); while (names.hasMoreElements()) { String name = names.nextElement(); map.put(name, accessor.getAttribute(name)); }/* 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 by parsing a {@code ProtocolInfo} string. * * @param protocolInfoString the {@link String} to parse. * @throws ParseException If {@code protocolInfoString} can't be parsed. *///from w w w . ja v a 2 s . c o m public ProtocolInfo(String protocolInfoString) throws ParseException { String tmpNetwork = WILDCARD; MimeType tmpMimeType = MimeType.ANYANY; String tmpAdditionalInfo = WILDCARD; if (isBlank(protocolInfoString)) { protocol = Protocol.ALL; } else { protocolInfoString = protocolInfoString.trim(); String[] elements = protocolInfoString.split("\\s*:\\s*"); protocol = Protocol.value(elements[0]); if (elements.length > 1) { tmpNetwork = elements[1]; } if (elements.length > 2) { tmpMimeType = createMimeType(elements[2]); } if (elements.length > 3) { tmpAdditionalInfo = elements[3]; } if (elements.length > 4) { throw new ParseException("Invalid protocolInfo string \"" + protocolInfoString + "\""); } } network = tmpNetwork; mimeType = tmpMimeType; additionalInfo = tmpAdditionalInfo; attributes = Collections.unmodifiableSortedMap(parseAdditionalInfo()); attributesString = generateAttributesString(); stringValue = generateStringValue(); }
From source file:com.uber.hoodie.common.model.HoodieTableMetadata.java
/** * Returns all the commit metadata for this table. Reads all the commit files from HDFS. * Expensive operation, use with caution. * * @return SortedMap of CommitTime,HoodieCommitMetadata *//* w w w .j ava 2 s. c om*/ public SortedMap<String, HoodieCommitMetadata> getAllCommitMetadata() { try { TreeMap<String, HoodieCommitMetadata> metadataMap = new TreeMap<>(); for (String commitTs : commits.getCommitList()) { metadataMap.put(commitTs, getCommitMetadata(commitTs)); } return Collections.unmodifiableSortedMap(metadataMap); } catch (IOException e) { throw new HoodieIOException("Could not load all commits for table " + getTableName(), e); } }