Class UsbId

java.lang.Object
com.kosdev.kos.core.service.udev.UsbId

public class UsbId extends Object
Represents the id of a usb device by vendorId / productId. This includes support for equality to make various comparisons easy.
Since:
9
Version:
10
  • Constructor Summary

    Constructors
    Constructor
    Description
    UsbId(int vendorId, int productId)
    Create a new id using the specified vendorId and productId.
    UsbId(String vidpid)
    Create a new id using the specified vendorId:productId string format which is %04X:%04X .
    UsbId(String vidpid, boolean exception)
    Create a new id using the specified vendorId:productId string format which is %04X:%04X .
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    equals(int vendorId, int productId)
    Check if this id matches the supplied productId / vendorId.
    boolean
     
    int
     
    int
     
    int
     
    boolean
    Return true if the UsbId contains a valid vendorId / productId.
    void
    setProductId(int productId)
     
    void
    setVendorId(int vendorId)
     
     

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • UsbId

      public UsbId(int vendorId, int productId)
      Create a new id using the specified vendorId and productId.
      Parameters:
      vendorId - the usb vendor id
      productId - the usb product id
      Since:
      9
    • UsbId

      public UsbId(String vidpid)
      Create a new id using the specified vendorId:productId string format which is %04X:%04X . If the string cannot be parsed or is invalid, the resulting UsbId will be invalid (calling isValid will return false).
      Parameters:
      vidpid - the vendorId:productId string
      Since:
      10
    • UsbId

      public UsbId(String vidpid, boolean exception)
      Create a new id using the specified vendorId:productId string format which is %04X:%04X . The exception flag determines how the constructor should behave if the string is invalid. If the flag is true, an invalid value will throw a ReasonException . If the flag is false, the constructor will be successful but isValid() will return false.
      Parameters:
      vidpid - the vendorId:productId string
      exception - true to throw an exception for invalid vid:pid
      Since:
      10
  • Method Details

    • isValid

      public boolean isValid()
      Return true if the UsbId contains a valid vendorId / productId.
    • equals

      public boolean equals(int vendorId, int productId)
      Check if this id matches the supplied productId / vendorId.
      Parameters:
      vendorId - the usb vendor id
      productId - the usb product id
      Since:
      9
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getVendorId

      public int getVendorId()
    • getProductId

      public int getProductId()
    • setVendorId

      public void setVendorId(int vendorId)
    • setProductId

      public void setProductId(int productId)
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object