X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.db.impl%2Fsrc%2Forg%2Fsimantics%2Fdb%2Fimpl%2Fgraph%2FPossibleObjectProcedure.java;h=f3e01a76f2bc93c33dd46121fb36b7a3abb04f8e;hb=3bcd1023180e2cdc55bc001d0f60075dd7184cfa;hp=5a2e138feec9109871e3759dd14fde5341a38032;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/graph/PossibleObjectProcedure.java b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/graph/PossibleObjectProcedure.java index 5a2e138fe..f3e01a76f 100644 --- a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/graph/PossibleObjectProcedure.java +++ b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/graph/PossibleObjectProcedure.java @@ -1,47 +1,46 @@ -package org.simantics.db.impl.graph; - -import org.simantics.db.Resource; -import org.simantics.db.exception.DatabaseException; -import org.simantics.db.exception.NoSingleResultException; -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; - } - -} +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; + } + +}