aboutsummaryrefslogtreecommitdiffstats
path: root/libraries/spongycastle/pg/src/main/java/org/spongycastle/openpgp/PGPLiteralData.java
blob: e6ac1bc6204306978f04c8b22c4018fec16c930e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package org.spongycastle.openpgp;

import java.io.IOException;
import java.io.InputStream;
import java.util.Date;

import org.spongycastle.bcpg.BCPGInputStream;
import org.spongycastle.bcpg.LiteralDataPacket;

/**
 * class for processing literal data objects.
 */
public class PGPLiteralData 
{
    public static final char    BINARY = 'b';
    public static final char    TEXT = 't';
    public static final char    UTF8 = 'u';

    /**
     * The special name indicating a "for your eyes only" packet.
     */
    public static final String  CONSOLE = "_CONSOLE";
    
    /**
     * The special time for a modification time of "now" or
     * the present time.
     */
    public static final Date    NOW = new Date(0L);
    
    LiteralDataPacket    data;
    
    public PGPLiteralData(
        BCPGInputStream    pIn)
        throws IOException
    {
        data  = (LiteralDataPacket)pIn.readPacket();
    }
    
    /**
     * Return the format of the data stream - BINARY or TEXT.
     * 
     * @return int
     */
    public int getFormat()
    {
        return data.getFormat();
    }
    
    /**
     * Return the file name that's associated with the data stream.
     * 
     * @return String
     */
    public String getFileName()
    {
        return data.getFileName();
    }

    /**
     * Return the file name as an unintrepreted byte array.
     */
    public byte[] getRawFileName()
    {
        return data.getRawFileName();
    }

    /**
     * Return the modification time for the file.
     * 
     * @return the modification time.
     */
    public Date getModificationTime()
    {
        return new Date(data.getModificationTime());
    }
    
    /**
     * Return the raw input stream for the data stream.
     * 
     * @return InputStream
     */
    public InputStream getInputStream()
    {
        return data.getInputStream();
    }
    
    /**
     * Return the input stream representing the data stream
     * 
     * @return InputStream
     */
    public InputStream getDataStream()
    {
        return this.getInputStream();
    }
}