Class HardTotalsProperties

java.lang.Object
de.gmxhome.conrad.jpos.jpos_base.JposCommonProperties
de.gmxhome.conrad.jpos.jpos_base.hardtotals.HardTotalsProperties
All Implemented Interfaces:
HardTotalsInterface, JposBaseInterface

public class HardTotalsProperties extends JposCommonProperties implements HardTotalsInterface
Class containing the hard totals specific properties, their default values and default implementations of HardTotalsInterface. For details about properties, methods and method parameters, see UPOS specification, chapter Hard Totals.
  • Field Details

    • CapErrorDetection

      public boolean CapErrorDetection
      UPOS property CapErrorDetection. Default: false. Can be overwritten by objects derived from JposDevice within the changeDefaults method.
    • CapSingleFile

      public boolean CapSingleFile
      UPOS property CapSingleFile. Default: true. Can be overwritten by objects derived from JposDevice within the changeDefaults method.
    • CapTransactions

      public boolean CapTransactions
      UPOS property CapTransactions. Default: true. Can be overwritten by objects derived from JposDevice within the changeDefaults method.
    • FreeData

      public Integer FreeData
      UPOS property FreeData. Must be initialized in the individual initOnEnable method.
    • NumberOfFiles

      public Integer NumberOfFiles
      UPOS property NumberOfFiles. Must be initialized in the individual initOnEnable method.
    • TotalsSize

      public Integer TotalsSize
      UPOS property TotalsSize. Must be overwritten in the individual initOnEnable method. Value must be ≥ FreeData.
    • TransactionInProgress

      public boolean TransactionInProgress
      UPOS property TransactionInProgress. Default: false. Must not be overwritten within the changeDefaults method.
    • Transaction

      public List<ChangeRequest> Transaction
      Buffered SetAll and Write requests, to be performed at transaction end. This list will be cleared and filled by the service implementation. A Device implementation must never change this list, but use the list as far as TransactionInProgress is true.
  • Constructor Details

    • HardTotalsProperties

      protected HardTotalsProperties(int dev)
      Constructor.
      Parameters:
      dev - Device index
  • Method Details

    • claimedHandles

      public int claimedHandles()
      Returns the number of currently claimed hard total files.
      Returns:
      Number of claimed files.
    • close

      public void close() throws jpos.JposException
      Description copied from interface: JposBaseInterface
      Final part of close method. Can be overwritten in derived class, if necessary. This method will be called only if the following plausibility checks lead to a positive result:
      • Device is neither enabled nor claimed.
      Specified by:
      close in interface JposBaseInterface
      Overrides:
      close in class JposCommonProperties
      Throws:
      jpos.JposException - See UPOS specification, method Close
    • beginTrans

      public void beginTrans() throws jpos.JposException
      Description copied from interface: HardTotalsInterface
      Final part of BeginTrans method. Can be overwritten in derived class, if necessary. This method will be called only if the following plausibility checks lead to a positive result:
      • Device is enabled,
      • CapTransaction is true,
      • TransactionInProgress is false.
      Keep in mind that TransactionInProgress must be set to true after successful transaction begin. This can be done using the implementation in class HardTotalsProperties.
      Specified by:
      beginTrans in interface HardTotalsInterface
      Throws:
      jpos.JposException - If an error occurs.
    • claimFile

      public void claimFile(int hTotalsFile, int timeout) throws jpos.JposException
      Description copied from interface: HardTotalsInterface
      Final part of ClaimFile method. Can be overwritten in derived class, if necessary. This method will be called only if the following plausibility checks lead to a positive result:
      • Device is enabled and not claimed by other instance,
      • The hard totals file specified by hTotalsFile has not been claimed previously,
      • timeout is FOREVER or positive.
      If the service must wait for a release from another instance and timeout is not FOREVER, timeout will be reduced by the number of milliseconds the service must wait to get exclusive access. If the service cannot get exclusive access, a JposException with error code E_TIMEOUT will be thrown without calling this method.
      Specified by:
      claimFile in interface HardTotalsInterface
      Parameters:
      hTotalsFile - Handle of a totals file.
      timeout - The (reduced) time in milliseconds to wait for the file to become available.
      Throws:
      jpos.JposException - If an error occurs.
    • commitTrans

      public void commitTrans() throws jpos.JposException
      Description copied from interface: HardTotalsInterface
      Final part of CommitTrans method. Can be overwritten in derived class, if necessary. This method will be called only if the following plausibility checks lead to a positive result:
      • Device is enabled and not claimed by other instance,
      • CapTransactions is true,
      • TransactionInProgress is true,
      • All files used in stored Write or SetAll operations have not been claimed by another instance.
      The ChangeRequest instances to be processed can be found in property Transaction.
      Specified by:
      commitTrans in interface HardTotalsInterface
      Throws:
      jpos.JposException - If an error occurs.
    • create

      public void create(String fileName, int[] hTotalsFile, int size, boolean errorDetection) throws jpos.JposException
      Description copied from interface: HardTotalsInterface
      Final part of Create method. Can be overwritten in derived class, if necessary. This method will be called only if the following plausibility checks lead to a positive result:
      • Device is enabled and not claimed by other instance,
      • if CapSingleFile is true, fileName is an empty string,
      • otherwise, fileName consists of no more than 10 ASCII characters (character codes between 0x20 and 0x7f,
      • hTotalsFile is an array with length = 1,
      • size is a positive value.
      Specified by:
      create in interface HardTotalsInterface
      Parameters:
      fileName - Name of totals file.
      hTotalsFile - No matter on call, handle to file on return.
      size - Requested size of the file.
      errorDetection - Error detection level.
      Throws:
      jpos.JposException - If an error occurs.
    • delete

      public void delete(String fileName) throws jpos.JposException
      Description copied from interface: HardTotalsInterface
      Final part of Delete method. Can be overwritten in derived class, if necessary. This method will be called only if the following plausibility checks lead to a positive result:
      • Device is enabled and not claimed by other instance,
      • if CapSingleFile is true, fileName is an empty string,
      • otherwise, fileName consists of no more than 10 ASCII characters (character codes between 0x20 and 0x7f.
      Keep in mind: This method must check whether the specified file has been claimed by another instance.
      Specified by:
      delete in interface HardTotalsInterface
      Parameters:
      fileName - Name of file to be deleted.
      Throws:
      jpos.JposException - If an error occurs.
    • find

      public void find(String fileName, int[] hTotalsFile, int[] size) throws jpos.JposException
      Description copied from interface: HardTotalsInterface
      Final part of Find method. Can be overwritten in derived class, if necessary. This method will be called only if the following plausibility checks lead to a positive result:
      • Device is enabled and not claimed by other instance,
      • if CapSingleFile is true, fileName is an empty string,
      • otherwise, fileName consists of no more than 10 ASCII characters (character codes between 0x20 and 0x7f,
      • hTotalsFile is an array with length = 1,
      • size is an array with length = 1.
      Specified by:
      find in interface HardTotalsInterface
      Parameters:
      fileName - Name of file to be found.
      hTotalsFile - No matter on call, file handle on return.
      size - No matter on call, file size on return.
      Throws:
      jpos.JposException - If an error occurs.
    • findByIndex

      public void findByIndex(int index, String[] fileName) throws jpos.JposException
      Description copied from interface: HardTotalsInterface
      Final part of FindByIndex method. Can be overwritten in derived class, if necessary. This method will be called only if the following plausibility checks lead to a positive result:
      • Device is enabled,
      • fileName is an array with length = 1,
      • index is ≥ 0 and < NumberOfFiles.
      Specified by:
      findByIndex in interface HardTotalsInterface
      Parameters:
      index - File index between 0 and NumberOfFiles - 1.
      fileName - No matter on call, file name on return.
      Throws:
      jpos.JposException - If an error occurs.
    • read

      public void read(int hTotalsFile, byte[] data, int offset, int count, List<ChangeRequest> transaction) throws jpos.JposException
      Description copied from interface: HardTotalsInterface
      Final part of Read method. Can be overwritten in derived class, if necessary. This method will be called only if the following plausibility checks lead to a positive result:
      • Device is enabled and not claimed by other instance,
      • offset ≥ 0, count ≥ 0 and length of data ≥ count,
      • offset + count ≤ TotalsSize,
      • The hard totals file specified by hTotalsFile has not been claimed by another instance.
      The list of ChangeRequest objects passed via transaction consists of stored Write and SetAll requests stored due to transaction processing for the given file. The contents of these objects can be used to modify data read to get the expected results, if necessary. However, after a transaction ends in one instance of the service, remaining operations of other transactions can lead to a different read result whenever a previously buffered operation will be committed later, resulting in not being overwritten by the finished transaction.
      Specified by:
      read in interface HardTotalsInterface
      Parameters:
      hTotalsFile - Handle of a totals file.
      data - Data buffer for read.
      offset - Starting offset for read operation.
      count - Number of bytes to be read.
      transaction - List of ChangeRequest objects stored within all current transactions. An empty list if no transaction is in progress.
      Throws:
      jpos.JposException - If an error occurs.
    • recalculateValidationData

      public void recalculateValidationData(int hTotalsFile) throws jpos.JposException
      Description copied from interface: HardTotalsInterface
      Final part of RecalculateValidationData method. Can be overwritten in derived class, if necessary. This method will be called only if the following plausibility checks lead to a positive result:
      • Device is enabled and not claimed by other instance,
      • The hard totals file specified by hTotalsFile has not been claimed by other instance,
      • Device supports advanced error detection.
      Specified by:
      recalculateValidationData in interface HardTotalsInterface
      Parameters:
      hTotalsFile - Handle of a totals file.
      Throws:
      jpos.JposException - If an error occurs.
    • releaseFile

      public void releaseFile(int hTotalsFile) throws jpos.JposException
      Description copied from interface: HardTotalsInterface
      Final part of ReleaseFile method. Can be overwritten in derived class, if necessary. This method will be called only if the following plausibility checks lead to a positive result:
      • Device is enabled and not claimed by other instance,
      • The hard totals file specified by hTotalsFile has not been claimed.
      Specified by:
      releaseFile in interface HardTotalsInterface
      Parameters:
      hTotalsFile - Handle of a totals file.
      Throws:
      jpos.JposException - If an error occurs.
    • setAll

      public SetAll setAll(int hTotalsFile, byte value) throws jpos.JposException
      Description copied from interface: HardTotalsInterface
      Validation part of SetAll method. Can be overwritten within derived classes, if necessary. This method shall only perform additional validation. It will be called before the service buffers the method call for synchronous or asynchronous execution. This method will be called only if the following plausibility checks lead to a positive result:
      • Device is enabled and not claimed by other instance,
      • The hard totals file specified by hTotalsFile has not been claimed by another instance.
      Specified by:
      setAll in interface HardTotalsInterface
      Parameters:
      hTotalsFile - Handle of a totals file.
      value - Value to set all locations to in totals file.
      Returns:
      SetAll object for use in final part or in CommitTrans.
      Throws:
      jpos.JposException - If an error occurs.
    • setAll

      public void setAll(SetAll request) throws jpos.JposException
      Description copied from interface: HardTotalsInterface
      Final part of SetAll method. Can be overwritten within derived classes, if necessary. The parameters of the method will be passed via a SetAll object. This method will be called when the corresponding operation shall be performed, either synchronously during commit. All plausibility checks have been made before, only runtime errors can occur.
      The default implementation should be called within derived methods to ensure that the property TransactionInProgress is updated as expected.
      Specified by:
      setAll in interface HardTotalsInterface
      Parameters:
      request - Output request object returned by validation method that contains all parameters to be used by SetAll.
      Throws:
      jpos.JposException - If an error occurs.
    • write

      public Write write(int hTotalsFile, byte[] data, int offset, int count) throws jpos.JposException
      Description copied from interface: HardTotalsInterface
      Validation part of Write method. Can be overwritten within derived classes, if necessary. This method shall only perform additional validation. It will be called before the service buffers the method call for synchronous or asynchronous execution. This method will be called only if the following plausibility checks lead to a positive result:
      • Device is enabled and not claimed by other instance,
      • The byte buffer consists of at least count bytes,
      • Both, offset and count, are ≥ 0 and their sum is %le; TotalsSize,
      • Device has not been claimed by another instance,
      • The hard totals file specified by hTotalsFile has not been claimed by another instance.
      Specified by:
      write in interface HardTotalsInterface
      Parameters:
      hTotalsFile - Handle of a totals file.
      data - Data to be written.
      offset - Starting offset for write operation.
      count - Number of bytes to be written.
      Returns:
      Write object for use in final part.
      Throws:
      jpos.JposException - If an error occurs.
    • write

      public void write(Write request) throws jpos.JposException
      Description copied from interface: HardTotalsInterface
      Final part of Write method. Can be overwritten within derived classes, if necessary. The parameters of the method will be passed via a Write object. This method will be called when the corresponding operation shall be performed, either synchronously during commit. All plausibility checks have been made before, only runtime errors can occur.
      The default implementation should be called within derived methods to ensure that the property TransactionInProgress is updated as expected.
      Specified by:
      write in interface HardTotalsInterface
      Parameters:
      request - Output request object returned by validation method that contains all parameters to be used by Write.
      Throws:
      jpos.JposException - If an error occurs.
    • rename

      public void rename(int hTotalsFile, String fileName) throws jpos.JposException
      Description copied from interface: HardTotalsInterface
      Final part of Rename method. Can be overwritten in derived class, if necessary. This method will be called only if the following plausibility checks lead to a positive result:
      • Device is enabled and not claimed by other instance,
      • if CapSingleFile is true, fileName is an empty string,
      • otherwise, fileName consists of no more than 10 ASCII characters (character codes between 0x20 and 0x7f,
      • The hard totals file specified by hTotalsFile has not been claimed by other instance.
      Specified by:
      rename in interface HardTotalsInterface
      Parameters:
      hTotalsFile - Handle of a totals file.
      fileName - New file name.
      Throws:
      jpos.JposException - If an error occurs.
    • rollback

      public void rollback() throws jpos.JposException
      Description copied from interface: HardTotalsInterface
      Final part of Rollback method. Can be overwritten in derived class, if necessary. This method will be called only if the following plausibility checks lead to a positive result:
      • Device is enabled,
      • CapTransactions and TransactionInProgress are true.
      Specified by:
      rollback in interface HardTotalsInterface
      Throws:
      jpos.JposException - If an error occurs.
    • validateData

      public void validateData(int hTotalsFile) throws jpos.JposException
      Description copied from interface: HardTotalsInterface
      Final part of OpenGate method. Can be overwritten in derived class, if necessary. This method will be called only if the following plausibility checks lead to a positive result:
      • Device is enabled and not claimed by other instance,
      • The hard totals file specified by hTotalsFile has not been claimed by other instance,
      • Device supports advanced error detection.
      Specified by:
      validateData in interface HardTotalsInterface
      Parameters:
      hTotalsFile - Handle of a totals file.
      Throws:
      jpos.JposException - If an error occurs.