1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.mapping.constraint.instructions;
14 import gnu.trove.map.hash.TIntIntHashMap;
15 import gnu.trove.set.hash.TIntHashSet;
17 import org.simantics.db.ReadGraph;
18 import org.simantics.db.WriteGraph;
19 import org.simantics.db.exception.DatabaseException;
20 import org.simantics.mapping.IContextualModification;
22 public class NotInstruction implements IInstruction {
23 IInstruction instruction;
25 public NotInstruction(IInstruction instruction) {
26 this.instruction = instruction;
30 public IContextualModification claim(ReadGraph g, Object[] bindings) throws DatabaseException {
31 return instruction.deny(g, bindings);
35 public void collectVariables(TIntHashSet reads, TIntHashSet writes) {
36 instruction.collectVariables(reads, writes);
40 public IContextualModification deny(ReadGraph g, Object[] bindings) throws DatabaseException {
41 return instruction.claim(g, bindings);
45 public void doClaim(WriteGraph g, Object[] bindings) throws DatabaseException {
46 instruction.doDeny(g, bindings);
50 public void doDeny(WriteGraph g, Object[] bindings) throws DatabaseException {
51 instruction.doClaim(g, bindings);
55 public void mapVariables(TIntIntHashMap map) {
56 instruction.mapVariables(map);
60 public Object next(ReadGraph g, Object[] bindings, Object continuation) {
61 return IInstruction.FAILURE;
65 public Object query(ReadGraph g, Object[] bindings) throws DatabaseException {
66 if(instruction.query(g, bindings)==IInstruction.FAILURE)
69 return IInstruction.FAILURE;
73 public void toString(StringBuilder b, int indent) {
75 instruction.toString(b, indent);