📄 localeutildecoderfallback.java
字号:
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space
// Source File Name: LocaleUtilDecoderFallback.java
package org.gudy.azureus2.core3.internat;
import java.io.File;
import java.io.UnsupportedEncodingException;
import org.gudy.azureus2.core3.util.ByteFormatter;
import org.gudy.azureus2.core3.util.SHA1Hasher;
// Referenced classes of package org.gudy.azureus2.core3.internat:
// LocaleUtilDecoder
public class LocaleUtilDecoderFallback
implements LocaleUtilDecoder
{
public static String NAME = "Fallback";
private static volatile int max_ok_name_length = 64;
private static volatile boolean max_ok_name_length_determined;
private static final String VALID_CHARS = "abcdefghijklmnopqrstuvwxyz1234567890_-.";
private int index;
protected LocaleUtilDecoderFallback(int _index)
{
index = _index;
}
public String getName()
{
return NAME;
}
public int getIndex()
{
return index;
}
public String tryDecode(byte bytes[], boolean lax)
{
return decode(bytes);
}
public String decodeString(byte bytes[])
throws UnsupportedEncodingException
{
return decode(bytes);
}
protected String decode(byte data[])
{
if (data == null)
return null;
StringBuffer res = new StringBuffer(data.length * 2);
for (int i = 0; i < data.length; i++)
{
byte c = data[i];
if ("abcdefghijklmnopqrstuvwxyz1234567890_-.".indexOf(Character.toLowerCase((char)c)) != -1)
{
res.append((char)c);
} else
{
res.append("_");
res.append(ByteFormatter.nicePrint(c));
}
}
int len = res.length();
if (len > max_ok_name_length)
if (!max_ok_name_length_determined && fileLengthOK(len))
{
max_ok_name_length = len;
} else
{
if (!max_ok_name_length_determined)
{
for (int i = max_ok_name_length + 16; i < len && fileLengthOK(i); i += 16)
max_ok_name_length = i;
max_ok_name_length_determined = true;
}
String extension = null;
int pos = res.lastIndexOf(".");
if (pos != -1)
{
extension = res.substring(pos);
if (extension.length() == 1 || extension.length() > 4)
extension = null;
}
byte hash[] = (new SHA1Hasher()).calculateHash(data);
String hash_str = ByteFormatter.nicePrint(hash, true);
res = new StringBuffer(res.substring(0, max_ok_name_length - hash_str.length() - (extension != null ? extension.length() : 0)));
res.append(hash_str);
if (extension != null)
res.append(extension);
}
return res.toString();
}
protected boolean fileLengthOK(int len)
{
StringBuffer n;
n = new StringBuffer(len);
for (int i = 0; i < len; i++)
n.append("A");
File f = File.createTempFile(n.toString(), "");
f.delete();
return true;
Throwable e;
e;
return false;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -