]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.mapping/src/org/simantics/mapping/constraint/instructions/OrInstruction.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.mapping / src / org / simantics / mapping / constraint / instructions / OrInstruction.java
index f571ccaa92cca5160bf7226acb1f45c6ff8e7bfa..4902ab494f9abebc158ee8075e98d6484f6b3674 100644 (file)
@@ -1,90 +1,90 @@
-/*******************************************************************************\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 org.simantics.db.ReadGraph;\r
-import org.simantics.db.exception.DatabaseException;\r
-\r
-public class OrInstruction extends CombinedInstruction {\r
-       \r
-       public OrInstruction(IInstruction... instructions) {\r
-               super(instructions);\r
-       }\r
-\r
-       static class Continuation {\r
-               Object continuation;\r
-               int instructionId;      \r
-               \r
-               public Continuation(Object continuation, int instructionId) {\r
-                       this.continuation = continuation;\r
-                       this.instructionId = instructionId;\r
-               }\r
-       }\r
-       \r
-       @Override\r
-       public Object query(ReadGraph g, Object[] bindings) throws DatabaseException {\r
-               int instructionId;\r
-               for(instructionId=0;instructionId<instructions.length-1;++instructionId) {\r
-                       if(DEBUG)\r
-                               System.out.println("OrInstruction.query " + instructionId + "/" + instructions.length);\r
-                       Object continuation = instructions[instructionId].query(g, bindings);\r
-                       if(continuation != IInstruction.FAILURE)\r
-                               return new Continuation(continuation, instructionId);\r
-               }\r
-               return instructions[instructionId].query(g, bindings);\r
-       }\r
-       \r
-       @Override\r
-       public Object next(ReadGraph g, Object[] bindings, Object ret_) throws DatabaseException {\r
-               Continuation ret = (Continuation)ret_;\r
-               int instructionId = ret.instructionId;\r
-               Object continuation = ret.continuation;\r
-               \r
-               if(continuation != null) {\r
-                       continuation = instructions[instructionId].next(g, bindings, continuation);\r
-                       if(continuation != IInstruction.FAILURE) {\r
-                               ret.continuation = continuation;\r
-                               return ret;\r
-                       }\r
-               }\r
-               \r
-               for(++instructionId;instructionId<instructions.length-1;++instructionId) {\r
-                       continuation = instructions[instructionId].query(g, bindings);\r
-                       if(continuation != IInstruction.FAILURE) {\r
-                               ret.continuation = continuation;\r
-                               ret.instructionId = instructionId;                              \r
-                               return ret;\r
-                       }\r
-               }\r
-               return instructions[instructionId].query(g, bindings);\r
-       }\r
-\r
-       @Override\r
-       public void toString(StringBuilder b, int indent) {             \r
-               b.append("(    ");\r
-               boolean first = true;\r
-               for(IInstruction inst : instructions) {\r
-                       if(first)\r
-                               first = false;\r
-                       else {\r
-                               b.append(";\n");\r
-                               for(int i=0;i<indent+1;++i)\r
-                                       b.append(INDENTATION);\r
-                       }\r
-                       inst.toString(b, indent + 1);                   \r
-               }\r
-               b.append('\n');\r
-               for(int i=0;i<indent;++i)\r
-                       b.append(INDENTATION);\r
-               b.append(")");          \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 org.simantics.db.ReadGraph;
+import org.simantics.db.exception.DatabaseException;
+
+public class OrInstruction extends CombinedInstruction {
+       
+       public OrInstruction(IInstruction... instructions) {
+               super(instructions);
+       }
+
+       static class Continuation {
+               Object continuation;
+               int instructionId;      
+               
+               public Continuation(Object continuation, int instructionId) {
+                       this.continuation = continuation;
+                       this.instructionId = instructionId;
+               }
+       }
+       
+       @Override
+       public Object query(ReadGraph g, Object[] bindings) throws DatabaseException {
+               int instructionId;
+               for(instructionId=0;instructionId<instructions.length-1;++instructionId) {
+                       if(DEBUG)
+                               System.out.println("OrInstruction.query " + instructionId + "/" + instructions.length);
+                       Object continuation = instructions[instructionId].query(g, bindings);
+                       if(continuation != IInstruction.FAILURE)
+                               return new Continuation(continuation, instructionId);
+               }
+               return instructions[instructionId].query(g, bindings);
+       }
+       
+       @Override
+       public Object next(ReadGraph g, Object[] bindings, Object ret_) throws DatabaseException {
+               Continuation ret = (Continuation)ret_;
+               int instructionId = ret.instructionId;
+               Object continuation = ret.continuation;
+               
+               if(continuation != null) {
+                       continuation = instructions[instructionId].next(g, bindings, continuation);
+                       if(continuation != IInstruction.FAILURE) {
+                               ret.continuation = continuation;
+                               return ret;
+                       }
+               }
+               
+               for(++instructionId;instructionId<instructions.length-1;++instructionId) {
+                       continuation = instructions[instructionId].query(g, bindings);
+                       if(continuation != IInstruction.FAILURE) {
+                               ret.continuation = continuation;
+                               ret.instructionId = instructionId;                              
+                               return ret;
+                       }
+               }
+               return instructions[instructionId].query(g, bindings);
+       }
+
+       @Override
+       public void toString(StringBuilder b, int indent) {             
+               b.append("(    ");
+               boolean first = true;
+               for(IInstruction inst : instructions) {
+                       if(first)
+                               first = false;
+                       else {
+                               b.append(";\n");
+                               for(int i=0;i<indent+1;++i)
+                                       b.append(INDENTATION);
+                       }
+                       inst.toString(b, indent + 1);                   
+               }
+               b.append('\n');
+               for(int i=0;i<indent;++i)
+                       b.append(INDENTATION);
+               b.append(")");          
+       }
+}