~ubuntu-branches/ubuntu/feisty/libitext-java/feisty

« back to all changes in this revision

Viewing changes to com/lowagie/bc/asn1/DERConstructedSet.java

  • Committer: Bazaar Package Importer
  • Author(s): Gerardo Curiel
  • Date: 2006-09-21 00:08:53 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20060921000853-le9rrpcnw9fc57sm
Tags: 1.4.5-1
* New upstream release
* debian/rules modified due to a new build.xml file
* Patched Pdfgraphics2d.java to remove privative dependencie on com.sun.image.codec.jpeg.*
  (more information on
  http://developer.classpath.org/mediation/ClasspathMigration#head-d4ee9efe53a641e29ffdcd96e985bf38bbc671c1 )
* ant/.ant.properties paths fixed
* Build package with the packages provided by java-gcj-compat-dev
* Removed unused README.Debian
* Removed unused debian/patches/01libitext-java-addbuildscript.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* see bouncycastle_license.txt */
 
2
 
 
3
package com.lowagie.bc.asn1;
 
4
 
 
5
import java.io.ByteArrayOutputStream;
 
6
import java.io.IOException;
 
7
import java.util.Enumeration;
 
8
 
 
9
public class DERConstructedSet
 
10
    extends ASN1Set
 
11
{
 
12
    public DERConstructedSet()
 
13
    {
 
14
    }
 
15
 
 
16
    /**
 
17
     * @param obj - a single object that makes up the set.
 
18
     */
 
19
    public DERConstructedSet(
 
20
        DEREncodable   obj)
 
21
    {
 
22
        this.addObject(obj);
 
23
    }
 
24
 
 
25
    /**
 
26
     * @param v - a vector of objects making up the set.
 
27
     */
 
28
    public DERConstructedSet(
 
29
        DEREncodableVector   v)
 
30
    {
 
31
        for (int i = 0; i != v.size(); i++)
 
32
        {
 
33
            this.addObject(v.get(i));
 
34
        }
 
35
    }
 
36
 
 
37
    public void addObject(
 
38
        DEREncodable    obj)
 
39
    {
 
40
        super.addObject(obj);
 
41
    }
 
42
 
 
43
    public int getSize()
 
44
    {
 
45
        return size();
 
46
    }
 
47
 
 
48
    /*
 
49
     * A note on the implementation:
 
50
     * <p>
 
51
     * As DER requires the constructed, definite-length model to
 
52
     * be used for structured types, this varies slightly from the
 
53
     * ASN.1 descriptions given. Rather than just outputing SET,
 
54
     * we also have to specify CONSTRUCTED, and the objects length.
 
55
     */
 
56
    void encode(
 
57
        DEROutputStream out)
 
58
        throws IOException
 
59
    {
 
60
        ByteArrayOutputStream   bOut = new ByteArrayOutputStream();
 
61
        DEROutputStream         dOut = new DEROutputStream(bOut);
 
62
        Enumeration             e = this.getObjects();
 
63
 
 
64
        while (e.hasMoreElements())
 
65
        {
 
66
            Object    obj = e.nextElement();
 
67
 
 
68
            dOut.writeObject(obj);
 
69
        }
 
70
 
 
71
        dOut.close();
 
72
 
 
73
        byte[]  bytes = bOut.toByteArray();
 
74
 
 
75
        out.writeEncoded(SET | CONSTRUCTED, bytes);
 
76
    }
 
77
}