@Test public void testSerialize() { final Path test = new Path("t", EnumSet.of(Path.Type.file)); CopyTransfer t = new CopyTransfer(new Host(new TestProtocol()), new Host(new TestProtocol()), Collections.singletonMap(test, new Path("d", EnumSet.of(Path.Type.file)))); t.addSize(4L); t.addTransferred(3L); final Transfer serialized = new TransferDictionary(new ProtocolFactory(Collections.singleton(new TestProtocol()))).deserialize(t.serialize(SerializerFactory.get())); assertNotSame(t, serialized); assertEquals(t.roots, serialized.getRoots()); assertEquals(t.getBandwidth(), serialized.getBandwidth()); assertEquals(4L, serialized.getSize(), 0L); assertEquals(3L, serialized.getTransferred(), 0L); }
@Override public <T> T serialize(final Serializer dict) { dict.setStringForKey(this.getType().name(), "Type"); dict.setObjectForKey(host, "Host"); if(destination != null) { dict.setObjectForKey(destination, "Destination"); } dict.setListForKey(new ArrayList<Serializable>(selected.values()), "Destinations"); dict.setListForKey(new ArrayList<Serializable>(selected.keySet()), "Roots"); dict.setStringForKey(uuid, "UUID"); dict.setStringForKey(String.valueOf(this.getSize()), "Size"); dict.setStringForKey(String.valueOf(this.getTransferred()), "Current"); if(timestamp != null) { dict.setStringForKey(String.valueOf(timestamp.getTime()), "Timestamp"); } if(bandwidth != null) { dict.setStringForKey(String.valueOf(bandwidth.getRate()), "Bandwidth"); } return dict.getSerialized(); }
CopyTransfer extends Transfer { @Override public <T> T serialize(final Serializer dict) { dict.setStringForKey(this.getType().name(), "Type"); dict.setObjectForKey(host, "Host"); if(destination != null) { dict.setObjectForKey(destination, "Destination"); } dict.setListForKey(new ArrayList<Serializable>(selected.values()), "Destinations"); dict.setListForKey(new ArrayList<Serializable>(selected.keySet()), "Roots"); dict.setStringForKey(uuid, "UUID"); dict.setStringForKey(String.valueOf(this.getSize()), "Size"); dict.setStringForKey(String.valueOf(this.getTransferred()), "Current"); if(timestamp != null) { dict.setStringForKey(String.valueOf(timestamp.getTime()), "Timestamp"); } if(bandwidth != null) { dict.setStringForKey(String.valueOf(bandwidth.getRate()), "Bandwidth"); } return dict.getSerialized(); } }
CopyTransfer extends Transfer { @Override public <T> T serialize(final Serializer dict) { dict.setStringForKey(this.getType().name(), "Type"); dict.setObjectForKey(host, "Host"); if(destination != null) { dict.setObjectForKey(destination, "Destination"); } dict.setListForKey(new ArrayList<Serializable>(selected.values()), "Destinations"); dict.setListForKey(new ArrayList<Serializable>(selected.keySet()), "Roots"); dict.setStringForKey(uuid, "UUID"); dict.setStringForKey(String.valueOf(this.getSize()), "Size"); dict.setStringForKey(String.valueOf(this.getTransferred()), "Current"); if(timestamp != null) { dict.setStringForKey(String.valueOf(timestamp.getTime()), "Timestamp"); } if(bandwidth != null) { dict.setStringForKey(String.valueOf(bandwidth.getRate()), "Bandwidth"); } return dict.getSerialized(); } CopyTransfer(final Host source, final Host destination,
                        final Map<Path, Path> selected);  CopyTransfer(final Host source, final Host destination,
                        final Map<Path, Path> selected, final BandwidthThrottle bandwidth); }
