comparison src/main/java/de/intevation/lada/data/importer/LAFFormat.java @ 366:567ce7697fc7 0.5

Code documentation.
author Raimund Renkert <rrenkert@intevation.de>
date Tue, 10 Sep 2013 15:55:54 +0200
parents 5844d7457dde
children 183f8116d9a6
comparison
equal deleted inserted replaced
365:fab80595ed55 366:567ce7697fc7
11 11
12 import org.json.JSONArray; 12 import org.json.JSONArray;
13 import org.json.JSONException; 13 import org.json.JSONException;
14 import org.json.JSONObject; 14 import org.json.JSONObject;
15 15
16 16 /**
17 * The LAFFormat reads the config file
18 * (https://bfs-intern.intevation.de/Server/Importer) and creates format
19 * objects for each entry.
20 *
21 * @author <a href="mailto:rrenkert@intevation.de">Raimund Renkert</a>
22 */
17 public class LAFFormat 23 public class LAFFormat
18 { 24 {
19 private JSONObject fileContent; 25 private JSONObject fileContent;
20 26
27 /**
28 * Reads the config file.
29 *
30 * @param fileName Path to the config file.
31 * @return success
32 */
21 public boolean readConfigFile(String fileName) { 33 public boolean readConfigFile(String fileName) {
22 try { 34 try {
23 byte[] encoded = Files.readAllBytes(Paths.get(fileName)); 35 byte[] encoded = Files.readAllBytes(Paths.get(fileName));
24 Charset encoding = Charset.defaultCharset(); 36 Charset encoding = Charset.defaultCharset();
25 String content = 37 String content =
33 catch (JSONException je) { 45 catch (JSONException je) {
34 return false; 46 return false;
35 } 47 }
36 } 48 }
37 49
50 /**
51 * Returns a List of EntryFormat for the requested entity type.
52 * The Entity type can be one of:
53 * * "probe"
54 * * "messung"
55 * * "ort"
56 *
57 * @param dataType The entity type
58 * @return List of entry formats defined for the requested type.
59 */
38 public List<EntryFormat> getFormat(String dataType) { 60 public List<EntryFormat> getFormat(String dataType) {
39 List<EntryFormat> formats = new LinkedList<EntryFormat>(); 61 List<EntryFormat> formats = new LinkedList<EntryFormat>();
40 try { 62 try {
41 JSONArray block = fileContent.getJSONArray(dataType); 63 JSONArray block = fileContent.getJSONArray(dataType);
42 for (int i = 0; i < block.length(); i++) { 64 for (int i = 0; i < block.length(); i++) {
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)