2 * Copyright 2008 ZXing authors
\r
4 * Licensed under the Apache License, Version 2.0 (the "License");
\r
5 * you may not use this file except in compliance with the License.
\r
6 * You may obtain a copy of the License at
\r
8 * http://www.apache.org/licenses/LICENSE-2.0
\r
10 * Unless required by applicable law or agreed to in writing, software
\r
11 * distributed under the License is distributed on an "AS IS" BASIS,
\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 * See the License for the specific language governing permissions and
\r
14 * limitations under the License.
\r
17 namespace com.google.zxing.client.result
\r
20 /// <author> Sean Owen
\r
22 /// <author>www.Redivivus.in (suraj.supekar@redivivus.in) - Ported from ZXING Java Source
\r
24 public sealed class CalendarParsedResult:ParsedResult
\r
26 public System.String Summary
\r
34 /// <summary> <p>We would return the start and end date as a {@link java.util.Date} except that this code
\r
35 /// needs to work under JavaME / MIDP and there is no date parsing library available there, such
\r
36 /// as <code>java.text.SimpleDateFormat</code>.</p> See validateDate() for the return format.
\r
39 /// <returns> start time formatted as a RFC 2445 DATE or DATE-TIME.</p>
\r
41 public System.String Start
\r
49 /// <seealso cref="getStart(). May return null if the event has no duration.">
\r
51 public System.String End
\r
59 public System.String Location
\r
67 public System.String Attendee
\r
75 public System.String Title
\r
83 override public System.String DisplayResult
\r
87 System.Text.StringBuilder result = new System.Text.StringBuilder(100);
\r
88 maybeAppend(summary, result);
\r
89 maybeAppend(start, result);
\r
90 maybeAppend(end, result);
\r
91 maybeAppend(location, result);
\r
92 maybeAppend(attendee, result);
\r
93 maybeAppend(title, result);
\r
94 return result.ToString();
\r
99 //UPGRADE_NOTE: Final was removed from the declaration of 'summary '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
\r
100 private System.String summary;
\r
101 //UPGRADE_NOTE: Final was removed from the declaration of 'start '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
\r
102 private System.String start;
\r
103 //UPGRADE_NOTE: Final was removed from the declaration of 'end '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
\r
104 private System.String end;
\r
105 //UPGRADE_NOTE: Final was removed from the declaration of 'location '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
\r
106 private System.String location;
\r
107 //UPGRADE_NOTE: Final was removed from the declaration of 'attendee '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
\r
108 private System.String attendee;
\r
109 //UPGRADE_NOTE: Final was removed from the declaration of 'title '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
\r
110 private System.String title;
\r
112 public CalendarParsedResult(System.String summary, System.String start, System.String end, System.String location, System.String attendee, System.String title):base(ParsedResultType.CALENDAR)
\r
114 // Start is required, end is not
\r
117 throw new System.ArgumentException();
\r
119 validateDate(start);
\r
121 this.summary = summary;
\r
122 this.start = start;
\r
124 this.location = location;
\r
125 this.attendee = attendee;
\r
126 this.title = title;
\r
129 /// <summary> RFC 2445 allows the start and end fields to be of type DATE (e.g. 20081021) or DATE-TIME
\r
130 /// (e.g. 20081021T123000 for local time, or 20081021T123000Z for UTC).
\r
133 /// <param name="date">The string to validate
\r
135 private static void validateDate(System.String date)
\r
139 int length = date.Length;
\r
140 if (length != 8 && length != 15 && length != 16)
\r
142 throw new System.ArgumentException();
\r
144 for (int i = 0; i < 8; i++)
\r
146 if (!System.Char.IsDigit(date[i]))
\r
148 throw new System.ArgumentException();
\r
153 if (date[8] != 'T')
\r
155 throw new System.ArgumentException();
\r
157 for (int i = 9; i < 15; i++)
\r
159 if (!System.Char.IsDigit(date[i]))
\r
161 throw new System.ArgumentException();
\r
164 if (length == 16 && date[15] != 'Z')
\r
166 throw new System.ArgumentException();
\r