Update of /cvsroot/exist/eXist-1.0/src/org/exist/xquery/value
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13064/src/org/exist/xquery/value
Modified Files:
IntegerValue.java
Log Message:
implement the missing constructors taking BigInteger as argument, and
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.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** IntegerValue.java 6 Jul 2004 16:10:41 -0000 1.3
--- IntegerValue.java 7 Jul 2004 08:29:27 -0000 1.4
***************
*** 36,39 ****
--- 36,43 ----
public final static IntegerValue ZERO = new IntegerValue(0);
private static final BigInteger ZERO_BIGINTEGER = new BigInteger("0");
+ 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("4294967295L");
+ private static final BigInteger SMALLEST_INT = LARGEST_INT.negate();
private BigInteger value;
***************
*** 83,92 ****
/**
! * @param value2
* @param requiredType
*/
! public IntegerValue(BigInteger value2, int requiredType) {
!
! // TODO Auto-generated constructor stub
}
--- 87,96 ----
/**
! * @param value
* @param requiredType
*/
! public IntegerValue(BigInteger value, int requiredType) {
! this.value = value;
! type = requiredType;
}
***************
*** 95,100 ****
*/
public IntegerValue(BigInteger integer) {
!
! // TODO Auto-generated constructor stub
}
--- 99,103 ----
*/
public IntegerValue(BigInteger integer) {
! this.value = integer;
}
***************
*** 102,109 ****
* @param value2
* @param type2
*/
! private void checkType(BigInteger value2, int type2) {
! // TODO Auto-generated method stub
}
--- 105,146 ----
* @param value2
* @param type2
+ * @throws XPathException
*/
! private boolean checkType(BigInteger value2, int type2) throws XPathException {
! switch (type) {
! case Type.LONG :
! // jmv: add test LARGEST_LONG SMALLEST_LONG ????
! case Type.INTEGER :
! case Type.DECIMAL :
! return true;
+ case Type.POSITIVE_INTEGER :
+ return value.compareTo(ZERO_BIGINTEGER) == 1; // >0
+ case Type.NON_NEGATIVE_INTEGER :
+ return value.compareTo(MINUS_ONE_BIGINTEGER) == 1; // > -1
+
+ case Type.NEGATIVE_INTEGER :
+ return value.compareTo(ZERO_BIGINTEGER) == -1; // <0
+ case Type.NON_POSITIVE_INTEGER :
+ return value.compareTo(ONE_BIGINTEGER) == -1; // <1
+
+ 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));
}
***************
*** 135,139 ****
return value > -1 && value <= 255;
case Type.POSITIVE_INTEGER :
! return value >= 0;
}
throw new XPathException("Unknown type: " + Type.getTypeName(type));
--- 172,176 ----
return value > -1 && value <= 255;
case Type.POSITIVE_INTEGER :
! return value > 0; // jmv >= 0;
}
throw new XPathException("Unknown type: " + Type.getTypeName(type));
|