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

📄 cocoajavabridge.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:   CocoaJavaBridge.java

package org.gudy.azureus2.platform.macosx.access.cocoa;

import com.apple.cocoa.foundation.*;
import java.io.File;
import java.text.MessageFormat;
import org.gudy.azureus2.core3.logging.LogAlert;
import org.gudy.azureus2.core3.logging.Logger;
import org.gudy.azureus2.core3.util.*;
import org.gudy.azureus2.platform.macosx.NativeInvocationBridge;

public final class CocoaJavaBridge extends NativeInvocationBridge
{
	private static class RunnableDispatcher
	{

		private void exec(Runnable runnable)
		{
			synchronized (this)
			{
				runnable.run();
			}
		}


		private RunnableDispatcher()
		{
		}

	}


	protected static final String CLASS_PATH = "/system/library/java";
	private static final String REVEAL_SCRIPT_FORMAT = "tell application \"System Events\"\ntell application \"{0}\"\nactivate\nreveal (posix file \"{1}\" as alias)\nend tell\nend tell";
	private static final String DEL_SCRIPT_FORMAT = "tell application \"Finder\" to move (posix file \"{0}\" as alias) to the trash";
	private int mainPool;
	protected AEMonitor classMon;
	private AEMonitor scriptMon;
	protected boolean isDisposed;
	protected RunnableDispatcher scriptDispatcher;

	public CocoaJavaBridge()
	{
		classMon = new AEMonitor("CocoaJavaBridge:C");
		scriptMon = new AEMonitor("CocoaJavaBridge:S");
		isDisposed = false;
		classMon.enter();
		mainPool = NSAutoreleasePool.push();
		scriptDispatcher = new RunnableDispatcher();
		classMon.exit();
		break MISSING_BLOCK_LABEL_81;
		Exception exception;
		exception;
		classMon.exit();
		throw exception;
	}

	protected boolean performRecoverableFileDelete(File path)
	{
		if (!path.exists())
			return false;
		NSAppleEventDescriptor result = executeScriptWithAsync("tell application \"Finder\" to move (posix file \"{0}\" as alias) to the trash", new Object[] {
			path.getAbsolutePath()
		});
		if (result != null)
		{
			int sleep = 25;
			int sleep_to_go = 2500;
			do
			{
				if (!path.exists() || sleep_to_go <= 0)
					break;
				try
				{
					Thread.sleep(25L);
					sleep_to_go -= 25;
					continue;
				}
				catch (Throwable e) { }
				break;
			} while (true);
			if (path.exists())
				Debug.outNoStack((new StringBuilder()).append("Gave up waiting for delete to complete for ").append(path).toString());
		}
		return result != null;
	}

	protected boolean showInFinder(File path, String fileBrowserApp)
	{
		NSAppleEventDescriptor result;
		int pool;
		if (!path.exists())
			return false;
		result = null;
		pool = NSAutoreleasePool.push();
		result = executeScriptWithAsync("tell application \"System Events\"\ntell application \"{0}\"\nactivate\nreveal (posix file \"{1}\" as alias)\nend tell\nend tell", new Object[] {
			fileBrowserApp, path.getAbsolutePath()
		});
		NSAutoreleasePool.pop(pool);
		break MISSING_BLOCK_LABEL_56;
		Exception exception;
		exception;
		NSAutoreleasePool.pop(pool);
		throw exception;
		return result != null;
	}

	protected boolean isEnabled()
	{
		return System.getProperty("java.class.path").toLowerCase().indexOf("/system/library/java") != -1;
	}

	protected final NSAppleEventDescriptor executeScript(String scriptFormat, Object params[])
	{
		NSAppleEventDescriptor nsappleeventdescriptor;
		scriptMon.enter();
		int pool = NSAutoreleasePool.push();
		long start = System.currentTimeMillis();
		String src;
		if (params == null || params.length == 0)
			src = scriptFormat;
		else
			src = MessageFormat.format(scriptFormat, params);
		Debug.outNoStack((new StringBuilder()).append("Executing: \n").append(src).toString());
		NSAppleScript scp = new NSAppleScript(src);
		NSAppleEventDescriptor result = scp.execute(new NSMutableDictionary());
		Debug.outNoStack(MessageFormat.format("Elapsed time: {0}ms\n", new Object[] {
			new Long(System.currentTimeMillis() - start)
		}));
		NSAutoreleasePool.pop(pool);
		nsappleeventdescriptor = result;
		scriptMon.exit();
		return nsappleeventdescriptor;
		Exception exception;
		exception;
		scriptMon.exit();
		throw exception;
	}

