]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.mapping/src/org/simantics/mapping/constraint/instructions/CombinedInstruction.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.mapping / src / org / simantics / mapping / constraint / instructions / CombinedInstruction.java
index 95134af09244d21d3c73d5af19276bfde97cac91..f14ae3aa3c3a2d1be07cb5cd29966c2b2f0c7a58 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
- * in Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *     VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.mapping.constraint.instructions;\r
-\r
-import gnu.trove.map.hash.TIntIntHashMap;\r
-import gnu.trove.set.hash.TIntHashSet;\r
-\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.WriteGraph;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.mapping.IContextualModification;\r
-\r
-public abstract class CombinedInstruction implements IInstruction {\r
-       IInstruction[] instructions;\r
-       \r
-       public CombinedInstruction(IInstruction... instructions) {\r
-               this.instructions = instructions;\r
-       }       \r
-       \r
-       class CompositeClaim implements IContextualModification {\r
-\r
-               IContextualModification modification;\r
-               int instructionId;\r
-               \r
-               public CompositeClaim(IContextualModification modification, int instructionId) {\r
-                       this.modification = modification;\r
-                       this.instructionId = instructionId;\r
-               }\r
-\r
-               @Override\r
-               public void perform(WriteGraph g, Object[] bindings) throws DatabaseException {\r
-                       modification.perform(g, bindings);\r
-                       for(int i=instructionId+1;i<instructions.length;++i)\r
-                               instructions[i].doClaim(g, bindings);\r
-               }\r
-               \r
-       }\r
-       \r
-       @Override\r
-       public IContextualModification claim(ReadGraph g, Object[] bindings) throws DatabaseException {\r
-               for(int instructionId=0;instructionId<instructions.length;++instructionId) {\r
-                       IContextualModification modification = instructions[instructionId].claim(g, bindings);\r
-                       if(modification != null) {\r
-                               if(instructionId==instructions.length-1)\r
-                                       return modification;\r
-                               else \r
-                                       return new CompositeClaim(modification, instructionId);\r
-                       }\r
-               }\r
-               return null;\r
-       }\r
-\r
-       class CompositeDeny implements IContextualModification {\r
-\r
-               IContextualModification modification;\r
-               int instructionId;\r
-               \r
-               public CompositeDeny(IContextualModification modification, int instructionId) {\r
-                       this.modification = modification;\r
-                       this.instructionId = instructionId;\r
-               }\r
-\r
-               @Override\r
-               public void perform(WriteGraph g, Object[] bindings) throws DatabaseException {\r
-                       modification.perform(g, bindings);\r
-                       for(int i=instructionId+1;i<instructions.length;++i)\r
-                               instructions[i].doDeny(g, bindings);\r
-               }\r
-               \r
-       }\r
-\r
-       @Override\r
-       public IContextualModification deny(ReadGraph g, Object[] bindings) throws DatabaseException {\r
-               for(int instructionId=0;instructionId<instructions.length;++instructionId) {\r
-                       IContextualModification modification = instructions[instructionId].deny(g, bindings);\r
-                       if(modification != null) {\r
-                               if(instructionId==instructions.length-1)\r
-                                       return modification;\r
-                               else \r
-                                       return new CompositeDeny(modification, instructionId);\r
-                       }\r
-               }\r
-               return null;\r
-       }\r
-\r
-       @Override\r
-       public void doClaim(WriteGraph g, Object[] bindings) throws DatabaseException {\r
-               for(int i=0;i<instructions.length;++i)\r
-                       instructions[i].doClaim(g, bindings);           \r
-       }\r
-\r
-       @Override\r
-       public void doDeny(WriteGraph g, Object[] bindings) throws DatabaseException {\r
-               for(int i=0;i<instructions.length;++i)\r
-                       instructions[i].doDeny(g, bindings);                                    \r
-       }\r
-\r
-       @Override\r
-       public void collectVariables(TIntHashSet reads, TIntHashSet writes) {\r
-               for(IInstruction inst : instructions)\r
-                       inst.collectVariables(reads, writes);\r
-       }       \r
-       \r
-       @Override\r
-       public void mapVariables(TIntIntHashMap map) {\r
-               for(IInstruction inst : instructions)\r
-                       inst.mapVariables(map);\r
-       }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.mapping.constraint.instructions;
+
+import gnu.trove.map.hash.TIntIntHashMap;
+import gnu.trove.set.hash.TIntHashSet;
+
+import org.simantics.db.ReadGraph;
+import org.simantics.db.WriteGraph;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.mapping.IContextualModification;
+
+public abstract class CombinedInstruction implements IInstruction {
+       IInstruction[] instructions;
+       
+       public CombinedInstruction(IInstruction... instructions) {
+               this.instructions = instructions;
+       }       
+       
+       class CompositeClaim implements IContextualModification {
+
+               IContextualModification modification;
+               int instructionId;
+               
+               public CompositeClaim(IContextualModification modification, int instructionId) {
+                       this.modification = modification;
+                       this.instructionId = instructionId;
+               }
+
+               @Override
+               public void perform(WriteGraph g, Object[] bindings) throws DatabaseException {
+                       modification.perform(g, bindings);
+                       for(int i=instructionId+1;i<instructions.length;++i)
+                               instructions[i].doClaim(g, bindings);
+               }
+               
+       }
+       
+       @Override
+       public IContextualModification claim(ReadGraph g, Object[] bindings) throws DatabaseException {
+               for(int instructionId=0;instructionId<instructions.length;++instructionId) {
+                       IContextualModification modification = instructions[instructionId].claim(g, bindings);
+                       if(modification != null) {
+                               if(instructionId==instructions.length-1)
+                                       return modification;
+                               else 
+                                       return new CompositeClaim(modification, instructionId);
+                       }
+               }
+               return null;
+       }
+
+       class CompositeDeny implements IContextualModification {
+
+               IContextualModification modification;
+               int instructionId;
+               
+               public CompositeDeny(IContextualModification modification, int instructionId) {
+                       this.modification = modification;
+                       this.instructionId = instructionId;
+               }
+
+               @Override
+               public void perform(WriteGraph g, Object[] bindings) throws DatabaseException {
+                       modification.perform(g, bindings);
+                       for(int i=instructionId+1;i<instructions.length;++i)
+                               instructions[i].doDeny(g, bindings);
+               }
+               
+       }
+
+       @Override
+       public IContextualModification deny(ReadGraph g, Object[] bindings) throws DatabaseException {
+               for(int instructionId=0;instructionId<instructions.length;++instructionId) {
+                       IContextualModification modification = instructions[instructionId].deny(g, bindings);
+                       if(modification != null) {
+                               if(instructionId==instructions.length-1)
+                                       return modification;
+                               else 
+                                       return new CompositeDeny(modification, instructionId);
+                       }
+               }
+               return null;
+       }
+
+       @Override
+       public void doClaim(WriteGraph g, Object[] bindings) throws DatabaseException {
+               for(int i=0;i<instructions.length;++i)
+                       instructions[i].doClaim(g, bindings);           
+       }
+
+       @Override
+       public void doDeny(WriteGraph g, Object[] bindings) throws DatabaseException {
+               for(int i=0;i<instructions.length;++i)
+                       instructions[i].doDeny(g, bindings);                                    
+       }
+
+       @Override
+       public void collectVariables(TIntHashSet reads, TIntHashSet writes) {
+               for(IInstruction inst : instructions)
+                       inst.collectVariables(reads, writes);
+       }       
+       
+       @Override
+       public void mapVariables(TIntIntHashMap map) {
+               for(IInstruction inst : instructions)
+                       inst.mapVariables(map);
+       }
+
+}