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


001:        // HttpContentRange.java
002:        // $Id: HttpContentRange.java,v 1.9 2003/02/11 10:55:18 ylafon Exp $
003:        // (c) COPYRIGHT MIT and INRIA, 1996.
004:        // Please first read the full copyright statement in file COPYRIGHT.html
005:
006:        package org.w3c.www.http;
007:
008:        public class HttpContentRange extends BasicValue {
009:            int firstpos = -1;
010:            int lastpos = -1;
011:            int length = -1;
012:            String unit = null;
013:
014:            /**
015:             * parse.
016:             * @exception HttpParserException if parsing failed.
017:             */
018:            protected void parse() throws HttpParserException {
019:                ParseState ps = new ParseState();
020:                ps.ioff = 0;
021:                ps.bufend = raw.length;
022:                // Get the byte unit:
023:                ps.separator = (byte) ' ';
024:                if (HttpParser.nextItem(raw, ps) < 0)
025:                    error("Invalid byte range (no byte unit).");
026:                this .unit = new String(raw, 0, ps.start, ps.end - ps.start);
027:                // Get the first position
028:                ps.separator = (byte) '-';
029:                ps.prepare();
030:                if (HttpParser.nextItem(raw, ps) < 0)
031:                    error("Invalid byte range (no first position).");
032:                ParseState pos = new ParseState();
033:                pos.ioff = ps.start;
034:                pos.bufend = ps.end;
035:                firstpos = HttpParser.parseInt(raw, pos);
036:                // Get the last positon
037:                ps.prepare();
038:                ps.separator = (byte) '/';
039:                if (HttpParser.nextItem(raw, ps) < 0)
040:                    error("Invalid byte range (no last position).");
041:                pos.ioff = ps.start;
042:                pos.bufend = ps.end;
043:                lastpos = HttpParser.parseInt(raw, pos);
044:                // Get the full length:
045:                ps.prepare();
046:                if (HttpParser.nextItem(raw, ps) < 0)
047:                    error("Invalid byte range (no full length).");
048:                pos.ioff = ps.start;
049:                pos.bufend = ps.end;
050:                if ((raw[pos.ioff] == (byte) '*') && (ps.end - ps.start == 1)) {
051:                    length = -1;
052:                } else {
053:                    length = HttpParser.parseInt(raw, pos);
054:                }
055:            }
056:
057:            protected void updateByteValue() {
058:                HttpBuffer buf = new HttpBuffer();
059:                buf.append(unit);
060:                buf.append((byte) ' ');
061:                buf.appendInt(firstpos);
062:                buf.append('-');
063:                buf.appendInt(lastpos);
064:                buf.append('/');
065:                if (length < 0) {
066:                    buf.append('*');
067:                } else {
068:                    buf.appendInt(length);
069:                }
070:                raw = buf.getByteCopy();
071:                roff = 0;
072:                rlen = raw.length;
073:            }
074:
075:            public Object getValue() {
076:                return this ;
077:            }
078:
079:            /**
080:             * Get this range first position.
081:             * The meaning of the returne integer is to be understood relative to
082:             * the unit, as obtained by <code>getUnit</code> method.
083:             * @return An integer value for thr first position.
084:             */
085:
086:            public int getFirstPosition() {
087:                validate();
088:                return firstpos;
089:            }
090:
091:            /**
092:             * Set this range first position.
093:             * @param firstpos The firt position of the range.
094:             */
095:
096:            public void setFirstPosition(int firstpos) {
097:                if (firstpos != this .firstpos)
098:                    invalidateByteValue();
099:                this .firstpos = firstpos;
100:            }
101:
102:            /**
103:             * Get this range last position.
104:             * The meaning of the returne integer is to be understood relative to
105:             * the unit, as obtained by <code>getUnit</code> method.
106:             * @return An integer value giving the last position.
107:             */
108:
109:            public int getLastPosition() {
110:                validate();
111:                return lastpos;
112:            }
113:
114:            /**
115:             * Set this range last position.
116:             * @param The last position, as an integer.
117:             */
118:
119:            public void setLastPosition(int lastpos) {
120:                if (lastpos != this .lastpos)
121:                    invalidateByteValue();
122:                this .lastpos = lastpos;
123:            }
124:
125:            /**
126:             * Get this range entity full length.
127:             * @return The full length of the entity.
128:             */
129:
130:            public int getFullLength() {
131:                validate();
132:                return length;
133:            }
134:
135:            /**
136:             * Set this range entity full length.
137:             * @param length The new full length for the entity, -1 if unknown.
138:             */
139:
140:            public void setFullLength(int length) {
141:                if (length != this .length)
142:                    invalidateByteValue();
143:                this .length = length;
144:            }
145:
146:            /**
147:             * Get this content range's unit.
148:             * @return A String giving the unit for the range, or <strong>null</strong>
149:             * if undefined.
150:             */
151:
152:            public String getUnit() {
153:                validate();
154:                return unit;
155:            }
156:
157:            /**
158:             * Set this content range's unit.
159:             * @param unit The unit in which this range was measured.
160:             */
161:
162:            public void setUnit(String unit) {
163:                invalidateByteValue();
164:                this .unit = unit;
165:            }
166:
167:            HttpContentRange() {
168:                this .isValid = false;
169:            }
170:
171:            public HttpContentRange(boolean isValid, String unit, int firstpos,
172:                    int lastpos, int length) {
173:                this .isValid = true;
174:                setUnit(unit);
175:                setFirstPosition(firstpos);
176:                setLastPosition(lastpos);
177:                setFullLength(length);
178:            }
179:
180:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.