Class FiscalPrinterToDecimalWrapper
java.lang.Object
de.gmxhome.conrad.jpos.jpos_base.fiscalprinter.FiscalPrinterToDecimalWrapper
- All Implemented Interfaces:
jpos.loader.JposServiceInstanceFactory
public class FiscalPrinterToDecimalWrapper
extends Object
implements jpos.loader.JposServiceInstanceFactory
Wrapper class as interface between applications and services which use different kinds of currency-to-string
conversion.
No wrapper is necessary for applications which use the same conversion as the unwrapped service: Given a value of
123.4567, stored in a long with implicit 4 decimal, two conversions are possible: Conversion to a decimal string
with decimal point ("123.4567") or conversion to a string which represents the internal long value ("1234567").
If both, application and service, use the same type of conversion, no wrapper is necessary.
If the application used the internal value representation, but the service works with decimal string with decimal point, this wrapper class can be used to translate between both representations on-the-fly.
If the application uses decimal strings with decimal point but the service uses the internal value representation, use the FiscalPrinterToIntegerWrapper class.
Configuration is as follows: The name of the wrapper class must be configured within the factoryClass attribute of the creation tag present in the JposEntry tag of jpos.xml. The name of the service class must be specified in the serviceClass attribute of the same creation tag.
The name of the class factory of the service class must be specified in the value attribute of a prop tag with JavaPOS_SPF_WrappedClassFactory in the corresponding name attribute. Furthermore, to specify the position of an optional percent character in the amount of a package adjustment, a boolean property JavaPOS_SPF_TrailingPercent can be used. The default value is true. To allow a leading percent character, the value must be false.
Here a sample to configure this wrapper for a service named sample.FiscalPrinterService with a factory class sample.FiscalPrinterFactory that expects a leading percent character to specify a percent value in package adjustments:
If both, application and service, use the same type of conversion, no wrapper is necessary.
If the application used the internal value representation, but the service works with decimal string with decimal point, this wrapper class can be used to translate between both representations on-the-fly.
If the application uses decimal strings with decimal point but the service uses the internal value representation, use the FiscalPrinterToIntegerWrapper class.
Configuration is as follows: The name of the wrapper class must be configured within the factoryClass attribute of the creation tag present in the JposEntry tag of jpos.xml. The name of the service class must be specified in the serviceClass attribute of the same creation tag.
The name of the class factory of the service class must be specified in the value attribute of a prop tag with JavaPOS_SPF_WrappedClassFactory in the corresponding name attribute. Furthermore, to specify the position of an optional percent character in the amount of a package adjustment, a boolean property JavaPOS_SPF_TrailingPercent can be used. The default value is true. To allow a leading percent character, the value must be false.
Here a sample to configure this wrapper for a service named sample.FiscalPrinterService with a factory class sample.FiscalPrinterFactory that expects a leading percent character to specify a percent value in package adjustments:
<creation factoryClass="de.gmxhome.conrad.jpos.jpos_base.fiscalprinter.FiscalPrinterToDecimalWrapper" serviceClass="sample.FiscalPrinterService"/>
<prop name="JavaPOS_SPF_WrappedClassFactory" value="sample.FiscalPrinterFactory"/>
<prop name="JavaPOS_SPF_TrailingPercent" value="false"/>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionjpos.loader.JposServiceInstance
createInstance(String name, jpos.config.JposEntry jposEntry)
-
Constructor Details
-
FiscalPrinterToDecimalWrapper
public FiscalPrinterToDecimalWrapper()
-
-
Method Details
-
createInstance
public jpos.loader.JposServiceInstance createInstance(String name, jpos.config.JposEntry jposEntry) throws jpos.JposException- Specified by:
createInstance
in interfacejpos.loader.JposServiceInstanceFactory
- Throws:
jpos.JposException
-