VEventResultParser.java (zxing-zxing-3.4.0) | : | VEventResultParser.java (zxing-zxing-3.4.1) | ||
---|---|---|---|---|
skipping to change at line 39 | skipping to change at line 39 | |||
public final class VEventResultParser extends ResultParser { | public final class VEventResultParser extends ResultParser { | |||
@Override | @Override | |||
public CalendarParsedResult parse(Result result) { | public CalendarParsedResult parse(Result result) { | |||
String rawText = getMassagedText(result); | String rawText = getMassagedText(result); | |||
int vEventStart = rawText.indexOf("BEGIN:VEVENT"); | int vEventStart = rawText.indexOf("BEGIN:VEVENT"); | |||
if (vEventStart < 0) { | if (vEventStart < 0) { | |||
return null; | return null; | |||
} | } | |||
String summary = matchSingleVCardPrefixedField("SUMMARY", rawText, true); | String summary = matchSingleVCardPrefixedField("SUMMARY", rawText); | |||
String start = matchSingleVCardPrefixedField("DTSTART", rawText, true); | String start = matchSingleVCardPrefixedField("DTSTART", rawText); | |||
if (start == null) { | if (start == null) { | |||
return null; | return null; | |||
} | } | |||
String end = matchSingleVCardPrefixedField("DTEND", rawText, true); | String end = matchSingleVCardPrefixedField("DTEND", rawText); | |||
String duration = matchSingleVCardPrefixedField("DURATION", rawText, true); | String duration = matchSingleVCardPrefixedField("DURATION", rawText); | |||
String location = matchSingleVCardPrefixedField("LOCATION", rawText, true); | String location = matchSingleVCardPrefixedField("LOCATION", rawText); | |||
String organizer = stripMailto(matchSingleVCardPrefixedField("ORGANIZER", ra | String organizer = stripMailto(matchSingleVCardPrefixedField("ORGANIZER", ra | |||
wText, true)); | wText)); | |||
String[] attendees = matchVCardPrefixedField("ATTENDEE", rawText, true); | String[] attendees = matchVCardPrefixedField("ATTENDEE", rawText); | |||
if (attendees != null) { | if (attendees != null) { | |||
for (int i = 0; i < attendees.length; i++) { | for (int i = 0; i < attendees.length; i++) { | |||
attendees[i] = stripMailto(attendees[i]); | attendees[i] = stripMailto(attendees[i]); | |||
} | } | |||
} | } | |||
String description = matchSingleVCardPrefixedField("DESCRIPTION", rawText, t rue); | String description = matchSingleVCardPrefixedField("DESCRIPTION", rawText); | |||
String geoString = matchSingleVCardPrefixedField("GEO", rawText, true); | String geoString = matchSingleVCardPrefixedField("GEO", rawText); | |||
double latitude; | double latitude; | |||
double longitude; | double longitude; | |||
if (geoString == null) { | if (geoString == null) { | |||
latitude = Double.NaN; | latitude = Double.NaN; | |||
longitude = Double.NaN; | longitude = Double.NaN; | |||
} else { | } else { | |||
int semicolon = geoString.indexOf(';'); | int semicolon = geoString.indexOf(';'); | |||
if (semicolon < 0) { | if (semicolon < 0) { | |||
return null; | return null; | |||
} | } | |||
skipping to change at line 93 | skipping to change at line 93 | |||
attendees, | attendees, | |||
description, | description, | |||
latitude, | latitude, | |||
longitude); | longitude); | |||
} catch (IllegalArgumentException ignored) { | } catch (IllegalArgumentException ignored) { | |||
return null; | return null; | |||
} | } | |||
} | } | |||
private static String matchSingleVCardPrefixedField(CharSequence prefix, | private static String matchSingleVCardPrefixedField(CharSequence prefix, | |||
String rawText, | String rawText) { | |||
boolean trim) { | List<String> values = VCardResultParser.matchSingleVCardPrefixedField(prefix | |||
List<String> values = VCardResultParser.matchSingleVCardPrefixedField(prefix | , rawText, true, false); | |||
, rawText, trim, false); | ||||
return values == null || values.isEmpty() ? null : values.get(0); | return values == null || values.isEmpty() ? null : values.get(0); | |||
} | } | |||
private static String[] matchVCardPrefixedField(CharSequence prefix, String ra | private static String[] matchVCardPrefixedField(CharSequence prefix, String ra | |||
wText, boolean trim) { | wText) { | |||
List<List<String>> values = VCardResultParser.matchVCardPrefixedField(prefix | List<List<String>> values = VCardResultParser.matchVCardPrefixedField(prefix | |||
, rawText, trim, false); | , rawText, true, false); | |||
if (values == null || values.isEmpty()) { | if (values == null || values.isEmpty()) { | |||
return null; | return null; | |||
} | } | |||
int size = values.size(); | int size = values.size(); | |||
String[] result = new String[size]; | String[] result = new String[size]; | |||
for (int i = 0; i < size; i++) { | for (int i = 0; i < size; i++) { | |||
result[i] = values.get(i).get(0); | result[i] = values.get(i).get(0); | |||
} | } | |||
return result; | return result; | |||
} | } | |||
End of changes. 7 change blocks. | ||||
18 lines changed or deleted | 17 lines changed or added |