const _MwWrapper = require("../_mwbridge/_mw-wrapper.js");
const BarCodeRegionParameters = require("./barcode-region-parameters");
const BarCodeExtendedParameters = require("./barcode-extended-parameters");
/**
* Stores recognized barcode data like SingleDecodeType type, {@code string} codetext,<br>
* BarCodeRegionParameters region and other parameters
* @example
* //This sample shows how to obtain BarCodeResult.
* let generator = new BarcodeGenerator(EncodeTypes.Code128, "12345");
* generator.save("test.png");
* let reader = new BarCodeReader("test.png", null, [ DecodeType.CODE_39, DecodeType.CODE_128 ]);
* let results = reader.readBarCodes();
* for(let i = 0; i < results.length; i++)
* {
* let result = results[i];
* console.log("BarCode Type: " + result.getCodeTypeName());
* console.log("BarCode CodeText: " + result.getCodeText());
* console.log("BarCode Confidence: " + result.getConfidence());
* console.log("BarCode ReadingQuality: " + result.getReadingQuality());
* console.log("BarCode Angle: " + result.getRegion().getAngle());
* }
*/
class BarCodeResult extends _MwWrapper
{
region;
extended;
constructor(javaclass)
{
super(javaclass);
this._initializeWrapperMembers()
}
_initializeWrapperMembers()
{
this.region = new BarCodeRegionParameters(this.getJavaClass().getRegionSync());
this.extended = new BarCodeExtendedParameters(this.getJavaClass().getExtendedSync());
}
/**
* Gets the reading quality. Works for 1D and postal barcodes. Value: The reading quality percent
*/
getReadingQuality()
{
return this.getJavaClass().getReadingQualitySync();
}
/**
* Gets recognition confidence level of the recognized barcode Value: <br>
* BarCodeConfidence.Strong does not have fakes or misrecognitions, BarCodeConfidence.Moderate<br>
* could sometimes have fakes or incorrect codetext because this confidence level for barcodews with weak cheksum or even without it,<br>
* BarCodeConfidence.NONE always has incorrect codetext and could be fake recognitions
*/
getConfidence()
{
return this.getJavaClass().getConfidenceSync();
}
/**
* <p>
* Gets the code text with encoding.
* </p><p><hr><blockquote><pre>
* <p>This example shows how to use {@code getCodeText}:</p>
* <pre>
* let gen = new BarcodeGenerator(EncodeTypes.DATA_MATRIX, null);
* gen.setCodeText("車種名", "932");
* gen.save("barcode.png", BarCodeImageFormat.PNG);
*
* let reader = new BarCodeReader("barcode.png", null, DecodeType.DATA_MATRIX);
* let results = reader.readBarCodes();
* for(let i = 0; i < results.length; i++)
* {
* let result = results[i];
* console.log("BarCode CodeText: " + result.getCodeText("932"));
* }
* </pre>
* </pre></blockquote></hr></p>
* @return A string containing recognized code text.
* @param encoding The encoding for codetext.
*/
getCodeText(encoding)
{
return this.getJavaClass().getCodeTextSync(encoding);
}
/**
* Gets the encoded code bytes Value: The code bytes of the barcode
*/
getCodeBytes()
{
let javaArray = this.getJavaClass().getCodeBytesSync();
return Array.from(javaArray);
}
/**
* Gets the barcode type Value: The type information of the recognized barcode
*/
getCodeType()
{
return this.getJavaClass().getCodeTypeSync();
}
/**
* Gets the name of the barcode type Value: The type name of the recognized barcode
*/
getCodeTypeName()
{
return this.getJavaClass().getCodeTypeNameSync();
}
/**
* Gets the barcode region Value: The region of the recognized barcode
*/
getRegion()
{
return this.region;
}
/**
* Gets extended parameters of recognized barcode Value: The extended parameters of recognized barcode
*/
getExtended()
{
return this.extended;
}
/**
* Returns a value indicating whether this instance is equal to a specified BarCodeResult value.
*
* @param other An BarCodeResult value to compare to this instance.
* @return true if obj has the same value as this instance; otherwise, false.
*/
equals(other)
{
return this.getJavaClass().equalsSync(other.getJavaClass());
}
/**
* Returns the hash code for this instance.
*
* @return A 32-bit signed integer hash code.
*/
hashCode()
{
return this.getJavaClass().hashCodeSync();
}
/**
* Returns a human-readable string representation of this BarCodeResult.
*
* @return A string that represents this BarCodeResult.
*/
toString()
{
return this.getJavaClass().toStringSync();
}
/**
* Creates a copy of BarCodeResult class.
*
* @return Returns copy of BarCodeResult class.
*/
deepClone()
{
return new BarCodeResult(this);
}
}
module.exports = BarCodeResult;