com.ibutton.tmex.utils
Class iButtonID

java.lang.Object
  |
  +--com.ibutton.tmex.utils.iButtonID

public class iButtonID
extends java.lang.Object

The iButtonID class encapsulates the 64 bit Read-Only-Memory (ROM) Identification (ID) number that all iButtons have. The iButtonID contains an 8 bit family code that indicates the feature set the iButton contains, a 48 bit unique serial number, and an 8 bit Cyclic-Redundency-Check (CRC) to verify the ID during intermittent communication.


Field Summary
static int numIDElements
          Number of iButton ID elements.
 
Constructor Summary
iButtonID()
          Constructs an iButton ID with all 0's.
iButtonID(int[] newID)
          Constructs an iButton ID with a starting value specified as an array of ints.
iButtonID(java.lang.String newID)
          Constructs an iButton ID with a starting value specified as a string.
 
Method Summary
 int getFamilyCode()
          Get the Family code from the ID.
 int[] getID()
          Get the ID as an array of ints.
 char[] getIDAsChars()
          Get the ID as an array of chars.
 java.lang.String getIDString()
          Get the ID as a String.
 boolean isValidID()
          Checks the CRC8 calculation of this ID.
 void setID(char[] newID)
          Set the ID using the provided array of chars.
 void setID(int[] newID)
          Set the ID using the provided array of ints.
 void setID(java.lang.String newID)
          Set the ID using the provided array of ints.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

numIDElements

public static final int numIDElements
Number of iButton ID elements. Each element is a byte embedded in an int.
Constructor Detail

iButtonID

public iButtonID()
Constructs an iButton ID with all 0's. This is not a valid ID. The first byte of the ID which is the family code must not be zero.

iButtonID

public iButtonID(int[] newID)
Constructs an iButton ID with a starting value specified as an array of ints.
Parameters:
newID - array of the new iButton ID

iButtonID

public iButtonID(java.lang.String newID)
Constructs an iButton ID with a starting value specified as a string.
Method Detail

setID

public void setID(int[] newID)
Set the ID using the provided array of ints.
Parameters:
newID - array of the new iButton ID

setID

public void setID(char[] newID)
Set the ID using the provided array of chars.
Parameters:
newID - array of the new iButton ID

setID

public void setID(java.lang.String newID)
Set the ID using the provided array of ints.
Parameters:
newID - array of the new iButton ID

getID

public int[] getID()
Get the ID as an array of ints. The number of ID elements is 'numIDElements'.
Returns:
array of ints that is the iButton ID

getIDAsChars

public char[] getIDAsChars()
Get the ID as an array of chars. The number of ID elements is 'numIDElements'.
Returns:
array of chars that is the iButton ID

getIDString

public java.lang.String getIDString()
Get the ID as a String. The number of ID elements is 'numIDElements'.
Returns:
String representation of the iButton ID

getFamilyCode

public int getFamilyCode()
Get the Family code from the ID. The family code value indicates the feature set of the iButton.
Returns:
the family code in the lower 8 bits

isValidID

public boolean isValidID()
Checks the CRC8 calculation of this ID.
Returns:
'true' if the family code is non-zero and the CRC8 calculation is correct.