1 /*
2  * Copyright (C) 2012 The Android Open Source Project
3  *
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
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 
17 package com.android.calendarcommon2;
18 
19 import android.util.Log;
20 
21 import java.util.LinkedHashMap;
22 import java.util.LinkedList;
23 import java.util.List;
24 import java.util.Set;
25 import java.util.ArrayList;
26 
27 /**
28  * Stub version of the ICalendar class, containing the subclasses for
29  * Component and Property, for use in the test.
30  */
31 public class ICalendar {
32 
33     private static final String TAG = "Sync";
34 
35     /**
36      * A component within an iCalendar (VEVENT, VTODO, VJOURNAL, VFEEBUSY,
37      * VTIMEZONE, VALARM).
38      */
39     public static class Component {
40         private final String mName;
41         private final LinkedHashMap<String, ArrayList<Property>> mPropsMap =
42                 new LinkedHashMap<String, ArrayList<Property>>();
43 
44         /**
45          * Creates a new component with the provided name.
46          * @param name The name of the component.
47          */
Component(String name, Component parent)48         public Component(String name, Component parent) {
49             mName = name;
50         }
51 
52         /**
53          * Adds a Property to this component.
54          * @param prop
55          */
addProperty(Property prop)56         public void addProperty(Property prop) {
57             String name= prop.getName();
58             ArrayList<Property> props = mPropsMap.get(name);
59             if (props == null) {
60                 props = new ArrayList<Property>();
61                 mPropsMap.put(name, props);
62             }
63             props.add(prop);
64         }
65 
66         /**
67          * Returns a list of properties with the specified name.  Returns null
68          * if there are no such properties.
69          * @param name The name of the property that should be returned.
70          * @return A list of properties with the requested name.
71          */
getProperties(String name)72         public List<Property> getProperties(String name) {
73             return mPropsMap.get(name);
74         }
75     }
76 
77     /**
78      * A property within an iCalendar component (e.g., DTSTART, DTEND, etc.,
79      * within a VEVENT).
80      */
81     public static class Property {
82         private final String mName;
83 
84         /**
85          * Creates a new property with the provided name.
86          * @param name The name of the property.
87          */
Property(String name)88         public Property(String name) {
89             mName = name;
90         }
91 
92         /**
93          * Returns the name of the property.
94          * @return The name of the property.
95          */
getName()96         public String getName() {
97             return mName;
98         }
99     }
100 
ICalendar()101     private ICalendar() {
102     }
103 }
104