KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > axis > attachments > DimeMultiPart


1 /*
2  * Copyright (C) The Apache Software Foundation. All rights reserved.
3  *
4  * This software is published under the terms of the Apache Software License
5  * version 1.1, a copy of which has been included with this distribution in
6  * the docs/licenses/apache-1.1.txt file.
7  */

8
9 package org.jboss.axis.attachments;
10
11
12 /**
13  * This class hold all parts of a DIME multipart message.
14  * @author Rick Rineholt
15  */

16
17 public final class DimeMultiPart
18 {
19    static final long transSize = Integer.MAX_VALUE;
20    static final byte CURRENT_VERSION = 1; //Anything above this we don't support.
21
protected java.util.Vector JavaDoc parts = new java.util.Vector JavaDoc();
22
23    public DimeMultiPart()
24    {
25    }
26
27    public void addBodyPart(DimeBodyPart part)
28    {
29       parts.add(part);
30    }
31
32    public void write(java.io.OutputStream JavaDoc os)
33            throws java.io.IOException JavaDoc
34    {
35       int size = parts.size();
36       int last = size - 1;
37
38       for (int i = 0; i < size; ++i)
39          ((DimeBodyPart)parts.elementAt(i)).write(os,
40                  (byte)((i == 0 ? DimeBodyPart.POSITION_FIRST :
41                  (byte)0)
42                  | (i == last ? DimeBodyPart.POSITION_LAST :
43                  (byte)0)), transSize);
44    }
45
46    public long getTransmissionSize()
47    {
48       long size = 0;
49
50       for (int i = parts.size() - 1; i > -1; --i)
51          size +=
52                  ((DimeBodyPart)parts.elementAt(i)).getTransmissionSize(transSize);
53
54       return size;
55    }
56 }
57
Popular Tags