Package org.apache.jena.sparql.expr
Class NodeValue
- java.lang.Object
-
- org.apache.jena.sparql.expr.ExprNode
-
- org.apache.jena.sparql.expr.NodeValue
-
- All Implemented Interfaces:
Expr
- Direct Known Subclasses:
NodeValueBoolean,NodeValueDateTime,NodeValueDecimal,NodeValueDouble,NodeValueDuration,NodeValueFloat,NodeValueInteger,NodeValueLang,NodeValueNode,NodeValueSortKey,NodeValueString
public abstract class NodeValue extends ExprNode
-
-
Field Summary
Fields Modifier and Type Field Description static NodeValueFALSEstatic NodeValuenvDecimalONEstatic NodeValuenvDecimalZEROstatic NodeValuenvEmptyStringstatic NodeValuenvINFstatic NodeValuenvNaNstatic NodeValuenvNegINFstatic NodeValuenvNegZEROstatic NodeValuenvONEstatic NodeValuenvTENstatic NodeValuenvZEROstatic NodeValueTRUEstatic booleanVerboseExceptionsstatic booleanVerboseWarningsstatic javax.xml.datatype.DatatypeFactoryxmlDatatypeFactorystatic java.lang.StringxsdNamespace-
Fields inherited from interface org.apache.jena.sparql.expr.Expr
CMP_EQUAL, CMP_GREATER, CMP_INDETERMINATE, CMP_LESS, CMP_UNEQUAL, NONE
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Exprapply(ExprTransform transform)ExprapplyNodeTransform(NodeTransform transform)Rewrite, applying a node->node transformationNodeasNode()java.lang.StringasQuotedString()java.lang.StringasQuotedString(SerializationContext context)java.lang.StringasString()java.lang.StringasUnquotedString()static NodeValuebooleanReturn(boolean b)static ValueSpaceClassificationclassifyValueOp(NodeValue nv1, NodeValue nv2)static intcompare(NodeValue nv1, NodeValue nv2)Compare by value (and only value) if possible.static intcompareAlways(NodeValue nv1, NodeValue nv2)Compare by value if possible else compare by kind/type/lexical form Only use when you want an ordering regardless of form of NodeValue, for example in ORDER BYExprcopySubstitute(Binding binding)Deep copy with substitutionbooleanequals(Expr other, boolean bySyntax)General equality operation - consider this to be 'protected'NodeValueeval(Binding binding, FunctionEnv env)Evaluate this expression against the bindingNodeevalNode(Binding binding, ExecutionContext execCxt)booleangetBoolean()NodeValuegetConstant()NodeValue constant (returns null if not a constant)java.lang.StringgetDatatypeURI()javax.xml.datatype.XMLGregorianCalendargetDateTime()java.math.BigDecimalgetDecimal()doublegetDouble()javax.xml.datatype.DurationgetDuration()floatgetFloat()java.math.BigIntegergetInteger()java.lang.StringgetLang()NodegetNode()getNode - return the node form - may be null (use .asNode() to force to a node)NodeValueSortKeygetSortKey()java.lang.StringgetString()ValueSpaceClassificationgetValueSpace()booleanhasDateTime()inthashCode()Exprare used in both syntax and algebra.booleanhasNode()booleanisBlank()booleanisBoolean()booleanisConstant()Answer whether this is a constant expression - false includes "don't know" No constant folding so "false" from an expression that evaluates to a constantbooleanisDate()booleanisDateTime()booleanisDayTimeDuration()booleanisDecimal()booleanisDouble()booleanisDuration()booleanisFloat()booleanisGDay()booleanisGMonth()booleanisGMonthDay()booleanisGYear()booleanisGYearMonth()booleanisInteger()booleanisIRI()booleanisLangString()booleanisLiteral()booleanisNumber()booleanisSortKey()booleanisString()booleanisTime()booleanisTripleTerm()booleanisYearMonthDuration()static NodeValuemakeBoolean(boolean b)static NodeValuemakeDate(java.lang.String lexicalForm)static NodeValuemakeDate(java.util.Calendar cal)static NodeValuemakeDate(javax.xml.datatype.XMLGregorianCalendar cal)static NodeValuemakeDateTime(java.lang.String lexicalForm)static NodeValuemakeDateTime(java.util.Calendar cal)static NodeValuemakeDateTime(javax.xml.datatype.XMLGregorianCalendar cal)static NodeValuemakeDecimal(double d)static NodeValuemakeDecimal(long i)static NodeValuemakeDecimal(java.lang.String lexicalForm)static NodeValuemakeDecimal(java.math.BigDecimal d)static NodeValuemakeDouble(double d)static NodeValuemakeDuration(java.lang.String lexicalForm)static NodeValuemakeDuration(javax.xml.datatype.Duration duration)static NodeValuemakeFloat(float f)static NodeValuemakeInteger(long i)static NodeValuemakeInteger(java.lang.String lexicalForm)static NodeValuemakeInteger(java.math.BigInteger i)static NodeValuemakeLangString(java.lang.String s, java.lang.String lang)static NodeValuemakeNode(java.lang.String lexicalForm, java.lang.String langTag, java.lang.String datatype)static NodeValuemakeNode(java.lang.String lexicalForm, java.lang.String langTag, Node datatype)static NodeValuemakeNode(java.lang.String lexicalForm, RDFDatatype dtype)static NodeValuemakeNode(Node n)static NodeValuemakeNodeBoolean(boolean b)static NodeValuemakeNodeBoolean(java.lang.String lexicalForm)static NodeValuemakeNodeDate(java.lang.String lexicalForm)static NodeValuemakeNodeDate(java.util.Calendar date)static NodeValuemakeNodeDateTime(java.lang.String lexicalForm)static NodeValuemakeNodeDateTime(java.util.Calendar date)static NodeValuemakeNodeDecimal(java.lang.String lexicalForm)static NodeValuemakeNodeDecimal(java.math.BigDecimal decimal)static NodeValuemakeNodeDouble(double v)static NodeValuemakeNodeDouble(java.lang.String lexicalForm)static NodeValuemakeNodeDuration(javax.xml.datatype.Duration duration, Node node)static NodeValuemakeNodeFloat(float f)static NodeValuemakeNodeFloat(java.lang.String lexicalForm)static NodeValuemakeNodeInteger(long v)static NodeValuemakeNodeInteger(java.lang.String lexicalForm)static NodeValuemakeNodeString(java.lang.String string)static NodeValuemakeSortKey(java.lang.String s, java.lang.String collation)static NodeValuemakeString(java.lang.String s)static booleannotSameAs(Node n1, Node n2)Return true if the two Nodes are known to be different, return false if the two Nodes are known to be the same, else throw ExprEvalExceptionstatic booleannotSameAs(NodeValue nv1, NodeValue nv2)Return true if the two NodeValues are known to be different, return false if the two NodeValues are known to be the same, else throw ExprEvalExceptionstatic NodeValueparse(java.lang.String string)Convenience operation - parse a string to produce a NodeValue - common namespaces like xsd: are built-instatic voidraise(ExprException ex)static booleansameAs(NodeValue nv1, NodeValue nv2)Return true if the two NodeValues are known to be the same value return false if known to be different values, throw ExprEvalException otherwisestatic NodetoNode(NodeValue nv)java.lang.StringtoString()voidvisit(ExprVisitor visitor)abstract voidvisit(NodeValueVisitor visitor)-
Methods inherited from class org.apache.jena.sparql.expr.ExprNode
asVar, deepCopy, equals, equalsBySyntax, getExpr, getExprVar, getFunction, getGraphPattern, getVarName, getVarsMentioned, isExpr, isFunction, isGraphPattern, isSatisfied, isVariable
-
-
-
-
Field Detail
-
VerboseWarnings
public static boolean VerboseWarnings
-
VerboseExceptions
public static boolean VerboseExceptions
-
TRUE
public static final NodeValue TRUE
-
FALSE
public static final NodeValue FALSE
-
nvZERO
public static final NodeValue nvZERO
-
nvNegZERO
public static final NodeValue nvNegZERO
-
nvONE
public static final NodeValue nvONE
-
nvTEN
public static final NodeValue nvTEN
-
nvDecimalZERO
public static final NodeValue nvDecimalZERO
-
nvDecimalONE
public static final NodeValue nvDecimalONE
-
nvNaN
public static final NodeValue nvNaN
-
nvINF
public static final NodeValue nvINF
-
nvNegINF
public static final NodeValue nvNegINF
-
nvEmptyString
public static final NodeValue nvEmptyString
-
xsdNamespace
public static final java.lang.String xsdNamespace
- See Also:
- Constant Field Values
-
xmlDatatypeFactory
public static javax.xml.datatype.DatatypeFactory xmlDatatypeFactory
-
-
Method Detail
-
parse
public static NodeValue parse(java.lang.String string)
Convenience operation - parse a string to produce a NodeValue - common namespaces like xsd: are built-in
-
makeInteger
public static NodeValue makeInteger(long i)
-
makeInteger
public static NodeValue makeInteger(java.math.BigInteger i)
-
makeInteger
public static NodeValue makeInteger(java.lang.String lexicalForm)
-
makeFloat
public static NodeValue makeFloat(float f)
-
makeDouble
public static NodeValue makeDouble(double d)
-
makeString
public static NodeValue makeString(java.lang.String s)
-
makeSortKey
public static NodeValue makeSortKey(java.lang.String s, java.lang.String collation)
-
makeLangString
public static NodeValue makeLangString(java.lang.String s, java.lang.String lang)
-
makeDecimal
public static NodeValue makeDecimal(java.math.BigDecimal d)
-
makeDecimal
public static NodeValue makeDecimal(long i)
-
makeDecimal
public static NodeValue makeDecimal(double d)
-
makeDecimal
public static NodeValue makeDecimal(java.lang.String lexicalForm)
-
makeDateTime
public static NodeValue makeDateTime(java.lang.String lexicalForm)
-
makeDate
public static NodeValue makeDate(java.lang.String lexicalForm)
-
makeDateTime
public static NodeValue makeDateTime(java.util.Calendar cal)
-
makeDateTime
public static NodeValue makeDateTime(javax.xml.datatype.XMLGregorianCalendar cal)
-
makeDate
public static NodeValue makeDate(java.util.Calendar cal)
-
makeDate
public static NodeValue makeDate(javax.xml.datatype.XMLGregorianCalendar cal)
-
makeDuration
public static NodeValue makeDuration(java.lang.String lexicalForm)
-
makeDuration
public static NodeValue makeDuration(javax.xml.datatype.Duration duration)
-
makeNodeDuration
public static NodeValue makeNodeDuration(javax.xml.datatype.Duration duration, Node node)
-
makeBoolean
public static NodeValue makeBoolean(boolean b)
-
booleanReturn
public static NodeValue booleanReturn(boolean b)
-
makeNode
public static NodeValue makeNode(java.lang.String lexicalForm, RDFDatatype dtype)
-
makeNode
public static NodeValue makeNode(java.lang.String lexicalForm, java.lang.String langTag, Node datatype)
-
makeNode
public static NodeValue makeNode(java.lang.String lexicalForm, java.lang.String langTag, java.lang.String datatype)
-
makeNodeBoolean
public static NodeValue makeNodeBoolean(boolean b)
-
makeNodeBoolean
public static NodeValue makeNodeBoolean(java.lang.String lexicalForm)
-
makeNodeInteger
public static NodeValue makeNodeInteger(long v)
-
makeNodeInteger
public static NodeValue makeNodeInteger(java.lang.String lexicalForm)
-
makeNodeFloat
public static NodeValue makeNodeFloat(float f)
-
makeNodeFloat
public static NodeValue makeNodeFloat(java.lang.String lexicalForm)
-
makeNodeDouble
public static NodeValue makeNodeDouble(double v)
-
makeNodeDouble
public static NodeValue makeNodeDouble(java.lang.String lexicalForm)
-
makeNodeDecimal
public static NodeValue makeNodeDecimal(java.math.BigDecimal decimal)
-
makeNodeDecimal
public static NodeValue makeNodeDecimal(java.lang.String lexicalForm)
-
makeNodeString
public static NodeValue makeNodeString(java.lang.String string)
-
makeNodeDateTime
public static NodeValue makeNodeDateTime(java.util.Calendar date)
-
makeNodeDateTime
public static NodeValue makeNodeDateTime(java.lang.String lexicalForm)
-
makeNodeDate
public static NodeValue makeNodeDate(java.util.Calendar date)
-
makeNodeDate
public static NodeValue makeNodeDate(java.lang.String lexicalForm)
-
eval
public NodeValue eval(Binding binding, FunctionEnv env)
Description copied from interface:ExprEvaluate this expression against the binding
-
copySubstitute
public Expr copySubstitute(Binding binding)
Description copied from interface:ExprDeep copy with substitution- Specified by:
copySubstitutein interfaceExpr- Specified by:
copySubstitutein classExprNode
-
applyNodeTransform
public Expr applyNodeTransform(NodeTransform transform)
Description copied from interface:ExprRewrite, applying a node->node transformation- Specified by:
applyNodeTransformin interfaceExpr- Specified by:
applyNodeTransformin classExprNode
-
evalNode
public Node evalNode(Binding binding, ExecutionContext execCxt)
-
isConstant
public boolean isConstant()
Description copied from interface:ExprAnswer whether this is a constant expression - false includes "don't know" No constant folding so "false" from an expression that evaluates to a constant- Specified by:
isConstantin interfaceExpr- Overrides:
isConstantin classExprNode
-
getConstant
public NodeValue getConstant()
Description copied from interface:ExprNodeValue constant (returns null if not a constant)- Specified by:
getConstantin interfaceExpr- Overrides:
getConstantin classExprNode
-
isIRI
public boolean isIRI()
-
isBlank
public boolean isBlank()
-
isTripleTerm
public boolean isTripleTerm()
-
sameAs
public static boolean sameAs(NodeValue nv1, NodeValue nv2)
Return true if the two NodeValues are known to be the same value return false if known to be different values, throw ExprEvalException otherwise
-
notSameAs
public static boolean notSameAs(Node n1, Node n2)
Return true if the two Nodes are known to be different, return false if the two Nodes are known to be the same, else throw ExprEvalException
-
notSameAs
public static boolean notSameAs(NodeValue nv1, NodeValue nv2)
Return true if the two NodeValues are known to be different, return false if the two NodeValues are known to be the same, else throw ExprEvalException
-
compareAlways
public static int compareAlways(NodeValue nv1, NodeValue nv2)
Compare by value if possible else compare by kind/type/lexical form Only use when you want an ordering regardless of form of NodeValue, for example in ORDER BY- Parameters:
nv1-nv2-- Returns:
- negative, 0, or positive for less than, equal, greater than.
-
compare
public static int compare(NodeValue nv1, NodeValue nv2)
Compare by value (and only value) if possible. Supports <, <=, >, >= but not = nor != (which are sameValueAs and notSameValueAs)- Parameters:
nv1-nv2-- Returns:
- Expr.CMP_INDETERMINATE(+2), Expr.CMP_LESS(-1), Expr.CMP_EQUAL(0) or Expr.CMP_GREATER(+1)
- Throws:
ExprNotComparableException
-
classifyValueOp
public static ValueSpaceClassification classifyValueOp(NodeValue nv1, NodeValue nv2)
-
getValueSpace
public ValueSpaceClassification getValueSpace()
-
asNode
public final Node asNode()
-
getNode
public Node getNode()
getNode - return the node form - may be null (use .asNode() to force to a node)
-
getDatatypeURI
public java.lang.String getDatatypeURI()
-
hasNode
public boolean hasNode()
-
isBoolean
public boolean isBoolean()
-
isString
public boolean isString()
-
isLangString
public boolean isLangString()
-
isSortKey
public boolean isSortKey()
-
isNumber
public boolean isNumber()
-
isInteger
public boolean isInteger()
-
isDecimal
public boolean isDecimal()
-
isFloat
public boolean isFloat()
-
isDouble
public boolean isDouble()
-
hasDateTime
public boolean hasDateTime()
-
isDateTime
public boolean isDateTime()
-
isDate
public boolean isDate()
-
isLiteral
public boolean isLiteral()
-
isTime
public boolean isTime()
-
isDuration
public boolean isDuration()
-
isYearMonthDuration
public boolean isYearMonthDuration()
-
isDayTimeDuration
public boolean isDayTimeDuration()
-
isGYear
public boolean isGYear()
-
isGYearMonth
public boolean isGYearMonth()
-
isGMonth
public boolean isGMonth()
-
isGMonthDay
public boolean isGMonthDay()
-
isGDay
public boolean isGDay()
-
getBoolean
public boolean getBoolean()
-
getString
public java.lang.String getString()
-
getLang
public java.lang.String getLang()
-
getSortKey
public NodeValueSortKey getSortKey()
-
getInteger
public java.math.BigInteger getInteger()
-
getDecimal
public java.math.BigDecimal getDecimal()
-
getFloat
public float getFloat()
-
getDouble
public double getDouble()
-
getDateTime
public javax.xml.datatype.XMLGregorianCalendar getDateTime()
-
getDuration
public javax.xml.datatype.Duration getDuration()
-
raise
public static void raise(ExprException ex)
-
visit
public void visit(ExprVisitor visitor)
-
asUnquotedString
public final java.lang.String asUnquotedString()
-
asQuotedString
public final java.lang.String asQuotedString()
-
asQuotedString
public final java.lang.String asQuotedString(SerializationContext context)
-
asString
public java.lang.String asString()
-
hashCode
public int hashCode()
Description copied from interface:ExprExprare used in both syntax and algebra. There is no syntax to algebra translation step because the parser uses operator precedence to build the right evaluation structure directly.The exceptions to this are the
NOT EXISTSandEXISTSexpressions which involve a query pattern. As a result there are different ways in syntax to produce the same algebra form.Two
Exprare considered equal if they are equal as algebra expressions.hashCodeandequalsmust implement that.There is also
equalsBySyntax. Because two different syntax forms can yield the same algebra, but two different algebra forms must be different syntax,equalsBySyntaximpliesequals(by alegbra).Hence, different
hashCode=> notequalsBySyntax.
-
equals
public boolean equals(Expr other, boolean bySyntax)
Description copied from interface:ExprGeneral equality operation - consider this to be 'protected'
-
visit
public abstract void visit(NodeValueVisitor visitor)
-
apply
public Expr apply(ExprTransform transform)
-
-