1 22 23 package com.ice.jni.registry; 24 25 import java.io.PrintWriter ; 26 import com.ice.text.HexNumberFormat; 27 28 29 36 37 public class 38 RegDWordValue extends RegistryValue 39 { 40 int data; 41 int dataLen; 42 43 public 44 RegDWordValue( RegistryKey key, String name ) 45 { 46 super( key, name, RegistryValue.REG_DWORD ); 47 this.data = 0; 48 this.dataLen = 0; 49 } 50 51 public 52 RegDWordValue( RegistryKey key, String name, int type ) 53 { 54 super( key, name, type ); 55 this.data = 0; 56 this.dataLen = 0; 57 } 58 59 public 60 RegDWordValue( RegistryKey key, String name, int type, int data ) 61 { 62 super( key, name, RegistryValue.REG_DWORD ); 63 this.setData( data ); 64 } 65 66 public int 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( int data ) 80 { 81 this.data = data; 82 this.dataLen = 1; 83 } 84 85 public byte[] 86 getByteData() 87 { 88 byte[] result = new byte[4]; 89 90 result[0] = (byte) ( (this.data >> 24) & 255 ); 91 result[1] = (byte) ( (this.data >> 16) & 255 ); 92 result[2] = (byte) ( (this.data >> 8) & 255 ); 93 result[3] = (byte) ( this.data & 255 ); 94 95 return result; 96 } 97 98 public int 99 getByteLength() 100 { 101 return 4; 102 } 103 104 public void 105 setByteData( byte[] data ) 106 { 107 int newValue = 108 ( (((int) data[0]) << 24) & 0xFF000000 ) 109 | ( (((int) data[1]) << 16) & 0x00FF0000 ) 110 | ( (((int) data[2]) << 8) & 0x0000FF00 ) 111 | ( ((int) data[3]) & 0x000000FF ); 112 113 this.setData( newValue ); 114 } 115 116 public void 117 export( PrintWriter out ) 118 { 119 out.print( "\"" + this.getName() + "\"=" ); 120 121 HexNumberFormat nFmt = 122 new HexNumberFormat( "xxxxxxxx" ); 123 124 out.println( "dword:" + nFmt.format( this.getData() ) ); 125 } 126 127 } 128 129 130 131 132 | Popular Tags |