/** * Tests if another Node is equal to this one. Nodes are equal by value. * * @param object the object to compare against. * @return <code>true</code> If the nodes match. */ public boolean equals(Object object) { boolean result; if (object == null) { return false; } try { LocalNode localNode = (LocalNode) object; result = (getValue() == localNode.getValue()); } catch (ClassCastException cce) { result = false; } return result; }
/** * METHOD TO DO * * @return RETURNED VALUE TO DO */ public ConstraintElement copy() { return new LocalNode(value); }
/** * Nodes compare based on their node number. * * @param object the object to compare against. * @return RETURNED VALUE TO DO * @throws IllegalArgumentException if the object is not the correct type. */ public int compareTo(Object object) throws IllegalArgumentException { if (object instanceof LocalNode) { long ov = ( (LocalNode) object).getValue(); return (ov == value) ? 0 : ( (ov < value) ? ( -1) : 1); } else { throw new IllegalArgumentException("Can't compare to " + object); } }
private ConstraintExpression constrainBindings(Map bindings) throws LocalizeException { List args = new ArrayList(); Iterator i = bindings.entrySet().iterator(); logger.debug("FIXME:localize should be lookup, need to preallocate MULGARA_IS"); while (i.hasNext()) { Map.Entry entry = (Map.Entry)i.next(); args.add(ConstraintIs.newLocalConstraintIs( (Variable)entry.getKey(), new LocalNode(resolverSession.localize(ConstraintIs.MULGARA_IS)), (ValueElement)entry.getValue(), null)); } return new ConstraintConjunction(args); }
public ConstraintElement globalize(ConstraintElement constraintElement) throws GlobalizeException { Value node; if (constraintElement instanceof LocalNode) { node = resolverSession.globalize(((LocalNode)constraintElement).getValue()); if (node instanceof URIReferenceImpl || node instanceof LiteralImpl || node instanceof BlankNodeImpl) { return (ValueElement)node; } else { throw new GlobalizeException(((LocalNode)constraintElement).getValue(), "Globalize of non-internal Nodes not supported by LocalQueryResolver: " + constraintElement + " -> " + node); } } else { return constraintElement; // Either Variable or GlobalNode } }
/** * Returns either a variable or the LocalNode local equivalent of the * ConstraintElement. * * @param constraintElement a global constraint element * @return the localized equivalent to the global <var>constraintElement</var> */ public ConstraintElement localize(ConstraintElement constraintElement) throws LocalizeException { if (constraintElement instanceof Value) { return new LocalNode(resolverSession.localize((Value)constraintElement)); } else if (constraintElement instanceof Variable) { return constraintElement; } else if (constraintElement instanceof LocalNode) { return (LocalNode)constraintElement; } else { throw new IllegalArgumentException("Not a global constraint element: " + constraintElement + "::" + constraintElement.getClass()); } }
/** * Returns the long representation of the constraint element or * NodePool.NONE if a variable. * * @param constraintElement the constraint element to resolve. * @throws TuplesException if the constraint element is not supported. * @return long the long representation of the constraint element. */ protected static long toGraphTuplesIndex(ConstraintElement constraintElement) throws TuplesException { if (constraintElement instanceof Variable) { return NodePool.NONE; } if (constraintElement instanceof LocalNode) { return ((LocalNode) constraintElement).getValue(); } throw new TuplesException("Unsupported constraint element: " + constraintElement + " (" + constraintElement.getClass() + ")"); }
private Map<Variable,ValueElement> createBindingMap(Tuples tuples) throws TuplesException { Map<Variable,ValueElement> bindings = new HashMap<Variable,ValueElement>(); Variable[] vars = tuples.getVariables(); for (int i = 0; i < columnIsAggregate.length; i++) { if (!columnIsAggregate[i]) { long columnValue = tuples.getColumnValue(i); if (columnValue != Tuples.UNBOUND) { bindings.put(vars[i], new LocalNode(columnValue)); } } } return bindings; }
public Tuples resolve(QueryEvaluationContext context, ModelExpression modelExpr, ConstraintExpression constraintExpr) throws Exception { ConstraintIs constraint = (ConstraintIs)constraintExpr; return TuplesOperations.assign((Variable)context.localize(constraint.getVariable()), ((LocalNode)context.localize(constraint.getValueNode())).getValue()); } }),
public void modifyModel(long model, Statements statements, boolean occurs) throws ResolverException { LocalNode modelLocalNode = new LocalNode(model); // Obtain the resolver against the cached version Resolver temporaryResolver; try { temporaryResolver = getTemporaryResolver(modelLocalNode); } catch (Exception e) { throw new ResolverException("Unable to cache model " + modelLocalNode, e); } assert temporaryResolver != null; // Modify the cached model temporaryResolver.modifyModel(model, statements, occurs); // Mark cached version of model as changed, needing write-back changedCachedModelSet.add(modelLocalNode); }
for (Iterator<LocalNode> i = cachedModelSet.iterator(); i.hasNext();) { LocalNode modelLocalNode = i.next(); long model = modelLocalNode.getValue();
LocalNode modelLocalNode = new LocalNode(model); URI modelTypeURI = systemModelCacheMap.get(modelLocalNode); if (modelTypeURI != null) { new ConstraintImpl(new LocalNode(model), new LocalNode(metadata.getRdfTypeNode()), modelTypeVariable, new LocalNode(metadata.getSystemModelNode())); Resolution resolution = systemResolver.resolve(modelConstraint); assert resolution != null;
long modelNode; try { modelNode = ((LocalNode) constraint.getModel()).getValue(); Value node = resolverSession.globalize(modelNode);
LocalNode modelNode = new LocalNode( session.lookupPersistent(modelValue) );
long subject = ((LocalNode) constraint.getElement(0)).getValue(); if (subject != statements.getSubject()) { continue; long predicate = ((LocalNode) constraint.getElement(1)).getValue(); if (predicate != statements.getPredicate()) { continue; long object = ((LocalNode) constraint.getElement(2)).getValue(); if (object != statements.getObject()) { continue;
long model = modelLocalNode.getValue();