01: /*
02: * (c) Copyright 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
03: * [See end of file]
04: */
05:
06: package com.hp.hpl.jena.rdf.arp.states.test;
07:
08: class FullEventRecord extends EventRecord {
09: String state;
10: EventRecord moreCharacter[];
11:
12: FullEventRecord(String fields[]) {
13: this .fields = fields;
14: state = fields[0];
15: ix = 1;
16: startEvents = upto("$");
17: rsltState = fields[ix++];
18: rsltCharacter = upto("{");
19: moreCharacter = new EventRecord[count(";")];
20: for (int i = 0; i < moreCharacter.length; i++) {
21: moreCharacter[i] = new EventRecord();
22: moreCharacter[i].startEvents = upto("$");
23: moreCharacter[i].rsltState = fields[ix++];
24: moreCharacter[i].rsltCharacter = upto(";");
25: moreCharacter[i].checkStar(state);
26: }
27: checkStar(state);
28:
29: }
30:
31: public String toString() {
32: StringBuffer rslt = new StringBuffer("|" + state + "| "
33: + super .toString());
34: rslt.append("{ ");
35: for (int i = 0; i < moreCharacter.length; i++)
36: rslt.append(moreCharacter[i].toString() + " ; ");
37: rslt.append(" }");
38: return rslt.toString();
39:
40: }
41:
42: private int count(String sep) {
43: int rslt = 0;
44: for (int i = 0; i + ix < fields.length; i++)
45: if (sep.equals(fields[i + ix]))
46: rslt++;
47: return rslt;
48: }
49:
50: private String[] upto(String sep) {
51: String rslt[] = new String[dist(sep)];
52: System.arraycopy(fields, ix, rslt, 0, rslt.length);
53: ix += rslt.length + 1;
54: return rslt;
55: }
56:
57: private int dist(String sep) {
58: int rslt;
59: if (ix >= fields.length)
60: return 0;
61: for (rslt = 0; !sep.equals(fields[ix + rslt]); rslt++)
62: if (rslt + ix == fields.length - 1)
63: return 0;
64: return rslt;
65: }
66:
67: String fields[];
68: int ix;
69: }
70:
71: /*
72: * (c) Copyright 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
73: * All rights reserved.
74: *
75: * Redistribution and use in source and binary forms, with or without
76: * modification, are permitted provided that the following conditions
77: * are met:
78: * 1. Redistributions of source code must retain the above copyright
79: * notice, this list of conditions and the following disclaimer.
80: * 2. Redistributions in binary form must reproduce the above copyright
81: * notice, this list of conditions and the following disclaimer in the
82: * documentation and/or other materials provided with the distribution.
83: * 3. The name of the author may not be used to endorse or promote products
84: * derived from this software without specific prior written permission.
85: *
86: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
87: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
88: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
89: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
90: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
91: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
92: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
93: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
94: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
95: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
96: */
|