001/* 002 * Copyright (c) 1995, 2022, Oracle and/or its affiliates. All rights reserved. 003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 004 * 005 * This code is free software; you can redistribute it and/or modify it 006 * under the terms of the GNU General Public License version 2 only, as 007 * published by the Free Software Foundation. Oracle designates this 008 * particular file as subject to the "Classpath" exception as provided 009 * by Oracle in the LICENSE file that accompanied this code. 010 * 011 * This code is distributed in the hope that it will be useful, but WITHOUT 012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 013 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 014 * version 2 for more details (a copy is included in the LICENSE file that 015 * accompanied this code). 016 * 017 * You should have received a copy of the GNU General Public License version 018 * 2 along with this work; if not, write to the Free Software Foundation, 019 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 020 * 021 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 022 * or visit www.oracle.com if you need additional information or have any 023 * questions. 024 */ 025package Torello.Java.ReadOnly; 026 027import java.util.Enumeration; 028 029/** 030 * Immutable variant of Java Collections Framework abstract class 031 * <CODE>java.util.Dictionary<K, V></CODE>. 032 * 033 * <EMBED CLASS='external-html' DATA-JDK=ReadOnlyDictionary DATA-FILE-ID=ABSTRACT_CLASS> 034 * 035 * @param <K> the type of keys 036 * @param <V> the type of mapped values 037 */ 038@Torello.JavaDoc.JDHeaderBackgroundImg(EmbedTagFileID="JDHBI_INTERFACE") 039public interface ReadOnlyDictionary<K, V> 040{ 041 /** 042 * Returns the number of entries (distinct keys) in this dictionary. 043 * @return the number of keys in this dictionary. 044 */ 045 int size(); 046 047 /** 048 * Tests if this dictionary maps no keys to value. The general contract for the {@code isEmpty} 049 * method is that the result is true if and only if this dictionary contains no entries. 050 * 051 * @return {@code true} if this dictionary maps no keys to values; {@code false} otherwise. 052 */ 053 boolean isEmpty(); 054 055 /** 056 * Returns an enumeration of the keys in this dictionary. The general contract for the keys 057 * method is that an {@code Enumeration} object is returned that will generate all the keys for 058 * which this dictionary contains entries. 059 * 060 * @return an enumeration of the keys in this dictionary. 061 * @see #elements() 062 */ 063 Enumeration<K> keys(); 064 065 /** 066 * Returns an enumeration of the values in this dictionary. The general contract for the 067 * {@code elements} method is that an {@code Enumeration} is returned that will generate all 068 * the elements contained in entries in this dictionary. 069 * 070 * @return an enumeration of the values in this dictionary. 071 * @see #keys() 072 */ 073 Enumeration<V> elements(); 074 075 /** 076 * Returns the value to which the key is mapped in this dictionary. The general contract for 077 * the {@code isEmpty} method is that if this dictionary contains an entry for the specified 078 * key, the associated value is returned; otherwise, {@code null} is returned. 079 * 080 * @return the value to which the key is mapped in this dictionary; 081 * 082 * @param key a key in this dictionary. {@code null} if the key is not mapped to any value 083 * in this dictionary. 084 * 085 * @throws NullPointerException if the {@code key} is {@code null}. 086 */ 087 V get(Object key); 088}