KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > tasklist > usertasks > translators > MyCalendarBuilder


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.tasklist.usertasks.translators;
21
22 import java.util.ArrayList JavaDoc;
23 import java.util.List JavaDoc;
24 import net.fortuna.ical4j.data.CalendarBuilder;
25 import org.netbeans.modules.tasklist.usertasks.util.UTUtils;
26
27 /**
28  * Workaround for the X-NETBEANS-WORK-PERIOD;START=20050524T083759Z:76 and
29  * X-NETBEANS-DEPENDENCY.
30  *
31  * @author tl
32  */

33 public class MyCalendarBuilder extends CalendarBuilder {
34     private List JavaDoc cmps = new ArrayList JavaDoc();
35     private String JavaDoc property;
36
37     /**
38      * Creates a new instance of MyCalendarParser
39      */

40     public MyCalendarBuilder() {
41     }
42
43     public void parameter(String JavaDoc name, String JavaDoc value) throws java.net.URISyntaxException JavaDoc {
44         String JavaDoc c = (String JavaDoc) cmps.get(cmps.size() - 1);
45         if (c.equals("VTODO") && "X-NETBEANS-WORK-PERIOD".equals(property) && // NOI18N
46
name.equals("START")) // NOI18N
47
name = "X-NETBEANS-START"; // NOI18N
48
if (c.equals("VTODO") && "X-NETBEANS-DEPENDENCY".equals(property) && // NOI18N
49
name.equals("TYPE")) // NOI18N
50
name = "X-NETBEANS-TYPE"; // NOI18N
51
super.parameter(name, value);
52     }
53
54     @SuppressWarnings JavaDoc("unchecked")
55     public void startComponent(String JavaDoc name) {
56         if (name.equals("X"))
57             name = "X-UNKNOWN";
58         
59         cmps.add(name);
60         
61         super.startComponent(name);
62     }
63
64     public void endComponent(String JavaDoc name) {
65         super.endComponent(name);
66         cmps.remove(cmps.size() - 1);
67     }
68
69     public void startProperty(String JavaDoc name) {
70         if (name.indexOf(' ') >= 0) {
71             name = "X-" + name.replace(' ', '-');
72         }
73         property = name;
74         super.startProperty(name);
75     }
76
77     public void endProperty(String JavaDoc name) {
78         super.endProperty(name);
79         property = null;
80     }
81 }
82
Popular Tags