1 18 19 package sync4j.server.engine; 20 21 import sync4j.framework.engine.SyncItem; 22 import sync4j.framework.engine.SyncItemKey; 23 import sync4j.framework.engine.SyncItemImpl; 24 25 import sync4j.framework.core.Item; 26 import sync4j.framework.core.ComplexData; 27 import sync4j.framework.core.Target; 28 import sync4j.framework.core.Source; 29 30 38 public class SyncItemHelper { 39 41 public static final String PROPERTY_COMMAND = "PROPERTY_COMMAND"; 42 43 45 56 public static Item toItem(String key , 57 SyncItem syncItem , 58 boolean includeTarget, 59 boolean includeSource, 60 boolean includeData ) { 61 ComplexData data = null; 62 63 if (includeData) { 64 data = new ComplexData( 65 new String ((byte[])syncItem.getPropertyValue(SyncItem.PROPERTY_BINARY_CONTENT)) 66 ); 67 } 68 69 Target target = null; 70 Source source = null; 71 72 if (includeTarget) { 73 target = new Target(key); 74 } 75 76 if (includeSource) { 77 source = new Source(key); 78 } 79 80 return new Item(target, 81 source, 82 null , data , 84 false); } 86 87 94 public static SyncItem newMappedSyncItem(SyncItemKey key, SyncItem fromSyncItem) { 95 SyncItemImpl syncItem 96 = new SyncItemImpl(fromSyncItem.getSyncSource() , 97 key.getKeyAsString() , 98 fromSyncItem.getKey().getKeyAsString(), 99 fromSyncItem.getState() ); 100 101 syncItem.setProperties(fromSyncItem.getProperties()); 102 103 return syncItem; 104 } 105 } | Popular Tags |