📄 codecs.java
字号:
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3)
// Source File Name: Codecs.java
package com.sap.mw.jco.util;
public class Codecs
{
public static class Base64
{
public static final char[] encode(String value)
{
if(value == null)
{
return new char[0];
} else
{
byte p[] = value.getBytes();
return encode(p, 0, p.length);
}
}
public static final char[] encode(byte bytes[])
{
if(bytes == null)
return new char[0];
else
return encode(bytes, 0, bytes.length);
}
public static final char[] encode(byte bytes[], int offset, int length)
{
int is = 0;
if(bytes == null || length <= 0)
return new char[0];
char s[] = new char[4 * ((length + 2) / 3)];
int n = (offset + length) - length % 3;
int i;
for(i = offset; i < n; i += 3)
{
int v = bytes[i] << 16 & 0xff0000 | bytes[i + 1] << 8 & 0xff00 | bytes[i + 2] & 0xff;
s[is++] = base64_table[v >> 18 & 0x3f];
s[is++] = base64_table[v >> 12 & 0x3f];
s[is++] = base64_table[v >> 6 & 0x3f];
s[is++] = base64_table[v & 0x3f];
}
n = length % 3;
i = (offset + length) - n;
if(n == 2)
{
int v = bytes[i] << 16 | bytes[i + 1] << 8;
v = bytes[i] << 16 & 0xff0000 | bytes[i + 1] << 8 & 0xff00;
s[is++] = base64_table[v >> 18 & 0x3f];
s[is++] = base64_table[v >> 12 & 0x3f];
s[is++] = base64_table[v >> 6 & 0x3f];
s[is++] = '=';
} else
if(n == 1)
{
int v = bytes[i] << 16 & 0xff0000;
s[is++] = base64_table[v >> 18 & 0x3f];
s[is++] = base64_table[v >> 12 & 0x3f];
s[is++] = '=';
s[is++] = '=';
}
return s;
}
public static final byte[] decode(String value)
{
if(value == null)
{
return new byte[0];
} else
{
char p[] = value.toCharArray();
return decode(p, 0, p.length);
}
}
public static final byte[] decode(char chars[])
{
if(chars == null)
return new byte[0];
else
return decode(chars, 0, chars.length);
}
public static final byte[] decode(char chars[], int offset, int length)
{
if(chars == null)
return new byte[0];
int shift = 0;
int accum = 0;
int index = 0;
int tmp_length = length;
for(int i = offset; i < offset + length; i++)
{
int value = base64_inv_table[chars[i] & 0xff];
if(value < 0 && chars[i] != '=')
tmp_length--;
}
int len = ((tmp_length + 3) / 4) * 3;
if(tmp_length > 0 && chars[(offset + length) - 1] == '=')
len--;
if(tmp_length > 1 && chars[(offset + length) - 2] == '=')
len--;
byte s[] = new byte[len];
for(int i = offset; i < offset + length; i++)
{
int value = base64_inv_table[chars[i] & 0xff];
if(value >= 0)
{
accum <<= 6;
shift += 6;
accum |= value;
if(shift >= 8)
{
shift -= 8;
s[index++] = (byte)(accum >> shift & 0xff);
}
}
}
return s;
}
private static final char base64_table[];
private static final byte base64_inv_table[];
static
{
base64_table = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".toCharArray();
base64_inv_table = new byte[256];
for(int i = 0; i < 256; i++)
base64_inv_table[i] = -1;
for(int i = 0; i < 64; i++)
base64_inv_table[base64_table[i]] = (byte)i;
}
public Base64()
{
}
}
public static class Hex
{
public static final String encode(byte value[])
{
if(value == null)
return "";
char s[] = new char[value.length * 2];
int i = 0;
int k = 0;
for(; i < value.length; i++)
{
s[k++] = hex[value[i] >> 4 & 0xf];
s[k++] = hex[value[i] & 0xf];
}
return new String(s);
}
public static final String encode(byte value)
{
char s[] = new char[2];
s[0] = hex[value >> 4 & 0xf];
s[1] = hex[value & 0xf];
return new String(s);
}
public static final String encode(char value)
{
char s[] = new char[4];
s[0] = hex[value >> 12 & 0xf];
s[1] = hex[value >> 8 & 0xf];
s[2] = hex[value >> 4 & 0xf];
s[3] = hex[value & 0xf];
return new String(s);
}
public static final String encode(int value)
{
char s[] = new char[8];
s[0] = hex[value >> 28 & 0xf];
s[1] = hex[value >> 24 & 0xf];
s[2] = hex[value >> 20 & 0xf];
s[3] = hex[value >> 16 & 0xf];
s[4] = hex[value >> 12 & 0xf];
s[5] = hex[value >> 8 & 0xf];
s[6] = hex[value >> 4 & 0xf];
s[7] = hex[value & 0xf];
return new String(s);
}
public static final byte[] decode(String value)
{
if(value == null)
{
return new byte[0];
} else
{
char chars[] = value.toCharArray();
return decode(chars, 0, chars.length);
}
}
public static final byte[] decode(char chars[], int offset, int length)
{
if(chars == null)
return new byte[0];
byte buf[] = new byte[(length + 1) / 2];
for(int i = 0; i < length; i++)
{
byte d = (byte)Character.digit(chars[offset + i], 16);
buf[i >> 1] |= d << (1 - (i & 1) << 2);
}
return buf;
}
private static char hex[] = {
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'A', 'B', 'C', 'D', 'E', 'F'
};
public Hex()
{
}
}
public Codecs()
{
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -