public abstract class SerialNumber
extends java.lang.Object
implements java.io.Serializable
SerialNumber
represent serial number indentifiers of hardware devices. For
USB-attached devices, these are usually the low-level USB serial number (see UsbDevice.getSerialNumber()
,
but that is not required. Rather, the notion of SerialNumber
is a general purpose one
representing a user-visible digital identity for a particular device instance.
'Fake' serial numbers are serial numbers that will *never* appear for a real device; they
are useful, for example, as the serial number of a ControllerConfiguration
that
has not yet been associated with a actual controller device. Fake serial numbers are never
shown to users.
Note that *all* serial numbers loaded in memory at any given instant are guaranteed unique and
different, even the fake ones; this allows code that processes USB-device-bound ControllerConfiguration
s to operate easily on unbound ones as well, a significant coding
simplification. The technology used in fake serial numbers, UUID
s, in fact guarantees
uniqueness across space and time, so fake serial numbers can be recorded persistently and
still maintain uniqueness. Historically, non-unique 'fake' serial numbers were also used: these
appeared int the form of "-1" or "N/A". When loaded from persistent storage, such legacy
fake serial numbers are converted to unique ones to maintain the uniqueness guarantee.Modifier and Type | Field and Description |
---|---|
protected static java.util.HashMap<java.lang.String,java.lang.String> |
deviceDisplayNames |
protected static java.lang.String |
embedded |
protected static java.lang.String |
fakePrefix |
protected static java.lang.String |
lynxModulePrefix |
protected java.lang.String |
serialNumberString |
protected static java.lang.String |
vendorProductPrefix |
Modifier | Constructor and Description |
---|---|
protected |
SerialNumber(java.lang.String serialNumberString)
Constructs a serial number using the supplied initialization string.
|
Modifier and Type | Method and Description |
---|---|
static SerialNumber |
createEmbedded() |
static SerialNumber |
createFake() |
boolean |
equals(java.lang.Object object) |
boolean |
equals(java.lang.String string) |
static SerialNumber |
fromString(java.lang.String serialNumberString) |
static SerialNumber |
fromStringOrNull(java.lang.String serialNumberString) |
static SerialNumber |
fromUsbOrNull(java.lang.String serialNumberString) |
static SerialNumber |
fromVidPid(int vid,
int pid,
java.lang.String connectionPath)
Makes up a serial-number-like-thing for USB devices that internally lack a serial number.
|
static java.lang.String |
getDeviceDisplayName(SerialNumber serialNumber) |
SerialNumber |
getScannableDeviceSerialNumber()
Returns the
SerialNumber of the device associated with this one that would appear
in a ScannedDevices . |
java.lang.String |
getString()
Returns the string contents of the serial number.
|
int |
hashCode() |
boolean |
isEmbedded()
Returns whether the serial number is the one used for the embedded
Expansion Hub inside a Rev Control Hub.
|
boolean |
isFake()
Returns whether the indicated serial number is one of the legacy
fake serial number forms or not.
|
boolean |
isUsb()
Returns whether the serial number is one of an actual USB device.
|
boolean |
isVendorProduct() |
boolean |
matches(java.lang.Object pattern) |
static void |
noteSerialNumberType(SerialNumber serialNumber,
java.lang.String typeName) |
protected static final java.lang.String fakePrefix
protected static final java.lang.String vendorProductPrefix
protected static final java.lang.String lynxModulePrefix
protected static final java.lang.String embedded
protected final java.lang.String serialNumberString
protected static final java.util.HashMap<java.lang.String,java.lang.String> deviceDisplayNames
protected SerialNumber(java.lang.String serialNumberString)
serialNumberString
- the initialization string for the serial number.public static SerialNumber createFake()
public static SerialNumber createEmbedded()
public static SerialNumber fromString(java.lang.String serialNumberString)
public static SerialNumber fromStringOrNull(java.lang.String serialNumberString)
public static SerialNumber fromUsbOrNull(java.lang.String serialNumberString)
public static SerialNumber fromVidPid(int vid, int pid, java.lang.String connectionPath)
public boolean isVendorProduct()
public boolean isFake()
public boolean isUsb()
public boolean isEmbedded()
public java.lang.String getString()
Object.toString()
public SerialNumber getScannableDeviceSerialNumber()
SerialNumber
of the device associated with this one that would appear
in a ScannedDevices
.public boolean matches(java.lang.Object pattern)
public boolean equals(java.lang.Object object)
equals
in class java.lang.Object
public boolean equals(java.lang.String string)
public int hashCode()
hashCode
in class java.lang.Object
public static void noteSerialNumberType(SerialNumber serialNumber, java.lang.String typeName)
public static java.lang.String getDeviceDisplayName(SerialNumber serialNumber)