KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ice > jni > registry > RegStringValue


1 /*
2 ** Java native interface to the Windows Registry API.
3 ** Copyright (c) 1997 by Timothy Gerard Endres
4 **
5 ** This program is free software.
6 **
7 ** You may redistribute it and/or modify it under the terms of the GNU
8 ** General Public License as published by the Free Software Foundation.
9 ** 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 JavaDoc;
26
27
28 /**
29  * The RegStringValue class represents a string value in the
30  * registry (REG_SZ, and REG_EXPAND_SZ).
31  *
32  * @see com.ice.jni.registry.Registry
33  * @see com.ice.jni.registry.RegistryKey
34  */

35
36 public class
37 RegStringValue extends RegistryValue
38     {
39     String JavaDoc data;
40     int dataLen;
41
42
43     public
44     RegStringValue( RegistryKey key, String JavaDoc name )
45         {
46         super( key, name, RegistryValue.REG_SZ );
47         this.data = null;
48         this.dataLen = 0;
49         }
50
51     public
52     RegStringValue( RegistryKey key, String JavaDoc name, int type )
53         {
54         super( key, name, type );
55         this.data = null;
56         this.dataLen = 0;
57         }
58
59     public
60     RegStringValue( RegistryKey key, String JavaDoc name, String JavaDoc data )
61         {
62         super( key, name, RegistryValue.REG_SZ );
63         this.setData( data );
64         }
65
66     public String JavaDoc
67     getData()
68         {
69         return this.data;
70         }
71
72     public int
73     getLength()
74         {
75         return this.dataLen;
76         }
77
78     public void
79     setData( String JavaDoc data )
80         {
81         this.data = data;
82         this.dataLen = data.length();
83         }
84
85     public byte[]
86     getByteData()
87         {
88         return this.data.getBytes();
89         }
90
91     public int
92     getByteLength()
93         {
94         return this.dataLen;
95         }
96
97     public void
98     setByteData( byte[] data )
99         {
100         this.setData( new String JavaDoc( data ) );
101         }
102
103     public void
104     export( PrintWriter JavaDoc out )
105         {
106         if ( this.getName().length() == 0 )
107             out.print( "@=" );
108         else
109             out.print( "\"" + this.getName() + "\"=" );
110
111         out.println( "\"" + this.getData() + "\"" );
112         }
113
114     }
115
116
117
118
119
Popular Tags