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