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: import junit.framework.Assert;
09:
10: import com.hp.hpl.jena.rdf.arp.impl.ANode;
11: import com.hp.hpl.jena.rdf.arp.impl.AbsXMLContext;
12: import com.hp.hpl.jena.rdf.arp.impl.XMLHandler;
13: import com.hp.hpl.jena.rdf.arp.states.AbsXMLLiteral;
14: import com.hp.hpl.jena.rdf.arp.states.HasSubjectFrameI;
15: import com.hp.hpl.jena.rdf.arp.states.WantsObjectFrameI;
16:
17: class TestFrame extends AbsXMLLiteral implements WantsObjectFrameI,
18: HasSubjectFrameI {
19:
20: public TestFrame(XMLHandler h, AbsXMLContext x) {
21: super (h, x);
22: }
23:
24: void clear() {
25: rslt.setLength(0);
26: oCount = 0;
27: pCount = 0;
28: rCount = 0;
29: }
30:
31: int oCount;
32: int pCount;
33: int rCount;
34:
35: public void endElement() {
36: }
37:
38: public void theObject(ANode a) {
39: oCount++;
40:
41: }
42:
43: public void aPredAndObj(ANode p, ANode o) {
44: pCount++;
45: }
46:
47: public String info() {
48: return (rslt.length() == 0 ? "" : ("x" + rslt.length() + " "))
49: + (oCount == 0 ? "" : "O" + oCount + " ")
50: + (pCount == 0 ? "" : "P" + pCount + " ")
51: + (rCount == 0 ? "" : "R" + rCount + " ");
52:
53: }
54:
55: public void check(EventRecord r) {
56: r.initCounts();
57: Assert.assertEquals("object looking for s,p count", r.objects,
58: oCount);
59: Assert.assertEquals("p,o looking for s count", r.preds, pCount);
60: Assert.assertEquals("reification count", r.reify, rCount);
61: }
62:
63: public void makeSubjectReificationWith(ANode r) {
64: rCount++;
65: }
66:
67: }
68:
69: /*
70: * (c) Copyright 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
71: * All rights reserved.
72: *
73: * Redistribution and use in source and binary forms, with or without
74: * modification, are permitted provided that the following conditions
75: * are met:
76: * 1. Redistributions of source code must retain the above copyright
77: * notice, this list of conditions and the following disclaimer.
78: * 2. Redistributions in binary form must reproduce the above copyright
79: * notice, this list of conditions and the following disclaimer in the
80: * documentation and/or other materials provided with the distribution.
81: * 3. The name of the author may not be used to endorse or promote products
82: * derived from this software without specific prior written permission.
83: *
84: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
85: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
86: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
87: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
88: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
89: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
90: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
91: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
92: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
93: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
94: */
|