configurationdescriptor.java

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

JAVA
89
字号
/*
 * $Id: ConfigurationDescriptor.java,v 1.1 2003/11/25 11:41:20 epr Exp $
 */
package org.jnode.driver.usb;


/**
 * @author Ewout Prangsma (epr@users.sourceforge.net)
 */
public final class ConfigurationDescriptor extends AbstractDescriptor {

	private String configurationName;
	
	/**
	 * Initialize a new instance
	 */
	public ConfigurationDescriptor() {
		super(USB_DT_CONFIG_SIZE);
	}
	
	/**
	 * @param data
	 * @param ofs
	 * @param len
	 */
	public ConfigurationDescriptor(byte[] data, int ofs, int len) {
		super(data, ofs, len);
	}

	/**
	 * Gets the total length of data returned for this configuration.
	 */
	public final int getTotalLength() {
		return getShort(2);
	}
	
	/**
	 * Gets the number of interfaces
	 */
	public final int getNumInterfaces() {
		return getByte(4);
	}
	
	/**
	 * Gets the value to use as an argument to SetConfiguration.
	 */
	public final int getConfigurationValue() {
		return getByte(5);
	}
	
	/**
	 * Gets the index of string descriptor describing this configuration.
	 */
	public final int getConfigurationStringIndex() {
		return getByte(6);
	}
	
	/**
	 * @return Returns the configuration.
	 */
	public final String getConfigurationName() {
		return this.configurationName;
	}

	/**
	 * Load all strings with the default Language ID.
	 * @param dev
	 */
	final void loadStrings(USBDevice dev) 
	throws USBException {
		final int cIdx = getConfigurationStringIndex();
		if (cIdx > 0) {
			configurationName = dev.getString(cIdx, 0);
		} 
	}

	/**
	 * Convert to a String representation 
	 * @see java.lang.Object#toString()
	 */
	public final String toString() {
		return "CONF[totlen:" + getTotalLength() +
			", #intf:" + getNumInterfaces() +
			", cnfval:" + getConfigurationValue() +
			", name:" + ((configurationName != null) ? configurationName : ("%" + getConfigurationStringIndex())) + "]";
	}

}

⌨️ 快捷键说明

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