|
|
@ -56,14 +56,9 @@ public class ExpressionTemporal extends Expression |
|
|
/** RHS of operator, null for nullary operators (e.g., S) */ |
|
|
/** RHS of operator, null for nullary operators (e.g., S) */ |
|
|
protected Expression operand2 = null; |
|
|
protected Expression operand2 = null; |
|
|
|
|
|
|
|
|
// Optional (time) bounds |
|
|
|
|
|
protected Expression lBound = null; // None if null, i.e. zero |
|
|
|
|
|
protected Expression uBound = null; // None if null, i.e. infinity |
|
|
|
|
|
// Strictness of (time) bounds |
|
|
|
|
|
protected boolean lBoundStrict = false; // true: >, false: >= |
|
|
|
|
|
protected boolean uBoundStrict = false; // true: <, false: <= |
|
|
|
|
|
// Display as =T rather than [T,T] ? |
|
|
|
|
|
protected boolean equals = false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// optional bound |
|
|
|
|
|
public TemporalOperatorBound bound; |
|
|
|
|
|
|
|
|
// Constructors |
|
|
// Constructors |
|
|
|
|
|
|
|
|
@ -105,65 +100,13 @@ public class ExpressionTemporal extends Expression |
|
|
operand2 = e2; |
|
|
operand2 = e2; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* Set lower time bound to be of form >= e |
|
|
|
|
|
* (null denotes no lower bound, i.e. zero) |
|
|
|
|
|
*/ |
|
|
|
|
|
public void setLowerBound(Expression e) |
|
|
|
|
|
{ |
|
|
|
|
|
setLowerBound(e, false); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* Set lower time bound to be of form >= e or > e |
|
|
|
|
|
* (null denotes no lower bound, i.e. zero) |
|
|
|
|
|
*/ |
|
|
|
|
|
public void setLowerBound(Expression e, boolean strict) |
|
|
|
|
|
{ |
|
|
|
|
|
lBound = e; |
|
|
|
|
|
lBoundStrict = strict; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* Set upper time bound to be of form <= e |
|
|
|
|
|
* (null denotes no upper bound, i.e. infinity) |
|
|
|
|
|
*/ |
|
|
|
|
|
public void setUpperBound(Expression e) |
|
|
|
|
|
{ |
|
|
|
|
|
setUpperBound(e, false); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* Set upper time bound to be of form <= e or < e |
|
|
|
|
|
* (null denotes no upper bound, i.e. infinity) |
|
|
|
|
|
*/ |
|
|
|
|
|
public void setUpperBound(Expression e, boolean strict) |
|
|
|
|
|
{ |
|
|
|
|
|
uBound = e; |
|
|
|
|
|
uBoundStrict = strict; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* Set both lower/upper time bound to e, i.e. "=e". |
|
|
|
|
|
*/ |
|
|
|
|
|
public void setEqualBounds(Expression e) |
|
|
|
|
|
{ |
|
|
|
|
|
lBound = e; |
|
|
|
|
|
lBoundStrict = false; |
|
|
|
|
|
uBound = e; |
|
|
|
|
|
uBoundStrict = false; |
|
|
|
|
|
equals = true; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Take the bounds information from the other ExpressionTemporal |
|
|
* Take the bounds information from the other ExpressionTemporal |
|
|
* and store them in this ExpressionTemporal (no deep copy). |
|
|
* and store them in this ExpressionTemporal (no deep copy). |
|
|
*/ |
|
|
*/ |
|
|
public void setBoundsFrom(ExpressionTemporal exprTemp) |
|
|
public void setBoundsFrom(ExpressionTemporal exprTemp) |
|
|
{ |
|
|
{ |
|
|
setLowerBound(exprTemp.getLowerBound(), exprTemp.lowerBoundIsStrict()); |
|
|
|
|
|
setUpperBound(exprTemp.getUpperBound(), exprTemp.upperBoundIsStrict()); |
|
|
|
|
|
equals = exprTemp.equals; |
|
|
|
|
|
|
|
|
bound = exprTemp.getBound(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Get methods |
|
|
// Get methods |
|
|
@ -200,38 +143,16 @@ public class ExpressionTemporal extends Expression |
|
|
return (operand1 == null) ? 1 : 2; |
|
|
return (operand1 == null) ? 1 : 2; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public boolean hasBounds() |
|
|
|
|
|
|
|
|
public TemporalOperatorBound getBound() |
|
|
{ |
|
|
{ |
|
|
return lBound != null || uBound != null; |
|
|
|
|
|
|
|
|
return bound; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public Expression getLowerBound() |
|
|
|
|
|
{ |
|
|
|
|
|
return lBound; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public boolean lowerBoundIsStrict() |
|
|
|
|
|
{ |
|
|
|
|
|
return lBoundStrict; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public Expression getUpperBound() |
|
|
|
|
|
|
|
|
public boolean hasBounds() |
|
|
{ |
|
|
{ |
|
|
return uBound; |
|
|
|
|
|
|
|
|
return bound != null; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public boolean upperBoundIsStrict() |
|
|
|
|
|
{ |
|
|
|
|
|
return uBoundStrict; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* Returns true if lower/upper bound are equal and should be displayed as =T |
|
|
|
|
|
*/ |
|
|
|
|
|
public boolean getEquals() |
|
|
|
|
|
{ |
|
|
|
|
|
return equals; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Methods required for Expression: |
|
|
// Methods required for Expression: |
|
|
|
|
|
|
|
|
@ -282,13 +203,17 @@ public class ExpressionTemporal extends Expression |
|
|
expr.setOperand1(operand1.deepCopy()); |
|
|
expr.setOperand1(operand1.deepCopy()); |
|
|
if (operand2 != null) |
|
|
if (operand2 != null) |
|
|
expr.setOperand2(operand2.deepCopy()); |
|
|
expr.setOperand2(operand2.deepCopy()); |
|
|
expr.setLowerBound(lBound == null ? null : lBound.deepCopy(), lBoundStrict); |
|
|
|
|
|
expr.setUpperBound(uBound == null ? null : uBound.deepCopy(), uBoundStrict); |
|
|
|
|
|
expr.equals = equals; |
|
|
|
|
|
|
|
|
if (bound != null) { |
|
|
|
|
|
expr.setBound((TemporalOperatorBound) bound.deepCopy()); |
|
|
|
|
|
} |
|
|
expr.setType(type); |
|
|
expr.setType(type); |
|
|
expr.setPosition(this); |
|
|
expr.setPosition(this); |
|
|
return expr; |
|
|
return expr; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void setBound(TemporalOperatorBound bound) { |
|
|
|
|
|
this.bound = bound; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// Standard methods |
|
|
// Standard methods |
|
|
|
|
|
|
|
|
@ -299,21 +224,23 @@ public class ExpressionTemporal extends Expression |
|
|
if (operand1 != null) |
|
|
if (operand1 != null) |
|
|
s += operand1 + " "; |
|
|
s += operand1 + " "; |
|
|
s += opSymbols[op]; |
|
|
s += opSymbols[op]; |
|
|
if (lBound == null) { |
|
|
|
|
|
if (uBound != null) { |
|
|
|
|
|
if (op != R_I) |
|
|
|
|
|
s += "<" + (uBoundStrict ? "" : "=") + uBound; |
|
|
|
|
|
else |
|
|
|
|
|
s += "=" + uBound; |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
if (uBound == null) { |
|
|
|
|
|
s += ">" + (lBoundStrict ? "" : "=") + lBound; |
|
|
|
|
|
|
|
|
if (bound != null) { |
|
|
|
|
|
if (bound.getLowerBound() == null) { |
|
|
|
|
|
if (bound.getUpperBound() != null) { |
|
|
|
|
|
if (op != R_I) |
|
|
|
|
|
s += "<" + (bound.upperBoundIsStrict() ? "" : "=") + bound.getUpperBound(); |
|
|
|
|
|
else |
|
|
|
|
|
s += "=" + bound.getUpperBound(); |
|
|
|
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
if (equals) |
|
|
|
|
|
s += "=" + lBound; |
|
|
|
|
|
else |
|
|
|
|
|
s += "[" + lBound + "," + uBound + "]"; |
|
|
|
|
|
|
|
|
if (bound.getUpperBound() == null) { |
|
|
|
|
|
s += ">" + (bound.lowerBoundIsStrict() ? "" : "=") + bound.getLowerBound(); |
|
|
|
|
|
} else { |
|
|
|
|
|
if (bound.getEquals()) |
|
|
|
|
|
s += "=" + bound.getLowerBound(); |
|
|
|
|
|
else |
|
|
|
|
|
s += "[" + bound.getLowerBound() + "," + bound.getUpperBound() + "]"; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
if (operand2 != null) |
|
|
if (operand2 != null) |
|
|
@ -326,14 +253,10 @@ public class ExpressionTemporal extends Expression |
|
|
{ |
|
|
{ |
|
|
final int prime = 31; |
|
|
final int prime = 31; |
|
|
int result = 1; |
|
|
int result = 1; |
|
|
result = prime * result + (equals ? 1231 : 1237); |
|
|
|
|
|
result = prime * result + ((lBound == null) ? 0 : lBound.hashCode()); |
|
|
|
|
|
result = prime * result + (lBoundStrict ? 1231 : 1237); |
|
|
|
|
|
|
|
|
result = prime * result + ((bound == null) ? 0 : bound.hashCode()); |
|
|
result = prime * result + op; |
|
|
result = prime * result + op; |
|
|
result = prime * result + ((operand1 == null) ? 0 : operand1.hashCode()); |
|
|
result = prime * result + ((operand1 == null) ? 0 : operand1.hashCode()); |
|
|
result = prime * result + ((operand2 == null) ? 0 : operand2.hashCode()); |
|
|
result = prime * result + ((operand2 == null) ? 0 : operand2.hashCode()); |
|
|
result = prime * result + ((uBound == null) ? 0 : uBound.hashCode()); |
|
|
|
|
|
result = prime * result + (uBoundStrict ? 1231 : 1237); |
|
|
|
|
|
return result; |
|
|
return result; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -344,17 +267,13 @@ public class ExpressionTemporal extends Expression |
|
|
return true; |
|
|
return true; |
|
|
if (obj == null) |
|
|
if (obj == null) |
|
|
return false; |
|
|
return false; |
|
|
if (getClass() != obj.getClass()) |
|
|
|
|
|
|
|
|
if (!(obj instanceof ExpressionTemporal)) |
|
|
return false; |
|
|
return false; |
|
|
ExpressionTemporal other = (ExpressionTemporal) obj; |
|
|
ExpressionTemporal other = (ExpressionTemporal) obj; |
|
|
if (equals != other.equals) |
|
|
|
|
|
return false; |
|
|
|
|
|
if (lBound == null) { |
|
|
|
|
|
if (other.lBound != null) |
|
|
|
|
|
|
|
|
if (bound == null) { |
|
|
|
|
|
if (other.bound != null) |
|
|
return false; |
|
|
return false; |
|
|
} else if (!lBound.equals(other.lBound)) |
|
|
|
|
|
return false; |
|
|
|
|
|
if (lBoundStrict != other.lBoundStrict) |
|
|
|
|
|
|
|
|
} else if (!bound.equals(other.bound)) |
|
|
return false; |
|
|
return false; |
|
|
if (op != other.op) |
|
|
if (op != other.op) |
|
|
return false; |
|
|
return false; |
|
|
@ -368,13 +287,6 @@ public class ExpressionTemporal extends Expression |
|
|
return false; |
|
|
return false; |
|
|
} else if (!operand2.equals(other.operand2)) |
|
|
} else if (!operand2.equals(other.operand2)) |
|
|
return false; |
|
|
return false; |
|
|
if (uBound == null) { |
|
|
|
|
|
if (other.uBound != null) |
|
|
|
|
|
return false; |
|
|
|
|
|
} else if (!uBound.equals(other.uBound)) |
|
|
|
|
|
return false; |
|
|
|
|
|
if (uBoundStrict != other.uBoundStrict) |
|
|
|
|
|
return false; |
|
|
|
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|