Source Code Cross Referenced for RepeatRules.java in  » Groupware » hipergate » org » jical » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Groupware » hipergate » org.jical 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *
003:         * Created on August 3, 2002, 9:01 PM
004:         *
005:         * Stores a repeat rule object for 
006:         * manipulation by the expand events methods.
007:         *  
008:         */
009:
010:        package org.jical;
011:
012:        /**
013:         *
014:         * @author  sfg
015:         * RFC 2445
016:         *
017:         */
018:
019:        import java.text.SimpleDateFormat;
020:        import java.util.Calendar;
021:        import java.util.Date;
022:
023:        /**
024:         * @hibernate.class
025:         *     table="ICALREPEATRULES"
026:         *     dynamic-update="false"
027:         *     dynamic-insert="false"
028:         *
029:         * @hibernate.discriminator
030:         *     column="class"
031:         */
032:
033:        public class RepeatRules {
034:
035:            private String id;
036:
037:            /**
038:             *
039:             * @hibernate.id 
040:             *     generator-class="uuid.hex"
041:             *     column="ID"
042:             *
043:             * @hibernate.column
044:             *     name="ID"
045:             *     sql-type="VARCHAR(255)"
046:             *
047:             */
048:
049:            public String getId() {
050:                return this .id;
051:            }
052:
053:            public void setId(String id) {
054:                this .id = id;
055:            }
056:
057:            private String uid;
058:
059:            /**
060:             *
061:             * @hibernate.property
062:             *     column="UID"
063:             *
064:             * @hibernate.column
065:             *     name="uid"
066:             *     sql-type="VARCHAR(255)"
067:             *
068:             */
069:
070:            public String getUid() {
071:                return uid;
072:            }
073:
074:            public void setUid(String uid) {
075:                this .uid = uid;
076:            }
077:
078:            int interval = 0;
079:
080:            /**
081:             *
082:             * @hibernate.property
083:             *     column="INTERVAL"
084:             *
085:             * @hibernate.column
086:             *     name="uid"
087:             *     sql-type="INTEGER"
088:             *
089:             */
090:
091:            public int getInterval() {
092:                return interval;
093:            }
094:
095:            public void setInterval(int interval) {
096:                this .interval = interval;
097:            }
098:
099:            int dateRepeatUnit = Calendar.DATE;
100:
101:            /**
102:             *
103:             * @hibernate.property
104:             *     column="DATEREPEATUNIT"
105:             *
106:             * @hibernate.column
107:             *     name="dateRepeatUnit"
108:             *     sql-type="INTEGER"
109:             *
110:             */
111:
112:            public int getDateRepeatUnit() {
113:                return dateRepeatUnit;
114:            }
115:
116:            public void setDateRepeatUnit(int dateRepeatUnit) {
117:                this .dateRepeatUnit = dateRepeatUnit;
118:            }
119:
120:            String frequency = null;
121:
122:            /**
123:             *
124:             * @hibernate.property
125:             *     column="FREQUENCY"
126:             *
127:             * @hibernate.column
128:             *     name="frequency"
129:             *     sql-type="VARCHAR(255)"
130:             *
131:             */
132:
133:            public String getFrequency() {
134:                return frequency;
135:            }
136:
137:            public void setFrequency(String frequency) {
138:                this .frequency = frequency;
139:            }
140:
141:            String repeatUntil = null;
142:
143:            /**
144:             *
145:             * @hibernate.property
146:             *     column="REPEATUNTIL"
147:             *
148:             * @hibernate.column
149:             *     name="repeatUntil"
150:             *     sql-type="VARCHAR(255)"
151:             *
152:             */
153:
154:            public String getRepeatUntil() {
155:                return repeatUntil;
156:            }
157:
158:            public void setRepeatUntil(String repeatUntil) {
159:                this .repeatUntil = repeatUntil;
160:            }
161:
162:            String repeatByDay = null;
163:
164:            /**
165:             *
166:             * @hibernate.property
167:             *     column="REPEATBYDAY"
168:             *
169:             * @hibernate.column
170:             *     name="repeatByDay"
171:             *     sql-type="VARCHAR(255)"
172:             *
173:             */
174:
175:            public String getRepeatByDay() {
176:                return repeatByDay;
177:            }
178:
179:            public void setRepeatByDay(String repeatByDay) {
180:                this .repeatByDay = repeatByDay;
181:            }
182:
183:            String repeatByMonth = null;
184:
185:            /**
186:             *
187:             * @hibernate.property
188:             *     column="REPEATBYMONTH"
189:             *
190:             * @hibernate.column
191:             *     name="repeatByMonth"
192:             *     sql-type="VARCHAR(255)"
193:             *
194:             */
195:
196:            public String getRepeatByMonth() {
197:                return repeatByMonth;
198:            }
199:
200:            public void setRepeatByMonth(String repeatByMonth) {
201:                this .repeatByMonth = repeatByMonth;
202:            }
203:
204:            String repeatBySecond = null;
205:
206:            /**
207:             *
208:             * @hibernate.property
209:             *     column="REPEATBYSECOND"
210:             *
211:             * @hibernate.column
212:             *     name="repeatBySecond"
213:             *     sql-type="VARCHAR(255)"
214:             *
215:             */
216:
217:            public String getRepeatBySecond() {
218:                return repeatBySecond;
219:            }
220:
221:            public void setRepeatBySecond(String repeatBySecond) {
222:                this .repeatBySecond = repeatBySecond;
223:            }
224:
225:            String repeatByMinute = null;
226:
227:            /**
228:             *
229:             * @hibernate.property
230:             *     column="REPEATBYMINUTE"
231:             *
232:             * @hibernate.column
233:             *     name="repeatByMinute"
234:             *     sql-type="VARCHAR(255)"
235:             *
236:             */
237:
238:            public String getRepeatByMinute() {
239:                return repeatByMinute;
240:            }
241:
242:            public void setRepeatByMinute(String repeatByMinute) {
243:                this .repeatByMinute = repeatByMinute;
244:            }
245:
246:            String repeatByHour = null;
247:
248:            /**
249:             *
250:             * @hibernate.property
251:             *     column="REPEATBYHOUR"
252:             *
253:             * @hibernate.column
254:             *     name="repeatByHour"
255:             *     sql-type="VARCHAR(255)"
256:             *
257:             */
258:
259:            public String getRepeatByHour() {
260:                return repeatByHour;
261:            }
262:
263:            public void setRepeatByHour(String repeatByHour) {
264:                this .repeatByHour = repeatByHour;
265:            }
266:
267:            String repeatByMonthDay = null;
268:
269:            /**
270:             *
271:             * @hibernate.property
272:             *     column="REPEATBYMONTHDAY"
273:             *
274:             * @hibernate.column
275:             *     name="repeatByMonthDay"
276:             *     sql-type="VARCHAR(255)"
277:             *
278:             */
279:
280:            public String getRepeatByMonthDay() {
281:                return repeatByMonthDay;
282:            }
283:
284:            public void setRepeatByMonthDay(String repeatByMonthDay) {
285:                this .repeatByMonthDay = repeatByMonthDay;
286:            }
287:
288:            String repeatByYearDay = null;
289:
290:            /**
291:             *
292:             * @hibernate.property
293:             *     column="REPEATBYYEARDAY"
294:             *
295:             * @hibernate.column
296:             *     name="repeatByYearDay"
297:             *     sql-type="VARCHAR(255)"
298:             *
299:             */
300:
301:            public String getRepeatByYearDay() {
302:                return repeatByYearDay;
303:            }
304:
305:            public void setRepeatByYearDay(String repeatByYearDay) {
306:                this .repeatByYearDay = repeatByYearDay;
307:            }
308:
309:            String repeatByWeekNo = null;
310:
311:            /**
312:             *
313:             * @hibernate.property
314:             *     column="REPEATBYWEEKNO"
315:             *
316:             * @hibernate.column
317:             *     name="repeatByWeekNo"
318:             *     sql-type="VARCHAR(255)"
319:             *
320:             */
321:
322:            public String getRepeatByWeekNo() {
323:                return repeatByWeekNo;
324:            }
325:
326:            public void setRepeatByWeekNo(String repeatByWeekNo) {
327:                this .repeatByWeekNo = repeatByWeekNo;
328:            }
329:
330:            // Altered to Integer as was using -1 to represent null while -1 was a valid value!!!
331:            Integer repeatBySetPos = null;
332:
333:            /**
334:             *
335:             * @hibernate.property
336:             *     column="REPEATBYSETPOS"
337:             *
338:             * @hibernate.column
339:             *     name="repeatBySetPos"
340:             *     sql-type="INTEGER"
341:             *
342:             */
343:
344:            public Integer getRepeatBySetPos() {
345:                return repeatBySetPos;
346:            }
347:
348:            public void setRepeatBySetPos(Integer repeatBySetPos) {
349:                this .repeatBySetPos = repeatBySetPos;
350:            }
351:
352:            int repeatUntilCount = 99999999;
353:
354:            /**
355:             *
356:             * @hibernate.property
357:             *     column="REPEATUNTILCOUNT"
358:             *
359:             * @hibernate.column
360:             *     name="repeatUntilCount"
361:             *     sql-type="INTEGER"
362:             *
363:             */
364:
365:            public int getRepeatUntilCount() {
366:                return repeatUntilCount;
367:            }
368:
369:            public void setRepeatUntilCount(int repeatUntilCount) {
370:                this .repeatUntilCount = repeatUntilCount;
371:            }
372:
373:            Date repeatUntilDate = null;
374:
375:            /**
376:             *
377:             * @hibernate.property
378:             *     column="REPEATUNTILDATE"
379:             *
380:             * @hibernate.column
381:             *     name="repeatUntilDate"
382:             *     sql-type="DATE"
383:             *
384:             */
385:
386:            public Date getRepeatUntilDate() {
387:                return repeatUntilDate;
388:            }
389:
390:            public void setRepeatUntilDate(Date repeatUntilDate) {
391:                this .repeatUntilDate = repeatUntilDate;
392:            }
393:
394:            private SimpleDateFormat dateFormatter = new SimpleDateFormat(
395:                    "yyyyMMddHHmmss");
396:
397:            public RepeatRules() {
398:            }
399:
400:            public void parseRepeatRules(String rRule) {
401:                int startPoint = -1;
402:                int ii = 0;
403:                while (rRule != null && ii < 10) {
404:                    ii++;
405:                    String this Rule = null;
406:                    startPoint = rRule.indexOf(";");
407:                    if (startPoint != -1) {
408:                        this Rule = rRule.substring(0, startPoint);
409:                        rRule = rRule.substring(startPoint + 1);
410:                    } else {
411:                        this Rule = rRule;
412:                        rRule = null;
413:                    }
414:                    // Now evaluate the parameter.. 
415:                    // This is a weird one! Evolution-EndDate?
416:                    if (this Rule.startsWith("X-EVOLUTION-ENDDATE=")) {
417:                        startPoint = this Rule.indexOf(":");
418:                        String newRule = this Rule.substring(0, startPoint);
419:                        String evoEndDate = newRule.substring(20);
420:                        this Rule = this Rule.substring(startPoint + 1);
421:                    }
422:
423:                    if (this Rule.startsWith("FREQ=")) {
424:                        frequency = this Rule.substring(5);
425:                    } else if (this Rule.startsWith("INTERVAL=")) {
426:                        try {
427:                            Long Lint = (new Long(this Rule.substring(9)));
428:                            interval = Lint.intValue();
429:                        } catch (Exception e) {
430:                            System.err.println("INTERVAL Parse Error on "
431:                                    + this Rule + e);
432:                        }
433:                    } else if (this Rule.startsWith("UNTIL=")) {
434:                        repeatUntil = this Rule;
435:                        if (repeatUntil != null) {
436:                            repeatUntil = repeatUntil.substring(6);
437:                            //UNTIL=20020919
438:                            //UNTIL=20020919T000000
439:                            if (repeatUntil.length() == 8) {
440:                                repeatUntil = repeatUntil + "235959";
441:                            }
442:                            try {
443:                                if (repeatUntil.charAt(8) == 'T') {
444:                                    repeatUntil = repeatUntil.substring(0, 8)
445:                                            + repeatUntil.substring(9);
446:                                }
447:                                /*
448:                                 * When frequency is more than one day and UNTIL time = 000000
449:                                 * time must be adjusted to 235959
450:                                 */
451:                                if ((dateRepeatUnit != Calendar.HOUR)
452:                                        && (dateRepeatUnit != Calendar.MINUTE)
453:                                        && (dateRepeatUnit != Calendar.SECOND)) {
454:                                    if (repeatUntil.substring(8).equals(
455:                                            "000000")) {
456:                                        repeatUntil = repeatUntil.substring(0,
457:                                                8)
458:                                                + "235959";
459:                                    }
460:                                }
461:                                repeatUntilDate = dateFormatter
462:                                        .parse(repeatUntil);
463:                            } catch (Exception e) {
464:                                System.err
465:                                        .println("Exception getting RepeatUntilDate"
466:                                                + e);
467:                                System.err.println("Exception for date string"
468:                                        + this Rule);
469:                                repeatUntilDate = null;
470:                            }
471:                        }
472:                    } else if (this Rule.startsWith("BYDAY=")) {
473:                        // Example: MO,TU,TH,FR
474:                        repeatByDay = this Rule.substring(6);
475:                    } else if (this Rule.startsWith("BYMONTH=")) {
476:                        // Example: 1 or 11 or 12
477:                        // Comma delim list potentially.
478:                        repeatByMonth = this Rule.substring(8);
479:                    } else if (this Rule.startsWith("BYSECOND=")) {
480:                        // Example: 1 or 11 or 12
481:                        // Comma delim list potentially.
482:                        repeatBySecond = this Rule.substring(9);
483:                    } else if (this Rule.startsWith("BYMINUTE=")) {
484:                        // Example: 1 or 11 or 12
485:                        // Comma delim list potentially.
486:                        repeatByMinute = this Rule.substring(9);
487:                    } else if (this Rule.startsWith("BYHOUR=")) {
488:                        // Example: 1 or 11 or 12
489:                        // Comma delim list potentially.
490:                        repeatByHour = this Rule.substring(7);
491:                    } else if (this Rule.startsWith("BYMONTHDAY=")) {
492:                        // Example: 1,11,12
493:                        // Comma delim list potentially.
494:                        repeatByMonthDay = this Rule.substring(11);
495:                    } else if (this Rule.startsWith("BYYEARDAY=")) {
496:                        // Example: -50 50th last day of year.
497:                        // Comma delim list potentially.
498:                        repeatByYearDay = this Rule.substring(10);
499:                    } else if (this Rule.startsWith("BYWEEKNO=")) {
500:                        // Example: 50 50th week of year.
501:                        // Comma delim list potentially.
502:                        repeatByWeekNo = this Rule.substring(9);
503:                    }
504:                    /*
505:                        The BYSETPOS rule part specifies a COMMA character (US-ASCII decimal
506:                        44) separated list of values which corresponds to the nth occurrence
507:                        within the set of events specified by the rule. Valid values are 1 to
508:                        366 or -366 to -1. It MUST only be used in conjunction with another
509:                        BYxxx rule part. For example "the last work day of the month" could
510:                        be represented as:
511:
512:                        RRULE:FREQ=MONTHLY;BYDAY=MO,TU,WE,TH,FR;BYSETPOS=-1                        
513:                     */
514:                    else if (this Rule.startsWith("BYSETPOS=")) {
515:                        //repeatBySetPos = new Integer(thisRule.substring(9)).intValue();
516:                        // No need to create an object, use static method
517:                        repeatBySetPos = new Integer(this Rule.substring(9));
518:                    } else if (this Rule.startsWith("COUNT=")) {
519:                        // Single integer.
520:                        try {
521:                            //repeatUntilCount = new Integer(thisRule.substring(6)).intValue();
522:                            // No need to create an object, use static method
523:                            repeatUntilCount = Integer.parseInt(this Rule
524:                                    .substring(6));
525:
526:                        } catch (Exception e) {
527:                            System.err.println("BYSETPOS= Parse Error on "
528:                                    + this Rule + e);
529:                        }
530:                    }
531:                }
532:
533:                // Now settle the dateRepeatUnit!
534:                if (frequency.equalsIgnoreCase("YEARLY")) {
535:                    dateRepeatUnit = Calendar.YEAR;
536:                } else if (frequency.equalsIgnoreCase("MONTHLY")) {
537:                    dateRepeatUnit = Calendar.MONTH;
538:                } else if (frequency.equalsIgnoreCase("WEEKLY")) {
539:                    dateRepeatUnit = Calendar.DAY_OF_WEEK;
540:                } else if (frequency.equalsIgnoreCase("DAILY")) {
541:                    dateRepeatUnit = Calendar.DATE;
542:                } else if (frequency.equalsIgnoreCase("HOURLY")) {
543:                    dateRepeatUnit = Calendar.HOUR;
544:                } else if (frequency.equalsIgnoreCase("MINUTELY")) {
545:                    dateRepeatUnit = Calendar.MINUTE;
546:                } else if (frequency.equalsIgnoreCase("SECONDLY")) {
547:                    dateRepeatUnit = Calendar.SECOND;
548:                } else {
549:                    System.err
550:                            .println("RepeatRules =- No Matching rule for frequency "
551:                                    + frequency);
552:                }
553:            }
554:
555:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.