KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tomcat > jni > Registry


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 package org.apache.tomcat.jni;
19
20 /** Windows Registy support
21  *
22  * @author Mladen Turk
23  * @version $Revision: 467222 $, $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $
24  */

25
26 public class Registry {
27
28     /* Registry Enums */
29     public static final int HKEY_CLASSES_ROOT = 1;
30     public static final int HKEY_CURRENT_CONFIG = 2;
31     public static final int HKEY_CURRENT_USER = 3;
32     public static final int HKEY_LOCAL_MACHINE = 4;
33     public static final int HKEY_USERS = 5;
34
35     public static final int KEY_ALL_ACCESS = 0x0001;
36     public static final int KEY_CREATE_LINK = 0x0002;
37     public static final int KEY_CREATE_SUB_KEY = 0x0004;
38     public static final int KEY_ENUMERATE_SUB_KEYS = 0x0008;
39     public static final int KEY_EXECUTE = 0x0010;
40     public static final int KEY_NOTIFY = 0x0020;
41     public static final int KEY_QUERY_VALUE = 0x0040;
42     public static final int KEY_READ = 0x0080;
43     public static final int KEY_SET_VALUE = 0x0100;
44     public static final int KEY_WOW64_64KEY = 0x0200;
45     public static final int KEY_WOW64_32KEY = 0x0400;
46     public static final int KEY_WRITE = 0x0800;
47
48     public static final int REG_BINARY = 1;
49     public static final int REG_DWORD = 2;
50     public static final int REG_EXPAND_SZ = 3;
51     public static final int REG_MULTI_SZ = 4;
52     public static final int REG_QWORD = 5;
53     public static final int REG_SZ = 6;
54
55      /**
56      * Create or open a Registry Key.
57      * @param name Registry Subkey to open
58      * @param root Root key, one of HKEY_*
59      * @param som Access mask that specifies the access rights for the key.
60      * @return Opened Registry key
61      */

62     public static native long create(int root, String JavaDoc name, int sam, long pool)
63         throws Error JavaDoc;
64
65      /**
66      * Opens the specified Registry Key.
67      * @param name Registry Subkey to open
68      * @param root Root key, one of HKEY_*
69      * @param som Access mask that specifies the access rights for the key.
70      * @return Opened Registry key
71      */

72     public static native long open(int root, String JavaDoc name, int sam, long pool)
73         throws Error JavaDoc;
74
75     /**
76      * Close the specified Registry key.
77      * @param key The Registry key descriptor to close.
78      */

79     public static native int close(long key);
80
81     /**
82      * Get the Registry key type.
83      * @param key The Registry key descriptor to use.
84      * @param name The name of the value to query
85      * @return Value type or negative error value
86      */

87     public static native int getType(long key, String JavaDoc name);
88
89     /**
90      * Get the Registry value for REG_DWORD
91      * @param key The Registry key descriptor to use.
92      * @param name The name of the value to query
93      * @return Registry key value
94      */

95     public static native int getValueI(long key, String JavaDoc name)
96         throws Error JavaDoc;
97
98     /**
99      * Get the Registry value for REG_QWORD or REG_DWORD
100      * @param key The Registry key descriptor to use.
101      * @param name The name of the value to query
102      * @return Registry key value
103      */

104     public static native long getValueJ(long key, String JavaDoc name)
105         throws Error JavaDoc;
106
107     /**
108      * Get the Registry key length.
109      * @param key The Registry key descriptor to use.
110      * @param name The name of the value to query
111      * @return Value size or negative error value
112      */

113     public static native int getSize(long key, String JavaDoc name);
114
115     /**
116      * Get the Registry value for REG_SZ or REG_EXPAND_SZ
117      * @param key The Registry key descriptor to use.
118      * @param name The name of the value to query
119      * @return Registry key value
120      */

121     public static native String JavaDoc getValueS(long key, String JavaDoc name)
122         throws Error JavaDoc;
123
124     /**
125      * Get the Registry value for REG_MULTI_SZ
126      * @param key The Registry key descriptor to use.
127      * @param name The name of the value to query
128      * @return Registry key value
129      */

130     public static native String JavaDoc[] getValueA(long key, String JavaDoc name)
131         throws Error JavaDoc;
132
133     /**
134      * Get the Registry value for REG_BINARY
135      * @param key The Registry key descriptor to use.
136      * @param name The name of the value to query
137      * @return Registry key value
138      */

139     public static native byte[] getValueB(long key, String JavaDoc name)
140         throws Error JavaDoc;
141
142
143     /**
144      * Set the Registry value for REG_DWORD
145      * @param key The Registry key descriptor to use.
146      * @param name The name of the value to set
147      * @param val The the value to set
148      * @return If the function succeeds, the return value is 0
149      */

150     public static native int setValueI(long key, String JavaDoc name, int val);
151
152     /**
153      * Set the Registry value for REG_QWORD
154      * @param key The Registry key descriptor to use.
155      * @param name The name of the value to set
156      * @param val The the value to set
157      * @return If the function succeeds, the return value is 0
158      */

159     public static native int setValueJ(long key, String JavaDoc name, int val);
160
161     /**
162      * Set the Registry value for REG_SZ
163      * @param key The Registry key descriptor to use.
164      * @param name The name of the value to set
165      * @param val The the value to set
166      * @return If the function succeeds, the return value is 0
167      */

168     public static native int setValueS(long key, String JavaDoc name, String JavaDoc val);
169
170     /**
171      * Set the Registry value for REG_EXPAND_SZ
172      * @param key The Registry key descriptor to use.
173      * @param name The name of the value to set
174      * @param val The the value to set
175      * @return If the function succeeds, the return value is 0
176      */

177     public static native int setValueE(long key, String JavaDoc name, String JavaDoc val);
178
179      /**
180      * Set the Registry value for REG_MULTI_SZ
181      * @param key The Registry key descriptor to use.
182      * @param name The name of the value to set
183      * @param val The the value to set
184      * @return If the function succeeds, the return value is 0
185      */

186     public static native int setValueA(long key, String JavaDoc name, String JavaDoc[] val);
187
188      /**
189      * Set the Registry value for REG_BINARY
190      * @param key The Registry key descriptor to use.
191      * @param name The name of the value to set
192      * @param val The the value to set
193      * @return If the function succeeds, the return value is 0
194      */

195     public static native int setValueB(long key, String JavaDoc name, byte[] val);
196
197     /**
198      * Enumerate the Registry subkeys
199      * @param key The Registry key descriptor to use.
200      * @param name The name of the value to query
201      * @return Array of all subkey names
202      */

203     public static native String JavaDoc[] enumKeys(long key)
204         throws Error JavaDoc;
205
206     /**
207      * Enumerate the Registry values
208      * @param key The Registry key descriptor to use.
209      * @param name The name of the value to query
210      * @return Array of all value names
211      */

212     public static native String JavaDoc[] enumValues(long key)
213         throws Error JavaDoc;
214
215      /**
216      * Delete the Registry value
217      * @param key The Registry key descriptor to use.
218      * @param name The name of the value to delete
219      * @return If the function succeeds, the return value is 0
220      */

221     public static native int deleteValue(long key, String JavaDoc name);
222
223      /**
224      * Delete the Registry subkey
225      * @param root Root key, one of HKEY_*
226      * @param name Subkey to delete
227      * @param onlyIfEmpty If true will not delete a key if
228      * it contains any subkeys or values
229      * @return If the function succeeds, the return value is 0
230      */

231     public static native int deleteKey(int root, String JavaDoc name,
232                                        boolean onlyIfEmpty);
233
234
235 }
236
Popular Tags