01: // DAVStatusURIList.java
02: // $Id: DAVStatusURIList.java,v 1.2 2000/09/21 15:55:40 bmahe Exp $
03: // (c) COPYRIGHT MIT, INRIA and Keio, 2000.
04: // Please first read the full copyright statement in file COPYRIGHT.html
05: package org.w3c.www.webdav;
06:
07: import java.util.Vector;
08:
09: import org.w3c.www.http.BasicValue;
10:
11: /**
12: * @version $Revision: 1.2 $
13: * @author Benoît Mahé (bmahe@w3.org)
14: */
15: public class DAVStatusURIList extends BasicValue {
16:
17: public static final boolean debug = false;
18:
19: DAVStatusURI statusURIs[] = null;
20:
21: protected void parse() {
22: Vector vstatus = new Vector();
23: if (debug) {
24: System.out.println("PARSING STATUS URI HEADER");
25: }
26: ParseState list = new ParseState(0, raw.length);
27: list.separator = (byte) ')';
28: list.spaceIsSep = false;
29: ParseState blist = new ParseState(0, 0);
30: blist.separator = (byte) '(';
31: blist.spaceIsSep = false;
32: DAVStatusURI dsu = null;
33: while (DAVParser.nextItem(raw, list) >= 0) {
34: blist.prepare(list);
35: while (DAVParser.nextItem(raw, blist) >= 0) {
36: dsu = new DAVStatusURI(raw, blist.start, blist.end);
37: addStatusURI(dsu);
38: }
39: }
40: }
41:
42: protected void updateByteValue() {
43: if (statusURIs != null) {
44: StringBuffer buf = new StringBuffer();
45: for (int i = 0; i < statusURIs.length; i++) {
46: DAVStatusURI dsu = statusURIs[i];
47: buf.append("(").append(dsu.getStatus()).append(" ");
48: buf.append("<").append(dsu.getURI()).append(">) ");
49: }
50: raw = buf.toString().getBytes();
51: roff = 0;
52: rlen = raw.length;
53: } else {
54: raw = new byte[0];
55: roff = 0;
56: rlen = 0;
57: }
58: }
59:
60: public void addStatusURI(DAVStatusURI su) {
61: if (statusURIs == null) {
62: statusURIs = new DAVStatusURI[1];
63: statusURIs[0] = su;
64: } else {
65: int len = statusURIs.length;
66: DAVStatusURI nsu[] = new DAVStatusURI[len + 1];
67: System.arraycopy(statusURIs, 0, nsu, 0, len);
68: nsu[len] = su;
69: statusURIs = nsu;
70: }
71: }
72:
73: public Object getValue() {
74: validate();
75: return statusURIs;
76: }
77:
78: /**
79: * Don't use this constructor
80: */
81: public DAVStatusURIList() {
82: this .isValid = false;
83: }
84:
85: public DAVStatusURIList(DAVStatusURI dsu[]) {
86: this .isValid = true;
87: this .statusURIs = dsu;
88: }
89:
90: public DAVStatusURIList(DAVStatusURI dsu) {
91: this .isValid = true;
92: this .statusURIs = new DAVStatusURI[1];
93: statusURIs[0] = dsu;
94: }
95:
96: }
|