com.ibm.jusb
Class UsbIrpImp

java.lang.Object
  extended by javax.usb.util.DefaultUsbIrp
      extended by com.ibm.jusb.UsbIrpImp
All Implemented Interfaces:
UsbIrp
Direct Known Subclasses:
UsbControlIrpImp

public class UsbIrpImp
extends DefaultUsbIrp
implements UsbIrp

UsbIrp implementation.

If the user provided their own UsbIrp implementation, then the UsbPipeImp will 'wrap' their implementation with this UsbIrpImp by setting the local UsbIrp. If this has a local UsbIrp when it is complete, this will set the proper fields on the wrapped UsbIrp.

Author:
Dan Streetman

Nested Class Summary
static interface UsbIrpImp.UsbIrpImpListener
           
 
Field Summary
protected  boolean createShortPacketException
           
protected  UsbIrp usbIrp
           
protected  UsbIrpImp.UsbIrpImpListener usbIrpImpListener
           
 
Fields inherited from class javax.usb.util.DefaultUsbIrp
acceptShortPacket, actualLength, complete, data, length, offset, usbException
 
Constructor Summary
UsbIrpImp()
          Constructor.
UsbIrpImp(UsbIrp irp)
          Constructor.
 
Method Summary
protected  void checkShortPacketException()
          If createShortPacketException is true, this will check for a short packet condition.
static void checkUsbIrp(UsbIrp irp)
          Check the specified UsbIrp.
 void complete()
          Complete this submission.
protected  void completeUsbIrp()
          If there is a wrapped UsbIrp, set its fields and complete it.
 UsbIrp getUsbIrp()
          Get the UsbIrp this is wrapping.
 UsbIrpImp.UsbIrpImpListener getUsbIrpImpListener()
          Get the UsbIrpImpListener.
 boolean hasUsbIrp()
          If this UsbIrpImp has a wrapped UsbIrp.
 void setCreateShortPacketException(boolean setting)
          This should be set by the UsbPipeImp or UsbDeviceImp if this UsbIrpImp should check/set ShortPacketExceptions.
 void setUsbIrp(UsbIrp irp)
          Set the UsbIrp to wrap.
 void setUsbIrpImpListener(UsbIrpImp.UsbIrpImpListener listener)
          Set the UsbIrpImpListener.
 
Methods inherited from class javax.usb.util.DefaultUsbIrp
getAcceptShortPacket, getActualLength, getData, getLength, getOffset, getUsbException, isComplete, isUsbException, setAcceptShortPacket, setActualLength, setComplete, setData, setData, setLength, setOffset, setUsbException, waitUntilComplete, waitUntilComplete
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.usb.UsbIrp
getAcceptShortPacket, getActualLength, getData, getLength, getOffset, getUsbException, isComplete, isUsbException, setAcceptShortPacket, setActualLength, setComplete, setData, setData, setLength, setOffset, setUsbException, waitUntilComplete, waitUntilComplete
 

Field Detail

usbIrp

protected UsbIrp usbIrp

usbIrpImpListener

protected UsbIrpImp.UsbIrpImpListener usbIrpImpListener

createShortPacketException

protected boolean createShortPacketException
Constructor Detail

UsbIrpImp

public UsbIrpImp()
Constructor.


UsbIrpImp

public UsbIrpImp(UsbIrp irp)
Constructor.

Parameters:
irp - The UsbIrp this should wrap.
Method Detail

complete

public void complete()
Complete this submission.

The order of events must be as follows:

  1. If there is a 'wrapped' UsbIrp, its fields must be set, and it should be completed.
  2. This UsbIrpImp should be completed.
  3. The UsbIrpImpListener should be notified (which will fire events on the device or pipe).

Specified by:
complete in interface UsbIrp
Overrides:
complete in class DefaultUsbIrp

completeUsbIrp

protected void completeUsbIrp()
If there is a wrapped UsbIrp, set its fields and complete it.


setUsbIrp

public void setUsbIrp(UsbIrp irp)
Set the UsbIrp to wrap.

Parameters:
irp - The UsbIrp.

hasUsbIrp

public boolean hasUsbIrp()
If this UsbIrpImp has a wrapped UsbIrp.

Returns:
If there is a wrapped UsbIrp.

getUsbIrp

public UsbIrp getUsbIrp()
Get the UsbIrp this is wrapping.

Returns:
The UsbIrp or null.

setUsbIrpImpListener

public void setUsbIrpImpListener(UsbIrpImp.UsbIrpImpListener listener)
Set the UsbIrpImpListener.

If there is already a Listener, this will clobber it!


getUsbIrpImpListener

public UsbIrpImp.UsbIrpImpListener getUsbIrpImpListener()
Get the UsbIrpImpListener.

Returns:
The UsbIrpImpListener.

checkUsbIrp

public static void checkUsbIrp(UsbIrp irp)
                        throws IllegalArgumentException,
                               UsbException
Check the specified UsbIrp.

This may be used to check the validity of an UsbIrp. This will throw an IllegalArgumentException if the UsbIrp does not behave as specified in the UsbIrp interface documentation. This will throw an UsbException if the UsbIrp is in a state not ready for submission, such as being complete or having a UsbException.

Throws:
IllegalArgumentException - If the UsbIrp is not valid.
UsbException - If the UsbIrp is not ready for submission.

checkShortPacketException

protected void checkShortPacketException()
If createShortPacketException is true, this will check for a short packet condition.

If there is a short packet condition but no exception is set, this will create and set one.


setCreateShortPacketException

public void setCreateShortPacketException(boolean setting)
This should be set by the UsbPipeImp or UsbDeviceImp if this UsbIrpImp should check/set ShortPacketExceptions.

If this is set to true, the checkShortPacketException method will create and set a UsbShortPacketException during {#link #complete() complete}, if appropriate.

Parameters:
setting - The setting.


Copyright © 2013 LSST. All Rights Reserved.