Rename JSR80 classes to short names and make everything package-private

This commit is contained in:
Klaus Reimer 2013-04-13 11:39:17 +02:00
parent d3f6baf840
commit 21e57b9375
21 changed files with 157 additions and 159 deletions

View File

@ -41,10 +41,10 @@ import de.ailis.usb4java.support.UsbDeviceListenerList;
*
* @author Klaus Reimer (k@ailis.de)
*/
abstract class Usb4JavaDevice implements UsbDevice
abstract class AbstractDevice implements UsbDevice
{
/** The USB device manager. */
private final UsbDeviceManager manager;
private final DeviceManager manager;
/** The device id. */
private final DeviceId id;
@ -56,11 +56,11 @@ abstract class Usb4JavaDevice implements UsbDevice
private final int speed;
/** The device configurations. */
private List<Usb4JavaConfiguration> configurations;
private List<Configuration> configurations;
/** Mapping from configuration value to configuration. */
private Map<Byte, Usb4JavaConfiguration> configMapping =
new HashMap<Byte, Usb4JavaConfiguration>();
private Map<Byte, Configuration> configMapping =
new HashMap<Byte, Configuration>();
/** The USB device listener list. */
private final UsbDeviceListenerList listeners = new UsbDeviceListenerList();
@ -103,7 +103,7 @@ abstract class Usb4JavaDevice implements UsbDevice
* @throws LibUsbException
* When device configuration could not be read.
*/
Usb4JavaDevice(final UsbDeviceManager manager, final DeviceId id,
AbstractDevice(final DeviceManager manager, final DeviceId id,
final DeviceId parentId, final int speed, final Device device)
throws LibUsbException
{
@ -118,8 +118,8 @@ abstract class Usb4JavaDevice implements UsbDevice
// Read device configurations
final int numConfigurations =
id.getDeviceDescriptor().bNumConfigurations() & 0xff;
final List<Usb4JavaConfiguration> configurations =
new ArrayList<Usb4JavaConfiguration>(numConfigurations);
final List<Configuration> configurations =
new ArrayList<Configuration>(numConfigurations);
for (int i = 0; i < numConfigurations; i += 1)
{
final ConfigDescriptor configDescriptor = new ConfigDescriptor();
@ -132,7 +132,7 @@ abstract class Usb4JavaDevice implements UsbDevice
}
try
{
final Usb4JavaConfiguration config = new Usb4JavaConfiguration(
final Configuration config = new Configuration(
this, configDescriptor);
configurations.add(config);
this.configMapping.put(configDescriptor.bConfigurationValue(),
@ -256,8 +256,8 @@ abstract class Usb4JavaDevice implements UsbDevice
// Disconnect client devices
if (port == null && isUsbHub())
{
final Usb4JavaHub hub = (Usb4JavaHub) this;
for (final Usb4JavaDevice device: hub.getAttachedUsbDevices())
final Hub hub = (Hub) this;
for (final AbstractDevice device: hub.getAttachedUsbDevices())
{
hub.disconnectUsbDevice(device);
}
@ -333,13 +333,13 @@ abstract class Usb4JavaDevice implements UsbDevice
}
@Override
public final List<Usb4JavaConfiguration> getUsbConfigurations()
public final List<Configuration> getUsbConfigurations()
{
return this.configurations;
}
@Override
public final Usb4JavaConfiguration getUsbConfiguration(final byte number)
public final Configuration getUsbConfiguration(final byte number)
{
return this.configMapping.get(number);
}
@ -466,7 +466,7 @@ abstract class Usb4JavaDevice implements UsbDevice
}
@Override
public final Usb4JavaConfiguration getActiveUsbConfiguration()
public final Configuration getActiveUsbConfiguration()
{
return getUsbConfiguration(getActiveUsbConfigurationNumber());
}

View File

@ -21,7 +21,7 @@ import de.ailis.usb4java.support.Config;
* @param <T>
* The type of IRPs this queue holds.
*/
public abstract class AbstractIrpQueue<T extends UsbIrp>
abstract class AbstractIrpQueue<T extends UsbIrp>
{
/** The queued packets. */
private final Queue<T> irps = new ConcurrentLinkedQueue<T>();
@ -30,7 +30,7 @@ public abstract class AbstractIrpQueue<T extends UsbIrp>
private Thread processor;
/** The USB device. */
private final Usb4JavaDevice device;
private final AbstractDevice device;
/**
* Constructor.
@ -38,7 +38,7 @@ public abstract class AbstractIrpQueue<T extends UsbIrp>
* @param device
* The USB device. Must not be null.
*/
public AbstractIrpQueue(final Usb4JavaDevice device)
AbstractIrpQueue(final AbstractDevice device)
{
if (device == null)
throw new IllegalArgumentException("device must be set");
@ -189,7 +189,7 @@ public abstract class AbstractIrpQueue<T extends UsbIrp>
*
* @return The USB device. Never null.
*/
protected final Usb4JavaDevice getDevice()
protected final AbstractDevice getDevice()
{
return this.device;
}

View File

@ -19,7 +19,6 @@ import javax.usb.UsbException;
import de.ailis.usb4java.descriptors.SimpleUsbConfigurationDescriptor;
import de.ailis.usb4java.libusb.ConfigDescriptor;
import de.ailis.usb4java.libusb.Interface;
import de.ailis.usb4java.libusb.InterfaceDescriptor;
import de.ailis.usb4java.libusb.LibUSB;
import de.ailis.usb4java.libusb.LibUsbException;
@ -29,24 +28,24 @@ import de.ailis.usb4java.libusb.LibUsbException;
*
* @author Klaus Reimer (k@ailis.de)
*/
public final class Usb4JavaConfiguration implements UsbConfiguration
final class Configuration implements UsbConfiguration
{
/** The configurationDescriptor. */
private final UsbConfigurationDescriptor descriptor;
/** The USB device this configuration belongs to. */
private final Usb4JavaDevice device;
private final AbstractDevice device;
/**
* The interfaces. This is a map from interface number to a map of alternate
* settings which maps setting numbers to actual interfaces.
*/
private final Map<Integer, Map<Integer, Usb4JavaInterface>> interfaces =
new HashMap<Integer, Map<Integer, Usb4JavaInterface>>();
private final Map<Integer, Map<Integer, Interface>> interfaces =
new HashMap<Integer, Map<Integer, Interface>>();
/** This map contains the active USB interfaces. */
private final Map<Integer, Usb4JavaInterface> activeSettings =
new HashMap<Integer, Usb4JavaInterface>();
private final Map<Integer, Interface> activeSettings =
new HashMap<Integer, Interface>();
/**
* Constructor.
@ -56,12 +55,12 @@ public final class Usb4JavaConfiguration implements UsbConfiguration
* @param descriptor
* The libusb configuration descriptor.
*/
Usb4JavaConfiguration(final Usb4JavaDevice device,
Configuration(final AbstractDevice device,
final ConfigDescriptor descriptor)
{
this.device = device;
this.descriptor = new SimpleUsbConfigurationDescriptor(descriptor);
for (Interface iface: descriptor.iface())
for (de.ailis.usb4java.libusb.Interface iface: descriptor.iface())
{
for (InterfaceDescriptor ifaceDescriptor: iface.altsetting())
{
@ -70,15 +69,15 @@ public final class Usb4JavaConfiguration implements UsbConfiguration
final int settingNumber =
ifaceDescriptor.bAlternateSetting() & 0xff;
Map<Integer, Usb4JavaInterface> settings = this.interfaces
Map<Integer, Interface> settings = this.interfaces
.get(ifaceNumber);
if (settings == null)
{
settings = new HashMap<Integer, Usb4JavaInterface>();
settings = new HashMap<Integer, Interface>();
this.interfaces.put(ifaceNumber, settings);
}
final Usb4JavaInterface usbInterface =
new Usb4JavaInterface(this, ifaceDescriptor);
final Interface usbInterface =
new Interface(this, ifaceDescriptor);
// If we have no active setting for current interface number
// yet or the alternate setting number is 0 (which marks the
@ -115,9 +114,9 @@ public final class Usb4JavaConfiguration implements UsbConfiguration
}
@Override
public List<Usb4JavaInterface> getUsbInterfaces()
public List<Interface> getUsbInterfaces()
{
return Collections.unmodifiableList(new ArrayList<Usb4JavaInterface>(
return Collections.unmodifiableList(new ArrayList<Interface>(
this.activeSettings.values()));
}
@ -128,7 +127,7 @@ public final class Usb4JavaConfiguration implements UsbConfiguration
* The interface number.
* @return The alternate settings for the specified interface.
*/
Map<Integer, Usb4JavaInterface> getSettings(final byte number)
Map<Integer, Interface> getSettings(final byte number)
{
return this.interfaces.get(number & 0xff);
}
@ -146,7 +145,7 @@ public final class Usb4JavaConfiguration implements UsbConfiguration
}
@Override
public Usb4JavaInterface getUsbInterface(final byte number)
public Interface getUsbInterface(final byte number)
{
return this.activeSettings.get(number & 0xff);
}
@ -161,7 +160,7 @@ public final class Usb4JavaConfiguration implements UsbConfiguration
* @throws UsbException
* When interface setting could not be set.
*/
void setUsbInterface(final byte number, final Usb4JavaInterface iface)
void setUsbInterface(final byte number, final Interface iface)
throws UsbException
{
if (this.activeSettings.get(number & 0xff) != iface)
@ -185,7 +184,7 @@ public final class Usb4JavaConfiguration implements UsbConfiguration
}
@Override
public Usb4JavaDevice getUsbDevice()
public AbstractDevice getUsbDevice()
{
return this.device;
}

View File

@ -23,7 +23,7 @@ import de.ailis.usb4java.support.UsbDeviceListenerList;
*
* @author Klaus Reimer (k@ailis.de)
*/
public final class ControlIrpQueue extends AbstractIrpQueue<UsbControlIrp>
final class ControlIrpQueue extends AbstractIrpQueue<UsbControlIrp>
{
/** The USB device listener list. */
private final UsbDeviceListenerList listeners;
@ -36,7 +36,7 @@ public final class ControlIrpQueue extends AbstractIrpQueue<UsbControlIrp>
* @param listeners
* The USB device listener list.
*/
public ControlIrpQueue(final Usb4JavaDevice device,
ControlIrpQueue(final AbstractDevice device,
final UsbDeviceListenerList listeners)
{
super(device);

View File

@ -17,7 +17,7 @@ import de.ailis.usb4java.descriptors.SimpleUsbDeviceDescriptor;
*
* @author Klaus Reimer (k@ailis.de)
*/
public final class DeviceId implements Serializable
final class DeviceId implements Serializable
{
/** The serial versionUID. */
private static final long serialVersionUID = 1L;
@ -47,7 +47,7 @@ public final class DeviceId implements Serializable
* @param deviceDescriptor
* The device descriptor. Must not be null.
*/
public DeviceId(final int busNumber, final int deviceAddress,
DeviceId(final int busNumber, final int deviceAddress,
final int portNumber, final SimpleUsbDeviceDescriptor deviceDescriptor)
{
if (deviceDescriptor == null)

View File

@ -28,17 +28,17 @@ import de.ailis.usb4java.libusb.LibUsbException;
*
* @author Klaus Reimer (k@ailis.de)
*/
public final class UsbDeviceManager
final class DeviceManager
{
/** The scan interval in milliseconds. */
private static final int DEFAULT_SCAN_INTERVAL = 500;
/** The logger. */
private static final Logger LOG = Logger.getLogger(UsbDeviceManager.class
private static final Logger LOG = Logger.getLogger(DeviceManager.class
.getName());
/** The virtual USB root hub. */
private final VirtualRootHub rootHub;
private final RootHub rootHub;
/** The libusb context. */
private final Context context;
@ -47,8 +47,8 @@ public final class UsbDeviceManager
private boolean scanned = false;
/** The currently connected devices. */
private final Map<DeviceId, Usb4JavaDevice> devices = Collections
.synchronizedMap(new HashMap<DeviceId, Usb4JavaDevice>());
private final Map<DeviceId, AbstractDevice> devices = Collections
.synchronizedMap(new HashMap<DeviceId, AbstractDevice>());
/**
* Constructs a new device manager.
@ -58,7 +58,7 @@ public final class UsbDeviceManager
* @throws UsbException
* When USB initialization fails.
*/
public UsbDeviceManager(final VirtualRootHub rootHub) throws UsbException
DeviceManager(final RootHub rootHub) throws UsbException
{
if (rootHub == null)
throw new IllegalArgumentException("rootHub must be set");
@ -111,14 +111,14 @@ public final class UsbDeviceManager
*
* @return The connected devices.
*/
private Set<Usb4JavaDevice> getConnectedDevices()
private Set<AbstractDevice> getConnectedDevices()
{
final DeviceList devices = new DeviceList();
final int result = LibUSB.getDeviceList(this.context, devices);
if (result < 0)
throw new Usb4JavaRuntimeException("Unable to get USB device list",
result);
final Set<Usb4JavaDevice> found = new HashSet<Usb4JavaDevice>();
final Set<AbstractDevice> found = new HashSet<AbstractDevice>();
try
{
try
@ -128,7 +128,7 @@ public final class UsbDeviceManager
final DeviceId id = createId(libUsbDevice);
if (id == null) continue;
Usb4JavaDevice device = this.devices.get(id);
AbstractDevice device = this.devices.get(id);
if (device == null)
{
final Device parent = LibUSB.getParent(libUsbDevice);
@ -138,12 +138,12 @@ public final class UsbDeviceManager
.bDeviceClass() == LibUSB.CLASS_HUB;
if (isHub)
{
device = new Usb4JavaHub(this, id, parentId,
device = new Hub(this, id, parentId,
speed, libUsbDevice);
}
else
{
device = new Usb4JavaNonHub(this, id,
device = new NonHub(this, id,
parentId, speed, libUsbDevice);
}
}
@ -171,19 +171,19 @@ public final class UsbDeviceManager
* @param current
* The currently connected devices.
*/
private void processRemovedDevices(final Set<Usb4JavaDevice> current)
private void processRemovedDevices(final Set<AbstractDevice> current)
{
final Iterator<Usb4JavaDevice> it = this.devices.values().iterator();
final Iterator<AbstractDevice> it = this.devices.values().iterator();
while (it.hasNext())
{
final Usb4JavaDevice device = it.next();
final AbstractDevice device = it.next();
if (!current.contains(device))
{
final Usb4JavaDevice parent = this.devices.get(device.getId());
final AbstractDevice parent = this.devices.get(device.getId());
if (parent == null)
this.rootHub.disconnectUsbDevice(device);
else if (parent.isUsbHub())
((Usb4JavaHub) parent).disconnectUsbDevice(device);
((Hub) parent).disconnectUsbDevice(device);
it.remove();
}
}
@ -197,9 +197,9 @@ public final class UsbDeviceManager
* @param current
* The currently connected devices.
*/
private void processNewDevices(final Set<Usb4JavaDevice> current)
private void processNewDevices(final Set<AbstractDevice> current)
{
for (Usb4JavaDevice device: current)
for (AbstractDevice device: current)
{
if (!this.devices.containsValue(device))
{
@ -208,10 +208,10 @@ public final class UsbDeviceManager
this.rootHub.connectUsbDevice(device);
else
{
final Usb4JavaDevice parent = this.devices.get(parentId);
final AbstractDevice parent = this.devices.get(parentId);
if (parent != null && parent.isUsbHub())
{
((Usb4JavaHub) parent).connectUsbDevice(device);
((Hub) parent).connectUsbDevice(device);
}
}
this.devices.put(device.getId(), device);
@ -224,7 +224,7 @@ public final class UsbDeviceManager
*/
public void scan()
{
final Set<Usb4JavaDevice> found = getConnectedDevices();
final Set<AbstractDevice> found = getConnectedDevices();
processRemovedDevices(found);
processNewDevices(found);
}

View File

@ -24,7 +24,7 @@ public final class DeviceNotFoundException extends RuntimeException
* @param id
* The ID of the device which was not found.
*/
public DeviceNotFoundException(final DeviceId id)
DeviceNotFoundException(final DeviceId id)
{
super("USB Device not found: " + id);
this.id = id;

View File

@ -18,16 +18,16 @@ import de.ailis.usb4java.libusb.EndpointDescriptor;
*
* @author Klaus Reimer (k@ailis.de)
*/
public final class Usb4JavaEndpoint implements UsbEndpoint
final class Endpoint implements UsbEndpoint
{
/** The interface this endpoint belongs to. */
private final Usb4JavaInterface iface;
private final Interface iface;
/** The endpoint descriptor. */
private final UsbEndpointDescriptor descriptor;
/** The USB pipe for this endpoint. */
private final Usb4JavaPipe pipe;
private final Pipe pipe;
/**
* Constructor.
@ -37,16 +37,16 @@ public final class Usb4JavaEndpoint implements UsbEndpoint
* @param descriptor
* The libusb endpoint descriptor.
*/
Usb4JavaEndpoint(final Usb4JavaInterface iface,
Endpoint(final Interface iface,
final EndpointDescriptor descriptor)
{
this.iface = iface;
this.descriptor = new SimpleUsbEndpointDescriptor(descriptor);
this.pipe = new Usb4JavaPipe(this);
this.pipe = new Pipe(this);
}
@Override
public Usb4JavaInterface getUsbInterface()
public Interface getUsbInterface()
{
return this.iface;
}

View File

@ -17,11 +17,11 @@ import de.ailis.usb4java.libusb.LibUsbException;
*
* @author Klaus Reimer (k@ailis.de)
*/
public final class Usb4JavaHub extends Usb4JavaDevice implements UsbHub,
UsbPorts<Usb4JavaPort, Usb4JavaDevice>
final class Hub extends AbstractDevice implements UsbHub,
UsbPorts<Port, AbstractDevice>
{
/** The hub ports. */
private final Usb4JavaPorts ports = new Usb4JavaPorts(this);
private final Ports ports = new Ports(this);
/**
* Constructs a new USB hub device.
@ -41,7 +41,7 @@ public final class Usb4JavaHub extends Usb4JavaDevice implements UsbHub,
* @throws LibUsbException
* When device configuration could not be read.
*/
public Usb4JavaHub(final UsbDeviceManager manager, final DeviceId id,
Hub(final DeviceManager manager, final DeviceId id,
final DeviceId parentId, final int speed, final Device device)
throws LibUsbException
{
@ -55,19 +55,19 @@ public final class Usb4JavaHub extends Usb4JavaDevice implements UsbHub,
}
@Override
public List<Usb4JavaPort> getUsbPorts()
public List<Port> getUsbPorts()
{
return this.ports.getUsbPorts();
}
@Override
public Usb4JavaPort getUsbPort(final byte number)
public Port getUsbPort(final byte number)
{
return this.ports.getUsbPort(number);
}
@Override
public List<Usb4JavaDevice> getAttachedUsbDevices()
public List<AbstractDevice> getAttachedUsbDevices()
{
return this.ports.getAttachedUsbDevices();
}
@ -79,13 +79,13 @@ public final class Usb4JavaHub extends Usb4JavaDevice implements UsbHub,
}
@Override
public void connectUsbDevice(final Usb4JavaDevice device)
public void connectUsbDevice(final AbstractDevice device)
{
this.ports.connectUsbDevice(device);
}
@Override
public void disconnectUsbDevice(final Usb4JavaDevice device)
public void disconnectUsbDevice(final AbstractDevice device)
{
this.ports.disconnectUsbDevice(device);
}
@ -102,7 +102,7 @@ public final class Usb4JavaHub extends Usb4JavaDevice implements UsbHub,
if (this == obj) return true;
if (obj == null) return false;
if (getClass() != obj.getClass()) return false;
final Usb4JavaDevice other = (Usb4JavaDevice) obj;
final AbstractDevice other = (AbstractDevice) obj;
return getId().equals(other.getId());
}

View File

@ -28,17 +28,17 @@ import de.ailis.usb4java.libusb.InterfaceDescriptor;
*
* @author Klaus Reimer (k@ailis.de)
*/
public final class Usb4JavaInterface implements UsbInterface
final class Interface implements UsbInterface
{
/** The configuration this interface belongs to. */
private final Usb4JavaConfiguration configuration;
private final Configuration configuration;
/** The interface descriptor. */
private final UsbInterfaceDescriptor descriptor;
/** The endpoints of this interface. */
private final Map<Byte, Usb4JavaEndpoint> endpoints =
new HashMap<Byte, Usb4JavaEndpoint>();
private final Map<Byte, Endpoint> endpoints =
new HashMap<Byte, Endpoint>();
/**
* Constructor.
@ -48,15 +48,15 @@ public final class Usb4JavaInterface implements UsbInterface
* @param descriptor
* The libusb interface descriptor.
*/
Usb4JavaInterface(final Usb4JavaConfiguration configuration,
Interface(final Configuration configuration,
final InterfaceDescriptor descriptor)
{
this.configuration = configuration;
this.descriptor = new SimpleUsbInterfaceDescriptor(descriptor);
for (EndpointDescriptor endpointDescriptor: descriptor.endpoint())
{
final Usb4JavaEndpoint endpoint =
new Usb4JavaEndpoint(this, endpointDescriptor);
final Endpoint endpoint =
new Endpoint(this, endpointDescriptor);
this.endpoints.put(endpointDescriptor.bEndpointAddress(), endpoint);
}
}
@ -98,7 +98,7 @@ public final class Usb4JavaInterface implements UsbInterface
{
checkActive();
checkConnected();
final Usb4JavaDevice device = this.configuration.getUsbDevice();
final AbstractDevice device = this.configuration.getUsbDevice();
device.claimInterface(this.descriptor.bInterfaceNumber(),
policy != null && policy.forceClaim(this));
this.configuration.setUsbInterface(
@ -145,7 +145,7 @@ public final class Usb4JavaInterface implements UsbInterface
}
@Override
public Usb4JavaInterface getActiveSetting()
public Interface getActiveSetting()
{
checkActive();
return this.configuration.getUsbInterface(this.descriptor
@ -153,7 +153,7 @@ public final class Usb4JavaInterface implements UsbInterface
}
@Override
public Usb4JavaInterface getSetting(final byte number)
public Interface getSetting(final byte number)
{
return (this.configuration).getSettings(
this.descriptor.bInterfaceNumber()).get(number & 0xff);
@ -167,22 +167,22 @@ public final class Usb4JavaInterface implements UsbInterface
}
@Override
public List<Usb4JavaInterface> getSettings()
public List<Interface> getSettings()
{
return Collections.unmodifiableList(new ArrayList<Usb4JavaInterface>(
return Collections.unmodifiableList(new ArrayList<Interface>(
this.configuration.getSettings(
this.descriptor.bInterfaceNumber()).values()));
}
@Override
public List<Usb4JavaEndpoint> getUsbEndpoints()
public List<Endpoint> getUsbEndpoints()
{
return Collections.unmodifiableList(new ArrayList<Usb4JavaEndpoint>(
return Collections.unmodifiableList(new ArrayList<Endpoint>(
this.endpoints.values()));
}
@Override
public Usb4JavaEndpoint getUsbEndpoint(final byte address)
public Endpoint getUsbEndpoint(final byte address)
{
return this.endpoints.get(address);
}
@ -194,7 +194,7 @@ public final class Usb4JavaInterface implements UsbInterface
}
@Override
public Usb4JavaConfiguration getUsbConfiguration()
public Configuration getUsbConfiguration()
{
return this.configuration;
}

View File

@ -25,10 +25,10 @@ import de.ailis.usb4java.libusb.LibUsbException;
*
* @author Klaus Reimer (k@ailis.de)
*/
public final class IrpQueue extends AbstractIrpQueue<UsbIrp>
final class IrpQueue extends AbstractIrpQueue<UsbIrp>
{
/** The USB pipe. */
private final Usb4JavaPipe pipe;
private final Pipe pipe;
/**
* Constructor.
@ -36,7 +36,7 @@ public final class IrpQueue extends AbstractIrpQueue<UsbIrp>
* @param pipe
* The USB pipe
*/
public IrpQueue(final Usb4JavaPipe pipe)
IrpQueue(final Pipe pipe)
{
super(pipe.getDevice());
this.pipe = pipe;

View File

@ -13,7 +13,7 @@ import de.ailis.usb4java.libusb.LibUsbException;
*
* @author Klaus Reimer (k@ailis.de)
*/
final class Usb4JavaNonHub extends Usb4JavaDevice
class NonHub extends AbstractDevice
{
/**
* Constructs a new non-hub USB device.
@ -34,7 +34,7 @@ final class Usb4JavaNonHub extends Usb4JavaDevice
* @throws LibUsbException
* When device configuration could not be read.
*/
Usb4JavaNonHub(final UsbDeviceManager manager, final DeviceId id,
NonHub(final DeviceManager manager, final DeviceId id,
final DeviceId parentId, final int speed, final Device device)
throws LibUsbException
{
@ -53,7 +53,7 @@ final class Usb4JavaNonHub extends Usb4JavaDevice
if (this == obj) return true;
if (obj == null) return false;
if (getClass() != obj.getClass()) return false;
final Usb4JavaNonHub other = (Usb4JavaNonHub) obj;
final NonHub other = (NonHub) obj;
return getId().equals(other.getId());
}

View File

@ -30,10 +30,10 @@ import de.ailis.usb4java.support.UsbPipeListenerList;
*
* @author Klaus Reimer (k@ailis.de)
*/
public final class Usb4JavaPipe implements UsbPipe
final class Pipe implements UsbPipe
{
/** The endpoint this pipe belongs to. */
private final Usb4JavaEndpoint endpoint;
private final Endpoint endpoint;
/** The USB pipe listeners. */
private final UsbPipeListenerList listeners = new UsbPipeListenerList();
@ -50,7 +50,7 @@ public final class Usb4JavaPipe implements UsbPipe
* @param endpoint
* The endpoint this pipe belongs to.
*/
Usb4JavaPipe(final Usb4JavaEndpoint endpoint)
Pipe(final Endpoint endpoint)
{
this.endpoint = endpoint;
this.queue = new IrpQueue(this);
@ -61,7 +61,7 @@ public final class Usb4JavaPipe implements UsbPipe
*
* @return The USB device.
*/
public Usb4JavaDevice getDevice()
public AbstractDevice getDevice()
{
return this.endpoint.getUsbInterface().getUsbConfiguration()
.getUsbDevice();
@ -151,7 +151,7 @@ public final class Usb4JavaPipe implements UsbPipe
}
@Override
public Usb4JavaEndpoint getUsbEndpoint()
public Endpoint getUsbEndpoint()
{
return this.endpoint;
}

View File

@ -13,7 +13,7 @@ import javax.usb.UsbPort;
*
* @author Klaus Reimer (k@ailis.de)
*/
public final class Usb4JavaPort implements UsbPort
final class Port implements UsbPort
{
/** The USB hub this port belongs to. */
private final UsbHub hub;
@ -22,7 +22,7 @@ public final class Usb4JavaPort implements UsbPort
private final byte portNumber;
/** The attached device. */
private Usb4JavaDevice device;
private AbstractDevice device;
/**
* Constructor.
@ -32,7 +32,7 @@ public final class Usb4JavaPort implements UsbPort
* @param portNumber
* The port number.
*/
public Usb4JavaPort(final UsbHub hub, final byte portNumber)
Port(final UsbHub hub, final byte portNumber)
{
this.hub = hub;
this.portNumber = portNumber;
@ -51,7 +51,7 @@ public final class Usb4JavaPort implements UsbPort
}
@Override
public Usb4JavaDevice getUsbDevice()
public AbstractDevice getUsbDevice()
{
return this.device;
}
@ -68,7 +68,7 @@ public final class Usb4JavaPort implements UsbPort
* @param device
* The device to connect.
*/
void connectUsbDevice(final Usb4JavaDevice device)
void connectUsbDevice(final AbstractDevice device)
{
if (device == null)
throw new IllegalArgumentException("device must not be null");
@ -86,7 +86,7 @@ public final class Usb4JavaPort implements UsbPort
{
if (this.device == null)
throw new IllegalStateException("Port has no connected device");
final Usb4JavaDevice device = this.device;
final AbstractDevice device = this.device;
this.device = null;
device.setParentUsbPort(null);
}

View File

@ -16,11 +16,11 @@ import javax.usb.UsbHub;
*
* @author Klaus Reimer (k@ailis.de)
*/
public final class Usb4JavaPorts
implements UsbPorts<Usb4JavaPort, Usb4JavaDevice>
final class Ports
implements UsbPorts<Port, AbstractDevice>
{
/** The hub ports. */
private final List<Usb4JavaPort> ports = new ArrayList<Usb4JavaPort>();
private final List<Port> ports = new ArrayList<Port>();
/** The hub these ports belong to. */
private final UsbHub hub;
@ -31,7 +31,7 @@ public final class Usb4JavaPorts
* @param hub
* The hub the port belongs to.
*/
public Usb4JavaPorts(final UsbHub hub)
Ports(final UsbHub hub)
{
this.hub = hub;
addPort();
@ -42,10 +42,10 @@ public final class Usb4JavaPorts
*
* @return The added port.
*/
private Usb4JavaPort addPort()
private Port addPort()
{
final byte portNo = (byte) (this.ports.size() + 1);
final Usb4JavaPort port = new Usb4JavaPort(this.hub, portNo);
final Port port = new Port(this.hub, portNo);
this.ports.add(port);
return port;
}
@ -55,9 +55,9 @@ public final class Usb4JavaPorts
*
* @return The first free port.
*/
private Usb4JavaPort getFreePort()
private Port getFreePort()
{
for (final Usb4JavaPort port: this.ports)
for (final Port port: this.ports)
{
if (!port.isUsbDeviceAttached()) return port;
}
@ -81,7 +81,7 @@ public final class Usb4JavaPorts
* @return The ports.
*/
@Override
public List<Usb4JavaPort> getUsbPorts()
public List<Port> getUsbPorts()
{
return Collections.unmodifiableList(this.ports);
}
@ -94,7 +94,7 @@ public final class Usb4JavaPorts
* @return The USB port or null if no such port.
*/
@Override
public Usb4JavaPort getUsbPort(final byte number)
public Port getUsbPort(final byte number)
{
final int index = (number & 0xff) - 1;
if (index < 0 || index >= this.ports.size()) return null;
@ -107,12 +107,12 @@ public final class Usb4JavaPorts
* @return The attached USB devices.
*/
@Override
public List<Usb4JavaDevice> getAttachedUsbDevices()
public List<AbstractDevice> getAttachedUsbDevices()
{
final List<Usb4JavaDevice> devices = new ArrayList<Usb4JavaDevice>();
final List<AbstractDevice> devices = new ArrayList<AbstractDevice>();
synchronized (this.ports)
{
for (final Usb4JavaPort port: this.ports)
for (final Port port: this.ports)
{
if (port.isUsbDeviceAttached())
{
@ -130,11 +130,11 @@ public final class Usb4JavaPorts
* The device to add to this hub.
*/
@Override
public void connectUsbDevice(final Usb4JavaDevice device)
public void connectUsbDevice(final AbstractDevice device)
{
synchronized (this.ports)
{
final Usb4JavaPort port = getFreePort();
final Port port = getFreePort();
port.connectUsbDevice(device);
}
}
@ -146,11 +146,11 @@ public final class Usb4JavaPorts
* The device to disconnected from the hub.
*/
@Override
public void disconnectUsbDevice(final Usb4JavaDevice device)
public void disconnectUsbDevice(final AbstractDevice device)
{
synchronized (this.ports)
{
for (final Usb4JavaPort port: this.ports)
for (final Port port: this.ports)
{
if (device.equals(port.getUsbDevice()))
{

View File

@ -27,14 +27,14 @@ import de.ailis.usb4java.support.UsbDeviceListenerList;
*
* @author Klaus Reimer (k@ailis.de)
*/
public final class VirtualRootHub implements UsbHub,
UsbPorts<Usb4JavaPort, Usb4JavaDevice>
final class RootHub implements UsbHub,
UsbPorts<Port, AbstractDevice>
{
/** The manufacturer string. */
private static final String MANUFACTURER = "usb4java";
/** The manufacturer string. */
private static final String PRODUCT = "virtual root hub";
private static final String PRODUCT = "root hub";
/** The serial number. */
private static final String SERIAL_NUMBER = "1.0.0";
@ -65,14 +65,14 @@ public final class VirtualRootHub implements UsbHub,
private final UsbDeviceListenerList listeners = new UsbDeviceListenerList();
/** The hub ports. */
private final Usb4JavaPorts ports = new Usb4JavaPorts(this);
private final Ports ports = new Ports(this);
/**
* Constructor.
*/
public VirtualRootHub()
RootHub()
{
this.configurations.add(new VirtualRootHubConfiguration(this));
this.configurations.add(new RootHubConfiguration(this));
}
@Override
@ -220,19 +220,19 @@ public final class VirtualRootHub implements UsbHub,
}
@Override
public List<Usb4JavaPort> getUsbPorts()
public List<Port> getUsbPorts()
{
return this.ports.getUsbPorts();
}
@Override
public Usb4JavaPort getUsbPort(final byte number)
public Port getUsbPort(final byte number)
{
return this.ports.getUsbPort(number);
}
@Override
public List<Usb4JavaDevice> getAttachedUsbDevices()
public List<AbstractDevice> getAttachedUsbDevices()
{
return this.ports.getAttachedUsbDevices();
}
@ -244,13 +244,13 @@ public final class VirtualRootHub implements UsbHub,
}
@Override
public void connectUsbDevice(final Usb4JavaDevice device)
public void connectUsbDevice(final AbstractDevice device)
{
this.ports.connectUsbDevice(device);
}
@Override
public void disconnectUsbDevice(final Usb4JavaDevice device)
public void disconnectUsbDevice(final AbstractDevice device)
{
this.ports.disconnectUsbDevice(device);
}

View File

@ -21,7 +21,7 @@ import de.ailis.usb4java.descriptors.SimpleUsbConfigurationDescriptor;
*
* @author Klaus Reimer (k@ailis.de)
*/
public final class VirtualRootHubConfiguration implements UsbConfiguration
final class RootHubConfiguration implements UsbConfiguration
{
/** The virtual interfaces. */
private final List<UsbInterface> interfaces =
@ -49,10 +49,10 @@ public final class VirtualRootHubConfiguration implements UsbConfiguration
* @param device
* The device this configuration belongs to.
*/
VirtualRootHubConfiguration(final UsbDevice device)
RootHubConfiguration(final UsbDevice device)
{
this.device = device;
this.interfaces.add(new VirtualRootHubInterface(this));
this.interfaces.add(new RootHubInterface(this));
}
@Override

View File

@ -23,7 +23,7 @@ import de.ailis.usb4java.descriptors.SimpleUsbInterfaceDescriptor;
*
* @author Klaus Reimer (k@ailis.de)
*/
public final class VirtualRootHubInterface implements UsbInterface
final class RootHubInterface implements UsbInterface
{
/** The list of endpoints. */
private final List<UsbEndpoint> endpoints = new ArrayList<UsbEndpoint>(0);
@ -53,7 +53,7 @@ public final class VirtualRootHubInterface implements UsbInterface
* @param configuration
* The USB configuration.
*/
public VirtualRootHubInterface(final UsbConfiguration configuration)
RootHubInterface(final UsbConfiguration configuration)
{
this.configuration = configuration;
}

View File

@ -26,11 +26,10 @@ import de.ailis.usb4java.support.UsbServicesListenerList;
public final class Services implements UsbServices
{
/** The implementation description. */
private static final String IMP_DESCRIPTION =
"usb4java JSR-80 implementation";
private static final String IMP_DESCRIPTION = "usb4java";
/** The implementation version. */
private static final String IMP_VERSION = "0.5.1";
private static final String IMP_VERSION = "1.0.0";
/** The API version. */
private static final String API_VERSION = "1.0.2";
@ -40,10 +39,10 @@ public final class Services implements UsbServices
new UsbServicesListenerList();
/** The virtual USB root hub. */
private final VirtualRootHub rootHub;
private final RootHub rootHub;
/** The USB device scanner. */
private final UsbDeviceManager deviceScanner;
private final DeviceManager deviceScanner;
/** If devices should be scanned by hierarchy. */
private final Config config;
@ -60,8 +59,8 @@ public final class Services implements UsbServices
{
this.config = new Config(UsbHostManager.getProperties());
Loader.load();
this.rootHub = new VirtualRootHub();
this.deviceScanner = new UsbDeviceManager(this.rootHub);
this.rootHub = new RootHub();
this.deviceScanner = new DeviceManager(this.rootHub);
this.deviceScanner.start();
}
@ -108,7 +107,7 @@ public final class Services implements UsbServices
* @param device
* The new attached device.
*/
public void usbDeviceAttached(final UsbDevice device)
void usbDeviceAttached(final UsbDevice device)
{
this.listeners.usbDeviceAttached(new UsbServicesEvent(this, device));
}
@ -119,7 +118,7 @@ public final class Services implements UsbServices
* @param device
* The detached device.
*/
public void usbDeviceDetached(final UsbDevice device)
void usbDeviceDetached(final UsbDevice device)
{
this.listeners.usbDeviceDetached(new UsbServicesEvent(this, device));
}
@ -129,7 +128,7 @@ public final class Services implements UsbServices
*
* @return The configuration.
*/
public Config getConfig()
Config getConfig()
{
return this.config;
}

View File

@ -12,7 +12,7 @@ import de.ailis.usb4java.libusb.LibUSB;
*
* @author Klaus Reimer (k@ailis.de)
*/
public final class Usb4JavaRuntimeException extends RuntimeException
final class Usb4JavaRuntimeException extends RuntimeException
{
/** Serial version UID. */
private static final long serialVersionUID = 1L;
@ -28,7 +28,7 @@ public final class Usb4JavaRuntimeException extends RuntimeException
* @param errorCode
* The error code.
*/
public Usb4JavaRuntimeException(final String message, final int errorCode)
Usb4JavaRuntimeException(final String message, final int errorCode)
{
super(String.format("USB error %d: %s: %s", -errorCode, message,
LibUSB.errorName(errorCode)));
@ -43,7 +43,7 @@ public final class Usb4JavaRuntimeException extends RuntimeException
* @param cause
* The root cause.
*/
public Usb4JavaRuntimeException(final String message, final Throwable cause)
Usb4JavaRuntimeException(final String message, final Throwable cause)
{
super("USB error: " + message, cause);
this.errorCode = 0;

View File

@ -19,7 +19,7 @@ import javax.usb.UsbPort;
* @param <D>
* The USB device type.
*/
public interface UsbPorts<P extends UsbPort, D extends UsbDevice>
interface UsbPorts<P extends UsbPort, D extends UsbDevice>
{
/**
* Returns the number of ports.