org.opengts.util
Class IButton

java.lang.Object
  extended by org.opengts.util.IButton

public class IButton
extends java.lang.Object

iButton container


Nested Class Summary
static class IButton.DisplayFormat
          DisplayFormat Enumeration
 
Constructor Summary
IButton(long value)
          Constructor.
IButton(long value, boolean bigEndian)
          Constructor.
IButton(java.lang.String value)
          Constructor.
 
Method Summary
static java.lang.String ConvertToBigEndianID(java.lang.String value)
           
static java.lang.String GetDisplayFormatDescription(IButton.DisplayFormat df, java.util.Locale locale)
          Gets the String representation of the specified DisplayFormat.
static IButton.DisplayFormat getDisplayFormatFromName(java.lang.String stn, IButton.DisplayFormat dft)
          Gets the DisplayFormat enumeration value from the specified name
 long getValue()
          Gets the iButton tag value (Little-Endian format)
 long getValue(boolean bigEndian)
          Gets the iButton tag value
 boolean isValid()
          Returns true if this instance contains a valid iButton tag value.
static void main(java.lang.String[] argv)
           
 java.lang.String toDecimalString()
          Converts the iButton tag value to a 64-bit decimal String (Little-Endian format)
 java.lang.String toDecimalString(boolean bigEndian)
          Converts the iButton tag value to a 64-bit decimal String
 java.lang.String toHexString()
          Converts the iButton tag value to a 64-bit hex String (Big-Endian format) (this format typically matches the hex value displayed on the iButton device)
 java.lang.String toHexString(boolean bigEndian)
          Converts the iButton tag value to a 64-bit hex String (Big-Endian format) (this format typically matches the hex value displayed on the iButton device)
 java.lang.String toHexString48()
          Extract the middle 48-bits of the iButton tag value and returns it as a 48-bit hex String (Big-Endian format).
 java.lang.String toHexString48(boolean bigEndian)
          Extract the middle 48-bits of the iButton tag value and returns it as a 48-bit hex String.
 java.lang.String toString()
          Returns the 64-bit hex String iButton tag value
 java.lang.String toString(IButton.DisplayFormat df)
          Returns the String representation of this iButton value in the specified DisplayFormat.
static java.lang.String toString(long value, IButton.DisplayFormat st)
          Converts the specified iButton value into a String value
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IButton

public IButton(long value)
Constructor. Values provided by iButton devices are in Little-Endian format. As such, these values are stored within this container in Little-Endian format.

Parameters:
value - The 64-bit iButton value (in Little-Endian format)

IButton

public IButton(long value,
               boolean bigEndian)
Constructor. Values provided by iButton devices are in Little-Endian format. As such, these values are stored within this container in Little-Endian format. If the specified value will be in Big-Endian format, then the second parameter should specify "true" so that this specified value will be converted into the internal Little-Endian format.

Parameters:
value - The 64-bit iButton value.
bigEndian - True if the specified value is in Big-Endian format, false if Little-Endian.

IButton

public IButton(java.lang.String value)
Constructor. IButton values are typically provided by the device as a Little-Endian 64-bit integer String. This value is printed on the physical iButton as a hex value with the LSB byte first. This constructor attempts to convert the specified Little-Endian hex String into a numeric value. The String is expected to be exactly 16 characters in length, containing the full iButton ID in Little-Endian format. After instantiating this iButton instance, "isValid()" should be called to verify that this iButton value is valid.

Method Detail

getDisplayFormatFromName

public static IButton.DisplayFormat getDisplayFormatFromName(java.lang.String stn,
                                                             IButton.DisplayFormat dft)
Gets the DisplayFormat enumeration value from the specified name


GetDisplayFormatDescription

public static java.lang.String GetDisplayFormatDescription(IButton.DisplayFormat df,
                                                           java.util.Locale locale)
Gets the String representation of the specified DisplayFormat. Returns "Unknown" id the specified DisplayFormat is null.


ConvertToBigEndianID

public static java.lang.String ConvertToBigEndianID(java.lang.String value)

isValid

public boolean isValid()
Returns true if this instance contains a valid iButton tag value. (hi-order byte must not be zero)


getValue

public long getValue()
Gets the iButton tag value (Little-Endian format)


getValue

public long getValue(boolean bigEndian)
Gets the iButton tag value

Parameters:
bigEndian - True to return as a Big-Endian value

toDecimalString

public java.lang.String toDecimalString(boolean bigEndian)
Converts the iButton tag value to a 64-bit decimal String


toDecimalString

public java.lang.String toDecimalString()
Converts the iButton tag value to a 64-bit decimal String (Little-Endian format)


toHexString

public java.lang.String toHexString(boolean bigEndian)
Converts the iButton tag value to a 64-bit hex String (Big-Endian format) (this format typically matches the hex value displayed on the iButton device)


toHexString

public java.lang.String toHexString()
Converts the iButton tag value to a 64-bit hex String (Big-Endian format) (this format typically matches the hex value displayed on the iButton device)


toHexString48

public java.lang.String toHexString48()
Extract the middle 48-bits of the iButton tag value and returns it as a 48-bit hex String (Big-Endian format).


toHexString48

public java.lang.String toHexString48(boolean bigEndian)
Extract the middle 48-bits of the iButton tag value and returns it as a 48-bit hex String.


toString

public java.lang.String toString()
Returns the 64-bit hex String iButton tag value

Overrides:
toString in class java.lang.Object

toString

public java.lang.String toString(IButton.DisplayFormat df)
Returns the String representation of this iButton value in the specified DisplayFormat. If the DisplayFormat is null, returns the 64-bit hex representation.


toString

public static java.lang.String toString(long value,
                                        IButton.DisplayFormat st)
Converts the specified iButton value into a String value

Parameters:
value - The iButton value
st - The display format
Returns:
The value converted to the specified output format, or null if the specified display format is null.

main

public static void main(java.lang.String[] argv)