]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.mapping/src/org/simantics/mapping/constraint/instructions/AndInstruction.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.mapping / src / org / simantics / mapping / constraint / instructions / AndInstruction.java
index fffb139b7455c8a9a5e629588490358a21a9a773..5694c2db640a43ea90ca5f93f909f0bfc4ccd85f 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 org.simantics.db.ReadGraph;\r
-import org.simantics.db.exception.DatabaseException;\r
-\r
-public class AndInstruction extends CombinedInstruction {\r
-       \r
-       public AndInstruction(IInstruction... instructions) {\r
-               super(instructions);\r
-       }\r
-\r
-       static class Continuation {\r
-               Object continuation;\r
-               int instructionId;      \r
-               Continuation next;              \r
-               \r
-               public Continuation(Object continuation, int instructionId,\r
-                               Continuation next) {\r
-                       this.continuation = continuation;\r
-                       this.instructionId = instructionId;\r
-                       this.next = next;\r
-               }\r
-\r
-       }\r
-       \r
-       @Override\r
-       public Object query(ReadGraph g, Object[] bindings) throws DatabaseException {\r
-               Continuation ret = null;\r
-               int instructionId = 0;\r
-               while(instructionId < instructions.length) {\r
-                       if(DEBUG)\r
-                               System.out.println("AndInstruction.query " + instructionId + "/" + instructions.length);\r
-                       Object continuation = instructions[instructionId].query(g, bindings);\r
-                       if(continuation == IInstruction.FAILURE) {\r
-                               while(true) {\r
-                                       if(ret == null)\r
-                                               return IInstruction.FAILURE;\r
-                                       instructionId = ret.instructionId;\r
-                                       continuation = instructions[instructionId].next(g, bindings, ret.continuation);\r
-                                       if(continuation == IInstruction.FAILURE) {\r
-                                               ret = ret.next;                                         \r
-                                               continue;\r
-                                       }\r
-                                       if(continuation == null) \r
-                                               ret = ret.next;\r
-                                       else\r
-                                               ret.continuation = continuation;\r
-                                       break;\r
-                               }                                                                       \r
-                       }\r
-                       else if(continuation != null)\r
-                               ret = new Continuation(continuation, instructionId, ret);\r
-                       ++instructionId;\r
-               }\r
-               return ret;\r
-       }\r
-       \r
-       @Override\r
-       public Object next(ReadGraph g, Object[] bindings, Object ret_) throws DatabaseException {\r
-               Continuation ret = (Continuation)ret_;\r
-               int instructionId;\r
-               while(true) {\r
-                       if(ret == null)\r
-                               return IInstruction.FAILURE;\r
-                       instructionId = ret.instructionId;\r
-                       Object continuation = \r
-                               instructions[instructionId].next(g, bindings, ret.continuation);\r
-                       if(continuation == IInstruction.FAILURE) {\r
-                               ret = ret.next;                                         \r
-                               continue;\r
-                       }\r
-                       if(continuation == null) \r
-                               ret = ret.next;\r
-                       else\r
-                               ret.continuation = continuation;\r
-                       break;\r
-               }\r
-               ++instructionId;\r
-               while(instructionId < instructions.length) {\r
-                       Object continuation = instructions[instructionId].query(g, bindings);\r
-                       if(continuation == IInstruction.FAILURE) {\r
-                               while(true) {\r
-                                       if(ret == null)\r
-                                               return IInstruction.FAILURE;\r
-                                       instructionId = ret.instructionId;\r
-                                       continuation = instructions[instructionId].next(g, bindings, ret.continuation);\r
-                                       if(continuation == IInstruction.FAILURE) {\r
-                                               ret = ret.next;                                         \r
-                                               continue;\r
-                                       }\r
-                                       if(continuation == null) \r
-                                               ret = ret.next;\r
-                                       else\r
-                                               ret.continuation = continuation;\r
-                                       break;\r
-                               }                                                                       \r
-                       }\r
-                       else if(continuation != null)\r
-                               ret = new Continuation(continuation, instructionId, ret);\r
-                       ++instructionId;\r
-               }\r
-               return ret;\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 AndInstruction extends CombinedInstruction {
+       
+       public AndInstruction(IInstruction... instructions) {
+               super(instructions);
+       }
+
+       static class Continuation {
+               Object continuation;
+               int instructionId;      
+               Continuation next;              
+               
+               public Continuation(Object continuation, int instructionId,
+                               Continuation next) {
+                       this.continuation = continuation;
+                       this.instructionId = instructionId;
+                       this.next = next;
+               }
+
+       }
+       
+       @Override
+       public Object query(ReadGraph g, Object[] bindings) throws DatabaseException {
+               Continuation ret = null;
+               int instructionId = 0;
+               while(instructionId < instructions.length) {
+                       if(DEBUG)
+                               System.out.println("AndInstruction.query " + instructionId + "/" + instructions.length);
+                       Object continuation = instructions[instructionId].query(g, bindings);
+                       if(continuation == IInstruction.FAILURE) {
+                               while(true) {
+                                       if(ret == null)
+                                               return IInstruction.FAILURE;
+                                       instructionId = ret.instructionId;
+                                       continuation = instructions[instructionId].next(g, bindings, ret.continuation);
+                                       if(continuation == IInstruction.FAILURE) {
+                                               ret = ret.next;                                         
+                                               continue;
+                                       }
+                                       if(continuation == null) 
+                                               ret = ret.next;
+                                       else
+                                               ret.continuation = continuation;
+                                       break;
+                               }                                                                       
+                       }
+                       else if(continuation != null)
+                               ret = new Continuation(continuation, instructionId, ret);
+                       ++instructionId;
+               }
+               return ret;
+       }
+       
+       @Override
+       public Object next(ReadGraph g, Object[] bindings, Object ret_) throws DatabaseException {
+               Continuation ret = (Continuation)ret_;
+               int instructionId;
+               while(true) {
+                       if(ret == null)
+                               return IInstruction.FAILURE;
+                       instructionId = ret.instructionId;
+                       Object continuation = 
+                               instructions[instructionId].next(g, bindings, ret.continuation);
+                       if(continuation == IInstruction.FAILURE) {
+                               ret = ret.next;                                         
+                               continue;
+                       }
+                       if(continuation == null) 
+                               ret = ret.next;
+                       else
+                               ret.continuation = continuation;
+                       break;
+               }
+               ++instructionId;
+               while(instructionId < instructions.length) {
+                       Object continuation = instructions[instructionId].query(g, bindings);
+                       if(continuation == IInstruction.FAILURE) {
+                               while(true) {
+                                       if(ret == null)
+                                               return IInstruction.FAILURE;
+                                       instructionId = ret.instructionId;
+                                       continuation = instructions[instructionId].next(g, bindings, ret.continuation);
+                                       if(continuation == IInstruction.FAILURE) {
+                                               ret = ret.next;                                         
+                                               continue;
+                                       }
+                                       if(continuation == null) 
+                                               ret = ret.next;
+                                       else
+                                               ret.continuation = continuation;
+                                       break;
+                               }                                                                       
+                       }
+                       else if(continuation != null)
+                               ret = new Continuation(continuation, instructionId, ret);
+                       ++instructionId;
+               }
+               return ret;
+       }
+
+       @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(")");          
+       }
+       
 }
\ No newline at end of file