2 * Copyright 2008 ZXing authors
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package com.google.zxing.client.result;
19 import com.google.zxing.Result;
22 * Partially implements the iCalendar format's "VEVENT" format for specifying a
23 * calendar event. See RFC 2445. This supports SUMMARY, LOCATION, DTSTART and DTEND fields.
27 final class VEventResultParser extends ResultParser {
29 private VEventResultParser() {
32 public static CalendarParsedResult parse(Result result) {
33 String rawText = result.getText();
34 if (rawText == null) {
37 int vEventStart = rawText.indexOf("BEGIN:VEVENT");
38 if (vEventStart < 0) {
41 int vEventEnd = rawText.indexOf("END:VEVENT");
46 String summary = VCardResultParser.matchSingleVCardPrefixedField("SUMMARY", rawText, true);
47 String start = VCardResultParser.matchSingleVCardPrefixedField("DTSTART", rawText, true);
48 String end = VCardResultParser.matchSingleVCardPrefixedField("DTEND", rawText, true);
49 String location = VCardResultParser.matchSingleVCardPrefixedField("LOCATION", rawText, true);
50 String description = VCardResultParser.matchSingleVCardPrefixedField("DESCRIPTION", rawText, true);
52 return new CalendarParsedResult(summary, start, end, location, null, description);
53 } catch (IllegalArgumentException iae) {