Source Code Cross Referenced for ICalUtil.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:         * Created on 29-Oct-2004
003:         *
004:         * TODO To change the template for this generated file go to
005:         * Window - Preferences - Java - Code Style - Code Templates
006:         */
007:        package org.jical;
008:
009:        import java.util.Date;
010:
011:        /**
012:         * @author sfg
013:         *
014:         * TODO To change the template for this generated type comment go to
015:         * Window - Preferences - Java - Code Style - Code Templates
016:         */
017:        public class ICalUtil {
018:
019:            public static String makeVEventLines(String type, String text) {
020:                if (text == null)
021:                    return "";
022:                StringBuffer textLine = new StringBuffer();
023:                textLine.append(type).append(text).append("\n");
024:
025:                // Now check for the fold over effect.
026:                //DESCRIPTION:This is a really big event line. I need to make this as I'm testing
027:                //  this stuff.
028:
029:                if (textLine.length() <= 75)
030:                    return textLine.toString();
031:
032:                StringBuffer newLines = new StringBuffer();
033:                while (textLine.length() > 75) {
034:                    newLines.append(textLine.substring(0, 75)).append("\n");
035:                    // Make text line from 78th char on.
036:                    String newTextLine = " " + textLine.substring(75);
037:                    textLine = new StringBuffer().append(newTextLine);
038:                }
039:
040:                return newLines.toString() + textLine;
041:            }
042:
043:            /*
044:             * TODO, all these renderings should be here in a util class.
045:             */
046:            public String getJiCaldisplayXML(ICalendar icalendar,
047:                    Date dateFrom, Date dateTo, String timeRange) {
048:                //        if (icalendar.getOrganizerEmail() == null
049:                //        ||  icalendar.getOrganizer() == null) {
050:                //            //logger.severe("Cannot create XML unless OrganizerEmail are Organizer provided to ICalendar");
051:                //            return "";
052:                //        }
053:                //
054:                //        /* 
055:                //         * This is more useful for rendering as HTML or PDF an
056:                //         * Evolution Calendar.
057:                //         *
058:                //         */
059:                //
060:                //        StringBuffer XMLString = new StringBuffer("<jicaldisplay>\n");
061:                //        XMLString.append("\t<organizer>").append( icalendar.getOrganizer()).append("</organizer>\n");
062:                //        XMLString.append("\t<organizeremail>").append(icalendar.getOrganizerEmail()).append("</organizeremail>\n");
063:                //        XMLString.append("\t<datestart>").append(dateFormatter.format(dateFrom)).append("</datestart>\n");
064:                //        XMLString.append("\t<dateend>").append(dateFormatter.format(dateTo)).append("</dateend>\n");
065:                //
066:                //        // Hmmm... If we truely want to represent this date range, we must get all dates from . 
067:                //        // to the To range. Reason being that some might start before this date and repeat in 
068:                //        // this range....
069:                //        
070:                //        // Make starting date really old!!
071:                //
072:                //        Date trueStartDate = new Date(0);
073:                //        getIcalExpandedEvents(trueStartDate, dateTo, timeRange);
074:                //
075:                //        /*
076:                //         * This is the tricky bit, iterate from the datefrom date, through the 
077:                //         * days to the dateto date. All days in between get some XML.
078:                //         */
079:                //        
080:                //        //int dateRepeatUnit = Calendar.HOUR_OF_DAY;
081:                //        
082:                //        Calendar repeatXMLDateStart = new GregorianCalendar();
083:                //        repeatXMLDateStart.setTime(dateFrom);
084:                //        
085:                //        XMLString.append("<days>\n");
086:                //        
087:                //        while (repeatXMLDateStart != null
088:                //        && !   repeatXMLDateStart.getTime().after(dateTo))
089:                //        {
090:                //            XMLString.append("\t\t<day>\n");
091:                //            XMLString.append("\t\t\t<dayofweek>").append(dayOfWeek.format(repeatXMLDateStart.getTime())).append("</dayofweek>\n");
092:                //            XMLString.append("\t\t\t<monthofyear>").append(monthOfYear.format(repeatXMLDateStart.getTime())).append("</monthofyear>\n");            
093:                //            XMLString.append("\t\t\t<weeknumber>").append(weekNumber.format(repeatXMLDateStart.getTime())).append("</weeknumber>\n");
094:                //            XMLString.append("\t\t\t<date>").append(dateOnlyFormat.format(repeatXMLDateStart.getTime())).append("</date>\n");
095:                //            XMLString.append("\t\t\t<vevents>\n");
096:                //            // Now find all events that match this date.
097:                //            Calendar thisDateFrom = new GregorianCalendar();
098:                //            thisDateFrom.setTime(repeatXMLDateStart.getTime());
099:                //            thisDateFrom.set(Calendar.HOUR_OF_DAY, 0);
100:                //            thisDateFrom.set(Calendar.MINUTE, 0);
101:                //            thisDateFrom.set(Calendar.SECOND, 0);
102:                //
103:                //            Date thisTimeFrom = thisDateFrom.getTime();
104:                //            // Altered as was excluding all day events which END at 00:00 on the next day..
105:                //            Calendar thisDateTo = new GregorianCalendar();
106:                //            thisDateTo.setTime(repeatXMLDateStart.getTime());
107:                //            thisDateTo.set(Calendar.HOUR_OF_DAY,24);
108:                //            thisDateTo.set(java.util.Calendar.MINUTE,0);
109:                //            thisDateTo.set(java.util.Calendar.SECOND,0);
110:                //            Date thisTimeTo = thisDateTo.getTime();
111:                //            
112:                //            Iterator eeIterator = sortedExpandedEvents.iterator();        
113:                //            while (eeIterator.hasNext())
114:                //            {
115:                //		ICalendarVEvent icalEvent = (ICalendarVEvent) eeIterator.next();
116:                //                /* There are four conditions for inclusion of this event
117:                //                 in this day. 
118:                //                 1) Runs right across this date and others.
119:                //                 *  ie day 23/2/2004. Event goes 22/2/2004 to 25/2/2004
120:                //                 2) Falls within the day
121:                //                 **  ie day 23/2/2004. Event goes 23/2/2004 to 23/2/2004
122:                //                 3) End period falls within the start day point or 
123:                //                 *   ie day 23/2/2004. Event goes 22/2/2004 to 23/2/2004 5am
124:                //                 4) Start period falls within the end day point. 
125:                //                 *   ie day 23/2/2004. Event goes 23/2/2004 12 noon to 25/2/2004
126:                //                */
127:                //                Date icalDateStart = icalEvent.getDateStart();
128:                //                Date icalDateEnd   = icalEvent.getDateEnd();
129:                //
130:                //                /*
131:                //                 * Whole day events are not handled well with this method as they run
132:                //                 * exactly on the 24hr time line. We need to recognise them and
133:                //                 * for the purposes of testing conditions, reduce the seconds so
134:                //                 * that they fit within a day.
135:                //                 */
136:                //                thisDateFrom.setTime(icalDateStart);
137:                //                thisDateTo.setTime(icalDateEnd);
138:                //                
139:                //                // Condition 1.
140:                //                if ((thisTimeFrom.after(icalDateStart)
141:                //                ||   thisTimeFrom.equals(icalDateStart))
142:                //                &&  (thisTimeTo.before(icalDateEnd)
143:                //                ||   thisTimeTo.equals(icalDateEnd)))
144:                //                {
145:                //                    // Create an all day event as this event wraps this day and others.
146:                //                    icalEvent.setDateStart(thisTimeFrom);
147:                //                    icalEvent.setDateEnd(thisTimeTo);                    
148:                //                    XMLString.append("\t\t");
149:                //                    XMLString.append(icalEvent.toXML());
150:                //                    XMLString.append("\n");
151:                //                }
152:                //                // Condition 2.
153:                //                else if (thisTimeFrom.before(icalDateStart)
154:                //                &&       thisTimeTo.after(icalDateEnd))
155:                //                {
156:                //                    // Create event as is.
157:                ////                    XMLString.append("Cond2");
158:                //                    XMLString.append("\t\t");
159:                //                    XMLString.append(icalEvent.toXML());
160:                //                    XMLString.append("\n");
161:                //                }    
162:                //                // Condition 3.
163:                //                else if (thisTimeFrom.before(icalDateEnd)
164:                //                &&       thisTimeTo.after(icalDateEnd))
165:                //                {
166:                //                    // Create event with end time as thisTimeTo, start time as speced.
167:                ////                    XMLString.append("Cond3" + thisTimeFrom + thisTimeTo);
168:                //                    icalEvent.setDateStart(thisTimeFrom);
169:                //                    icalEvent.setDateEnd(icalDateEnd);
170:                //                    XMLString.append("\t\t");
171:                //                    XMLString.append(icalEvent.toXML());
172:                //                    XMLString.append("\n");
173:                //                }    
174:                //                // Condition 4.
175:                //                else if (thisTimeFrom.before(icalDateStart)
176:                //                &&       thisTimeTo.after(icalDateStart))
177:                //                {
178:                //                    // Create event with starttime time as thisTimeFrom, end time as speced.
179:                ////                    XMLString.append("Cond4");
180:                //                    icalEvent.setDateStart(icalDateStart);
181:                //                    icalEvent.setDateEnd(thisTimeTo);
182:                //                    XMLString.append("\t\t");
183:                //                    XMLString.append(icalEvent.toXML());
184:                //                    XMLString.append("\n");
185:                //                }
186:                //                else {
187:                //                    //Event rejected for this date
188:                //                }
189:                //            }
190:                //
191:                //            XMLString.append("\t\t\t</vevents>");
192:                //            XMLString.append("\t\t</day>\n");
193:                //
194:                //            // On to the next day..
195:                //            repeatXMLDateStart.add(Calendar.HOUR_OF_DAY, 24);
196:                //            
197:                //        }
198:                //        
199:                //        XMLString.append("\t</days>\n");
200:                //        XMLString.append("</jicaldisplay>\n");
201:                //        return XMLString.toString();
202:                return "";
203:            }
204:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.