/[projects]/dao/DaoAdresseService/src/dk/daoas/daoadresseservice/AddressUtils.java
ViewVC logotype

Diff of /dao/DaoAdresseService/src/dk/daoas/daoadresseservice/AddressUtils.java

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

revision 2267 by torben, Thu Feb 12 13:57:32 2015 UTC revision 2403 by torben, Fri Feb 27 11:40:08 2015 UTC
# Line 12  public class AddressUtils { Line 12  public class AddressUtils {
12                  public String etage = "";                  public String etage = "";
13                  public String lejlighed = "";                  public String lejlighed = "";
14                  public String resten = "";                  public String resten = "";
15                    
16                    @Override
17                    public String toString() {
18                            return vej + " / " + husnr + " / " + litra;
19                    }
20            }
21            
22            public static char fjernAccentTegn(char c) {
23                    switch (c) {
24                    case 'é':
25                            return 'e';
26                    case 'è':
27                            return 'e';
28                            
29                    case 'û':
30                            return 'u';
31                    case 'ü':
32                            return 'u';
33                            
34                    case 'ö':
35                            return 'o';
36                    case 'ô':
37                            return 'o';
38    
39                    case 'ä':
40                            return 'a';
41                    case 'â':
42                            return 'a';
43                            
44                    case 'ñ':
45                            return 'n';                    
46                                    
47                    default:
48                            return c;
49                    }              
50          }          }
51                    
52          public static String vaskVejnavn(String indVejnavn) {          public static String vaskVejnavn(String indVejnavn) {
53                  String out = indVejnavn.toLowerCase();                  StringBuilder sb = new StringBuilder();
54                  out = out.replace(" ", "");                  char chars[] = indVejnavn.toCharArray();
55                  out = out.replace(".", "");                  
56                  out = out.replace(",", "");                  for (char c: chars) {                  
57                  out = out.replace("-", "");                          if ( Character.isAlphabetic(c)) {
58                  out = out.replace("/", "");                                  c = Character.toLowerCase(c);
59                  out = out.replace("\\", "");                                  c = fjernAccentTegn(c);
60                  out = out.replace("'", "");                                  
61                                    sb.append( c );
62                            }
63                    }              
64                    
65                    return sb.toString();
66            }
67            
68            public static String injectIntoBk(String bkrute, String injected) {
69                    String parts[] = bkrute.split("/");
70                    
71                    if (parts.length != 4) {
72                            System.out.println(">BK " + bkrute);
73                            return bkrute;
74                    }
75                                    
76                  return out;                  return parts[0] + "/" + parts[1] + "/" + parts[2] + "/" + injected + parts[3];
77          }          }
78                    
79    
# Line 52  public class AddressUtils { Line 101  public class AddressUtils {
101                          delStreng.append( indAdresse.charAt(i) );                          delStreng.append( indAdresse.charAt(i) );
102                          i++;                          i++;
103                  }                  }
104                  result.vej = WordUtils.capitalize( delStreng.toString().trim() );                  
105    
106                    result.vej = delStreng.toString().toLowerCase().trim();
107                    if ( result.vej.endsWith(".") || result.vej.endsWith(",")) {
108                            result.vej =  result.vej.substring(0, result.vej.length() - 1);
109                            result.vej = result.vej.trim();
110                    }
111                    
112                    //special case - hvis strengen ender med ' nr' skal ' nr' fjernes
113                    if ( result.vej.endsWith(" nr")) {
114                            result.vej =  result.vej.substring(0, result.vej.length() - 3);
115                    }
116                    
117                    result.vej = WordUtils.capitalize( result.vej.trim() );
118                                    
119    
120    
# Line 97  public class AddressUtils { Line 159  public class AddressUtils {
159                  if (i>=len) //THN tilføjelse                  if (i>=len) //THN tilføjelse
160                          return result;                          return result;
161                                    
162                  if (Character.isAlphabetic(indAdresse.charAt(i)) &&                  if (Character.isAlphabetic(indAdresse.charAt(i) )) {
163                                  (i+1 == len || Character.isAlphabetic(indAdresse.charAt(i+1)) == false                          char current = Character.toUpperCase( indAdresse.charAt(i) );
164                            
165                            if (current != 'Æ'&& current != 'Ø' && current != 'Å') {
166                                    if ( (i+1 == len ||
167                                                    (Character.isAlphabetic(indAdresse.charAt(i+1)) == false
168                                                    /*&& indAdresse.charAt(i+1) != '.'*/)
169                                                  )                                                  )
170                                  ) {                                          ) {
171                          result.litra = "" + indAdresse.charAt(i);                                          result.litra = "" + current;
172                          result.litra = result.litra.toUpperCase();                                          i++;
173                                    }
174                            }
175                    }
176                    
177                    // ignorer blanke og komma og punktum
178                    while (i<len && (indAdresse.charAt(i) == '.' || indAdresse.charAt(i) == ',' || indAdresse.charAt(i) == ' ') ) {
179                          i++;                          i++;
180                  }                  }
181                                    
# Line 191  public class AddressUtils { Line 264  public class AddressUtils {
264                  }                  }
265                                    
266                  // saml resten op (kan gøres smartere med en substr)                  // saml resten op (kan gøres smartere med en substr)
267                  result.resten = indAdresse.substring(i);                  result.resten = indAdresse.substring(i).trim();
268                                    
269                  return result;                  return result;
270          }          }

Legend:
Removed from v.2267  
changed lines
  Added in v.2403

  ViewVC Help
Powered by ViewVC 1.1.20