Source Code Cross Referenced for JRVirtualizationContext.java in  » Report » jasperreports-2.0.1 » net » sf » jasperreports » engine » fill » 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 » jasperreports 2.0.1 » net.sf.jasperreports.engine.fill 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * ============================================================================
003:         * GNU Lesser General Public License
004:         * ============================================================================
005:         *
006:         * JasperReports - Free Java report-generating library.
007:         * Copyright (C) 2001-2006 JasperSoft Corporation http://www.jaspersoft.com
008:         * 
009:         * This library is free software; you can redistribute it and/or
010:         * modify it under the terms of the GNU Lesser General Public
011:         * License as published by the Free Software Foundation; either
012:         * version 2.1 of the License, or (at your option) any later version.
013:         * 
014:         * This library is distributed in the hope that it will be useful,
015:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
016:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
017:         * Lesser General Public License for more details.
018:         * 
019:         * You should have received a copy of the GNU Lesser General Public
020:         * License along with this library; if not, write to the Free Software
021:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307, USA.
022:         * 
023:         * JasperSoft Corporation
024:         * 303 Second Street, Suite 450 North
025:         * San Francisco, CA 94107
026:         * http://www.jaspersoft.com
027:         */
028:        package net.sf.jasperreports.engine.fill;
029:
030:        import java.io.Serializable;
031:        import java.util.HashMap;
032:        import java.util.Map;
033:
034:        import org.apache.commons.collections.ReferenceMap;
035:        import org.apache.commons.logging.Log;
036:        import org.apache.commons.logging.LogFactory;
037:
038:        import net.sf.jasperreports.engine.JRConstants;
039:        import net.sf.jasperreports.engine.JRPrintImage;
040:        import net.sf.jasperreports.engine.JRRenderable;
041:        import net.sf.jasperreports.engine.JasperPrint;
042:
043:        /**
044:         * Context used to store data shared by virtualized objects resulted from a report fill process.
045:         * 
046:         * @author Lucian Chirita (lucianc@users.sourceforge.net)
047:         * @version $Id: JRVirtualizationContext.java 1254 2006-05-15 08:57:30Z lucianc $
048:         */
049:        public class JRVirtualizationContext implements  Serializable {
050:            private static final long serialVersionUID = JRConstants.SERIAL_VERSION_UID;
051:
052:            private static final Log log = LogFactory
053:                    .getLog(JRVirtualizationContext.class);
054:
055:            private static final ReferenceMap contexts = new ReferenceMap(
056:                    ReferenceMap.WEAK, ReferenceMap.WEAK);
057:
058:            private Map cachedRenderers;
059:            private Map cachedTemplates;
060:
061:            private boolean readOnly;
062:
063:            /**
064:             * Constructs a context.
065:             */
066:            public JRVirtualizationContext() {
067:                cachedRenderers = new HashMap();
068:                cachedTemplates = new HashMap();
069:            }
070:
071:            /**
072:             * Caches an image renderer.
073:             * 
074:             * @param image the image whose renderer should be cached
075:             */
076:            public void cacheRenderer(JRPrintImage image) {
077:                JRRenderable renderer = image.getRenderer();
078:                if (renderer != null) {
079:                    cachedRenderers.put(renderer.getId(), renderer);
080:                }
081:            }
082:
083:            /**
084:             * Retrieves a cached image renderer based on an ID.
085:             * 
086:             * @param id the ID
087:             * @return the cached image renderer for the ID
088:             */
089:            public JRRenderable getCachedRenderer(String id) {
090:                return (JRRenderable) cachedRenderers.get(id);
091:            }
092:
093:            /**
094:             * Determines whether a cached image renderer for a specified ID exists.
095:             * 
096:             * @param id the ID
097:             * @return <code>true</code> iff the context contains a cached renderer with the specified ID
098:             */
099:            public boolean hasCachedRenderer(String id) {
100:                return cachedRenderers.containsKey(id);
101:            }
102:
103:            /**
104:             * Determines whether a cached {@link JRTemplateElement template} with a specified ID exists.
105:             * 
106:             * @param id the template ID
107:             * @return <code>true</code> iff the context contains a cached template with the specified ID
108:             */
109:            public boolean hasCachedTemplate(String id) {
110:                return cachedTemplates.containsKey(id);
111:            }
112:
113:            /**
114:             * Caches an element template.
115:             * 
116:             * @param template the template to cache
117:             */
118:            public void cacheTemplate(JRTemplateElement template) {
119:                Object old = cachedTemplates.put(template.getId(), template);
120:                if (old == null && log.isDebugEnabled()) {
121:                    log.debug("Cached template " + template + " having id "
122:                            + template.getId());
123:                }
124:            }
125:
126:            /**
127:             * Retrieves a cached template.
128:             * 
129:             * @param templateId the template ID
130:             * @return the cached template having the given ID
131:             */
132:            public JRTemplateElement getCachedTemplate(String templateId) {
133:                return (JRTemplateElement) cachedTemplates.get(templateId);
134:            }
135:
136:            /**
137:             * Determines whether this context has been marked as read-only.
138:             * 
139:             * @return whether this context has been marked as read-only
140:             * @see #setReadOnly(boolean)
141:             */
142:            public boolean isReadOnly() {
143:                return readOnly;
144:            }
145:
146:            /**
147:             * Sets the read-only flag for this context.
148:             * <p>
149:             * When in read-only mode, all the virtualizable objects belonging to this context
150:             * are assumed final by the virtualizer and any change in a virtualizable object's data
151:             * would be discarded on virtualization.
152:             * 
153:             * @param readOnly the read-only flag
154:             */
155:            public void setReadOnly(boolean readOnly) {
156:                this .readOnly = readOnly;
157:            }
158:
159:            /**
160:             * Registers a virtualization context for {@link JasperPrint JasperPrint} object.
161:             * 
162:             * @param context the virtualization context
163:             * @param print the print object
164:             */
165:            public static void register(JRVirtualizationContext context,
166:                    JasperPrint print) {
167:                synchronized (contexts) {
168:                    contexts.put(print, context);
169:                }
170:            }
171:
172:            /**
173:             * Returns the virtualization context registered for a print object.
174:             * <p>
175:             * When the engine fills a report using a virtualizer, it {@link #register(JRVirtualizationContext, JasperPrint) registers}
176:             * the virtualization context with the generated {@link JasperPrint JasperPrint} object so that the caller
177:             * would be able to retrieve the context based on the returned print object.
178:             * 
179:             * @param print a print object
180:             * @return the virtualization context registered for the print object, or <code>null</code> if no context
181:             * has been registered
182:             */
183:            public static JRVirtualizationContext getRegistered(
184:                    JasperPrint print) {
185:                synchronized (contexts) {
186:                    return (JRVirtualizationContext) contexts.get(print);
187:                }
188:            }
189:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.