From: Jean-Marc V. <jm...@us...> - 2004-07-07 17:15:56
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xquery/value In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12216/src/org/exist/xquery/value Modified Files: IntegerValue.java Log Message: finish implementing: private boolean checkType(BigInteger value2, int type2) Index: IntegerValue.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/value/IntegerValue.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** IntegerValue.java 7 Jul 2004 13:56:54 -0000 1.5 --- IntegerValue.java 7 Jul 2004 17:15:46 -0000 1.6 *************** *** 38,43 **** private static final BigInteger ONE_BIGINTEGER = new BigInteger("1"); private static final BigInteger MINUS_ONE_BIGINTEGER = new BigInteger("1"); ! private static final BigInteger LARGEST_INT = new BigInteger("4294967295"); private static final BigInteger SMALLEST_INT = LARGEST_INT.negate(); private BigInteger value; --- 38,49 ---- private static final BigInteger ONE_BIGINTEGER = new BigInteger("1"); private static final BigInteger MINUS_ONE_BIGINTEGER = new BigInteger("1"); ! private static final BigInteger LARGEST_LONG = new BigInteger("9223372036854775808" ); ! private static final BigInteger SMALLEST_LONG = LARGEST_LONG.negate(); ! private static final BigInteger LARGEST_INT = new BigInteger("4294967296"); private static final BigInteger SMALLEST_INT = LARGEST_INT.negate(); + private static final BigInteger LARGEST_SHORT = new BigInteger("65536"); + private static final BigInteger SMALLEST_SHORT = LARGEST_SHORT.negate(); + private static final BigInteger LARGEST_BYTE = new BigInteger("256"); + private static final BigInteger SMALLEST_BYTE = LARGEST_BYTE.negate(); private BigInteger value; *************** *** 62,68 **** value = new BigInteger(stringValue); // Long.parseLong(stringValue); } catch (NumberFormatException e) { - // try { - // value = (long) Double.parseDouble(stringValue); - // } catch (NumberFormatException e1) { throw new XPathException( "failed to convert '" + stringValue + "' to an integer: " + e.getMessage(), e); --- 68,71 ---- *************** *** 76,82 **** value = new BigInteger(stringValue); // Long.parseLong(stringValue); } catch (NumberFormatException e) { - // try { - // value = (long) Double.parseDouble(stringValue); - // } catch (NumberFormatException e1) { throw new XPathException( "failed to convert '" + stringValue + "' to an integer: " + e.getMessage()); --- 79,82 ---- *************** *** 110,114 **** switch (type) { case Type.LONG : ! // jmv: add test LARGEST_LONG SMALLEST_LONG ???? case Type.INTEGER : case Type.DECIMAL : --- 110,116 ---- switch (type) { case Type.LONG : ! // jmv: add test since now long is not the default implementation anymore: ! return value.compareTo(SMALLEST_LONG) == 1 && ! value.compareTo(LARGEST_LONG ) == -1; case Type.INTEGER : case Type.DECIMAL : *************** *** 127,144 **** case Type.INT : return value.compareTo(SMALLEST_INT) == 1 && ! value.compareTo(LARGEST_INT) == -1; ! // >= -4294967295L && value <= 4294967295L; ! // case Type.SHORT : ! // return value >= -65535 && value <= 65535; ! // case Type.BYTE : ! // return value >= -255 && value <= 255; ! // case Type.UNSIGNED_LONG : ! // return value > -1; ! // case Type.UNSIGNED_INT: ! // return value > -1 && value <= 4294967295L; ! // case Type.UNSIGNED_SHORT : ! // return value > -1 && value <= 65535; ! // case Type.UNSIGNED_BYTE : ! // return value > -1 && value <= 255; } throw new XPathException("Unknown type: " + Type.getTypeName(type)); --- 129,152 ---- case Type.INT : return value.compareTo(SMALLEST_INT) == 1 && ! value.compareTo(LARGEST_INT) == -1; ! case Type.SHORT : ! return value.compareTo(SMALLEST_SHORT) == 1 && ! value.compareTo(LARGEST_SHORT) == -1; ! case Type.BYTE : ! return value.compareTo(SMALLEST_BYTE) == 1 && ! value.compareTo(LARGEST_BYTE) == -1; ! ! case Type.UNSIGNED_LONG : ! return value.compareTo(MINUS_ONE_BIGINTEGER) == 1 && ! value.compareTo(LARGEST_LONG ) == -1; ! case Type.UNSIGNED_INT: ! return value.compareTo(MINUS_ONE_BIGINTEGER) == 1 && ! value.compareTo(LARGEST_INT) == -1; ! case Type.UNSIGNED_SHORT : ! return value.compareTo(MINUS_ONE_BIGINTEGER) == 1 && ! value.compareTo(LARGEST_SHORT) == -1; ! case Type.UNSIGNED_BYTE : ! return value.compareTo(MINUS_ONE_BIGINTEGER) == 1 && ! value.compareTo(LARGEST_BYTE) == -1; } throw new XPathException("Unknown type: " + Type.getTypeName(type)); |