	protected final NSAppleEventDescriptor executeScriptWithNewThread(String scriptFormat, Object params[])
	{
		Thread worker = new AEThread(params, scriptFormat) {

			final Object val$params[];
			final String val$scriptFormat;
			final CocoaJavaBridge this$0;

			public void runSupport()
			{
				int pool = NSAutoreleasePool.push();
				long start = System.currentTimeMillis();
				String src;
				if (params == null || params.length == 0)
					src = scriptFormat;
				else
					src = MessageFormat.format(scriptFormat, params);
				Debug.outNoStack((new StringBuilder()).append("Executing: \n").append(src).toString());
				NSMutableDictionary errorInfo = new NSMutableDictionary();
				if ((new NSAppleScript(src)).execute(errorInfo) == null)
					Debug.out(String.valueOf(errorInfo.objectForKey("NSAppleScriptErrorMessage")));
				Debug.outNoStack(MessageFormat.format("Elapsed time: {0}ms\n", new Object[] {
					new Long(System.currentTimeMillis() - start)
				}));
				NSAutoreleasePool.pop(pool);
			}

			
			{
				this$0 = CocoaJavaBridge.this;
				params = aobj;
				scriptFormat = s;
				super(x0, x1);
			}
		};
		worker.setPriority(4);
		worker.start();
		return NSAppleEventDescriptor.descriptorWithBoolean(true);
	}

	protected final NSAppleEventDescriptor executeScriptWithAsync(final String scriptFormat, final Object params[])
	{
		AERunnable worker = new AERunnable() {

			final Object val$params[];
			final String val$scriptFormat;
			final CocoaJavaBridge this$0;

			public void runSupport()
			{
				int pool = NSAutoreleasePool.push();
				long start = System.currentTimeMillis();
				String src;
				if (params == null || params.length == 0)
					src = scriptFormat;
				else
					src = MessageFormat.format(scriptFormat, params);
				Debug.outNoStack((new StringBuilder()).append("Executing: \n").append(src).toString());
				NSMutableDictionary errorInfo = new NSMutableDictionary();
				if ((new NSAppleScript(src)).execute(errorInfo) == null)
					Debug.out(String.valueOf(errorInfo.objectForKey("NSAppleScriptErrorMessage")));
				Debug.outNoStack(MessageFormat.format("Elapsed time: {0}ms\n", new Object[] {
					new Long(System.currentTimeMillis() - start)
				}));
				NSAutoreleasePool.pop(pool);
			}

			
			{
				this$0 = CocoaJavaBridge.this;
				params = aobj;
				scriptFormat = s;
				super();
			}
		};
		AEThread t = new AEThread(true, worker) {

			final AERunnable val$worker;
			final CocoaJavaBridge this$0;

			public void runSupport()
			{
				scriptDispatcher.exec(worker);
			}

			
			{
				this$0 = CocoaJavaBridge.this;
				worker = aerunnable;
				super(x0, x1);
			}
		};
		t.setPriority(4);
		t.start();
		return NSAppleEventDescriptor.descriptorWithBoolean(true);
	}

	private void logWarning(String message)
	{
		classMon.enter();
		Logger.log(new LogAlert(false, 1, message));
		classMon.exit();
		break MISSING_BLOCK_LABEL_40;
		Exception exception;
		exception;
		classMon.exit();
		throw exception;
	}

	protected void dispose()
	{
		classMon.enter();
		if (!isDisposed)
		{
			Debug.outNoStack("Disposing Native PlatformManager...");
			NSAutoreleasePool.pop(mainPool);
			isDisposed = true;
			Debug.outNoStack("Done");
		}
		classMon.exit();
		break MISSING_BLOCK_LABEL_56;
		Exception exception;
		exception;
		classMon.exit();
		throw exception;
	}

	protected void finalize()
		throws Throwable
	{
		dispose();
		super.finalize();
	}
}

⌨️ 快捷键说明

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