/[projects]/dao/DaoAdresseVedligehold/src/main/java/dk/daoas/adressevedligehold/AddressSourceBK.java
ViewVC logotype

Diff of /dao/DaoAdresseVedligehold/src/main/java/dk/daoas/adressevedligehold/AddressSourceBK.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2838 by torben, Sun Jan 24 21:48:55 2016 UTC revision 2857 by torben, Thu Jan 28 10:30:01 2016 UTC
# Line 28  public class AddressSourceBK implements Line 28  public class AddressSourceBK implements
28                  this.file = file;                  this.file = file;
29    
30    
31                  is = file.getInputStream();  
                 isr = new InputStreamReader(is, Charset.forName("ISO-8859-1") );  
                 br = new BufferedReader(isr);  
                                   
32          }          }
33    
34          @Override          @Override
# Line 39  public class AddressSourceBK implements Line 36  public class AddressSourceBK implements
36                  return file.getName();                  return file.getName();
37          }          }
38                    
39            @Override
40            public void validate() throws IOException {
41                    try (          
42                                    InputStream is1 = file.getInputStream();
43                                    InputStreamReader isr1 = new InputStreamReader(is1, Charset.forName("ISO-8859-1") );
44                                    BufferedReader br1 = new BufferedReader(isr1)
45                            ) {
46                            String line = br1.readLine();
47                            String[] parts = line.split(";");
48                            int numFields = parts.length;
49                            if (numFields != 13) {
50                                    throw new IOException("Not enough fields in CSV file. Found " + numFields + ", expected 13");
51                            }
52                    }
53    
54                    
55                    is = file.getInputStream();
56                    isr = new InputStreamReader(is, Charset.forName("ISO-8859-1") );
57                    br = new BufferedReader(isr);
58            }
59    
60          //TODO: Skal csv parsning klares med Apache Commons CSV ?          //TODO: Skal csv parsning klares med Apache Commons CSV ?
61    
62          @Override          @Override
# Line 56  public class AddressSourceBK implements Line 74  public class AddressSourceBK implements
74                  entry.distributor = "BK";                  entry.distributor = "BK";
75                                    
76                  String[] parts = line.split(";");                  String[] parts = line.split(";");
77                    
78                    if (parts.length != 13) {
79                            throw new IOException("Not enough fields in CSV file. Found " + parts.length + ", expected 13");
80                    }
81                    
82                  entry.postnr = Short.parseShort( parts[0]);                  entry.postnr = Short.parseShort( parts[0]);
83                  entry.vejnavn = parts[1].replace("\"", "");                  entry.vejnavn = parts[1].replace("\"", "");
84                  entry.husnr = Short.parseShort( parts[2] );                  entry.husnr = Short.parseShort( parts[2] );
# Line 68  public class AddressSourceBK implements Line 91  public class AddressSourceBK implements
91                                    
92                  String laesnr = parts[8].replace("\"", "");                  String laesnr = parts[8].replace("\"", "");
93                                    
94                  @SuppressWarnings("unused") String distnr = parts[9].replace("\"", "");                  //String distnr = parts[9].replace("\"", ""); //Bruges ikke
95                  String foede = parts[10].replace("\"", "");                  String foede = parts[10].replace("\"", "");
96                  String jobnr = parts[11].replace("\"", "");                  String jobnr = parts[11].replace("\"", "");
97                  String tklaes = parts[12].replace("\"", "");                  String tklaes = parts[12].replace("\"", "");

Legend:
Removed from v.2838  
changed lines
  Added in v.2857

  ViewVC Help
Powered by ViewVC 1.1.20