Source Code Cross Referenced for PentahoResourceLoader.java in  » Report » pentaho-report » org » pentaho » plugin » jfreereport » helper » 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 » pentaho report » org.pentaho.plugin.jfreereport.helper 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2006 Pentaho Corporation.  All rights reserved.
003:         * This software was developed by Pentaho Corporation and is provided under the terms
004:         * of the Mozilla Public License, Version 1.1, or any later version. You may not use
005:         * this file except in compliance with the license. If you need a copy of the license,
006:         * please go to http://www.mozilla.org/MPL/MPL-1.1.txt. The Original Code is the Pentaho
007:         * BI Platform.  The Initial Developer is Pentaho Corporation.
008:         *
009:         * Software distributed under the Mozilla Public License is distributed on an "AS IS"
010:         * basis, WITHOUT WARRANTY OF ANY KIND, either express or  implied. Please refer to
011:         * the license for the specific language governing your rights and limitations.
012:         */
013:        package org.pentaho.plugin.jfreereport.helper;
014:
015:        import java.net.URL;
016:        import java.util.HashMap;
017:        import java.util.Map;
018:
019:        import org.jfree.resourceloader.ResourceData;
020:        import org.jfree.resourceloader.ResourceKey;
021:        import org.jfree.resourceloader.ResourceKeyCreationException;
022:        import org.jfree.resourceloader.ResourceLoader;
023:        import org.jfree.resourceloader.ResourceLoadingException;
024:        import org.jfree.resourceloader.ResourceManager;
025:
026:        /**
027:         * This class is implemented to support loading solution files
028:         * from the pentaho repository into JFreeReport
029:         *
030:         * @author Will Gorman
031:         */
032:        public class PentahoResourceLoader implements  ResourceLoader {
033:
034:            public static final String SOLUTION_SCHEMA_NAME = "solution"; //$NON-NLS-1$
035:
036:            public static final String SCHEMA_SEPARATOR = ":/"; //$NON-NLS-1$
037:
038:            public static final String PATH_SEPARATOR = "/"; //$NON-NLS-1$
039:
040:            public static final String WIN_PATH_SEPARATOR = "\\"; //$NON-NLS-1$
041:
042:            /** keep track of the resource manager */
043:            private ResourceManager manager;
044:
045:            /**
046:             * default constructor
047:             */
048:            public PentahoResourceLoader() {
049:            }
050:
051:            /**
052:             * set the resource manager
053:             *  
054:             * @param manager resource manager
055:             */
056:            public void setResourceManager(ResourceManager manager) {
057:                this .manager = manager;
058:            }
059:
060:            /**
061:             * get the resource manager
062:             * 
063:             * @return resource manager
064:             */
065:            public ResourceManager getManager() {
066:                return manager;
067:            }
068:
069:            /**
070:             * get the schema name, in this case it's always "solution"
071:             * 
072:             * @return the schema name
073:             */
074:            public String getSchema() {
075:                return SOLUTION_SCHEMA_NAME;
076:            }
077:
078:            /**
079:             * create a resource data object
080:             * 
081:             * @param key resource key
082:             * @return resource data
083:             * @throws ResourceLoadingException
084:             */
085:            public ResourceData load(ResourceKey key)
086:                    throws ResourceLoadingException {
087:                return new PentahoResourceData(key);
088:            }
089:
090:            /**
091:             * see if the pentaho resource loader can support the content key path
092:             * 
093:             * @param values map of values to look in
094:             * @return true if class supports the content key.
095:             */
096:            public boolean isSupportedKey(ResourceKey key) {
097:                if (key.getSchema().equals(getSchema())) {
098:                    return true;
099:                }
100:                return false;
101:            }
102:
103:            /**
104:             * create a new key based on the values provided
105:             * 
106:             * @param values map of values
107:             * @return new resource key
108:             * @throws ResourceKeyCreationException
109:             */
110:            public ResourceKey createKey(Object value, Map factoryKeys)
111:                    throws ResourceKeyCreationException {
112:                if (value instanceof  String) {
113:                    String valueString = (String) value;
114:                    if (valueString.startsWith(getSchema() + SCHEMA_SEPARATOR)) {
115:                        String path = valueString.substring(getSchema()
116:                                .length()
117:                                + SCHEMA_SEPARATOR.length());
118:                        return new ResourceKey(getSchema(), path, factoryKeys);
119:                    }
120:                }
121:                return null;
122:            }
123:
124:            /**
125:             * derive a key from an existing key, used when a relative path is given.
126:             * 
127:             * @param parent the parent key
128:             * @param data the new data to be keyed
129:             * @return derived key
130:             * @throws ResourceKeyCreationException
131:             */
132:            public ResourceKey deriveKey(ResourceKey parent, String path,
133:                    Map data) throws ResourceKeyCreationException {
134:
135:                // update url to absolute path if currently a relative path
136:                if (!path.startsWith(getSchema() + SCHEMA_SEPARATOR)) {
137:                    // we are looking for the current directory specified by the parent.  currently
138:                    // the pentaho system uses the native File.separator, so we need to support it
139:                    // we're simply looking for the last "/" or "\" in the parent's url.
140:                    int winindex = ((String) parent.getIdentifier())
141:                            .lastIndexOf(WIN_PATH_SEPARATOR);
142:                    int regindex = ((String) parent.getIdentifier())
143:                            .lastIndexOf(PATH_SEPARATOR);
144:                    int dirindex = 0;
145:                    if (winindex > regindex) {
146:                        dirindex = winindex + WIN_PATH_SEPARATOR.length();
147:                    } else {
148:                        dirindex = regindex + PATH_SEPARATOR.length();
149:                    }
150:                    path = ((String) parent.getIdentifier()).substring(0,
151:                            dirindex)
152:                            + path;
153:                }
154:                final Map derivedValues = new HashMap(parent
155:                        .getFactoryParameters());
156:                derivedValues.putAll(data);
157:                return new ResourceKey(getSchema(), path, derivedValues);
158:            }
159:
160:            public URL toURL(ResourceKey key) {
161:                // not supported ..
162:                return null;
163:            }
164:
165:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.