001: /*
002: *
003: *
004: * Copyright 1990-2007 Sun Microsystems, Inc. All Rights Reserved.
005: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
006: *
007: * This program is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU General Public License version
009: * 2 only, as published by the Free Software Foundation.
010: *
011: * This program is distributed in the hope that it will be useful, but
012: * WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * General Public License version 2 for more details (a copy is
015: * included at /legal/license.txt).
016: *
017: * You should have received a copy of the GNU General Public License
018: * version 2 along with this work; if not, write to the Free Software
019: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA
021: *
022: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
023: * Clara, CA 95054 or visit www.sun.com if you need additional
024: * information or have any questions.
025: */
026:
027: package com.sun.kvem.midp.pim;
028:
029: import com.sun.kvem.midp.pim.formats.VCalendar10Format;
030: import javax.microedition.pim.PIM;
031: import javax.microedition.pim.ToDo;
032:
033: /**
034: * Implementation of a PIM ToDo.
035: *
036: */
037: public class ToDoImpl extends AbstractPIMItem implements ToDo {
038: /**
039: * Constructs a ToDo list.
040: * @param list template list
041: */
042: public ToDoImpl(AbstractPIMList list) {
043: super (list, PIM.TODO_LIST);
044: if (list != null && !(list instanceof ToDoListImpl)) {
045: throw new RuntimeException("Wrong list passed");
046: }
047: }
048:
049: /**
050: * Constructs a ToDo list.
051: * @param list template list
052: * @param base ToDo entry
053: */
054: ToDoImpl(AbstractPIMList list, ToDo base) {
055: super (list, base);
056: if (!(list instanceof ToDoListImpl)) {
057: throw new RuntimeException("Wrong list passed");
058: }
059: }
060:
061: /**
062: * Gets the encoding format.
063: * @return handle to format implementation
064: */
065: PIMFormat getEncodingFormat() {
066: return new VCalendar10Format();
067: }
068:
069: /**
070: * Checks if field is supported.
071: * @param field identifier for field
072: * @return <code>true</code> if field is supported
073: */
074: static boolean isValidPIMField(int field) {
075: switch (field) {
076: case ToDo.CLASS:
077: case ToDo.COMPLETED:
078: case ToDo.COMPLETION_DATE:
079: case ToDo.DUE:
080: case ToDo.NOTE:
081: case ToDo.PRIORITY:
082: case ToDo.REVISION:
083: case ToDo.SUMMARY:
084: case ToDo.UID:
085: return true;
086: default:
087: return false;
088: }
089: }
090:
091: /**
092: * Gets the revision field identifier.
093: * @return revision field identifier
094: */
095: protected int getRevisionField() {
096: return REVISION;
097: }
098:
099: /**
100: * Gets the UID field identifier.
101: * @return UID field identifier
102: */
103: protected int getUIDField() {
104: return UID;
105: }
106:
107: /**
108: * Converts the ToDo record to a printable format.
109: * @return formatted ToDo record
110: */
111: protected String toDisplayableString() {
112: return "ToDo[" + formatData() + "]";
113: }
114:
115: }
|