0
|
1 |
/*
|
|
2 |
* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
package com.nokia.s60tools.creator.components.calendar;
|
|
19 |
|
|
20 |
import com.nokia.s60tools.creator.components.AbstractComponent;
|
|
21 |
import com.nokia.s60tools.creator.components.AbstractValue;
|
|
22 |
import com.nokia.s60tools.creator.core.CreatorEditorSettings;
|
|
23 |
|
|
24 |
/**
|
|
25 |
* One row of data of calendar
|
|
26 |
*/
|
|
27 |
public class CalendarValue extends AbstractValue {
|
|
28 |
|
|
29 |
private boolean isAttendee = false;
|
|
30 |
private String attendeeEmail = null;
|
|
31 |
private String attendeeCommonName = null;
|
|
32 |
|
|
33 |
/**
|
|
34 |
* @param value
|
|
35 |
* @param randomType
|
|
36 |
* @param amount
|
|
37 |
*/
|
|
38 |
public CalendarValue(String type, String value, ModeTypes randomType, int amount) {
|
|
39 |
this();
|
|
40 |
setValue(type, value);
|
|
41 |
setModeType(randomType);
|
|
42 |
setAmount(amount);
|
|
43 |
}
|
|
44 |
|
|
45 |
|
|
46 |
/**
|
|
47 |
* Set amount and also maxamount as amount
|
|
48 |
* For now in calendar there is no any other possible amount fields in calendar than maxamount in contact-set reference
|
|
49 |
* So using always amount also as maxamount. If there is new requirement for amount in calendar, reimplement.
|
|
50 |
*
|
|
51 |
* @param amount -for amount and maxamount
|
|
52 |
*/
|
|
53 |
public void setAmount(int amount) {
|
|
54 |
super.setAmount(amount);
|
|
55 |
super.setMaxAmount(amount);
|
|
56 |
}
|
|
57 |
|
|
58 |
/**
|
|
59 |
*
|
|
60 |
* @param value
|
|
61 |
* @param amount
|
|
62 |
*/
|
|
63 |
public CalendarValue(String type, String value, int amount) {
|
|
64 |
this();
|
|
65 |
setValue(type, value);
|
|
66 |
setModeType(ModeTypes.RandomTypeNotRandom);
|
|
67 |
setAmount(amount);
|
|
68 |
}
|
|
69 |
|
|
70 |
|
|
71 |
/**
|
|
72 |
* Creates new Value.
|
|
73 |
*
|
|
74 |
* @param value
|
|
75 |
* @param isRandom if false, random type is set to {@link ModeTypes#RandomTypeNotRandom}
|
|
76 |
* if true random type is set to {@link ModeTypes#RandomTypeDefaultLength}
|
|
77 |
* @param amount
|
|
78 |
*/
|
|
79 |
public CalendarValue(String type, String value, boolean isRandom, int amount) {
|
|
80 |
this();
|
|
81 |
if(!isRandom){
|
|
82 |
setModeType(ModeTypes.RandomTypeNotRandom);
|
|
83 |
}
|
|
84 |
else{
|
|
85 |
setModeType(ModeTypes.RandomTypeDefaultLength);
|
|
86 |
}
|
|
87 |
setValue(type, value);
|
|
88 |
setAmount(amount);
|
|
89 |
}
|
|
90 |
|
|
91 |
/**
|
|
92 |
* Creates new Value with no random and no amount.
|
|
93 |
* random value is set to {@link ModeTypes#RandomTypeNotRandom} and
|
|
94 |
* amount is set to 0.
|
|
95 |
* @param value
|
|
96 |
*/
|
|
97 |
public CalendarValue(String type, String value) {
|
|
98 |
this();
|
|
99 |
setValue(type, value);
|
|
100 |
setModeType(ModeTypes.RandomTypeNotRandom);
|
|
101 |
setAmount(0);
|
|
102 |
}
|
|
103 |
|
|
104 |
/**
|
|
105 |
* Creates new Value.
|
|
106 |
* Attributes is set by default;
|
|
107 |
* - random value is set to {@link ModeTypes#RandomTypeDefaultLength}
|
|
108 |
* - random is set to true
|
|
109 |
* - value is set to EMPTY_STRING
|
|
110 |
* - amount is set to 0.
|
|
111 |
*/
|
|
112 |
public CalendarValue() {
|
|
113 |
super(CreatorEditorSettings.TYPE_CALENDAR);
|
|
114 |
}
|
|
115 |
|
|
116 |
/**
|
|
117 |
* Is this value an attendee value
|
|
118 |
* @return <code>true</code> if this is attendee <code>false</code> otherwise
|
|
119 |
*/
|
|
120 |
public boolean isAttendee() {
|
|
121 |
return isAttendee;
|
|
122 |
}
|
|
123 |
|
|
124 |
/**
|
|
125 |
* Set this value to be an attendee value
|
|
126 |
* @param isAttendee <code>true</code> if this is attendee, <code>false</code> otherwise
|
|
127 |
*/
|
|
128 |
public void setAttendee(boolean isAttendee) {
|
|
129 |
this.isAttendee = isAttendee;
|
|
130 |
}
|
|
131 |
|
|
132 |
/**
|
|
133 |
* Get attendee email
|
|
134 |
* @return attendee email
|
|
135 |
*/
|
|
136 |
public String getAttendeeEmail() {
|
|
137 |
return attendeeEmail;
|
|
138 |
}
|
|
139 |
|
|
140 |
/**
|
|
141 |
* Get attendee common nane
|
|
142 |
* @return attendeee common name
|
|
143 |
*/
|
|
144 |
public String getAttendeeCommonName() {
|
|
145 |
return attendeeCommonName;
|
|
146 |
}
|
|
147 |
|
|
148 |
|
|
149 |
/**
|
|
150 |
* Set value by type. If type is "Attendee" using setAttendeeValue(value)
|
|
151 |
* otherwise using setValue(String)
|
|
152 |
* @param value
|
|
153 |
* @param type as in ZML
|
|
154 |
*/
|
|
155 |
public void setValue(String type, String value) {
|
|
156 |
|
|
157 |
if (type != null) {
|
|
158 |
setType(type);
|
|
159 |
if (type.equalsIgnoreCase(CalendarVariables.ATTENDEEEMAIL_XML_ELEMENT)
|
|
160 |
|| type.equalsIgnoreCase(CalendarVariables.ATTENDEEEMAIL)) {
|
|
161 |
this.attendeeEmail = value;
|
|
162 |
setAttendee(true);
|
|
163 |
} else if (type.equalsIgnoreCase(CalendarVariables.ATTENDEECOMMONNAME_XML_ELEMENT)
|
|
164 |
|| type.equalsIgnoreCase(CalendarVariables.ATTENDEECOMMONNAME)) {
|
|
165 |
this.attendeeCommonName = value;
|
|
166 |
setAttendee(true);
|
|
167 |
}else if (type.equalsIgnoreCase(CalendarVariables.ATTENDEE)
|
|
168 |
|| type.equalsIgnoreCase(CalendarVariables.ATTENDEE_XML_ELEMENT)) {
|
|
169 |
setAttendeeValue(value);
|
|
170 |
}else {
|
|
171 |
setValue(value);
|
|
172 |
}
|
|
173 |
|
|
174 |
} else {
|
|
175 |
setValue(value);
|
|
176 |
}
|
|
177 |
|
|
178 |
}
|
|
179 |
|
|
180 |
/**
|
|
181 |
* Set attendee value, calling this will also set this object as attendee by using setAttendee(true)
|
|
182 |
* @param attendeeEmail - <code>null</code> not allowed.
|
|
183 |
* @param attendeeCommonName or <code>null</code> if not set
|
|
184 |
*/
|
|
185 |
public void setAttendeeValue(String attendeeEmail, String attendeeCommonName) {
|
|
186 |
setAttendee(true);
|
|
187 |
|
|
188 |
this.attendeeEmail = attendeeEmail;
|
|
189 |
this.attendeeCommonName = attendeeCommonName;
|
|
190 |
|
|
191 |
}
|
|
192 |
|
|
193 |
/**
|
|
194 |
* Set attendee value, calling this will also set this object as attendee by using setAttendee(true)
|
|
195 |
* @param attendee with email and optional common name separated with '|'
|
|
196 |
*/
|
|
197 |
public void setAttendeeValue(String attendee) {
|
|
198 |
|
|
199 |
if(attendee != null){
|
|
200 |
|
|
201 |
setAttendee(true);
|
|
202 |
|
|
203 |
int separatorIndex = attendee.indexOf("|") ;
|
|
204 |
if(separatorIndex != -1){
|
|
205 |
this.attendeeEmail = attendee.substring(0,separatorIndex).trim();
|
|
206 |
this.attendeeCommonName = attendee.substring(separatorIndex +1).trim();;
|
|
207 |
|
|
208 |
}else{
|
|
209 |
this.attendeeEmail = attendee;
|
|
210 |
}
|
|
211 |
}
|
|
212 |
}
|
|
213 |
|
|
214 |
|
|
215 |
/* (non-Javadoc)
|
|
216 |
* @see com.nokia.s60tools.creator.components.AbstractValue#getValue()
|
|
217 |
*/
|
|
218 |
public String getValue() {
|
|
219 |
|
|
220 |
//In case of Attendee, there is two parameters in one value
|
|
221 |
if(isAttendee()){
|
|
222 |
if(getAttendeeCommonName() == null){
|
|
223 |
return getAttendeeEmail();
|
|
224 |
}else{
|
|
225 |
return getAttendeeEmail() + AbstractComponent.COMPONENT_TYPE_SEPARATOR
|
|
226 |
+getAttendeeCommonName();
|
|
227 |
}
|
|
228 |
|
|
229 |
}
|
|
230 |
//In case of contact set reference, value is not set, but id is
|
|
231 |
else if(isContactSetReference()){
|
|
232 |
return ""+getId();
|
|
233 |
}
|
|
234 |
else{
|
|
235 |
return super.getValue();
|
|
236 |
}
|
|
237 |
}
|
|
238 |
|
|
239 |
|
|
240 |
|
|
241 |
}
|