From 46a03a3ea3c26a65e4428bc9de036a01487aeda3 Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Fri, 17 Oct 2003 17:34:54 +0000 Subject: First go at refactoring for PathSpecs --- src/org/noreply/fancydress/type3/Payload.java | 49 ++++++++++----------------- 1 file changed, 18 insertions(+), 31 deletions(-) (limited to 'src/org/noreply/fancydress/type3/Payload.java') diff --git a/src/org/noreply/fancydress/type3/Payload.java b/src/org/noreply/fancydress/type3/Payload.java index 16b1b57..73027cd 100644 --- a/src/org/noreply/fancydress/type3/Payload.java +++ b/src/org/noreply/fancydress/type3/Payload.java @@ -8,34 +8,10 @@ import org.noreply.fancydress.misc.Util; import org.noreply.fancydress.type3.routing.*; public class Payload { - byte[] thisPayload; - - public Payload() { - RoutingSMTP route = new RoutingSMTP("peter@palfrader.org"); - String body = "FROM:Peter\n" + - "SUBJECT:test fancydress\n" + - "\n" + - "blubb\n"; - - /* - // Encode a String into bytes - String inputString = "blahblahblah??"; - byte[] input = inputString.getBytes("UTF-8"); - - // Compress the bytes - byte[] output = new byte[100]; - Deflater compresser = new Deflater(); - compresser.setInput(input); - compresser.finish(); - int compressedDataLength = compresser.deflate(output); - - // Decompress the bytes - Inflater decompresser = new Inflater(); - decompresser.setInput(output, 0, compressedDataLength); - byte[] result = new byte[100]; - int resultLength = decompresser.inflate(result); - decompresser.end(); - */ + byte[][] payloads; + RoutingDestination[] route; + + public Payload(RoutingDestination route, String body) { try { PipedOutputStream poMessage = new PipedOutputStream(); PipedInputStream piMessage = new PipedInputStream( poMessage ); @@ -77,18 +53,29 @@ public class Payload { if (pos != 28*1024) throw new Error("did not fill in 28k bytes"); - thisPayload = payload; + payloads = new byte[1][]; + payloads[0] = payload; } catch (Exception e) { throw new Error(e); }; + this.route = new RoutingDestination[1]; + this.route[0] = route; // Return a singleton payload containing: // Flag 0 | Int(15,LEN(M_C)) | Hash(M_C | PADDING) | M_C | PADDING } - public byte[] asOctets() { - return thisPayload; + public int numPackets() { + return payloads.length; + } + + public byte[] getPayload(int i) { + return payloads[i]; + } + + public RoutingDestination getRoute(int i) { + return route[i]; } } -- cgit v1.2.3