| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package uk.me.parabola.tdbfmt; |
| 18 |
|
| 19 |
import uk.me.parabola.io.FileBlock; |
| 20 |
import uk.me.parabola.io.StructuredOutputStream; |
| 21 |
import uk.me.parabola.log.Logger; |
| 22 |
import uk.me.parabola.io.StructuredInputStream; |
| 23 |
|
| 24 |
import java.io.IOException; |
| 25 |
import java.util.ArrayList; |
| 26 |
import java.util.List; |
| 27 |
import java.util.Set; |
| 28 |
import java.util.HashSet; |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
class CopyrightBlock extends FileBlock { |
| 36 |
public static final int BLOCK_ID = 0x44; |
| 37 |
|
| 38 |
private static final Logger log = Logger.getLogger(CopyrightBlock.class); |
| 39 |
|
| 40 |
private final List<CopyrightSegment> segments = new ArrayList<>(); |
| 41 |
private final Set<CopyrightSegment> copySet = new HashSet<>(); |
| 42 |
|
| 43 |
CopyrightBlock() { |
| 44 |
super(BLOCK_ID); |
| 45 |
} |
| 46 |
|
| 47 |
CopyrightBlock(StructuredInputStream ds) throws IOException { |
| 48 |
super(BLOCK_ID); |
| 49 |
|
| 50 |
while (!ds.testEof()) { |
| 51 |
CopyrightSegment segment = new CopyrightSegment(ds); |
| 52 |
|
| 53 |
log.info("segment: " + segment); |
| 54 |
segments.add(segment); |
| 55 |
} |
| 56 |
} |
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
protected void writeBody(StructuredOutputStream ds) throws IOException { |
| 62 |
for (CopyrightSegment seg : segments) { |
| 63 |
seg.write(ds); |
| 64 |
} |
| 65 |
} |
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
public void addSegment(CopyrightSegment seg) { |
| 72 |
if (copySet.add(seg)) |
| 73 |
segments.add(seg); |
| 74 |
} |
| 75 |
} |