|
|
@ -412,6 +412,17 @@ public abstract class ValueNode { |
|
|
|
string = escape ? Utils.unescape(charSequence.toString()) : charSequence.toString(); |
|
|
|
string = escape ? Utils.unescape(charSequence.toString()) : charSequence.toString(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public NumberNode asNumberNode() { |
|
|
|
|
|
|
|
BigDecimal number = null; |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
number = new BigDecimal(string); |
|
|
|
|
|
|
|
} catch (NumberFormatException nfe){ |
|
|
|
|
|
|
|
return NumberNode.NAN; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return new NumberNode(number); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public String getString() { |
|
|
|
public String getString() { |
|
|
|
return string; |
|
|
|
return string; |
|
|
|
} |
|
|
|
} |
|
|
@ -450,22 +461,33 @@ public abstract class ValueNode { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public boolean equals(Object o) { |
|
|
|
public boolean equals(Object o) { |
|
|
|
if (this == o) return true; |
|
|
|
if (this == o) return true; |
|
|
|
if (!(o instanceof StringNode)) return false; |
|
|
|
if (!(o instanceof StringNode) && !(o instanceof NumberNode)) return false; |
|
|
|
|
|
|
|
|
|
|
|
StringNode that = (StringNode) o; |
|
|
|
StringNode that = ((ValueNode) o).asStringNode(); |
|
|
|
|
|
|
|
|
|
|
|
return !(string != null ? !string.equals(that.string) : that.string != null); |
|
|
|
return !(string != null ? !string.equals(that.getString()) : that.getString() != null); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static class NumberNode extends ValueNode { |
|
|
|
public static class NumberNode extends ValueNode { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static NumberNode NAN = new NumberNode((BigDecimal)null); |
|
|
|
|
|
|
|
|
|
|
|
private final BigDecimal number; |
|
|
|
private final BigDecimal number; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private NumberNode(BigDecimal number) { |
|
|
|
|
|
|
|
this.number = number; |
|
|
|
|
|
|
|
} |
|
|
|
private NumberNode(CharSequence num) { |
|
|
|
private NumberNode(CharSequence num) { |
|
|
|
number = new BigDecimal(num.toString()); |
|
|
|
number = new BigDecimal(num.toString()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public StringNode asStringNode() { |
|
|
|
|
|
|
|
return new StringNode(number.toString(), false); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public BigDecimal getNumber() { |
|
|
|
public BigDecimal getNumber() { |
|
|
|
return number; |
|
|
|
return number; |
|
|
|
} |
|
|
|
} |
|
|
@ -491,14 +513,14 @@ public abstract class ValueNode { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public boolean equals(Object o) { |
|
|
|
public boolean equals(Object o) { |
|
|
|
if (this == o) return true; |
|
|
|
if (this == o) return true; |
|
|
|
if (!(o instanceof NumberNode)) return false; |
|
|
|
if (!(o instanceof NumberNode) && !(o instanceof StringNode)) return false; |
|
|
|
|
|
|
|
|
|
|
|
ValueNode that = (ValueNode) o; |
|
|
|
NumberNode that = ((ValueNode)o).asNumberNode(); |
|
|
|
|
|
|
|
|
|
|
|
if(!that.isNumberNode()){ |
|
|
|
if(that == NumberNode.NAN){ |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
return number.compareTo(that.asNumberNode().number) == 0; |
|
|
|
return number.compareTo(that.number) == 0; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|