Package SampleCAT

Class ElectronicJournal

All Implemented Interfaces:
ElectronicJournalInterface, JposBaseInterface

public class ElectronicJournal extends ElectronicJournalProperties
Sample device specific accessor class, bound to the credit authorization terminal service. This implementation provides up to two electronic journal devices, depending on the CAT device configuration:
  • If a path prefix has been specified in jpos.xml (entry JournalPath), ElectronicJournal services are available. They use the device indices 0 (for customer tickets) and 1 (for merchant tickets).
  • Otherwise, ticket data will be passed to the application via DirectIOEvents, fired by the CAT service.
If available, the ElectronicJournal devices work as follows:
  • The ElectronicJournal will be written automatically whenever ticket data are received from the terminal.
  • The transaction time stamp will be used as markers for the corresponding tickets.
  • All ticket data will be written to electronic journal wih index 0.
  • All ticket data that shall be printed twice will be written to electronic journal with index 1 as well.
  • The application can retrieve ticket data with the QueryContent method. Print methods are not available because the sample device has no printer.
  • To be able to use QueryContent, methods RetrieveCurrentMarker and RetrieveMarkerByDateTime can be used. In addition, the contents of the CAT property SlipNumber can be used as marker.
  • Each electronic journal can be cleared with the EraseMedium method. This method must be called whenever property MediumFreeSpace is 0.
  • Constructor Details

    • ElectronicJournal

      public ElectronicJournal(int index, Device dev)
      Constructor.
      Parameters:
      index - Property set used by this accessor.
      dev - Device communication handler object.
  • Method Details

    • checkHealth

      public void checkHealth(int level) throws jpos.JposException
      Description copied from interface: JposBaseInterface
      Final part of CheckHealth method. Can be overwritten in derived class, if necessary. Keep in mind that dvice class specific checks (e.g. check of Claimed or DeviceEnabled) must be done within derived classes. This method will be called only if the following plausibility checks lead to a positive result:
      • Device is neither enabled nor claimed.
      Specified by:
      checkHealth in interface JposBaseInterface
      Overrides:
      checkHealth in class JposCommonProperties
      Parameters:
      level - See UPOS specification, method CheckHealth
      Throws:
      jpos.JposException - See UPOS specification, method CheckHealth
    • claim

      public void claim(int timeout) throws jpos.JposException
      Description copied from interface: JposBaseInterface
      Final part of setting claim. Can be overwritten within derived classes. This method will be called only if the following plausibility checks lead to a positive result:
      • Device has not been closed,
      • The device is not claimed,
      • ExclusiveUse dos not equal ExclusiveNo,
      • timeout is negative not equal to FOREVER.
      Specified by:
      claim in interface JposBaseInterface
      Overrides:
      claim in class JposCommonProperties
      Parameters:
      timeout - see UPOS specification, method Claim
      Throws:
      jpos.JposException - If an error occurs while claiming the device
    • deviceEnabled

      public void deviceEnabled(boolean enable) throws jpos.JposException
      Description copied from interface: JposBaseInterface
      Final part of setting DeviceEnabled. Can be overwritten within derived classes. Performs initOnEnable method of corresponding property set in addition to setting DeviceEnabled. This method will be called only if the following plausibility checks lead to a positive result:
      • Device has not been closed,
      • ExclusiveUse equals ExclusiveYes: Device is claimed,
      • DeviceEnabled != enabled.
      Specified by:
      deviceEnabled in interface JposBaseInterface
      Overrides:
      deviceEnabled in class JposCommonProperties
      Parameters:
      enable - True to enable, false to disable
      Throws:
      jpos.JposException - If an error occurs during enable or disable
    • station

      public void station(int station) throws jpos.JposException
      Description copied from interface: ElectronicJournalInterface
      Final part of setting Station. Can be overwritten within derived classes, if necessary. This method will be called only if the following plausibility checks lead to a positive result:
      • Device is enabled,
      • All bits set in station are set in CapStation as well,
      • internal property AllowAlwaysSetProperties is true or station equals the previous value of Station.
      Specified by:
      station in interface ElectronicJournalInterface
      Overrides:
      station in class ElectronicJournalProperties
      Parameters:
      station - Station for subsequent storing data into journal.
      Throws:
      jpos.JposException - If an error occurs.
    • handlePowerStateOnEnable

      public void handlePowerStateOnEnable() throws jpos.JposException
      Description copied from interface: JposBaseInterface
      Will be called whenever DeviceEnabled will be set to true if power notification is enabled (PowerNotify = PN_ENABLED). Should update the PowerState property. Further processing like firing a StatusUpdateEvent is not necessary, this will be made by the framework automatically.
      Specified by:
      handlePowerStateOnEnable in interface JposBaseInterface
      Overrides:
      handlePowerStateOnEnable in class JposCommonProperties
      Throws:
      jpos.JposException - If an error occurs.
    • eraseMedium

      public void eraseMedium(EraseMedium request) throws jpos.JposException
      Description copied from interface: ElectronicJournalInterface
      Final part of EraseMedium method. Can be overwritten within derived classes, if necessary. The parameters of the method will be passed via a EraseMedium object. This method will be called when the corresponding operation shall be performed, either synchronously or asynchronously. All plausibility checks have been made before, only runtime errors can occur.
      Specified by:
      eraseMedium in interface ElectronicJournalInterface
      Overrides:
      eraseMedium in class ElectronicJournalProperties
      Parameters:
      request - Output request object returned by validation method that contains all parameters to be used by EraseMedium.
      Throws:
      jpos.JposException - If an error occurs.
    • queryContent

      public void queryContent(QueryContent request) throws jpos.JposException
      Description copied from interface: ElectronicJournalInterface
      Final part of QueryContent method. Can be overwritten within derived classes, if necessary. The parameters of the method will be passed via a QueryContent object. This method will be called when the corresponding operation shall be performed, either synchronously or asynchronously. All plausibility checks have been made before, only runtime errors can occur.
      Specified by:
      queryContent in interface ElectronicJournalInterface
      Overrides:
      queryContent in class ElectronicJournalProperties
      Parameters:
      request - Output request object returned by validation method that contains all parameters to be used by QueryContent.
      Throws:
      jpos.JposException - If an error occurs.
    • retrieveCurrentMarker

      public void retrieveCurrentMarker(int type, String[] marker) throws jpos.JposException
      Description copied from interface: ElectronicJournalInterface
      Final part of RetrieveCurrentMarker method. Can be overwritten within derived classes, if necessary. This method will be called only if the following plausibility checks lead to a positive result:
      • Device is enabled,
      • marker is a String array of length 1,
      • CapRetrieveCurrentMarker is true,
      • marterType is one of MT_SESSION_BEG, MT_SESSION_END, MT_DOCUMENT, MT_HEAD or MT_TAIL.
      Specified by:
      retrieveCurrentMarker in interface ElectronicJournalInterface
      Overrides:
      retrieveCurrentMarker in class ElectronicJournalProperties
      Parameters:
      type - Specifies the type of the queried current marker.
      marker - Contains the return value, the implementation specific marker.
      Throws:
      jpos.JposException - If an error occurs.
    • retrieveMarkerByDateTime

      public void retrieveMarkerByDateTime(int type, String date, String count, String[] marker) throws jpos.JposException
      Description copied from interface: ElectronicJournalInterface
      Final part of RetrieveMarkerByDateTime method. Can be overwritten within derived classes, if necessary. This method will be called only if the following plausibility checks lead to a positive result:
      • Device is enabled,
      • Neither dateTime normarkerNumber is null,
      • marker is a String array of length 1,
      • CapRetrieveMarkerByDateTime is true,
      • markerType is one of MT_SESSION_BEG, MT_SESSION_END or MT_DOCUMENT,
      • dateTime consists of a valid date and - if present - a valid time,
      • markerNumber is numeric, the value is ≥ 1,
      Specified by:
      retrieveMarkerByDateTime in interface ElectronicJournalInterface
      Overrides:
      retrieveMarkerByDateTime in class ElectronicJournalProperties
      Parameters:
      type - Specifies the type of the queried marker.
      date - The date-time period the marker is queried for.
      count - The number of the marker which has to be queried.
      marker - Contains the return value, the implementation specific marker.
      Throws:
      jpos.JposException - If an error occurs.
    • retrieveMarkersDateTime

      public void retrieveMarkersDateTime(String marker, String[] date) throws jpos.JposException
      Description copied from interface: ElectronicJournalInterface
      Final part of RetrieveMarkersDateTime method. Can be overwritten within derived classes, if necessary. This method will be called only if the following plausibility checks lead to a positive result:
      • Device is enabled,
      • marker is not null,
      • dateTime is a String array of length 1,
      • CapRetrieveMarkersDateTime is true.
      Specified by:
      retrieveMarkersDateTime in interface ElectronicJournalInterface
      Overrides:
      retrieveMarkersDateTime in class ElectronicJournalProperties
      Parameters:
      marker - Specifies the marker for which the time has to be determined.
      date - Contains the return value, the date and time string of the given marker.
      Throws:
      jpos.JposException - If an error occurs.