Source Code Cross Referenced for CalTaskRepeat.java in  » Portal » Open-Portal » com » sun » portal » app » sharedtasks » util » 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 » Portal » Open Portal » com.sun.portal.app.sharedtasks.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.sun.portal.app.sharedtasks.util;
002:
003:        import com.sun.comclient.calendar.RecurrencePattern;
004:        import com.sun.portal.app.sharedtasks.faces.beans.TaskUserSessionBackingBean;
005:        import com.sun.web.ui.model.Option;
006:        import java.util.ResourceBundle;
007:
008:        import com.sun.portal.log.common.PortalLogger;
009:        import java.util.logging.Logger;
010:        import java.util.logging.Level;
011:
012:        /**
013:         * Type-safe enumeration to model all available recurrence patterns.
014:         *
015:         * @author ashwin.mathew@sun.com
016:         */
017:        public class CalTaskRepeat {
018:            private static final String RECURRENCE_COUNT = "COUNT=";
019:            private static final String RECURRENCE_PREFIX = "RRULE:";
020:            private static final String RECURRENCE_SEPARATOR = ";";
021:            private static final int REPEAT_NO = 9;
022:
023:            private String[] rStringElements;
024:
025:            private String rString;
026:
027:            private String displayKey;
028:
029:            private static Logger logger = PortalLogger
030:                    .getLogger(CalTaskRepeat.class);
031:
032:            private static CalTaskRepeat[] repeats = new CalTaskRepeat[REPEAT_NO];
033:            private static int repeatIndex = 0;
034:
035:            private CalTaskRepeat(String[] rStringElements, String displayKey) {
036:                this .displayKey = displayKey;
037:                this .rStringElements = rStringElements;
038:
039:                StringBuffer rStringBuffer = new StringBuffer();
040:                for (int i = 0; i < rStringElements.length; i++) {
041:                    rStringBuffer.append(rStringElements[i]).append(
042:                            RECURRENCE_SEPARATOR);
043:                }
044:                this .rString = rStringBuffer.toString();
045:
046:                repeats[repeatIndex++] = this ;
047:            }
048:
049:            public String getDisplayKey() {
050:                return displayKey;
051:            }
052:
053:            public String getRString() {
054:                return rString;
055:            }
056:
057:            public String[] getRStringElements() {
058:                return rStringElements;
059:            }
060:
061:            public static String getStringForPattern(RecurrencePattern pattern) {
062:                String rPattern = null;
063:                int matchSpecificity = 0;
064:                String patternString = pattern.toRFC2445();
065:
066:                if (logger.isLoggable(Level.FINE)) {
067:                    logger.fine("Getting string for recurrence pattern ["
068:                            + patternString + "]");
069:                }
070:
071:                for (int i = 0; i < REPEAT_NO; i++) {
072:                    boolean match = true;
073:
074:                    String[] rStringElements = repeats[i].getRStringElements();
075:
076:                    for (int j = 0; j < rStringElements.length; j++) {
077:                        if (logger.isLoggable(Level.FINEST)) {
078:                            logger.finest("Matching against element ["
079:                                    + rStringElements[j] + "]");
080:                        }
081:
082:                        if (patternString.indexOf(rStringElements[j]) == -1) {
083:                            match = false;
084:                            break;
085:                        }
086:                    }
087:
088:                    if (match && rStringElements.length > matchSpecificity) {
089:                        rPattern = repeats[i].getRString();
090:                        matchSpecificity = rStringElements.length;
091:                        // Don't break after this, since a more specific match
092:                        // may be found.
093:                        if (logger.isLoggable(Level.FINEST)) {
094:                            logger.finest("Found pattern match [" + rPattern
095:                                    + "]");
096:                        }
097:                    }
098:                }
099:
100:                if (logger.isLoggable(Level.FINE)) {
101:                    logger.fine("Matched pattern [" + rPattern + "]");
102:                }
103:
104:                return rPattern;
105:            }
106:
107:            public static RecurrencePattern makeRPattern(String rString,
108:                    int rCount) {
109:                StringBuffer rfcPattern = new StringBuffer();
110:                rfcPattern.append(RECURRENCE_PREFIX).append(rString).append(
111:                        RECURRENCE_COUNT).append(rCount);
112:
113:                return new RecurrencePattern(rfcPattern.toString());
114:            }
115:
116:            public static Option[] getRecurrenceOptions() {
117:                TaskUserSessionBackingBean userSession = (TaskUserSessionBackingBean) TaskBeanFactory
118:                        .getBean(TaskUserSessionBackingBean.BEAN_NAME);
119:
120:                ResourceBundle bundle = userSession.getResourceBundle();
121:
122:                Option[] recurrenceOptions = new Option[REPEAT_NO];
123:
124:                for (int i = 0; i < REPEAT_NO; i++) {
125:                    recurrenceOptions[i] = new Option(repeats[i].getRString(),
126:                            bundle.getString(repeats[i].getDisplayKey()));
127:                }
128:
129:                return recurrenceOptions;
130:            }
131:
132:            /**
133:             * Recurrence options.
134:             */
135:
136:            public static final CalTaskRepeat REPEAT_ONE_TIME = new CalTaskRepeat(
137:                    new String[] { "REPEAT_ONE_TIME" }, "task_repeat_onetime");
138:
139:            public static final CalTaskRepeat REPEAT_HOURLY = new CalTaskRepeat(
140:                    new String[] { "FREQ=HOURLY" }, "task_repeat_hourly");
141:
142:            public static final CalTaskRepeat REPEAT_DAILY = new CalTaskRepeat(
143:                    new String[] { "FREQ=DAILY" }, "task_repeat_daily");
144:
145:            public static final CalTaskRepeat REPEAT_WEEKLY = new CalTaskRepeat(
146:                    new String[] { "FREQ=WEEKLY" }, "task_repeat_weekly");
147:
148:            public static final CalTaskRepeat REPEAT_MONTHLY = new CalTaskRepeat(
149:                    new String[] { "FREQ=MONTHLY" }, "task_repeat_monthly");
150:
151:            public static final CalTaskRepeat REPEAT_MON_WED_FRI = new CalTaskRepeat(
152:                    new String[] { "FREQ=WEEKLY", "BYDAY=MO,WE,FR" },
153:                    "task_repeat_monwedfri");
154:
155:            public static final CalTaskRepeat REPEAT_TUE_THU = new CalTaskRepeat(
156:                    new String[] { "FREQ=WEEKLY", "BYDAY=TU,TH" },
157:                    "task_repeat_tuethu");
158:
159:            public static final CalTaskRepeat REPEAT_SAT_SUN = new CalTaskRepeat(
160:                    new String[] { "FREQ=WEEKLY", "BYDAY=SA,SU" },
161:                    "task_repeat_satsun");
162:
163:            public static final CalTaskRepeat REPEAT_MON_TUE_WED_THU_FRI = new CalTaskRepeat(
164:                    new String[] { "FREQ=WEEKLY", "BYDAY=MO,TU,WE,TH,FR" },
165:                    "task_repeat_montuewedthufri");
166:
167:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.