Java Code Examples for java.util.Collections.checkedMap()

The following are Jave code examples for showing how to use checkedMap() of the java.util.Collections class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: openjdk-jdk10   File: XPathType.java   View Source Code Vote up 6 votes
/**
 * Creates an <code>XPathType</code> instance with the specified XPath
 * expression, filter, and namespace map. The map is copied to protect
 * against subsequent modification.
 *
 * @param expression the XPath expression to be evaluated
 * @param filter the filter operation ({@link Filter#INTERSECT},
 *    {@link Filter#SUBTRACT}, or {@link Filter#UNION})
 * @param namespaceMap the map of namespace prefixes. Each key is a
 *    namespace prefix <code>String</code> that maps to a corresponding
 *    namespace URI <code>String</code>.
 * @throws NullPointerException if <code>expression</code>,
 *    <code>filter</code> or <code>namespaceMap</code> are
 *    <code>null</code>
 * @throws ClassCastException if any of the map's keys or entries are
 *    not of type <code>String</code>
 */
public XPathType(String expression, Filter filter,
    Map<String,String> namespaceMap) {
    if (expression == null) {
        throw new NullPointerException("expression cannot be null");
    }
    if (filter == null) {
        throw new NullPointerException("filter cannot be null");
    }
    if (namespaceMap == null) {
        throw new NullPointerException("namespaceMap cannot be null");
    }
    this.expression = expression;
    this.filter = filter;
    Map<String,String> tempMap = Collections.checkedMap(new HashMap<>(),
                                                        String.class,
                                                        String.class);
    tempMap.putAll(namespaceMap);
    this.nsMap = Collections.unmodifiableMap(tempMap);
}
 
Example 2
Project: jdk8u-jdk   File: java_util_Collections_CheckedMap.java   View Source Code Vote up 4 votes
protected Map<String, String> getObject() {
    Map<String, String> map = Collections.singletonMap("key", "value");
    return Collections.checkedMap(map, String.class, String.class);
}
 
Example 3
Project: jdk8u-jdk   File: java_util_Collections_CheckedMap.java   View Source Code Vote up 4 votes
protected Map<String, String> getAnotherObject() {
    Map<String, String> map = Collections.emptyMap();
    return Collections.checkedMap(map, String.class, String.class);
}
 
Example 4
Project: OpenJSharp   File: CertificateRevokedException.java   View Source Code Vote up 3 votes
/**
 * Constructs a {@code CertificateRevokedException} with
 * the specified revocation date, reason code, authority name, and map
 * of extensions.
 *
 * @param revocationDate the date on which the certificate was revoked. The
 *    date is copied to protect against subsequent modification.
 * @param reason the revocation reason
 * @param extensions a map of X.509 Extensions. Each key is an OID String
 *    that maps to the corresponding Extension. The map is copied to
 *    prevent subsequent modification.
 * @param authority the {@code X500Principal} that represents the name
 *    of the authority that signed the certificate's revocation status
 *    information
 * @throws NullPointerException if {@code revocationDate},
 *    {@code reason}, {@code authority}, or
 *    {@code extensions} is {@code null}
 */
public CertificateRevokedException(Date revocationDate, CRLReason reason,
    X500Principal authority, Map<String, Extension> extensions) {
    if (revocationDate == null || reason == null || authority == null ||
        extensions == null) {
        throw new NullPointerException();
    }
    this.revocationDate = new Date(revocationDate.getTime());
    this.reason = reason;
    this.authority = authority;
    // make sure Map only contains correct types
    this.extensions = Collections.checkedMap(new HashMap<>(),
                                             String.class, Extension.class);
    this.extensions.putAll(extensions);
}
 
Example 5
Project: jdk8u-jdk   File: CertificateRevokedException.java   View Source Code Vote up 3 votes
/**
 * Constructs a {@code CertificateRevokedException} with
 * the specified revocation date, reason code, authority name, and map
 * of extensions.
 *
 * @param revocationDate the date on which the certificate was revoked. The
 *    date is copied to protect against subsequent modification.
 * @param reason the revocation reason
 * @param extensions a map of X.509 Extensions. Each key is an OID String
 *    that maps to the corresponding Extension. The map is copied to
 *    prevent subsequent modification.
 * @param authority the {@code X500Principal} that represents the name
 *    of the authority that signed the certificate's revocation status
 *    information
 * @throws NullPointerException if {@code revocationDate},
 *    {@code reason}, {@code authority}, or
 *    {@code extensions} is {@code null}
 */
public CertificateRevokedException(Date revocationDate, CRLReason reason,
    X500Principal authority, Map<String, Extension> extensions) {
    if (revocationDate == null || reason == null || authority == null ||
        extensions == null) {
        throw new NullPointerException();
    }
    this.revocationDate = new Date(revocationDate.getTime());
    this.reason = reason;
    this.authority = authority;
    // make sure Map only contains correct types
    this.extensions = Collections.checkedMap(new HashMap<>(),
                                             String.class, Extension.class);
    this.extensions.putAll(extensions);
}
 
Example 6
Project: openjdk-jdk10   File: CertificateRevokedException.java   View Source Code Vote up 3 votes
/**
 * Constructs a {@code CertificateRevokedException} with
 * the specified revocation date, reason code, authority name, and map
 * of extensions.
 *
 * @param revocationDate the date on which the certificate was revoked. The
 *    date is copied to protect against subsequent modification.
 * @param reason the revocation reason
 * @param extensions a map of X.509 Extensions. Each key is an OID String
 *    that maps to the corresponding Extension. The map is copied to
 *    prevent subsequent modification.
 * @param authority the {@code X500Principal} that represents the name
 *    of the authority that signed the certificate's revocation status
 *    information
 * @throws NullPointerException if {@code revocationDate},
 *    {@code reason}, {@code authority}, or
 *    {@code extensions} is {@code null}
 * @throws ClassCastException if {@code extensions} contains an incorrectly
 *    typed key or value
 */
public CertificateRevokedException(Date revocationDate, CRLReason reason,
    X500Principal authority, Map<String, Extension> extensions) {
    if (revocationDate == null || reason == null || authority == null ||
        extensions == null) {
        throw new NullPointerException();
    }
    this.revocationDate = new Date(revocationDate.getTime());
    this.reason = reason;
    this.authority = authority;
    // make sure Map only contains correct types
    this.extensions = Collections.checkedMap(new HashMap<>(),
                                             String.class, Extension.class);
    this.extensions.putAll(extensions);
}
 
Example 7
Project: openjdk-jdk10   File: XPathFilterParameterSpec.java   View Source Code Vote up 3 votes
/**
 * Creates an <code>XPathFilterParameterSpec</code> with the specified
 * XPath expression and namespace map. The map is copied to protect against
 * subsequent modification.
 *
 * @param xPath the XPath expression to be evaluated
 * @param namespaceMap the map of namespace prefixes. Each key is a
 *    namespace prefix <code>String</code> that maps to a corresponding
 *    namespace URI <code>String</code>.
 * @throws NullPointerException if <code>xPath</code> or
 *    <code>namespaceMap</code> are <code>null</code>
 * @throws ClassCastException if any of the map's keys or entries are not
 *    of type <code>String</code>
 */
public XPathFilterParameterSpec(String xPath, Map<String,String> namespaceMap) {
    if (xPath == null || namespaceMap == null) {
        throw new NullPointerException();
    }
    this.xPath = xPath;
    Map<String,String> tempMap = Collections.checkedMap(new HashMap<>(),
                                                        String.class,
                                                        String.class);
    tempMap.putAll(namespaceMap);
    this.nsMap = Collections.unmodifiableMap(tempMap);
}