Skip to content

Commit 771ad5e

Browse files
committed
Noch zu PR #142 - wenn die Methode nur noch mit "true" bei "leadingSvwz"
aufgerufen wird, kann der Parameter auch ganz entfallen.
1 parent 4b377bd commit 771ad5e

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

src/de/willuhn/jameica/hbci/server/VerwendungszweckUtil.java

+5-6
Original file line numberDiff line numberDiff line change
@@ -210,30 +210,29 @@ public static Map<Tag,String> parse(Transfer t) throws RemoteException
210210
public static Map<Tag,String> parse(String... lines) throws RemoteException
211211
{
212212
// Wir parsen erstmal alles mit "+".
213-
Map<Tag,String> result = parse(true,'+',lines);
213+
Map<Tag,String> result = parse('+',lines);
214214
if (result == null || result.size() == 0)
215215
{
216216
// Vielleicht enthaelt es ja nur Tags mit Doppelpunkt?
217-
return parse(true,':',lines);
217+
return parse(':',lines);
218218
}
219219

220220
// Jetzt schauen wir, ob wir den Verwendungszweck per ":" noch weiter zerlegen koennen
221221
String svwz = result.get(Tag.SVWZ);
222222
if (StringUtils.trimToNull(svwz) != null)
223-
result.putAll(parse(true,':',svwz));
223+
result.putAll(parse(':',svwz));
224224

225225
return result;
226226
}
227227

228228
/**
229229
* Parst die SEPA-Tags aus den Verwendungszweck-Zeilen.
230-
* @param leadingSvwz true, wenn ein fuehrerender Verwendungszweck ohne dediziertes Tag beachtet werden soll.
231230
* @param sep das zu verwendende Trennzeichen.
232231
* @param lines die Verwendungszweck-Zeilen.
233232
* @return Map mit den geparsten Infos. Niemals NULL sondern hoechstens eine leere Map.
234233
* @throws RemoteException
235234
*/
236-
private static Map<Tag,String> parse(boolean leadingSvwz, char sep, String... lines) throws RemoteException
235+
private static Map<Tag,String> parse(char sep, String... lines) throws RemoteException
237236
{
238237
Map<Tag,String> result = new HashMap<Tag,String>();
239238

@@ -298,7 +297,7 @@ private static Map<Tag,String> parse(boolean leadingSvwz, char sep, String... li
298297
// Sprich: Der Verwendungszweck enthaelt zwar Tags, der Verwendungszweck selbst hat aber keines
299298
// sondern steht nur vorn dran.
300299
// Wenn wir Tags haben, SVWZ aber fehlt, nehmen wir als SVWZ den Text bis zum ersten Tag
301-
if (leadingSvwz && result.size() > 0 && !result.containsKey(Tag.SVWZ) && first > 0)
300+
if (result.size() > 0 && !result.containsKey(Tag.SVWZ) && first > 0)
302301
{
303302
result.put(Tag.SVWZ,StringUtils.trimToEmpty(line.substring(0,first).replace("\n","")));
304303
}

test/de/willuhn/jameica/hbci/server/TestVerwendungszweckUtil.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ public void testRewrap() throws Exception
4444
String[] result = VerwendungszweckUtil.rewrap(27,test);
4545

4646
assertArrayEquals(new String[]{"123456789012345678901234567",
47-
"890123456789012345678901234",
48-
"567890d12345678901234567890",
49-
"1234567"},
47+
"890123456789012345678901234",
48+
"567890d12345678901234567890",
49+
"1234567"},
5050
result);
5151
}
5252

0 commit comments

Comments
 (0)