abstractusbrequest.java

来自「纯java操作系统jnode,安装简单和操作简单的个人使用的Java操作系统」· Java 代码 · 共 81 行

JAVA
81
字号
/*
 * $Id: AbstractUSBRequest.java,v 1.1 2003/11/25 11:42:29 epr Exp $
 */
package org.jnode.driver.usb.spi;

import org.jnode.driver.usb.USBRequest;

/**
 * @author Ewout Prangsma (epr@users.sourceforge.net)
 */
public class AbstractUSBRequest implements USBRequest {

	private int actualLength = 0;
	private boolean completed = false;
	private int status = 0;

	/**
	 * Gets the actual transfered data length.
	 * 
	 * @return Returns the actualLength.
	 */
	public int getActualLength() {
		return actualLength;
	}

	/**
	 * Has this request bee completed.
	 */
	public boolean isCompleted() {
		return completed;
	}

	/**
	 * Gets the status of as this request.
	 */
	public int getStatus() {
		return status;
	}

	/**
	 * @param actualLength
	 *            The actualLength to set.
	 */
	public void setActualLength(int actualLength) {
		this.actualLength = actualLength;
	}

	/**
	 * The status and actual must be set, before calling this method.
	 * @param completed
	 *            The completed to set.
	 */
	public synchronized void setCompleted(boolean completed) {
		this.completed = completed;
		notifyAll();
	}

	/**
	 * @param status
	 *            The status to set.
	 */
	public void setStatus(int status) {
		this.status = status;
	}

	/**
	 * Wait for this request to complete, or until a timeout occurs.
	 * 
	 * @param timeout
	 */
	public synchronized void waitUntilComplete(long timeout) {
		while (!isCompleted()) {
			try {
				wait(timeout);
			} catch (InterruptedException ex) {
				// Ignore
			}
		}
	}
}

⌨️ 快捷键说明

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