diff -urN --exclude=.svn --exclude=.settings --exclude=META-INF --exclude='*.jj' --exclude='*.rej' work-copy/build.xml work-copy/build.xml --- work-copy/build.xml 2007-10-07 07:19:19.000000000 -0400 +++ work-copy/build.xml 2007-10-21 11:58:06.000000000 -0400 @@ -33,7 +33,7 @@ - + @@ -149,4 +149,4 @@ - \ No newline at end of file + diff -urN --exclude=.svn --exclude=.settings --exclude=META-INF --exclude='*.jj' --exclude='*.rej' work-copy/conf/grammars/20070624.jjt work-copy/conf/grammars/20070624.jjt --- work-copy/conf/grammars/20070624.jjt 2007-10-07 07:19:16.000000000 -0400 +++ work-copy/conf/grammars/20070624.jjt 2008-05-03 16:55:36.000000000 -0400 @@ -144,7 +144,7 @@ | <#WS: ("\u0020" | "\u0009" | "\r" | "\n") > | <#VARNAME: ( | ["0"-"9"]) ( | ["0"-"9"] | "\u00B7" | ["\u0300"-"\u036F"] | ["\u203F"-"\u2040"] )* > | <#PN_CHARS: | "-" | ["0"-"9"] | "\u00B7" | ["\u0300"-"\u036F"] | ["\u203F"-"\u2040"] > - | <#PN_PREFIX: ( ( | ".")* )? > + | <#PN_PREFIX: ( "_" ( | ".")* ) | ( ( ( | ".")* )? ) > /* don't accept the underscore alone because that is for BNODE_LABEL */ | <#PN_LOCAL: ( | ["0"-"9"]) ( ( | ".")* )? > | <#EXPONENT: ["E","e"] (["+","-"])? (["0"-"9"])+ > | <#ECHAR: "\\" ["t","b","n","r","f","\\","'","\""] > @@ -262,7 +262,7 @@ } { ( ( ( "ASC" | "DESC" {ascending = false;} ) BracketedExpression() #AscOrder(ascending) ) #DescOrder(!ascending) ) - | ( ( FunctionCall() | Var() | BracketedExpression() )#DefaultOrder ) + | ( ( BuiltInCall() | FunctionCall() | Var() | BracketedExpression() )#DefaultOrder ) } void LimitClause() #Limit : diff -urN --exclude=.svn --exclude=.settings --exclude=META-INF --exclude='*.jj' --exclude='*.rej' work-copy/src/main/name/levering/ryan/sparql/common/AdvancedRdfSource.java work-copy/src/main/name/levering/ryan/sparql/common/AdvancedRdfSource.java --- work-copy/src/main/name/levering/ryan/sparql/common/AdvancedRdfSource.java 1969-12-31 19:00:00.000000000 -0500 +++ work-copy/src/main/name/levering/ryan/sparql/common/AdvancedRdfSource.java 2008-08-13 16:22:22.000000000 -0400 @@ -0,0 +1,61 @@ +/* + * SPARQL Engine + * Copyright (C) 2005 Ryan Levering, All rights reserved. + * See LICENSE for full license information + */ +package name.levering.ryan.sparql.common; + +import java.util.Iterator; +import java.util.List; + +import name.levering.ryan.sparql.common.URI; +import name.levering.ryan.sparql.common.Value; + +/** + * Description... + * + * @author Joshua Tauberer + * @version 1.0 + */ +public interface AdvancedRdfSource extends RdfSource { + /** + * Gets all statements with a specific subject, predicate and/or object, within + * a certain set of graphs. The graphs might be from FROM or FROM NAMED clauses. + * subj, pred, obj, and graph may be null. If graph is null, both FROM and + * FROM NAMED graphs may match. + * + * @param subj subject of pattern + * @param pred predicate of pattern + * @param obj object of pattern + * @param graph the context with which to match the statements against + * @return iterator over statements + */ + public Iterator getStatements(Value[] subj, Value[] pred, Value[] obj, URI[] graph, Object[] litFilters, int limit); + + /** + * Gets all statements with a specific subject, predicate and/or object in + * the default graph of the repository. All three parameters may be null to + * indicate wildcards. This is only used in SPARQL queries when no graph + * names are indicated. + * + * @param subj subject of pattern + * @param pred predicate of pattern + * @param obj object of pattern + * @return iterator over statements + */ + public Iterator getDefaultGraphStatements(Value[] subj, Value[] pred, Value[] obj, Object[] litFilters, int limit); + + /** + * Gets all statements with a specific subject, predicate and/or object in + * a named graph of the repository. All three parameters may be null to + * indicate wildcards. This is only used in SPARQL queries when no graph * names are indicated. + * + * @param subj subject of pattern + * @param pred predicate of pattern + * @param obj object of pattern + * @return iterator over statements + */ + public Iterator getNamedGraphStatements(Value[] subj, Value[] pred, Value[] obj, Object[] litFilters, int limit); + +} + diff -urN --exclude=.svn --exclude=.settings --exclude=META-INF --exclude='*.jj' --exclude='*.rej' work-copy/src/main/name/levering/ryan/sparql/common/impl/DateTime.java work-copy/src/main/name/levering/ryan/sparql/common/impl/DateTime.java --- work-copy/src/main/name/levering/ryan/sparql/common/impl/DateTime.java 2006-08-20 20:01:00.000000000 -0400 +++ work-copy/src/main/name/levering/ryan/sparql/common/impl/DateTime.java 2008-08-09 17:06:38.000000000 -0400 @@ -33,6 +33,9 @@ import java.util.NoSuchElementException; import java.util.StringTokenizer; +import name.levering.ryan.sparql.common.URI; +import name.levering.ryan.sparql.common.SPARQLConstants; + /** * This class provides utility functions for comparisons operating on * xml:dateTime datatypes as specified in 1999-05-31T13:20:00-05:00. + */ + public DateTime(String dateTimeString, URI datatype) { + DateTimeFields fields; + if (datatype.equals(SPARQLConstants.DATETIME_TYPE)) { + fields = parseDateTimeString(dateTimeString); + } else if (datatype.equals(SPARQLConstants.DATE_TYPE)) { + fields = parseDateString(dateTimeString); + hasTime = false; + } else { + throw new IllegalArgumentException("datatype is not xsd:date or xsd:dateTime"); + } + setNumericFields(fields, dateTimeString); + validateFieldValues(fields, dateTimeString); + } + + /** * Wraps the standard memory cloning to throw a runtime exception rather * than the more annoying CloneNotSupportedException. * @@ -133,6 +159,8 @@ result = thisDT.months - otherDT.months; } else if (thisDT.days != otherDT.days) { result = thisDT.days - otherDT.days; + } else if (!hasTime) { + result = 0; } else if (thisDT.hours != otherDT.hours) { result = thisDT.hours - otherDT.hours; } else if (thisDT.minutes != otherDT.minutes) { @@ -300,18 +328,19 @@ result.append(formatInt(this.months, 2)); result.append('-'); result.append(formatInt(this.days, 2)); - result.append('T'); - result.append(formatInt(this.hours, 2)); - result.append(':'); - result.append(formatInt(this.minutes, 2)); - result.append(':'); - result.append(formatInt(this.seconds, 2)); - - if (this.fractionalSeconds > 0) { - result.append('.'); - result.append(this.fractionalSeconds); + if (hasTime) { + result.append('T'); + result.append(formatInt(this.hours, 2)); + result.append(':'); + result.append(formatInt(this.minutes, 2)); + result.append(':'); + result.append(formatInt(this.seconds, 2)); + + if (this.fractionalSeconds > 0) { + result.append('.'); + result.append(this.fractionalSeconds); + } } - if (this.hasTimeZone) { if (this.hoursTimeZone == 0 && this.minutesTimeZone == 0) { result.append("Z"); @@ -409,6 +438,52 @@ return fields; } + private DateTimeFields parseDateString(String dateString) { + if (dateString.length() < 10) { + throw new IllegalArgumentException("String value too short to be a valid xsd:date value: " + + dateString); + } + + DateTimeFields fields = new DateTimeFields(); + + String errMsg = "Invalid xsd:date value: " + dateString; + + StringTokenizer st = new StringTokenizer(dateString, "+-TZ", true); + try { + fields.yearString = st.nextToken(); + fields.isNegativeYear = fields.yearString.equals("-"); + if (fields.isNegativeYear) { + fields.yearString = st.nextToken(); + } + verifyTokenValue(st.nextToken(), "-", errMsg); + fields.monthsString = st.nextToken(); + verifyTokenValue(st.nextToken(), "-", errMsg); + fields.daysString = st.nextToken(); + fields.hoursString = "00"; + fields.minutesString = "00"; + fields.secondsString = "00"; + + String token = st.hasMoreTokens() ? st.nextToken() : null; + + if ("+".equals(token) || "-".equals(token)) { + fields.isNegativeTimeZone = "-".equals(token); + fields.hoursTimeZoneString = st.nextToken(); + verifyTokenValue(st.nextToken(), ":", errMsg); + fields.minutesTimeZoneString = st.nextToken(); + } else if ("Z".equals(token)) { + fields.isNegativeTimeZone = false; + fields.hoursTimeZoneString = fields.minutesTimeZoneString = "00"; + } + + if (st.hasMoreTokens()) { + throw new IllegalArgumentException(errMsg); + } + } catch (NoSuchElementException e) { + throw new IllegalArgumentException(errMsg); + } + return fields; + } + private void setNumericFields(DateTimeFields fields, String dateTimeString) { try { this.year = Integer.parseInt(fields.yearString); diff -urN --exclude=.svn --exclude=.settings --exclude=META-INF --exclude='*.jj' --exclude='*.rej' work-copy/src/main/name/levering/ryan/sparql/common/impl/InternalSPARQLValueFactory.java work-copy/src/main/name/levering/ryan/sparql/common/impl/InternalSPARQLValueFactory.java --- work-copy/src/main/name/levering/ryan/sparql/common/impl/InternalSPARQLValueFactory.java 2007-10-07 07:19:17.000000000 -0400 +++ work-copy/src/main/name/levering/ryan/sparql/common/impl/InternalSPARQLValueFactory.java 2007-10-21 12:35:15.000000000 -0400 @@ -52,7 +52,7 @@ } public URI createURI(String namespace, String localName) { - return new URIImpl(namespace, localName); + return new URIImpl(namespace + localName); } public URI createURI(URI baseURI) { @@ -279,11 +279,8 @@ | Variables | +---------------------------------------*/ - /** The namespace. * */ - private String _namespace; - - /** local name * */ - private String _localName; + /** complete URI * */ + private String _uri; /*---------------------------------------+ | Constructors | @@ -297,68 +294,12 @@ * (absolute) URI. */ public URIImpl(String uri) { - // Find the place to split the uri - int i = uri.length() - 1; - while (i >= 0) { - char c = uri.charAt(i); - if (c == '#' || c == ':' || c == '/') { - break; - } - i--; - } - - if (i > 0) { - // Split the uri - _namespace = uri.substring(0, i + 1); - _localName = uri.substring(i + 1); - } else { - throw new IllegalArgumentException("'" + uri + "' is not a legal (absolute) URI"); - } - } - - /** - * Creates a new URI that will get the supplied namespace and local - * name. - * - * @param namespace A namespace. - * @param localName A legal local name. A legal local name adheres to - * the definition of an NCName as specified at http://www.w3.org/TR/REC-xml-names/#NT-NCName. - */ - public URIImpl(String namespace, String localName) { - if (namespace == null) { - throw new IllegalArgumentException("namespace must not be null"); - } - if (localName == null) { - throw new IllegalArgumentException("localName must not be null"); - } - - _namespace = namespace; - _localName = localName; - } - - /*---------------------------------------+ - | Methods | - +---------------------------------------*/ - - // inherit comments - public String getNamespace() { - return _namespace; - } - - // inherit comments - public String getLocalName() { - return _localName; + this._uri = uri; } // inherit comments public String getURI() { - // This code is (much) more efficient then just concatenating the - // two strings. - char[] result = new char[_namespace.length() + _localName.length()]; - _namespace.getChars(0, _namespace.length(), result, 0); - _localName.getChars(0, _localName.length(), result, _namespace.length()); - return new String(result); + return _uri; } /** @@ -376,7 +317,7 @@ if (o instanceof URI) { URI other = (URI) o; - return _localName.equals(other.getLocalName()) && _namespace.equals(other.getNamespace()); + return _uri.equals(other.getURI()); } return false; @@ -384,7 +325,7 @@ // Implements Object.hashCode() public int hashCode() { - return _namespace.hashCode() ^ _localName.hashCode(); + return _uri.hashCode(); } /** diff -urN --exclude=.svn --exclude=.settings --exclude=META-INF --exclude='*.jj' --exclude='*.rej' work-copy/src/main/name/levering/ryan/sparql/common/impl/RdfBindingSetImpl.java work-copy/src/main/name/levering/ryan/sparql/common/impl/RdfBindingSetImpl.java --- work-copy/src/main/name/levering/ryan/sparql/common/impl/RdfBindingSetImpl.java 2007-10-07 07:19:17.000000000 -0400 +++ work-copy/src/main/name/levering/ryan/sparql/common/impl/RdfBindingSetImpl.java 2007-10-21 12:35:14.000000000 -0400 @@ -98,6 +98,8 @@ for (Iterator oldRows = oldSet.iterator(); oldRows.hasNext();) { this.addRow((RdfBindingRow) oldRows.next()); } + setDistinct(oldSet.isDistinct()); + setOrdered(oldSet.isOrdered()); } /** @@ -141,11 +143,10 @@ if (row == null) { throw new NullPointerException("RdfBindingRow 'row' cannot be null"); } - List newValues = new ArrayList(); - for (int i = 0; i < this.variables.length; i++) { - newValues.add(row.getValue(this.variables[i])); - } - this.values.add(newValues.toArray(new Value[0])); + Value[] newValues = new Value[this.variables.length]; + for (int i = 0; i < this.variables.length; i++) + newValues[i] = row.getValue(this.variables[i]); + this.values.add(newValues); } /** diff -urN --exclude=.svn --exclude=.settings --exclude=META-INF --exclude='*.jj' --exclude='*.rej' work-copy/src/main/name/levering/ryan/sparql/common/impl/VariableImpl.java work-copy/src/main/name/levering/ryan/sparql/common/impl/VariableImpl.java --- work-copy/src/main/name/levering/ryan/sparql/common/impl/VariableImpl.java 2007-10-07 07:19:17.000000000 -0400 +++ work-copy/src/main/name/levering/ryan/sparql/common/impl/VariableImpl.java 2008-02-09 10:17:15.000000000 -0500 @@ -77,4 +77,9 @@ return bindings.getValue(this); } + public java.util.Set getVariables() { + java.util.HashSet ret = new java.util.HashSet(); + ret.add(this); + return ret; + } } diff -urN --exclude=.svn --exclude=.settings --exclude=META-INF --exclude='*.jj' --exclude='*.rej' work-copy/src/main/name/levering/ryan/sparql/common/RdfSource.java work-copy/src/main/name/levering/ryan/sparql/common/RdfSource.java --- work-copy/src/main/name/levering/ryan/sparql/common/RdfSource.java 2007-10-07 07:19:17.000000000 -0400 +++ work-copy/src/main/name/levering/ryan/sparql/common/RdfSource.java 2008-08-13 16:17:09.000000000 -0400 @@ -19,8 +19,10 @@ public interface RdfSource { /** - * Gets all statements with a specific subject, predicate and/or object. All - * three parameters may be null to indicate wildcards. + * Gets all statements with a specific subject, predicate and/or object, within + * a certain set of graphs. The graphs might be from FROM or FROM NAMED clauses. + * subj, pred, and obj, and graph may be null. If graph is null, both FROM and + * FROM NAMED graphs may match. * * @param subj subject of pattern * @param pred predicate of pattern @@ -28,7 +30,7 @@ * @param graph the context with which to match the statements against * @return iterator over statements */ - public Iterator getStatements(Value subj, URI pred, Value obj, URI graph); + public Iterator getStatements(Value subj, URI pred, Value obj, URI[] graph); /** * Gets all statements with a specific subject, predicate and/or object in @@ -41,57 +43,56 @@ * @param obj object of pattern * @return iterator over statements */ - public Iterator getDefaultStatements(Value subj, URI pred, Value obj); + public Iterator getDefaultGraphStatements(Value subj, URI pred, Value obj); /** - * Gets all the statements, regardless of graph context, with a specific - * subject, predicate and/or object in the default graph of the repository. - * All three parameters may be null to indicate wildcards. + * Gets all statements with a specific subject, predicate and/or object in + * a named graph of the repository. All three parameters may be null to + * indicate wildcards. This is only used in SPARQL queries when no graph * names are indicated. * * @param subj subject of pattern * @param pred predicate of pattern * @param obj object of pattern * @return iterator over statements */ - public Iterator getStatements(Value subj, URI pred, Value obj); + public Iterator getNamedGraphStatements(Value subj, URI pred, Value obj); /** - * Checks whether some statement with a specific subject, predicate and/or - * object is present in the default graph of the repository. All three - * parameters may be null to indicate wildcards. This is only used in SPARQL - * queries when no graph names are indicated. + * Checks whether the statement exist with a specific subject, predicate and/or object, within + * a certain set of graphs. The graphs might be from FROM or FROM NAMED clauses. + * subj, pred, and obj may not be null. * - * @param subj subject of statement - * @param pred predicate of statement - * @param obj object of statement - * @return boolean indicating if specified statement is present + * @param subj subject of pattern + * @param pred predicate of pattern + * @param obj object of pattern + * @param graph the context with which to match the statements against + * @return iterator over statements */ - public boolean hasDefaultStatement(Value subj, URI pred, Value obj); + public boolean hasStatement(Value subj, URI pred, Value obj, URI[] graph); /** - * Checks whether some statement with a specific subject, predicate and/or - * object is present in any graph of the repository. All three parameters - * may be null to indicate wildcards. + * Checks whether the statement exists with a specific subject, predicate and/or object in + * the default graph of the repository. No parameters may be null. + * This is only used in SPARQL queries when no graph names are indicated. * - * @param subj subject of statement - * @param pred predicate of statement - * @param obj object of statement - * @return boolean indicating if specified statement is present + * @param subj subject of pattern + * @param pred predicate of pattern + * @param obj object of pattern + * @return iterator over statements */ - public boolean hasStatement(Value subj, URI pred, Value obj); + public boolean hasDefaultGraphStatement(Value subj, URI pred, Value obj); /** - * Checks whether some statement with a specific subject, predicate and/or - * object is present in the repository. All three parameters may be null to - * indicate wildcards. + * Checks whether the statement exists with a specific subject, predicate and/or object in + * a named graph of the repository. No parameters may be null. + * This is only used in SPARQL queries when no graph names are indicated. * - * @param subj subject of statement - * @param pred predicate of statement - * @param obj object of statement - * @param graph the context to match the statements against - * @return boolean indicating if specified statement is present + * @param subj subject of pattern + * @param pred predicate of pattern + * @param obj object of pattern + * @return iterator over statements */ - public boolean hasStatement(Value subj, URI pred, Value obj, URI graph); + public boolean hasNamedGraphStatement(Value subj, URI pred, Value obj); /** * This useful method returns a value factory that is actually used by the diff -urN --exclude=.svn --exclude=.settings --exclude=META-INF --exclude='*.jj' --exclude='*.rej' work-copy/src/main/name/levering/ryan/sparql/common/SPARQLConstants.java work-copy/src/main/name/levering/ryan/sparql/common/SPARQLConstants.java --- work-copy/src/main/name/levering/ryan/sparql/common/SPARQLConstants.java 2007-10-07 07:19:17.000000000 -0400 +++ work-copy/src/main/name/levering/ryan/sparql/common/SPARQLConstants.java 2008-03-06 07:55:03.000000000 -0500 @@ -26,42 +26,121 @@ public static final URI TYPE = initFactory.createURI("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"); /** - * The datatype for double precision numerals. + * The URI for xsd:duration. */ - public static final URI DOUBLE_TYPE = initFactory.createURI("http://www.w3.org/2001/XMLSchema#double"); + public static final URI DURATION_TYPE = initFactory.createURI("http://www.w3.org/2001/XMLSchema#duration"); /** - * The datatype for a smaller precision decimal numeral. + * The URI for xsd:dateTime. */ - public static final URI INTEGER_TYPE = initFactory.createURI("http://www.w3.org/2001/XMLSchema#integer"); + public static final URI DATETIME_TYPE = initFactory.createURI("http://www.w3.org/2001/XMLSchema#dateTime"); + + /** + /** + * The URI for xsd:time. + */ + public static final URI TIME_TYPE = initFactory.createURI("http://www.w3.org/2001/XMLSchema#time"); /** - * The datatype for the decimal type numeral, which is a generic - * non-fractional number. + * The URI for xsd:date. */ - public static final URI DECIMAL_TYPE = initFactory.createURI("http://www.w3.org/2001/XMLSchema#decimal"); + public static final URI DATE_TYPE = initFactory.createURI("http://www.w3.org/2001/XMLSchema#date"); + + /** + * The datatype for a true/false value. + */ + public static final URI BOOLEAN_TYPE = initFactory.createURI("http://www.w3.org/2001/XMLSchema#boolean"); /** * The datatype for a single precision numeral. */ public static final URI FLOAT_TYPE = initFactory.createURI("http://www.w3.org/2001/XMLSchema#float"); - /** - * The datatype for a date/time representation, represented according to - * ISO-8601. + /* + * The URI for xsd:double. */ - public static final URI DATE_TYPE = initFactory.createURI("http://www.w3.org/2001/XMLSchema#dateTime"); + public static final URI DOUBLE_TYPE = initFactory.createURI("http://www.w3.org/2001/XMLSchema#double"); + + /* + * The URI for xsd:anyURI. + */ + public static final URI ANYURI_TYPE = initFactory.createURI("http://www.w3.org/2001/XMLSchema#anyURI"); /** - * The datatype for a string representation, which is a general sequence of + * The XSD datatype for a string representation, which is a general sequence of * UNICODE or ASCII characters. */ public static final URI STRING_TYPE = initFactory.createURI("http://www.w3.org/2001/XMLSchema#string"); /** - * The datatype for a true/false value. + * xsd:decimal */ - public static final URI BOOLEAN_TYPE = initFactory.createURI("http://www.w3.org/2001/XMLSchema#boolean"); + public static final URI DECIMAL_TYPE = initFactory.createURI("http://www.w3.org/2001/XMLSchema#decimal"); + + /** + * xsd:integer + */ + public static final URI INTEGER_TYPE = initFactory.createURI("http://www.w3.org/2001/XMLSchema#integer"); + + /** + * xsd:nonPositiveInteger + */ + public static final URI NONPOSITIVEINTEGER_TYPE = initFactory.createURI("http://www.w3.org/2001/XMLSchema#nonPositiveInteger"); + + /** + * xsd:negativeInteger + */ + public static final URI NEGATIVEINTEGER_TYPE = initFactory.createURI("http://www.w3.org/2001/XMLSchema#negativeInteger"); + + /** + * The datatype for a higher precision decimal numeral. + */ + public static final URI LONG_TYPE = initFactory.createURI("http://www.w3.org/2001/XMLSchema#long"); + + /** + * The datatype for a smaller precision decimal numeral. + */ + public static final URI INT_TYPE = initFactory.createURI("http://www.w3.org/2001/XMLSchema#int"); + + /** + * The datatype for an even smaller precision decimal numeral. + */ + public static final URI SHORT_TYPE = initFactory.createURI("http://www.w3.org/2001/XMLSchema#short"); + + /** + * The datatype for an even smaller precision decimal numeral. + */ + public static final URI BYTE_TYPE = initFactory.createURI("http://www.w3.org/2001/XMLSchema#byte"); + + /** + * xsd:nonNegativeInteger + */ + public static final URI NONNEGATIVEINTEGER_TYPE = initFactory.createURI("http://www.w3.org/2001/XMLSchema#nonNegativeInteger"); + + /** + * xsd:positiveInteger + */ + public static final URI POSITIVEINTEGER_TYPE = initFactory.createURI("http://www.w3.org/2001/XMLSchema#positiveInteger"); + + /** + * The datatype for a higher precision decimal numeral. + */ + public static final URI UNSIGNEDLONG_TYPE = initFactory.createURI("http://www.w3.org/2001/XMLSchema#unsignedLong"); + + /** + * The datatype for a smaller precision decimal numeral. + */ + public static final URI UNSIGNEDINT_TYPE = initFactory.createURI("http://www.w3.org/2001/XMLSchema#unsignedInt"); + + /** + * The datatype for an even smaller precision decimal numeral. + */ + public static final URI UNSIGNEDSHORT_TYPE = initFactory.createURI("http://www.w3.org/2001/XMLSchema#unsignedShort"); + + /** + * The datatype for an even smaller precision decimal numeral. + */ + public static final URI UNSIGNEDBYTE_TYPE = initFactory.createURI("http://www.w3.org/2001/XMLSchema#unsignedByte"); /** * The datatype specifically for RDF data, that represents an URI in an RDF triple. diff -urN --exclude=.svn --exclude=.settings --exclude=META-INF --exclude='*.jj' --exclude='*.rej' work-copy/src/main/name/levering/ryan/sparql/common/URI.java work-copy/src/main/name/levering/ryan/sparql/common/URI.java --- work-copy/src/main/name/levering/ryan/sparql/common/URI.java 2007-10-07 07:19:17.000000000 -0400 +++ work-copy/src/main/name/levering/ryan/sparql/common/URI.java 2007-10-21 12:35:15.000000000 -0400 @@ -3,17 +3,10 @@ public interface URI extends Resource { /** - * Gets the namespace of this URI. + * Gets the URI of this URI. * - * @return The URI's namespace. + * @return The URI as a string. **/ - public String getNamespace(); - - /** - * Gets the local name of this URI. - * - * @return The URI's local name. - **/ - public String getLocalName(); + public String getURI(); } diff -urN --exclude=.svn --exclude=.settings --exclude=META-INF --exclude='*.jj' --exclude='*.rej' work-copy/src/main/name/levering/ryan/sparql/extensions/fpredicates/FunctionalPredicateLogic.java work-copy/src/main/name/levering/ryan/sparql/extensions/fpredicates/FunctionalPredicateLogic.java --- work-copy/src/main/name/levering/ryan/sparql/extensions/fpredicates/FunctionalPredicateLogic.java 2006-08-20 20:00:59.000000000 -0400 +++ work-copy/src/main/name/levering/ryan/sparql/extensions/fpredicates/FunctionalPredicateLogic.java 2008-08-13 16:14:08.000000000 -0400 @@ -1,6 +1,7 @@ package name.levering.ryan.sparql.extensions.fpredicates; import java.util.Collection; +import java.util.Map; import name.levering.ryan.sparql.common.RdfBindingSet; import name.levering.ryan.sparql.common.RdfSource; @@ -35,16 +36,11 @@ * Delegates to the function to return a binding set based on the source and * the subject and object of the functional predicate statement. * - * @param bindings the current bindings, ignored - * @param source the RDF source to pass to the function - * @param defaultDatasets the default named graphs, ignored - * @param namedDatasets the named graphs, ignored * @return a binding set according to the function */ - public RdfBindingSet constrain(RdfBindingSet bindings, RdfSource source, Collection defaultDatasets, - Collection namedDatasets) { + public RdfBindingSet constrain(ConstraintLogic.CallParams p) { - return this.function.getBindingSet(this.data.getSubjectExpression(), this.data.getObjectExpression(), source); + return this.function.getBindingSet(this.data.getSubjectExpression(), this.data.getObjectExpression(), p.source); } } diff -urN --exclude=.svn --exclude=.settings --exclude=META-INF --exclude='*.jj' --exclude='*.rej' work-copy/src/main/name/levering/ryan/sparql/extensions/fpredicates/ListMemberProperty.java work-copy/src/main/name/levering/ryan/sparql/extensions/fpredicates/ListMemberProperty.java --- work-copy/src/main/name/levering/ryan/sparql/extensions/fpredicates/ListMemberProperty.java 2007-10-07 07:19:16.000000000 -0400 +++ work-copy/src/main/name/levering/ryan/sparql/extensions/fpredicates/ListMemberProperty.java 2008-08-13 16:17:49.000000000 -0400 @@ -65,14 +65,14 @@ // Start off with two server queries to cache the members of all // lists and the edges between lists - Iterator edgeStatements = source.getStatements(null, SPARQLConstants.LIST_REST, null); // list + Iterator edgeStatements = source.getStatements(null, SPARQLConstants.LIST_REST, null, null); // list // edges while (edgeStatements.hasNext()) { Statement statement = (Statement) edgeStatements.next(); edgeCache.put(statement.getSubject(), statement.getObject()); } - Iterator memberStatements = source.getStatements(null, SPARQLConstants.LIST_FIRST, null); // list + Iterator memberStatements = source.getStatements(null, SPARQLConstants.LIST_FIRST, null, null); // list // members while (memberStatements.hasNext()) { Statement statement = (Statement) memberStatements.next(); diff -urN --exclude=.svn --exclude=.settings --exclude=META-INF --exclude='*.jj' --exclude='*.rej' work-copy/src/main/name/levering/ryan/sparql/extensions/fpredicates/RdfsMemberProperty.java work-copy/src/main/name/levering/ryan/sparql/extensions/fpredicates/RdfsMemberProperty.java --- work-copy/src/main/name/levering/ryan/sparql/extensions/fpredicates/RdfsMemberProperty.java 2007-10-07 07:19:16.000000000 -0400 +++ work-copy/src/main/name/levering/ryan/sparql/extensions/fpredicates/RdfsMemberProperty.java 2008-08-13 16:44:25.000000000 -0400 @@ -83,7 +83,7 @@ objVar = (Value) this.objExpression; } - return new RdfsMemberIterator(this.source.getStatements(subjVar, null, objVar)); + return new RdfsMemberIterator(this.source.getStatements(subjVar, null, objVar, null)); } /** diff -urN --exclude=.svn --exclude=.settings --exclude=META-INF --exclude='*.jj' --exclude='*.rej' work-copy/src/main/name/levering/ryan/sparql/extensions/functions/aggregate/CountFunction.java work-copy/src/main/name/levering/ryan/sparql/extensions/functions/aggregate/CountFunction.java --- work-copy/src/main/name/levering/ryan/sparql/extensions/functions/aggregate/CountFunction.java 2007-10-07 07:19:16.000000000 -0400 +++ work-copy/src/main/name/levering/ryan/sparql/extensions/functions/aggregate/CountFunction.java 2008-07-11 15:28:33.000000000 -0400 @@ -65,7 +65,7 @@ counter = set.size(); this.countCache.put(set, new Integer(counter)); } - return this.converter.convertInteger(counter); + return this.converter.convertInteger(java.math.BigInteger.valueOf(counter)); } /** diff -urN --exclude=.svn --exclude=.settings --exclude=META-INF --exclude='*.jj' --exclude='*.rej' work-copy/src/main/name/levering/ryan/sparql/extensions/functions/aggregate/IsMaxFunction.java work-copy/src/main/name/levering/ryan/sparql/extensions/functions/aggregate/IsMaxFunction.java --- work-copy/src/main/name/levering/ryan/sparql/extensions/functions/aggregate/IsMaxFunction.java 2007-10-07 07:19:16.000000000 -0400 +++ work-copy/src/main/name/levering/ryan/sparql/extensions/functions/aggregate/IsMaxFunction.java 2007-10-21 12:35:16.000000000 -0400 @@ -128,7 +128,7 @@ return new ExternalFunctionFactory() { public ExternalFunction create(LogicFactory logicFactory, SPARQLValueFactory valueFactory) { - return new IsMaxFunction(logicFactory.getValueOrderingLogic()); + return new IsMaxFunction(logicFactory.getValueOrderingLogic(valueFactory)); } }; diff -urN --exclude=.svn --exclude=.settings --exclude=META-INF --exclude='*.jj' --exclude='*.rej' work-copy/src/main/name/levering/ryan/sparql/extensions/functions/aggregate/IsMinFunction.java work-copy/src/main/name/levering/ryan/sparql/extensions/functions/aggregate/IsMinFunction.java --- work-copy/src/main/name/levering/ryan/sparql/extensions/functions/aggregate/IsMinFunction.java 2007-10-07 07:19:16.000000000 -0400 +++ work-copy/src/main/name/levering/ryan/sparql/extensions/functions/aggregate/IsMinFunction.java 2007-10-21 12:35:16.000000000 -0400 @@ -126,7 +126,7 @@ return new ExternalFunctionFactory() { public ExternalFunction create(LogicFactory logicFactory, SPARQLValueFactory valueFactory) { - return new IsMinFunction(logicFactory.getValueOrderingLogic()); + return new IsMinFunction(logicFactory.getValueOrderingLogic(valueFactory)); } }; diff -urN --exclude=.svn --exclude=.settings --exclude=META-INF --exclude='*.jj' --exclude='*.rej' work-copy/src/main/name/levering/ryan/sparql/extensions/functions/aggregate/MaxFunction.java work-copy/src/main/name/levering/ryan/sparql/extensions/functions/aggregate/MaxFunction.java --- work-copy/src/main/name/levering/ryan/sparql/extensions/functions/aggregate/MaxFunction.java 2007-10-07 07:19:16.000000000 -0400 +++ work-copy/src/main/name/levering/ryan/sparql/extensions/functions/aggregate/MaxFunction.java 2007-10-21 12:35:16.000000000 -0400 @@ -121,7 +121,7 @@ return new ExternalFunctionFactory() { public ExternalFunction create(LogicFactory logicFactory, SPARQLValueFactory valueFactory) { - return new MaxFunction(logicFactory.getValueOrderingLogic()); + return new MaxFunction(logicFactory.getValueOrderingLogic(valueFactory)); } }; diff -urN --exclude=.svn --exclude=.settings --exclude=META-INF --exclude='*.jj' --exclude='*.rej' work-copy/src/main/name/levering/ryan/sparql/extensions/functions/aggregate/MinFunction.java work-copy/src/main/name/levering/ryan/sparql/extensions/functions/aggregate/MinFunction.java --- work-copy/src/main/name/levering/ryan/sparql/extensions/functions/aggregate/MinFunction.java 2007-10-07 07:19:16.000000000 -0400 +++ work-copy/src/main/name/levering/ryan/sparql/extensions/functions/aggregate/MinFunction.java 2007-10-21 12:35:16.000000000 -0400 @@ -121,7 +121,7 @@ return new ExternalFunctionFactory() { public ExternalFunction create(LogicFactory logicFactory, SPARQLValueFactory valueFactory) { - return new MinFunction(logicFactory.getValueOrderingLogic()); + return new MinFunction(logicFactory.getValueOrderingLogic(valueFactory)); } }; diff -urN --exclude=.svn --exclude=.settings --exclude=META-INF --exclude='*.jj' --exclude='*.rej' work-copy/src/main/name/levering/ryan/sparql/extensions/functions/datetime/AddDayFunction.java work-copy/src/main/name/levering/ryan/sparql/extensions/functions/datetime/AddDayFunction.java --- work-copy/src/main/name/levering/ryan/sparql/extensions/functions/datetime/AddDayFunction.java 2007-10-07 07:19:16.000000000 -0400 +++ work-copy/src/main/name/levering/ryan/sparql/extensions/functions/datetime/AddDayFunction.java 2008-07-11 15:28:33.000000000 -0400 @@ -51,7 +51,7 @@ throw new ExternalFunctionException("Values need to be literals to be understood"); } - int number = this.converter.convertInteger((Literal) daysToAdd); + int number = this.converter.convertInteger((Literal) daysToAdd).intValue(); DateTime date = this.converter.convertDateTime((Literal) origDate); Calendar cal = new GregorianCalendar(date.getYear(), date.getMonth() - 1, date.getDay(), date.getHour(), date diff -urN --exclude=.svn --exclude=.settings --exclude=META-INF --exclude='*.jj' --exclude='*.rej' work-copy/src/main/name/levering/ryan/sparql/extensions/functions/datetime/AddHourFunction.java work-copy/src/main/name/levering/ryan/sparql/extensions/functions/datetime/AddHourFunction.java --- work-copy/src/main/name/levering/ryan/sparql/extensions/functions/datetime/AddHourFunction.java 2007-10-07 07:19:16.000000000 -0400 +++ work-copy/src/main/name/levering/ryan/sparql/extensions/functions/datetime/AddHourFunction.java 2008-07-11 15:28:33.000000000 -0400 @@ -52,7 +52,7 @@ "Values need to be literals to be understood"); } - int number = this.converter.convertInteger((Literal) hoursToAdd); + int number = this.converter.convertInteger((Literal) hoursToAdd).intValue(); DateTime date = this.converter.convertDateTime((Literal) origDate); Calendar cal = new GregorianCalendar(date.getYear(), date.getMonth() - 1, date.getDay(), date.getHour(), date.getMinute(), date.getSecond()); diff -urN --exclude=.svn --exclude=.settings --exclude=META-INF --exclude='*.jj' --exclude='*.rej' work-copy/src/main/name/levering/ryan/sparql/extensions/functions/datetime/AddMinuteFunction.java work-copy/src/main/name/levering/ryan/sparql/extensions/functions/datetime/AddMinuteFunction.java --- work-copy/src/main/name/levering/ryan/sparql/extensions/functions/datetime/AddMinuteFunction.java 2007-10-07 07:19:16.000000000 -0400 +++ work-copy/src/main/name/levering/ryan/sparql/extensions/functions/datetime/AddMinuteFunction.java 2008-07-11 15:28:33.000000000 -0400 @@ -52,7 +52,7 @@ "Values need to be literals to be understood"); } - int number = this.converter.convertInteger((Literal) minutesToAdd); + int number = this.converter.convertInteger((Literal) minutesToAdd).intValue(); DateTime date = this.converter.convertDateTime((Literal) origDate); Calendar cal = new GregorianCalendar(date.getYear(), date.getMonth() - 1, date.getDay(), date.getHour(), date.getMinute(), date.getSecond()); diff -urN --exclude=.svn --exclude=.settings --exclude=META-INF --exclude='*.jj' --exclude='*.rej' work-copy/src/main/name/levering/ryan/sparql/extensions/functions/datetime/AddMonthFunction.java work-copy/src/main/name/levering/ryan/sparql/extensions/functions/datetime/AddMonthFunction.java --- work-copy/src/main/name/levering/ryan/sparql/extensions/functions/datetime/AddMonthFunction.java 2007-10-07 07:19:16.000000000 -0400 +++ work-copy/src/main/name/levering/ryan/sparql/extensions/functions/datetime/AddMonthFunction.java 2008-07-11 15:28:33.000000000 -0400 @@ -52,7 +52,7 @@ "Values need to be literals to be understood"); } - int number = this.converter.convertInteger((Literal) monthsToAdd); + int number = this.converter.convertInteger((Literal) monthsToAdd).intValue(); DateTime date = this.converter.convertDateTime((Literal) origDate); Calendar cal = new GregorianCalendar(date.getYear(), date.getMonth() - 1, date.getDay(), date.getHour(), date.getMinute(), date.getSecond()); diff -urN --exclude=.svn --exclude=.settings --exclude=META-INF --exclude='*.jj' --exclude='*.rej' work-copy/src/main/name/levering/ryan/sparql/extensions/functions/datetime/AddSecondFunction.java work-copy/src/main/name/levering/ryan/sparql/extensions/functions/datetime/AddSecondFunction.java --- work-copy/src/main/name/levering/ryan/sparql/extensions/functions/datetime/AddSecondFunction.java 2007-10-07 07:19:16.000000000 -0400 +++ work-copy/src/main/name/levering/ryan/sparql/extensions/functions/datetime/AddSecondFunction.java 2008-07-11 15:28:33.000000000 -0400 @@ -52,7 +52,7 @@ "Values need to be literals to be understood"); } - int number = this.converter.convertInteger((Literal) secondsToAdd); + int number = this.converter.convertInteger((Literal) secondsToAdd).intValue(); DateTime date = this.converter.convertDateTime((Literal) origDate); Calendar cal = new GregorianCalendar(date.getYear(), date.getMonth() - 1, date.getDay(), date.getHour(), date.getMinute(), date.getSecond()); diff -urN --exclude=.svn --exclude=.settings --exclude=META-INF --exclude='*.jj' --exclude='*.rej' work-copy/src/main/name/levering/ryan/sparql/extensions/functions/datetime/AddYearFunction.java work-copy/src/main/name/levering/ryan/sparql/extensions/functions/datetime/AddYearFunction.java --- work-copy/src/main/name/levering/ryan/sparql/extensions/functions/datetime/AddYearFunction.java 2007-10-07 07:19:16.000000000 -0400 +++ work-copy/src/main/name/levering/ryan/sparql/extensions/functions/datetime/AddYearFunction.java 2008-07-11 15:28:33.000000000 -0400 @@ -52,7 +52,7 @@ "Values need to be literals to be understood"); } - int number = this.converter.convertInteger((Literal) yearsToAdd); + int number = this.converter.convertInteger((Literal) yearsToAdd).intValue(); DateTime date = this.converter.convertDateTime((Literal) origDate); Calendar cal = new GregorianCalendar(date.getYear(), date.getMonth() - 1, date.getDay(), date.getHour(), date.getMinute(), date.getSecond()); diff -urN --exclude=.svn --exclude=.settings --exclude=META-INF --exclude='*.jj' --exclude='*.rej' work-copy/src/main/name/levering/ryan/sparql/extensions/functions/datetime/DayFunction.java work-copy/src/main/name/levering/ryan/sparql/extensions/functions/datetime/DayFunction.java --- work-copy/src/main/name/levering/ryan/sparql/extensions/functions/datetime/DayFunction.java 2007-10-07 07:19:16.000000000 -0400 +++ work-copy/src/main/name/levering/ryan/sparql/extensions/functions/datetime/DayFunction.java 2008-07-11 15:28:33.000000000 -0400 @@ -49,7 +49,7 @@ DateTime date = this.converter.convertDateTime((Literal) value); - return this.converter.convertInteger(date.getDay()); + return this.converter.convertInteger(java.math.BigInteger.valueOf(date.getDay())); } /** diff -urN --exclude=.svn --exclude=.settings --exclude=META-INF --exclude='*.jj' --exclude='*.rej' work-copy/src/main/name/levering/ryan/sparql/extensions/functions/datetime/HourFunction.java work-copy/src/main/name/levering/ryan/sparql/extensions/functions/datetime/HourFunction.java --- work-copy/src/main/name/levering/ryan/sparql/extensions/functions/datetime/HourFunction.java 2007-10-07 07:19:16.000000000 -0400 +++ work-copy/src/main/name/levering/ryan/sparql/extensions/functions/datetime/HourFunction.java 2008-07-11 15:28:33.000000000 -0400 @@ -49,7 +49,7 @@ DateTime date = this.converter.convertDateTime((Literal) value); - return this.converter.convertInteger(date.getHour()); + return this.converter.convertInteger(java.math.BigInteger.valueOf(date.getHour())); } /** diff -urN --exclude=.svn --exclude=.settings --exclude=META-INF --exclude='*.jj' --exclude='*.rej' work-copy/src/main/name/levering/ryan/sparql/extensions/functions/datetime/MinuteFunction.java work-copy/src/main/name/levering/ryan/sparql/extensions/functions/datetime/MinuteFunction.java --- work-copy/src/main/name/levering/ryan/sparql/extensions/functions/datetime/MinuteFunction.java 2007-10-07 07:19:16.000000000 -0400 +++ work-copy/src/main/name/levering/ryan/sparql/extensions/functions/datetime/MinuteFunction.java 2008-07-11 15:28:33.000000000 -0400 @@ -49,7 +49,7 @@ DateTime date = this.converter.convertDateTime((Literal) value); - return this.converter.convertInteger(date.getMinute()); + return this.converter.convertInteger(java.math.BigInteger.valueOf(date.getMinute())); } /** diff -urN --exclude=.svn --exclude=.settings --exclude=META-INF --exclude='*.jj' --exclude='*.rej' work-copy/src/main/name/levering/ryan/sparql/extensions/functions/datetime/MonthFunction.java work-copy/src/main/name/levering/ryan/sparql/extensions/functions/datetime/MonthFunction.java --- work-copy/src/main/name/levering/ryan/sparql/extensions/functions/datetime/MonthFunction.java 2007-10-07 07:19:16.000000000 -0400 +++ work-copy/src/main/name/levering/ryan/sparql/extensions/functions/datetime/MonthFunction.java 2008-07-11 15:28:33.000000000 -0400 @@ -49,7 +49,7 @@ DateTime date = this.converter.convertDateTime((Literal) value); - return this.converter.convertInteger(date.getMonth()); + return this.converter.convertInteger(java.math.BigInteger.valueOf(date.getMonth())); } /** diff -urN --exclude=.svn --exclude=.settings --exclude=META-INF --exclude='*.jj' --exclude='*.rej' work-copy/src/main/name/levering/ryan/sparql/extensions/functions/datetime/SecondFunction.java work-copy/src/main/name/levering/ryan/sparql/extensions/functions/datetime/SecondFunction.java --- work-copy/src/main/name/levering/ryan/sparql/extensions/functions/datetime/SecondFunction.java 2007-10-07 07:19:16.000000000 -0400 +++ work-copy/src/main/name/levering/ryan/sparql/extensions/functions/datetime/SecondFunction.java 2008-07-11 15:28:33.000000000 -0400 @@ -49,7 +49,7 @@ DateTime date = this.converter.convertDateTime((Literal) value); - return this.converter.convertInteger(date.getSecond()); + return this.converter.convertInteger(java.math.BigInteger.valueOf(date.getSecond())); } /** diff -urN --exclude=.svn --exclude=.settings --exclude=META-INF --exclude='*.jj' --exclude='*.rej' work-copy/src/main/name/levering/ryan/sparql/extensions/functions/datetime/YearFunction.java work-copy/src/main/name/levering/ryan/sparql/extensions/functions/datetime/YearFunction.java --- work-copy/src/main/name/levering/ryan/sparql/extensions/functions/datetime/YearFunction.java 2007-10-07 07:19:16.000000000 -0400 +++ work-copy/src/main/name/levering/ryan/sparql/extensions/functions/datetime/YearFunction.java 2008-07-11 15:28:33.000000000 -0400 @@ -49,7 +49,7 @@ DateTime date = this.converter.convertDateTime((Literal) value); - return this.converter.convertInteger(date.getYear()); + return this.converter.convertInteger(java.math.BigInteger.valueOf(date.getYear())); } /** diff -urN --exclude=.svn --exclude=.settings --exclude=META-INF --exclude='*.jj' --exclude='*.rej' work-copy/src/main/name/levering/ryan/sparql/extensions/functions/string/LengthFunction.java work-copy/src/main/name/levering/ryan/sparql/extensions/functions/string/LengthFunction.java --- work-copy/src/main/name/levering/ryan/sparql/extensions/functions/string/LengthFunction.java 2007-10-07 07:19:16.000000000 -0400 +++ work-copy/src/main/name/levering/ryan/sparql/extensions/functions/string/LengthFunction.java 2008-07-11 15:28:33.000000000 -0400 @@ -48,7 +48,7 @@ String string = this.converter.convertString((Literal) stringValue); - return this.converter.convertInteger(string.length()); + return this.converter.convertInteger(java.math.BigInteger.valueOf(string.length())); } /** diff -urN --exclude=.svn --exclude=.settings --exclude=META-INF --exclude='*.jj' --exclude='*.rej' work-copy/src/main/name/levering/ryan/sparql/extensions/functions/string/SubstringFunction.java work-copy/src/main/name/levering/ryan/sparql/extensions/functions/string/SubstringFunction.java --- work-copy/src/main/name/levering/ryan/sparql/extensions/functions/string/SubstringFunction.java 2007-10-07 07:19:16.000000000 -0400 +++ work-copy/src/main/name/levering/ryan/sparql/extensions/functions/string/SubstringFunction.java 2008-07-11 15:28:33.000000000 -0400 @@ -48,7 +48,7 @@ } String string = this.converter.convertString((Literal) stringValue); - int start = this.converter.convertInteger((Literal) startIndex); + int start = this.converter.convertInteger((Literal) startIndex).intValue(); return this.converter.convertString(string.substring(start)); } @@ -72,8 +72,8 @@ } String string = this.converter.convertString((Literal) stringValue); - int start = this.converter.convertInteger((Literal) startIndex); - int chars = this.converter.convertInteger((Literal) length); + int start = this.converter.convertInteger((Literal) startIndex).intValue(); + int chars = this.converter.convertInteger((Literal) length).intValue(); return this.converter.convertString(string.substring(start, start + chars)); } diff -urN --exclude=.svn --exclude=.settings --exclude=META-INF --exclude='*.jj' --exclude='*.rej' work-copy/src/main/name/levering/ryan/sparql/extensions/with/DefaultWithConstraintLogic.java work-copy/src/main/name/levering/ryan/sparql/extensions/with/DefaultWithConstraintLogic.java --- work-copy/src/main/name/levering/ryan/sparql/extensions/with/DefaultWithConstraintLogic.java 2006-08-20 20:00:59.000000000 -0400 +++ work-copy/src/main/name/levering/ryan/sparql/extensions/with/DefaultWithConstraintLogic.java 2008-08-13 16:14:32.000000000 -0400 @@ -1,6 +1,7 @@ package name.levering.ryan.sparql.extensions.with; import java.util.Collection; +import java.util.Map; import name.levering.ryan.sparql.common.RdfBindingSet; import name.levering.ryan.sparql.common.RdfSource; @@ -37,16 +38,11 @@ * Ignores the inputs and just lets the extension return a binding set to be * intersected with the current running set. * - * @param bindings the current bindings, ignored - * @param source the source to query against, passed to the WITH extension - * @param defaultDatasets the default data sets to query against, ignored - * @param namedDatasets the named data sets to query against, ignored * @return the binding set created by the extension */ - public RdfBindingSet constrain(RdfBindingSet bindings, RdfSource source, Collection defaultDatasets, - Collection namedDatasets) { + public RdfBindingSet constrain(ConstraintLogic.CallParams p) { return this.extension.getBindingSet((ExpressionLogic[]) this.data.getArguments().toArray( - new ExpressionLogic[] {}), source); + new ExpressionLogic[] {}), p.source); } } diff -urN --exclude=.svn --exclude=.settings --exclude=META-INF --exclude='*.jj' --exclude='*.rej' work-copy/src/main/name/levering/ryan/sparql/logic/BaseLogic.java work-copy/src/main/name/levering/ryan/sparql/logic/BaseLogic.java --- work-copy/src/main/name/levering/ryan/sparql/logic/BaseLogic.java 2007-10-07 07:19:19.000000000 -0400 +++ work-copy/src/main/name/levering/ryan/sparql/logic/BaseLogic.java 2008-02-09 10:18:23.000000000 -0500 @@ -25,7 +25,6 @@ import name.levering.ryan.sparql.logic.function.LangLogic; import name.levering.ryan.sparql.logic.function.LangMatchesLogic; import name.levering.ryan.sparql.logic.function.RegexLogic; -import name.levering.ryan.sparql.logic.function.SameTermLogic; import name.levering.ryan.sparql.logic.function.StrLogic; import name.levering.ryan.sparql.model.data.BinaryExpressionData; import name.levering.ryan.sparql.model.data.CallExpressionData; @@ -90,16 +89,6 @@ } /** - * Gets the default variables evaluation logic. - * - * @param data the variable the logic is evaluating - * @return the logic handling the variable evaluation - */ - public ExpressionLogic getVariableLogic(Variable data) { - return new DefaultVariableLogic(data); - } - - /** * Gets the default division logic. * * @param data the binary data containing the expressions to divide @@ -279,17 +268,6 @@ } /** - * Gets the default 'sameTerm' function logic. - * - * @param data the function data containing arguments passed to the - * langMatches function - * @return the logic handling the langMatches function - */ - public ExpressionLogic getSameTermLogic(CallExpressionData data, SPARQLValueFactory valueFactory) { - return new SameTermLogic(data, getValueConversionLogic(valueFactory)); - } - - /** * Gets the default 'regex' function logic. * * @param data the function data containing arguments passed to the regex @@ -357,8 +335,8 @@ * * @return the logic that orders Value objects */ - public ValueOrderingLogic getValueOrderingLogic() { - return new DefaultValueOrderingLogic(); + public ValueOrderingLogic getValueOrderingLogic(SPARQLValueFactory valueFactory) { + return new DefaultValueOrderingLogic(getNumericPromotionLogic(valueFactory), getValueConversionLogic(valueFactory)); } } diff -urN --exclude=.svn --exclude=.settings --exclude=META-INF --exclude='*.jj' --exclude='*.rej' work-copy/src/main/name/levering/ryan/sparql/logic/BNodeRenamingConstructQueryLogic.java work-copy/src/main/name/levering/ryan/sparql/logic/BNodeRenamingConstructQueryLogic.java --- work-copy/src/main/name/levering/ryan/sparql/logic/BNodeRenamingConstructQueryLogic.java 2007-10-07 07:19:19.000000000 -0400 +++ work-copy/src/main/name/levering/ryan/sparql/logic/BNodeRenamingConstructQueryLogic.java 2008-08-13 14:57:43.000000000 -0400 @@ -22,6 +22,7 @@ import name.levering.ryan.sparql.model.GroupConstraint; import name.levering.ryan.sparql.model.TripleConstraint; import name.levering.ryan.sparql.model.data.ConstructQueryData; +import name.levering.ryan.sparql.model.logic.ConstraintLogic; import name.levering.ryan.sparql.model.logic.ConstructQueryLogic; import name.levering.ryan.sparql.model.logic.OrderExpressionLogic; import name.levering.ryan.sparql.model.logic.helper.SetRangeLogic; @@ -85,31 +86,21 @@ * @return an RDF graph containing the formed triples */ public RdfGraph execute(RdfSource source) { + ConstraintLogic.CallParams p = new ConstraintLogic.CallParams(); + p.bindings = new RdfBindingSetImpl(); + p.source = source; + // Grab the necessary fields from the data GroupConstraint constraint = this.data.getConstraint(); - Collection defaultDatasets = this.data.getDefaultDatasets(); - Collection namedDatasets = this.data.getNamedDatasets(); - List orderExpressions = this.data.getOrderExpressions(); - int limit = this.data.getLimit(); - int offset = this.data.getOffset(); + p.defaultDatasets = this.data.getDefaultDatasets(); + p.namedDatasets = this.data.getNamedDatasets(); + p.orderExpressions = this.data.getOrderExpressions(); + p.limit = this.data.getLimit(); + p.offset = this.data.getOffset(); + p.rangeLogic = this.rangeLogic; // First bind the result table - RdfBindingSet results = constraint.constrain(new RdfBindingSetImpl(), source, defaultDatasets, namedDatasets); - - // Now apply ordering in reverse order to give priority to the first - // variable - for (int i = orderExpressions.size() - 1; i >= 0; i--) { - OrderExpressionLogic orderer = (OrderExpressionLogic) orderExpressions.get(i); - orderer.order(results); - } - - // Now apply limiting and offsetting - if (limit >= 0) { - results = this.rangeLogic.limit(results, limit); - } - if (offset >= 0) { - results = this.rangeLogic.offset(results, offset); - } + RdfBindingSet results = constraint.constrain(p); // Now apply the solutions to the template RdfGraphImpl graph = new RdfGraphImpl(); diff -urN --exclude=.svn --exclude=.settings --exclude=META-INF --exclude='*.jj' --exclude='*.rej' work-copy/src/main/name/levering/ryan/sparql/logic/debug/DebugLogicWrapper.java work-copy/src/main/name/levering/ryan/sparql/logic/debug/DebugLogicWrapper.java --- work-copy/src/main/name/levering/ryan/sparql/logic/debug/DebugLogicWrapper.java 2007-10-07 07:19:19.000000000 -0400 +++ work-copy/src/main/name/levering/ryan/sparql/logic/debug/DebugLogicWrapper.java 2008-07-11 15:31:54.000000000 -0400 @@ -89,8 +89,8 @@ return this.baseFactory.getDatatypeLogic(data); } - public DescribeQueryLogic getDescribeQueryLogic(DescribeQueryData data) { - return this.baseFactory.getDescribeQueryLogic(data); + public DescribeQueryLogic getDescribeQueryLogic(DescribeQueryData data, SPARQLValueFactory valueFactory) { + return this.baseFactory.getDescribeQueryLogic(data, valueFactory); } public ExpressionLogic getDivisionLogic(BinaryExpressionData data, SPARQLValueFactory valueFactory) { @@ -145,10 +145,6 @@ return this.baseFactory.getLangMatchesLogic(data, valueFactory); } - public ExpressionLogic getSameTermLogic(CallExpressionData data, SPARQLValueFactory valueFactory) { - return this.baseFactory.getSameTermLogic(data, valueFactory); - } - public ExpressionLogic getLTELogic(BinaryExpressionData data, SPARQLValueFactory valueFactory) { return this.baseFactory.getLTELogic(data, valueFactory); } @@ -177,8 +173,8 @@ return new OptionalConstraintDebug(this.baseFactory.getOptionalConstraintLogic(data, valueFactory), this.out); } - public OrderExpressionLogic getOrderExpressionLogic(OrderExpressionData data) { - return this.baseFactory.getOrderExpressionLogic(data); + public OrderExpressionLogic getOrderExpressionLogic(OrderExpressionData data, SPARQLValueFactory valueFactory) { + return this.baseFactory.getOrderExpressionLogic(data, valueFactory); } public ExpressionLogic getOrLogic(BinaryExpressionData data, SPARQLValueFactory valueFactory) { @@ -209,10 +205,6 @@ return new UnionConstraintDebug(this.baseFactory.getUnionConstraintLogic(data), this.out); } - public ExpressionLogic getVariableLogic(Variable data) { - return this.baseFactory.getVariableLogic(data); - } - public ConstraintLogic getWithConstraintLogic(WithConstraintData data) { if (this.baseFactory instanceof ExtendedLogicFactory) { ((ExtendedLogicFactory) this.baseFactory).getWithConstraintLogic(data); @@ -240,8 +232,8 @@ return this.baseFactory.getValueConversionLogic(valueFactory); } - public ValueOrderingLogic getValueOrderingLogic() { - return this.baseFactory.getValueOrderingLogic(); + public ValueOrderingLogic getValueOrderingLogic(SPARQLValueFactory valueFactory) { + return this.baseFactory.getValueOrderingLogic(valueFactory); } public ConstructQueryLogic getConstructQueryLogic(ExtendedConstructQueryData data, SPARQLValueFactory valueFactory) { diff -urN --exclude=.svn --exclude=.settings --exclude=META-INF --exclude='*.jj' --exclude='*.rej' work-copy/src/main/name/levering/ryan/sparql/logic/debug/FilterConstraintDebug.java work-copy/src/main/name/levering/ryan/sparql/logic/debug/FilterConstraintDebug.java --- work-copy/src/main/name/levering/ryan/sparql/logic/debug/FilterConstraintDebug.java 2006-08-20 20:01:00.000000000 -0400 +++ work-copy/src/main/name/levering/ryan/sparql/logic/debug/FilterConstraintDebug.java 2007-10-21 12:35:15.000000000 -0400 @@ -1,6 +1,7 @@ package name.levering.ryan.sparql.logic.debug; import java.util.Collection; +import java.util.Map; import name.levering.ryan.sparql.common.RdfBindingSet; import name.levering.ryan.sparql.common.RdfSource; @@ -19,11 +20,10 @@ this.out = listener; } - public RdfBindingSet constrain(RdfBindingSet bindings, RdfSource source, Collection defaultDatasets, - Collection namedDatasets) { - this.out.filterConstraintPreExecute(this.data, bindings); + public RdfBindingSet constrain(ConstraintLogic.CallParams p) { + this.out.filterConstraintPreExecute(this.data, p.bindings); long start = System.currentTimeMillis(); - RdfBindingSet returnSet = this.filterLogic.constrain(bindings, source, defaultDatasets, namedDatasets); + RdfBindingSet returnSet = this.filterLogic.constrain(p); long end = System.currentTimeMillis(); this.out.filterConstraintPostExecute(end-start, returnSet); return returnSet; diff -urN --exclude=.svn --exclude=.settings --exclude=META-INF --exclude='*.jj' --exclude='*.rej' work-copy/src/main/name/levering/ryan/sparql/logic/debug/GraphConstraintDebug.java work-copy/src/main/name/levering/ryan/sparql/logic/debug/GraphConstraintDebug.java --- work-copy/src/main/name/levering/ryan/sparql/logic/debug/GraphConstraintDebug.java 2006-08-20 20:01:00.000000000 -0400 +++ work-copy/src/main/name/levering/ryan/sparql/logic/debug/GraphConstraintDebug.java 2007-10-21 12:35:15.000000000 -0400 @@ -1,6 +1,7 @@ package name.levering.ryan.sparql.logic.debug; import java.util.Collection; +import java.util.Map; import name.levering.ryan.sparql.common.RdfBindingSet; import name.levering.ryan.sparql.common.RdfSource; @@ -16,11 +17,10 @@ this.out = listener; } - public RdfBindingSet constrain(RdfBindingSet bindings, RdfSource source, Collection defaultDatasets, - Collection namedDatasets) { + public RdfBindingSet constrain(ConstraintLogic.CallParams p) { this.out.graphConstraintPreExecute(); long start = System.currentTimeMillis(); - RdfBindingSet returnSet = this.logic.constrain(bindings, source, defaultDatasets, namedDatasets); + RdfBindingSet returnSet = this.logic.constrain(p); long end = System.currentTimeMillis(); this.out.graphConstraintPostExecute(end-start, returnSet); return returnSet; diff -urN --exclude=.svn --exclude=.settings --exclude=META-INF --exclude='*.jj' --exclude='*.rej' work-copy/src/main/name/levering/ryan/sparql/logic/debug/GroupConstraintDebug.java work-copy/src/main/name/levering/ryan/sparql/logic/debug/GroupConstraintDebug.java --- work-copy/src/main/name/levering/ryan/sparql/logic/debug/GroupConstraintDebug.java 2006-08-20 20:01:00.000000000 -0400 +++ work-copy/src/main/name/levering/ryan/sparql/logic/debug/GroupConstraintDebug.java 2007-10-21 12:35:15.000000000 -0400 @@ -1,6 +1,7 @@ package name.levering.ryan.sparql.logic.debug; import java.util.Collection; +import java.util.Map; import name.levering.ryan.sparql.common.RdfBindingSet; import name.levering.ryan.sparql.common.RdfSource; @@ -16,11 +17,10 @@ this.out = listener; } - public RdfBindingSet constrain(RdfBindingSet bindings, RdfSource source, Collection defaultDatasets, - Collection namedDatasets) { + public RdfBindingSet constrain(ConstraintLogic.CallParams p) { this.out.groupConstraintPreExecute(); long start = System.currentTimeMillis(); - RdfBindingSet returnSet = this.logic.constrain(bindings, source, defaultDatasets, namedDatasets); + RdfBindingSet returnSet = this.logic.constrain(p); long end = System.currentTimeMillis(); this.out.groupConstraintPostExecute(end-start, returnSet); return returnSet; diff -urN --exclude=.svn --exclude=.settings --exclude=META-INF --exclude='*.jj' --exclude='*.rej' work-copy/src/main/name/levering/ryan/sparql/logic/debug/OptionalConstraintDebug.java work-copy/src/main/name/levering/ryan/sparql/logic/debug/OptionalConstraintDebug.java --- work-copy/src/main/name/levering/ryan/sparql/logic/debug/OptionalConstraintDebug.java 2006-08-20 20:01:00.000000000 -0400 +++ work-copy/src/main/name/levering/ryan/sparql/logic/debug/OptionalConstraintDebug.java 2007-10-21 12:35:15.000000000 -0400 @@ -1,6 +1,7 @@ package name.levering.ryan.sparql.logic.debug; import java.util.Collection; +import java.util.Map; import name.levering.ryan.sparql.common.RdfBindingSet; import name.levering.ryan.sparql.common.RdfSource; @@ -16,11 +17,10 @@ this.out = listener; } - public RdfBindingSet constrain(RdfBindingSet bindings, RdfSource source, Collection defaultDatasets, - Collection namedDatasets) { + public RdfBindingSet constrain(ConstraintLogic.CallParams p) { this.out.optionalConstraintPreExecute(); long start = System.currentTimeMillis(); - RdfBindingSet returnSet = this.logic.constrain(bindings, source, defaultDatasets, namedDatasets); + RdfBindingSet returnSet = this.logic.constrain(p); long end = System.currentTimeMillis(); this.out.optionalConstraintPostExecute(end-start, returnSet); return returnSet; diff -urN --exclude=.svn --exclude=.settings --exclude=META-INF --exclude='*.jj' --exclude='*.rej' work-copy/src/main/name/levering/ryan/sparql/logic/debug/TripleConstraintDebug.java work-copy/src/main/name/levering/ryan/sparql/logic/debug/TripleConstraintDebug.java --- work-copy/src/main/name/levering/ryan/sparql/logic/debug/TripleConstraintDebug.java 2006-08-20 20:01:00.000000000 -0400 +++ work-copy/src/main/name/levering/ryan/sparql/logic/debug/TripleConstraintDebug.java 2007-10-21 12:35:15.000000000 -0400 @@ -6,6 +6,7 @@ package name.levering.ryan.sparql.logic.debug; import java.util.Collection; +import java.util.Map; import name.levering.ryan.sparql.common.RdfBindingSet; import name.levering.ryan.sparql.common.RdfSource; @@ -24,11 +25,10 @@ this.out = listener; } - public RdfBindingSet constrain(RdfBindingSet bindings, RdfSource source, - Collection defaultDatasets, Collection namedDatasets) { + public RdfBindingSet constrain(ConstraintLogic.CallParams p) { this.out.tripleFetchPreExecute(this.data); long start = System.currentTimeMillis(); - RdfBindingSet returnSet = this.logic.constrain(bindings, source, defaultDatasets, namedDatasets); + RdfBindingSet returnSet = this.logic.constrain(p); long end = System.currentTimeMillis(); this.out.tripleFetchPostExecute(end-start, returnSet); return returnSet; diff -urN --exclude=.svn --exclude=.settings --exclude=META-INF --exclude='*.jj' --exclude='*.rej' work-copy/src/main/name/levering/ryan/sparql/logic/debug/UnionConstraintDebug.java work-copy/src/main/name/levering/ryan/sparql/logic/debug/UnionConstraintDebug.java --- work-copy/src/main/name/levering/ryan/sparql/logic/debug/UnionConstraintDebug.java 2006-08-20 20:01:00.000000000 -0400 +++ work-copy/src/main/name/levering/ryan/sparql/logic/debug/UnionConstraintDebug.java 2007-10-21 12:35:15.000000000 -0400 @@ -1,6 +1,7 @@ package name.levering.ryan.sparql.logic.debug; import java.util.Collection; +import java.util.Map; import name.levering.ryan.sparql.common.RdfBindingSet; import name.levering.ryan.sparql.common.RdfSource; @@ -16,11 +17,10 @@ this.out = listener; } - public RdfBindingSet constrain(RdfBindingSet bindings, RdfSource source, Collection defaultDatasets, - Collection namedDatasets) { + public RdfBindingSet constrain(ConstraintLogic.CallParams p) { this.out.unionConstrainPreExecute(); long start = System.currentTimeMillis(); - RdfBindingSet returnSet = this.unionLogic.constrain(bindings, source, defaultDatasets, namedDatasets); + RdfBindingSet returnSet = this.unionLogic.constrain(p); long end = System.currentTimeMillis(); this.out.unionConstraintPostExecute(end-start, returnSet); return returnSet; diff -urN --exclude=.svn --exclude=.settings --exclude=META-INF --exclude='*.jj' --exclude='*.rej' work-copy/src/main/name/levering/ryan/sparql/logic/DefaultAskQueryLogic.java work-copy/src/main/name/levering/ryan/sparql/logic/DefaultAskQueryLogic.java --- work-copy/src/main/name/levering/ryan/sparql/logic/DefaultAskQueryLogic.java 2006-08-20 20:01:01.000000000 -0400 +++ work-copy/src/main/name/levering/ryan/sparql/logic/DefaultAskQueryLogic.java 2008-02-10 07:52:12.000000000 -0500 @@ -13,6 +13,8 @@ import name.levering.ryan.sparql.model.GroupConstraint; import name.levering.ryan.sparql.model.data.AskQueryData; import name.levering.ryan.sparql.model.logic.AskQueryLogic; +import name.levering.ryan.sparql.model.logic.ConstraintLogic; +import name.levering.ryan.sparql.model.logic.helper.SetRangeLogic; /** * This is the simplest query logic in SPARQL, as it doesn't have to deal with @@ -29,6 +31,8 @@ * The data to delegate the data requests to. */ private final AskQueryData data; + + private final SetRangeLogic rangeLogic; /** * Creates a new object that handles the logic of the ask query, delegating @@ -36,8 +40,9 @@ * * @param data the ask query data object delegate */ - public DefaultAskQueryLogic(AskQueryData data) { + public DefaultAskQueryLogic(AskQueryData data, SetRangeLogic rangeLogic) { this.data = data; + this.rangeLogic = rangeLogic; } /** @@ -48,14 +53,19 @@ * @return true if the delegated query data binds any value rows */ public boolean execute(RdfSource source) { - // Grab the necessary fields from the data + ConstraintLogic.CallParams p = new ConstraintLogic.CallParams(); + p.bindings = new RdfBindingSetImpl(); + p.source = source; + + // Grab the necessary fields from the data GroupConstraint constraint = this.data.getConstraint(); - Collection defaultDatasets = this.data.getDefaultDatasets(); - Collection namedDatasets = this.data.getNamedDatasets(); + p.defaultDatasets = this.data.getDefaultDatasets(); + p.namedDatasets = this.data.getNamedDatasets(); + p.limit = 1; + p.rangeLogic = rangeLogic; // First bind the result table - RdfBindingSet results = constraint.constrain(new RdfBindingSetImpl(), - source, defaultDatasets, namedDatasets); + RdfBindingSet results = constraint.constrain(p); // Return whether or not the iterator returns any rows return results.iterator().hasNext(); diff -urN --exclude=.svn --exclude=.settings --exclude=META-INF --exclude='*.jj' --exclude='*.rej' work-copy/src/main/name/levering/ryan/sparql/logic/DefaultConstructQueryLogic.java work-copy/src/main/name/levering/ryan/sparql/logic/DefaultConstructQueryLogic.java --- work-copy/src/main/name/levering/ryan/sparql/logic/DefaultConstructQueryLogic.java 2007-10-07 07:19:19.000000000 -0400 +++ work-copy/src/main/name/levering/ryan/sparql/logic/DefaultConstructQueryLogic.java 2008-02-05 08:36:55.000000000 -0500 @@ -6,19 +6,32 @@ package name.levering.ryan.sparql.logic; import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; import java.util.List; +import java.util.Map; +import name.levering.ryan.sparql.common.RdfBindingRow; import name.levering.ryan.sparql.common.RdfBindingSet; import name.levering.ryan.sparql.common.RdfGraph; import name.levering.ryan.sparql.common.RdfSource; import name.levering.ryan.sparql.common.impl.RdfBindingSetImpl; +import name.levering.ryan.sparql.common.impl.RdfGraphImpl; +import name.levering.ryan.sparql.common.impl.StatementImpl; import name.levering.ryan.sparql.model.GroupConstraint; +import name.levering.ryan.sparql.model.TripleConstraint; import name.levering.ryan.sparql.model.data.ConstructQueryData; +import name.levering.ryan.sparql.model.logic.ConstraintLogic; import name.levering.ryan.sparql.model.logic.ConstructQueryLogic; import name.levering.ryan.sparql.model.logic.OrderExpressionLogic; import name.levering.ryan.sparql.model.logic.helper.GraphTranslationLogic; import name.levering.ryan.sparql.model.logic.helper.SetRangeLogic; +import name.levering.ryan.sparql.common.BNode; +import name.levering.ryan.sparql.common.URI; +import name.levering.ryan.sparql.common.Value; +import name.levering.ryan.sparql.common.BNode; + /** * This query logic constructs an RDF graph by applying an RDF template to a set * of value bindings. It must first bind the variables values, then apply @@ -67,33 +80,23 @@ * @return an RDF graph containing the formed triples */ public RdfGraph execute(RdfSource source) { + ConstraintLogic.CallParams p = new ConstraintLogic.CallParams(); + p.bindings = new RdfBindingSetImpl(); + p.source = source; + // Grab the necessary fields from the data GroupConstraint constraint = this.data.getConstraint(); - Collection defaultDatasets = this.data.getDefaultDatasets(); - Collection namedDatasets = this.data.getNamedDatasets(); - List orderExpressions = this.data.getOrderExpressions(); - int limit = this.data.getLimit(); - int offset = this.data.getOffset(); - + p.defaultDatasets = this.data.getDefaultDatasets(); + p.namedDatasets = this.data.getNamedDatasets(); + p.orderExpressions = this.data.getOrderExpressions(); + p.limit = this.data.getLimit(); + p.offset = this.data.getOffset(); + p.rangeLogic = this.rangeLogic; + // First bind the result table - RdfBindingSet results = constraint.constrain(new RdfBindingSetImpl(), - source, defaultDatasets, namedDatasets); - - // Now apply ordering in reverse order to give priority to the first - // variable - for (int i = orderExpressions.size() - 1; i >= 0; i--) { - OrderExpressionLogic orderer = (OrderExpressionLogic) orderExpressions.get(i); - orderer.order(results); - } - - // Now apply limiting and offsetting - if (limit >= 0) { - results = this.rangeLogic.limit(results, limit); - } - if (offset >= 0) { - results = this.rangeLogic.offset(results, offset); - } + RdfBindingSet results = constraint.constrain(p); + // Then construct the triples output. return this.translationLogic.translate(this.data.getTriples(), results); } diff -urN --exclude=.svn --exclude=.settings --exclude=META-INF --exclude='*.jj' --exclude='*.rej' work-copy/src/main/name/levering/ryan/sparql/logic/DefaultDescribeQueryLogic.java work-copy/src/main/name/levering/ryan/sparql/logic/DefaultDescribeQueryLogic.java --- work-copy/src/main/name/levering/ryan/sparql/logic/DefaultDescribeQueryLogic.java 2007-10-07 07:19:19.000000000 -0400 +++ work-copy/src/main/name/levering/ryan/sparql/logic/DefaultDescribeQueryLogic.java 2008-08-13 16:45:44.000000000 -0400 @@ -7,6 +7,7 @@ import java.util.ArrayList; import java.util.Collection; +import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; @@ -19,12 +20,15 @@ import name.levering.ryan.sparql.common.RdfGraph; import name.levering.ryan.sparql.common.RdfSource; import name.levering.ryan.sparql.common.Resource; +import name.levering.ryan.sparql.common.SPARQLValueFactory; +import name.levering.ryan.sparql.common.URI; import name.levering.ryan.sparql.common.Value; import name.levering.ryan.sparql.common.Variable; import name.levering.ryan.sparql.common.impl.RdfBindingSetImpl; import name.levering.ryan.sparql.common.impl.RdfGraphImpl; import name.levering.ryan.sparql.model.GroupConstraint; import name.levering.ryan.sparql.model.data.DescribeQueryData; +import name.levering.ryan.sparql.model.logic.ConstraintLogic; import name.levering.ryan.sparql.model.logic.DescribeQueryLogic; import name.levering.ryan.sparql.model.logic.OrderExpressionLogic; import name.levering.ryan.sparql.model.logic.helper.SetProjectionLogic; @@ -50,12 +54,17 @@ * The logic that projects the binding set to the desired variables for * construction. */ - private final SetProjectionLogic logic; + private final SetProjectionLogic projectionLogic; /** * The logic to handle limiting the rows of the binding set results. */ private final SetRangeLogic rangeLogic; + + /** + * The logic to create resources. + */ + private final SPARQLValueFactory valueFactory; /** * Creates a new object that handles the logic of the describe query, @@ -67,10 +76,11 @@ * @param logic the logic to use to project the variables to the desired * variables to describe */ - public DefaultDescribeQueryLogic(DescribeQueryData data, SetProjectionLogic logic, SetRangeLogic rangeLogic) { + public DefaultDescribeQueryLogic(DescribeQueryData data, SetProjectionLogic projectionLogic, SetRangeLogic rangeLogic, SPARQLValueFactory valueFactory) { this.data = data; - this.logic = logic; + this.projectionLogic = projectionLogic; this.rangeLogic = rangeLogic; + this.valueFactory = valueFactory; } /** @@ -82,41 +92,35 @@ * @return an RDF graph containing the formed triples */ public RdfGraph execute(RdfSource source) { + ConstraintLogic.CallParams p = new ConstraintLogic.CallParams(); + p.bindings = new RdfBindingSetImpl(); + p.source = source; + // Grab the necessary fields from the data GroupConstraint constraint = this.data.getConstraint(); - Collection defaultDatasets = this.data.getDefaultDatasets(); - Collection namedDatasets = this.data.getNamedDatasets(); - List orderExpressions = this.data.getOrderExpressions(); + p.defaultDatasets = this.data.getDefaultDatasets(); + p.namedDatasets = this.data.getNamedDatasets(); + p.orderExpressions = this.data.getOrderExpressions(); List queryResources = this.data.getQueryResources(); - int limit = this.data.getLimit(); - int offset = this.data.getOffset(); - - // First bind the result table - RdfBindingSet results = constraint.constrain(new RdfBindingSetImpl(), source, defaultDatasets, namedDatasets); + p.limit = this.data.getLimit(); + p.offset = this.data.getOffset(); - // Now project to the solution set - List variables = new ArrayList(); + // Get the distinguished variables. + p.distinguishedVariables = new HashSet(); for (Iterator i = queryResources.iterator(); i.hasNext();) { Object resource = i.next(); if (resource instanceof Variable) { - variables.add(resource); + p.distinguishedVariables.add(resource); } } - results = this.logic.project(results, variables); - - // Now apply ordering in reverse order - for (int i = orderExpressions.size(); i >= 0; i--) { - OrderExpressionLogic orderer = (OrderExpressionLogic) orderExpressions.get(i); - orderer.order(results); - } + + p.rangeLogic = this.rangeLogic; + p.projectionLogic = this.projectionLogic; - // Now apply limiting and offsetting - if (limit >= 0) { - results = this.rangeLogic.limit(results, limit); - } - if (offset >= 0) { - results = this.rangeLogic.offset(results, offset); - } + // First bind the result table + RdfBindingSet results = new RdfBindingSetImpl(); + if (constraint != null) + results = constraint.constrain(p); // Now find the next level of concrete nodes // For every resource in the solution set @@ -147,7 +151,7 @@ RdfGraphImpl graph = new RdfGraphImpl(); for (int i = 0; i < resources.length; i++) { for (Iterator varResources = resources[i].iterator(); varResources.hasNext();) { - graph.addTriples(describe((Resource) varResources.next(), source, new HashSet())); + graph.addTriples(uniq(describe((Resource) varResources.next(), source, new HashSet(), -1, 0))); } } @@ -163,27 +167,116 @@ * @return all of the statements that give a one-level description of a * resource */ - private Collection describe(Value value, RdfSource source, Set alreadyDescribed) { + private Collection describe(Value value, RdfSource source, Set alreadyDescribed, int direction, int depth) { // First add the current node to the described list alreadyDescribed.add(value); // Now accumulate statements Collection descriptions = new ArrayList(); - Iterator statements = source.getDefaultStatements(value, null, null); - while (statements.hasNext()) { - LenientStatement statement = (LenientStatement) statements.next(); - - // If the statement points to a blank node, recurse and describe - // that - if (statement.getObject() instanceof BNode) { - // Check if we covered the blank node already to prevent loops - if (!alreadyDescribed.contains(statement.getObject())) { - descriptions.addAll(describe(statement.getObject(), source, alreadyDescribed)); + + // do forward, then back links + for (int i = 0; i <= 1; i++) { + if (direction != -1 && direction != i) continue; + + Iterator statements; + if (i == 0) // forward + statements = source.getDefaultGraphStatements(value, null, null); + else // back links + statements = source.getDefaultGraphStatements(null, null, value); + + // Accumulate statements and objects by predicate. + HashMap statementsByPred = new HashMap(); + HashMap objectsByPred = new HashMap(); + + while (statements.hasNext()) { + LenientStatement statement = (LenientStatement) statements.next(); + + Value predicate = statement.getPredicate(); + + if (!statementsByPred.containsKey(predicate)) { + statementsByPred.put(predicate, new ArrayList()); + objectsByPred.put(predicate, new HashSet()); + } + + ((ArrayList)statementsByPred.get(predicate)).add(statement); + + Value object; + if (i == 0) + object = statement.getObject(); + else + object = statement.getSubject(); + + // If the statement points to a blank node or URI, add it to the list objects to describe. + if (object instanceof BNode || object instanceof URI) { + // Check if we covered the node already to prevent loops + if (!alreadyDescribed.contains(object)) { + ((HashSet)objectsByPred.get(predicate)).add(object); + } + } + } + + // Don't include predicates for backlinks that have too many statement instances. + for (Iterator si = statementsByPred.keySet().iterator(); si.hasNext(); ) { + Object predicate = si.next(); + ArrayList slist = (ArrayList)statementsByPred.get(predicate); + if ((i == 0 && slist.size() < (1024>>depth)) || (i == 1 && slist.size() < (512>>depth))) { + // Add all of the statements for this predicate. + descriptions.addAll(slist); + + // For each of the nodes on the other end of the statement + // that haven't yet been described (checked above), add + // descriptions for them too. For BNodes, do it recursively. + // But for URIs, just include statements on some common properties. + for (Iterator j = ((HashSet)objectsByPred.get(predicate)).iterator(); j.hasNext(); ) { + Value v = (Value)j.next(); + if (v instanceof BNode) { + descriptions.addAll(describe(v, source, alreadyDescribed, direction, depth+1)); + } else { + descriptions.addAll(toCollection(source.getDefaultGraphStatements(v, valueFactory.createURI("http://www.w3.org/2000/01/rdf-schema#label"), null))); + descriptions.addAll(toCollection(source.getDefaultGraphStatements(v, valueFactory.createURI("http://purl.org/dc/elements/1.1/title"), null))); + descriptions.addAll(toCollection(source.getDefaultGraphStatements(v, valueFactory.createURI("http://xmlns.com/foaf/0.1/name"), null))); + } + } } } - descriptions.add(statements.next()); } + return descriptions; } + /** + * Makes a collection of statements unique by removing duplicate elements. + * This preserves the order of the list and keeps the first occurrences of elements. + */ + private Collection uniq(Collection x) { + HashSet y = new HashSet(); + Collection z = new ArrayList(); + for (Iterator i = x.iterator(); i.hasNext(); ) { + LenientStatement a = (LenientStatement)i.next(); + StatementWrapper w = new StatementWrapper(a); + if (y.contains(w)) continue; + y.add(w); + z.add(a); + } + return z; + } + + private class StatementWrapper { + LenientStatement s; + public StatementWrapper(LenientStatement s) { this.s = s; } + public int hashCode() { + return s.getSubject().hashCode() ^ s.getPredicate().hashCode() ^ s.getObject().hashCode(); + } + public boolean equals(Object other) { + StatementWrapper t = (StatementWrapper)other; + return s.getSubject().equals(t.s.getSubject()) && s.getPredicate().equals(t.s.getPredicate()) && s.getObject().equals(t.s.getObject()); + } + } + + private ArrayList toCollection(Iterator iter) { + ArrayList ret = new ArrayList(); + while (iter.hasNext()) + ret.add(iter.next()); + return ret; + } } diff -urN --exclude=.svn --exclude=.settings --exclude=META-INF --exclude='*.jj' --exclude='*.rej' work-copy/src/main/name/levering/ryan/sparql/logic/DefaultEffectiveBooleanLogic.java work-copy/src/main/name/levering/ryan/sparql/logic/DefaultEffectiveBooleanLogic.java --- work-copy/src/main/name/levering/ryan/sparql/logic/DefaultEffectiveBooleanLogic.java 2007-10-07 07:19:19.000000000 -0400 +++ work-copy/src/main/name/levering/ryan/sparql/logic/DefaultEffectiveBooleanLogic.java 2008-07-11 15:28:33.000000000 -0400 @@ -8,6 +8,7 @@ import name.levering.ryan.sparql.common.SPARQLConstants; import name.levering.ryan.sparql.model.logic.helper.EffectiveBooleanLogic; import name.levering.ryan.sparql.model.logic.helper.ValueConversionLogic; +import name.levering.ryan.sparql.logic.expression.TypeError; import name.levering.ryan.sparql.common.Literal; import name.levering.ryan.sparql.common.URI; @@ -63,6 +64,10 @@ return SPARQLConstants.FALSE_LITERAL; } + if (!(value instanceof Literal)) { + throw new TypeError("The value " + value + " cannot be used in some evaluated expression because it cannot be coerced to a boolean value"); + } + Literal litValue = (Literal) value; URI datatype = litValue.getDatatype(); @@ -104,15 +109,15 @@ } if (datatype.equals(SPARQLConstants.INTEGER_TYPE)) { - int java = this.converter.convertInteger(litValue); - if (java == 0) { + java.math.BigInteger v = this.converter.convertInteger(litValue); + if (v.equals(java.math.BigInteger.ZERO)) { return SPARQLConstants.FALSE_LITERAL; } } if (datatype.equals(SPARQLConstants.DECIMAL_TYPE)) { - long java = this.converter.convertDecimal(litValue); - if (java == 0) { + java.math.BigDecimal v = this.converter.convertDecimal(litValue); + if (v.equals(java.math.BigDecimal.ZERO)) { return SPARQLConstants.FALSE_LITERAL; } } diff -urN --exclude=.svn --exclude=.settings --exclude=META-INF --exclude='*.jj' --exclude='*.rej' work-copy/src/main/name/levering/ryan/sparql/logic/DefaultGraphTranslationLogic.java work-copy/src/main/name/levering/ryan/sparql/logic/DefaultGraphTranslationLogic.java --- work-copy/src/main/name/levering/ryan/sparql/logic/DefaultGraphTranslationLogic.java 2007-10-07 07:19:19.000000000 -0400 +++ work-copy/src/main/name/levering/ryan/sparql/logic/DefaultGraphTranslationLogic.java 2007-10-21 12:35:15.000000000 -0400 @@ -5,18 +5,20 @@ import java.util.Iterator; import java.util.Map; -import name.levering.ryan.sparql.common.BNode; import name.levering.ryan.sparql.common.RdfBindingRow; import name.levering.ryan.sparql.common.RdfBindingSet; import name.levering.ryan.sparql.common.RdfGraph; -import name.levering.ryan.sparql.common.SPARQLValueFactory; -import name.levering.ryan.sparql.common.URI; -import name.levering.ryan.sparql.common.Value; import name.levering.ryan.sparql.common.impl.RdfGraphImpl; +import name.levering.ryan.sparql.common.SPARQLValueFactory; import name.levering.ryan.sparql.common.impl.StatementImpl; +import name.levering.ryan.sparql.model.TripleConstraint; import name.levering.ryan.sparql.model.data.UnboundStatement; import name.levering.ryan.sparql.model.logic.helper.GraphTranslationLogic; +import name.levering.ryan.sparql.common.BNode; +import name.levering.ryan.sparql.common.URI; +import name.levering.ryan.sparql.common.Value; + public class DefaultGraphTranslationLogic implements GraphTranslationLogic { private final SPARQLValueFactory valueFactory; diff -urN --exclude=.svn --exclude=.settings --exclude=META-INF --exclude='*.jj' --exclude='*.rej' work-copy/src/main/name/levering/ryan/sparql/logic/DefaultIntersectOrderLogic.java work-copy/src/main/name/levering/ryan/sparql/logic/DefaultIntersectOrderLogic.java --- work-copy/src/main/name/levering/ryan/sparql/logic/DefaultIntersectOrderLogic.java 2006-08-20 20:01:01.000000000 -0400 +++ work-copy/src/main/name/levering/ryan/sparql/logic/DefaultIntersectOrderLogic.java 2007-10-21 12:35:15.000000000 -0400 @@ -119,6 +119,7 @@ for (int i = 0; i < otherSets.size(); i++) { if (otherSets.get(i) == set || otherSets.get(i) == oldAgg) { otherSets.remove(i); + i--; } } // And check to make sure this wasn't a final set, so we diff -urN --exclude=.svn --exclude=.settings --exclude=META-INF --exclude='*.jj' --exclude='*.rej' work-copy/src/main/name/levering/ryan/sparql/logic/DefaultNumericPromotionLogic.java work-copy/src/main/name/levering/ryan/sparql/logic/DefaultNumericPromotionLogic.java --- work-copy/src/main/name/levering/ryan/sparql/logic/DefaultNumericPromotionLogic.java 2007-10-07 07:19:19.000000000 -0400 +++ work-copy/src/main/name/levering/ryan/sparql/logic/DefaultNumericPromotionLogic.java 2008-08-09 17:04:42.000000000 -0400 @@ -56,6 +56,16 @@ URI leftDatatype = leftLiteral.getDatatype(); URI rightDatatype = rightLiteral.getDatatype(); + + if (leftDatatype == null) + leftDatatype = SPARQLConstants.STRING_TYPE; + if (rightDatatype == null) + rightDatatype = SPARQLConstants.STRING_TYPE; + + // Exit fast because if we are dealing with non-numeric types like dateTime, + // we don't want to attempt to promote to a number. + if (leftDatatype.equals(rightDatatype)) + return literals; if (leftDatatype.equals(SPARQLConstants.DOUBLE_TYPE) || rightDatatype.equals(SPARQLConstants.DOUBLE_TYPE)) { @@ -67,8 +77,14 @@ return new Literal[] { promoteFloat(leftLiteral), promoteFloat(rightLiteral) }; } - return new Literal[] { promoteDecimal(leftLiteral), - promoteDecimal(rightLiteral) }; + + if (leftDatatype.equals(SPARQLConstants.DECIMAL_TYPE) + || rightDatatype.equals(SPARQLConstants.DECIMAL_TYPE)) { + return new Literal[] { promoteDecimal(leftLiteral), + promoteDecimal(rightLiteral) }; + } + return new Literal[] { promoteInteger(leftLiteral), + promoteInteger(rightLiteral) }; } @@ -83,7 +99,7 @@ try { result = Double.valueOf(numeral.getLabel()); } catch (NumberFormatException e) { - throw new TypeError("Cannot promote non-numeral to a double value"); + throw new TypeError("Cannot promote non-numeral (" + numeral.getLabel() + "^^" + numeral.getDatatype() + ") to a double value"); } return this.factory.createLiteral(result.toString(), SPARQLConstants.DOUBLE_TYPE); } @@ -99,7 +115,7 @@ try { result = Float.valueOf(numeral.getLabel()); } catch (NumberFormatException e) { - throw new TypeError("Cannot promote non-numeral to a float value"); + throw new TypeError("Cannot promote non-numeral (" + numeral.getLabel() + "^^" + numeral.getDatatype() + ") to a float value"); } return this.factory.createLiteral(result.toString(), SPARQLConstants.FLOAT_TYPE); } @@ -111,12 +127,28 @@ * @return a xsd:double literal with the passed in literals value */ private Literal promoteDecimal(Literal numeral) { - Long result; + java.math.BigDecimal result; try { - result = Long.valueOf(numeral.getLabel()); + result = new java.math.BigDecimal(numeral.getLabel()); } catch (NumberFormatException e) { - throw new TypeError("Cannot promote non-numeral to a decimal value"); + throw new TypeError("Cannot promote " + numeral.getLabel() + " to a decimal value"); } return this.factory.createLiteral(result.toString(), SPARQLConstants.DECIMAL_TYPE); } + + /** + * Promotes a literal to an integer datatype, reparsing the label. + * + * @param numeral the literal to promote to a decimal datatype + * @return a xsd:double literal with the passed in literals value + */ + private Literal promoteInteger(Literal numeral) { + java.math.BigInteger result; + try { + result = new java.math.BigInteger(numeral.getLabel()); + } catch (NumberFormatException e) { + throw new TypeError("Cannot promote non-numeral (" + numeral.getLabel() + "^^" + numeral.getDatatype() + ") to an integer value"); + } + return this.factory.createLiteral(result.toString(), SPARQLConstants.INTEGER_TYPE); + } } diff -urN --exclude=.svn --exclude=.settings --exclude=META-INF --exclude='*.jj' --exclude='*.rej' work-copy/src/main/name/levering/ryan/sparql/logic/DefaultOrderExpressionLogic.java work-copy/src/main/name/levering/ryan/sparql/logic/DefaultOrderExpressionLogic.java --- work-copy/src/main/name/levering/ryan/sparql/logic/DefaultOrderExpressionLogic.java 2006-08-20 20:01:01.000000000 -0400 +++ work-copy/src/main/name/levering/ryan/sparql/logic/DefaultOrderExpressionLogic.java 2008-04-27 11:18:16.000000000 -0400 @@ -10,6 +10,7 @@ import java.util.Comparator; import java.util.Iterator; import java.util.List; +import java.util.Set; import name.levering.ryan.sparql.common.RdfBindingRow; import name.levering.ryan.sparql.common.RdfBindingSet; @@ -51,6 +52,11 @@ this.data = data; this.orderingLogic = orderingLogic; } + + public Set getVariables() { + return this.data.getExpression().getVariables(); + } + /** * Orders the binding set, by comparing the Value result of each expression @@ -67,6 +73,9 @@ sortedList.add(row); } Collections.sort(sortedList, new ExpressionComparator(this.data.getExpression())); + + if (data.getDirection() == OrderExpressionData.DESCENDING) + Collections.reverse(sortedList); RdfBindingSetImpl newSet = new RdfBindingSetImpl(set.getVariables()); newSet.setOrdered(true); diff -urN --exclude=.svn --exclude=.settings --exclude=META-INF --exclude='*.jj' --exclude='*.rej' work-copy/src/main/name/levering/ryan/sparql/logic/DefaultSelectQueryLogic.java work-copy/src/main/name/levering/ryan/sparql/logic/DefaultSelectQueryLogic.java --- work-copy/src/main/name/levering/ryan/sparql/logic/DefaultSelectQueryLogic.java 2006-08-20 20:01:01.000000000 -0400 +++ work-copy/src/main/name/levering/ryan/sparql/logic/DefaultSelectQueryLogic.java 2008-04-27 11:05:53.000000000 -0400 @@ -6,12 +6,14 @@ package name.levering.ryan.sparql.logic; import java.util.Collection; +import java.util.HashSet; import java.util.List; import name.levering.ryan.sparql.common.RdfBindingSet; import name.levering.ryan.sparql.common.RdfSource; import name.levering.ryan.sparql.model.GroupConstraint; import name.levering.ryan.sparql.model.data.SelectQueryData; +import name.levering.ryan.sparql.model.logic.ConstraintLogic; import name.levering.ryan.sparql.model.logic.OrderExpressionLogic; import name.levering.ryan.sparql.model.logic.SelectQueryLogic; import name.levering.ryan.sparql.model.logic.helper.SetDistinctionLogic; @@ -36,7 +38,7 @@ /** * The logic used to do the set projection onto the result variables. */ - private final SetProjectionLogic logic; + private final SetProjectionLogic projectionLogic; /** * The logic to remove duplicates from a set. @@ -58,9 +60,9 @@ * @param rangeLogic the logic to use to limit and offset */ public DefaultSelectQueryLogic(SelectQueryData data, - SetProjectionLogic logic, SetDistinctionLogic distinctLogic, SetRangeLogic rangeLogic) { + SetProjectionLogic projectionLogic, SetDistinctionLogic distinctLogic, SetRangeLogic rangeLogic) { this.data = data; - this.logic = logic; + this.projectionLogic = projectionLogic; this.distinctLogic = distinctLogic; this.rangeLogic = rangeLogic; } @@ -74,46 +76,30 @@ * @return an RDF graph containing the formed triples */ public RdfBindingSet execute(RdfSource source) { + ConstraintLogic.CallParams p = new ConstraintLogic.CallParams(); + p.source = source; + // Grab the necessary fields from the data GroupConstraint constraint = this.data.getConstraint(); - Collection defaultDatasets = this.data.getDefaultDatasets(); - Collection namedDatasets = this.data.getNamedDatasets(); - List orderExpressions = this.data.getOrderExpressions(); - List queryExpressions = this.data.getQueryVariables(); - int limit = this.data.getLimit(); - int offset = this.data.getOffset(); - boolean distinct = this.data.getDistinct(); - + p.defaultDatasets = this.data.getDefaultDatasets(); + p.namedDatasets = this.data.getNamedDatasets(); + p.orderExpressions = this.data.getOrderExpressions(); + if (this.data.getQueryVariables().isEmpty()) + p.distinguishedVariables = new HashSet(this.data.getVariables()); + else + p.distinguishedVariables = new HashSet(this.data.getQueryVariables()); + p.limit = this.data.getLimit(); + p.offset = this.data.getOffset() > 0 ? this.data.getOffset() : 0; + if (this.data.getDistinct()) + p.distinct = ConstraintLogic.CallParams.DistinctType.DISTINCT; + + p.rangeLogic = this.rangeLogic; + p.distinctionLogic = this.distinctLogic; + p.projectionLogic = this.projectionLogic; + // First bind the result table - RdfBindingSet results = constraint.constrain(null, - source, defaultDatasets, namedDatasets); - - // Now project to the solution set or the variable set - if (!queryExpressions.isEmpty()) { - results = this.logic.project(results, queryExpressions); - } else { - results = this.logic.project(results, this.data.getVariables()); - } - - // Now apply distinct - if (distinct) { - results = this.distinctLogic.makeDistinct(results); - } - - // Now apply ordering in reverse order - for (int i = orderExpressions.size() - 1; i >= 0; i--) { - OrderExpressionLogic orderer = (OrderExpressionLogic) orderExpressions.get(i); - results = orderer.order(results); - } - - // Now apply limiting and offsetting - if (limit >= 0) { - results = this.rangeLogic.limit(results, limit); - } - if (offset >= 0) { - results = this.rangeLogic.offset(results, offset); - } - + RdfBindingSet results = constraint.constrain(p); + return results; } diff -urN --exclude=.svn --exclude=.settings --exclude=META-INF --exclude='*.jj' --exclude='*.rej' work-copy/src/main/name/levering/ryan/sparql/logic/DefaultValueConversionLogic.java work-copy/src/main/name/levering/ryan/sparql/logic/DefaultValueConversionLogic.java --- work-copy/src/main/name/levering/ryan/sparql/logic/DefaultValueConversionLogic.java 2007-10-07 07:19:19.000000000 -0400 +++ work-copy/src/main/name/levering/ryan/sparql/logic/DefaultValueConversionLogic.java 2008-08-09 17:06:38.000000000 -0400 @@ -57,26 +57,34 @@ if (datatype.equals(SPARQLConstants.DOUBLE_TYPE)) { return new Double(convertDouble(literal)); } - if (datatype.equals(SPARQLConstants.INTEGER_TYPE)) { - return new Integer(convertInteger(literal)); - } if (datatype.equals(SPARQLConstants.FLOAT_TYPE)) { return new Float(convertFloat(literal)); } if (datatype.equals(SPARQLConstants.DECIMAL_TYPE)) { - return new Long(convertDecimal(literal)); + return convertDecimal(literal); + } + if (datatype.equals(SPARQLConstants.INTEGER_TYPE) + || datatype.equals(SPARQLConstants.NONPOSITIVEINTEGER_TYPE) || datatype.equals(SPARQLConstants.NEGATIVEINTEGER_TYPE) || datatype.equals(SPARQLConstants.NONNEGATIVEINTEGER_TYPE) || datatype.equals(SPARQLConstants.POSITIVEINTEGER_TYPE) + || datatype.equals(SPARQLConstants.LONG_TYPE) + || datatype.equals(SPARQLConstants.UNSIGNEDLONG_TYPE) + || datatype.equals(SPARQLConstants.INT_TYPE) || datatype.equals(SPARQLConstants.SHORT_TYPE) || datatype.equals(SPARQLConstants.BYTE_TYPE) + || datatype.equals(SPARQLConstants.UNSIGNEDINT_TYPE) || datatype.equals(SPARQLConstants.UNSIGNEDSHORT_TYPE) || datatype.equals(SPARQLConstants.UNSIGNEDBYTE_TYPE)) { + return convertInteger(literal); } if (datatype.equals(SPARQLConstants.BOOLEAN_TYPE)) { return new Boolean(convertBoolean(literal)); } if (datatype.equals(SPARQLConstants.DATE_TYPE)) { + return convertDate(literal); + } + if (datatype.equals(SPARQLConstants.DATETIME_TYPE)) { return convertDateTime(literal); } if (datatype.equals(SPARQLConstants.STRING_TYPE)) { return convertString(literal); } throw new ConversionException( - "Literal can't be converted to primitive object"); + "Literal can't be converted to primitive object: Unrecognized datatype: " + datatype); } else { return convertString(literal); } @@ -95,14 +103,14 @@ if (o instanceof Double) { return convertDouble(((Double) o).doubleValue()); } - if (o instanceof Integer) { - return convertInteger(((Integer) o).intValue()); + if (o instanceof java.math.BigInteger) { + return convertInteger((java.math.BigInteger) o); } if (o instanceof Float) { return convertFloat(((Float) o).floatValue()); } - if (o instanceof Long) { - return convertDecimal(((Long) o).longValue()); + if (o instanceof java.math.BigDecimal) { + return convertDecimal((java.math.BigDecimal) o); } if (o instanceof Boolean) { return convertBoolean(((Boolean) o).booleanValue()); @@ -191,27 +199,27 @@ } /** - * Converts a double value to a xsd:integer type literal. + * Converts a java.math.BigInteger value to a xsd:integer type literal. * - * @param value the int value to convert + * @param value the java.math.BigInteger value to convert * @return a correctly formed xsd:integer literal */ - public Literal convertInteger(int value) { - return this.factory.createLiteral(Integer.toString(value), + public Literal convertInteger(java.math.BigInteger value) { + return this.factory.createLiteral(value.toString(), SPARQLConstants.INTEGER_TYPE); } /** - * Converts a literal to a int value. + * Converts a literal to a java.math.BigInteger value. * * @param literal the xsd:integer to convert - * @return a int value equating to the literal value + * @return a java.math.BigInteger value equating to the literal value * @throws ConversionException if the literal is of an incorrect type or is * unparseable */ - public int convertInteger(Literal literal) { + public java.math.BigInteger convertInteger(Literal literal) { try { - return Integer.parseInt(literal.getLabel()); + return new java.math.BigInteger(literal.getLabel()); } catch (NumberFormatException e) { throw new ConversionException( "Could not parse literal label to int type"); @@ -232,6 +240,24 @@ /** * Converts a literal to a DateTime value. * + * @param literal the xsd:date to convert + * @return a DateTime value equating to the literal value + * @throws ConversionException if the literal is of an incorrect type or is + * unparseable + */ + public DateTime convertDate(Literal literal) { + try { + return new DateTime(literal.getLabel(), literal.getDatatype()); + } catch (IllegalArgumentException e) { + System.err.println(e); + throw new ConversionException( + "Could not parse literal label to datetime type"); + } + } + + /** + * Converts a literal to a DateTime value. + * * @param literal the xsd:dateTime to convert * @return a DateTime value equating to the literal value * @throws ConversionException if the literal is of an incorrect type or is @@ -275,27 +301,27 @@ } /** - * Converts a long value to a xsd:decimal type literal. + * Converts a java.math.BigDecimal value to a xsd:decimal type literal. * - * @param value the long value to convert + * @param value the java.math.BigDecimal value to convert * @return a correctly formed xsd:decimal literal */ - public Literal convertDecimal(long value) { - return this.factory.createLiteral(Long.toString(value), + public Literal convertDecimal(java.math.BigDecimal value) { + return this.factory.createLiteral(value.toString(), SPARQLConstants.DECIMAL_TYPE); } /** - * Converts a literal to a long value. + * Converts a literal to a java.math.BigDecimal value. * * @param literal the xsd:decimal to convert - * @return a long value equating to the literal value + * @return a java.math.BigDecimal value equating to the literal value * @throws ConversionException if the literal is of an incorrect type or is * unparseable */ - public long convertDecimal(Literal literal) { + public java.math.BigDecimal convertDecimal(Literal literal) { try { - return Long.parseLong(literal.getLabel()); + return new java.math.BigDecimal(literal.getLabel()); } catch (NumberFormatException e) { throw new ConversionException( "Could not parse literal label to long type"); diff -urN --exclude=.svn --exclude=.settings --exclude=META-INF --exclude='*.jj' --exclude='*.rej' work-copy/src/main/name/levering/ryan/sparql/logic/DefaultValueOrderingLogic.java work-copy/src/main/name/levering/ryan/sparql/logic/DefaultValueOrderingLogic.java --- work-copy/src/main/name/levering/ryan/sparql/logic/DefaultValueOrderingLogic.java 2007-10-07 07:19:19.000000000 -0400 +++ work-copy/src/main/name/levering/ryan/sparql/logic/DefaultValueOrderingLogic.java 2008-08-07 07:55:54.000000000 -0400 @@ -1,5 +1,10 @@ package name.levering.ryan.sparql.logic; +import name.levering.ryan.sparql.common.SPARQLConstants; +import name.levering.ryan.sparql.common.impl.DateTime; + +import name.levering.ryan.sparql.model.logic.NumericPromotionLogic; +import name.levering.ryan.sparql.model.logic.helper.ValueConversionLogic; import name.levering.ryan.sparql.model.logic.helper.ValueOrderingLogic; import name.levering.ryan.sparql.common.BNode; @@ -22,6 +27,13 @@ * @version 1.0 */ public class DefaultValueOrderingLogic implements ValueOrderingLogic { + NumericPromotionLogic promoter; + ValueConversionLogic converter; + + public DefaultValueOrderingLogic(NumericPromotionLogic promoter, ValueConversionLogic converter) { + this.promoter = promoter; + this.converter = converter; + } /** * Compares two value objects according to section 10.1. @@ -64,14 +76,44 @@ return -1; } - // First value is an untyped literal - if (value1 instanceof Literal && ((Literal) value1).getDatatype() == null) { - if (value2 == null || value2 instanceof BNode || value2 instanceof URI) { + // First value is a literal + if (value1 instanceof Literal) { + if (value2 == null || value2 instanceof BNode || value2 instanceof URI) return 1; + + if (value2 instanceof Literal) { + if (((Literal) value1).getDatatype() == null && ((Literal) value2).getDatatype() == null) + return ((Literal) value1).getLabel().compareTo(((Literal) value2).getLabel()); + + if (((Literal) value1).getDatatype() == null) + return -1; + if (((Literal) value2).getDatatype() == null) + return 1; + + if (((Literal) value1).getDatatype().equals(SPARQLConstants.STRING_TYPE) && ((Literal) value2).getDatatype().equals(SPARQLConstants.STRING_TYPE)) + return ((Literal) value1).getLabel().compareTo(((Literal) value2).getLabel()); + + Literal[] promoted = promoter.promote(new Literal[] { (Literal) value1, (Literal) value2 } ); + + Object v1 = converter.convertLiteral(promoted[0]); + Object v2 = converter.convertLiteral(promoted[1]); + + if (v1 instanceof Double) + return ((Double)v1).compareTo((Double)v2); + if (v1 instanceof Float) + return ((Float)v1).compareTo((Float)v2); + if (v1 instanceof java.math.BigDecimal) + return ((java.math.BigDecimal)v1).compareTo((java.math.BigDecimal)v2); + if (v1 instanceof java.math.BigInteger) + return ((java.math.BigInteger)v1).compareTo((java.math.BigInteger)v2); + if (v1 instanceof Boolean) + return ((Boolean)v1).compareTo((Boolean)v2); + if (v1 instanceof DateTime) + return ((DateTime)v1).compareTo((DateTime)v2); + if (v1 instanceof String) + return ((String)v1).compareTo((String)v2); } - if (value2 instanceof Literal && ((Literal) value2).getDatatype() == null) { - return ((Literal) value1).getLabel().compareTo(((Literal) value2).getLabel()); - } + return -1; } diff -urN --exclude=.svn --exclude=.settings --exclude=META-INF --exclude='*.jj' --exclude='*.rej' work-copy/src/main/name/levering/ryan/sparql/logic/DefaultVariableLogic.java work-copy/src/main/name/levering/ryan/sparql/logic/DefaultVariableLogic.java --- work-copy/src/main/name/levering/ryan/sparql/logic/DefaultVariableLogic.java 2007-10-07 07:19:19.000000000 -0400 +++ work-copy/src/main/name/levering/ryan/sparql/logic/DefaultVariableLogic.java 1969-12-31 19:00:00.000000000 -0500 @@ -1,50 +0,0 @@ -/* - * SPARQL Engine - * Copyright (C) 2005 Ryan Levering, All rights reserved. - * See LICENSE for full license information - */ -package name.levering.ryan.sparql.logic; - -import name.levering.ryan.sparql.common.RdfBindingRow; -import name.levering.ryan.sparql.common.Variable; -import name.levering.ryan.sparql.model.logic.ExpressionLogic; - -import name.levering.ryan.sparql.common.Value; - -/** - * The main lowest level logic in variable expression resolution, this will - * return the result of the variable binding in the current row being evaluated. - * - * @author Ryan Levering - * @version 1.0 - */ -public class DefaultVariableLogic implements ExpressionLogic { - - /** - * The variable to return the value of in the current row. - */ - private final Variable variable; - - /** - * Creates a new default logic that returns the value bound to a variable in - * a binding row. - * - * @param variable the variable to checking the binding for - */ - public DefaultVariableLogic(Variable variable) { - this.variable = variable; - } - - /** - * Returns the object bound to the variable header in the current binding - * row. - * - * @param bindings the bindings used to evaluate the variable - * @return the current bound Value object to the Variable in the row, or - * null if it isn't bound - */ - public Value evaluate(RdfBindingRow bindings) { - return bindings.getValue(this.variable); - } - -} diff -urN --exclude=.svn --exclude=.settings --exclude=META-INF --exclude='*.jj' --exclude='*.rej' work-copy/src/main/name/levering/ryan/sparql/logic/expression/AdditionLogic.java work-copy/src/main/name/levering/ryan/sparql/logic/expression/AdditionLogic.java --- work-copy/src/main/name/levering/ryan/sparql/logic/expression/AdditionLogic.java 2006-08-20 20:01:00.000000000 -0400 +++ work-copy/src/main/name/levering/ryan/sparql/logic/expression/AdditionLogic.java 2008-07-11 15:28:33.000000000 -0400 @@ -38,8 +38,8 @@ * @param num2 the second number to add * @return the sum of the two numbers */ - public int evaluateInteger(int num1, int num2) { - return num1 + num2; + public java.math.BigInteger evaluateInteger(java.math.BigInteger num1, java.math.BigInteger num2) { + return num1.add(num2); } /** @@ -71,8 +71,8 @@ * @param num2 the second number to add * @return the sum of the two numbers */ - public long evaluateDecimal(long num1, long num2) { - return num1 + num2; + public java.math.BigDecimal evaluateDecimal(java.math.BigDecimal num1, java.math.BigDecimal num2) { + return num1.add(num2); } } diff -urN --exclude=.svn --exclude=.settings --exclude=META-INF --exclude='*.jj' --exclude='*.rej' work-copy/src/main/name/levering/ryan/sparql/logic/expression/BinaryLogic.java work-copy/src/main/name/levering/ryan/sparql/logic/expression/BinaryLogic.java --- work-copy/src/main/name/levering/ryan/sparql/logic/expression/BinaryLogic.java 2007-10-07 07:19:19.000000000 -0400 +++ work-copy/src/main/name/levering/ryan/sparql/logic/expression/BinaryLogic.java 2008-05-03 17:13:37.000000000 -0400 @@ -59,5 +59,20 @@ * @return the result of evaluating the operation */ public abstract Value evaluate(Value leftValue, Value rightValue); + + public java.util.Set getVariables() { + java.util.HashSet ret = new java.util.HashSet(); + ret.addAll(this.data.getLeftExpression().getVariables()); + ret.addAll(this.data.getRightExpression().getVariables()); + return ret; + } + + public ExpressionLogic getLeftExpression() { + return this.data.getLeftExpression(); + } + + public ExpressionLogic getRightExpression() { + return this.data.getRightExpression(); + } } diff -urN --exclude=.svn --exclude=.settings --exclude=META-INF --exclude='*.jj' --exclude='*.rej' work-copy/src/main/name/levering/ryan/sparql/logic/expression/DivisionLogic.java work-copy/src/main/name/levering/ryan/sparql/logic/expression/DivisionLogic.java --- work-copy/src/main/name/levering/ryan/sparql/logic/expression/DivisionLogic.java 2006-08-20 20:01:00.000000000 -0400 +++ work-copy/src/main/name/levering/ryan/sparql/logic/expression/DivisionLogic.java 2008-07-11 15:28:33.000000000 -0400 @@ -38,8 +38,8 @@ * @param num2 the second number to divide * @return the result of division of the two numbers */ - public int evaluateInteger(int num1, int num2) { - return num1 / num2; + public java.math.BigInteger evaluateInteger(java.math.BigInteger num1, java.math.BigInteger num2) { + return num1.divide(num2); } /** @@ -71,8 +71,8 @@ * @param num2 the second number to divide * @return the result of division of the two numbers */ - public long evaluateDecimal(long num1, long num2) { - return num1 / num2; + public java.math.BigDecimal evaluateDecimal(java.math.BigDecimal num1, java.math.BigDecimal num2) { + return num1.divide(num2); } } diff -urN --exclude=.svn --exclude=.settings --exclude=META-INF --exclude='*.jj' --exclude='*.rej' work-copy/src/main/name/levering/ryan/sparql/logic/expression/EqualsLogic.java work-copy/src/main/name/levering/ryan/sparql/logic/expression/EqualsLogic.java --- work-copy/src/main/name/levering/ryan/sparql/logic/expression/EqualsLogic.java 2007-10-07 07:19:19.000000000 -0400 +++ work-copy/src/main/name/levering/ryan/sparql/logic/expression/EqualsLogic.java 2008-07-11 15:28:33.000000000 -0400 @@ -34,71 +34,9 @@ super(data, numLogic, converter); } - /** - * Evaluates any integer comparison. - * - * @param num1 the first number to compare - * @param num2 the second number to compare - * @return true if the two numbers are equal - */ - public boolean evaluateInteger(int num1, int num2) { - return num1 == num2; - } - - /** - * Evaluates any float comparison. - * - * @param num1 the first number to compare - * @param num2 the second number to compare - * @return true if the two numbers are equal - */ - public boolean evaluateFloat(float num1, float num2) { - return num1 == num2; - } - - /** - * Evaluates any double comparison. - * - * @param num1 the first number to compare - * @param num2 the second number to compare - * @return true if the two numbers are equal - */ - public boolean evaluateDouble(double num1, double num2) { - return num1 == num2; - } - - /** - * Evaluates any long comparison. - * - * @param num1 the first number to compare - * @param num2 the second number to compare - * @return true if the two numbers are equal - */ - public boolean evaluateDecimal(long num1, long num2) { - return num1 == num2; - } - - /** - * Evaluates any date/time comparison. - * - * @param cal1 the first date to compare - * @param cal2 the second date to compare - * @return true if the two date/times are equal - */ - public boolean evaluateDate(DateTime cal1, DateTime cal2) { - return cal1.compareTo(cal2) == 0; - } - - /** - * Evaluates any String comparison. - * - * @param string1 the first String to compare - * @param string2 the second String to compare - * @return true if the two Strings are equal - */ - public boolean evaluateString(String string1, String string2) { - return string1.equals(string2); - } + protected boolean comparisonResult(int comparison) { + return comparison == 0; + } /** * Evaluates any non-overloaded Value comparison. diff -urN --exclude=.svn --exclude=.settings --exclude=META-INF --exclude='*.jj' --exclude='*.rej' work-copy/src/main/name/levering/ryan/sparql/logic/expression/GreaterThanEqualsLogic.java work-copy/src/main/name/levering/ryan/sparql/logic/expression/GreaterThanEqualsLogic.java --- work-copy/src/main/name/levering/ryan/sparql/logic/expression/GreaterThanEqualsLogic.java 2007-10-07 07:19:19.000000000 -0400 +++ work-copy/src/main/name/levering/ryan/sparql/logic/expression/GreaterThanEqualsLogic.java 2008-07-11 15:28:33.000000000 -0400 @@ -36,73 +36,10 @@ super(data, numLogic, converter); } - /** - * Evaluates any integer comparison. - * - * @param num1 the first number to compare - * @param num2 the second number to compare - * @return true if the first number is greater than or equal to the second - */ - public boolean evaluateInteger(int num1, int num2) { - return num1 >= num2; - } - - /** - * Evaluates any float comparison. - * - * @param num1 the first number to compare - * @param num2 the second number to compare - * @return true if the first number is greater than or equal to the second - */ - public boolean evaluateFloat(float num1, float num2) { - return num1 >= num2; - } - - /** - * Evaluates any double comparison. - * - * @param num1 the first number to compare - * @param num2 the second number to compare - * @return true if the first number is greater than or equal to the second - */ - public boolean evaluateDouble(double num1, double num2) { - return num1 >= num2; - } - - /** - * Evaluates any long comparison. - * - * @param num1 the first number to compare - * @param num2 the second number to compare - * @return true if the first number is greater than or equal to the second - */ - public boolean evaluateDecimal(long num1, long num2) { - return num1 >= num2; - } - - /** - * Evaluates any date comparison. - * - * @param cal1 the first date to compare - * @param cal2 the second date to compare - * @return true if the first date is after or the same as the second - */ - public boolean evaluateDate(DateTime cal1, DateTime cal2) { - return cal1.compareTo(cal2) >= 0; - } - - /** - * Evaluates any String comparison. - * - * @param string1 the first String to compare - * @param string2 the second String to compare - * @return never - * @throws UnsupportedOperationException always - */ - public boolean evaluateString(String string1, String string2) { - throw new UnsupportedOperationException("Strings cannot be compared using a >= operation"); - } - + protected boolean comparisonResult(int comparison) { + return comparison >= 0; + } + /** * Evaluates any non-overloaded Value comparison. * diff -urN --exclude=.svn --exclude=.settings --exclude=META-INF --exclude='*.jj' --exclude='*.rej' work-copy/src/main/name/levering/ryan/sparql/logic/expression/GreaterThanLogic.java work-copy/src/main/name/levering/ryan/sparql/logic/expression/GreaterThanLogic.java --- work-copy/src/main/name/levering/ryan/sparql/logic/expression/GreaterThanLogic.java 2007-10-07 07:19:19.000000000 -0400 +++ work-copy/src/main/name/levering/ryan/sparql/logic/expression/GreaterThanLogic.java 2008-07-11 15:28:33.000000000 -0400 @@ -36,72 +36,9 @@ super(data, numLogic, converter); } - /** - * Evaluates any integer comparison. - * - * @param num1 the first number to compare - * @param num2 the second number to compare - * @return true if the first number is greater than the second - */ - public boolean evaluateInteger(int num1, int num2) { - return num1 > num2; - } - - /** - * Evaluates any float comparison. - * - * @param num1 the first number to compare - * @param num2 the second number to compare - * @return true if the first number is greater than the second - */ - public boolean evaluateFloat(float num1, float num2) { - return num1 > num2; - } - - /** - * Evaluates any double comparison. - * - * @param num1 the first number to compare - * @param num2 the second number to compare - * @return true if the first number is greater than the second - */ - public boolean evaluateDouble(double num1, double num2) { - return num1 > num2; - } - - /** - * Evaluates any long comparison. - * - * @param num1 the first number to compare - * @param num2 the second number to compare - * @return true if the first number is greater than the second - */ - public boolean evaluateDecimal(long num1, long num2) { - return num1 > num2; - } - - /** - * Evaluates any date comparison. - * - * @param cal1 the first date to compare - * @param cal2 the second date to compare - * @return true if the first date is after the second - */ - public boolean evaluateDate(DateTime cal1, DateTime cal2) { - return cal1.compareTo(cal2) > 0; - } - - /** - * Evaluates any String comparison. - * - * @param string1 the first String to compare - * @param string2 the second String to compare - * @return never - * @throws UnsupportedOperationException always - */ - public boolean evaluateString(String string1, String string2) { - throw new UnsupportedOperationException("Strings cannot be compared using a > operation"); - } + protected boolean comparisonResult(int comparison) { + return comparison > 0; + } /** * Evaluates any non-overloaded Value comparison. diff -urN --exclude=.svn --exclude=.settings --exclude=META-INF --exclude='*.jj' --exclude='*.rej' work-copy/src/main/name/levering/ryan/sparql/logic/expression/LessThanEqualsLogic.java work-copy/src/main/name/levering/ryan/sparql/logic/expression/LessThanEqualsLogic.java --- work-copy/src/main/name/levering/ryan/sparql/logic/expression/LessThanEqualsLogic.java 2007-10-07 07:19:19.000000000 -0400 +++ work-copy/src/main/name/levering/ryan/sparql/logic/expression/LessThanEqualsLogic.java 2008-07-11 15:28:33.000000000 -0400 @@ -36,72 +36,9 @@ super(data, numLogic, converter); } - /** - * Evaluates any integer comparison. - * - * @param num1 the first number to compare - * @param num2 the second number to compare - * @return true if the first number is less than or equal to the second - */ - public boolean evaluateInteger(int num1, int num2) { - return num1 <= num2; - } - - /** - * Evaluates any float comparison. - * - * @param num1 the first number to compare - * @param num2 the second number to compare - * @return true if the first number is less than or equal to the second - */ - public boolean evaluateFloat(float num1, float num2) { - return num1 <= num2; - } - - /** - * Evaluates any double comparison. - * - * @param num1 the first number to compare - * @param num2 the second number to compare - * @return true if the first number is less than or equal to the second - */ - public boolean evaluateDouble(double num1, double num2) { - return num1 <= num2; - } - - /** - * Evaluates any long comparison. - * - * @param num1 the first number to compare - * @param num2 the second number to compare - * @return true if the first number is less than or equal to the second - */ - public boolean evaluateDecimal(long num1, long num2) { - return num1 <= num2; - } - - /** - * Evaluates any date comparison. - * - * @param cal1 the first date to compare - * @param cal2 the second date to compare - * @return true if the first date is before or the same as the second - */ - public boolean evaluateDate(DateTime cal1, DateTime cal2) { - return cal1.compareTo(cal2) <= 0; - } - - /** - * Evaluates any String comparison. - * - * @param string1 the first String to compare - * @param string2 the second String to compare - * @return never - * @throws UnsupportedOperationException always - */ - public boolean evaluateString(String string1, String string2) { - throw new UnsupportedOperationException("Strings cannot be compared using a <= operation"); - } + protected boolean comparisonResult(int comparison) { + return comparison <= 0; + } /** * Evaluates any non-overloaded Value comparison. diff -urN --exclude=.svn --exclude=.settings --exclude=META-INF --exclude='*.jj' --exclude='*.rej' work-copy/src/main/name/levering/ryan/sparql/logic/expression/LessThanLogic.java work-copy/src/main/name/levering/ryan/sparql/logic/expression/LessThanLogic.java --- work-copy/src/main/name/levering/ryan/sparql/logic/expression/LessThanLogic.java 2007-10-07 07:19:19.000000000 -0400 +++ work-copy/src/main/name/levering/ryan/sparql/logic/expression/LessThanLogic.java 2008-07-11 15:28:33.000000000 -0400 @@ -36,72 +36,10 @@ super(data, numLogic, converter); } - /** - * Evaluates any integer comparison. - * - * @param num1 the first number to compare - * @param num2 the second number to compare - * @return true if the first number is less than the second - */ - public boolean evaluateInteger(int num1, int num2) { - return num1 < num2; - } - - /** - * Evaluates any float comparison. - * - * @param num1 the first number to compare - * @param num2 the second number to compare - * @return true if the first number is less than the second - */ - public boolean evaluateFloat(float num1, float num2) { - return num1 < num2; - } - - /** - * Evaluates any double comparison. - * - * @param num1 the