01: // HttpInteger.java
02: // $Id: HttpInteger.java,v 1.11 2003/02/24 10:54:49 ylafon Exp $$
03: // (c) COPYRIGHT MIT and INRIA, 1996.
04: // Please first read the full copyright statement in file COPYRIGHT.html
05:
06: package org.w3c.www.http;
07:
08: public class HttpInteger extends BasicValue {
09: Integer value = null;
10:
11: protected void parse() {
12: ParseState ps = new ParseState();
13: ps.ioff = 0;
14: ps.bufend = raw.length;
15: value = new Integer(HttpParser.parseInt(raw, ps));
16: }
17:
18: protected void updateByteValue() {
19: HttpBuffer buf = new HttpBuffer(11);
20: // kludge for difference between rfc2616 maxint and java maxint
21: if (value.intValue() == Integer.MAX_VALUE) {
22: buf.append("2147483648");
23: }
24: buf.appendInt(value.intValue());
25: raw = buf.getByteCopy();
26: roff = 0;
27: rlen = raw.length;
28: }
29:
30: public Object getValue() {
31: validate();
32: return value;
33: }
34:
35: public void setValue(int ival) {
36: if (value.intValue() == ival)
37: return;
38: invalidateByteValue();
39: value = new Integer(ival);
40: isValid = true;
41: }
42:
43: public void setValue(Integer ival) {
44: if (ival.intValue() == value.intValue())
45: return;
46: invalidateByteValue();
47: value = ival;
48: isValid = true;
49: }
50:
51: HttpInteger(boolean isValid, int ival) {
52: this .isValid = isValid;
53: this .value = new Integer(ival);
54: }
55:
56: public HttpInteger() {
57: this .isValid = false;
58: }
59: }
|