-/*******************************************************************************\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 fi.vtt.simantics.procore.internal;\r
-\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.Statement;\r
-import org.simantics.db.impl.ResourceImpl;\r
-import org.simantics.db.procore.protocol.Constants;\r
-\r
-\r
-public abstract class StatementImpl implements Statement {\r
- public final static StatementImpl[] NONE = new StatementImpl[0];\r
- public final ResourceImpl subject;\r
- public final ResourceImpl predicate;\r
- protected ResourceImpl object;\r
- public StatementImpl(ResourceImpl subject, ResourceImpl predicate) {\r
- if (null == subject)\r
- throw new IllegalArgumentException();\r
- if(null == predicate)\r
- throw new IllegalArgumentException();\r
- this.subject = (ResourceImpl)subject;\r
- this.predicate = (ResourceImpl)predicate;\r
- }\r
- \r
- public ResourceImpl getObjectImpl() {\r
- return object;\r
- }\r
- @Override\r
- public Resource getObject() {\r
- return object;\r
- }\r
-\r
- @Override\r
- final public Resource getPredicate() {\r
- return predicate;\r
- }\r
-\r
- @Override\r
- final public Resource getSubject() {\r
- return subject;\r
- }\r
-\r
- @Override\r
- public boolean isAsserted(Resource testSubject) {\r
- return !subject.equals(testSubject);\r
- }\r
- \r
- public abstract boolean equals(long s, long p, long o);\r
- \r
- }\r
-\r
-final class StatementImplOld extends StatementImpl {\r
- \r
- public StatementImplOld(ResourceImpl subject, ResourceImpl predicate, ResourceImpl object) {\r
- super(subject, predicate);\r
- this.object = (ResourceImpl)object;\r
- }\r
- @Override\r
- public int hashCode() {\r
- return subject.hashCode() + (int)object.id; \r
- }\r
-\r
- @Override\r
- public boolean equals(long s, long p, long o) {\r
- return (subject.id == s) && (predicate.id == p) && (object.id == o);\r
- }\r
-\r
- @Override\r
- public boolean equals(Object obj) {\r
- if (this == obj)\r
- return true;\r
- else if (!(obj instanceof StatementImpl))\r
- return false;\r
- StatementImpl r = (StatementImpl)obj;\r
- return r.equals(subject.id, predicate.id, object.id);\r
- }\r
-}\r
-\r
-final class StatementImplNew extends StatementImpl {\r
- public final long objectResourceId;\r
- public final long objectClusterId;\r
- public final GraphSession graphSession;\r
- public StatementImplNew(ResourceImpl subject, ResourceImpl predicate, long id, long cluster, GraphSession graphSession) {\r
- super(subject, predicate);\r
- this.object = null;\r
- this.objectResourceId = id;\r
- if (Constants.ReservedClusterId == cluster)\r
- throw new IllegalArgumentException("Argh!");\r
- this.objectClusterId = cluster;\r
- this.graphSession = graphSession;\r
- }\r
-\r
- @Override\r
- final public Resource getObject() {\r
-// if (null == object)\r
-// try {\r
-// object = graphSession.getResourceOrThrow(objectResourceId, objectClusterId);\r
-// } catch (ResourceNotFoundException e) {\r
-// e.printStackTrace();\r
-// return null;\r
-// }\r
-// return object;\r
- throw new Error("No can do.");\r
- }\r
-\r
- @Override\r
- public ResourceImpl getObjectImpl() {\r
-// if (null == object)\r
-// try {\r
-// object = graphSession.getResourceOrThrow(objectResourceId, objectClusterId);\r
-// } catch (ResourceNotFoundException e) {\r
-// e.printStackTrace();\r
-// return null;\r
-// }\r
-// return object;\r
- throw new Error("No can do.");\r
- }\r
-\r
- @Override\r
- public int hashCode() {\r
- return subject.hashCode() + (int)objectResourceId; \r
- }\r
-\r
- @Override\r
- public boolean equals(long s, long p, long o) {\r
- return (subject.id == s) && (predicate.id == p) && (objectResourceId == o);\r
- }\r
-\r
- @Override\r
- public boolean equals(Object obj) {\r
- if (this == obj)\r
- return true;\r
- else if (obj == null)\r
- return false;\r
- else if (StatementImpl.class != obj.getClass())\r
- return false;\r
- StatementImpl r = (StatementImpl)obj;\r
- return r.equals(subject.id, predicate.id, objectResourceId);\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 fi.vtt.simantics.procore.internal;
+
+import org.simantics.db.Resource;
+import org.simantics.db.Statement;
+import org.simantics.db.impl.ResourceImpl;
+import org.simantics.db.procore.protocol.Constants;
+
+
+public abstract class StatementImpl implements Statement {
+ public final static StatementImpl[] NONE = new StatementImpl[0];
+ public final ResourceImpl subject;
+ public final ResourceImpl predicate;
+ protected ResourceImpl object;
+ public StatementImpl(ResourceImpl subject, ResourceImpl predicate) {
+ if (null == subject)
+ throw new IllegalArgumentException();
+ if(null == predicate)
+ throw new IllegalArgumentException();
+ this.subject = (ResourceImpl)subject;
+ this.predicate = (ResourceImpl)predicate;
+ }
+
+ public ResourceImpl getObjectImpl() {
+ return object;
+ }
+ @Override
+ public Resource getObject() {
+ return object;
+ }
+
+ @Override
+ final public Resource getPredicate() {
+ return predicate;
+ }
+
+ @Override
+ final public Resource getSubject() {
+ return subject;
+ }
+
+ @Override
+ public boolean isAsserted(Resource testSubject) {
+ return !subject.equals(testSubject);
+ }
+
+ public abstract boolean equals(long s, long p, long o);
+
+ }
+
+final class StatementImplOld extends StatementImpl {
+
+ public StatementImplOld(ResourceImpl subject, ResourceImpl predicate, ResourceImpl object) {
+ super(subject, predicate);
+ this.object = (ResourceImpl)object;
+ }
+ @Override
+ public int hashCode() {
+ return subject.hashCode() + (int)object.id;
+ }
+
+ @Override
+ public boolean equals(long s, long p, long o) {
+ return (subject.id == s) && (predicate.id == p) && (object.id == o);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ else if (!(obj instanceof StatementImpl))
+ return false;
+ StatementImpl r = (StatementImpl)obj;
+ return r.equals(subject.id, predicate.id, object.id);
+ }
+}
+
+final class StatementImplNew extends StatementImpl {
+ public final long objectResourceId;
+ public final long objectClusterId;
+ public final GraphSession graphSession;
+ public StatementImplNew(ResourceImpl subject, ResourceImpl predicate, long id, long cluster, GraphSession graphSession) {
+ super(subject, predicate);
+ this.object = null;
+ this.objectResourceId = id;
+ if (Constants.ReservedClusterId == cluster)
+ throw new IllegalArgumentException("Argh!");
+ this.objectClusterId = cluster;
+ this.graphSession = graphSession;
+ }
+
+ @Override
+ final public Resource getObject() {
+// if (null == object)
+// try {
+// object = graphSession.getResourceOrThrow(objectResourceId, objectClusterId);
+// } catch (ResourceNotFoundException e) {
+// e.printStackTrace();
+// return null;
+// }
+// return object;
+ throw new Error("No can do.");
+ }
+
+ @Override
+ public ResourceImpl getObjectImpl() {
+// if (null == object)
+// try {
+// object = graphSession.getResourceOrThrow(objectResourceId, objectClusterId);
+// } catch (ResourceNotFoundException e) {
+// e.printStackTrace();
+// return null;
+// }
+// return object;
+ throw new Error("No can do.");
+ }
+
+ @Override
+ public int hashCode() {
+ return subject.hashCode() + (int)objectResourceId;
+ }
+
+ @Override
+ public boolean equals(long s, long p, long o) {
+ return (subject.id == s) && (predicate.id == p) && (objectResourceId == o);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ else if (obj == null)
+ return false;
+ else if (StatementImpl.class != obj.getClass())
+ return false;
+ StatementImpl r = (StatementImpl)obj;
+ return r.equals(subject.id, predicate.id, objectResourceId);
+ }
+}