src/org/objectweb/cjdbc/common/stream/encoding/HexaEncoding.java

説明を見る。
00001 00025 package org.objectweb.cjdbc.common.stream.encoding; 00026 00033 public class HexaEncoding 00034 { 00041 public static final String data2hex(byte[] data) 00042 { 00043 if (data == null) 00044 return null; 00045 00046 int len = data.length; 00047 StringBuffer buf = new StringBuffer(len * 2); 00048 for (int pos = 0; pos < len; pos++) 00049 buf.append(toHexChar((data[pos] >>> 4) & 0x0F)).append( 00050 toHexChar(data[pos] & 0x0F)); 00051 return buf.toString(); 00052 } 00053 00060 public static final byte[] hex2data(String str) 00061 { 00062 if (str == null) 00063 return new byte[0]; 00064 00065 int len = str.length(); 00066 char hex[] = str.toCharArray(); 00067 byte[] buf = new byte[len / 2]; 00068 00069 for (int pos = 0; pos < len / 2; pos++) 00070 buf[pos] = (byte) (((toDataNibble(hex[2 * pos]) << 4) & 0xF0) | (toDataNibble(hex[2 * pos + 1]) & 0x0F)); 00071 00072 return buf; 00073 } 00074 00081 public static char toHexChar(int i) 00082 { 00083 if ((0 <= i) && (i <= 9)) 00084 return (char) ('0' + i); 00085 else 00086 return (char) ('a' + (i - 10)); 00087 } 00088 00095 public static byte toDataNibble(char c) 00096 { 00097 if (('0' <= c) && (c <= '9')) 00098 return (byte) ((byte) c - (byte) '0'); 00099 else if (('a' <= c) && (c <= 'f')) 00100 return (byte) ((byte) c - (byte) 'a' + 10); 00101 else if (('A' <= c) && (c <= 'F')) 00102 return (byte) ((byte) c - (byte) 'A' + 10); 00103 else 00104 return -1; 00105 } 00106 }

CJDBCversion1.0.4に対してTue Oct 12 15:15:58 2004に生成されました。 doxygen 1.3.8