annotate src/myVncClient/CapsContainer.java @ 17:f9ecb0315303

add package
author e085711
date Sun, 24 Apr 2011 16:55:29 +0900
parents src/CapsContainer.java@e04119c40b9b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17
f9ecb0315303 add package
e085711
parents: 0
diff changeset
1 package myVncClient;
0
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
2 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
3 // Copyright (C) 2003 Constantin Kaplinsky. All Rights Reserved.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
4 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
5 // This is free software; you can redistribute it and/or modify
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
6 // it under the terms of the GNU General Public License as published by
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
7 // the Free Software Foundation; either version 2 of the License, or
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
8 // (at your option) any later version.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
9 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
10 // This software is distributed in the hope that it will be useful,
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
13 // GNU General Public License for more details.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
14 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
15 // You should have received a copy of the GNU General Public License
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
16 // along with this software; if not, write to the Free Software
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
17 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
18 // USA.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
19 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
20
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
21 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
22 // CapsContainer.java - A container of capabilities as used in the RFB
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
23 // protocol 3.130
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
24 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
25
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
26 import java.util.Vector;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
27 import java.util.Hashtable;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
28
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
29 class CapsContainer {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
30
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
31 // Public methods
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
32
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
33 public CapsContainer() {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
34 infoMap = new Hashtable(64, (float)0.25);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
35 orderedList = new Vector(32, 8);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
36 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
37
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
38 public void add(CapabilityInfo capinfo) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
39 Integer key = new Integer(capinfo.getCode());
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
40 infoMap.put(key, capinfo);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
41 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
42
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
43 public void add(int code, String vendor, String name, String desc) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
44 Integer key = new Integer(code);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
45 infoMap.put(key, new CapabilityInfo(code, vendor, name, desc));
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
46 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
47
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
48 public boolean isKnown(int code) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
49 return infoMap.containsKey(new Integer(code));
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
50 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
51
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
52 public CapabilityInfo getInfo(int code) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
53 return (CapabilityInfo)infoMap.get(new Integer(code));
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
54 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
55
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
56 public String getDescription(int code) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
57 CapabilityInfo capinfo = (CapabilityInfo)infoMap.get(new Integer(code));
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
58 if (capinfo == null)
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
59 return null;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
60
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
61 return capinfo.getDescription();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
62 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
63
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
64 public boolean enable(CapabilityInfo other) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
65 Integer key = new Integer(other.getCode());
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
66 CapabilityInfo capinfo = (CapabilityInfo)infoMap.get(key);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
67 if (capinfo == null)
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
68 return false;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
69
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
70 boolean enabled = capinfo.enableIfEquals(other);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
71 if (enabled)
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
72 orderedList.addElement(key);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
73
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
74 return enabled;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
75 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
76
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
77 public boolean isEnabled(int code) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
78 CapabilityInfo capinfo = (CapabilityInfo)infoMap.get(new Integer(code));
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
79 if (capinfo == null)
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
80 return false;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
81
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
82 return capinfo.isEnabled();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
83 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
84
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
85 public int numEnabled() {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
86 return orderedList.size();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
87 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
88
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
89 public int getByOrder(int idx) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
90 int code;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
91 try {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
92 code = ((Integer)orderedList.elementAt(idx)).intValue();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
93 } catch (ArrayIndexOutOfBoundsException e) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
94 code = 0;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
95 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
96 return code;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
97 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
98
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
99 // Protected data
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
100
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
101 protected Hashtable infoMap;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
102 protected Vector orderedList;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
103 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
104