01: // HttpWarningList.java
02: // $Id: HttpWarningList.java,v 1.7 2000/08/16 21:38:01 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: import java.util.Vector;
09:
10: public class HttpWarningList extends BasicValue {
11: HttpWarning warnings[] = null;
12:
13: protected void parse() {
14: Vector ws = new Vector(4);
15: ParseState ps = new ParseState(roff, rlen);
16: ps.spaceIsSep = false;
17: while (HttpParser.nextItem(raw, ps) >= 0) {
18: ws.addElement(new HttpWarning(this , raw, ps.start, ps.end));
19: ps.prepare();
20: }
21: warnings = new HttpWarning[ws.size()];
22: ws.copyInto(warnings);
23: }
24:
25: protected void updateByteValue() {
26: HttpBuffer buf = new HttpBuffer();
27: for (int i = 0; i < warnings.length; i++) {
28: if (i > 0)
29: buf.append(',');
30: warnings[i].appendValue(buf);
31: }
32: raw = buf.getByteCopy();
33: roff = 0;
34: rlen = raw.length;
35: }
36:
37: public Object getValue() {
38: validate();
39: return warnings;
40: }
41:
42: /**
43: * Add a warning to that list.
44: * @param w The warning to add.
45: */
46:
47: public void addWarning(HttpWarning w) {
48: if (warnings == null) {
49: warnings = new HttpWarning[1];
50: warnings[0] = w;
51: } else {
52: int len = warnings.length;
53: HttpWarning newwarn[] = new HttpWarning[len + 1];
54: System.arraycopy(warnings, 0, newwarn, 0, len);
55: newwarn[len] = w;
56: warnings = newwarn;
57: }
58: }
59:
60: HttpWarningList() {
61: this .isValid = false;
62: }
63:
64: HttpWarningList(HttpWarning warnings[]) {
65: this .isValid = true;
66: this .warnings = warnings;
67: }
68:
69: HttpWarningList(HttpWarning warning) {
70: this .isValid = true;
71: this .warnings = new HttpWarning[1];
72: this .warnings[0] = warning;
73: }
74: }
|