001: /*
002: * $RCSfile: J3dQueryProps.java,v $
003: *
004: * Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved.
005: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
006: *
007: * This code is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU General Public License version 2 only, as
009: * published by the Free Software Foundation. Sun designates this
010: * particular file as subject to the "Classpath" exception as provided
011: * by Sun in the LICENSE file that accompanied this code.
012: *
013: * This code is distributed in the hope that it will be useful, but WITHOUT
014: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
015: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
016: * version 2 for more details (a copy is included in the LICENSE file that
017: * accompanied this code).
018: *
019: * You should have received a copy of the GNU General Public License version
020: * 2 along with this work; if not, write to the Free Software Foundation,
021: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
022: *
023: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
024: * CA 95054 USA or visit www.sun.com if you need additional information or
025: * have any questions.
026: *
027: * $Revision: 1.5 $
028: * $Date: 2008/02/28 20:17:25 $
029: * $State: Exp $
030: */
031:
032: package javax.media.j3d;
033:
034: import java.util.*;
035:
036: /**
037: * Properties object for query operations. It is a read-only Map backed
038: * up by a Hashtable.
039: */
040: class J3dQueryProps extends AbstractMap {
041: private Hashtable table;
042: private Set entrySet = null;
043:
044: /**
045: * Constructs a new J3dQueryProps object using the specified
046: * array of keys and the specified values. The arrays must be
047: * the same size.
048: */
049: J3dQueryProps(String[] keys, Object[] values) {
050: table = new Hashtable();
051: for (int i = 0; i < keys.length; i++) {
052: table.put(keys[i], values[i]);
053: }
054: }
055:
056: /**
057: * Gets value corresponding to specified key
058: */
059: public Object get(Object key) {
060: return table.get(key);
061: }
062:
063: /**
064: * Returns true if the specified key is contained in this Map
065: */
066: public boolean containsKey(Object key) {
067: return table.containsKey(key);
068: }
069:
070: /**
071: * Returns true if the specified value is contained in this Map
072: */
073: public boolean containsValue(Object value) {
074: return table.containsValue(value);
075: }
076:
077: /**
078: * Returns a new Set object for the entries of this map
079: */
080: public Set entrySet() {
081: if (entrySet == null)
082: entrySet = new EntrySet();
083:
084: return entrySet;
085: }
086:
087: /**
088: * Entry set class
089: */
090: private class EntrySet extends AbstractSet {
091: private EntrySet() {
092: }
093:
094: public int size() {
095: return table.size();
096: }
097:
098: public Iterator iterator() {
099: return new MapIterator();
100: }
101: }
102:
103: /**
104: * Entry set class
105: */
106: private class MapIterator implements Iterator {
107: private Iterator i;
108:
109: private MapIterator() {
110: i = table.entrySet().iterator();
111: }
112:
113: public boolean hasNext() {
114: return i.hasNext();
115: }
116:
117: public Object next() {
118: return i.next();
119: }
120:
121: public void remove() {
122: throw new UnsupportedOperationException();
123: }
124: }
125: }
|