Source Code Cross Referenced for OSDecoratorMapper.java in  » Web-Framework » SiteMesh » com » opensymphony » module » sitemesh » mapper » 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 » Web Framework » SiteMesh » com.opensymphony.module.sitemesh.mapper 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


01:        /*
02:         * Title:        OSDecoratorMapper
03:         * Description:
04:         *
05:         * This software is published under the terms of the OpenSymphony Software
06:         * License version 1.1, of which a copy has been included with this
07:         * distribution in the LICENSE.txt file.
08:         */
09:
10:        package com.opensymphony.module.sitemesh.mapper;
11:
12:        import com.opensymphony.module.sitemesh.Config;
13:        import com.opensymphony.module.sitemesh.Decorator;
14:        import com.opensymphony.module.sitemesh.DecoratorMapper;
15:        import com.opensymphony.module.sitemesh.Page;
16:
17:        import javax.servlet.http.HttpServletRequest;
18:        import java.util.Enumeration;
19:        import java.util.Properties;
20:
21:        /**
22:         * The OSDecoratorMapper will map a suitable decorator based on the operating system
23:         * of the remote client.
24:         *
25:         * <p>OSDecoratorMapper works by checking to see if the "UA-OS" header
26:         * was sent with the HTTP request. If it was, the class will check the
27:         * value of the header with all the different os's the user has configured
28:         * the Decorator Mapper to identify and, if a match is found, routes the
29:         * request accordingly.  Configuration is done using the sitemesh.xml file.
30:         * The param name is a string literal (operating system name) you would like
31:         * to match in the UA-OS header, and the value is what will be appended to the
32:         * decorator name if the user is using that operating system</p>
33:         *
34:         * @author	<a href="mailto:schepdawg@yahoo.com">Adam P. Schepis</a>
35:         * @version	$Revision: 1.3 $
36:         *
37:         * @see com.opensymphony.module.sitemesh.mapper.AbstractDecoratorMapper
38:         */
39:        public class OSDecoratorMapper extends AbstractDecoratorMapper {
40:            /**
41:             * Properties holds the parameters that the object was initialized with.
42:             */
43:            protected Properties properties;
44:
45:            /**
46:             * Init initializes the OSDecoratorMapper object by setting the parent
47:             * DecoratorMapper, and loading the initialization properties.
48:             *
49:             * @param config	The config file
50:             * @param properties	An object containing intialization parameters
51:             * @param parent	The parent DecoratorMapper object
52:             */
53:            public void init(Config config, Properties properties,
54:                    DecoratorMapper parent)
55:                    throws java.lang.InstantiationException {
56:                this .properties = properties;
57:                this .parent = parent;
58:            }
59:
60:            /**
61:             * Attempts to find the correct decorator for Page page based on
62:             * the UA-OS HTTP header in the request.
63:             *
64:             * @param request The HTTP request sent to the server
65:             * @param page The page SiteMesh is trying to find a decorator for
66:             *
67:             * @return A Decorator object that is either the decorator for the identified
68:             * OS, or the parent DecoratorMapper's decorator
69:             */
70:            public Decorator getDecorator(HttpServletRequest request, Page page) {
71:                String osHeader = request.getHeader("UA-OS").toLowerCase();
72:                if (osHeader == null)
73:                    return parent.getDecorator(request, page);
74:
75:                // run through the list of operating systems the application developer listed
76:                // in sitemesh.xml to see if we have a match to the user's current OS
77:                for (Enumeration e = properties.propertyNames(); e
78:                        .hasMoreElements();) {
79:                    String os = (String) e.nextElement();
80:
81:                    // see if the name matches the user's operating system name
82:                    if (osHeader.indexOf(os.toLowerCase()) != -1) {
83:                        String decoratorName = parent.getDecorator(request,
84:                                page).getName();
85:                        if (decoratorName != null) {
86:                            decoratorName += '-' + properties.getProperty(os);
87:                        }
88:                        return getNamedDecorator(request, decoratorName);
89:                    }
90:                }
91:
92:                return parent.getDecorator(request, page);
93:            }
94:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.