1
package com.thaiopensource.datatype.xsd;
3
import org.relaxng.datatype.ValidationContext;
5
import java.math.BigDecimal;
7
class DecimalDatatype extends DatatypeBase implements OrderRelation {
9
boolean lexicallyAllows(String str) {
10
int len = str.length();
14
switch (str.charAt(i)) {
20
boolean hadDecimalPoint = false;
21
if (str.charAt(i) == '.') {
22
hadDecimalPoint = true;
27
switch (str.charAt(i)) {
42
hadDecimalPoint = true;
51
String getLexicalSpaceKey() {
55
Object getValue(String str, ValidationContext vc) {
56
if (str.charAt(0) == '+')
57
str = str.substring(1); // JDK 1.1 doesn't handle leading +
58
return new BigDecimal(str);
61
OrderRelation getOrderRelation() {
65
public boolean isLessThan(Object obj1, Object obj2) {
66
return ((BigDecimal)obj1).compareTo((BigDecimal)obj2) < 0;
70
* BigDecimal.equals considers objects distinct if they have the
71
* different scales but the same mathematical value. Similarly
75
public boolean sameValue(Object value1, Object value2) {
76
return ((BigDecimal)value1).compareTo((BigDecimal)value2) == 0;
79
public int valueHashCode(Object value) {
80
return ((BigDecimal)value).toBigInteger().hashCode();