2 // Copyright (C) 2003 Constantin Kaplinsky. All Rights Reserved.
4 // This is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 2 of the License, or
7 // (at your option) any later version.
9 // This software is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this software; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
21 // CapsContainer.java - A container of capabilities as used in the RFB
25 import java.util.Vector;
26 import java.util.Hashtable;
32 public CapsContainer() {
33 infoMap = new Hashtable(64, (float)0.25);
34 orderedList = new Vector(32, 8);
37 public void add(CapabilityInfo capinfo) {
38 Integer key = new Integer(capinfo.getCode());
39 infoMap.put(key, capinfo);
42 public void add(int code, String vendor, String name, String desc) {
43 Integer key = new Integer(code);
44 infoMap.put(key, new CapabilityInfo(code, vendor, name, desc));
47 public boolean isKnown(int code) {
48 return infoMap.containsKey(new Integer(code));
51 public CapabilityInfo getInfo(int code) {
52 return (CapabilityInfo)infoMap.get(new Integer(code));
55 public String getDescription(int code) {
56 CapabilityInfo capinfo = (CapabilityInfo)infoMap.get(new Integer(code));
60 return capinfo.getDescription();
63 public boolean enable(CapabilityInfo other) {
64 Integer key = new Integer(other.getCode());
65 CapabilityInfo capinfo = (CapabilityInfo)infoMap.get(key);
69 boolean enabled = capinfo.enableIfEquals(other);
71 orderedList.addElement(key);
76 public boolean isEnabled(int code) {
77 CapabilityInfo capinfo = (CapabilityInfo)infoMap.get(new Integer(code));
81 return capinfo.isEnabled();
84 public int numEnabled() {
85 return orderedList.size();
88 public int getByOrder(int idx) {
91 code = ((Integer)orderedList.elementAt(idx)).intValue();
92 } catch (ArrayIndexOutOfBoundsException e) {
100 protected Hashtable infoMap;
101 protected Vector orderedList;