| 1 | /* |
| 2 | * Copyright (C) 2008 Steve Ratcliffe |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License version 2 as |
| 6 | * published by the Free Software Foundation. |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
| 12 | * |
| 13 | * |
| 14 | * Author: Steve Ratcliffe |
| 15 | * Create date: 23-Jun-2008 |
| 16 | */ |
| 17 | package uk.me.parabola.tdbfmt; |
| 18 | |
| 19 | import java.io.IOException; |
| 20 | |
| 21 | import uk.me.parabola.io.FileBlock; |
| 22 | import uk.me.parabola.io.StructuredOutputStream; |
| 23 | |
| 24 | /** |
| 25 | * @author Steve Ratcliffe |
| 26 | */ |
| 27 | public class TBlock extends FileBlock { |
| 28 | private static final int BLOCK_ID = 'T'; |
| 29 | |
| 30 | private long sum; |
| 31 | |
| 32 | public TBlock() { |
| 33 | super(BLOCK_ID); |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * This is to overridden in a subclass. |
| 38 | */ |
| 39 | protected void writeBody(StructuredOutputStream os) throws IOException { |
| 40 | // If you change A,B,C or D the maps |
| 41 | // will not load, you can change the rest without easily visible |
| 42 | // problems although I suppose they must do something. |
| 43 | // |
| 44 | // A,B,C,D is a standard crc32 sum of the rest of the file. |
| 45 | // (Andrzej Popowsk) |
| 46 | os.write2(0); |
| 47 | os.write((int) (sum >> 24)); // A |
| 48 | os.write3(0); |
| 49 | os.write3(0); |
| 50 | os.write((int) (sum >> 16)); // B |
| 51 | os.write2(0); |
| 52 | os.write((int) (sum >> 8)); // C |
| 53 | os.write4(0); |
| 54 | os.write((int) sum); // D |
| 55 | os.write2(0); |
| 56 | } |
| 57 | |
| 58 | public void setSum(long sum) { |
| 59 | this.sum = sum; |
| 60 | } |
| 61 | } |