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

📄 directbytebuffer.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:   DirectByteBuffer.java

package org.gudy.azureus2.core3.util;

import java.io.IOException;
import java.io.PrintStream;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.channels.SocketChannel;

// Referenced classes of package org.gudy.azureus2.core3.util:
//			Debug, DirectByteBufferPool, ReferenceCountedDirectByteBuffer

public class DirectByteBuffer
{

	public static final byte AL_NONE = 0;
	public static final byte AL_EXTERNAL = 1;
	public static final byte AL_OTHER = 2;
	public static final byte AL_PT_READ = 3;
	public static final byte AL_PT_LENGTH = 4;
	public static final byte AL_CACHE_READ = 5;
	public static final byte AL_DM_READ = 6;
	public static final byte AL_DM_ZERO = 7;
	public static final byte AL_DM_CHECK = 8;
	public static final byte AL_BT_PIECE = 9;
	public static final byte AL_CACHE_WRITE = 10;
	public static final byte AL_PROXY_RELAY = 11;
	public static final byte AL_MSG = 12;
	public static final byte AL_MSG_AZ_HAND = 13;
	public static final byte AL_MSG_AZ_PEX = 14;
	public static final byte AL_MSG_BT_CANCEL = 15;
	public static final byte AL_MSG_BT_HAND = 16;
	public static final byte AL_MSG_BT_HAVE = 17;
	public static final byte AL_MSG_BT_PIECE = 18;
	public static final byte AL_MSG_BT_REQUEST = 19;
	public static final byte AL_MSG_BT_KEEPALIVE = 20;
	public static final byte AL_MSG_BT_HEADER = 21;
	public static final byte AL_MSG_AZ_HEADER = 22;
	public static final byte AL_MSG_BT_PAYLOAD = 23;
	public static final byte AL_MSG_AZ_PAYLOAD = 24;
	public static final byte AL_FILE = 25;
	public static final byte AL_NET_CRYPT = 26;
	public static final byte AL_MSG_LT_EXT_MESSAGE = 27;
	public static final byte AL_MSG_LT_HANDSHAKE = 28;
	public static final byte AL_MSG_UT_PEX = 29;
	public static final byte AL_MSG_BT_DHT_PORT = 30;
	public static final String AL_DESCS[] = {
		"None", "Ext", "Other", "PeerRead", "PeerLen", "CacheRead", "DiskRead", "DiskZero", "DiskCheck", "BTPiece", 
		"CacheWrite", "ProxyRelay", "Messaging", "AZHandshake", "AZPEX", "BTCancel", "BTHandshake", "BTHave", "BTPiece", "BTRequest", 
		"BTKeepAlive", "BTHeader", "AZHeader", "BTPayload", "AZPayload", "File", "MsgCrypt", "LTExtMsg", "LTExtHandshake", "UTPEX", 
		"BTDHTPort"
	};
	public static final byte SS_NONE = 0;
	public static final byte SS_EXTERNAL = 1;
	public static final byte SS_OTHER = 2;
	public static final byte SS_CACHE = 3;
	public static final byte SS_FILE = 4;
	public static final byte SS_NET = 5;
	public static final byte SS_BT = 6;
	public static final byte SS_DR = 7;
	public static final byte SS_DW = 8;
	public static final byte SS_PEER = 9;
	public static final byte SS_PROXY = 10;
	public static final byte SS_MSG = 11;
	public static final String SS_DESCS[] = {
		"None", "Ext", "Other", "Cache", "File", "Net", "BT", "DiskRead", "DiskWrite", "Peer", 
		"Proxy", "Messaging"
	};
	public static final byte OP_LIMIT = 0;
	public static final byte OP_LIMIT_INT = 1;
	public static final byte OP_POSITION = 2;
	public static final byte OP_POSITION_INT = 3;
	public static final byte OP_CLEAR = 4;
	public static final byte OP_FLIP = 5;
	public static final byte OP_REMANING = 6;
	public static final byte OP_CAPACITY = 7;
	public static final byte OP_PUT_BYTEARRAY = 8;
	public static final byte OP_PUT_DBB = 9;
	public static final byte OP_PUT_BB = 10;
	public static final byte OP_PUTINT = 11;
	public static final byte OP_PUT_BYTE = 12;
	public static final byte OP_GET = 13;
	public static final byte OP_GET_INT = 14;
	public static final byte OP_GET_BYTEARRAY = 15;
	public static final byte OP_GETINT = 16;
	public static final byte OP_GETINT_INT = 17;
	public static final byte OP_HASREMAINING = 18;
	public static final byte OP_READ_FC = 19;
	public static final byte OP_WRITE_FC = 20;
	public static final byte OP_READ_SC = 21;
	public static final byte OP_WRITE_SC = 22;
	public static final byte OP_GETBUFFER = 23;
	public static final byte OP_GETSHORT = 24;
	public static final byte OP_PUTSHORT = 25;
	public static final String OP_DESCS[] = {
		"limit", "limit(int)", "position", "position(int)", "clear", "flip", "remaining", "capacity", "put(byte[])", "put(dbb)", 
		"put(bbb)", "putInt", "put(byte)", "get", "get(int)", "get(byte[])", "getInt", "getInt(int", "hasRemaining", "read(fc)", 
		"write(fc)", "read(sc)", "write(sc)", "getBuffer", "getShort", "putShort"
	};
	protected static final boolean TRACE = false;
	protected static final int TRACE_BUFFER_SIZE = 64;
	private ByteBuffer buffer;
	private DirectByteBufferPool pool;
	private byte allocator;
	private boolean was_returned_to_pool;

