Source Code Cross Referenced for CCPPRequest.java in  » Web-Server » Jigsaw » org » w3c » jigsaw » ccpp » 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 Server » Jigsaw » org.w3c.jigsaw.ccpp 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // CCPPRequest.java
002:        // $Id: CCPPRequest.java,v 1.4 2000/08/16 21:37:34 ylafon Exp $
003:        // (c) COPYRIGHT MIT, INRIA and Keio, 2000.
004:        // Please first read the full copyright statement in file COPYRIGHT.html
005:
006:        package org.w3c.jigsaw.ccpp;
007:
008:        import org.w3c.jigsaw.http.Reply;
009:        import org.w3c.jigsaw.http.Request;
010:
011:        import org.w3c.www.http.HttpExtList;
012:        import org.w3c.www.http.HttpExt;
013:        import org.w3c.www.http.HttpFactory;
014:        import org.w3c.www.http.HttpTokenList;
015:
016:        /**
017:         * @version $Revision: 1.4 $
018:         * @author  Benoît Mahé (bmahe@w3.org)
019:         */
020:        public class CCPPRequest implements  CCPP {
021:
022:            Request request = null;
023:            ProfileRef references[] = null;
024:            HttpExtList httpextlist = null;
025:
026:            /**
027:             * Get the HTTP Request
028:             * @return a Request
029:             */
030:            public Request getHTTPRequest() {
031:                return request;
032:            }
033:
034:            /**
035:             * Get the standard CCPP reason phrase for the given warning code.
036:             * @param warning The given warning code.
037:             * @return A String giving the standard reason phrase, or
038:             * <strong>null</strong> if the status doesn't match any knowned error.
039:             */
040:            public static String getStandardWarning(int warning) {
041:                int category = warning / 100;
042:                int catcode = warning % 100;
043:                switch (category) {
044:                case 1:
045:                    if ((catcode >= 0) && (catcode < msg_100.length))
046:                        return msg_100[catcode];
047:                    break;
048:                case 2:
049:                    if ((catcode >= 0) && (catcode < msg_200.length))
050:                        return msg_200[catcode];
051:                    break;
052:                }
053:                return UNKNOWN_WARNING_MESSAGE;
054:            }
055:
056:            /**
057:             * Get a header value (relative to the CC/PP Extension protocol)
058:             * @param request the HTTP Request
059:             * @param header the header name (ie "Profile")
060:             * @return a String.
061:             */
062:            public String getCCPPHeaderValue(String header) {
063:                return request.getExtHeader(HTTP_EXT_ID, header);
064:            }
065:
066:            /**
067:             * Get the profile diff header relative to the given profile diff number.
068:             * @param request the HTTP Request
069:             * @param diffnumber the diff number
070:             */
071:            public String getProfileDiff(int diffnumber) {
072:                String diffname = PROFILE_DIFF_HEADER + "-" + diffnumber;
073:                return getCCPPHeaderValue(diffname);
074:            }
075:
076:            /**
077:             * Get the Profile references (absolute URI or Profile-diff-name)
078:             * ordered by priority (the last one has the highest priority).
079:             * @return a ProfileRef array (or null)
080:             * @see ProfileRef
081:             */
082:            public ProfileRef[] getProfileReferences() {
083:                if (references == null) {
084:                    String profile = getCCPPHeaderValue(PROFILE_HEADER);
085:                    if (profile != null) {
086:                        String profiles[] = (String[]) HttpFactory
087:                                .parseTokenList(profile).getValue();
088:                        references = new ProfileRef[profiles.length];
089:                        for (int i = 0; i < references.length; i++) {
090:                            references[i] = new ProfileRef(profiles[i]);
091:                        }
092:                    } else {
093:                        return null;
094:                    }
095:                }
096:                return references;
097:            }
098:
099:            /**
100:             * Get the CC/PP Request associated to the given HTTP Request
101:             * @param request the HTTP Request
102:             * @return a CCPPRequest instance
103:             */
104:            public static CCPPRequest getCCPPRequest(Request request) {
105:                if (request.hasState(CCPP_REQUEST_STATE)) {
106:                    return (CCPPRequest) request.getState(CCPP_REQUEST_STATE);
107:                } else {
108:                    CCPPRequest ccpprequest = new CCPPRequest(request);
109:                    request.setState(CCPP_REQUEST_STATE, ccpprequest);
110:                    return ccpprequest;
111:                }
112:            }
113:
114:            /**
115:             * Set the Acknowledgement Headers if it's appropriate.
116:             * @param reply the reply
117:             * @return the aknowledged reply
118:             */
119:            protected Reply acknowledge(Reply reply) {
120:                HttpExtList man = request.getHttpManExtDecl();
121:                if ((man != null) && (man.getLength() == 1)
122:                        && (man.getHttpExt(HTTP_EXT_ID) != null)) {
123:                    reply.setEnd2EndExtensionAcknowledgmentHeader();
124:                }
125:
126:                HttpExtList cman = request.getHttpCManExtDecl();
127:                if ((cman != null) && (cman.getLength() == 1)
128:                        && (cman.getHttpExt(HTTP_EXT_ID) != null)) {
129:                    reply.setHopByHopExtensionAcknowledgmentHeader();
130:                }
131:
132:                return reply;
133:            }
134:
135:            /**
136:             * Add a CC/PP Warning to the given reply.
137:             * @param reply the HTTP Reply
138:             * @param warning the CC/PP Warning code
139:             * @param reference the Profile reference
140:             */
141:            public void addWarning(Reply reply, int warning, String reference) {
142:                CCPPWarning ccppwarning = (CCPPWarning) reply
143:                        .getState(CCPPWarning.CCPPWARNING_STATE);
144:                if (ccppwarning == null) {
145:                    ccppwarning = new CCPPWarning();
146:                    reply.setState(CCPPWarning.CCPPWARNING_STATE, ccppwarning);
147:                }
148:                ccppwarning.addWarning(warning, reference);
149:                // is the extension declared?
150:                HttpExtList list = reply.getExtList(HTTP_EXT_ID);
151:                if (list == null) {
152:                    list = new HttpExtList(httpextlist);
153:                    reply.setHttpExtDecl(list);
154:                }
155:                HttpExt ext = list.getHttpExt(HTTP_EXT_ID);
156:                reply.setExtensionHeader(ext, PROFILE_WARNING_HEADER,
157:                        ccppwarning.toString());
158:            }
159:
160:            private CCPPRequest(Request request) {
161:                this.request = request;
162:                this.httpextlist = request.getExtList(HTTP_EXT_ID);
163:            }
164:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.