Source Code Cross Referenced for ClientStream.java in  » Net » hyperpool-0.4.0 » vicazh » hyperpool » stream » net » http » 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 » Net » hyperpool 0.4.0 » vicazh.hyperpool.stream.net.http 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        //accept-language: bg,ru;q=0.9,en;q=0.8
002:
003:        package vicazh.hyperpool.stream.net.http;
004:
005:        import java.io.*;
006:        import java.util.*;
007:
008:        /**
009:         * This class implements an http stream from client
010:         * 
011:         * @author Victor Zhigunov
012:         * @version 0.4.0
013:         */
014:        public class ClientStream extends Stream {
015:            public ClientStream() {
016:            }
017:
018:            private static final char SP = ' ';
019:
020:            private String method;
021:
022:            /**
023:             * Set the method
024:             */
025:            public void setMethod(String method) {
026:                this .method = method;
027:            }
028:
029:            /**
030:             * Get the method
031:             */
032:            public String getMethod() {
033:                return method;
034:            }
035:
036:            private String file;
037:
038:            /**
039:             * Set the file
040:             */
041:            public void setFile(String file) {
042:                this .file = file;
043:            }
044:
045:            /**
046:             * Get the file
047:             */
048:            public String getFile() {
049:                return file;
050:            }
051:
052:            private String version;
053:
054:            /**
055:             * Set the version
056:             */
057:            public void setVersion(String version) {
058:                this .version = version;
059:            }
060:
061:            /**
062:             * Get the version
063:             */
064:            public String getVersion() {
065:                return version;
066:            }
067:
068:            /**
069:             * @param session
070:             *            parent session
071:             * @param outputstream
072:             *            linked output stream
073:             */
074:            public ClientStream(Session session, OutputStream outputstream) {
075:                super (session, outputstream);
076:            }
077:
078:            public void head(String s) throws IOException {
079:                StringTokenizer stringtokenizer = new StringTokenizer(s);
080:                head(stringtokenizer.nextToken(), stringtokenizer.nextToken(),
081:                        stringtokenizer.nextToken());
082:            }
083:
084:            /**
085:             * Writes the http parameters to this stream
086:             * 
087:             * @param method
088:             *            the http method
089:             * @param file
090:             *            the http file
091:             * @param version
092:             *            the http version
093:             */
094:            public void head(String method, String file, String version)
095:                    throws IOException {
096:                this .method = method;
097:                this .file = file;
098:                this .version = version;
099:                super .head(method + SP + file + SP + version);
100:            }
101:
102:            protected boolean isContent() {
103:                return method.equalsIgnoreCase("post") && length == -1
104:                        || method.equalsIgnoreCase("connect") || length > 0
105:                        || isChunked;
106:            }
107:
108:            /**
109:             * Return page locale
110:             */
111:            public Locale getLocale() {
112:                String s = getFields().get("accept-language");
113:                if (s == null)
114:                    return Locale.getDefault();
115:                TreeMap<Double, Locale> map = new TreeMap<Double, Locale>();
116:                StringTokenizer st = new StringTokenizer(s, ",");
117:                while (st.hasMoreTokens()) {
118:                    String s2 = st.nextToken();
119:                    double q = 1;
120:                    int i = s2.indexOf(";q=");
121:                    if (i != -1) {
122:                        try {
123:                            q = Double.parseDouble(s2.substring(i + 3));
124:                        } catch (NumberFormatException e) {
125:                            q = 0;
126:                        }
127:                        s2 = s2.substring(0, i);
128:                    }
129:                    if (q >= 5.0000000000000002E-005 && !s2.equals("*")) {
130:                        String language = s2;
131:                        String country = "";
132:                        String variant = "";
133:                        i = s2.indexOf('-');
134:                        if (i != -1) {
135:                            language = s2.substring(0, i);
136:                            country = s2.substring(i + 1);
137:                            i = country.indexOf('-');
138:                            if (i != -1) {
139:                                variant = country.substring(i + 1);
140:                                country = country.substring(0, i);
141:                            }
142:                        }
143:                        map.put(new Double(-q), new Locale(language, country,
144:                                variant));
145:                    }
146:                }
147:                return map.get(map.firstKey());
148:            }
149:
150:            protected void set() throws IOException {
151:                Session s = ((Connection) connection).getSession();
152:                s.setClient(outputstream);
153:                connection.getClient().outputstream = s.getClient();
154:                synchronized (session) {
155:                    ((Connection) connection).add(s);
156:                    session.notifyAll();
157:                }
158:            }
159:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.