Class CashDrawer

  • Direct Known Subclasses:

    public abstract class CashDrawer
    extends Object
    An abstraction for a cash drawer. The identifier and drawer number together may be used to uniquely identify each particular cash drawer. New identifiers may be added as new cash drawers are supported by Clover but values for existing cash drawers will not change and may be saved in persistent storage. Here are example values:
       identifier                     drawer number
       ----------                     -------------
       com.clover.BAYLEAF             1
       com.clover.BAYLEAF             2
       com.clover.USB                 1
       com.clover.USB                 2
       com.clover.USB                 3
       com.clover.FUTUREX             1
       org.otherapp.XYZ77             1
    No two drawers will ever have the same pair of identifier and drawer number.
    • Field Detail

      • TAG

        protected static final String TAG
      • context

        protected Context context
      • drawerNumber

        protected final int drawerNumber
    • Constructor Detail

      • CashDrawer

        protected CashDrawer​(Context context,
                             int drawerNumber)
    • Method Detail

      • getIdentifier

        public abstract String getIdentifier()
        The identifier String along with the drawer number uniquely identify cash drawer. Some examples (not exhaustive) are:
        Subclasses written by 3rd party developers should never prefix their cash drawer identifier with "com.clover" to avoid conflicts with cash drawers discovered by Clover Services.
        the identifier, never null
      • getDrawerNumber

        public int getDrawerNumber()
        Get the cash drawer number for this identifier. Numbers start from 1 and counting up with no gaps. Each identifier has it's own sequence.
      • getDisplayName

        public abstract String getDisplayName()
        A human readable name for this cash drawer. The name does not include the drawer number. The name is adjusted to the currently chosen device locale.
      • pop

        public abstract boolean pop()
        Attempt to pop (open) this cash drawer.

        This method may perform blocking IO operations depending on the specific cash drawer hardware. It must not be called from the main (UI) thread.

        Direct use of this method is not recommended, prefer to use the CashEvents class to pop the cash drawer so that cash event logging is also performed.

        false indicates the cash drawer definitely did not open, true indicates the cash drawer likely opened but possibly did not open due to mechanical or electrical issues or may simply be locked.
      • hashCode

        public int hashCode()
        hashCode in class Object
      • getUniqueIdentifier

        public final String getUniqueIdentifier()
        Get a completely unique identifier for this cash drawer as a String which includes the identifier and drawer number.