[Mulgara-svn] r706 - branches/mgr-61-sparql/src/jar/query/java/org/mulgara/query
pag at mulgara.org
pag at mulgara.org
Tue Mar 25 05:12:31 UTC 2008
Author: pag
Date: 2008-03-24 22:12:30 -0700 (Mon, 24 Mar 2008)
New Revision: 706
Added:
branches/mgr-61-sparql/src/jar/query/java/org/mulgara/query/ConstraintFilter.java
Log:
A new AST object to indicate filtering of a constraint
Added: branches/mgr-61-sparql/src/jar/query/java/org/mulgara/query/ConstraintFilter.java
===================================================================
--- branches/mgr-61-sparql/src/jar/query/java/org/mulgara/query/ConstraintFilter.java (rev 0)
+++ branches/mgr-61-sparql/src/jar/query/java/org/mulgara/query/ConstraintFilter.java 2008-03-25 05:12:30 UTC (rev 706)
@@ -0,0 +1,147 @@
+/*
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is the Kowari Metadata Store.
+ *
+ * The Initial Developer of the Original Code is Plugged In Software Pty
+ * Ltd (http://www.pisoftware.com, mailto:info at pisoftware.com). Portions
+ * created by Plugged In Software Pty Ltd are Copyright (C) 2001,2002
+ * Plugged In Software Pty Ltd. All Rights Reserved.
+ *
+ * Contributor(s):
+ * getModel() contributed by Netymon Pty Ltd on behalf of
+ * The Australian Commonwealth Government under contract 4500507038.
+ *
+ * [NOTE: The text of this Exhibit A may differ slightly from the text
+ * of the notices in the Source Code files of the Original Code. You
+ * should use the text of this Exhibit A rather than the text found in the
+ * Original Code Source Code for Your Modifications.]
+ *
+ */
+
+package org.mulgara.query;
+
+import java.util.Set;
+
+import org.mulgara.query.filter.Filter;
+
+// Third party packages
+import org.apache.log4j.Logger;
+
+/**
+ * A constraint expression comprised of filtering the subexpression according
+ * to an abstract formula specified as a {@link org.mulgara.query.filter.Filter}.
+ *
+ * @created Mar 24, 2008
+ * @author Paul Gearon
+ * @copyright © 2008 <a href="mailto:pgearon at users.sourceforge.net">Paul Gearon</a>
+ * @licence <a href="{@docRoot}/../../LICENCE.txt">Open Software License v3.0</a>
+ */
+public class ConstraintFilter implements Constraint {
+
+ @SuppressWarnings("unused")
+ /** The logger */
+ private final static Logger logger = Logger.getLogger(ConstraintFilter.class.getName());
+
+ /**
+ * Allow newer compiled version of the stub to operate when changes
+ * have not occurred with the class.
+ * NOTE : update this serialVersionUID when a method or a public member is
+ * deleted.
+ */
+ private static final long serialVersionUID = -816733883358318430L;
+
+ /** The filtered expression. */
+ private Constraint constraint;
+
+ /** The filter construct. */
+ private Filter filter;
+
+ /**
+ * Construct a filtered constraint.
+ * @param constraint a non-<code>null</code> constraint
+ * @throws IllegalArgumentException if <var>constraint</var> is <code>null</code>
+ */
+ public ConstraintFilter(Constraint constraint, Filter filter) {
+ if (constraint == null) throw new IllegalArgumentException("Null \"constraint\" parameter");
+ if (filter == null) throw new IllegalArgumentException("Null \"filter\" parameter");
+ this.constraint = constraint;
+ this.filter = filter;
+ }
+
+ /**
+ * Retrieve the internal filter expression. This constraint returns data whenever the filter
+ * returns <code>true</code>.
+ * @return the filter for this constraint.
+ */
+ public Filter getFilter() {
+ return filter;
+ }
+
+ /**
+ * Gets the constraint being filtered by this constraint.
+ * @return The original constraint expression.
+ */
+ public Constraint getUnfilteredConstraint() {
+ return constraint;
+ }
+
+ /**
+ * @see org.mulgara.query.Constraint#isRepeating()
+ * Returns the same value as the underlying constraint.
+ */
+ public boolean isRepeating() {
+ return constraint.isRepeating();
+ }
+
+
+ /** {@inheritDoc} */
+ public ConstraintElement getElement(int index) {
+ return constraint.getElement(index);
+ }
+
+ /** {@inheritDoc} */
+ public ConstraintElement getModel() {
+ return constraint.getModel();
+ }
+
+
+ /** {@inheritDoc} */
+ public Set<Variable> getVariables() {
+ return constraint.getVariables();
+ }
+
+
+ /** {@inheritDoc} */
+ public boolean isInnerConstraintIs() {
+ return constraint instanceof ConstraintIs;
+ }
+
+ /** {@inheritDoc} */
+ public String toString() {
+ return "filter " + constraint + " by ";
+ }
+
+ /** {@inheritDoc} */
+ public int hashCode() {
+ return constraint.hashCode() * -1;
+ }
+
+ /** {@inheritDoc} */
+ public boolean equals(Object object) {
+ if (object == null) return false;
+ if (object == this) return true;
+
+ // Check that the given object is the correct class if so check each element.
+ return ConstraintFilter.class.equals(object.getClass()) &&
+ constraint.equals(((ConstraintFilter)object).constraint);
+ }
+}
More information about the Mulgara-svn
mailing list