javax.usb.util
Class DefaultUsbIrp

java.lang.Object
  extended byjavax.usb.util.DefaultUsbIrp
All Implemented Interfaces:
UsbIrp
Direct Known Subclasses:
DefaultUsbControlIrp

public class DefaultUsbIrp
extends java.lang.Object
implements UsbIrp

UsbIrp default implementation.

The behavior and defaults follow those defined in the interface. Any of the fields may be updated if the default is not appropriate; in most cases the data will be the only field that needs to be set.

Author:
Dan Streetman

Constructor Summary
DefaultUsbIrp()
          Constructor.
DefaultUsbIrp(byte[] data)
          Constructor.
DefaultUsbIrp(byte[] data, int offset, int length, boolean shortPacket)
          Constructor.
 
Method Summary
 void complete()
          Complete this submission.
 boolean getAcceptShortPacket()
          Get the Short Packet policy.
 int getActualLength()
          Get the actual length.
 byte[] getData()
          Get the data.
 int getLength()
          Get the length.
 int getOffset()
          Get the offset.
 UsbException getUsbException()
          Get the UsbException.
 boolean isComplete()
          If this is complete.
 boolean isUsbException()
          If a UsbException occurred.
 void setAcceptShortPacket(boolean accept)
          Set the Short Packet policy.
 void setActualLength(int l)
          Set the actual length.
 void setComplete(boolean b)
          Set this as complete (or not).
 void setData(byte[] d)
          Set the data.
 void setData(byte[] d, int o, int l)
          Set the data, offset, and length.
 void setLength(int l)
          Set the length.
 void setOffset(int o)
          Set the offset.
 void setUsbException(UsbException exception)
          Set the UsbException.
 void waitUntilComplete()
          Wait until complete.
 void waitUntilComplete(long timeout)
          Wait until complete, or the timeout has expired.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultUsbIrp

public DefaultUsbIrp()
Constructor.


DefaultUsbIrp

public DefaultUsbIrp(byte[] data)
Constructor.

Parameters:
data - The data.
Throws:
java.lang.IllegalArgumentException - If the data is null.

DefaultUsbIrp

public DefaultUsbIrp(byte[] data,
                     int offset,
                     int length,
                     boolean shortPacket)
Constructor.

Parameters:
data - The data.
offset - The offset.
length - The length.
shortPacket - The Short Packet policy.
Throws:
java.lang.IllegalArgumentException - If the data is null, or the offset and/or length is negative.
Method Detail

getData

public byte[] getData()
Get the data.

Specified by:
getData in interface UsbIrp
Returns:
The data.

getOffset

public int getOffset()
Get the offset.

Specified by:
getOffset in interface UsbIrp
Returns:
The offset.

getLength

public int getLength()
Get the length.

Specified by:
getLength in interface UsbIrp
Returns:
The length.

getActualLength

public int getActualLength()
Get the actual length.

Specified by:
getActualLength in interface UsbIrp
Returns:
The actual length.

setData

public void setData(byte[] d,
                    int o,
                    int l)
             throws java.lang.IllegalArgumentException
Set the data, offset, and length.

Specified by:
setData in interface UsbIrp
Parameters:
d - The data.
o - The offset.
l - The length.
Throws:
java.lang.IllegalArgumentException - If the data is null, or the offset and/or length is negative.

setData

public void setData(byte[] d)
             throws java.lang.IllegalArgumentException
Set the data.

Specified by:
setData in interface UsbIrp
Parameters:
d - The data.
Throws:
java.lang.IllegalArgumentException - If the data is null.

setOffset

public void setOffset(int o)
               throws java.lang.IllegalArgumentException
Set the offset.

Specified by:
setOffset in interface UsbIrp
Parameters:
o - The offset.
Throws:
java.lang.IllegalArgumentException - If the offset is negative.

setLength

public void setLength(int l)
               throws java.lang.IllegalArgumentException
Set the length.

Specified by:
setLength in interface UsbIrp
Parameters:
l - The length.
Throws:
java.lang.IllegalArgumentException - If the length is negative.

setActualLength

public void setActualLength(int l)
                     throws java.lang.IllegalArgumentException
Set the actual length.

Specified by:
setActualLength in interface UsbIrp
Parameters:
l - The actual length.
Throws:
java.lang.IllegalArgumentException - If the length is negative.

isUsbException

public boolean isUsbException()
If a UsbException occurred.

Specified by:
isUsbException in interface UsbIrp
Returns:
If a UsbException occurred.

getUsbException

public UsbException getUsbException()
Get the UsbException.

Specified by:
getUsbException in interface UsbIrp
Returns:
The UsbException, or null.

setUsbException

public void setUsbException(UsbException exception)
Set the UsbException.

Specified by:
setUsbException in interface UsbIrp
Parameters:
exception - The UsbException.

getAcceptShortPacket

public boolean getAcceptShortPacket()
Get the Short Packet policy.

Specified by:
getAcceptShortPacket in interface UsbIrp
Returns:
The Short Packet policy.

setAcceptShortPacket

public void setAcceptShortPacket(boolean accept)
Set the Short Packet policy.

Specified by:
setAcceptShortPacket in interface UsbIrp
Parameters:
accept - The Short Packet policy.

isComplete

public boolean isComplete()
If this is complete.

Specified by:
isComplete in interface UsbIrp
Returns:
If this is complete.

setComplete

public void setComplete(boolean b)
Set this as complete (or not).

Specified by:
setComplete in interface UsbIrp
Parameters:
b - If this is complete (or not).

complete

public void complete()
Complete this submission.

This will:

Specified by:
complete in interface UsbIrp

waitUntilComplete

public void waitUntilComplete()
Wait until complete.

This will block until this is complete.

Specified by:
waitUntilComplete in interface UsbIrp

waitUntilComplete

public void waitUntilComplete(long timeout)
Wait until complete, or the timeout has expired.

This will block until this is complete, or the timeout has expired. If the timeout is 0 or less, this behaves as the no-timeout method.

Specified by:
waitUntilComplete in interface UsbIrp
Parameters:
timeout - The maximum number of milliseconds to wait.


Copyright © 2009 Eurotech Inc. All rights reserved.