←Select platform

Clone Method

Summary
Creates an exact copy of this barcode.
Syntax
C#
Objective-C
C++/CLI
Java
Python
public virtual BarcodeData Clone() 
- (instancetype)copy 
public BarcodeData clone() 
public: 
virtual BarcodeData^ Clone();  
def Clone(self): 

Return Value

The BarcodeData method creates, and casts the barcode as an object.

Remarks

This methods clones (creates a new object) of the byte array that represents that data obtained from GetData. This data will not be shared between this BarcodeData and the object that is returned.

However, Tag is user defined value and BarcodeData does not have rules to dictate what action to perform when the object is cloned. Therefore, this method will simply set the Tag property of the returned object to the value in the source object. It is up to the user to change this behavior.

Example
C#
Java
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Barcode; 
using Leadtools.ImageProcessing; 
 
 
public void BarcodeData_CloneExample() 
{ 
   // Create a BarcodeData object 
   BarcodeData data1 = new BarcodeData(BarcodeSymbology.UPCA, "01234567890"); 
   data1.Bounds = new LeadRect(0, 0, 400, 200); 
 
   // Clone it 
   BarcodeData data2 = data1.Clone() as BarcodeData; 
 
   // Make sure they have the same value but not same reference 
   Debug.Assert(data1 != data2); 
   Debug.Assert(data1.Symbology == data2.Symbology); 
   Debug.Assert(data1.Value == data2.Value); 
   Debug.Assert(data1.Bounds == data2.Bounds); 
 
   Console.WriteLine("Cloned OK"); 
} 
 
import java.io.File; 
import java.io.IOException; 
import java.nio.charset.StandardCharsets; 
 
import org.junit.*; 
import org.junit.runner.JUnitCore; 
import org.junit.runner.Result; 
import org.junit.runner.notification.Failure; 
import static org.junit.Assert.*; 
 
import leadtools.*; 
import leadtools.barcode.*; 
import leadtools.codecs.*; 
 
 
public void barcodeDataCloneExample() {  
   // Create a BarcodeData object 
   BarcodeData data1 = new BarcodeData(BarcodeSymbology.UPC_A, "01234567890"); 
   data1.setBounds(new LeadRect(0, 0, 400, 200)); 
 
   // Clone it 
   BarcodeData data2 = (BarcodeData)data1.clone(); 
 
   // Make sure they have the same value but not same reference 
   assertTrue(data1 != data2); 
   assertTrue("Unsuccessfully cloned", data1.getSymbology() == data2.getSymbology()); 
   System.out.println("Cloned OK"); 
} 
Requirements

Target Platforms

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Barcode Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.