IBM Branch Transformation Toolkit Javadoc

com.ibm.dse.services.landp
Class MsreService

java.lang.Object
  extended bycom.ibm.dse.base.DSENotifier
      extended bycom.ibm.dse.base.Service
          extended bycom.ibm.dse.services.landp.MsreService
All Implemented Interfaces:
java.util.EventListener, Externalizable, java.io.Externalizable, MsreServiceInterface, Notifier, ReadListener, java.io.Serializable, TimeoutListener, WriteListener

public class MsreService
extends Service
implements MsreServiceInterface, ReadListener, TimeoutListener, WriteListener

Magnetic Stripe Reader and Encoder service. It extends MsreLandp, which interacts with the MSRE hardware through a LANDP server.

See Also:
Serialized Form

Field Summary
 java.lang.String COMPID
           
static int RC_ALREADY_OPENED
           
static int RC_IN_PROCESS
           
static int RC_INVALID_DATA
           
static int RC_NOT_OPENED
           
static int RC_OK
           
static int TIMEOUT_FOREVER
           
 
Fields inherited from class com.ibm.dse.base.Service
externalizer
 
Fields inherited from class com.ibm.dse.base.DSENotifier
handlersList, name
 
Constructor Summary
MsreService()
          MsreService constructor.
 
Method Summary
 void addReadListener(ReadListener newListener)
           
 void addTimeoutListener(TimeoutListener newListener)
           
 void addWriteListener(WriteListener newListener)
           
 int cancel()
          Cancels a previous read or write operation.
 int close()
          Closes the device.
 int getAllTrackParams(MsreTrackParams[] tp)
          Gets the track parameters for all three tracks.
 int getCapabilities(MsreCapabilities cap)
          Gets the device capabilities.
 int getCounters(MsreErrorCounters ec)
          Gets the error counters.
 java.lang.String getLandpServerName()
          Getter for the externalizable parameter landpServerName.
 DeviceStatus getStatus()
          Gets the device status: OPEN,CLOSED,READING or WRITING.
 boolean getTraceFlag()
          Returns the trace flag.
 int getTrackParams(int trackNum, MsreTrackParams tp)
          Gets track parameters.
 int getTrackSelFlags(MsreTrackSelFlags tf)
          Gets the track selection flags.
 java.lang.Object initializeFrom(Tag aTag)
          Initializes the service.
 int open()
          Opens the device with its default server name.
 int open(java.lang.String name)
          Opens the device.
 int read()
          Prepares (arms) the device for reading.
 int read(int timeout)
          Prepares (arms) the device for reading.
 void readCompleted(ReadEvent ev)
          Event handler for the ReadEvent event.
 void removeReadListener(ReadListener newListener)
           
 void removeTimeoutListener(TimeoutListener newListener)
           
 void removeWriteListener(WriteListener newListener)
           
 int setAllTrackParams(MsreTrackParams[] tps)
          Sets the track parameters for all three tracks.
 void setLandpServerName(java.lang.String sname)
          Setter for the externalizable parameter landpServerName.
 void setTraceFlag(boolean tf)
          Enables or disables tracing
 int setTrackParams(int trackNum, MsreTrackParams tp)
          Sets track parameters.
 int setTrackSelFlags(MsreTrackSelFlags tf)
          Sets the track selection flags.
 void timedOut(TimeoutEvent ev)
          Event handler for the TimeoutEvent event.
 java.lang.String toString()
          Gives an SGML representation of the service and its parameters.
protected  void trace(java.lang.String s)
          Traces a line to the trace facility.
 int write(java.lang.String data)
          Prepares the device for writing.
 int write(java.lang.String data, int timeout)
          Prepares the device for writing.
 void writeCompleted(WriteEvent ev)
          Event handler for the WriteEvent event.
 
Methods inherited from class com.ibm.dse.base.Service
externalizer, getExternalizer, getTagName, readExternal, readExternal, readObject, removeExternal, setExternalizer, terminate, toStrings, toTags, writeExternal, writeExternal
 
Methods inherited from class com.ibm.dse.base.DSENotifier
addHandler, getHandlersList, getName, removeHandler, setName, signalEvent, signalEvent, signalEvent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.ibm.dse.base.Externalizable
getName, setName
 

Field Detail

TIMEOUT_FOREVER

public static final int TIMEOUT_FOREVER
See Also:
Constant Field Values

RC_OK

public static final int RC_OK
See Also:
Constant Field Values

RC_ALREADY_OPENED

public static final int RC_ALREADY_OPENED
See Also:
Constant Field Values

