-package org.simantics.db.impl.graph;\r
-\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.exception.NoSingleResultException;\r
-import org.simantics.db.impl.query.IntProcedure;\r
-import org.simantics.db.impl.query.QueryProcessor;\r
-\r
-public class PossibleObjectProcedure implements IntProcedure {\r
-\r
- private static DatabaseException DUMMY = new DatabaseException();\r
- \r
- final private QueryProcessor processor;\r
- private DatabaseException exception;\r
- private Resource result;\r
- \r
- public PossibleObjectProcedure(QueryProcessor processor) {\r
- this.processor = processor;\r
- }\r
- \r
- @Override\r
- public void execute(ReadGraphImpl graph, int i) {\r
- Resource resource = processor.querySupport.getResource(i);\r
- if(result != null) {\r
- exception = DUMMY;\r
- } else {\r
- result = resource;\r
- }\r
- }\r
-\r
- @Override\r
- public void finished(ReadGraphImpl graph) {\r
- }\r
-\r
- @Override\r
- public void exception(ReadGraphImpl graph, Throwable throwable) {\r
- if(throwable instanceof DatabaseException) exception = (DatabaseException)throwable;\r
- else throwable = new DatabaseException(throwable);\r
- }\r
- \r
- public Resource get() throws DatabaseException {\r
- if(exception == DUMMY) return null;\r
- else if(exception != null) throw exception;\r
- else return result;\r
- }\r
-\r
-}\r
+package org.simantics.db.impl.graph;
+
+import org.simantics.db.Resource;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.impl.query.IntProcedure;
+import org.simantics.db.impl.query.QueryProcessor;
+
+public class PossibleObjectProcedure implements IntProcedure {
+
+ private static DatabaseException DUMMY = new DatabaseException();
+
+ final private QueryProcessor processor;
+ private DatabaseException exception;
+ private Resource result;
+
+ public PossibleObjectProcedure(QueryProcessor processor) {
+ this.processor = processor;
+ }
+
+ @Override
+ public void execute(ReadGraphImpl graph, int i) {
+ Resource resource = processor.querySupport.getResource(i);
+ if(result != null) {
+ exception = DUMMY;
+ } else {
+ result = resource;
+ }
+ }
+
+ @Override
+ public void finished(ReadGraphImpl graph) {
+ }
+
+ @Override
+ public void exception(ReadGraphImpl graph, Throwable throwable) {
+ if(throwable instanceof DatabaseException) exception = (DatabaseException)throwable;
+ else throwable = new DatabaseException(throwable);
+ }
+
+ public Resource get() throws DatabaseException {
+ if(exception == DUMMY) return null;
+ else if(exception != null) throw exception;
+ else return result;
+ }
+
+}