/** * Constructor: create a date value from a supplied string, in * ISO 8601 format * @param s the lexical form of the date value * @throws ValidationException if the supplied string is not a valid date */ public DateValue(CharSequence s) throws ValidationException { setLexicalValue(this, s).asAtomic(); typeLabel = BuiltInAtomicType.DATE; }
/** * Constructor: create a date value from a supplied string, in * ISO 8601 format * @param s the lexical form of the date value * @throws ValidationException if the supplied string is not a valid date */ public DateValue(CharSequence s) throws ValidationException { setLexicalValue(this, s).asAtomic(); typeLabel = BuiltInAtomicType.DATE; }
public Item map(Item item) throws XPathException { return ((AtomicValue)item).convert(requiredPrimitiveType, true, context).asAtomic(); } };
public Item map(Item item) throws XPathException { return ((AtomicValue)item).convert(requiredPrimitiveType, true, context).asAtomic(); } };
public Item map(Item item) throws XPathException { return ((AtomicValue)item).convert(requiredPrimitiveType, true, context).asAtomic(); } };
/** * Convert the value to a given type. The result of the conversion will be an * atomic value of the required type. This method works only where the target * type is a built-in type. * * @param schemaType the required atomic type * @param context the XPath dynamic context * @return the result of the conversion, if conversion was possible. This * will always be an instance of the class corresponding to the type * of value requested * @throws XPathException if conversion is not allowed for this * required type, or if the particular value cannot be converted */ public final AtomicValue convert(AtomicType schemaType, XPathContext context) throws XPathException { // Note this method is used from XQuery compiled code return convert(schemaType, true, context).asAtomic(); }
public Item map(Item item) throws XPathException { if (!(item instanceof NumericValue || item instanceof UntypedAtomicValue)) { throw new XPathException( "Cannot promote non-numeric value to " + requiredItemType.toString(), "XPTY0004", context); } return ((AtomicValue)item).convert((AtomicType)requiredItemType, true, context).asAtomic(); } };
/** * Examine the already-validated properties to see whether the html-version property is present * with the decimal value 5.; used to decide whether to produce XHTML 5.0 in the XHTML output * method. * * @param properties the properties to be examined * @return true if the properties include html-version="5.0". The property is a decimal value, so * it can also be written, for example, "5" or "+5.00". */ public static boolean isXhtmlHtmlVersion5(Properties properties) { String htmlVersion = properties.getProperty(SaxonOutputKeys.HTML_VERSION); try { return htmlVersion != null && ((BigDecimalValue)BigDecimalValue.makeDecimalValue(htmlVersion, false).asAtomic()) .getDecimalValue().equals(BigDecimal.valueOf(5)); } catch (ValidationException e) { return false; } }
/** * Evaluate as an Item. This should only be called if the AtomicSequenceConverter has cardinality zero-or-one */ public Item evaluateItem(XPathContext context) throws XPathException { Item item = operand.evaluateItem(context); if (item==null) return null; return ((AtomicValue)item).convert(requiredPrimitiveType, true, context).asAtomic(); }
/** * Return the numeric value as a Java long. * * @exception net.sf.saxon.trans.XPathException if the value cannot be converted * @return the numeric value as a Java long. This performs truncation * towards zero. */ public long longValue() throws XPathException { return ((Int64Value)convertPrimitive(BuiltInAtomicType.INTEGER, true, null).asAtomic()).longValue(); }
public AtomicValue mapItem(AtomicValue item) throws XPathException { ConversionResult result = converter.convert(item); if (errorCode != null && result instanceof ValidationFailure) { ((ValidationFailure)result).setErrorCode(errorCode); } return result.asAtomic(); } }
private int processVersionAttribute(String version) throws XPathException { if (version != null) { ConversionResult cr = BigDecimalValue.makeDecimalValue(version, true); if (cr instanceof ValidationFailure) { throw new XPathException("Invalid version number: " + version, "XTSE0110"); } BigDecimalValue d = (BigDecimalValue)cr.asAtomic(); return d.getDecimalValue().multiply(BigDecimal.TEN).intValue(); } else { return Integer.MIN_VALUE; } }
private int processVersionAttribute(String version) throws XPathException { if (version != null) { ConversionResult cr = BigDecimalValue.makeDecimalValue(version, true); if (cr instanceof ValidationFailure) { throw new XPathException("Invalid version number: " + version, "XTSE0110"); } BigDecimalValue d = (BigDecimalValue)cr.asAtomic(); return d.getDecimalValue().multiply(BigDecimal.TEN).intValue(); } else { return Integer.MIN_VALUE; } }
/** * Return the numeric value as a Java long. * * @exception net.sf.saxon.trans.XPathException if the value cannot be converted * @return the numeric value as a Java long. This performs truncation * towards zero. */ public long longValue() throws XPathException { return ((Int64Value)convertPrimitive(BuiltInAtomicType.INTEGER, true, null).asAtomic()).longValue(); }
/** * Constructor: create a date value from a supplied string, in * ISO 8601 format * * @param s the lexical form of the date value * @param rules the conversion rules (determining whether year zero is allowed) * @throws ValidationException if the supplied string is not a valid date */ public DateValue(CharSequence s, ConversionRules rules) throws ValidationException { setLexicalValue(this, s, rules.isAllowYearZero()).asAtomic(); typeLabel = BuiltInAtomicType.DATE; }
/** * Get the numeric value converted to a float * @return a float representing this numeric value; NaN if it cannot be converted */ public float getFloatValue() { try { return ((FloatValue)convertPrimitive(BuiltInAtomicType.FLOAT, true, null).asAtomic()).getFloatValue(); } catch (XPathException err) { return Float.NaN; } }
/** * Constructor: create a date value from a supplied string, in * ISO 8601 format * * @param s the lexical form of the date value * @param rules the conversion rules (determining whether year zero is allowed) * @throws ValidationException if the supplied string is not a valid date */ public DateValue(CharSequence s, ConversionRules rules) throws ValidationException { setLexicalValue(this, s, rules.isAllowYearZero()).asAtomic(); typeLabel = BuiltInAtomicType.DATE; }
/** * Get the numeric value converted to a decimal * @return a decimal representing this numeric value; * @throws XPathException if the value cannot be converted, for example if it is NaN or infinite */ public BigDecimal getDecimalValue() throws XPathException { return ((DecimalValue)convertPrimitive(BuiltInAtomicType.DECIMAL, true, null).asAtomic()).getDecimalValue(); }
public AtomicValue mapItem(AtomicValue item) throws XPathException { ConversionResult result = converter.convert(item); if (errorCode != null && result instanceof ValidationFailure) { ((ValidationFailure)result).setErrorCode(errorCode); } return result.asAtomic(); } }
/** * Evaluate as an Item. This should only be called if the AtomicSequenceConverter has cardinality zero-or-one */ public Item evaluateItem(XPathContext context) throws XPathException { Item item = operand.evaluateItem(context); if (item==null) return null; return ((AtomicValue)item).convert(requiredPrimitiveType, true, context).asAtomic(); }