VCalendar10Formatpublic class VCalendar10Format extends EndMatcher implements com.sun.kvem.midp.pim.PIMFormatImplementation of PIMEncoding for VCalendar/1.0. |
Fields Summary |
---|
private static final int[] | DAYS_OF_WEEKList of the weekday masks from RepeatRule | private static final String[] | DAYS_OF_WEEK_CODESList of vCalendar weekday codes. This sequence is parallel to
DAYS_OF_WEEK. | private static final int[] | WEEKS_OF_MONTHList of the week in month masks from RepeatRule | private static final String[] | WEEKS_OF_MONTH_CODESList of vCalendar week of month codes. This sequence is
parallel to WEEKS_OF_MONTH. | private static final int[] | MONTHS_IN_YEARList of month in year masks from RepeatRule |
Constructors Summary |
---|
public VCalendar10Format()VCalendar 1.0 formatter.
super("VCALENDAR");
|
Methods Summary |
---|
public PIMItem[] | decode(java.io.InputStream in, java.lang.String encoding, PIMList list)Constructs one or more PIMItems from serialized data.
LineReader r = new LineReader(in, encoding, this);
String line = r.readLine();
if (line == null) {
return null;
}
if (!line.toUpperCase().equals("BEGIN:VCALENDAR")) {
throw new UnsupportedPIMFormatException("Not a vCalendar object");
}
Vector items = new Vector();
for (AbstractPIMItem item; (item = decode(r, list)) != null; ) {
items.addElement(item);
}
if (items.size() == 0) {
return null;
}
AbstractPIMItem[] a = new AbstractPIMItem[items.size()];
items.copyInto(a);
return a;
| private com.sun.kvem.midp.pim.AbstractPIMItem | decode(com.sun.kvem.midp.pim.LineReader in, PIMList list)Constructs a single PIMItem from serialized data.
while (true) {
String line = in.readLine();
if (line == null) {
return null;
}
FormatSupport.DataElement element =
FormatSupport.parseObjectLine(line);
if (element.propertyName.equals("BEGIN")) {
if (element.data.toUpperCase().equals("VEVENT")) {
return decodeEvent(in, list);
} else if (element.data.toUpperCase().equals("VTODO")) {
return decodeToDo(in, list);
} else {
throw new UnsupportedPIMFormatException(
"Bad argument to BEGIN: " + element.data);
}
} else if (element.propertyName.equals("END")) {
if (element.data.toUpperCase().equals("VCALENDAR")) {
return null;
} else {
throw new UnsupportedPIMFormatException(
"Bad argument to END: " + element.data);
}
} else if (element.propertyName.equals("PRODID")) {
// ignore product ID
} else if (element.propertyName.equals("VERSION")) {
// check version, then keep reading
if (!element.data.equals("1.0")) {
throw
new UnsupportedPIMFormatException("vCalendar version '"
+ element.data + "' is not supported");
}
} else if (element.propertyName.equals("CATEGORIES")) {
// what should I do with this? this seems to be the wrong place
// to put the field.
} else {
throw new UnsupportedPIMFormatException("Unrecognized item: "
+ line);
}
}
| private int | decodeDaysInWeek(com.sun.kvem.midp.pim.formats.Parser parser)Decodes days in a week.
int daysInWeek = 0;
while (true) { // decode days
parser.skipBlank();
if (!parser.isNextMatchStr(DAYS_OF_WEEK_CODES)) {
break;
}
String dayStr = parser.readId();
int i;
for (i = 0; i < DAYS_OF_WEEK_CODES.length; i++) {
if (DAYS_OF_WEEK_CODES[i].equals(dayStr)) {
daysInWeek |= DAYS_OF_WEEK[i];
break;
}
}
if (i == DAYS_OF_WEEK_CODES.length) {
throw new IOException("Wrong format"); // not found
}
}
return daysInWeek;
| private com.sun.kvem.midp.pim.EventImpl | decodeEvent(com.sun.kvem.midp.pim.LineReader in, PIMList list)Reads and decodes a single vEvent.
EventImpl event = new EventImpl((AbstractPIMList)list);
String line;
while ((line = in.readLine()) != null) {
FormatSupport.DataElement element =
FormatSupport.parseObjectLine(line);
if (element.propertyName.equals("END")) {
// patch DALARM values
int alarmValues = event.countValues(Event.ALARM);
if (alarmValues > 0 && event.countValues(Event.START) > 0) {
int startTime = (int)
(event.getDate(Event.START, 0) / 1000);
for (int i = 0, j = 0; i < alarmValues; i++, j++) {
int alarmTime = event.getInt(Event.ALARM, i);
if (alarmTime * 1000 < startTime) {
event.setInt(Event.ALARM, i, Event.ATTR_NONE,
startTime - alarmTime);
} else {
event.removeValue(Event.ALARM, i);
alarmValues --;
i --;
}
}
}
return event;
} else if (element.propertyName.equals("VERSION")) {
if (!element.data.equals("1.0")) {
throw new UnsupportedPIMFormatException("Version "
+ element.data + " is not supported");
}
} else if (element.propertyName.equals("CATEGORIES")) {
String[] categories = FormatSupport.split(element.data, ',", 0);
for (int j = 0; j < categories.length; j++) {
try {
event.addToCategory(categories[j]);
} catch (PIMException e) {
// cannot add item
}
}
} else if (element.propertyName.equals("RRULE")) {
RepeatRule rule = new RepeatRule();
if (!decodeRepeatRule(rule, element.data, true)) {
throw new IOException(
"Empty or invalid RepeatRule data");
}
event.setRepeat(rule);
} else if (element.propertyName.equals("EXDATE")) {
RepeatRule rule = event.getRepeat();
if (rule != null) {
decodeExDates(rule, element.data);
event.setRepeat(rule);
}
} else {
importData(event,
element.propertyName, element.attributes, element.data);
}
}
throw new IOException("Unterminated vEvent");
| private void | decodeExDates(RepeatRule rule, java.lang.String data)Decodes except dates.
For more details please see The Electronic Calendaring and Scheduling
Exchange Format Version 1.0
Parser parser = new Parser(data);
long date;
while (parser.hasNextDate()) {
date = PIMHandler.getInstance().
parseDate(parser.getEndDate());
parser.setPos(parser.getPos() + parser.getEndDate().length());
rule.addExceptDate(date);
if (!parser.hasMoreChars()) {
break;
}
parser.matchSkip(',"); // separator
}
| private int | decodeMonthsInYear(com.sun.kvem.midp.pim.formats.Parser parser, RepeatRule rule)Decodes months in a year.
int monthsInYear = 0;
int monthNum;
while (true) { // decode monthes
parser.skipBlank();
if (!parser.isNextInt()) {
break;
}
monthNum = parser.readInt();
if (monthNum >= MONTHS_IN_YEAR.length) {
throw new IOException("Wrong month number");
}
monthsInYear |= MONTHS_IN_YEAR[monthNum];
}
return monthsInYear;
| private boolean | decodeRepeatRule(RepeatRule rule, java.lang.String data, boolean isTop)Decodes repeat rule.
For more details please see The Electronic Calendaring and Scheduling
Exchange Format Version 1.0
boolean res = true;
Parser parser = new Parser(data);
char sym;
try {
parser.skipBlank();
sym = parser.readChar();
int interval;
switch (sym) {
case FormatSupport.DAILY:
// D<interval> [<duration>]
interval = parser.readInt();
if (isTop) {
rule.setInt(RepeatRule.FREQUENCY, RepeatRule.DAILY);
rule.setInt(RepeatRule.INTERVAL, interval);
}
setRepeatRuleCount(parser, rule, isTop);
break;
case FormatSupport.WEEKLY:
// W<interval> <weekday> [<duration>]
interval = parser.readInt();
if (isTop) {
rule.setInt(RepeatRule.FREQUENCY, RepeatRule.WEEKLY);
rule.setInt(RepeatRule.INTERVAL, interval);
}
rule.setInt(RepeatRule.DAY_IN_WEEK, decodeDaysInWeek(parser));
setRepeatRuleCount(parser, rule, isTop);
break;
case FormatSupport.MONTHLY:
if (isTop) {
rule.setInt(RepeatRule.FREQUENCY, RepeatRule.MONTHLY);
}
sym = parser.readChar();
switch (sym) {
case FormatSupport.DAY_IN_MONTH:
// MD<interval> <daynumber> [<duration>]
interval = parser.readInt();
if (isTop) {
rule.setInt(RepeatRule.INTERVAL, interval);
}
parser.skipBlank();
rule.setInt(RepeatRule.DAY_IN_MONTH,
parser.readInt());
setRepeatRuleCount(parser, rule, isTop);
break;
case FormatSupport.WEEK_IN_MONTH:
interval = parser.readInt();
if (isTop) {
rule.setInt(RepeatRule.INTERVAL, interval);
}
parser.skipBlank();
rule.setInt(RepeatRule.WEEK_IN_MONTH,
decodeWeeksInMonth(parser, rule));
setRepeatRuleCount(parser, rule, isTop);
parser.skipBlank();
if (parser.hasMoreChars()) { // parse next rule
res = decodeRepeatRule(rule,
parser.getRemainder(), false);
}
break;
default:
res = false;
}
break;
case FormatSupport.YEARLY:
if (isTop) {
rule.setInt(RepeatRule.FREQUENCY, RepeatRule.YEARLY);
}
sym = parser.readChar();
switch (sym) {
case FormatSupport.DAY_IN_YEAR:
interval = parser.readInt();
if (isTop) {
rule.setInt(RepeatRule.INTERVAL, interval);
}
parser.skipBlank();
rule.setInt(RepeatRule.DAY_IN_YEAR, parser.readInt());
setRepeatRuleCount(parser, rule, isTop);
break;
case FormatSupport.MONTH_IN_YEAR:
interval = parser.readInt();
if (isTop) {
rule.setInt(RepeatRule.INTERVAL, interval);
}
rule.setInt(RepeatRule.MONTH_IN_YEAR,
decodeMonthsInYear(parser, rule));
setRepeatRuleCount(parser, rule, isTop);
parser.skipBlank();
if (parser.hasMoreChars()) { // parse next rule
res = decodeRepeatRule(rule,
parser.getRemainder(), false);
}
break;
default:
res = false;
}
}
} catch (IOException ex) {
res = false;
} catch (NumberFormatException ex) {
res = false;
} catch (IllegalArgumentException ex) {
res = false;
} catch (FieldEmptyException ex) {
res = false;
}
return res;
| private com.sun.kvem.midp.pim.ToDoImpl | decodeToDo(com.sun.kvem.midp.pim.LineReader in, PIMList list)Reads and decodes a single vToDo.
ToDoImpl todo = new ToDoImpl((AbstractPIMList)list);
String line;
while ((line = in.readLine()) != null) {
FormatSupport.DataElement element =
FormatSupport.parseObjectLine(line);
if (element.propertyName.equals("END")) {
return todo;
} else if (element.propertyName.equals("VERSION")) {
if (!element.data.equals("1.0")) {
throw new UnsupportedPIMFormatException("Version "
+ element.data + " is not supported");
}
} else if (element.propertyName.equals("CATEGORIES")) {
String[] categories = FormatSupport.split(element.data, ',", 0);
for (int j = 0; j < categories.length; j++) {
try {
todo.addToCategory(categories[j]);
} catch (PIMException e) {
// cannot add item to category
}
}
} else {
importData(todo,
element.propertyName, element.attributes, element.data);
}
}
throw new IOException("Unterminated vToDo");
| private int | decodeWeeksInMonth(com.sun.kvem.midp.pim.formats.Parser parser, RepeatRule rule)Decodes weeks in a month.
int weeksInMonth = 0;
while (true) { // decode weeks
parser.skipBlank();
if (!parser.isNextMatchStr(WEEKS_OF_MONTH_CODES)) {
break;
}
String weekStr = parser.readId();
int i;
for (i = 0; i < WEEKS_OF_MONTH_CODES.length; i++) {
if (WEEKS_OF_MONTH_CODES[i].equals(weekStr)) {
weeksInMonth |= WEEKS_OF_MONTH[i];
break;
}
}
if (i == WEEKS_OF_MONTH_CODES.length) {
throw new IOException("Wrong format"); // not found
}
}
return weeksInMonth;
| public void | encode(java.io.OutputStream out, java.lang.String encoding, PIMItem pimItem)Serializes a PIMItem.
Writer w = new OutputStreamWriter(out, encoding);
w.write("BEGIN:VCALENDAR\r\n");
w.write("VERSION:1.0\r\n");
if (pimItem instanceof Event) {
encode(w, (Event) pimItem);
} else if (pimItem instanceof ToDo) {
encode(w, (ToDo) pimItem);
}
w.write("END:VCALENDAR\r\n");
w.flush();
| private void | encode(java.io.Writer w, Event event)Serializes a vEvent.
w.write("BEGIN:VEVENT\r\n");
// write known fields
int[] fields = event.getFields();
for (int i = 0; i < fields.length; i++) {
int valueCount = event.countValues(fields[i]);
for (int j = 0; j < valueCount; j++) {
writeValue(w, event, fields[i], j);
}
}
// write categories
String categories = FormatSupport.join(event.getCategories(), ",");
if (categories.length() > 0) {
w.write("CATEGORIES:");
w.write(categories);
w.write("\r\n");
}
// write repeat rule
RepeatRule rule = event.getRepeat();
if (rule != null) {
String s = encodeRepeatRule(rule, 0);
if (s != null) {
w.write("RRULE:");
w.write(s);
w.write("\r\n");
}
Enumeration exDates = rule.getExceptDates();
if (exDates.hasMoreElements()) {
w.write("EXDATE;VALUE=DATE:");
while (exDates.hasMoreElements()) {
long time = ((Date) exDates.nextElement()).getTime();
w.write(PIMHandler.getInstance().composeDate1(time));
if (exDates.hasMoreElements()) {
w.write(",");
}
}
w.write("\r\n");
}
}
w.write("END:VEVENT\r\n");
| private void | encode(java.io.Writer w, ToDo todo)Serializes a vToDo.
w.write("BEGIN:VTODO\r\n");
// write known fields
int[] fields = todo.getFields();
for (int i = 0; i < fields.length; i++) {
int valueCount = todo.countValues(fields[i]);
for (int j = 0; j < valueCount; j++) {
writeValue(w, todo, fields[i], j);
}
}
// write categories
String categories = FormatSupport.join(todo.getCategories(), ",");
if (categories.length() > 0) {
w.write("CATEGORIES:");
w.write(categories);
w.write("\r\n");
}
w.write("END:VTODO\r\n");
| private java.lang.String | encodeRepeatRule(RepeatRule rule, int startFreq)Returns a VCalendar representation of a repeating rule, or
null if the rule cannot be encoded.
For more details please see The Electronic Calendaring and Scheduling
Exchange Format Version 1.0
StringBuffer sb = new StringBuffer();
int[] fields = rule.getFields();
FormatSupport.sort(fields);
if (!FormatSupport.contains(fields, RepeatRule.FREQUENCY)) {
return null;
}
int frequency;
if (startFreq != 0) {
frequency = startFreq;
} else {
frequency = rule.getInt(RepeatRule.FREQUENCY);
}
int interval = 1; // default value according to JSR75 spec
if (FormatSupport.contains(fields, RepeatRule.INTERVAL) &&
(startFreq == 0)) {
interval = rule.getInt(RepeatRule.INTERVAL);
}
String encodedCount = " #0"; // forever
if (FormatSupport.contains(fields, RepeatRule.COUNT) &&
(startFreq == 0)) {
encodedCount = " #" + rule.getInt(RepeatRule.COUNT);
}
// enddate - ISO 8601 clause 5.4.1
String encodedEndDate = "";
if (FormatSupport.contains(fields, RepeatRule.END)) {
encodedEndDate = " " + PIMHandler.getInstance().composeDateTime(
rule.getDate(RepeatRule.END));
}
switch (frequency) {
case RepeatRule.DAILY: {
// D<interval> [<duration>]
sb.append(FormatSupport.DAILY);
sb.append(interval);
sb.append(encodedCount);
break;
}
case RepeatRule.WEEKLY: {
// W<interval> <weekday> [<duration>]
sb.append(FormatSupport.WEEKLY);
sb.append(interval);
if (FormatSupport.contains(fields, RepeatRule.DAY_IN_WEEK)) {
sb.append(encodeRepeatRuleDaysInWeek(rule));
}
sb.append(encodedCount);
break;
}
case RepeatRule.MONTHLY: {
sb.append(FormatSupport.MONTHLY);
if (FormatSupport.contains(fields, RepeatRule.DAY_IN_MONTH)) {
// MD<interval> <daynumber> [<duration>]
sb.append(FormatSupport.DAY_IN_MONTH);
sb.append(interval);
sb.append(" ");
sb.append(rule.getInt(RepeatRule.DAY_IN_MONTH));
sb.append(encodedCount);
} else if (FormatSupport.contains(fields,
RepeatRule.WEEK_IN_MONTH)) {
// MP<interval> {<1>|<2>}{<+>|<->} [<duration>] [weekly|daily]
sb.append(FormatSupport.WEEK_IN_MONTH);
sb.append(interval);
sb.append(encodeRepeatRuleWeeksInMonth(fields, rule));
sb.append(encodedCount);
if (FormatSupport.contains(fields, RepeatRule.DAY_IN_WEEK)) {
sb.append(" " + encodeRepeatRule(rule, RepeatRule.WEEKLY));
}
}
break;
}
case RepeatRule.YEARLY: {
sb.append(FormatSupport.YEARLY);
if (FormatSupport.contains(fields, RepeatRule.DAY_IN_YEAR)) {
sb.append(FormatSupport.DAY_IN_YEAR);
sb.append(interval);
sb.append(" ");
sb.append(rule.getInt(RepeatRule.DAY_IN_YEAR));
sb.append(encodedCount);
} else if (FormatSupport.contains(fields,
RepeatRule.MONTH_IN_YEAR)) {
sb.append(FormatSupport.MONTH_IN_YEAR);
sb.append(interval);
sb.append(encodeRepeatRuleMonthsInYear(fields, rule));
sb.append(encodedCount);
if (FormatSupport.contains(fields, RepeatRule.DAY_IN_MONTH) ||
FormatSupport.contains(fields, RepeatRule.WEEK_IN_MONTH)) {
sb.append(" " +
encodeRepeatRule(rule, RepeatRule.MONTHLY));
}
}
break;
}
default: return null;
}
if (startFreq == 0) {
sb.append(encodedEndDate);
}
return sb.toString();
| private java.lang.String | encodeRepeatRuleDaysInWeek(RepeatRule rule)Returns a string representation of a weekly rule.
StringBuffer sb = new StringBuffer();
int daysInWeek = rule.getInt(RepeatRule.DAY_IN_WEEK);
for (int i = 0; i < DAYS_OF_WEEK.length; i++) {
if ((daysInWeek & DAYS_OF_WEEK[i]) != 0) {
sb.append(" ");
sb.append(DAYS_OF_WEEK_CODES[i]);
}
}
return sb.toString();
| private java.lang.String | encodeRepeatRuleMonthsInYear(int[] fields, RepeatRule rule)Returns a string representation of a yearly rule with a monthly
parameter.
StringBuffer sb = new StringBuffer();
int monthsInYear = rule.getInt(RepeatRule.MONTH_IN_YEAR);
for (int i = 0; i < MONTHS_IN_YEAR.length; i++) {
if ((monthsInYear & MONTHS_IN_YEAR[i]) != 0) {
sb.append(" ");
sb.append(i);
}
}
return sb.toString();
| private java.lang.String | encodeRepeatRuleWeeksInMonth(int[] fields, RepeatRule rule)Returns a string representation of a monthly rule with a weekly
parameter.
StringBuffer sb = new StringBuffer();
int weeksInMonth = rule.getInt(RepeatRule.WEEK_IN_MONTH);
for (int i = 0; i < WEEKS_OF_MONTH.length; i++) {
if ((weeksInMonth & WEEKS_OF_MONTH[i]) != 0) {
sb.append(" ");
sb.append(WEEKS_OF_MONTH_CODES[i]);
}
}
return sb.toString();
| public java.lang.String | getName()Gets the code name of this encoding (e.g. "VCARD/2.1").
return "VCALENDAR/1.0";
| private void | importData(Event event, java.lang.String propertyName, java.lang.String[] attributes, java.lang.String data)Decodes one line of a vEvent.
int field = VEventSupport.getFieldCode(propertyName);
switch (field) {
case Event.SUMMARY:
case Event.LOCATION:
case Event.NOTE:
case Event.UID: {
String sdata = FormatSupport.parseString(attributes, data);
event.addString(field, Event.ATTR_NONE, sdata);
break;
}
case Event.END:
case Event.REVISION:
case Event.START: {
long date = PIMHandler.getInstance().parseDateTime(data);
event.addDate(field, Event.ATTR_NONE, date);
break;
}
case Event.CLASS: {
String sdata = FormatSupport.parseString(attributes, data);
int c = VEventSupport.getClassCode(sdata);
event.addInt(Event.CLASS, Event.ATTR_NONE, c);
break;
}
case Event.ALARM: {
String[] s = FormatSupport.parseStringArray(attributes, data);
if (s.length > 0) {
long alarmTime =
PIMHandler.getInstance().parseDateTime(s[0]);
event.addInt(Event.ALARM, Event.ATTR_NONE,
(int) (alarmTime / 1000));
}
break;
}
}
| private void | importData(ToDo todo, java.lang.String propertyName, java.lang.String[] attributes, java.lang.String data)Decodes one line of a vToDo.
int field = VToDoSupport.getFieldCode(propertyName);
switch (field) {
case ToDo.SUMMARY:
case ToDo.NOTE:
case ToDo.UID: {
String sdata = FormatSupport.parseString(attributes, data);
todo.addString(field, ToDo.ATTR_NONE, sdata);
break;
}
case ToDo.COMPLETION_DATE:
todo.addBoolean(ToDo.COMPLETED, ToDo.ATTR_NONE, true);
// fall through
case ToDo.DUE:
case ToDo.REVISION: {
long date = PIMHandler.getInstance().parseDateTime(data);
todo.addDate(field, ToDo.ATTR_NONE, date);
break;
}
case ToDo.CLASS: {
String sdata = FormatSupport.parseString(attributes, data);
int c = VToDoSupport.getClassCode(sdata);
todo.addInt(ToDo.CLASS, ToDo.ATTR_NONE, c);
break;
}
case ToDo.PRIORITY: {
try {
int i = Integer.parseInt(data);
todo.addInt(ToDo.PRIORITY, ToDo.ATTR_NONE, i);
} catch (NumberFormatException e) {
// ignore this field
}
break;
}
}
| public boolean | isTypeSupported(int pimListType)Checks to see if a given PIM list type is supported by this encoding.
return pimListType == PIM.TODO_LIST || pimListType == PIM.EVENT_LIST;
| private void | setRepeatRuleCount(com.sun.kvem.midp.pim.formats.Parser parser, RepeatRule rule, boolean isSetCount)Puts duration (#value) and end date (yyyymmddThhmmss(Z)/yyyyMMdd)
to COUNT and END fields of the repeat rule.
// parse duration
parser.skipBlank();
if (parser.match('#")) {
parser.skip();
int count = parser.readInt();
if (isSetCount && count > 0) {
rule.setInt(RepeatRule.COUNT, count);
}
}
// parse end date
parser.skipBlank();
if (parser.hasNextDate()) {
int dateLen = parser.getEndDate().length();
// end date is either date in yyyyMMdd format or
// date/time in yyyymmddThhmmss(Z).
long date = (dateLen < 15) ?
PIMHandler.getInstance().parseDate(parser.getEndDate()) :
PIMHandler.getInstance().parseDateTime(parser.getEndDate());
rule.setDate(RepeatRule.END, date);
parser.setPos(parser.getPos() + dateLen);
}
| private void | writeValue(java.io.Writer w, Event event, int field, int index)Serializes one line of a vEvent.
switch (field) {
case Event.CLASS: {
int iValue = event.getInt(field, index);
String sValue = VEventSupport.getClassType(iValue);
if (sValue != null) {
w.write("CLASS:");
w.write(sValue);
w.write("\r\n");
}
break;
}
case Event.ALARM: {
int iValue = event.getInt(field, index);
// subtract Event.ALARM from Event.START
try {
long startTime = event.getDate(Event.START, 0);
w.write("DALARM:");
w.write(PIMHandler.getInstance()
.composeDateTime(startTime - iValue * 1000));
w.write("\r\n");
} catch (IOException e) {
// don't write a DALARM field
}
break;
}
case Event.LOCATION:
case Event.NOTE:
case Event.SUMMARY:
case Event.UID: {
String sValue = event.getString(field, index);
if (sValue != null) {
String property = VEventSupport.getFieldLabel(field);
w.write(property);
w.write(":");
w.write(sValue);
w.write("\r\n");
}
break;
}
case Event.END:
case Event.REVISION:
case Event.START: {
long date = event.getDate(field, index);
w.write(VEventSupport.getFieldLabel(field));
w.write(":");
w.write(PIMHandler.getInstance().composeDateTime(date));
w.write("\r\n");
break;
}
}
| private void | writeValue(java.io.Writer w, ToDo todo, int field, int index)Serializes one line of a vToDo.
switch (field) {
case ToDo.CLASS: {
int iValue = todo.getInt(field, index);
String sValue = VToDoSupport.getClassType(iValue);
if (sValue != null) {
w.write("CLASS:");
w.write(sValue);
w.write("\r\n");
}
break;
}
case ToDo.NOTE:
case ToDo.SUMMARY:
case ToDo.UID: {
String sValue = todo.getString(field, index);
if (sValue != null) {
String property = VToDoSupport.getFieldLabel(field);
w.write(property);
w.write(":");
w.write(sValue);
w.write("\r\n");
}
break;
}
case ToDo.DUE:
case ToDo.COMPLETION_DATE:
case ToDo.REVISION: {
long date = todo.getDate(field, index);
w.write(VToDoSupport.getFieldLabel(field));
w.write(":");
w.write(PIMHandler.getInstance().composeDateTime(date));
w.write("\r\n");
break;
}
case ToDo.COMPLETED: {
w.write("STATUS:COMPLETED\r\n");
break;
}
case ToDo.PRIORITY: {
w.write(VToDoSupport.getFieldLabel(field));
w.write(":");
w.write(String.valueOf(todo.getInt(field, index)));
w.write("\r\n");
break;
}
}
|
|