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, DTSTART and DTEND fields.
25 * @author srowen@google.com (Sean Owen)
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 int vEventEnd = rawText.indexOf("END:VEVENT");
39 if (vEventStart < 0 || vEventEnd < 0) {
42 rawText = rawText.substring(vEventStart + 14, vEventEnd); // skip over BEGIN:VEVENT\r\n at start
44 String summary = VCardResultParser.matchSingleVCardPrefixedField("SUMMARY", rawText, true);
45 String start = VCardResultParser.matchSingleVCardPrefixedField("DTSTART", rawText, true);
46 String end = VCardResultParser.matchSingleVCardPrefixedField("DTEND", rawText, true);
48 return new CalendarParsedResult(summary, start, end, null, null, null);
49 } catch (IllegalArgumentException iae) {