Source Code Cross Referenced for DateExpressionResolver.java in  » Report » jmagallanes-1.0 » com » calipso » reportgenerator » common » 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 » Report » jmagallanes 1.0 » com.calipso.reportgenerator.common 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.calipso.reportgenerator.common;
002:
003:        import java.util.Date;
004:        import java.util.Calendar;
005:        import java.util.Map;
006:        import java.util.HashMap;
007:        import java.text.DateFormat;
008:
009:        import com.calipso.common.DateEx;
010:
011:        /**
012:         * Esta clase se encarga de resolver las expresiones que generan las columnas calculadas de fechas
013:         */
014:        public abstract class DateExpressionResolver {
015:
016:            public static String DAY = "DAY";
017:            public static String WEEK = "WEEK";
018:            public static String YEAR = "YEAR";
019:            public static String QUARTER = "QUARTER";
020:            public static String FORTNIGTH = "FORTNIGTH";
021:            public static String MONTH = "MONTH";
022:            public static String SEMESTRE = "SEMESTRE";
023:            private static Map resolvers;
024:
025:            private DateFormat dateFormatter;
026:            private String datePattern;
027:            private Calendar cal;
028:
029:            private static String defaultDatePattern = "dd/MM/yyyy";
030:
031:            /**
032:             * Retorna un HashMap que contiene los mecanismos para resolver cada una de las funciones
033:             * @return Map
034:             */
035:            private static Map getResolvers() {
036:                if (resolvers == null) {
037:                    resolvers = new HashMap();
038:                    resolvers.put(DAY, new ResolveDay());
039:                    resolvers.put(WEEK, new ResolveWeek());
040:                    resolvers.put(SEMESTRE, new ResolveSemestre());
041:                    resolvers.put(YEAR, new ResolveYear());
042:                    resolvers.put(MONTH, new ResolveMonth());
043:                    resolvers.put(FORTNIGTH, new ResolveFortnight());
044:                    resolvers.put(QUARTER, new ResolveQuarter());
045:                }
046:                return resolvers;
047:            }
048:
049:            /**
050:             * Crea e inicializa un <code>DateExpressionResolver</code>
051:             */
052:            public DateExpressionResolver() {
053:                datePattern = defaultDatePattern;
054:            }
055:
056:            /**
057:             * Retorna un objeto Calendar
058:             * @return Calendar
059:             */
060:            public Calendar getCal() {
061:                return cal;
062:            }
063:
064:            /**
065:             * Asigna la fecha a partir de una dateString y un datePattern
066:             * @throws com.calipso.reportgenerator.common.InfoException
067:             */
068:            public void setDate(String dateString, String datePattern)
069:                    throws InfoException {
070:                /*SimpleDateFormat simpleDateFormat = new SimpleDateFormat();
071:                String dateFormat = "yyyyMMdd";
072:                int length= (dateString).length();
073:                if ( length == 8 ){
074:                  dateFormat = "yyyyMMdd";
075:                }else if ( length == 15 ){
076:                  dateFormat = "yyyyMMddHHmmssSSS";
077:                }
078:                simpleDateFormat.applyPattern(dateFormat);
079:                Date date = null;*/
080:                Date date = (new DateEx(dateString, datePattern)).getDate();
081:                //try {
082:                Calendar calHoy = Calendar.getInstance();
083:                calHoy.setTime(new Date());
084:                cal = (Calendar) calHoy.clone();
085:                //date = simpleDateFormat.parse(dateString);
086:                dateFormatter = DateFormat.getDateInstance(DateFormat.SHORT);
087:                dateFormatter.setCalendar(cal);
088:                cal.setTime(date);
089:                /*} catch (ParseException e) {
090:                  throw new InfoException(LanguageTraslator.traslate("77"), e);
091:                }*/
092:            }
093:
094:            /**
095:             * Retorna el objeto DateFormat correspondiente
096:             * @return DateFormat
097:             */
098:            public DateFormat getDateFormatter() {
099:                return dateFormatter;
100:            }
101:
102:            /**
103:             * Retorna un String que representa el formato de la Fecha
104:             * @return String
105:             */
106:            public String getDatePattern() {
107:                return datePattern;
108:            }
109:
110:            /**
111:             * Asigna un String que representa el formato de la Fecha al atributo datePattern
112:             */
113:            public void setDatePattern(String datePattern) {
114:                this .datePattern = datePattern;
115:            }
116:
117:            /**
118:             * Devuelve el valor dependiendo de  su clave
119:             DAY
120:             WEEK
121:             YEAR
122:             QUARTER
123:             FORTNIGTH
124:             MONTH
125:             SEMESTRE
126:             */
127:
128:            public String getValue(String dateValue) throws InfoException {
129:                setDate(dateValue, getDatePattern());
130:                return doGetValue();
131:            };
132:
133:            /**
134:             * Método abstracto que se sobrescribe para cada tipo
135:             * @return
136:             */
137:            protected abstract String doGetValue();
138:
139:            /**
140:             * Obtiene el valor de la función dateFunction , utilizando el datePatern por default dd/MM/yyyy
141:             * @throws com.calipso.reportgenerator.common.InfoException
142:             */
143:            public static String Resolve(String dateFunction, String dateValue)
144:                    throws InfoException {
145:                DateExpressionResolver resolver = (DateExpressionResolver) getResolvers()
146:                        .get(dateFunction);
147:                return resolver.getValue(dateValue);
148:            }
149:
150:            /**
151:             * Obtiene el valor de la función dateFunction , utilizando el datePatern nuevo
152:             * @throws com.calipso.reportgenerator.common.InfoException
153:             */
154:            public static String Resolve(String dateFunction, String dateValue,
155:                    String datePattern) throws InfoException {
156:                DateExpressionResolver resolver = (DateExpressionResolver) getResolvers()
157:                        .get(dateFunction);
158:                resolver.setDatePattern(datePattern);
159:                return resolver.getValue(dateValue);
160:            }
161:
162:            /**
163:             * Obtiene el valor de la función dateFunction , utilizando el datePatern nuevo
164:             * @throws com.calipso.reportgenerator.common.InfoException
165:             */
166:            public static String Resolve(String dateFunction, Date date)
167:                    throws InfoException {
168:                DateExpressionResolver resolver = (DateExpressionResolver) getResolvers()
169:                        .get(dateFunction);
170:                resolver.dateFormatter = DateFormat
171:                        .getDateInstance(DateFormat.SHORT);
172:                resolver.cal = Calendar.getInstance();
173:                resolver.dateFormatter.setCalendar(resolver.cal);
174:                resolver.cal.setTime(date);
175:                return resolver.doGetValue();
176:            }
177:
178:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.