Source Code Cross Referenced for ChildRequestEncoder.java in  » Web-Framework » rife-1.6.1 » com » uwyn » rife » engine » 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 » rife 1.6.1 » com.uwyn.rife.engine 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
003:         * Distributed under the terms of either:
004:         * - the common development and distribution license (CDDL), v1.0; or
005:         * - the GNU Lesser General Public License, v2.1 or later
006:         * $Id: ChildRequestEncoder.java 3634 2007-01-08 21:42:24Z gbevin $
007:         */
008:        package com.uwyn.rife.engine;
009:
010:        import com.uwyn.rife.engine.RequestMethod;
011:        import com.uwyn.rife.tools.ArrayUtils;
012:        import com.uwyn.rife.tools.Base64;
013:        import java.util.Map;
014:
015:        class ChildRequestEncoder {
016:            private static final String SEP_DECLARATION_NAME = "x\000";
017:            private static final int SEP_DECLARATION_NAME_LENGTH = SEP_DECLARATION_NAME
018:                    .length();
019:            private static final byte[] SEP_DECLARATION_NAME_BYTES = SEP_DECLARATION_NAME
020:                    .getBytes();
021:            private static final String SEP_METHOD = "m\000";
022:            private static final int SEP_METHOD_LENGTH = SEP_METHOD.length();
023:            private static final byte[] SEP_METHOD_BYTES = SEP_METHOD
024:                    .getBytes();
025:            private static final String SEP_PATHINFO = "i\000";
026:            private static final int SEP_PATHINFO_LENGTH = SEP_PATHINFO
027:                    .length();
028:            private static final byte[] SEP_PATHINFO_BYTES = SEP_PATHINFO
029:                    .getBytes();
030:
031:            static String encode(ElementInfo elementInfo, RequestState state) {
032:                byte[] childrequest_bytes = new byte[0];
033:
034:                if (state != null) {
035:                    // serialize the declaration name
036:                    String declaration_name = elementInfo.getDeclarationName();
037:                    childrequest_bytes = declaration_name.getBytes();
038:                    childrequest_bytes = ArrayUtils.join(childrequest_bytes,
039:                            SEP_DECLARATION_NAME_BYTES);
040:
041:                    // serialize the method
042:                    RequestMethod method = state.getElementState().getMethod();
043:                    if (method != null) {
044:                        childrequest_bytes = ArrayUtils.join(
045:                                childrequest_bytes, method.toString()
046:                                        .getBytes());
047:                        childrequest_bytes = ArrayUtils.join(
048:                                childrequest_bytes, SEP_METHOD_BYTES);
049:                    }
050:
051:                    // serialize the pathinfo
052:                    String path_info = state.getElementState().getPathInfo();
053:                    if (path_info != null && path_info.length() > 0) {
054:                        childrequest_bytes = ArrayUtils.join(
055:                                childrequest_bytes, path_info.getBytes());
056:                        childrequest_bytes = ArrayUtils.join(
057:                                childrequest_bytes, SEP_PATHINFO_BYTES);
058:                    }
059:
060:                    // serialize the parameters and their values
061:                    childrequest_bytes = ArrayUtils.join(childrequest_bytes,
062:                            ParameterMapEncoder.encodeToBytes(state
063:                                    .getElementState().getRequestParameters()));
064:                }
065:
066:                return Base64.encodeToString(childrequest_bytes, false);
067:            }
068:
069:            static void decode(ElementInfo elementInfo, RequestState state) {
070:                if (state != null) {
071:                    String encoded_childrequest = state.getElementState()
072:                            .getRequestParameter(
073:                                    ReservedParameters.CHILDREQUEST);
074:
075:                    String declaration_name = null;
076:                    String method = "";
077:                    String path_info = "";
078:                    Map<String, String[]> parameters = null;
079:                    if (encoded_childrequest != null
080:                            & encoded_childrequest.length() > 0) {
081:                        String decoded_childrequest = new String(Base64
082:                                .decode(encoded_childrequest));
083:
084:                        // deserialize the declaration name
085:                        int declaration_name_index = decoded_childrequest
086:                                .indexOf(SEP_DECLARATION_NAME);
087:                        if (declaration_name_index != -1) {
088:                            declaration_name = decoded_childrequest.substring(
089:                                    0, declaration_name_index);
090:                        }
091:                        // online use this childrequest if it's element declaration name
092:                        // matches the one that was targeted when the child request was
093:                        // encoded
094:                        if (null == declaration_name
095:                                || !declaration_name.equals(elementInfo
096:                                        .getDeclarationName())) {
097:                            return;
098:                        }
099:                        decoded_childrequest = decoded_childrequest
100:                                .substring(declaration_name_index
101:                                        + SEP_DECLARATION_NAME_LENGTH);
102:
103:                        // deserialize the method
104:                        int method_index = decoded_childrequest
105:                                .indexOf(SEP_METHOD);
106:                        if (method_index != -1) {
107:                            method = decoded_childrequest.substring(0,
108:                                    method_index);
109:                            decoded_childrequest = decoded_childrequest
110:                                    .substring(method_index + SEP_METHOD_LENGTH);
111:                        }
112:
113:                        // deserialize the pathinfo
114:                        int path_info_index = decoded_childrequest
115:                                .indexOf(SEP_PATHINFO);
116:                        if (path_info_index != -1) {
117:                            path_info = decoded_childrequest.substring(0,
118:                                    path_info_index);
119:                            decoded_childrequest = decoded_childrequest
120:                                    .substring(path_info_index
121:                                            + SEP_PATHINFO_LENGTH);
122:                        }
123:
124:                        // deserialize the parameters and their values
125:                        parameters = ParameterMapEncoder
126:                                .decodeFromString(decoded_childrequest);
127:                    }
128:
129:                    state.getElementState().setMethod(
130:                            RequestMethod.getMethod(method));
131:                    state.getElementState().setPathInfo(path_info);
132:                    state.getElementState().setRequestParameters(parameters);
133:                }
134:            }
135:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.