Debian Codegraph @

src/uk/me/parabola/imgfmt/app/mdr/Mdr14.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2009.
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 3 or
6 * version 2 as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
12 */
13 package uk.me.parabola.imgfmt.app.mdr;
14
15 import java.util.ArrayList;
16 import java.util.List;
17
18 import uk.me.parabola.imgfmt.app.ImgFileWriter;
19
20 /**
21 * The countries that occur in each map.
22 *
23 * @author Steve Ratcliffe
24 */
25 public class Mdr14 extends MdrSection implements HasHeaderFlags {
26 private final List<Mdr14Record> countries = new ArrayList<>();
27
28 public Mdr14(MdrConfig config) {
29 setConfig(config);
30 }
31
32 public void writeSectData(ImgFileWriter writer) {
33 countries.sort(null);
34
35 for (Mdr14Record country : countries) {
36 putMapIndex(writer, country.getMapIndex());
37 writer.put2u(country.getCountryIndex());
38 putStringOffset(writer, country.getStrOff());
39 }
40 }
41
42 public void addCountry(Mdr14Record country) {
43 countries.add(country);
44 }
45
46 public int getItemSize() {
47 PointerSizes sizes = getSizes();
48 return sizes.getMapSize() + 2 + sizes.getStrOffSize();
49 }
50
51 /**
52 * The number of records in this section.
53 * @return The number of items in the section.
54 */
55 protected int numberOfItems() {
56 return countries.size();
57 }
58
59 public int getExtraValue() {
60 return 0x00;
61 }
62
63 public List<Mdr14Record> getCountries() {
64 return countries;
65 }
66 }