Source Code Cross Referenced for ICalendarVEvent.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) 


0001:        /*
0002:         *
0003:         * Created on August 3, 2002, 9:01 PM
0004:         *
0005:         * Stores an icalendar Time Zone as a java object.
0006:         * There can be more than one iCal time zone per Calendar.
0007:         * To make it easy, all times are recorded as GMT.
0008:         *  
0009:         */
0010:
0011:        package org.jical;
0012:
0013:        /**
0014:         * 
0015:         * @author sfg RFC 2445
0016:         * @author David Wellington
0017:         *  
0018:         */
0019:
0020:        import java.io.ByteArrayInputStream;
0021:        import java.text.SimpleDateFormat;
0022:        import java.util.ArrayList;
0023:        import java.util.Calendar;
0024:        import java.util.Collection;
0025:        import java.util.Comparator;
0026:        import java.util.Date;
0027:        import java.util.GregorianCalendar;
0028:        import java.util.TimeZone;
0029:
0030:        import javax.xml.parsers.DocumentBuilder;
0031:        import javax.xml.parsers.DocumentBuilderFactory;
0032:
0033:        import org.w3c.dom.Document;
0034:        import org.w3c.dom.Node;
0035:        import org.w3c.dom.NodeList;
0036:
0037:        /**
0038:         * @hibernate.class
0039:         *     table="ICALVEVENT"
0040:         *     dynamic-update="false"
0041:         *     dynamic-insert="false"
0042:         *
0043:         * @hibernate.discriminator
0044:         *     column="class"
0045:         */
0046:
0047:        public class ICalendarVEvent implements  Cloneable {
0048:
0049:            private static SimpleDateFormat localDateFormatter = new SimpleDateFormat(
0050:                    "yyyyMMdd'T'HHmmss");
0051:            private static SimpleDateFormat formatter = new SimpleDateFormat(
0052:                    "yyyyMMddHHmmss");
0053:            private static final SimpleDateFormat VEVENTformatter = new SimpleDateFormat(
0054:                    "yyyyMMdd'T'HHmmss'Z'");
0055:
0056:            private Date dateStamp;
0057:            private String organizer;
0058:            private String organizerEmail;
0059:            private Date created;
0060:            private Date lastModified;
0061:            private int priority;
0062:            private String attach;
0063:            private String location;
0064:            private String percentComplete;
0065:            private String status;
0066:            private String comment;
0067:            private boolean recurrenceId;
0068:            private String url;
0069:            private String geo;
0070:            private float geoX;
0071:            private float geoY;
0072:            private String resources;
0073:            private String contact;
0074:            private String relatedTo;
0075:            private String requestStatus;
0076:
0077:            private String id;
0078:
0079:            /**
0080:             *
0081:             * @hibernate.id 
0082:             *     generator-class="uuid.hex"
0083:             *     column="ID"
0084:             *
0085:             * @hibernate.column
0086:             *     name="ID"
0087:             *     sql-type="VARCHAR(255)"
0088:             *
0089:             */
0090:
0091:            public String getId() {
0092:                return this .id;
0093:            }
0094:
0095:            public void setId(String id) {
0096:                this .id = id;
0097:            }
0098:
0099:            private String uid;
0100:
0101:            /**
0102:             *
0103:             * @hibernate.property
0104:             *     column="UID"
0105:             *
0106:             * @hibernate.column
0107:             *     name="uid"
0108:             *     sql-type="VARCHAR(255)"
0109:             *
0110:             */
0111:
0112:            public String getUid() {
0113:                return uid;
0114:            }
0115:
0116:            public void setUid(String uid) {
0117:                this .uid = uid;
0118:            }
0119:
0120:            private String transparency;
0121:
0122:            /**
0123:             *
0124:             * @hibernate.property
0125:             *     column="TRANSPARENCY"
0126:             *
0127:             * @hibernate.column
0128:             *     name="transparency"
0129:             *     sql-type="VARCHAR(255)"
0130:             *
0131:             */
0132:
0133:            public String getTransparency() {
0134:                return this .transparency;
0135:            }
0136:
0137:            public void setTransparency(String transparency) {
0138:                this .transparency = transparency;
0139:            }
0140:
0141:            private Date dateStart;
0142:
0143:            /**
0144:             *
0145:             * @hibernate.property
0146:             *     column="DATE_START"
0147:             *
0148:             * @hibernate.column
0149:             *     name="dateStart"
0150:             *     sql-type="TIMESTAMP"
0151:             *
0152:             */
0153:
0154:            public Date getDateStart() {
0155:                return this .dateStart;
0156:            }
0157:
0158:            public void setDateStart(Date dateStart) {
0159:                this .dateStart = dateStart;
0160:            }
0161:
0162:            private Date dateEnd;
0163:
0164:            /**
0165:             *
0166:             * @hibernate.property
0167:             *     column="DATE_END"
0168:             *
0169:             * @hibernate.column
0170:             *     name="dateEnd"
0171:             *     sql-type="TIMESTAMP"
0172:             *
0173:             */
0174:
0175:            public Date getDateEnd() {
0176:                return this .dateEnd;
0177:            }
0178:
0179:            public void setDateEnd(Date dateEnd) {
0180:                this .dateEnd = dateEnd;
0181:            }
0182:
0183:            private String duration;
0184:
0185:            /** Getter for property duration.
0186:            /**
0187:             *
0188:             * @hibernate.property
0189:             *     column="DURATION"
0190:             *
0191:             * @hibernate.column
0192:             *     name="duration"
0193:             *     sql-type="VARCHAR(255)"
0194:             *
0195:             */
0196:
0197:            public String getDuration() {
0198:                return this .duration;
0199:            }
0200:
0201:            public void setDuration(String duration) {
0202:                this .duration = duration;
0203:                /*
0204:                 * Currently, use this duration to create a DateEnd. This is not optimal
0205:                 * but works for Apple iCal and is strictly true.
0206:                 */
0207:                if (getDateStart() != null && getDateEnd() == null) {
0208:                    //System.err.println("Generating a DateEnd");
0209:                    // PT15M
0210:                    char durationArray[] = duration.substring(2).toCharArray();
0211:                    // Now read each char and build up numerics into a number and
0212:                    // non-numerics
0213:                    // indicate a unit of time. Convert all units of time into secs then
0214:                    // add
0215:                    // to the result.
0216:                    String timeBuilt = "";
0217:                    int totalSecs = 0;
0218:                    for (int ctr = 0; ctr < durationArray.length; ctr++) {
0219:                        String this Char = String.valueOf(durationArray[ctr]);
0220:                        // Is this a number or a letter.
0221:                        int timeUnit = this Char.indexOf("HMS");
0222:                        if (timeUnit != -1) {
0223:                            // This is a time unit! Multiply by seconds
0224:                            if (timeUnit == 0)
0225:                                totalSecs = totalSecs
0226:                                        + Integer.parseInt(timeBuilt) * 3600;
0227:                            if (timeUnit == 1)
0228:                                totalSecs = totalSecs
0229:                                        + Integer.parseInt(timeBuilt) * 60;
0230:                            if (timeUnit == 2)
0231:                                totalSecs = totalSecs
0232:                                        + Integer.parseInt(timeBuilt);
0233:                            timeBuilt = "";
0234:                        } else {
0235:                            // Build up total time for time unit.
0236:                            timeBuilt = timeBuilt.concat(this Char);
0237:                        }
0238:                    }
0239:                    // Now adjust the dateEnd to dateStart + secs.
0240:                    int dateRepeatUnit = Calendar.SECOND;
0241:                    Calendar workDateEnd = new GregorianCalendar();
0242:                    workDateEnd.setTime(getDateStart());
0243:                    workDateEnd.add(dateRepeatUnit, totalSecs);
0244:                    setDateEnd(workDateEnd.getTime());
0245:                }
0246:            }
0247:
0248:            private String description;
0249:
0250:            /**
0251:             *
0252:             * @hibernate.property
0253:             *     column="DESCRIPTION"
0254:             *
0255:             * @hibernate.column
0256:             *     name="description"
0257:             *     sql-type="VARCHAR(255)"
0258:             *
0259:             */
0260:
0261:            public String getDescription() {
0262:                return this .description;
0263:            }
0264:
0265:            public void setDescription(String description) {
0266:                this .description = description;
0267:            }
0268:
0269:            private String summary;
0270:
0271:            /**
0272:             *
0273:             * @hibernate.property
0274:             *     column="SUMMARY"
0275:             *
0276:             * @hibernate.column
0277:             *     name="summary"
0278:             *     sql-type="VARCHAR(255)"
0279:             *
0280:             */
0281:
0282:            public String getSummary() {
0283:                return this .summary;
0284:            }
0285:
0286:            public void setSummary(String summary) {
0287:                this .summary = summary;
0288:            }
0289:
0290:            private int sequence;
0291:
0292:            /**
0293:             *
0294:             * @hibernate.property
0295:             *     column="SEQUENCE"
0296:             *
0297:             * @hibernate.column
0298:             *     name="sequence"
0299:             *     sql-type="INTEGER"
0300:             *
0301:             */
0302:
0303:            public int getSequence() {
0304:                return this .sequence;
0305:            }
0306:
0307:            public void setSequence(int sequence) {
0308:                this .sequence = sequence;
0309:            }
0310:
0311:            private String categories;
0312:
0313:            /**
0314:             *
0315:             * @hibernate.property
0316:             *     column="CATEGORIES"
0317:             *
0318:             * @hibernate.column
0319:             *     name="categories"
0320:             *     sql-type="VARCHAR(255)"
0321:             *
0322:             */
0323:
0324:            public String getCategories() {
0325:                return this .categories;
0326:            }
0327:
0328:            public void setCategories(String categories) {
0329:                this .categories = categories;
0330:            }
0331:
0332:            private String eventClass;
0333:
0334:            /**
0335:             *
0336:             * @hibernate.property
0337:             *     column="CLASS_OF_EVENT"
0338:             *
0339:             * @hibernate.column
0340:             *     name="classOfEvent"
0341:             *     sql-type="VARCHAR(255)"
0342:             *
0343:             */
0344:
0345:            public String getEventClass() {
0346:                return this .eventClass;
0347:            }
0348:
0349:            public void setEventClass(String eventClass) {
0350:                this .eventClass = eventClass;
0351:                //System.err.println("icalevent>>" +eventClass);
0352:            }
0353:
0354:            private String rRule;
0355:
0356:            /**
0357:             *
0358:             * @hibernate.property
0359:             *     column="RRULE"
0360:             *
0361:             * @hibernate.column
0362:             *     name="rrule"
0363:             *     sql-type="VARCHAR(255)"
0364:             *
0365:             */
0366:
0367:            public String getRRule() {
0368:                return this .rRule;
0369:            }
0370:
0371:            public void setRRule(String rRule) {
0372:                this .rRule = rRule;
0373:            }
0374:
0375:            private int repeatCount;
0376:
0377:            /**
0378:             *
0379:             * @hibernate.property
0380:             *     column="REPEAT_COUNT"
0381:             *
0382:             * @hibernate.column
0383:             *     name="repeatCount"
0384:             *     sql-type="INTEGER"
0385:             *
0386:             */
0387:
0388:            public int getRepeatCount() {
0389:                return this .repeatCount;
0390:            }
0391:
0392:            public void setRepeatCount(int repeatCount) {
0393:                this .repeatCount = repeatCount;
0394:            }
0395:
0396:            public Collection exDateCollection;
0397:
0398:            public Collection getExDateCollection() {
0399:                return this .exDateCollection;
0400:            }
0401:
0402:            public void setExDateCollection(Collection exDateCollection) {
0403:                this .exDateCollection = exDateCollection;
0404:            }
0405:
0406:            private boolean exDatesExist;
0407:
0408:            /**
0409:             *
0410:             * @hibernate.property
0411:             *     column="EXDATES_EXIST"
0412:             *
0413:             * @hibernate.column
0414:             *     name="exDatesExist"
0415:             *     sql-type="Boolean"
0416:             *
0417:             */
0418:
0419:            public boolean isExDatesExist() {
0420:                return this .exDatesExist;
0421:            }
0422:
0423:            public void setExDatesExist(boolean exDatesExist) {
0424:                this .exDatesExist = exDatesExist;
0425:            }
0426:
0427:            /** Holds value of property repeatRules. */
0428:            private RepeatRules repeatRules;
0429:
0430:            /** Getter for property repeatRules.
0431:             * @return Value of property repeatRules.
0432:             *
0433:             */
0434:            public RepeatRules getRepeatRules() {
0435:                return this .repeatRules;
0436:            }
0437:
0438:            /** Setter for property repeatRules.
0439:             * @param repeatRules New value of property repeatRules.
0440:             *
0441:             */
0442:            public void setRepeatRules(RepeatRules repeatRules) {
0443:                this .repeatRules = repeatRules;
0444:            }
0445:
0446:            public ICalendarVEvent() {
0447:                this .exDateCollection = new ArrayList();
0448:                this .eventClass = null;
0449:                this .repeatCount = 0;
0450:                this .repeatRules = new RepeatRules();
0451:                this .categories = null;
0452:                this .dateStart = null;
0453:                this .dateEnd = null;
0454:                this .description = null;
0455:                this .duration = null;
0456:                this .eventClass = null;
0457:                this .exDatesExist = false;
0458:                this .rRule = null;
0459:                this .sequence = 0;
0460:                this .summary = null;
0461:                this .transparency = null;
0462:                this .uid = null;
0463:            }
0464:
0465:            public ICalendarVEvent(Date dateStart, Date dateEnd,
0466:                    String description, String duration, String summary,
0467:                    ArrayList exDates, RepeatRules repRules) {
0468:                this .exDateCollection = exDates;
0469:                this .eventClass = null;
0470:                this .repeatCount = 0;
0471:                this .repeatRules = repRules;
0472:                this .categories = null;
0473:                this .dateStart = dateStart;
0474:                this .dateEnd = dateEnd;
0475:                this .description = description;
0476:                this .duration = duration;
0477:                this .eventClass = null;
0478:                this .exDatesExist = false;
0479:                this .rRule = null;
0480:                this .sequence = 0;
0481:                this .summary = summary;
0482:                this .transparency = null;
0483:                this .uid = null;
0484:            }
0485:
0486:            public Object clone() throws CloneNotSupportedException {
0487:                return super .clone();
0488:            }
0489:
0490:            /*
0491:             * To VEVENT
0492:             * 
0493:             * 
0494:             * This will create a VEVENT if applicable.
0495:             * 
0496:             * Note there is plenty to be improved here. Not least the rule that wraps lines to 78 chars..
0497:             * 
0498:             * 
0499:            		BEGIN:VEVENT
0500:            		DTSTAMP:20041029T184718Z
0501:            		ORGANIZER:MAILTO:sfg@eurekait.com
0502:            		CREATED:20041029T021927Z
0503:            		UID:libkcal-2020175830.1064
0504:            		SEQUENCE:0
0505:            		LAST-MODIFIED:20041029T021927Z
0506:            		SUMMARY:Hibernate integrate to Claims
0507:            		CLASS:PUBLIC
0508:            		PRIORITY:3
0509:            		DTSTART:20041028T131500Z
0510:            		DTEND:20041028T223000Z
0511:            		TRANSP:OPAQUE
0512:            		END:VEVENT
0513:
0514:             * 
0515:             */
0516:            public String toVEvent() {
0517:
0518:                //VEVENTformatter.setTimeZone(TimeZone.getDefault().getTimeZone("GMT"));
0519:
0520:                StringBuffer vEventBuffer = new StringBuffer();
0521:                vEventBuffer.append(ICalUtil
0522:                        .makeVEventLines("BEGIN:VEVENT", ""));
0523:                vEventBuffer.append(ICalUtil.makeVEventLines("UID:", this .uid));
0524:                vEventBuffer.append(ICalUtil.makeVEventLines("TRANSP:",
0525:                        this .transparency));
0526:                vEventBuffer.append(ICalUtil.makeVEventLines("DTSTART;",
0527:                        getVEventLocalTime(this .dateStart)));
0528:                vEventBuffer.append(ICalUtil.makeVEventLines("DTEND;",
0529:                        getVEventLocalTime(this .dateEnd)));
0530:                vEventBuffer.append(ICalUtil.makeVEventLines("DTSTAMP:",
0531:                        VEVENTformatter.format(this .dateStamp)));
0532:                vEventBuffer.append(ICalUtil.makeVEventLines("ORGANIZER:",
0533:                        this .organizer));
0534:                vEventBuffer.append(ICalUtil.makeVEventLines("CREATED:",
0535:                        VEVENTformatter.format(this .created)));
0536:                vEventBuffer.append(ICalUtil.makeVEventLines("LAST-MODIFIED:",
0537:                        VEVENTformatter.format(this .lastModified)));
0538:                vEventBuffer.append(ICalUtil.makeVEventLines("SUMMARY:",
0539:                        this .summary));
0540:                vEventBuffer.append(ICalUtil.makeVEventLines("DESCRIPTION:",
0541:                        this .description));
0542:                vEventBuffer.append(ICalUtil.makeVEventLines("SEQUENCE:",
0543:                        new Integer(this .sequence).toString()));
0544:                vEventBuffer.append(ICalUtil.makeVEventLines("CLASS:",
0545:                        this .eventClass));
0546:                vEventBuffer.append(ICalUtil.makeVEventLines("ATTACH:",
0547:                        this .attach));
0548:                vEventBuffer.append(ICalUtil.makeVEventLines("END:VEVENT", ""));
0549:
0550:                return vEventBuffer.toString();
0551:            }
0552:
0553:            /*
0554:             * Make this locale dependent...
0555:             */
0556:            public String getVEventLocalTime(Date localTime) {
0557:                if (localTime != null)
0558:                    return "VALUE=DATE-TIME;TZID=/softwarestudio.org/Olson_20011030_5/"
0559:                            + TimeZone.getDefault().getID()
0560:                            + ":"
0561:                            + localDateFormatter.format(localTime);
0562:                else
0563:                    return "";
0564:            }
0565:
0566:            /*
0567:             * To XML method Originally built so as to enable a collection of expanded
0568:             * dates to be created.
0569:             */
0570:
0571:            public String toXML() {
0572:                StringBuffer buffer = new StringBuffer();
0573:                buffer.append("<vevent>");
0574:                buffer.append("<uid>").append(this .uid).append("</uid>");
0575:                // Only add element if it has a value
0576:                if (this .transparency != null && this .transparency.length() > 0) {
0577:                    buffer.append("<transparency>");
0578:                    buffer.append(this .transparency);
0579:                    buffer.append("</transparency>");
0580:                }
0581:                // Add new elements for additional iCal fields added
0582:                if (this .location != null && this .location.length() > 0) {
0583:                    buffer.append("<location>");
0584:                    buffer.append("<![CDATA[");
0585:                    buffer.append(this .location);
0586:                    buffer.append("]]>");
0587:                    buffer.append("</location>");
0588:                }
0589:                if (this .url != null && this .url.length() > 0) {
0590:                    buffer.append("<url>");
0591:                    buffer.append(this .url);
0592:                    buffer.append("</url>");
0593:                }
0594:                if (this .organizer != null && this .organizer.length() > 0) {
0595:                    buffer.append("<organizer>");
0596:                    buffer.append(this .organizer);
0597:                    buffer.append("</organizer>");
0598:                }
0599:                if (this .organizerEmail != null
0600:                        && this .organizerEmail.length() > 0) {
0601:                    buffer.append("<organizeremail>");
0602:                    buffer.append("<![CDATA[");
0603:                    buffer.append(this .organizerEmail);
0604:                    buffer.append("]]>");
0605:                    buffer.append("</organizeremail>");
0606:                }
0607:                if (getStatus() != null && getStatus().length() > 0) {
0608:                    buffer.append("<status>");
0609:                    buffer.append(getStatus());
0610:                    buffer.append("</status>");
0611:                }
0612:                buffer.append("<datestart>");
0613:                if (this .dateStart != null)
0614:                    buffer.append(formatter.format(this .dateStart));
0615:                buffer.append("</datestart>");
0616:                buffer.append("<dateend>");
0617:                if (this .dateEnd != null)
0618:                    buffer.append(formatter.format(this .dateEnd));
0619:                buffer.append("</dateend>");
0620:
0621:                if (this .description != null && this .description.length() > 0) {
0622:                    buffer.append("<description>");
0623:                    buffer.append("<![CDATA[").append(this .description).append(
0624:                            "]]>");
0625:                    buffer.append("</description>");
0626:                }
0627:                buffer.append("<summary>");
0628:                if (this .summary != null)
0629:                    buffer.append("<![CDATA[").append(this .summary).append(
0630:                            "]]>");
0631:                buffer.append("</summary>");
0632:                buffer.append("<sequence>");
0633:                if (java.lang.Integer.toString(this .sequence) != null)
0634:                    buffer.append(java.lang.Integer.toString(this .sequence));
0635:                buffer.append("</sequence>");
0636:                if (this .categories != null && this .categories.length() > 0) {
0637:                    buffer.append("<categories>");
0638:                    buffer.append(this .categories);
0639:                    buffer.append("</categories>");
0640:                }
0641:                if (this .eventClass != null && this .eventClass.length() > 0) {
0642:                    buffer.append("<eventclass>");
0643:                    buffer.append(this .eventClass);
0644:                    buffer.append("</eventclass>");
0645:                }
0646:                buffer.append("</vevent>");
0647:                return buffer.toString();
0648:            }
0649:
0650:            /*
0651:             * Reads XML back into event class Originally built so as to enable a
0652:             * collection of expanded dates to be created.
0653:             */
0654:            public void fromXML(String inXML) {
0655:                try {
0656:                    DocumentBuilderFactory docuBuilderFactory = DocumentBuilderFactory
0657:                            .newInstance();
0658:                    docuBuilderFactory.setValidating(false);
0659:                    DocumentBuilder docuBuilder = docuBuilderFactory
0660:                            .newDocumentBuilder();
0661:                    ByteArrayInputStream bais = new ByteArrayInputStream(inXML
0662:                            .getBytes());
0663:                    Document doc = docuBuilder.parse(bais);
0664:                    NodeList nl = doc.getFirstChild().getChildNodes();
0665:
0666:                    for (int ctr = 0; ctr < nl.getLength(); ctr++) {
0667:                        Node ni = nl.item(ctr);
0668:                        //                System.err.println("ctr:" +ctr);
0669:                        String nodeName = ni.getNodeName();
0670:                        Node nodeChild = ni.getFirstChild();
0671:                        String nodeValue = "";
0672:                        try {
0673:                            nodeValue = nodeChild.getNodeValue();
0674:                        } catch (Exception e) {
0675:                            // Ignore catch, process next.. as NULL
0676:                        }
0677:                        //                System.err.println("Node/Value:" +nodeName +nodeValue);
0678:                        if (nodeValue != null) {
0679:                            if (nodeName.equals("uid"))
0680:                                this .setUid(nodeValue);
0681:                            else if (nodeName.equals("transparency"))
0682:                                this .setTransparency(nodeValue);
0683:                            else if (nodeName.equals("datestart"))
0684:                                this .setDateStart((Date) formatter
0685:                                        .parse(nodeValue));
0686:                            else if (nodeName.equals("dateend"))
0687:                                this .setDateEnd((Date) formatter
0688:                                        .parse(nodeValue));
0689:                            else if (nodeName.equals("description"))
0690:                                this .setDescription(nodeValue);
0691:                            else if (nodeName.equals("summary"))
0692:                                this .setSummary(nodeValue);
0693:                            else if (nodeName.equals("categories"))
0694:                                this .setCategories(nodeValue);
0695:                            else if (nodeName.equals("eventclass"))
0696:                                this .setEventClass(nodeValue);
0697:                            // Add new iCal fields
0698:                            else if (nodeName.equals("location"))
0699:                                this .setLocation(nodeValue);
0700:                            else if (nodeName.equals("url"))
0701:                                this .setUrl(nodeValue);
0702:                            else if (nodeName.equals("organizer"))
0703:                                this .setOrganizer(nodeValue);
0704:                            else if (nodeName.equals("organizeremail"))
0705:                                this .setOrganizerEmail(nodeValue);
0706:                            else if (nodeName.equals("status"))
0707:                                this .setPercentComplete(nodeValue);
0708:                        }
0709:                    }
0710:                } catch (Exception e) {
0711:                    System.err.println("XML Parser exception: fromXML:" + e);
0712:                }
0713:            }
0714:
0715:            public boolean equals(Object o) {
0716:                if (o instanceof  ICalendarVEvent) {
0717:                    ICalendarVEvent e = (ICalendarVEvent) o;
0718:                    return uid.equals(e.uid) && dateStart.equals(e.dateStart)
0719:                            && dateEnd.equals(e.dateEnd);
0720:                }
0721:                return false;
0722:            }
0723:
0724:            public int hashCode() {
0725:                return uid.hashCode() ^ dateStart.hashCode()
0726:                        ^ dateEnd.hashCode();
0727:            }
0728:
0729:            public static class StartDateComparator implements  Comparator {
0730:                public int compare(Object o1, Object o2) {
0731:                    ICalendarVEvent e1 = (ICalendarVEvent) o1;
0732:                    ICalendarVEvent e2 = (ICalendarVEvent) o2;
0733:                    return e1.getDateStart().compareTo(e2.getDateStart());
0734:                }
0735:
0736:                public boolean equals(Object obj) {
0737:                    return (obj instanceof  StartDateComparator);
0738:                }
0739:            }
0740:
0741:            public static class StartDateUIDComparator implements  Comparator {
0742:                public int compare(Object o1, Object o2) {
0743:                    ICalendarVEvent e1 = (ICalendarVEvent) o1;
0744:                    ICalendarVEvent e2 = (ICalendarVEvent) o2;
0745:                    int out = e1.getDateStart().compareTo(e2.getDateStart());
0746:                    if (out == 0) {
0747:                        out = e1.getUid().compareTo(e2.getUid());
0748:                    }
0749:                    return out;
0750:                }
0751:
0752:                public boolean equals(Object obj) {
0753:                    return (obj instanceof  StartDateUIDComparator);
0754:                }
0755:            }
0756:
0757:            /**
0758:             *
0759:             * @hibernate.property
0760:             *     column="DATE_CREATED"
0761:             *
0762:             * @hibernate.column
0763:             *     name="created"
0764:             *     sql-type="TIMESTAMP"
0765:             *
0766:             */
0767:            public Date getCreated() {
0768:                return created;
0769:            }
0770:
0771:            public void setCreated(Date created) {
0772:                this .created = created;
0773:            }
0774:
0775:            /**
0776:             *
0777:             * @hibernate.property
0778:             *     column="DATE_STAMP"
0779:             *
0780:             * @hibernate.column
0781:             *     name="dateStamp"
0782:             *     sql-type="TIMESTAMP"
0783:             *
0784:             */
0785:            public Date getDateStamp() {
0786:                return dateStamp;
0787:            }
0788:
0789:            public void setDateStamp(Date dateStamp) {
0790:                this .dateStamp = dateStamp;
0791:            }
0792:
0793:            /**
0794:             *
0795:             * @hibernate.property
0796:             *     column="LAST_MODIFIED"
0797:             *
0798:             * @hibernate.column
0799:             *     name="lastModified"
0800:             *     sql-type="TIMESTAMP"
0801:             *
0802:             */
0803:            public Date getLastModified() {
0804:                return lastModified;
0805:            }
0806:
0807:            public void setLastModified(Date lastModified) {
0808:                this .lastModified = lastModified;
0809:            }
0810:
0811:            /**
0812:             *
0813:             * @hibernate.property
0814:             *     column="ORGANIZER"
0815:             *
0816:             * @hibernate.column
0817:             *     name="organizer"
0818:             *     sql-type="VARCHAR"
0819:             *
0820:             */
0821:            public String getOrganizer() {
0822:                return organizer;
0823:            }
0824:
0825:            public void setOrganizer(String organizer) {
0826:                this .organizer = organizer;
0827:            }
0828:
0829:            /**
0830:             *
0831:             * @hibernate.property
0832:             *     column="PRIORITY"
0833:             *
0834:             * @hibernate.column
0835:             *     name="priority"
0836:             *     sql-type="INTEGER"
0837:             *
0838:             */
0839:            public int getPriority() {
0840:                return priority;
0841:            }
0842:
0843:            public void setPriority(int priority) {
0844:                this .priority = priority;
0845:            }
0846:
0847:            /**
0848:             *
0849:             * @hibernate.property
0850:             *     column="ATTACH"
0851:             *
0852:             * @hibernate.column
0853:             *     name="attach"
0854:             *     sql-type="VARCHAR(255)"
0855:             *
0856:             */
0857:            public String getAttach() {
0858:                return attach;
0859:            }
0860:
0861:            public void setAttach(String attach) {
0862:                this .attach = attach;
0863:            }
0864:
0865:            /**
0866:             *
0867:             * @hibernate.property
0868:             *     column="LOCATION"
0869:             *
0870:             * @hibernate.column
0871:             *     name="location"
0872:             *     sql-type="VARCHAR(255)"
0873:             *
0874:             */
0875:            public String getLocation() {
0876:                return location;
0877:            }
0878:
0879:            public void setLocation(String location) {
0880:                this .location = location;
0881:            }
0882:
0883:            /**
0884:             *
0885:             * @hibernate.property
0886:             *     column="PERCENTCOMPLETE"
0887:             *
0888:             * @hibernate.column
0889:             *     name="percentComplete"
0890:             *     sql-type="VARCHAR(255)"
0891:             *
0892:             */
0893:            public String getPercentComplete() {
0894:                return percentComplete;
0895:            }
0896:
0897:            public void setPercentComplete(String percentComplete) {
0898:                this .percentComplete = percentComplete;
0899:            }
0900:
0901:            public boolean isRecurrenceId() {
0902:                return recurrenceId;
0903:            }
0904:
0905:            public void setRecurrenceId(boolean recurrenceId) {
0906:                this .recurrenceId = recurrenceId;
0907:            }
0908:
0909:            /**
0910:             *
0911:             * @hibernate.property
0912:             *     column="URL"
0913:             *
0914:             * @hibernate.column
0915:             *     name="url"
0916:             *     sql-type="VARCHAR(255)"
0917:             *
0918:             */
0919:            public String getUrl() {
0920:                return url;
0921:            }
0922:
0923:            public void setUrl(String url) {
0924:                this .url = url;
0925:            }
0926:
0927:            /**
0928:             *
0929:             * @hibernate.property
0930:             *     column="ORGANISEREMAIL"
0931:             *
0932:             * @hibernate.column
0933:             *     name="organizerEmail"
0934:             *     sql-type="VARCHAR(255)"
0935:             *
0936:             */
0937:            public String getOrganizerEmail() {
0938:                return organizerEmail;
0939:            }
0940:
0941:            public void setOrganizerEmail(String organizerEmail) {
0942:                this .organizerEmail = organizerEmail;
0943:            }
0944:
0945:            public String getStatus() {
0946:                return status;
0947:            }
0948:
0949:            public void setStatus(String s) {
0950:                status = s;
0951:            }
0952:
0953:            public String getComment() {
0954:                return comment;
0955:            }
0956:
0957:            public void setComment(String comment) {
0958:                this .comment = comment;
0959:            }
0960:
0961:            public String getGeo() {
0962:                return geo;
0963:            }
0964:
0965:            public void setGeo(String geo) {
0966:                this .geo = geo;
0967:            }
0968:
0969:            public float getGeoX() {
0970:                return geoX;
0971:            }
0972:
0973:            public void setGeoX(float geoX) {
0974:                this .geoX = geoX;
0975:            }
0976:
0977:            public float getGeoY() {
0978:                return geoY;
0979:            }
0980:
0981:            public void setGeoY(float geoY) {
0982:                this .geoY = geoY;
0983:            }
0984:
0985:            public String getResources() {
0986:                return resources;
0987:            }
0988:
0989:            public void setResources(String resources) {
0990:                this .resources = resources;
0991:            }
0992:
0993:            public String getContact() {
0994:                return contact;
0995:            }
0996:
0997:            public void setContact(String contact) {
0998:                this .contact = contact;
0999:            }
1000:
1001:            public String getRelatedTo() {
1002:                return relatedTo;
1003:            }
1004:
1005:            public void setRelatedTo(String relatedTo) {
1006:                this .relatedTo = relatedTo;
1007:            }
1008:
1009:            public String getRequestStatus() {
1010:                return requestStatus;
1011:            }
1012:
1013:            public void setRequestStatus(String requestStatus) {
1014:                this.requestStatus = requestStatus;
1015:            }
1016:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.