Grabba Driver for Android
Unified driver for Grabba devices on the Android operating system
MagstripeData Class Reference

Description

Class encapsulating magnetic stripe data tracks.

This structure is used by MagstripeListener to deliver the results of magstripe card scans to the user.

Track data may be read in 5-bit or 7-bit formats. These will be decoded according to standard magstripe encoding rules, and each track's embedded checksum will be verified. If verification succeeds, then track data is converted to UTF-16 format so that it may be accessed using the String type.

Thread safety:

  • Concurrent accesses to distinct objects: safe
  • Concurrent accesses to same object: unsafe, unless all accesses are read-only (i.e. query functions)

Public Member Functions

 MagstripeData ()
 Default construction - sets each track to an empty string.
 
 MagstripeData (@NonNull String initTrack1, @NonNull String initTrack2, @NonNull String initTrack3)
 Construction - sets formatted track data. More...
 
void setTrack1 (@NonNull String newTrack)
 Set the contents of the first track. More...
 
void setTrack2 (@NonNull String newTrack)
 Set the contents of the second track. More...
 
void setTrack3 (@NonNull String newTrack)
 Set the contents of the third track. More...
 
String track1 ()
 Query the contents of the first track. More...
 
String track2 ()
 Query the contents of the second track. More...
 
String track3 ()
 Query the contents of the third track. More...
 

Constructor & Destructor Documentation

◆ MagstripeData()

MagstripeData ( @NonNull String  initTrack1,
@NonNull String  initTrack2,
@NonNull String  initTrack3 
)

Construction - sets formatted track data.

Parameters
initTrack1Initial value of first track's data - empty if track is invalid or missing, non-empty if it is present and valid
initTrack2Initial value of second track's data - empty if track is invalid or missing, non-empty if it is present and valid
initTrack3Initial value of third track's data - empty if track is invalid or missing, non-empty if it is present and valid
Note
All parameter values are passed by copy; their reference counts will not be incremented beyond the lifetime of this function call.

Member Function Documentation

◆ setTrack1()

void setTrack1 ( @NonNull String  newTrack)

Set the contents of the first track.

Parameters
newTrackTrack data in String format; an empty string signifies the track was missing or invalid.

◆ setTrack2()

void setTrack2 ( @NonNull String  newTrack)

Set the contents of the second track.

Parameters
newTrackTrack data in String format; an empty string signifies the track was missing or invalid.

◆ setTrack3()

void setTrack3 ( @NonNull String  newTrack)

Set the contents of the third track.

Parameters
newTrackTrack data in String format; an empty string signifies the track was missing or invalid.

◆ track1()

String track1 ( )

Query the contents of the first track.

Returns
Copy of the first track data in String format; an empty string indicates that the track was either missing or invalid.

◆ track2()

String track2 ( )

Query the contents of the second track.

Returns
Copy of the second track data in String format; an empty string indicates that the track was either missing or invalid.

◆ track3()

String track3 ( )

Query the contents of the third track.

Returns
Copy of the third track data in String format; an empty string indicates that the track was either missing or invalid.