RC_NOT_OPENED

public static final int RC_NOT_OPENED
See Also:
Constant Field Values

RC_IN_PROCESS

public static final int RC_IN_PROCESS
See Also:
Constant Field Values

RC_INVALID_DATA

public static final int RC_INVALID_DATA
See Also:
Constant Field Values

COMPID

public java.lang.String COMPID
Constructor Detail

MsreService

public MsreService()
            throws LandpException
MsreService constructor.

Throws:
LandpException - thrown when LANDP is not loaded.
Method Detail

addReadListener

public void addReadListener(ReadListener newListener)
Specified by:
addReadListener in interface MsreServiceInterface
Parameters:
newListener - ReadListener

addTimeoutListener

public void addTimeoutListener(TimeoutListener newListener)
Specified by:
addTimeoutListener in interface MsreServiceInterface
Parameters:
newListener - TimeoutListener

addWriteListener

public void addWriteListener(WriteListener newListener)
Specified by:
addWriteListener in interface MsreServiceInterface
Parameters:
newListener - WriteListener

cancel

public int cancel()
           throws LandpException
Cancels a previous read or write operation.

Specified by:
cancel in interface MsreServiceInterface
Returns:
int - an integer return code. See the constants defined in this class for more information.
Throws:
LandpException - thrown when the remote request returned some unexpected error.

close

public int close()
          throws LandpException
Closes the device.

Specified by:
close in interface MsreServiceInterface
Returns:
int - an integer return code. See the constants defined in this class for more information.
Throws:
LandpException - thrown when the remote request returned some unexpected error.

getAllTrackParams

public int getAllTrackParams(MsreTrackParams[] tp)
                      throws LandpException
Gets the track parameters for all three tracks.

Specified by:
getAllTrackParams in interface MsreServiceInterface
Parameters:
tp - - array of track parameters
Returns:
- the operation return code
Throws:
LandpException - thrown when the remote request returned some unexpected error.

getCapabilities

public int getCapabilities(MsreCapabilities cap)
                    throws LandpException
Gets the device capabilities.

Specified by:
getCapabilities in interface MsreServiceInterface
Parameters:
cap - destination capabilities object
Returns:
- the operation return code
Throws:
LandpException - thrown when the remote request returned some unexpected error.

getCounters

public int getCounters(MsreErrorCounters ec)
                throws LandpException
Gets the error counters.

Specified by:
getCounters in interface MsreServiceInterface
Parameters:
ec - destination error counter object
Returns:
- the operation return code
Throws:
LandpException - thrown when the remote request returned some unexpected error.

getLandpServerName

public java.lang.String getLandpServerName()
Getter for the externalizable parameter landpServerName.

Returns:
String the name of the LANDP server

getStatus

public DeviceStatus getStatus()
Gets the device status: OPEN,CLOSED,READING or WRITING.

Specified by:
getStatus in interface MsreServiceInterface
Returns:
DeviceStatus the device status.

getTraceFlag

public boolean getTraceFlag()
Returns the trace flag.

Returns:
- true if trace is active, false otherwise

getTrackParams

public int getTrackParams(int trackNum,
                          MsreTrackParams tp)
                   throws LandpException
Gets track parameters.

Specified by:
getTrackParams in interface MsreServiceInterface
Parameters:
trackNum - - number of track, 1 to 3.
tp - - destination track parameters
Returns:
- the operation return code
Throws:
LandpException - thrown when the remote request returned some unexpected error.

getTrackSelFlags

public int getTrackSelFlags(MsreTrackSelFlags tf)
                     throws LandpException
Gets the track selection flags.

Specified by:
getTrackSelFlags in interface MsreServiceInterface
Parameters:
tf - destination flags
Returns:
- the operation return code
Throws:
LandpException - thrown when the remote request returned some unexpected error.

initializeFrom

public java.lang.Object initializeFrom(Tag aTag)
                                throws java.io.IOException
Initializes the service.

Specified by:
initializeFrom in interface Externalizable
Overrides:
initializeFrom in class Service
Parameters:
aTag - com.ibm.dse.base.Tag
Returns:
java.lang.Object
Throws:
java.io.IOException - thrown when an IO exception happens

open

public int open()
         throws LandpException
Opens the device with its default server name.

Specified by:
open in interface MsreServiceInterface
Returns:
int - the return code of the operation.
Throws:
LandpException - thrown when the remote request returned some unexpected error.

open

public int open(java.lang.String name)
         throws LandpException
Opens the device.