	public DirectByteBuffer(ByteBuffer _buffer)
	{
		this((byte)0, _buffer, null);
	}

	public DirectByteBuffer(byte _allocator, ByteBuffer _buffer, DirectByteBufferPool _pool)
	{
		was_returned_to_pool = false;
		if (_buffer == null)
		{
			throw new NullPointerException("buffer is null");
		} else
		{
			allocator = _allocator;
			buffer = _buffer;
			pool = _pool;
			return;
		}
	}

	protected DirectByteBuffer(DirectByteBuffer basis)
	{
		was_returned_to_pool = false;
		allocator = basis.allocator;
		buffer = basis.buffer;
		pool = null;
		if (buffer == null)
			throw new NullPointerException("basis.buffer is null");
		else
			return;
	}

	public ReferenceCountedDirectByteBuffer getReferenceCountedBuffer()
	{
		ReferenceCountedDirectByteBuffer res = new ReferenceCountedDirectByteBuffer(this);
		return res;
	}

	protected void traceUsage(byte byte0, byte byte1)
	{
	}

	protected String getTraceString()
	{
		return null;
	}

	protected void dumpTrace(Throwable throwable)
	{
	}

	protected ByteBuffer getBufferInternal()
	{
		return buffer;
	}

	protected byte getAllocator()
	{
		return allocator;
	}

	public int limit(byte subsystem)
	{
		return buffer.limit();
	}

	public void limit(byte subsystem, int l)
	{
		if (buffer == null)
			System.out.println((new StringBuilder()).append("Trying to limit null buffer - returned? ").append(was_returned_to_pool).toString());
		buffer.limit(l);
	}

	public int position(byte subsystem)
	{
		return buffer.position();
	}

	public void position(byte subsystem, int l)
	{
		buffer.position(l);
	}

	public void clear(byte subsystem)
	{
		buffer.clear();
	}

	public void flip(byte subsystem)
	{
		buffer.flip();
	}

	public int remaining(byte subsystem)
	{
		return buffer.remaining();
	}

	public int capacity(byte subsystem)
	{
		return buffer.capacity();
	}

	public void put(byte subsystem, byte data[])
	{
		buffer.put(data);
	}

	public void put(byte subsystem, byte data[], int offset, int length)
	{
		buffer.put(data, offset, length);
	}

	public void put(byte subsystem, DirectByteBuffer data)
	{
		buffer.put(data.buffer);
	}

	public void put(byte subsystem, ByteBuffer data)
	{
		buffer.put(data);
	}

	public void put(byte subsystem, byte data)
	{
		buffer.put(data);
	}

	public void putShort(byte subsystem, short x)
	{
		buffer.putShort(x);
	}

	public void putInt(byte subsystem, int data)
	{
		buffer.putInt(data);
	}

	public byte get(byte subsystem)
	{
		return buffer.get();
	}

	public byte get(byte subsystem, int x)
	{
		return buffer.get(x);
	}

	public void get(byte subsystem, byte data[])
	{
		buffer.get(data);
	}

	public short getShort(byte subsystem)
	{
		return buffer.getShort();
	}

	public int getInt(byte subsystem)
	{
		return buffer.getInt();
	}

	public int getInt(byte subsystem, int x)
	{
		return buffer.getInt(x);
	}

	public boolean hasRemaining(byte subsystem)
	{
		return buffer.hasRemaining();
	}

	public int read(byte subsystem, FileChannel chan)
		throws IOException
	{
		return chan.read(buffer);
		IllegalArgumentException e;
		e;
		dumpTrace(e);
		throw e;
	}

	public int write(byte subsystem, FileChannel chan)
		throws IOException
	{
		return chan.write(buffer);
		IllegalArgumentException e;
		e;
		dumpTrace(e);
		throw e;
	}

	public int read(byte subsystem, SocketChannel chan)
		throws IOException
	{
		return chan.read(buffer);
		IllegalArgumentException e;
		e;
		dumpTrace(e);
		throw e;
	}

	public int write(byte subsystem, SocketChannel chan)
		throws IOException
	{
		return chan.write(buffer);
		IllegalArgumentException e;
		e;
		dumpTrace(e);
		throw e;
	}

	public ByteBuffer getBuffer(byte subsystem)
	{
		return buffer;
	}

	public void returnToPool()
	{
		if (pool != null)
			synchronized (this)
			{
				if (buffer == null)
				{
					Debug.out("Buffer already returned to pool");
				} else
				{
					pool.returnBufferSupport(this);
					buffer = null;
					was_returned_to_pool = true;
				}
			}
	}

	public void returnToPoolIfNotFree()
	{
		if (pool != null)
			synchronized (this)
			{
				if (buffer != null)
				{
					pool.returnBufferSupport(this);
					buffer = null;
					was_returned_to_pool = true;
				}
			}
	}

}

⌨️ 快捷键说明

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