01: /*
02: (c) Copyright 2006, 2007, 2008 Hewlett-Packard Development Company, LP
03: All rights reserved.
04: $Id: ReificationCache.java,v 1.3 2008/01/02 12:08:24 andy_seaborne Exp $
05: */
06:
07: package com.hp.hpl.jena.db.impl;
08:
09: import com.hp.hpl.jena.graph.Node;
10:
11: class ReificationCache {
12: protected Node stmtURI;
13: protected ReificationStatementMask mask;
14: protected int tripleCount;
15:
16: ReificationCache(Node s, ReificationStatementMask m, int cnt) {
17: stmtURI = s;
18: mask = m;
19: tripleCount = cnt;
20: }
21:
22: public ReificationStatementMask getStmtMask() {
23: return mask;
24: }
25:
26: public int getCnt() {
27: return tripleCount;
28: }
29:
30: public Node getStmtURI() {
31: return stmtURI;
32: }
33:
34: public void setMask(ReificationStatementMask m) {
35: mask = m;
36: }
37:
38: public void setCount(int count) {
39: tripleCount = count;
40: }
41:
42: public void incCount(int count) {
43: tripleCount += 1;
44: }
45:
46: public void decCount(int count) {
47: tripleCount -= 1;
48: }
49:
50: public boolean canMerge(ReificationStatementMask fragMask) {
51: return !mask.hasIntersect(fragMask);
52: }
53:
54: public boolean canUpdate(ReificationStatementMask fragMask) {
55: return (canMerge(fragMask) && (tripleCount == 1));
56: }
57:
58: public void update(ReificationStatementMask fragMask) {
59: mask.setMerge(fragMask);
60: if (isStmt())
61: mask.setIsStmt();
62: }
63:
64: private boolean isStmt() {
65: return mask.hasSPOT() && tripleCount == 1;
66: }
67: }
68:
69: /*
70: * (c) Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development
71: * Company, LP 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 are met:
75: * 1. Redistributions of source code must retain the above copyright notice,
76: * this list of conditions and the following disclaimer. 2. Redistributions in
77: * binary form must reproduce the above copyright notice, this list of
78: * conditions and the following disclaimer in the documentation and/or other
79: * materials provided with the distribution. 3. The name of the author may not
80: * be used to endorse or promote products derived from this software without
81: * specific prior written permission.
82: *
83: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
84: * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
85: * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
86: * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
87: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
88: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
89: * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
90: * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
91: * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
92: * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
93: */
|