01: /*
02: ** Java native interface to the Windows Registry API.
03: ** Copyright (c) 1997 by Timothy Gerard Endres
04: **
05: ** This program is free software.
06: **
07: ** You may redistribute it and/or modify it under the terms of the GNU
08: ** General Public License as published by the Free Software Foundation.
09: ** Version 2 of the license should be included with this distribution in
10: ** the file LICENSE, as well as License.html. If the license is not
11: ** included with this distribution, you may find a copy at the FSF web
12: ** site at 'www.gnu.org' or 'www.fsf.org', or you may write to the
13: ** Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139 USA.
14: **
15: ** THIS SOFTWARE IS PROVIDED AS-IS WITHOUT WARRANTY OF ANY KIND,
16: ** NOT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY. THE AUTHOR
17: ** OF THIS SOFTWARE, ASSUMES _NO_ RESPONSIBILITY FOR ANY
18: ** CONSEQUENCE RESULTING FROM THE USE, MODIFICATION, OR
19: ** REDISTRIBUTION OF THIS SOFTWARE.
20: **
21: */
22:
23: package com.ice.jni.registry;
24:
25: import java.io.PrintWriter;
26:
27: /**
28: * The RegStringValue class represents a string value in the
29: * registry (REG_SZ, and REG_EXPAND_SZ).
30: *
31: * @see com.ice.jni.registry.Registry
32: * @see com.ice.jni.registry.RegistryKey
33: */
34:
35: public class RegStringValue extends RegistryValue {
36: String data;
37: int dataLen;
38:
39: public RegStringValue(RegistryKey key, String name) {
40: super (key, name, RegistryValue.REG_SZ);
41: this .data = null;
42: this .dataLen = 0;
43: }
44:
45: public RegStringValue(RegistryKey key, String name, int type) {
46: super (key, name, type);
47: this .data = null;
48: this .dataLen = 0;
49: }
50:
51: public RegStringValue(RegistryKey key, String name, String data) {
52: super (key, name, RegistryValue.REG_SZ);
53: this .setData(data);
54: }
55:
56: public String getData() {
57: return this .data;
58: }
59:
60: public int getLength() {
61: return this .dataLen;
62: }
63:
64: public void setData(String data) {
65: this .data = data;
66: this .dataLen = data.length();
67: }
68:
69: public byte[] getByteData() {
70: return this .data.getBytes();
71: }
72:
73: public int getByteLength() {
74: return this .dataLen;
75: }
76:
77: public void setByteData(byte[] data) {
78: this .setData(new String(data));
79: }
80:
81: public void export(PrintWriter out) {
82: if (this .getName().length() == 0)
83: out.print("@=");
84: else
85: out.print("\"" + this .getName() + "\"=");
86:
87: out.println("\"" + this .getData() + "\"");
88: }
89:
90: }
|