Class POSPrinter

All Implemented Interfaces:
JposBaseInterface, POSPrinterInterface

public class POSPrinter extends POSPrinterProperties
Class implementing the POSPrinterInterface for the sample pos printer.
  • Constructor Details

    • POSPrinter

      public POSPrinter(Device dev)
      Constructor. Gets instance of Device to be used as communication object. Device index for sample is always 0.
      Parameters:
      dev - Instance of Device this object belongs to.
  • Method Details

    • 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
    • release

      public void release() throws jpos.JposException
      Description copied from interface: JposBaseInterface
      Final part of release 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 claimed,
      • ExclusiveUse equals ExclusiveYes: Device is not enabled.
      Specified by:
      release in interface JposBaseInterface
      Overrides:
      release in class JposCommonProperties
      Throws:
      jpos.JposException - See UPOS specification, method Release
    • 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
    • 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
    • mapMode

      public void mapMode(int i) throws jpos.JposException
      Description copied from interface: POSPrinterInterface
      Final part of setting MapMode. 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,
      • The new value is one of MM_DOTS, MM_TWIPS, MM_ENGLISH or MM_METRIC.
      Specified by:
      mapMode in interface POSPrinterInterface
      Overrides:
      mapMode in class POSPrinterProperties
      Parameters:
      i - New MapMode value
      Throws:
      jpos.JposException - If an error occurs
    • characterSet

      public void characterSet(int value) throws jpos.JposException
      Description copied from interface: POSPrinterInterface
      Final part of setting CharacterSet. 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,
      • CapJrnCartridgeSensor, CapRecCartridgeSensor or CapSlpCartridgeSensor is not 0,
      • The new value is one of the values specified in CharacterSetList.
      Specified by:
      characterSet in interface POSPrinterInterface
      Overrides:
      characterSet in class POSPrinterProperties
      Parameters:
      value - New character set value
      Throws:
      jpos.JposException - If an error occurs
    • recLineChars

      public void recLineChars(int value) throws jpos.JposException
      Description copied from interface: POSPrinterInterface
      Final part of setting RecLineChars. 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,
      • CapRecPresent is true,
      • The new value is ≥ 0 and ≤ the maximum value specified in RecLineCharsList.
      Specified by:
      recLineChars in interface POSPrinterInterface
      Overrides:
      recLineChars in class POSPrinterProperties
      Parameters:
      value - New RecLineChars value
      Throws:
      jpos.JposException - If an error occurs
    • recLineHeight

      public void recLineHeight(int i) throws jpos.JposException
      Description copied from interface: POSPrinterInterface
      Final part of setting RecLineHeight. 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,
      • CapRecPresent is true.
      Specified by:
      recLineHeight in interface POSPrinterInterface
      Overrides:
      recLineHeight in class POSPrinterProperties
      Parameters:
      i - New RecLineHeight value
      Throws:
      jpos.JposException - If an error occurs
    • recLineSpacing

      public void recLineSpacing(int i) throws jpos.JposException
      Description copied from interface: POSPrinterInterface
      Final part of setting RecLineSpacing. 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,
      • CapRecPresent is true.
      Specified by:
      recLineSpacing in interface POSPrinterInterface
      Overrides:
      recLineSpacing in class POSPrinterProperties
      Parameters:
      i - New RecLineSpacing value
      Throws:
      jpos.JposException - If an error occurs
    • getLogoData

      public POSPrinterService.PrintDataPart[] getLogoData(boolean top)
      Description copied from interface: POSPrinterInterface
      This method will be called whenever print data contain a logo print sequence ESC|tL or ESC|bL. Since it is possible that logos can be changed between the print call and execution of methods for asynchronous print, e.g. when transaction printing will be used, data describing the logo must be retrieved by POSPrinterService whenever an EscLogo object is generated. Every POSPrinter service implementation must overwrite this method because only the specific service stores information about the logo data. However, logo data are of type POSPrinterService.PrintDataPart[], where POSPrinterService.PrintDataPart is one of the objects supported by validateData(int, POSPrinterService.PrintDataPart). As default, this method returns an empty list of objects.
      Specified by:
      getLogoData in interface POSPrinterInterface
      Overrides:
      getLogoData in class POSPrinterProperties
      Parameters:
      top - Specifies which logo data shall be filled, true for top logo, false for bottom logo.
      Returns:
      POSPrinterService.PrintDataPart array containing logo data. Array is empty if the requested logo has not been set.
    • setLogo

      public void setLogo(int location, String data) throws jpos.JposException
      Description copied from interface: POSPrinterInterface
      Final part of SetLogo 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,
      • Selected location is L_TOP or L_BOTTOM,
      • data is not null.
      Specified by:
      setLogo in interface POSPrinterInterface
      Overrides:
      setLogo in class POSPrinterProperties
      Parameters:
      location - See UPOS specification, method SetLogo.
      data - See UPOS specification, method SetLogo.
      Throws:
      jpos.JposException - See UPOS specification, method SetLogo.
    • validateData

      public void validateData(int station, POSPrinterService.PrintData data) throws jpos.JposException
      Description copied from interface: POSPrinterInterface
      Validate printable character sequence. ESC sequences, CR and LF have been filtered out. Default behavior is that all other characters with character code ≤ 0x20 are invalid. If a service should support more characters, this method must be overwritten.
      Keep in mind that data may contain an empty string. In that case, it marks the end of printable data in cases where the last character was a CR to support post-validation of CR.
      Specified by:
      validateData in interface POSPrinterInterface
      Overrides:
      validateData in class POSPrinterProperties
      Parameters:
      station - POSPrinter station, one of S_JOURNAL, S_RECEIPT or S_SLIP.
      data - Data to be printed.
      Throws:
      jpos.JposException - For details, see UPOS method ValidateData.
    • validateData

      public void validateData(int station, POSPrinterService.ControlChar ctrl) throws jpos.JposException
      Description copied from interface: POSPrinterInterface
      Validate control character. One of CR or LF. Default behavior is that both characters are valid. CR will be passed to ValidateData only once for any sequence of multiple CR in the original data stream and only if LF is neither the previous nor the following character. However, even if the printer supports CR, CR might be valid behind or in case of a following escape sequence.
      Specified by:
      validateData in interface POSPrinterInterface
      Overrides:
      validateData in class POSPrinterProperties
      Parameters:
      station - POSPrinter station, one of S_JOURNAL, S_RECEIPT or S_SLIP.
      ctrl - ControlChar object, representing CR or LF.
      Throws:
      jpos.JposException - For details, see UPOS method ValidateData.
    • validateData

      public void validateData(int station, POSPrinterService.EscLogo esc) throws jpos.JposException
      Description copied from interface: POSPrinterInterface
      Validate logo sequence. For details, see UPOS specification of ESC|xL. The default behavior is to assume that requests to print a logo are always valid. The following plausibility checks will be made before this method will be called:
      • The printer station is valid.
      Specified by:
      validateData in interface POSPrinterInterface
      Overrides:
      validateData in class POSPrinterProperties
      Parameters:
      station - A valid printer station, S_RECEIPT, S_JOURNAL or S_SLIP.
      esc - EscLogo object containing sequence attributes.
      Throws:
      jpos.JposException - For details, see UPOS method ValidateData.
    • validateData

      public void validateData(int station, POSPrinterService.EscFeed esc) throws jpos.JposException
      Description copied from interface: POSPrinterInterface
      Validate feed sequence. For details, see UPOS specification of ESC|[#]xF. Default behavior is that all count values are valid. The following plausibility checks will be made before this method will be called:
      • The printer station is valid.
      Specified by:
      validateData in interface POSPrinterInterface
      Overrides:
      validateData in class POSPrinterProperties
      Parameters:
      station - A valid printer station, S_RECEIPT, S_JOURNAL or S_SLIP.
      esc - EscFeed object containing the sequence attributes.
      Throws:
      jpos.JposException - For details, see UPOS method ValidateData.
    • validateData

      public void validateData(int station, POSPrinterService.EscEmbedded esc) throws jpos.JposException
      Description copied from interface: POSPrinterInterface
      Validate embedded data sequence. For details, see UPOS specification of ESC|[*]#E. Default behavior is that the given sequence is valid. The following plausibility checks will be made before this method will be called:
      • The printer station is valid.
      Specified by:
      validateData in interface POSPrinterInterface
      Overrides:
      validateData in class POSPrinterProperties
      Parameters:
      station - A valid printer station, S_RECEIPT, S_JOURNAL or S_SLIP.
      esc - EscEmbedded object containing sequence attributes.
      Throws:
      jpos.JposException - For details, see UPOS method ValidateData.
    • validateData

      public void validateData(int station, POSPrinterService.EscCut esc) throws jpos.JposException
      Description copied from interface: POSPrinterInterface
      Validate cut sequence. For details, see UPOS specification of ESC|[#][x]P. Default behavior is that a service supports only full cut and no cut (CP_FULLCUT and 0 percent). If a service supports more values, this method must be overwritten. The following plausibility checks will be made before this method will be called:
      • The printer station is valid,
      • Capability CapXxxPapercut is true,
      • EscCut attribute Stamp is false or CapXxxStamp is true.
      Specified by:
      validateData in interface POSPrinterInterface
      Overrides:
      validateData in class POSPrinterProperties
      Parameters:
      station - S_RECEIPT.
      esc - EscCut object containing sequence attributes.
      Throws:
      jpos.JposException - For details, see UPOS method ValidateData.
    • cutPaper

      public void cutPaper(CutPaper request) throws jpos.JposException
      Description copied from interface: POSPrinterInterface
      Final part of CutPaper method. Can be overwritten within derived classes, if necessary. The parameters of the method will be passed via a CutPaper 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.
      In case of asynchronous processing, the following additional checks have been made before invocation:
      • Receipt paper is present.
      • Cover is closed.
      • If present, cartridge is operational.
      Specified by:
      cutPaper in interface POSPrinterInterface
      Overrides:
      cutPaper in class POSPrinterProperties
      Parameters:
      request - Output request object returned by validation method that contains all parameters to be used by CutPaper.
      Throws:
      jpos.JposException - For details, see UPOS method CutPaper.
    • printNormal

      public PrintNormal printNormal(int station, String data) throws jpos.JposException
      Description copied from interface: POSPrinterInterface
      Validation part of PrintNormal method. For details, see UPOS specification. 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,
      • If AsyncMode is false: State is S_IDLE, paper present, cover closed and if present, cartridge is operational,
      • station is valid (S_JOURNAL, S_RECEIPT or S_SLIP and the corresponding CapXxxPresent is true),
      • data is not null.
      Specified by:
      printNormal in interface POSPrinterInterface
      Overrides:
      printNormal in class POSPrinterProperties
      Parameters:
      station - Print station, see UPOS method PrintNormal.
      data - Print data. See UPOS method PrintNormal.
      Returns:
      PrintNormal object for use in final part.
      Throws:
      jpos.JposException - For details, see UPOS method PrintNormal.
    • printImmediate

      public PrintImmediate printImmediate(int station, String data) throws jpos.JposException
      Description copied from interface: POSPrinterInterface
      Validation part of PrintImmediate method. For details, see UPOS specification. 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 (high-priority) execution. This method will be called only if the following plausibility checks lead to a positive result:
      • Device is enabled,
      • Selected station is S_JOURNAL, S_RECEIPT or S_SLIP,
      • The cover is closed, paper present, head ready and cartridge neither empty nor removed.
      If the service supports page mode but does not support immediate printing in page mode, this method must be overwritten. In this case, it must throw E_ILLEGAL if called in page mode. Keep in mind: Since PrintImmediate prints always synchronously, but page mode printing will start after leaving page mode, PrintImmediate prints outside page mode before page mode printing starts. This is also the case in sideways print mode.
      Specified by:
      printImmediate in interface POSPrinterInterface
      Overrides:
      printImmediate in class POSPrinterProperties
      Parameters:
      station - See UPOS specification, method PrintImmediate.
      data - Print data. See UPOS specification, method PrintImmediate.
      Returns:
      PrintImmediate object for use in final part.
      Throws:
      jpos.JposException - See UPOS specification, method PrintImmediate.
    • printNormal

      public void printNormal(PrintNormal request) throws jpos.JposException
      Description copied from interface: POSPrinterInterface
      Final part of PrintNormal method. Can be overwritten within derived classes, if necessary. The parameters of the method will be passed via a PrintNormal 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.
      In case of asynchronous processing, the following additional checks have been made before invocation:
      • The station specified by request.getStation() is present.
      • Cover is closed.
      • If present, cartridge is operational.
      Specified by:
      printNormal in interface POSPrinterInterface
      Overrides:
      printNormal in class POSPrinterProperties
      Parameters:
      request - Output request object returned by validation method that contains all parameters to be used by PrintNormal.
      Throws:
      jpos.JposException - For details, see UPOS method PrintNormal.
    • transactionPrint

      public void transactionPrint(TransactionPrint request) throws jpos.JposException
      Description copied from interface: POSPrinterInterface
      Final part of TransactionPrint method. Can be overwritten within derived classes, if necessary. The parameters of the method will be passed via a TransactionPrint 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.
      In case of asynchronous processing, the following additional checks have been made before invocation:
      • The station specified by request.getStation() is present.
      • Cover is closed.
      • If present, cartridge is operational.
      Specified by:
      transactionPrint in interface POSPrinterInterface
      Overrides:
      transactionPrint in class POSPrinterProperties
      Parameters:
      request - Output request object returned by validation method that contains all parameters to be used by TransactionPrint.
      Throws:
      jpos.JposException - For details, see UPOS method TransactionPrint.