⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ddbasehelpers.java

📁 java 文件下载器。可自定义
💻 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:   DDBaseHelpers.java

package org.gudy.azureus2.pluginsimpl.local.ddb;

import java.io.*;
import org.gudy.azureus2.core3.util.HashWrapper;
import org.gudy.azureus2.core3.util.SHA1Simple;
import org.gudy.azureus2.plugins.ddb.DistributedDatabaseException;

public class DDBaseHelpers
{

	public DDBaseHelpers()
	{
	}

	protected static byte[] encode(Object obj)
		throws DistributedDatabaseException
	{
		if (obj == null)
			throw new DistributedDatabaseException("null not supported");
		byte res[];
		if (obj instanceof byte[])
			res = (byte[])(byte[])obj;
		else
		if (obj instanceof String)
		{
			try
			{
				res = ((String)obj).getBytes("UTF-8");
			}
			catch (UnsupportedEncodingException e)
			{
				throw new DistributedDatabaseException("charset error", e);
			}
		} else
		{
			if ((obj instanceof Byte) || (obj instanceof Short) || (obj instanceof Integer) || (obj instanceof Long) || (obj instanceof Float) || (obj instanceof Double) || (obj instanceof Boolean))
				throw new DistributedDatabaseException("not supported yet!");
			try
			{
				ByteArrayOutputStream baos = new ByteArrayOutputStream();
				ObjectOutputStream oos = new ObjectOutputStream(baos);
				oos.writeObject(obj);
				oos.close();
				res = baos.toByteArray();
			}
			catch (Throwable e)
			{
				throw new DistributedDatabaseException("encoding fails", e);
			}
		}
		return res;
	}

	protected static Object decode(Class target, byte data[])
		throws DistributedDatabaseException
	{
		if (target == [B)
			return data;
		if (target != java/lang/String)
			break MISSING_BLOCK_LABEL_39;
		return new String(data, "UTF-8");
		UnsupportedEncodingException e;
		e;
		throw new DistributedDatabaseException("charset error", e);
		Object res;
		ObjectInputStream iis = new ObjectInputStream(new ByteArrayInputStream(data));
		res = iis.readObject();
		if (target.isInstance(res))
			return res;
		try
		{
			throw new DistributedDatabaseException("decoding fails, incompatible type");
		}
		// Misplaced declaration of an exception variable
		catch (ObjectInputStream iis)
		{
			throw iis;
		}
		// Misplaced declaration of an exception variable
		catch (ObjectInputStream iis)
		{
			throw new DistributedDatabaseException("decoding fails", iis);
		}
	}

	protected static HashWrapper getKey(Class c)
		throws DistributedDatabaseException
	{
		String name = c.getName();
		if (name == null)
			throw new DistributedDatabaseException((new StringBuilder()).append("name doesn't exist for '").append(c.getName()).append("'").toString());
		else
			return new HashWrapper((new SHA1Simple()).calculateHash(name.getBytes()));
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -