File: CdfDescriptorRecord.java

package info (click to toggle)
jcdf 1.2.5%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 572 kB
  • sloc: java: 5,315; makefile: 198; sh: 98
file content (61 lines) | stat: -rw-r--r-- 2,119 bytes parent folder | download | duplicates (2)
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
package uk.ac.bristol.star.cdf.record;

import java.io.IOException;

/**
 * Field data for CDF record of type CDF Descriptor Record.
 *
 * @author   Mark Taylor
 * @since    19 Jun 2013
 */
public class CdfDescriptorRecord extends Record {

    @CdfField @OffsetField public final long gdrOffset;
    @CdfField public final int version;
    @CdfField public final int release;
    @CdfField public final int encoding;
    @CdfField public final int flags;
    @CdfField public final int rfuA;
    @CdfField public final int rfuB;
    @CdfField public final int increment;
    @CdfField public final int rfuD;
    @CdfField public final int rfuE;
    public final String[] copyright;

    /**
     * Constructor.
     *
     * @param   plan   basic record information
     */
    public CdfDescriptorRecord( RecordPlan plan ) throws IOException {
        super( plan, "CDR", 1 );
        Buf buf = plan.getBuf();
        Pointer ptr = plan.createContentPointer();
        this.gdrOffset = buf.readOffset( ptr );
        this.version = buf.readInt( ptr );
        this.release = buf.readInt( ptr );
        this.encoding = buf.readInt( ptr );
        this.flags = buf.readInt( ptr );
        this.rfuA = buf.readInt( ptr );
        this.rfuB = buf.readInt( ptr );
        this.increment = buf.readInt( ptr );
        this.rfuD = buf.readInt( ptr );
        this.rfuE = buf.readInt( ptr );
        int crLeng = versionAtLeast( 2, 5 ) ? 256 : 1945;
        this.copyright = toLines( buf.readAsciiString( ptr, crLeng ) );
        checkEndRecord( ptr );
    }

    /**
     * Determines whether this CDR represents a CDF version of equal to
     * or greater than a given target version.
     *
     * @param   targetVersion  major version number to test against
     * @param   targetRelease  minor version number to test against
     * @return  true iff this version is at least targetVersion.targetRelease
     */
    private boolean versionAtLeast( int targetVersion, int targetRelease ) {
        return this.version > targetVersion
            || this.version == targetVersion && this.release >= targetRelease;
    }
}