View Javadoc
1   package com.srv4pos.server.api.sync.sample;
2   
3   import com.srv4pos.server.api.product.ProductInfo;
4   
5   import java.io.ByteArrayInputStream;
6   import java.io.InputStream;
7   
8   public class SyncProduct extends SyncEntity<ProductInfo> {
9       private byte[] icon;
10  
11      private SyncTax tax;
12  
13      public SyncProduct(ProductInfo info) {
14          super(info);
15      }
16  
17      public SyncProduct(ProductInfo info, boolean synced) {
18          super(info, synced);
19      }
20  
21      public SyncProduct(ProductInfo info, SyncTax tax) {
22          super(info);
23          this.tax = tax;
24      }
25  
26      public InputStream getPictureInputStream() {
27          return icon == null ? null : new ByteArrayInputStream(icon);
28      }
29  
30      public void setPictureBytes(byte[] buf) {
31          icon = new byte[buf.length];
32          System.arraycopy(buf, 0, icon, 0, buf.length);
33      }
34  
35      /**
36       * <p>This method is <b>for testing purposes only</b> (it is used in unit tests and in integration tests).
37       * Actual sync helpers (and thus sync algorithm) does not use it.</p>
38       * @return product picture as array of bytes
39       */
40      public byte[] getPictureBytes() {
41          return icon == null ? null : icon.clone();
42      }
43  
44      public SyncTax getTax() {
45          return tax;
46      }
47  
48      public void setTax(SyncTax tax) {
49          this.tax = tax;
50      }
51  }