Specified by:
open in interface MsreServiceInterface
Parameters:
name - - the LANDP MSRE server name.
Throws:
LandpException - thrown when the remote request returned some unexpected error.

read

public int read()
         throws LandpException
Prepares (arms) the device for reading. Generates a read event when a card is read.

Specified by:
read in interface MsreServiceInterface
Throws:
LandpException - thrown when the remote request returned some unexpected error.

read

public int read(int timeout)
         throws LandpException
Prepares (arms) the device for reading. Generates a read event when a card is read, or a timeout event if no card is read in that time.

Specified by:
read in interface MsreServiceInterface
Parameters:
timeout - Time out in seconds.
Throws:
LandpException - thrown when the remote request returned some unexpected error.

readCompleted

public void readCompleted(ReadEvent ev)
Event handler for the ReadEvent event. This handler receives a JavaBean event and generates a toolkit event.

Specified by:
readCompleted in interface ReadListener
Parameters:
ev - ReadEvent the read event object

removeReadListener

public void removeReadListener(ReadListener newListener)
Specified by:
removeReadListener in interface MsreServiceInterface
Parameters:
newListener - ReadListener

removeTimeoutListener

public void removeTimeoutListener(TimeoutListener newListener)
Specified by:
removeTimeoutListener in interface MsreServiceInterface
Parameters:
newListener - TimeoutListener

removeWriteListener

public void removeWriteListener(WriteListener newListener)
Specified by:
removeWriteListener in interface MsreServiceInterface
Parameters:
newListener - WriteListener

setAllTrackParams

public int setAllTrackParams(MsreTrackParams[] tps)
                      throws LandpException
Sets the track parameters for all three tracks.

Specified by:
setAllTrackParams in interface MsreServiceInterface
Returns:
- the operation return code
Throws:
LandpException - thrown when the remote request returned some unexpected error.

setLandpServerName

public void setLandpServerName(java.lang.String sname)
Setter for the externalizable parameter landpServerName.


setTraceFlag

public void setTraceFlag(boolean tf)
                  throws java.lang.NumberFormatException
Enables or disables tracing

Parameters:
tf - boolean - true if trace active, false otherwise
Throws:
java.lang.NumberFormatException

setTrackParams

public int setTrackParams(int trackNum,
                          MsreTrackParams tp)
                   throws LandpException
Sets track parameters.

Specified by:
setTrackParams in interface MsreServiceInterface
Parameters:
trackNum - number of track, 1 to 3.
tp - track parameters
Returns:
- the operation return code
Throws:
LandpException - thrown when the remote request returned some unexpected error.

setTrackSelFlags

public int setTrackSelFlags(MsreTrackSelFlags tf)
                     throws LandpException
Sets the track selection flags.

Specified by:
setTrackSelFlags in interface MsreServiceInterface
Returns:
- the operation return code
Throws:
LandpException - thrown when the remote request returned some unexpected error.

timedOut

public void timedOut(TimeoutEvent ev)
Event handler for the TimeoutEvent event. This handler receives a JavaBean event and generates a toolkit event.

Specified by:
timedOut in interface TimeoutListener
Parameters:
ev - TimeoutEvent - the timeout event object

toString

public java.lang.String toString()
Gives an SGML representation of the service and its parameters.

Overrides:
toString in class Service
Returns:
String - the SGML text

trace

protected void trace(java.lang.String s)
Traces a line to the trace facility.

Parameters:
s - String - the text to trace

write

public int write(java.lang.String data)
          throws LandpException
Prepares the device for writing. Generates a write event when a card is written.

Specified by:
write in interface MsreServiceInterface
Parameters:
data - String - the data to write to the magnetic stripe.
Returns:
int - the operation return code.
Throws:
LandpException - thrown when the remote request returned some unexpected error.

write

public int write(java.lang.String data,
                 int timeout)
          throws LandpException
Prepares the device for writing. Generates a write event when a card is written, or a timeout event if no card is written in that time.

Specified by:
write in interface MsreServiceInterface
Parameters:
timeout - - Time out in seconds.
data - String - the data to write to the stripe.
Returns:
int - the operation return code.
Throws:
LandpException - thrown when the remote request returned some unexpected error.

writeCompleted

public void writeCompleted(WriteEvent ev)
Event handler for the WriteEvent event. This handler receives a JavaBean event and generates a toolkit event.

Specified by:
writeCompleted in interface WriteListener
Parameters:
ev - WriteEvent - the write event object

IBM Branch Transformation Toolkit Javadoc

(c) Copyright IBM Corporation 1998, 2005