All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.usb4java.javax.RootHubInterface Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (C) 2011 Klaus Reimer 
 * See LICENSE.md for licensing information.
 */

package org.usb4java.javax;

import java.util.ArrayList;
import java.util.List;

import javax.usb.UsbConfiguration;
import javax.usb.UsbConst;
import javax.usb.UsbEndpoint;
import javax.usb.UsbException;
import javax.usb.UsbInterface;
import javax.usb.UsbInterfaceDescriptor;
import javax.usb.UsbInterfacePolicy;

import org.usb4java.javax.descriptors.SimpleUsbInterfaceDescriptor;

/**
 * The virtual USB interfaces used by the virtual USB root hub.
 *
 * @author Klaus Reimer ([email protected])
 */
final class RootHubInterface implements UsbInterface
{
    /** The list of endpoints. */
    private final List endpoints = new ArrayList(0);

    /** The list of alternate settings. */
    private final List settings = new ArrayList(0);

    /** The USB configuration. */
    private final UsbConfiguration configuration;

    /** The interface descriptor. */
    private final UsbInterfaceDescriptor descriptor =
        new SimpleUsbInterfaceDescriptor(
            UsbConst.DESCRIPTOR_MIN_LENGTH_INTERFACE,
            UsbConst.DESCRIPTOR_TYPE_INTERFACE,
            (byte) 0,
            (byte) 0,
            (byte) 0,
            UsbConst.HUB_CLASSCODE,
            (byte) 0,
            (byte) 0,
            (byte) 0);

    /**
     * Constructor.
     *
     * @param configuration
     *            The USB configuration.
     */
    RootHubInterface(final UsbConfiguration configuration)
    {
        this.configuration = configuration;
    }

    @Override
    public void claim() throws UsbException
    {
        throw new UsbException("Virtual interfaces can't be claimed");
    }

    @Override
    public void claim(final UsbInterfacePolicy policy) throws UsbException
    {
        throw new UsbException("Virtual interfaces can't be claimed");
    }

    @Override
    public void release() throws UsbException
    {
        throw new UsbException("Virtual interfaces can't be released");
    }

    @Override
    public boolean isClaimed()
    {
        return true;
    }

    @Override
    public boolean isActive()
    {
        return true;
    }

    @Override
    public int getNumSettings()
    {
        return 0;
    }

    @Override
    public byte getActiveSettingNumber()
    {
        return 0;
    }

    @Override
    public UsbInterface getActiveSetting()
    {
        return this;
    }

    @Override
    public UsbInterface getSetting(final byte number)
    {
        return this;
    }

    @Override
    public boolean containsSetting(final byte number)
    {
        return false;
    }

    @Override
    public List getSettings()
    {
        return this.settings;
    }

    @Override
    public List getUsbEndpoints()
    {
        return this.endpoints;
    }

    @Override
    public UsbEndpoint getUsbEndpoint(final byte address)
    {
        return null;
    }

    @Override
    public boolean containsUsbEndpoint(final byte address)
    {
        return false;
    }

    @Override
    public UsbConfiguration getUsbConfiguration()
    {
        return this.configuration;
    }

    @Override
    public UsbInterfaceDescriptor getUsbInterfaceDescriptor()
    {
        return this.descriptor;
    }

    @Override
    public String getInterfaceString()
    {
        return null;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy