All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.ontoware.rdf2go.model.impl.QuadPatternImpl Maven / Gradle / Ivy

Go to download

RDF2go is an implementation-independent Java API with the design goals: portability (hence the name), performance and ease of implementation. This project was started at FZI Forschungszentrum Informatik Karlsruhe, Germany - www.fzi.de

The newest version!
/**
 * LICENSE INFORMATION
 *
 * Copyright 2005-2008 by FZI (http://www.fzi.de).
 * Licensed under a BSD license (http://www.opensource.org/licenses/bsd-license.php)
 *  = Max Völkel
 *  = FZI Forschungszentrum Informatik Karlsruhe, Karlsruhe, Germany
 *  = 2010
 *
 * Further project information at http://semanticweb.org/wiki/RDF2Go
 */

package org.ontoware.rdf2go.model.impl;

import org.ontoware.rdf2go.model.QuadPattern;
import org.ontoware.rdf2go.model.Statement;
import org.ontoware.rdf2go.model.node.NodeOrVariable;
import org.ontoware.rdf2go.model.node.ResourceOrVariable;
import org.ontoware.rdf2go.model.node.UriOrVariable;
import org.ontoware.rdf2go.model.node.Variable;

/**
 * A statement with variables
 * @author voelkel
 *
 */
public class QuadPatternImpl extends TriplePatternImpl implements QuadPattern {

	/**
     * 
     */
    private static final long serialVersionUID = -4492270855601646699L;
	private UriOrVariable context;

	public QuadPatternImpl(UriOrVariable context, ResourceOrVariable subject, UriOrVariable predicate, NodeOrVariable object) {
		super(subject,predicate,object);
		this.context = context;
	}

	@Override
    public UriOrVariable getContext() {
		return this.context;
	}
	
	@Override
	public boolean equals(Object o) {
		return ((o instanceof Statement)
				&& (this.getContext().equals( ((Statement) o ).getContext()))
				&& (this.getSubject().equals(((Statement) o).getSubject()))
				&& (this.getPredicate().equals(((Statement) o).getPredicate())) && (this
				.getObject().equals(((Statement) o).getObject())));
	}
	
	@Override
	public int hashCode() {
		return this.context.hashCode() + super.hashCode();
	}
	
	@Override
	public boolean matches(Statement statement)
	{
		boolean matchesContext = statement.getContext().equals(this.getContext())
			|| this.getContext() instanceof Variable;
		return matchesContext && super.matches(statement);
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy