| 1 22 23 package com.ice.jni.registry; 24 25 import java.io.PrintWriter ; 26 27 39 40 abstract public class 41 RegistryValue 42 { 43 public static final int REG_NONE = 0; 44 public static final int REG_SZ = 1; 45 public static final int REG_EXPAND_SZ = 2; 46 public static final int REG_BINARY = 3; 47 public static final int REG_DWORD = 4; 48 public static final int REG_DWORD_LITTLE_ENDIAN = 4; 49 public static final int REG_DWORD_BIG_ENDIAN = 5; 50 public static final int REG_LINK = 6; 51 public static final int REG_MULTI_SZ = 7; 52 public static final int REG_RESOURCE_LIST = 8; 53 public static final int REG_FULL_RESOURCE_DESCRIPTOR = 9; 54 public static final int REG_RESOURCE_REQUIREMENTS_LIST = 10; 55 56 protected static char[] hexChars; 57 58 int type; 59 String name; 60 RegistryKey key; 61 62 static 63 { 64 RegistryValue.hexChars = new char[20]; 65 66 RegistryValue.hexChars[0] = '0'; 67 RegistryValue.hexChars[1] = '1'; 68 RegistryValue.hexChars[2] = '2'; 69 RegistryValue.hexChars[3] = '3'; 70 RegistryValue.hexChars[4] = '4'; 71 RegistryValue.hexChars[5] = '5'; 72 RegistryValue.hexChars[6] = '6'; 73 RegistryValue.hexChars[7] = '7'; 74 RegistryValue.hexChars[8] = '8'; 75 RegistryValue.hexChars[9] = '9'; 76 RegistryValue.hexChars[10] = 'a'; 77 RegistryValue.hexChars[11] = 'b'; 78 RegistryValue.hexChars[12] = 'c'; 79 RegistryValue.hexChars[13] = 'd'; 80 RegistryValue.hexChars[14] = 'e'; 81 RegistryValue.hexChars[15] = 'f'; 82 } 83 84 public 85 RegistryValue( RegistryKey key, String name, int type ) 86 { 87 this.key = key; 88 this.name = name; 89 this.type = type; 90 } 91 92 public RegistryKey 93 getKey() 94 { 95 return this.key; 96 } 97 98 public String  99 getName() 100 { 101 return this.name; 102 } 103 104 public int 105 getType() 106 { 107 return this.type; 108 } 109 110 public void 111 export( PrintWriter out ) 112 { 113 out.print( "\"" + this.getName() + "\"=" ); 114 out.println( "\"ERROR called RegistryValue.export()!\"" ); 115 } 116 117 public String  118 toString() 119 { 120 return "[type=" + this.type + ",name=" + this.name + "]"; 121 } 122 123 public static void 124 exportHexData( PrintWriter out, byte[] data ) 125 { 126 int i, cnt; 127 char ch1, ch2; 128 int len = data.length; 129 130 for ( i = 0, cnt = 0 ; i < len ; ++i ) 131 { 132 byte dByte = data[i]; 133 134 ch2 = RegistryValue.hexChars[ (dByte & 0x0F) ]; 135 ch1 = RegistryValue.hexChars[ ((dByte >> 4) & 0x0F) ]; 136 137 if ( cnt == 0 ) out.print( " " ); 138 139 out.print( ch1 ); 140 out.print( ch2 ); 141 142 if ( i < (len - 1) ) 143 out.print( "," ); 144 145 if ( ++cnt > 15 ) 146 { 147 cnt = 0; 148 if ( i < (len-1) ) 149 out.println( "\\" ); 150 } 151 } 152 153 out.println( "" ); 154 } 155 156 abstract public byte[] 157 getByteData(); 158 159 abstract public int 160 getByteLength(); 161 162 abstract public void 163 setByteData( byte[] data ); 164 165 } 166 167 168 | Popular Tags |