CopyTransfer extends Transfer { @Override public <T> T serialize(final Serializer dict) { dict.setStringForKey(this.getType().name(), "Type"); dict.setObjectForKey(host, "Host"); if(destination != null) { dict.setObjectForKey(destination, "Destination"); } dict.setListForKey(new ArrayList<Serializable>(selected.values()), "Destinations"); dict.setListForKey(new ArrayList<Serializable>(selected.keySet()), "Roots"); dict.setStringForKey(uuid, "UUID"); dict.setStringForKey(String.valueOf(this.getSize()), "Size"); dict.setStringForKey(String.valueOf(this.getTransferred()), "Current"); if(timestamp != null) { dict.setStringForKey(String.valueOf(timestamp.getTime()), "Timestamp"); } if(bandwidth != null) { dict.setStringForKey(String.valueOf(bandwidth.getRate()), "Bandwidth"); } return dict.getSerialized(); } CopyTransfer(final Host source, final Host destination,
                        final Map<Path, Path> selected);  CopyTransfer(final Host source, final Host destination,
                        final Map<Path, Path> selected, final BandwidthThrottle bandwidth); @Override Transfer withCache(final Cache<Path> cache); @Override Type getType(); @Override Host getDestination(); @Override String getLocal(); @Override T serialize(final Serializer dict); @Override TransferAction action(final Session<?> source, final Session<?> destination, boolean resumeRequested, boolean reloadRequested,
                                 final TransferPrompt prompt, final ListProgressListener listener); @Override TransferPathFilter filter(final Session<?> source, final Session<?> destination, final TransferAction action, final ProgressListener listener); @Override List<TransferItem> list(final Session<?> session, final Path directory, final Local local,
                                   final ListProgressListener listener); @Override void pre(final Session<?> source, final Session<?> destination, final Map<TransferItem, TransferStatus> files, final ConnectionCallback callback); @Override void post(final Session<?> source, final Session<?> destination, final Map<TransferItem, TransferStatus> files, final ConnectionCallback callback); @Override void transfer(final Session<?> session, final Session<?> destination, final Path source, final Local n,
                         final TransferOptions options, final TransferStatus status,
                         final ConnectionCallback connectionCallback,
                         final ProgressListener listener, final StreamListener streamListener); @Override void normalize(); }
CopyTransfer extends Transfer { @Override public <T> T serialize(final Serializer dict) { dict.setStringForKey(this.getType().name(), "Type"); dict.setObjectForKey(host, "Host"); if(destination != null) { dict.setObjectForKey(destination, "Destination"); } dict.setListForKey(new ArrayList<Serializable>(selected.values()), "Destinations"); dict.setListForKey(new ArrayList<Serializable>(selected.keySet()), "Roots"); dict.setStringForKey(uuid, "UUID"); dict.setStringForKey(String.valueOf(this.getSize()), "Size"); dict.setStringForKey(String.valueOf(this.getTransferred()), "Current"); if(timestamp != null) { dict.setStringForKey(String.valueOf(timestamp.getTime()), "Timestamp"); } if(bandwidth != null) { dict.setStringForKey(String.valueOf(bandwidth.getRate()), "Bandwidth"); } return dict.getSerialized(); } CopyTransfer(final Host source, final Host destination,
                        final Map<Path, Path> selected);  CopyTransfer(final Host source, final Host destination,
                        final Map<Path, Path> selected, final BandwidthThrottle bandwidth); @Override Transfer withCache(final Cache<Path> cache); @Override Type getType(); @Override Host getDestination(); @Override String getLocal(); @Override T serialize(final Serializer dict); @Override TransferAction action(final Session<?> source, final Session<?> destination, boolean resumeRequested, boolean reloadRequested,
                                 final TransferPrompt prompt, final ListProgressListener listener); @Override TransferPathFilter filter(final Session<?> source, final Session<?> destination, final TransferAction action, final ProgressListener listener); @Override List<TransferItem> list(final Session<?> session, final Path directory, final Local local,
                                   final ListProgressListener listener); @Override void pre(final Session<?> source, final Session<?> destination, final Map<TransferItem, TransferStatus> files, final ConnectionCallback callback); @Override void post(final Session<?> source, final Session<?> destination, final Map<TransferItem, TransferStatus> files, final ConnectionCallback callback); @Override void transfer(final Session<?> session, final Session<?> destination, final Path source, final Local n,
                         final TransferOptions options, final TransferStatus status,
                         final ConnectionCallback connectionCallback,
                         final ProgressListener listener, final StreamListener streamListener); @Override void normalize();  }