Source Code Cross Referenced for HourRule.java in  » Workflow-Engines » obe-1.0 » org » obe » engine » calendar » 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 » Workflow Engines » obe 1.0 » org.obe.engine.calendar 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.obe.engine.calendar;
002:
003:        import java.util.BitSet;
004:        import java.util.Calendar;
005:        import java.util.GregorianCalendar;
006:        import java.util.TimeZone;
007:
008:        /**
009:         * A rule that includes or excludes an interval of time within a single day.
010:         * Hours are expressed in the 24 hour clock from 00 to 23.
011:         * <p/>
012:         * If a date value is specified, the rule applies just to that one day;
013:         * otherwise, it applies to every day.
014:         */
015:        public class HourRule extends CalendarRule {
016:            //    private static final long serialVersionUID = 8762823343045505816L;
017:
018:            /**
019:             * Denotes the start of the timeframe for this rule.
020:             */
021:            private int _startHour;
022:
023:            /**
024:             * Denotes the end of the timeframe for this rule.  If equal to _startHour,
025:             * the applies to one hour.
026:             */
027:            private int _endHour;
028:
029:            /**
030:             * Limits the rule to a single day.
031:             */
032:            private GregorianCalendar _date;
033:
034:            /**
035:             * Number of intervals for this rule.
036:             */
037:            private int _ruleLength;
038:
039:            public HourRule() {
040:            }
041:
042:            public HourRule(int startHour) {
043:                _startHour = startHour;
044:                _endHour = startHour;
045:                _ruleLength = BusinessCalendar.INTERVALS_PER_HOUR;
046:            }
047:
048:            public HourRule(int startHour, int endHour) {
049:                _startHour = startHour;
050:                _endHour = endHour;
051:                _ruleLength = BusinessCalendar.INTERVALS_PER_HOUR
052:                        * (endHour - startHour);
053:            }
054:
055:            public HourRule(int startHour, GregorianCalendar date) {
056:                _startHour = startHour;
057:                _endHour = startHour;
058:                _date = date;
059:                _ruleLength = BusinessCalendar.INTERVALS_PER_HOUR;
060:            }
061:
062:            public HourRule(int startHour, int endHour, GregorianCalendar date) {
063:                _startHour = startHour;
064:                _endHour = endHour;
065:                _date = date;
066:                _ruleLength = BusinessCalendar.INTERVALS_PER_HOUR
067:                        * (endHour - startHour);
068:            }
069:
070:            public long getStartHour() {
071:                return _startHour;
072:            }
073:
074:            public void setStartHour(int startHour) {
075:                _startHour = startHour;
076:            }
077:
078:            public long getEndHour() {
079:                return _endHour;
080:            }
081:
082:            public void setEndHour(int endHour) {
083:                _endHour = endHour;
084:            }
085:
086:            public GregorianCalendar getDate() {
087:                return _date;
088:            }
089:
090:            public void setDate(GregorianCalendar date) {
091:                _date = date;
092:            }
093:
094:            public void applyRule(BitSet mask, int length,
095:                    GregorianCalendar startDate, GregorianCalendar endDate,
096:                    TimeZone tz) {
097:
098:                int startIndex = _startHour
099:                        * BusinessCalendar.INTERVALS_PER_HOUR;
100:
101:                if (_LOGGER.isDebugEnabled()) {
102:                    _LOGGER.debug("Length: " + length + " Start Index: "
103:                            + startIndex + " Start: " + startDate.getTime()
104:                            + " End: " + endDate.getTime());
105:                }
106:
107:                // Applies to all days
108:                if (_date == null) {
109:                    GregorianCalendar start = (GregorianCalendar) startDate
110:                            .clone();
111:                    int intervalsInDay;
112:                    for (int i = 0; i < length; i += intervalsInDay) {
113:                        BusinessCalendarUtilities.setBitSetBits(mask,
114:                                startIndex, _ruleLength);
115:                        start.add(Calendar.DATE, 1);
116:                        intervalsInDay = BusinessCalendarUtilities
117:                                .getIntervalsInDate(start);
118:                        startIndex += intervalsInDay;
119:                    }
120:                } else {
121:                    int index = BusinessCalendarUtilities.getIntervalIndex(
122:                            startDate.getTime(), _date.getTime(), tz)
123:                            + startIndex;
124:
125:                    BusinessCalendarUtilities.setBitSetBits(mask, index,
126:                            _ruleLength);
127:                }
128:            }
129:
130:            public String toString() {
131:                return "HourRule[" + "_startHour=" + _startHour + ", _endHour="
132:                        + _endHour + ", _date=" + _date + ']';
133:            }
134:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.