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


001:        package com.calipso.reportgenerator.reportmanager;
002:
003:        import com.calipso.reportgenerator.reportdefinitions.DimensionSourceDefinition;
004:        import com.calipso.reportgenerator.reportcalculator.IDataSource;
005:        import com.calipso.reportgenerator.common.*;
006:
007:        /**
008:         * Esta clase se utliza para llenar la <code>Matix</code> del <code>ReportSource</code> a partir del <IDataSource> entregado
009:         * por los <ReportDataSource>.
010:         * En las columnas comunes se encarga del obtener el valor a partir del índice del campo en el registro
011:         * En las columnas calculadas se encarga de ejecutar las operaciones necesarias para obtener el valor
012:         */
013:
014:        public class ReportSourceDimension {
015:
016:            private int index;
017:            private int dataIndex;
018:            private DimensionSourceDefinition dimensionSourceDefinition;
019:            private DateExpressionParser expressionParser;
020:            private String datePattern;
021:
022:            /**
023:             * Constructor que inicializa
024:             * @param dimensionSourceDefinition
025:             * @param index Indice de la matriz del pivot
026:             * @param dataIndex Indice del data source
027:             */
028:            public ReportSourceDimension(
029:                    DimensionSourceDefinition dimensionSourceDefinition,
030:                    int index, int dataIndex) {
031:                this .dimensionSourceDefinition = dimensionSourceDefinition;
032:                this .index = index;
033:                if (dimensionSourceDefinition.getCalculated()) {
034:                    this .dataIndex = -1;
035:                } else {
036:                    this .dataIndex = dataIndex;
037:                }
038:            }
039:
040:            /**
041:             * Constructor que inicializa el el formato de fecha
042:             * @param dimensionSourceDefinition
043:             * @param index
044:             * @param dataIndex
045:             * @param datePattern
046:             */
047:            public ReportSourceDimension(
048:                    DimensionSourceDefinition dimensionSourceDefinition,
049:                    int index, int dataIndex, String datePattern) {
050:                this (dimensionSourceDefinition, index, dataIndex);
051:                this .datePattern = datePattern;
052:            }
053:
054:            /**
055:             * Devuelve un date expression parser
056:             * @see com.calipso.reportgenerator.common.DateExpressionParser
057:             * @return
058:             */
059:            protected DateExpressionParser getExpressionParser() {
060:                if (expressionParser == null) {
061:                    expressionParser = new DateExpressionParser();
062:                }
063:                return expressionParser;
064:            }
065:
066:            /**
067:             * Indice que se utiliza para buscar en la matrix de datos para calcular
068:             * @return
069:             */
070:            public int getIndex() {
071:                return index;
072:            }
073:
074:            /**
075:             * Indice que se utiliza para buscar en el IDataSource
076:             * Este indice es distinto porque en el IDataSource no están las columnas calculadas
077:             * @return
078:             */
079:            public int getDataIndex() {
080:                return dataIndex;
081:            }
082:
083:            /**
084:             * Devuelve el dimension source definition
085:             * @return
086:             */
087:            public DimensionSourceDefinition getDimensionSourceDefinition() {
088:                return dimensionSourceDefinition;
089:            }
090:
091:            private int getCalculatedDataIndex(String name,
092:                    IDataSource dataSource) {
093:                if (dataIndex == -1) {
094:                    for (int i = 0; i < dataSource.getColumCount(); i++) {
095:                        String colName = dataSource.getColumName(i);
096:                        if (colName.equals(name)) {
097:                            return i;
098:                        }
099:                    }
100:                }
101:                return dataIndex;
102:            }
103:
104:            /**
105:             * Devuelve el valor de la dimensión
106:             * @param dataSource
107:             * @param index
108:             * @return
109:             * @throws InfoException
110:             */
111:            public Object getValue(IDataSource dataSource, int index)
112:                    throws InfoException {
113:                try {
114:                    if (getDimensionSourceDefinition().getCalculated()) {
115:                        String expression = getDimensionSourceDefinition()
116:                                .getExpression();
117:                        getExpressionParser().setExpression(expression);
118:                        String refDimensionName = getExpressionParser()
119:                                .getFieldName();
120:                        int calcDataIndex = getCalculatedDataIndex(
121:                                refDimensionName, dataSource);
122:                        String dateString = dataSource.getValueAt(index,
123:                                calcDataIndex).toString();
124:                        String resultValue = DateExpressionResolver.Resolve(
125:                                getExpressionParser().getDateFunction(),
126:                                dateString, getDatePattern());
127:                        return resultValue;
128:                    } else {
129:                        return dataSource.getValueAt(index, this .dataIndex)
130:                                .toString();
131:                    }
132:                } catch (Exception e) {
133:                    throw new InfoException(LanguageTraslator.traslate("90"), e);
134:                }
135:            }
136:
137:            /**
138:             * Devuelve el formato de fecha
139:             * @return
140:             */
141:            public String getDatePattern() {
142:                return datePattern;
143:            }
144:
145:            /**
146:             * Asigna el formato de fecha
147:             * @param pattern
148:             */
149:            public void setDatePattern(String pattern) {
150:                datePattern = pattern;
151:            }
152:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.