01: // ParseState.java
02: // $Id: ParseState.java,v 1.3 1998/01/22 14:29:53 bmahe 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: class ParseState {
09: int ioff = -1; // input offset
10: int ooff = -1; // output ofset (where parsing should continue)
11: int start = -1; // Start of parsed item (if needed)
12: int end = -1; // End of parsed item (if needed)
13: int bufend = -1; // End of the buffer to parse
14:
15: boolean isSkipable = true; // Always skip space when this make sense
16: boolean isQuotable = true; // Support quted string while parsing next item
17: boolean spaceIsSep = true;
18:
19: byte separator = (byte) ','; // Separator for parsing list
20:
21: final void prepare() {
22: ioff = ooff;
23: start = -1;
24: end = -1;
25: }
26:
27: final void prepare(ParseState ps) {
28: this .ioff = ps.start;
29: this .bufend = ps.end;
30: }
31:
32: final String toString(byte raw[]) {
33: return new String(raw, 0, start, end - start);
34: }
35:
36: final String toString(byte raw[], boolean lower) {
37: if (lower) {
38: // To lower case:
39: for (int i = start; i < end; i++)
40: raw[i] = (((raw[i] >= 'A') && (raw[i] <= 'Z')) ? (byte) (raw[i] - 'A' + 'a')
41: : raw[i]);
42: } else {
43: // To upper case:
44: for (int i = start; i < end; i++)
45: raw[i] = (((raw[i] >= 'a') && (raw[i] <= 'z')) ? (byte) (raw[i] - 'a' + 'A')
46: : raw[i]);
47: }
48: return new String(raw, 0, start, end - start);
49: }
50:
51: ParseState(int ioff) {
52: this .ioff = ioff;
53: }
54:
55: ParseState(int ioff, int bufend) {
56: this.ioff = ioff;
57: this.bufend = bufend;
58: }
59:
60: ParseState() {
61: }
62:
63: }
|