Strabon

changeset 1441:54679bf9f89b

cleaned class XMLGSDatatypeUtil by removing unused methods and making datatype comparisons null-safe
author Babis Nikolaou <charnik@di.uoa.gr>
date Thu Oct 30 15:36:00 2014 +0200 (2014-10-30)
parents 9eb039fea93d
children 025b64f6f1fa
files generaldb/src/main/java/org/openrdf/sail/generaldb/model/XMLGSDatatypeUtil.java
line diff
     1.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/model/XMLGSDatatypeUtil.java	Thu Oct 30 14:14:33 2014 +0200
     1.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/model/XMLGSDatatypeUtil.java	Thu Oct 30 15:36:00 2014 +0200
     1.3 @@ -1,19 +1,10 @@
     1.4  package org.openrdf.sail.generaldb.model;
     1.5  
     1.6 -import java.math.BigDecimal;
     1.7 -import java.math.BigInteger;
     1.8 -import java.util.StringTokenizer;
     1.9 -
    1.10 -import javax.xml.datatype.DatatypeConfigurationException;
    1.11 -import javax.xml.datatype.DatatypeConstants;
    1.12 -import javax.xml.datatype.DatatypeFactory;
    1.13  import javax.xml.datatype.XMLGregorianCalendar;
    1.14 -import javax.xml.namespace.QName;
    1.15  
    1.16  import org.openrdf.model.Literal;
    1.17  import org.openrdf.model.URI;
    1.18  import org.openrdf.model.Value;
    1.19 -import org.openrdf.model.datatypes.XMLDateTime;
    1.20  import org.openrdf.model.vocabulary.XMLSchema;
    1.21  import org.openrdf.query.algebra.evaluation.function.spatial.StrabonPolyhedron;
    1.22  
    1.23 @@ -21,24 +12,8 @@
    1.24  import eu.earthobservatory.constants.WKTConstants;
    1.25  
    1.26  
    1.27 -
    1.28  public class XMLGSDatatypeUtil {
    1.29  	
    1.30 -	private static DatatypeFactory dtFactory;
    1.31 -
    1.32 -	static {
    1.33 -		try {
    1.34 -			dtFactory = DatatypeFactory.newInstance();
    1.35 -		}
    1.36 -		catch (DatatypeConfigurationException e) {
    1.37 -			throw new RuntimeException(e);
    1.38 -		}
    1.39 -	}
    1.40 -
    1.41 -	/*-------------------*
    1.42 -	 * Datatype checking *
    1.43 -	 *-------------------*/
    1.44 -
    1.45  	/**
    1.46  	 * Returns true when the given value is an instance of class @{link GeneralDBPolyhedron} 
    1.47  	 * or @{link Literal} with datatype @{link StrabonPolyhedron#ogcGeometry} (WKT) or 
    1.48 @@ -153,25 +128,25 @@
    1.49  	 */
    1.50  	public static boolean isPrimitiveDatatype(URI datatype) {
    1.51  		return
    1.52 -		datatype.equals(XMLSchema.DURATION) ||
    1.53 -		datatype.equals(XMLSchema.DATETIME) ||
    1.54 -		datatype.equals(XMLSchema.TIME) ||
    1.55 -		datatype.equals(XMLSchema.DATE) ||
    1.56 -		datatype.equals(XMLSchema.GYEARMONTH) ||
    1.57 -		datatype.equals(XMLSchema.GYEAR) ||
    1.58 -		datatype.equals(XMLSchema.GMONTHDAY) ||
    1.59 -		datatype.equals(XMLSchema.GDAY) ||
    1.60 -		datatype.equals(XMLSchema.GMONTH) ||
    1.61 -		datatype.equals(XMLSchema.STRING) ||
    1.62 -		datatype.equals(XMLSchema.BOOLEAN) ||
    1.63 -		datatype.equals(XMLSchema.BASE64BINARY) ||
    1.64 -		datatype.equals(XMLSchema.HEXBINARY) ||
    1.65 -		datatype.equals(XMLSchema.FLOAT) ||
    1.66 -		datatype.equals(XMLSchema.DECIMAL) ||
    1.67 -		datatype.equals(XMLSchema.DOUBLE) ||
    1.68 -		datatype.equals(XMLSchema.ANYURI) ||
    1.69 -		datatype.equals(XMLSchema.QNAME) ||
    1.70 -		datatype.equals(XMLSchema.NOTATION);
    1.71 +		XMLSchema.DURATION.equals(datatype)||
    1.72 +		XMLSchema.DATETIME.equals(datatype) ||
    1.73 +		XMLSchema.TIME.equals(datatype) ||
    1.74 +		XMLSchema.DATE.equals(datatype) ||
    1.75 +		XMLSchema.GYEARMONTH.equals(datatype) ||
    1.76 +		XMLSchema.GYEAR.equals(datatype) ||
    1.77 +		XMLSchema.GMONTHDAY.equals(datatype) ||
    1.78 +		XMLSchema.GDAY.equals(datatype) ||
    1.79 +		XMLSchema.GMONTH.equals(datatype) ||
    1.80 +		XMLSchema.STRING.equals(datatype) ||
    1.81 +		XMLSchema.BOOLEAN.equals(datatype) ||
    1.82 +		XMLSchema.BASE64BINARY.equals(datatype) ||
    1.83 +		XMLSchema.HEXBINARY.equals(datatype) ||
    1.84 +		XMLSchema.FLOAT.equals(datatype) ||
    1.85 +		XMLSchema.DECIMAL.equals(datatype) ||
    1.86 +		XMLSchema.DOUBLE.equals(datatype) ||
    1.87 +		XMLSchema.ANYURI.equals(datatype) ||
    1.88 +		XMLSchema.QNAME.equals(datatype) ||
    1.89 +		XMLSchema.NOTATION.equals(datatype);
    1.90  	}
    1.91  
    1.92  	/**
    1.93 @@ -179,31 +154,31 @@
    1.94  	 */
    1.95  	public static boolean isDerivedDatatype(URI datatype) {
    1.96  		return
    1.97 -		datatype.equals(XMLSchema.NORMALIZEDSTRING) ||
    1.98 -		datatype.equals(XMLSchema.TOKEN) ||
    1.99 -		datatype.equals(XMLSchema.LANGUAGE) ||
   1.100 -		datatype.equals(XMLSchema.NMTOKEN) ||
   1.101 -		datatype.equals(XMLSchema.NMTOKENS) ||
   1.102 -		datatype.equals(XMLSchema.NAME) ||
   1.103 -		datatype.equals(XMLSchema.NCNAME) ||
   1.104 -		datatype.equals(XMLSchema.ID) ||
   1.105 -		datatype.equals(XMLSchema.IDREF) ||
   1.106 -		datatype.equals(XMLSchema.IDREFS) ||
   1.107 -		datatype.equals(XMLSchema.ENTITY) ||
   1.108 -		datatype.equals(XMLSchema.ENTITIES) ||
   1.109 -		datatype.equals(XMLSchema.INTEGER) ||
   1.110 -		datatype.equals(XMLSchema.LONG) ||
   1.111 -		datatype.equals(XMLSchema.INT) ||
   1.112 -		datatype.equals(XMLSchema.SHORT) ||
   1.113 -		datatype.equals(XMLSchema.BYTE) ||
   1.114 -		datatype.equals(XMLSchema.NON_POSITIVE_INTEGER) ||
   1.115 -		datatype.equals(XMLSchema.NEGATIVE_INTEGER) ||
   1.116 -		datatype.equals(XMLSchema.NON_NEGATIVE_INTEGER) ||
   1.117 -		datatype.equals(XMLSchema.POSITIVE_INTEGER) ||
   1.118 -		datatype.equals(XMLSchema.UNSIGNED_LONG) ||
   1.119 -		datatype.equals(XMLSchema.UNSIGNED_INT) ||
   1.120 -		datatype.equals(XMLSchema.UNSIGNED_SHORT) ||
   1.121 -		datatype.equals(XMLSchema.UNSIGNED_BYTE);
   1.122 +		XMLSchema.NORMALIZEDSTRING.equals(datatype) ||
   1.123 +		XMLSchema.TOKEN.equals(datatype) ||
   1.124 +		XMLSchema.LANGUAGE.equals(datatype) ||
   1.125 +		XMLSchema.NMTOKEN.equals(datatype) ||
   1.126 +		XMLSchema.NMTOKENS.equals(datatype) ||
   1.127 +		XMLSchema.NAME.equals(datatype) ||
   1.128 +		XMLSchema.NCNAME.equals(datatype) ||
   1.129 +		XMLSchema.ID.equals(datatype) ||
   1.130 +		XMLSchema.IDREF.equals(datatype) ||
   1.131 +		XMLSchema.IDREFS.equals(datatype) ||
   1.132 +		XMLSchema.ENTITY.equals(datatype) ||
   1.133 +		XMLSchema.ENTITIES.equals(datatype) ||
   1.134 +		XMLSchema.INTEGER.equals(datatype) ||
   1.135 +		XMLSchema.LONG.equals(datatype) ||
   1.136 +		XMLSchema.INT.equals(datatype) ||
   1.137 +		XMLSchema.SHORT.equals(datatype) ||
   1.138 +		XMLSchema.BYTE.equals(datatype) ||
   1.139 +		XMLSchema.NON_POSITIVE_INTEGER.equals(datatype) ||
   1.140 +		XMLSchema.NEGATIVE_INTEGER.equals(datatype) ||
   1.141 +		XMLSchema.NON_NEGATIVE_INTEGER.equals(datatype) ||
   1.142 +		XMLSchema.POSITIVE_INTEGER.equals(datatype) ||
   1.143 +		XMLSchema.UNSIGNED_LONG.equals(datatype) ||
   1.144 +		XMLSchema.UNSIGNED_INT.equals(datatype) ||
   1.145 +		XMLSchema.UNSIGNED_SHORT.equals(datatype) ||
   1.146 +		XMLSchema.UNSIGNED_BYTE.equals(datatype);
   1.147  	}
   1.148  
   1.149  	/**
   1.150 @@ -228,7 +203,7 @@
   1.151  	 */
   1.152  	public static boolean isDecimalDatatype(URI datatype) {
   1.153  		return
   1.154 -		datatype.equals(XMLSchema.DECIMAL) ||
   1.155 +		XMLSchema.DECIMAL.equals(datatype) ||
   1.156  		isIntegerDatatype(datatype);
   1.157  	}
   1.158  
   1.159 @@ -238,19 +213,19 @@
   1.160  	 */
   1.161  	public static boolean isIntegerDatatype(URI datatype) {
   1.162  		return
   1.163 -		datatype.equals(XMLSchema.INTEGER) ||
   1.164 -		datatype.equals(XMLSchema.LONG) ||
   1.165 -		datatype.equals(XMLSchema.INT) ||
   1.166 -		datatype.equals(XMLSchema.SHORT) ||
   1.167 -		datatype.equals(XMLSchema.BYTE) ||
   1.168 -		datatype.equals(XMLSchema.NON_POSITIVE_INTEGER) ||
   1.169 -		datatype.equals(XMLSchema.NEGATIVE_INTEGER) ||
   1.170 -		datatype.equals(XMLSchema.NON_NEGATIVE_INTEGER) ||
   1.171 -		datatype.equals(XMLSchema.POSITIVE_INTEGER) ||
   1.172 -		datatype.equals(XMLSchema.UNSIGNED_LONG) ||
   1.173 -		datatype.equals(XMLSchema.UNSIGNED_INT) ||
   1.174 -		datatype.equals(XMLSchema.UNSIGNED_SHORT) ||
   1.175 -		datatype.equals(XMLSchema.UNSIGNED_BYTE);
   1.176 +		XMLSchema.INTEGER.equals(datatype) ||
   1.177 +		XMLSchema.LONG.equals(datatype) ||
   1.178 +		XMLSchema.INT.equals(datatype) ||
   1.179 +		XMLSchema.SHORT.equals(datatype) ||
   1.180 +		XMLSchema.BYTE.equals(datatype) ||
   1.181 +		XMLSchema.NON_POSITIVE_INTEGER.equals(datatype) ||
   1.182 +		XMLSchema.NEGATIVE_INTEGER.equals(datatype) ||
   1.183 +		XMLSchema.NON_NEGATIVE_INTEGER.equals(datatype) ||
   1.184 +		XMLSchema.POSITIVE_INTEGER.equals(datatype) ||
   1.185 +		XMLSchema.UNSIGNED_LONG.equals(datatype) ||
   1.186 +		XMLSchema.UNSIGNED_INT.equals(datatype) ||
   1.187 +		XMLSchema.UNSIGNED_SHORT.equals(datatype) ||
   1.188 +		XMLSchema.UNSIGNED_BYTE.equals(datatype);
   1.189  	}
   1.190  
   1.191  	/**
   1.192 @@ -258,8 +233,8 @@
   1.193  	 */
   1.194  	public static boolean isFloatingPointDatatype(URI datatype) {
   1.195  		return 
   1.196 -		datatype.equals(XMLSchema.FLOAT) || 
   1.197 -		datatype.equals(XMLSchema.DOUBLE);
   1.198 +		XMLSchema.FLOAT.equals(datatype) || 
   1.199 +		XMLSchema.DOUBLE.equals(datatype);
   1.200  	}
   1.201  
   1.202  	/**
   1.203 @@ -272,1597 +247,24 @@
   1.204  	 */
   1.205  	public static boolean isCalendarDatatype(URI datatype) {
   1.206  		return
   1.207 -		datatype.equals(XMLSchema.DATETIME) ||
   1.208 -		datatype.equals(XMLSchema.DATE)||
   1.209 -		datatype.equals(XMLSchema.TIME) ||
   1.210 -		datatype.equals(XMLSchema.GYEARMONTH) ||
   1.211 -		datatype.equals(XMLSchema.GMONTHDAY) ||
   1.212 -		datatype.equals(XMLSchema.GYEAR) ||
   1.213 -		datatype.equals(XMLSchema.GMONTH) ||
   1.214 -		datatype.equals(XMLSchema.GDAY);
   1.215 +		XMLSchema.DATETIME.equals(datatype) ||
   1.216 +		XMLSchema.DATE.equals(datatype) ||
   1.217 +		XMLSchema.TIME.equals(datatype) ||
   1.218 +		XMLSchema.GYEARMONTH.equals(datatype) ||
   1.219 +		XMLSchema.GMONTHDAY.equals(datatype) ||
   1.220 +		XMLSchema.GYEAR.equals(datatype) ||
   1.221 +		XMLSchema.GMONTH.equals(datatype) ||
   1.222 +		XMLSchema.GDAY.equals(datatype);
   1.223  
   1.224  	}
   1.225  
   1.226  	/**
   1.227 -	 * Checks whether the supplied datatype is ordered. The values of an ordered
   1.228 -	 * datatype can be compared to eachother using operators like <tt>&lt;</tt>
   1.229 -	 * and <tt>&gt;</tt>.
   1.230 +	 * Checks whether the supplied datatype is equal to xsd:boolean.
   1.231 +	 * 
   1.232 +	 * @param datatype
   1.233 +	 * @return
   1.234  	 */
   1.235 -	public static boolean isOrderedDatatype(URI datatype) {
   1.236 -		return isNumericDatatype(datatype) || isCalendarDatatype(datatype);
   1.237 +	public static boolean isBooleanDatatype(URI datatype) {
   1.238 +		return XMLSchema.BOOLEAN.equals(datatype);
   1.239  	}
   1.240 -
   1.241 -	/*----------------*
   1.242 -	 * Value checking *
   1.243 -	 *----------------*/
   1.244 -
   1.245 -	public static boolean isValidValue(String value, URI datatype) {
   1.246 -		boolean result = true;
   1.247 -
   1.248 -		if (datatype.equals(XMLSchema.DECIMAL)) {
   1.249 -			result = isValidDecimal(value);
   1.250 -		}
   1.251 -		else if (datatype.equals(XMLSchema.INTEGER)) {
   1.252 -			result = isValidInteger(value);
   1.253 -		}
   1.254 -		else if (datatype.equals(XMLSchema.NEGATIVE_INTEGER)) {
   1.255 -			result = isValidNegativeInteger(value);
   1.256 -		}
   1.257 -		else if (datatype.equals(XMLSchema.NON_POSITIVE_INTEGER)) {
   1.258 -			result = isValidNonPositiveInteger(value);
   1.259 -		}
   1.260 -		else if (datatype.equals(XMLSchema.NON_NEGATIVE_INTEGER)) {
   1.261 -			result = isValidNonNegativeInteger(value);
   1.262 -		}
   1.263 -		else if (datatype.equals(XMLSchema.POSITIVE_INTEGER)) {
   1.264 -			result = isValidPositiveInteger(value);
   1.265 -		}
   1.266 -		else if (datatype.equals(XMLSchema.LONG)) {
   1.267 -			result = isValidLong(value);
   1.268 -		}
   1.269 -		else if (datatype.equals(XMLSchema.INT)) {
   1.270 -			result = isValidInt(value);
   1.271 -		}
   1.272 -		else if (datatype.equals(XMLSchema.SHORT)) {
   1.273 -			result = isValidShort(value);
   1.274 -		}
   1.275 -		else if (datatype.equals(XMLSchema.BYTE)) {
   1.276 -			result = isValidByte(value);
   1.277 -		}
   1.278 -		else if (datatype.equals(XMLSchema.UNSIGNED_LONG)) {
   1.279 -			result = isValidUnsignedLong(value);
   1.280 -		}
   1.281 -		else if (datatype.equals(XMLSchema.UNSIGNED_INT)) {
   1.282 -			result = isValidUnsignedInt(value);
   1.283 -		}
   1.284 -		else if (datatype.equals(XMLSchema.UNSIGNED_SHORT)) {
   1.285 -			result = isValidUnsignedShort(value);
   1.286 -		}
   1.287 -		else if (datatype.equals(XMLSchema.UNSIGNED_BYTE)) {
   1.288 -			result = isValidUnsignedByte(value);
   1.289 -		}
   1.290 -		else if (datatype.equals(XMLSchema.FLOAT)) {
   1.291 -			result = isValidFloat(value);
   1.292 -		}
   1.293 -		else if (datatype.equals(XMLSchema.DOUBLE)) {
   1.294 -			result = isValidDouble(value);
   1.295 -		}
   1.296 -		else if (datatype.equals(XMLSchema.BOOLEAN)) {
   1.297 -			result = isValidBoolean(value);
   1.298 -		}
   1.299 -		else if (datatype.equals(XMLSchema.DATETIME)) {
   1.300 -			result = isValidDateTime(value);
   1.301 -		}
   1.302 -
   1.303 -		return result;
   1.304 -	}
   1.305 -
   1.306 -	public static boolean isValidDecimal(String value) {
   1.307 -		try {
   1.308 -			normalizeDecimal(value);
   1.309 -			return true;
   1.310 -		}
   1.311 -		catch (IllegalArgumentException e) {
   1.312 -			return false;
   1.313 -		}
   1.314 -	}
   1.315 -
   1.316 -	public static boolean isValidInteger(String value) {
   1.317 -		try {
   1.318 -			normalizeInteger(value);
   1.319 -			return true;
   1.320 -		}
   1.321 -		catch (IllegalArgumentException e) {
   1.322 -			return false;
   1.323 -		}
   1.324 -	}
   1.325 -
   1.326 -	public static boolean isValidNegativeInteger(String value) {
   1.327 -		try {
   1.328 -			normalizeNegativeInteger(value);
   1.329 -			return true;
   1.330 -		}
   1.331 -		catch (IllegalArgumentException e) {
   1.332 -			return false;
   1.333 -		}
   1.334 -	}
   1.335 -
   1.336 -	public static boolean isValidNonPositiveInteger(String value) {
   1.337 -		try {
   1.338 -			normalizeNonPositiveInteger(value);
   1.339 -			return true;
   1.340 -		}
   1.341 -		catch (IllegalArgumentException e) {
   1.342 -			return false;
   1.343 -		}
   1.344 -	}
   1.345 -
   1.346 -	public static boolean isValidNonNegativeInteger(String value) {
   1.347 -		try {
   1.348 -			normalizeNonNegativeInteger(value);
   1.349 -			return true;
   1.350 -		}
   1.351 -		catch (IllegalArgumentException e) {
   1.352 -			return false;
   1.353 -		}
   1.354 -	}
   1.355 -
   1.356 -	public static boolean isValidPositiveInteger(String value) {
   1.357 -		try {
   1.358 -			normalizePositiveInteger(value);
   1.359 -			return true;
   1.360 -		}
   1.361 -		catch (IllegalArgumentException e) {
   1.362 -			return false;
   1.363 -		}
   1.364 -	}
   1.365 -	public static boolean isValidLong(String value) {
   1.366 -		try {
   1.367 -			normalizeLong(value);
   1.368 -			return true;
   1.369 -		}
   1.370 -		catch (IllegalArgumentException e) {
   1.371 -			return false;
   1.372 -		}
   1.373 -	}
   1.374 -
   1.375 -	public static boolean isValidInt(String value) {
   1.376 -		try {
   1.377 -			normalizeInt(value);
   1.378 -			return true;
   1.379 -		}
   1.380 -		catch (IllegalArgumentException e) {
   1.381 -			return false;
   1.382 -		}
   1.383 -	}
   1.384 -
   1.385 -	public static boolean isValidShort(String value) {
   1.386 -		try {
   1.387 -			normalizeShort(value);
   1.388 -			return true;
   1.389 -		}
   1.390 -		catch (IllegalArgumentException e) {
   1.391 -			return false;
   1.392 -		}
   1.393 -	}
   1.394 -
   1.395 -	public static boolean isValidByte(String value) {
   1.396 -		try {
   1.397 -			normalizeByte(value);
   1.398 -			return true;
   1.399 -		}
   1.400 -		catch (IllegalArgumentException e) {
   1.401 -			return false;
   1.402 -		}
   1.403 -	}
   1.404 -
   1.405 -	public static boolean isValidUnsignedLong(String value) {
   1.406 -		try {
   1.407 -			normalizeUnsignedLong(value);
   1.408 -			return true;
   1.409 -		}
   1.410 -		catch (IllegalArgumentException e) {
   1.411 -			return false;
   1.412 -		}
   1.413 -	}
   1.414 -
   1.415 -	public static boolean isValidUnsignedInt(String value) {
   1.416 -		try {
   1.417 -			normalizeUnsignedInt(value);
   1.418 -			return true;
   1.419 -		}
   1.420 -		catch (IllegalArgumentException e) {
   1.421 -			return false;
   1.422 -		}
   1.423 -	}
   1.424 -
   1.425 -	public static boolean isValidUnsignedShort(String value) {
   1.426 -		try {
   1.427 -			normalizeUnsignedShort(value);
   1.428 -			return true;
   1.429 -		}
   1.430 -		catch (IllegalArgumentException e) {
   1.431 -			return false;
   1.432 -		}
   1.433 -	}
   1.434 -
   1.435 -	public static boolean isValidUnsignedByte(String value) {
   1.436 -		try {
   1.437 -			normalizeUnsignedByte(value);
   1.438 -			return true;
   1.439 -		}
   1.440 -		catch (IllegalArgumentException e) {
   1.441 -			return false;
   1.442 -		}
   1.443 -	}
   1.444 -
   1.445 -	public static boolean isValidFloat(String value) {
   1.446 -		try {
   1.447 -			normalizeFloat(value);
   1.448 -			return true;
   1.449 -		}
   1.450 -		catch (IllegalArgumentException e) {
   1.451 -			return false;
   1.452 -		}
   1.453 -	}
   1.454 -
   1.455 -	public static boolean isValidDouble(String value) {
   1.456 -		try {
   1.457 -			normalizeDouble(value);
   1.458 -			return true;
   1.459 -		}
   1.460 -		catch (IllegalArgumentException e) {
   1.461 -			return false;
   1.462 -		}
   1.463 -	}
   1.464 -
   1.465 -	public static boolean isValidBoolean(String value) {
   1.466 -		try {
   1.467 -			normalizeBoolean(value);
   1.468 -			return true;
   1.469 -		}
   1.470 -		catch (IllegalArgumentException e) {
   1.471 -			return false;
   1.472 -		}
   1.473 -	}
   1.474 -
   1.475 -	public static boolean isValidDateTime(String value) {
   1.476 -		try {
   1.477 -			@SuppressWarnings("unused")
   1.478 -			XMLDateTime dt = new XMLDateTime(value);
   1.479 -			return true;
   1.480 -		}
   1.481 -		catch (IllegalArgumentException e) {
   1.482 -			return false;
   1.483 -		}
   1.484 -	}
   1.485 -
   1.486 -	/*---------------------*
   1.487 -	 * Value normalization *
   1.488 -	 *---------------------*/
   1.489 -
   1.490 -	/**
   1.491 -	 * Normalizes the supplied value according to the normalization rules for the
   1.492 -	 * supplied datatype.
   1.493 -	 * 
   1.494 -	 * @param value
   1.495 -	 *        The value to normalize.
   1.496 -	 * @param datatype
   1.497 -	 *        The value's datatype.
   1.498 -	 * @return The normalized value if there are any (supported) normalization
   1.499 -	 *         rules for the supplied datatype, or the original supplied value
   1.500 -	 *         otherwise.
   1.501 -	 * @throws IllegalArgumentException
   1.502 -	 *         If the supplied value is illegal considering the supplied
   1.503 -	 *         datatype.
   1.504 -	 */
   1.505 -	public static String normalize(String value, URI datatype) {
   1.506 -		String result = value;
   1.507 -
   1.508 -		if (datatype.equals(XMLSchema.DECIMAL)) {
   1.509 -			result = normalizeDecimal(value);
   1.510 -		}
   1.511 -		else if (datatype.equals(XMLSchema.INTEGER)) {
   1.512 -			result = normalizeInteger(value);
   1.513 -		}
   1.514 -		else if (datatype.equals(XMLSchema.NEGATIVE_INTEGER)) {
   1.515 -			result = normalizeNegativeInteger(value);
   1.516 -		}
   1.517 -		else if (datatype.equals(XMLSchema.NON_POSITIVE_INTEGER)) {
   1.518 -			result = normalizeNonPositiveInteger(value);
   1.519 -		}
   1.520 -		else if (datatype.equals(XMLSchema.NON_NEGATIVE_INTEGER)) {
   1.521 -			result = normalizeNonNegativeInteger(value);
   1.522 -		}
   1.523 -		else if (datatype.equals(XMLSchema.POSITIVE_INTEGER)) {
   1.524 -			result = normalizePositiveInteger(value);
   1.525 -		}
   1.526 -		else if (datatype.equals(XMLSchema.LONG)) {
   1.527 -			result = normalizeLong(value);
   1.528 -		}
   1.529 -		else if (datatype.equals(XMLSchema.INT)) {
   1.530 -			result = normalizeInt(value);
   1.531 -		}
   1.532 -		else if (datatype.equals(XMLSchema.SHORT)) {
   1.533 -			result = normalizeShort(value);
   1.534 -		}
   1.535 -		else if (datatype.equals(XMLSchema.BYTE)) {
   1.536 -			result = normalizeByte(value);
   1.537 -		}
   1.538 -		else if (datatype.equals(XMLSchema.UNSIGNED_LONG)) {
   1.539 -			result = normalizeUnsignedLong(value);
   1.540 -		}
   1.541 -		else if (datatype.equals(XMLSchema.UNSIGNED_INT)) {
   1.542 -			result = normalizeUnsignedInt(value);
   1.543 -		}
   1.544 -		else if (datatype.equals(XMLSchema.UNSIGNED_SHORT)) {
   1.545 -			result = normalizeUnsignedShort(value);
   1.546 -		}
   1.547 -		else if (datatype.equals(XMLSchema.UNSIGNED_BYTE)) {
   1.548 -			result = normalizeUnsignedByte(value);
   1.549 -		}
   1.550 -		else if (datatype.equals(XMLSchema.FLOAT)) {
   1.551 -			result = normalizeFloat(value);
   1.552 -		}
   1.553 -		else if (datatype.equals(XMLSchema.DOUBLE)) {
   1.554 -			result = normalizeDouble(value);
   1.555 -		}
   1.556 -		else if (datatype.equals(XMLSchema.BOOLEAN)) {
   1.557 -			result = normalizeBoolean(value);
   1.558 -		}
   1.559 -		else if (datatype.equals(XMLSchema.DATETIME)) {
   1.560 -			result = normalizeDateTime(value);
   1.561 -		}
   1.562 -
   1.563 -		return result;
   1.564 -	}
   1.565 -
   1.566 -	/**
   1.567 -	 * Normalizes a boolean value to its canonical representation. More
   1.568 -	 * specifically, the values <tt>1</tt> and <tt>0</tt> will be normalized
   1.569 -	 * to the canonical values <tt>true</tt> and <tt>false</tt>,
   1.570 -	 * respectively. Supplied canonical values will remain as is.
   1.571 -	 * 
   1.572 -	 * @param value
   1.573 -	 *        The boolean value to normalize.
   1.574 -	 * @return The normalized value.
   1.575 -	 * @throws IllegalArgumentException
   1.576 -	 *         If the supplied value is not a legal boolean.
   1.577 -	 */
   1.578 -	public static String normalizeBoolean(String value) {
   1.579 -		value = collapseWhiteSpace(value);
   1.580 -
   1.581 -		if (value.equals("1")) {
   1.582 -			return "true";
   1.583 -		}
   1.584 -		else if (value.equals("0")) {
   1.585 -			return "false";
   1.586 -		}
   1.587 -		else if (value.equals("true") || value.equals("false")) {
   1.588 -			return value;
   1.589 -		}
   1.590 -		else {
   1.591 -			throw new IllegalArgumentException("Not a legal boolean value: " + value);
   1.592 -		}
   1.593 -	}
   1.594 -
   1.595 -	/**
   1.596 -	 * Normalizes a decimal to its canonical representation. For example:
   1.597 -	 * <tt>120</tt> becomes <tt>120.0</tt>, <tt>+.3</tt> becomes
   1.598 -	 * <tt>0.3</tt>, <tt>00012.45000</tt> becomes <tt>12.45</tt> and
   1.599 -	 * <tt>-.0</tt> becomes <tt>0.0</tt>.
   1.600 -	 * 
   1.601 -	 * @param decimal
   1.602 -	 *        The decimal to normalize.
   1.603 -	 * @return The canonical representation of <tt>decimal</tt>.
   1.604 -	 * @throws IllegalArgumentException
   1.605 -	 *         If one of the supplied strings is not a legal decimal.
   1.606 -	 */
   1.607 -	public static String normalizeDecimal(String decimal) {
   1.608 -		decimal = collapseWhiteSpace(decimal);
   1.609 -
   1.610 -		String errMsg = "Not a legal decimal: " + decimal;
   1.611 -
   1.612 -		int decLength = decimal.length();
   1.613 -		StringBuilder result = new StringBuilder(decLength + 2);
   1.614 -
   1.615 -		if (decLength == 0) {
   1.616 -			throwIAE(errMsg);
   1.617 -		}
   1.618 -
   1.619 -		boolean isZeroPointZero = true;
   1.620 -
   1.621 -		// process any sign info
   1.622 -		int idx = 0;
   1.623 -		if (decimal.charAt(idx) == '-') {
   1.624 -			result.append('-');
   1.625 -			idx++;
   1.626 -		}
   1.627 -		else if (decimal.charAt(idx) == '+') {
   1.628 -			idx++;
   1.629 -		}
   1.630 -
   1.631 -		if (idx == decLength) {
   1.632 -			throwIAE(errMsg);
   1.633 -		}
   1.634 -
   1.635 -		// skip any leading zeros
   1.636 -		while (idx < decLength && decimal.charAt(idx) == '0') {
   1.637 -			idx++;
   1.638 -		}
   1.639 -
   1.640 -		// Process digits before the dot
   1.641 -		if (idx == decLength) {
   1.642 -			// decimal consists of zeros only
   1.643 -			result.append('0');
   1.644 -		}
   1.645 -		else if (idx < decLength && decimal.charAt(idx) == '.') {
   1.646 -			// no non-zero digit before the dot
   1.647 -			result.append('0');
   1.648 -		}
   1.649 -		else {
   1.650 -			isZeroPointZero = false;
   1.651 -
   1.652 -			// Copy any digits before the dot
   1.653 -			while (idx < decLength) {
   1.654 -				char c = decimal.charAt(idx);
   1.655 -				if (c == '.') {
   1.656 -					break;
   1.657 -				}
   1.658 -				if (!isDigit(c)) {
   1.659 -					throwIAE(errMsg);
   1.660 -				}
   1.661 -				result.append(c);
   1.662 -				idx++;
   1.663 -			}
   1.664 -		}
   1.665 -
   1.666 -		result.append('.');
   1.667 -
   1.668 -		// Process digits after the dot
   1.669 -		if (idx == decLength) {
   1.670 -			// No dot was found in the decimal
   1.671 -			result.append('0');
   1.672 -		}
   1.673 -		else {
   1.674 -			idx++;
   1.675 -
   1.676 -			// search last non-zero digit
   1.677 -			int lastIdx = decLength - 1;
   1.678 -			while (lastIdx >= 0 && decimal.charAt(lastIdx) == '0') {
   1.679 -				lastIdx--;
   1.680 -			}
   1.681 -
   1.682 -			if (idx > lastIdx) {
   1.683 -				// No non-zero digits found
   1.684 -				result.append('0');
   1.685 -			}
   1.686 -			else {
   1.687 -				isZeroPointZero = false;
   1.688 -
   1.689 -				while (idx <= lastIdx) {
   1.690 -					char c = decimal.charAt(idx);
   1.691 -					if (!isDigit(c)) {
   1.692 -						throwIAE(errMsg);
   1.693 -					}
   1.694 -					result.append(c);
   1.695 -					idx++;
   1.696 -				}
   1.697 -			}
   1.698 -		}
   1.699 -
   1.700 -		if (isZeroPointZero) {
   1.701 -			// Make sure we don't return "-0.0"
   1.702 -			return "0.0";
   1.703 -		}
   1.704 -		else {
   1.705 -			return result.toString();
   1.706 -		}
   1.707 -	}
   1.708 -
   1.709 -	/**
   1.710 -	 * Normalizes an integer to its canonical representation. For example:
   1.711 -	 * <tt>+120</tt> becomes <tt>120</tt> and <tt>00012</tt> becomes
   1.712 -	 * <tt>12</tt>.
   1.713 -	 * 
   1.714 -	 * @param value
   1.715 -	 *        The value to normalize.
   1.716 -	 * @return The canonical representation of <tt>value</tt>.
   1.717 -	 * @throws IllegalArgumentException
   1.718 -	 *         If the supplied value is not a legal integer.
   1.719 -	 */
   1.720 -	public static String normalizeInteger(String value) {
   1.721 -		return normalizeIntegerValue(value, null, null);
   1.722 -	}
   1.723 -
   1.724 -	/**
   1.725 -	 * Normalizes an xsd:negativeInteger.
   1.726 -	 */
   1.727 -	public static String normalizeNegativeInteger(String value) {
   1.728 -		return normalizeIntegerValue(value, null, "-1");
   1.729 -	}
   1.730 -
   1.731 -	/**
   1.732 -	 * Normalizes an xsd:nonPositiveInteger.
   1.733 -	 */
   1.734 -	public static String normalizeNonPositiveInteger(String value) {
   1.735 -		return normalizeIntegerValue(value, null, "0");
   1.736 -	}
   1.737 -
   1.738 -	/**
   1.739 -	 * Normalizes an xsd:nonNegativeInteger.
   1.740 -	 */
   1.741 -	public static String normalizeNonNegativeInteger(String value) {
   1.742 -		return normalizeIntegerValue(value, "0", null);
   1.743 -	}
   1.744 -
   1.745 -	/**
   1.746 -	 * Normalizes an xsd:positiveInteger.
   1.747 -	 */
   1.748 -	public static String normalizePositiveInteger(String value) {
   1.749 -		return normalizeIntegerValue(value, "1", null);
   1.750 -	}
   1.751 -
   1.752 -	/**
   1.753 -	 * Normalizes an xsd:long.
   1.754 -	 */
   1.755 -	public static String normalizeLong(String value) {
   1.756 -		return normalizeIntegerValue(value, "-9223372036854775808", "9223372036854775807");
   1.757 -	}
   1.758 -
   1.759 -	/**
   1.760 -	 * Normalizes an xsd:int.
   1.761 -	 */
   1.762 -	public static String normalizeInt(String value) {
   1.763 -		return normalizeIntegerValue(value, "-2147483648", "2147483647");
   1.764 -	}
   1.765 -
   1.766 -	/**
   1.767 -	 * Normalizes an xsd:short.
   1.768 -	 */
   1.769 -	public static String normalizeShort(String value) {
   1.770 -		return normalizeIntegerValue(value, "-32768", "32767");
   1.771 -	}
   1.772 -
   1.773 -	/**
   1.774 -	 * Normalizes an xsd:byte.
   1.775 -	 */
   1.776 -	public static String normalizeByte(String value) {
   1.777 -		return normalizeIntegerValue(value, "-128", "127");
   1.778 -	}
   1.779 -
   1.780 -	/**
   1.781 -	 * Normalizes an xsd:unsignedLong.
   1.782 -	 */
   1.783 -	public static String normalizeUnsignedLong(String value) {
   1.784 -		return normalizeIntegerValue(value, "0", "18446744073709551615");
   1.785 -	}
   1.786 -
   1.787 -	/**
   1.788 -	 * Normalizes an xsd:unsignedInt.
   1.789 -	 */
   1.790 -	public static String normalizeUnsignedInt(String value) {
   1.791 -		return normalizeIntegerValue(value, "0", "4294967295");
   1.792 -	}
   1.793 -
   1.794 -	/**
   1.795 -	 * Normalizes an xsd:unsignedShort.
   1.796 -	 */
   1.797 -	public static String normalizeUnsignedShort(String value) {
   1.798 -		return normalizeIntegerValue(value, "0", "65535");
   1.799 -	}
   1.800 -
   1.801 -	/**
   1.802 -	 * Normalizes an xsd:unsignedByte.
   1.803 -	 */
   1.804 -	public static String normalizeUnsignedByte(String value) {
   1.805 -		return normalizeIntegerValue(value, "0", "255");
   1.806 -	}
   1.807 -
   1.808 -	/**
   1.809 -	 * Normalizes an integer to its canonical representation and checks that the
   1.810 -	 * value is in the range [minValue, maxValue].
   1.811 -	 */
   1.812 -	private static String normalizeIntegerValue(String integer, String minValue, String maxValue) {
   1.813 -		integer = collapseWhiteSpace(integer);
   1.814 -
   1.815 -		String errMsg = "Not a legal integer: " + integer;
   1.816 -
   1.817 -		int intLength = integer.length();
   1.818 -
   1.819 -		if (intLength == 0) {
   1.820 -			throwIAE(errMsg);
   1.821 -		}
   1.822 -
   1.823 -		int idx = 0;
   1.824 -
   1.825 -		// process any sign info
   1.826 -		boolean isNegative = false;
   1.827 -		if (integer.charAt(idx) == '-') {
   1.828 -			isNegative = true;
   1.829 -			idx++;
   1.830 -		}
   1.831 -		else if (integer.charAt(idx) == '+') {
   1.832 -			idx++;
   1.833 -		}
   1.834 -
   1.835 -		if (idx == intLength) {
   1.836 -			throwIAE(errMsg);
   1.837 -		}
   1.838 -
   1.839 -		if (integer.charAt(idx) == '0' && idx < intLength - 1) {
   1.840 -			// integer starts with a zero followed by more characters,
   1.841 -			// skip any leading zeros
   1.842 -			idx++;
   1.843 -			while (idx < intLength - 1 && integer.charAt(idx) == '0') {
   1.844 -				idx++;
   1.845 -			}
   1.846 -		}
   1.847 -
   1.848 -		String norm = integer.substring(idx);
   1.849 -
   1.850 -		// Check that all characters in 'norm' are digits
   1.851 -		for (int i = 0; i < norm.length(); i++) {
   1.852 -			if (!isDigit(norm.charAt(i))) {
   1.853 -				throwIAE(errMsg);
   1.854 -			}
   1.855 -		}
   1.856 -
   1.857 -		if (isNegative && norm.charAt(0) != '0') {
   1.858 -			norm = "-" + norm;
   1.859 -		}
   1.860 -
   1.861 -		// Check lower and upper bounds, if applicable
   1.862 -		if (minValue != null) {
   1.863 -			if (compareCanonicalIntegers(norm, minValue) < 0) {
   1.864 -				throwIAE("Value smaller than minimum value");
   1.865 -			}
   1.866 -		}
   1.867 -		if (maxValue != null) {
   1.868 -			if (compareCanonicalIntegers(norm, maxValue) > 0) {
   1.869 -				throwIAE("Value larger than maximum value");
   1.870 -			}
   1.871 -		}
   1.872 -
   1.873 -		return norm;
   1.874 -	}
   1.875 -
   1.876 -	/**
   1.877 -	 * Normalizes a float to its canonical representation.
   1.878 -	 * 
   1.879 -	 * @param value
   1.880 -	 *        The value to normalize.
   1.881 -	 * @return The canonical representation of <tt>value</tt>.
   1.882 -	 * @throws IllegalArgumentException
   1.883 -	 *         If the supplied value is not a legal float.
   1.884 -	 */
   1.885 -	public static String normalizeFloat(String value) {
   1.886 -		return normalizeFPNumber(value, "-16777215.0", "16777215.0", "-149", "104");
   1.887 -	}
   1.888 -
   1.889 -	/**
   1.890 -	 * Normalizes a double to its canonical representation.
   1.891 -	 * 
   1.892 -	 * @param value
   1.893 -	 *        The value to normalize.
   1.894 -	 * @return The canonical representation of <tt>value</tt>.
   1.895 -	 * @throws IllegalArgumentException
   1.896 -	 *         If the supplied value is not a legal double.
   1.897 -	 */
   1.898 -	public static String normalizeDouble(String value) {
   1.899 -		return normalizeFPNumber(value, "-9007199254740991.0", "9007199254740991.0", "-1075", "970");
   1.900 -	}
   1.901 -
   1.902 -	/**
   1.903 -	 * Normalizes a floating point number to its canonical representation.
   1.904 -	 * 
   1.905 -	 * @param value
   1.906 -	 *        The value to normalize.
   1.907 -	 * @return The canonical representation of <tt>value</tt>.
   1.908 -	 * @throws IllegalArgumentException
   1.909 -	 *         If the supplied value is not a legal floating point number.
   1.910 -	 */
   1.911 -	public static String normalizeFPNumber(String value) {
   1.912 -		return normalizeFPNumber(value, null, null, null, null);
   1.913 -	}
   1.914 -
   1.915 -	/**
   1.916 -	 * Normalizes a floating point number to its canonical representation.
   1.917 -	 * 
   1.918 -	 * @param value
   1.919 -	 *        The value to normalize.
   1.920 -	 * @param minMantissa
   1.921 -	 *        A normalized decimal indicating the lowest value that the mantissa
   1.922 -	 *        may have.
   1.923 -	 * @param maxMantissa
   1.924 -	 *        A normalized decimal indicating the highest value that the mantissa
   1.925 -	 *        may have.
   1.926 -	 * @param minExponent
   1.927 -	 *        A normalized integer indicating the lowest value that the exponent
   1.928 -	 *        may have.
   1.929 -	 * @param maxExponent
   1.930 -	 *        A normalized integer indicating the highest value that the exponent
   1.931 -	 *        may have.
   1.932 -	 * @return The canonical representation of <tt>value</tt>.
   1.933 -	 * @throws IllegalArgumentException
   1.934 -	 *         If the supplied value is not a legal floating point number.
   1.935 -	 */
   1.936 -	private static String normalizeFPNumber(
   1.937 -			String value,
   1.938 -			String minMantissa, String maxMantissa,
   1.939 -			String minExponent, String maxExponent)
   1.940 -	{
   1.941 -		value = collapseWhiteSpace(value);
   1.942 -
   1.943 -		// handle special values
   1.944 -		if (value.equals("INF") || value.equals("-INF") || value.equals("NaN")) {
   1.945 -			return value;
   1.946 -		}
   1.947 -
   1.948 -		// Search for the exponent character E or e
   1.949 -		int eIdx = value.indexOf('E');
   1.950 -		if (eIdx == -1) {
   1.951 -			// try lower case
   1.952 -			eIdx = value.indexOf('e');
   1.953 -		}
   1.954 -
   1.955 -		// Extract mantissa and exponent
   1.956 -		String mantissa, exponent;
   1.957 -		if (eIdx == -1) {
   1.958 -			mantissa = normalizeDecimal(value);
   1.959 -			exponent = "0";
   1.960 -		}
   1.961 -		else {
   1.962 -			mantissa = normalizeDecimal(value.substring(0, eIdx));
   1.963 -			exponent = normalizeInteger(value.substring(eIdx + 1));
   1.964 -		}
   1.965 -
   1.966 -		// Check lower and upper bounds, if applicable
   1.967 -		if (minMantissa != null) {
   1.968 -			if (compareCanonicalDecimals(mantissa, minMantissa) < 0) {
   1.969 -				throwIAE("Mantissa smaller than minimum value (" + minMantissa + ")");
   1.970 -			}
   1.971 -		}
   1.972 -		if (maxMantissa != null) {
   1.973 -			if (compareCanonicalDecimals(mantissa, maxMantissa) > 0) {
   1.974 -				throwIAE("Mantissa larger than maximum value (" + maxMantissa + ")");
   1.975 -			}
   1.976 -		}
   1.977 -		if (minExponent != null) {
   1.978 -			if (compareCanonicalIntegers(exponent, minExponent) < 0) {
   1.979 -				throwIAE("Exponent smaller than minimum value (" + minExponent + ")");
   1.980 -			}
   1.981 -		}
   1.982 -		if (maxExponent != null) {
   1.983 -			if (compareCanonicalIntegers(exponent, maxExponent) > 0) {
   1.984 -				throwIAE("Exponent larger than maximum value (" + maxExponent + ")");
   1.985 -			}
   1.986 -		}
   1.987 -
   1.988 -		// Normalize mantissa to one non-zero digit before the dot
   1.989 -		int shift = 0;
   1.990 -
   1.991 -		int dotIdx = mantissa.indexOf('.');
   1.992 -		int digitCount = dotIdx;
   1.993 -		if (mantissa.charAt(0) == '-') {
   1.994 -			digitCount--;
   1.995 -		}
   1.996 -
   1.997 -		if (digitCount > 1) {
   1.998 -			// more than one digit before the dot, e.g 123.45, -10.0 or 100.0
   1.999 -			StringBuilder sb = new StringBuilder(mantissa.length());
  1.1000 -			int firstDigitIdx = 0;
  1.1001 -			if (mantissa.charAt(0) == '-') {
  1.1002 -				sb.append('-');
  1.1003 -				firstDigitIdx = 1;
  1.1004 -			}
  1.1005 -			sb.append(mantissa.charAt(firstDigitIdx));
  1.1006 -			sb.append('.');
  1.1007 -			sb.append(mantissa.substring(firstDigitIdx + 1, dotIdx));
  1.1008 -			sb.append(mantissa.substring(dotIdx + 1));
  1.1009 -
  1.1010 -			mantissa = sb.toString();
  1.1011 -
  1.1012 -			// Check if the mantissa has excessive trailing zeros.
  1.1013 -			// For example, 100.0 will be normalize to 1.000 and
  1.1014 -			// -10.0 to -1.00.
  1.1015 -			int nonZeroIdx = mantissa.length() - 1;
  1.1016 -			while (nonZeroIdx >= 3 && mantissa.charAt(nonZeroIdx) == '0') {
  1.1017 -				nonZeroIdx--;
  1.1018 -			}
  1.1019 -
  1.1020 -			if (nonZeroIdx < 3 && mantissa.charAt(0) == '-') {
  1.1021 -				nonZeroIdx++;
  1.1022 -			}
  1.1023 -
  1.1024 -			if (nonZeroIdx < mantissa.length() - 1) {
  1.1025 -				mantissa = mantissa.substring(0, nonZeroIdx + 1);
  1.1026 -			}
  1.1027 -
  1.1028 -			shift = 1 - digitCount;
  1.1029 -		}
  1.1030 -		else if (mantissa.startsWith("0.") || mantissa.startsWith("-0.")) {
  1.1031 -			// Example mantissas: 0.0, -0.1, 0.00345 and 0.09
  1.1032 -			// search first non-zero digit
  1.1033 -			int nonZeroIdx = 2;
  1.1034 -			while (nonZeroIdx < mantissa.length() && mantissa.charAt(nonZeroIdx) == '0') {
  1.1035 -				nonZeroIdx++;
  1.1036 -			}
  1.1037 -
  1.1038 -			// 0.0 does not need any normalization:
  1.1039 -			if (nonZeroIdx < mantissa.length()) {
  1.1040 -				StringBuilder sb = new StringBuilder(mantissa.length());
  1.1041 -				sb.append(mantissa.charAt(nonZeroIdx));
  1.1042 -				sb.append('.');
  1.1043 -				if (nonZeroIdx == mantissa.length() - 1) {
  1.1044 -					// There was only one non-zero digit, e.g. as in 0.09
  1.1045 -					sb.append('0');
  1.1046 -				}
  1.1047 -				else {
  1.1048 -					sb.append(mantissa.substring(nonZeroIdx + 1));
  1.1049 -				}
  1.1050 -
  1.1051 -				mantissa = sb.toString();
  1.1052 -				shift = nonZeroIdx - 1;
  1.1053 -			}
  1.1054 -		}
  1.1055 -
  1.1056 -		if (shift != 0) {
  1.1057 -			try {
  1.1058 -				int exp = Integer.parseInt(exponent);
  1.1059 -				exponent = String.valueOf(exp - shift);
  1.1060 -			}
  1.1061 -			catch (NumberFormatException e) {
  1.1062 -				throw new RuntimeException("NumberFormatException: " + e.getMessage());
  1.1063 -			}
  1.1064 -		}
  1.1065 -
  1.1066 -		return mantissa + "E" + exponent;
  1.1067 -	}
  1.1068 -
  1.1069 -	/**
  1.1070 -	 * Normalizes an xsd:dateTime.
  1.1071 -	 * 
  1.1072 -	 * @param value
  1.1073 -	 *        The value to normalize.
  1.1074 -	 * @return The normalized value.
  1.1075 -	 * @throws IllegalArgumentException
  1.1076 -	 *         If the supplied value is not a legal xsd:dateTime value.
  1.1077 -	 */
  1.1078 -	public static String normalizeDateTime(String value) {
  1.1079 -		XMLDateTime dt = new XMLDateTime(value);
  1.1080 -		dt.normalize();
  1.1081 -		return dt.toString();
  1.1082 -	}
  1.1083 -
  1.1084 -	/**
  1.1085 -	 * Replaces all occurences of #x9 (tab), #xA (line feed) and #xD (carriage
  1.1086 -	 * return) with #x20 (space), as specified for whiteSpace facet
  1.1087 -	 * <tt>replace</tt>.
  1.1088 -	 */
  1.1089 -	// private static String replaceWhiteSpace(String s) {
  1.1090 -	// s = StringUtil.gsub("\t", " ", s);
  1.1091 -	// s = StringUtil.gsub("\r", " ", s);
  1.1092 -	// s = StringUtil.gsub("\n", " ", s);
  1.1093 -	// return s;
  1.1094 -	// }
  1.1095 -
  1.1096 -	/**
  1.1097 -	 * Replaces all contiguous sequences of #x9 (tab), #xA (line feed) and #xD
  1.1098 -	 * (carriage return) with a single #x20 (space) character, and removes any
  1.1099 -	 * leading and trailing whitespace characters, as specified for whiteSpace
  1.1100 -	 * facet <tt>collapse</tt>.
  1.1101 -	 */
  1.1102 -	public static String collapseWhiteSpace(String s) {
  1.1103 -		StringBuilder sb = new StringBuilder(s.length());
  1.1104 -
  1.1105 -		StringTokenizer st = new StringTokenizer(s, "\t\r\n ");
  1.1106 -
  1.1107 -		if (st.hasMoreTokens()) {
  1.1108 -			sb.append(st.nextToken());
  1.1109 -		}
  1.1110 -
  1.1111 -		while (st.hasMoreTokens()) {
  1.1112 -			sb.append(' ').append(st.nextToken());
  1.1113 -		}
  1.1114 -
  1.1115 -		return sb.toString();
  1.1116 -	}
  1.1117 -
  1.1118 -	/*------------------*
  1.1119 -	 * Value comparison *
  1.1120 -	 *------------------*/
  1.1121 -
  1.1122 -	public static int compare(String value1, String value2, URI datatype) {
  1.1123 -		if (datatype.equals(XMLSchema.DECIMAL)) {
  1.1124 -			return compareDecimals(value1, value2);
  1.1125 -		}
  1.1126 -		else if (datatype.equals(XMLSchema.INTEGER)) {
  1.1127 -			return compareIntegers(value1, value2);
  1.1128 -		}
  1.1129 -		else if (datatype.equals(XMLSchema.NEGATIVE_INTEGER)) {
  1.1130 -			return compareNegativeIntegers(value1, value2);
  1.1131 -		}
  1.1132 -		else if (datatype.equals(XMLSchema.NON_POSITIVE_INTEGER)) {
  1.1133 -			return compareNonPositiveIntegers(value1, value2);
  1.1134 -		}
  1.1135 -		else if (datatype.equals(XMLSchema.NON_NEGATIVE_INTEGER)) {
  1.1136 -			return compareNonNegativeIntegers(value1, value2);
  1.1137 -		}
  1.1138 -		else if (datatype.equals(XMLSchema.POSITIVE_INTEGER)) {
  1.1139 -			return comparePositiveIntegers(value1, value2);
  1.1140 -		}
  1.1141 -		else if (datatype.equals(XMLSchema.LONG)) {
  1.1142 -			return compareLongs(value1, value2);
  1.1143 -		}
  1.1144 -		else if (datatype.equals(XMLSchema.INT)) {
  1.1145 -			return compareInts(value1, value2);
  1.1146 -		}
  1.1147 -		else if (datatype.equals(XMLSchema.SHORT)) {
  1.1148 -			return compareShorts(value1, value2);
  1.1149 -		}
  1.1150 -		else if (datatype.equals(XMLSchema.BYTE)) {
  1.1151 -			return compareBytes(value1, value2);
  1.1152 -		}
  1.1153 -		else if (datatype.equals(XMLSchema.UNSIGNED_LONG)) {
  1.1154 -			return compareUnsignedLongs(value1, value2);
  1.1155 -		}
  1.1156 -		else if (datatype.equals(XMLSchema.UNSIGNED_INT)) {
  1.1157 -			return compareUnsignedInts(value1, value2);
  1.1158 -		}
  1.1159 -		else if (datatype.equals(XMLSchema.UNSIGNED_SHORT)) {
  1.1160 -			return compareUnsignedShorts(value1, value2);
  1.1161 -		}
  1.1162 -		else if (datatype.equals(XMLSchema.UNSIGNED_BYTE)) {
  1.1163 -			return compareUnsignedBytes(value1, value2);
  1.1164 -		}
  1.1165 -		else if (datatype.equals(XMLSchema.FLOAT)) {
  1.1166 -			return compareFloats(value1, value2);
  1.1167 -		}
  1.1168 -		else if (datatype.equals(XMLSchema.DOUBLE)) {
  1.1169 -			return compareDoubles(value1, value2);
  1.1170 -		}
  1.1171 -		else if (datatype.equals(XMLSchema.DATETIME)) {
  1.1172 -			return compareDateTime(value1, value2);
  1.1173 -		}
  1.1174 -		else {
  1.1175 -			throw new IllegalArgumentException("datatype is not ordered");
  1.1176 -		}
  1.1177 -	}
  1.1178 -
  1.1179 -	/**
  1.1180 -	 * Compares two decimals to eachother.
  1.1181 -	 * 
  1.1182 -	 * @return A negative number if <tt>dec1</tt> is smaller than <tt>dec2</tt>,
  1.1183 -	 *         <tt>0</tt> if they are equal, or positive (&gt;0) if
  1.1184 -	 *         <tt>dec1</tt> is larger than <tt>dec2</tt>.
  1.1185 -	 * @throws IllegalArgumentException
  1.1186 -	 *         If one of the supplied strings is not a legal decimal.
  1.1187 -	 */
  1.1188 -	public static int compareDecimals(String dec1, String dec2) {
  1.1189 -		dec1 = normalizeDecimal(dec1);
  1.1190 -		dec2 = normalizeDecimal(dec2);
  1.1191 -
  1.1192 -		return compareCanonicalDecimals(dec1, dec2);
  1.1193 -	}
  1.1194 -
  1.1195 -	/**
  1.1196 -	 * Compares two canonical decimals to eachother.
  1.1197 -	 * 
  1.1198 -	 * @return A negative number if <tt>dec1</tt> is smaller than <tt>dec2</tt>,
  1.1199 -	 *         <tt>0</tt> if they are equal, or positive (&gt;0) if
  1.1200 -	 *         <tt>dec1</tt> is larger than <tt>dec2</tt>. The result is
  1.1201 -	 *         undefined when one or both of the arguments is not a canonical
  1.1202 -	 *         decimal.
  1.1203 -	 * @throws IllegalArgumentException
  1.1204 -	 *         If one of the supplied strings is not a legal decimal.
  1.1205 -	 */
  1.1206 -	public static int compareCanonicalDecimals(String dec1, String dec2) {
  1.1207 -		if (dec1.equals(dec2)) {
  1.1208 -			return 0;
  1.1209 -		}
  1.1210 -
  1.1211 -		// Check signs
  1.1212 -		if (dec1.charAt(0) == '-' && dec2.charAt(0) != '-') {
  1.1213 -			// dec1 is negative, dec2 is not
  1.1214 -			return -1;
  1.1215 -		}
  1.1216 -		if (dec2.charAt(0) == '-' && dec1.charAt(0) != '-') {
  1.1217 -			// dec2 is negative, dec1 is not
  1.1218 -			return 1;
  1.1219 -		}
  1.1220 -
  1.1221 -		int dotIdx1 = dec1.indexOf('.');
  1.1222 -		int dotIdx2 = dec2.indexOf('.');
  1.1223 -
  1.1224 -		// The decimal with the most digits before the dot is the largest
  1.1225 -		int result = dotIdx1 - dotIdx2;
  1.1226 -
  1.1227 -		if (result == 0) {
  1.1228 -			// equal number of digits before the dot, compare them
  1.1229 -			for (int i = 0; result == 0 && i < dotIdx1; i++) {
  1.1230 -				result = dec1.charAt(i) - dec2.charAt(i);
  1.1231 -			}
  1.1232 -
  1.1233 -			// Continue comparing digits after the dot if necessary
  1.1234 -			int dec1Length = dec1.length();
  1.1235 -			int dec2Length = dec2.length();
  1.1236 -			int lastIdx = dec1Length <= dec2Length ? dec1Length : dec2Length;
  1.1237 -
  1.1238 -			for (int i = dotIdx1 + 1; result == 0 && i < lastIdx; i++) {
  1.1239 -				result = dec1.charAt(i) - dec2.charAt(i);
  1.1240 -			}
  1.1241 -
  1.1242 -			// Still equal? The decimal with the most digits is the largest
  1.1243 -			if (result == 0) {
  1.1244 -				result = dec1Length - dec2Length;
  1.1245 -			}
  1.1246 -		}
  1.1247 -
  1.1248 -		if (dec1.charAt(0) == '-') {
  1.1249 -			// reverse result for negative values
  1.1250 -			result = -result;
  1.1251 -		}
  1.1252 -
  1.1253 -		return result;
  1.1254 -	}
  1.1255 -
  1.1256 -	/**
  1.1257 -	 * Compares two integers to eachother.
  1.1258 -	 * 
  1.1259 -	 * @return A negative number if <tt>int1</tt> is smaller than <tt>int2</tt>,
  1.1260 -	 *         <tt>0</tt> if they are equal, or positive (&gt;0) if
  1.1261 -	 *         <tt>int1</tt> is larger than <tt>int2</tt>.
  1.1262 -	 * @throws IllegalArgumentException
  1.1263 -	 *         If one of the supplied strings is not a legal integer.
  1.1264 -	 */
  1.1265 -	public static int compareIntegers(String int1, String int2) {
  1.1266 -		int1 = normalizeInteger(int1);
  1.1267 -		int2 = normalizeInteger(int2);
  1.1268 -
  1.1269 -		return compareCanonicalIntegers(int1, int2);
  1.1270 -	}
  1.1271 -
  1.1272 -	/**
  1.1273 -	 * Compares two canonical integers to eachother.
  1.1274 -	 * 
  1.1275 -	 * @return A negative number if <tt>int1</tt> is smaller than <tt>int2</tt>,
  1.1276 -	 *         <tt>0</tt> if they are equal, or positive (&gt;0) if
  1.1277 -	 *         <tt>int1</tt> is larger than <tt>int2</tt>. The result is
  1.1278 -	 *         undefined when one or both of the arguments is not a canonical
  1.1279 -	 *         integer.
  1.1280 -	 * @throws IllegalArgumentException
  1.1281 -	 *         If one of the supplied strings is not a legal integer.
  1.1282 -	 */
  1.1283 -	public static int compareCanonicalIntegers(String int1, String int2) {
  1.1284 -		if (int1.equals(int2)) {
  1.1285 -			return 0;
  1.1286 -		}
  1.1287 -
  1.1288 -		// Check signs
  1.1289 -		if (int1.charAt(0) == '-' && int2.charAt(0) != '-') {
  1.1290 -			// int1 is negative, int2 is not
  1.1291 -			return -1;
  1.1292 -		}
  1.1293 -		if (int2.charAt(0) == '-' && int1.charAt(0) != '-') {
  1.1294 -			// int2 is negative, int1 is not
  1.1295 -			return 1;
  1.1296 -		}
  1.1297 -
  1.1298 -		// The integer with the most digits is the largest
  1.1299 -		int result = int1.length() - int2.length();
  1.1300 -
  1.1301 -		if (result == 0) {
  1.1302 -			// equal number of digits, compare them
  1.1303 -			for (int i = 0; result == 0 && i < int1.length(); i++) {
  1.1304 -				result = int1.charAt(i) - int2.charAt(i);
  1.1305 -			}
  1.1306 -		}
  1.1307 -
  1.1308 -		if (int1.charAt(0) == '-') {
  1.1309 -			// reverse result for negative values
  1.1310 -			result = -result;
  1.1311 -		}
  1.1312 -
  1.1313 -		return result;
  1.1314 -	}
  1.1315 -
  1.1316 -	public static int compareNegativeIntegers(String int1, String int2) {
  1.1317 -		int1 = normalizeNegativeInteger(int1);
  1.1318 -		int2 = normalizeNegativeInteger(int2);
  1.1319 -
  1.1320 -		return compareCanonicalIntegers(int1, int2);
  1.1321 -	}
  1.1322 -
  1.1323 -	public static int compareNonPositiveIntegers(String int1, String int2) {
  1.1324 -		int1 = normalizeNonPositiveInteger(int1);
  1.1325 -		int2 = normalizeNonPositiveInteger(int2);
  1.1326 -
  1.1327 -		return compareCanonicalIntegers(int1, int2);
  1.1328 -	}
  1.1329 -
  1.1330 -	public static int compareNonNegativeIntegers(String int1, String int2) {
  1.1331 -		int1 = normalizeNonNegativeInteger(int1);
  1.1332 -		int2 = normalizeNonNegativeInteger(int2);
  1.1333 -
  1.1334 -		return compareCanonicalIntegers(int1, int2);
  1.1335 -	}
  1.1336 -
  1.1337 -	public static int comparePositiveIntegers(String int1, String int2) {
  1.1338 -		int1 = normalizePositiveInteger(int1);
  1.1339 -		int2 = normalizePositiveInteger(int2);
  1.1340 -
  1.1341 -		return compareCanonicalIntegers(int1, int2);
  1.1342 -	}
  1.1343 -
  1.1344 -	public static int compareLongs(String int1, String int2) {
  1.1345 -		int1 = normalizeLong(int1);
  1.1346 -		int2 = normalizeLong(int2);
  1.1347 -
  1.1348 -		return compareCanonicalIntegers(int1, int2);
  1.1349 -	}
  1.1350 -
  1.1351 -	public static int compareInts(String int1, String int2) {
  1.1352 -		int1 = normalizeInt(int1);
  1.1353 -		int2 = normalizeInt(int2);
  1.1354 -
  1.1355 -		return compareCanonicalIntegers(int1, int2);
  1.1356 -	}
  1.1357 -
  1.1358 -	public static int compareShorts(String int1, String int2) {
  1.1359 -		int1 = normalizeShort(int1);
  1.1360 -		int2 = normalizeShort(int2);
  1.1361 -
  1.1362 -		return compareCanonicalIntegers(int1, int2);
  1.1363 -	}
  1.1364 -
  1.1365 -	public static int compareBytes(String int1, String int2) {
  1.1366 -		int1 = normalizeByte(int1);
  1.1367 -		int2 = normalizeByte(int2);
  1.1368 -
  1.1369 -		return compareCanonicalIntegers(int1, int2);
  1.1370 -	}
  1.1371 -
  1.1372 -	public static int compareUnsignedLongs(String int1, String int2) {
  1.1373 -		int1 = normalizeUnsignedLong(int1);
  1.1374 -		int2 = normalizeUnsignedLong(int2);
  1.1375 -
  1.1376 -		return compareCanonicalIntegers(int1, int2);
  1.1377 -	}
  1.1378 -
  1.1379 -	public static int compareUnsignedInts(String int1, String int2) {
  1.1380 -		int1 = normalizeUnsignedInt(int1);
  1.1381 -		int2 = normalizeUnsignedInt(int2);
  1.1382 -
  1.1383 -		return compareCanonicalIntegers(int1, int2);
  1.1384 -	}
  1.1385 -
  1.1386 -	public static int compareUnsignedShorts(String int1, String int2) {
  1.1387 -		int1 = normalizeUnsignedShort(int1);
  1.1388 -		int2 = normalizeUnsignedShort(int2);
  1.1389 -
  1.1390 -		return compareCanonicalIntegers(int1, int2);
  1.1391 -	}
  1.1392 -
  1.1393 -	public static int compareUnsignedBytes(String int1, String int2) {
  1.1394 -		int1 = normalizeUnsignedByte(int1);
  1.1395 -		int2 = normalizeUnsignedByte(int2);
  1.1396 -
  1.1397 -		return compareCanonicalIntegers(int1, int2);
  1.1398 -	}
  1.1399 -
  1.1400 -	/**
  1.1401 -	 * Compares two floats to eachother.
  1.1402 -	 * 
  1.1403 -	 * @return A negative number if <tt>float1</tt> is smaller than
  1.1404 -	 *         <tt>float2</tt>, <tt>0</tt> if they are equal, or positive
  1.1405 -	 *         (&gt;0) if <tt>float1</tt> is larger than <tt>float2</tt>.
  1.1406 -	 * @throws IllegalArgumentException
  1.1407 -	 *         If one of the supplied strings is not a legal float or if
  1.1408 -	 *         <tt>NaN</tt> is compared to a float other than <tt>NaN</tt>.
  1.1409 -	 */
  1.1410 -	public static int compareFloats(String float1, String float2) {
  1.1411 -		float1 = normalizeFloat(float1);
  1.1412 -		float2 = normalizeFloat(float2);
  1.1413 -
  1.1414 -		return compareCanonicalFloats(float1, float2);
  1.1415 -	}
  1.1416 -
  1.1417 -	/**
  1.1418 -	 * Compares two canonical floats to eachother.
  1.1419 -	 * 
  1.1420 -	 * @return A negative number if <tt>float1</tt> is smaller than
  1.1421 -	 *         <tt>float2</tt>, <tt>0</tt> if they are equal, or positive
  1.1422 -	 *         (&gt;0) if <tt>float1</tt> is larger than <tt>float2</tt>.
  1.1423 -	 *         The result is undefined when one or both of the arguments is not a
  1.1424 -	 *         canonical float.
  1.1425 -	 * @throws IllegalArgumentException
  1.1426 -	 *         If one of the supplied strings is not a legal float or if
  1.1427 -	 *         <tt>NaN</tt> is compared to a float other than <tt>NaN</tt>.
  1.1428 -	 */
  1.1429 -	public static int compareCanonicalFloats(String float1, String float2) {
  1.1430 -		return compareCanonicalFPNumbers(float1, float2);
  1.1431 -	}
  1.1432 -
  1.1433 -	/**
  1.1434 -	 * Compares two doubles to eachother.
  1.1435 -	 * 
  1.1436 -	 * @return A negative number if <tt>double1</tt> is smaller than
  1.1437 -	 *         <tt>double2</tt>, <tt>0</tt> if they are equal, or positive
  1.1438 -	 *         (&gt;0) if <tt>double1</tt> is larger than <tt>double2</tt>.
  1.1439 -	 * @throws IllegalArgumentException
  1.1440 -	 *         If one of the supplied strings is not a legal double or if
  1.1441 -	 *         <tt>NaN</tt> is compared to a double other than <tt>NaN</tt>.
  1.1442 -	 */
  1.1443 -	public static int compareDoubles(String double1, String double2) {
  1.1444 -		double1 = normalizeDouble(double1);
  1.1445 -		double2 = normalizeDouble(double2);
  1.1446 -
  1.1447 -		return compareCanonicalDoubles(double1, double2);
  1.1448 -	}
  1.1449 -
  1.1450 -	/**
  1.1451 -	 * Compares two canonical doubles to eachother.
  1.1452 -	 * 
  1.1453 -	 * @return A negative number if <tt>double1</tt> is smaller than
  1.1454 -	 *         <tt>double2</tt>, <tt>0</tt> if they are equal, or positive
  1.1455 -	 *         (&gt;0) if <tt>double1</tt> is larger than <tt>double2</tt>.
  1.1456 -	 *         The result is undefined when one or both of the arguments is not a
  1.1457 -	 *         canonical double.
  1.1458 -	 * @throws IllegalArgumentException
  1.1459 -	 *         If one of the supplied strings is not a legal double or if
  1.1460 -	 *         <tt>NaN</tt> is compared to a double other than <tt>NaN</tt>.
  1.1461 -	 */
  1.1462 -	public static int compareCanonicalDoubles(String double1, String double2) {
  1.1463 -		return compareCanonicalFPNumbers(double1, double2);
  1.1464 -	}
  1.1465 -
  1.1466 -	/**
  1.1467 -	 * Compares two floating point numbers to eachother.
  1.1468 -	 * 
  1.1469 -	 * @return A negative number if <tt>float1</tt> is smaller than
  1.1470 -	 *         <tt>float2</tt>, <tt>0</tt> if they are equal, or positive
  1.1471 -	 *         (&gt;0) if <tt>float1</tt> is larger than <tt>float2</tt>.
  1.1472 -	 * @throws IllegalArgumentException
  1.1473 -	 *         If one of the supplied strings is not a legal floating point
  1.1474 -	 *         number or if <tt>NaN</tt> is compared to a floating point number
  1.1475 -	 *         other than <tt>NaN</tt>.
  1.1476 -	 */
  1.1477 -	public static int compareFPNumbers(String fp1, String fp2) {
  1.1478 -		fp1 = normalizeFPNumber(fp1);
  1.1479 -		fp2 = normalizeFPNumber(fp2);
  1.1480 -
  1.1481 -		return compareCanonicalFPNumbers(fp1, fp2);
  1.1482 -	}
  1.1483 -
  1.1484 -	/**
  1.1485 -	 * Compares two canonical floating point numbers to eachother.
  1.1486 -	 * 
  1.1487 -	 * @return A negative number if <tt>float1</tt> is smaller than
  1.1488 -	 *         <tt>float2</tt>, <tt>0</tt> if they are equal, or positive
  1.1489 -	 *         (&gt;0) if <tt>float1</tt> is larger than <tt>float2</tt>.
  1.1490 -	 *         The result is undefined when one or both of the arguments is not a
  1.1491 -	 *         canonical floating point number.
  1.1492 -	 * @throws IllegalArgumentException
  1.1493 -	 *         If one of the supplied strings is not a legal floating point
  1.1494 -	 *         number or if <tt>NaN</tt> is compared to a floating point number
  1.1495 -	 *         other than <tt>NaN</tt>.
  1.1496 -	 */
  1.1497 -	public static int compareCanonicalFPNumbers(String float1, String float2) {
  1.1498 -		// Handle special case NaN
  1.1499 -		if (float1.equals("NaN") || float2.equals("NaN")) {
  1.1500 -			if (float1.equals(float2)) {
  1.1501 -				// NaN is equal to itself
  1.1502 -				return 0;
  1.1503 -			}
  1.1504 -			else {
  1.1505 -				throwIAE("NaN cannot be compared to other floats");
  1.1506 -			}
  1.1507 -		}
  1.1508 -
  1.1509 -		// Handle special case INF
  1.1510 -		if (float1.equals("INF")) {
  1.1511 -			return (float2.equals("INF")) ? 0 : 1;
  1.1512 -		}
  1.1513 -		else if (float2.equals("INF")) {
  1.1514 -			return -1;
  1.1515 -		}
  1.1516 -
  1.1517 -		// Handle special case -INF
  1.1518 -		if (float1.equals("-INF")) {
  1.1519 -			return (float2.equals("-INF")) ? 0 : -1;
  1.1520 -		}
  1.1521 -		else if (float2.equals("-INF")) {
  1.1522 -			return 1;
  1.1523 -		}
  1.1524 -
  1.1525 -		// Check signs
  1.1526 -		if (float1.charAt(0) == '-' && float2.charAt(0) != '-') {
  1.1527 -			// float1 is negative, float2 is not
  1.1528 -			return -1;
  1.1529 -		}
  1.1530 -		if (float2.charAt(0) == '-' && float1.charAt(0) != '-') {
  1.1531 -			// float2 is negative, float1 is not
  1.1532 -			return 1;
  1.1533 -		}
  1.1534 -
  1.1535 -		int eIdx1 = float1.indexOf('E');
  1.1536 -		String mantissa1 = float1.substring(0, eIdx1);
  1.1537 -		String exponent1 = float1.substring(eIdx1 + 1);
  1.1538 -
  1.1539 -		int eIdx2 = float2.indexOf('E');
  1.1540 -		String mantissa2 = float2.substring(0, eIdx2);
  1.1541 -		String exponent2 = float2.substring(eIdx2 + 1);
  1.1542 -
  1.1543 -		// Compare exponents
  1.1544 -		int result = compareCanonicalIntegers(exponent1, exponent2);
  1.1545 -
  1.1546 -		if (result != 0 && float1.charAt(0) == '-') {
  1.1547 -			// reverse result for negative values
  1.1548 -			result = -result;
  1.1549 -		}
  1.1550 -
  1.1551 -		if (result == 0) {
  1.1552 -			// Equal exponents, compare mantissas
  1.1553 -			result = compareCanonicalDecimals(mantissa1, mantissa2);
  1.1554 -		}
  1.1555 -
  1.1556 -		return result;
  1.1557 -	}
  1.1558 -
  1.1559 -	/**
  1.1560 -	 * Compares two dateTime objects. <b>Important:</b> The comparison only
  1.1561 -	 * works if both values have, or both values don't have specified a valid
  1.1562 -	 * value for the timezone.
  1.1563 -	 * 
  1.1564 -	 * @param value1
  1.1565 -	 *        An xsd:dateTime value.
  1.1566 -	 * @param value2
  1.1567 -	 *        An xsd:dateTime value.
  1.1568 -	 * @return <tt>-1</tt> if <tt>value1</tt> is before <tt>value2</tt>
  1.1569 -	 *         (i.e. if the dateTime object represented by value1 is before the
  1.1570 -	 *         dateTime object represented by value2), <tt>0</tt> if both are
  1.1571 -	 *         equal and <tt>1</tt> if <tt>value2</tt> is before
  1.1572 -	 *         <tt>value1</tt><br>.
  1.1573 -	 */
  1.1574 -	public static int compareDateTime(String value1, String value2) {
  1.1575 -		XMLDateTime dateTime1 = new XMLDateTime(value1);
  1.1576 -		XMLDateTime dateTime2 = new XMLDateTime(value2);
  1.1577 -
  1.1578 -		dateTime1.normalize();
  1.1579 -		dateTime2.normalize();
  1.1580 -
  1.1581 -		return dateTime1.compareTo(dateTime2);
  1.1582 -	}
  1.1583 -
  1.1584 -	/*---------------*
  1.1585 -	 * Value parsing *
  1.1586 -	 *---------------*/
  1.1587 -
  1.1588 -	/**
  1.1589 -	 * Parses the supplied xsd:boolean string and returns its value.
  1.1590 -	 * 
  1.1591 -	 * @param s
  1.1592 -	 *        A string representation of an xsd:boolean value.
  1.1593 -	 * @return The <tt>boolean</tt> value represented by the supplied string
  1.1594 -	 *         argument.
  1.1595 -	 * @throws NumberFormatException
  1.1596 -	 *         If the supplied string is not a valid xsd:boolean value.
  1.1597 -	 */
  1.1598 -	public static boolean parseBoolean(String s) {
  1.1599 -		return normalizeBoolean(s).equals("true");
  1.1600 -	}
  1.1601 -
  1.1602 -	/**
  1.1603 -	 * Parses the supplied xsd:byte string and returns its value.
  1.1604 -	 * 
  1.1605 -	 * @param s
  1.1606 -	 *        A string representation of an xsd:byte value.
  1.1607 -	 * @return The <tt>byte</tt> value represented by the supplied string
  1.1608 -	 *         argument.
  1.1609 -	 * @throws NumberFormatException
  1.1610 -	 *         If the supplied string is not a valid xsd:byte value.
  1.1611 -	 */
  1.1612 -	public static byte parseByte(String s) {
  1.1613 -		s = trimPlusSign(s);
  1.1614 -		return Byte.parseByte(s);
  1.1615 -	}
  1.1616 -
  1.1617 -	/**
  1.1618 -	 * Parses the supplied xsd:short string and returns its value.
  1.1619 -	 * 
  1.1620 -	 * @param s
  1.1621 -	 *        A string representation of an xsd:short value.
  1.1622 -	 * @return The <tt>short</tt> value represented by the supplied string
  1.1623 -	 *         argument.
  1.1624 -	 * @throws NumberFormatException
  1.1625 -	 *         If the supplied string is not a valid xsd:short value.
  1.1626 -	 */
  1.1627 -	public static short parseShort(String s) {
  1.1628 -		s = trimPlusSign(s);
  1.1629 -		return Short.parseShort(s);
  1.1630 -	}
  1.1631 -
  1.1632 -	/**
  1.1633 -	 * Parses the supplied xsd:int strings and returns its value.
  1.1634 -	 * 
  1.1635 -	 * @param s
  1.1636 -	 *        A string representation of an xsd:int value.
  1.1637 -	 * @return The <tt>int</tt> value represented by the supplied string
  1.1638 -	 *         argument.
  1.1639 -	 * @throws NumberFormatException
  1.1640 -	 *         If the supplied string is not a valid xsd:int value.
  1.1641 -	 */
  1.1642 -	public static int parseInt(String s) {
  1.1643 -		s = trimPlusSign(s);
  1.1644 -		return Integer.parseInt(s);
  1.1645 -	}
  1.1646 -
  1.1647 -	/**
  1.1648 -	 * Parses the supplied xsd:long string and returns its value.
  1.1649 -	 * 
  1.1650 -	 * @param s
  1.1651 -	 *        A string representation of an xsd:long value.
  1.1652 -	 * @return The <tt>long</tt> value represented by the supplied string
  1.1653 -	 *         argument.
  1.1654 -	 * @throws NumberFormatException
  1.1655 -	 *         If the supplied string is not a valid xsd:long value.
  1.1656 -	 */
  1.1657 -	public static long parseLong(String s) {
  1.1658 -		s = trimPlusSign(s);
  1.1659 -		return Long.parseLong(s);
  1.1660 -	}
  1.1661 -
  1.1662 -	/**
  1.1663 -	 * Parses the supplied xsd:float string and returns its value.
  1.1664 -	 * 
  1.1665 -	 * @param s
  1.1666 -	 *        A string representation of an xsd:float value.
  1.1667 -	 * @return The <tt>float</tt> value represented by the supplied string
  1.1668 -	 *         argument.
  1.1669 -	 * @throws NumberFormatException
  1.1670 -	 *         If the supplied string is not a valid xsd:float value.
  1.1671 -	 */
  1.1672 -	public static float parseFloat(String s) {
  1.1673 -		s = trimPlusSign(s);
  1.1674 -		return Float.parseFloat(s);
  1.1675 -	}
  1.1676 -
  1.1677 -	/**
  1.1678 -	 * Parses the supplied xsd:double string and returns its value.
  1.1679 -	 * 
  1.1680 -	 * @param s
  1.1681 -	 *        A string representation of an xsd:double value.
  1.1682 -	 * @return The <tt>double</tt> value represented by the supplied string
  1.1683 -	 *         argument.
  1.1684 -	 * @throws NumberFormatException
  1.1685 -	 *         If the supplied string is not a valid xsd:double value.
  1.1686 -	 */
  1.1687 -	public static double parseDouble(String s) {
  1.1688 -		s = trimPlusSign(s);
  1.1689 -		return Double.parseDouble(s);
  1.1690 -	}
  1.1691 -
  1.1692 -	/**
  1.1693 -	 * Parses the supplied xsd:integer string and returns its value.
  1.1694 -	 * 
  1.1695 -	 * @param s
  1.1696 -	 *        A string representation of an xsd:integer value.
  1.1697 -	 * @return The integer value represented by the supplied string argument.
  1.1698 -	 * @throws NumberFormatException
  1.1699 -	 *         If the supplied string is not a valid xsd:integer value.
  1.1700 -	 */
  1.1701 -	public static BigInteger parseInteger(String s) {
  1.1702 -		s = trimPlusSign(s);
  1.1703 -		return new BigInteger(s);
  1.1704 -	}
  1.1705 -
  1.1706 -	/**
  1.1707 -	 * Parses the supplied decimal/floating point string and returns its value.
  1.1708 -	 * 
  1.1709 -	 * @param s
  1.1710 -	 *        A string representation of an xsd:decimal or xsd:double value.
  1.1711 -	 * @return The decimal/floating point value represented by the supplied
  1.1712 -	 *         string argument.
  1.1713 -	 * @throws NumberFormatException
  1.1714 -	 *         If the supplied string is not a valid xsd:decimal or xsd:double
  1.1715 -	 *         value.
  1.1716 -	 */
  1.1717 -	public static BigDecimal parseDecimal(String s) {
  1.1718 -		// Note: BigDecimal can handle leading plus signs itself
  1.1719 -		return new BigDecimal(s);
  1.1720 -	}
  1.1721 -
  1.1722 -	/**
  1.1723 -	 * Parses the supplied calendar value string and returns its value.
  1.1724 -	 * 
  1.1725 -	 * @param s
  1.1726 -	 *        A string representation of an xsd:dateTime, xsd:time, xsd:date,
  1.1727 -	 *        xsd:gYearMonth, xsd:gMonthDay, xsd:gYear, xsd:gMonth or xsd:gDay
  1.1728 -	 *        value.
  1.1729 -	 * @return The calendar value represented by the supplied string argument.
  1.1730 -	 * @throws NumberFormatException
  1.1731 -	 *         If the supplied string is not a valid calendar value.
  1.1732 -	 */
  1.1733 -	public static XMLGregorianCalendar parseCalendar(String s) {
  1.1734 -		return dtFactory.newXMLGregorianCalendar(s);
  1.1735 -	}
  1.1736 -
  1.1737 -	/**
  1.1738 -	 * Removes the first character from the supplied string if this is a plus
  1.1739 -	 * sign ('+'). Number strings with leading plus signs cannot be parsed by
  1.1740 -	 * methods such as {@link Integer#parseInt(String)}.
  1.1741 -	 */
  1.1742 -	private static String trimPlusSign(String s) {
  1.1743 -		if (s.length() > 0 && s.charAt(0) == '+') {
  1.1744 -			return s.substring(1);
  1.1745 -		}
  1.1746 -		else {
  1.1747 -			return s;
  1.1748 -		}
  1.1749 -	}
  1.1750 -
  1.1751 -	/**
  1.1752 -	 * Maps a datatype QName from the javax.xml.namespace package to an XML
  1.1753 -	 * Schema URI for the corresponding datatype. This method recognizes the XML
  1.1754 -	 * Schema qname mentioned in {@link DatatypeConstants}.
  1.1755 -	 * 
  1.1756 -	 * @param qname
  1.1757 -	 *        One of the XML Schema qnames from {@link DatatypeConstants}.
  1.1758 -	 * @return A URI for the specified datatype.
  1.1759 -	 * @throws IllegalArgumentException
  1.1760 -	 *         If the supplied qname was not recognized by this method.
  1.1761 -	 * @see DatatypeConstants
  1.1762 -	 */
  1.1763 -	public static URI qnameToURI(QName qname) {
  1.1764 -		if (DatatypeConstants.DATETIME.equals(qname)) {
  1.1765 -			return XMLSchema.DATETIME;
  1.1766 -		}
  1.1767 -		else if (DatatypeConstants.DATE.equals(qname)) {
  1.1768 -			return XMLSchema.DATE;
  1.1769 -		}
  1.1770 -		else if (DatatypeConstants.TIME.equals(qname)) {
  1.1771 -			return XMLSchema.TIME;
  1.1772 -		}
  1.1773 -		else if (DatatypeConstants.GYEARMONTH.equals(qname)) {
  1.1774 -			return XMLSchema.GYEARMONTH;
  1.1775 -		}
  1.1776 -		else if (DatatypeConstants.GMONTHDAY.equals(qname)) {
  1.1777 -			return XMLSchema.GMONTHDAY;
  1.1778 -		}
  1.1779 -		else if (DatatypeConstants.GYEAR.equals(qname)) {
  1.1780 -			return XMLSchema.GYEAR;
  1.1781 -		}
  1.1782 -		else if (DatatypeConstants.GMONTH.equals(qname)) {
  1.1783 -			return XMLSchema.GMONTH;
  1.1784 -		}
  1.1785 -		else if (DatatypeConstants.GDAY.equals(qname)) {
  1.1786 -			return XMLSchema.GDAY;
  1.1787 -		}
  1.1788 -		else if (DatatypeConstants.DURATION.equals(qname)) {
  1.1789 -			return XMLSchema.DURATION;
  1.1790 -		}
  1.1791 -		else {
  1.1792 -			throw new IllegalArgumentException("QName cannot be mapped to an XML Schema URI: " + qname.toString());
  1.1793 -		}
  1.1794 -	}
  1.1795 -
  1.1796 -	/*-----------------*
  1.1797 -	 * Utility methods *
  1.1798 -	 *-----------------*/
  1.1799 -
  1.1800 -	/**
  1.1801 -	 * Checks whether the supplied character is a digit.
  1.1802 -	 */
  1.1803 -	private static final boolean isDigit(char c) {
  1.1804 -		return c >= '0' && c <= '9';
  1.1805 -	}
  1.1806 -
  1.1807 -	/**
  1.1808 -	 * Throws an IllegalArgumentException that contains the supplied message.
  1.1809 -	 */
  1.1810 -	private static final void throwIAE(String msg) {
  1.1811 -		throw new IllegalArgumentException(msg);
  1.1812 -	}
  1.1813 -
  1.1814  }