@Override public Sequence call(XPathContext context, Sequence[] arguments) throws XPathException { if (arguments.length > 0) { long most = (Long) SequenceTool.convertToJava(arguments[0].head()); long least = 0; if (arguments.length > 1) { least = (Long) SequenceTool.convertToJava(arguments[1].head()); } return StringValue.makeStringValue(new UUID(most, least).toString()); } return StringValue.makeStringValue(UUID.randomUUID().toString()); } };
@Override public Sequence call(XPathContext context, Sequence[] arguments) throws XPathException { //return Int64Value.makeIntegerValue(SequenceTool.convertToJava(arguments[0].head()).hashCode()); return new Int64Value(SequenceTool.convertToJava(arguments[0].head()).hashCode()); } };
static private Object getValue(AtomicValue value, CommandContext context) throws XPathException { if (value instanceof CalendarValue) { CalendarValue cv = (CalendarValue)value; if (!cv.hasTimezone()) { TimeZone tz = context.getServerTimeZone(); int tzMin = tz.getRawOffset()/60000; if (tz.getDSTSavings() > 0) { tzMin = tz.getOffset(cv.getCalendar().getTimeInMillis())/60000; } cv.setTimezoneInMinutes(tzMin); Calendar cal = cv.getCalendar(); return new Timestamp(cal.getTime().getTime()); } } return SequenceTool.convertToJava(value); }
static private Object getValue(AtomicValue value, CommandContext context) throws XPathException { if (value instanceof CalendarValue) { CalendarValue cv = (CalendarValue)value; if (!cv.hasTimezone()) { TimeZone tz = context.getServerTimeZone(); int tzMin = tz.getRawOffset()/60000; if (tz.getDSTSavings() > 0) { tzMin = tz.getOffset(cv.getCalendar().getTimeInMillis())/60000; } cv.setTimezoneInMinutes(tzMin); Calendar cal = cv.getCalendar(); return new Timestamp(cal.getTime().getTime()); } } return SequenceTool.convertToJava(value); }
static private Object getValue(AtomicValue value, CommandContext context) throws XPathException { if (value instanceof CalendarValue) { CalendarValue cv = (CalendarValue)value; if (!cv.hasTimezone()) { TimeZone tz = context.getServerTimeZone(); int tzMin = tz.getRawOffset()/60000; if (tz.getDSTSavings() > 0) { tzMin = tz.getOffset(cv.getCalendar().getTimeInMillis())/60000; } cv.setTimezoneInMinutes(tzMin); Calendar cal = cv.getCalendar(); return new Timestamp(cal.getTime().getTime()); } } return SequenceTool.convertToJava(value); }
@Override public Sequence call(XPathContext context, Sequence[] arguments) throws XPathException { long txId = (Long) SequenceTool.convertToJava(arguments[0].head()); try { txMgr.rollbackTransaction(txId); return null; } catch (BagriException ex) { throw new XPathException(ex); } } };
@Override public Sequence call(XPathContext context, Sequence[] arguments) throws XPathException { long txId = (Long) SequenceTool.convertToJava(arguments[0].head()); try { txMgr.commitTransaction(txId); return null; } catch (BagriException ex) { throw new XPathException(ex); } } };
/** * Execute a the compiled Query, returning the results as a List of objects * obtained by converting the items in the query result to the nearest appropriate * Java type * * @param env Provides the dynamic query evaluation context * @return The results of the expression, as a List. The List represents the sequence * of items returned by the expression. Each item in the list will either be an * object representing a node, or an object representing an atomic value. * For the types of Java object that may be returned, see the description of the * {@link net.sf.saxon.xpath.XPathEvaluator#evaluate evaluate} method * of class XPathProcessor * @throws XPathException if a dynamic error occurs during query evaluation */ /*@NotNull*/ public List<Object> evaluate(/*@NotNull*/ DynamicQueryContext env) throws XPathException { if (isUpdateQuery()) { throw new XPathException("Cannot call evaluate() on an updating query"); } ArrayList<Object> list = new ArrayList<>(100); iterator(env).forEachOrFail(item -> list.add(SequenceTool.convertToJava(item))); return list; }
/** * Execute a the compiled Query, returning the results as a List of objects * obtained by converting the items in the query result to the nearest appropriate * Java type * * @param env Provides the dynamic query evaluation context * @return The results of the expression, as a List. The List represents the sequence * of items returned by the expression. Each item in the list will either be an * object representing a node, or an object representing an atomic value. * For the types of Java object that may be returned, see the description of the * {@link net.sf.saxon.xpath.XPathEvaluator#evaluate evaluate} method * of class XPathProcessor * @throws XPathException if a dynamic error occurs during query evaluation */ /*@NotNull*/ public List<Object> evaluate(/*@NotNull*/ DynamicQueryContext env) throws XPathException { if (isUpdateQuery()) { throw new XPathException("Cannot call evaluate() on an updating query"); } ArrayList<Object> list = new ArrayList<>(100); iterator(env).forEachOrFail(item -> list.add(SequenceTool.convertToJava(item))); return list; }
public static Map<String, Object> sequence2Params(Sequence sq) throws XPathException { SequenceIterator itr = sq.iterate(); Map<String, Object> params = new HashMap<>(); do { Item item = itr.next(); if (item != null) { String name = item.getStringValue(); Object value = null; item = itr.next(); if (item != null) { value = SequenceTool.convertToJava(item); } params.put(name, value); } else { break; } } while (true); return params; }
/** * Execute the compiled Query, returning the first item in the result. * This is useful where it is known that the expression will only return * a singleton value (for example, a single node, or a boolean). * * @param env Provides the dynamic query evaluation context * @return The first item in the sequence returned by the expression. If the expression * returns an empty sequence, this method returns null. Otherwise, it returns the first * item in the result sequence, represented as a Java object using the same mapping as for * the {@link XQueryExpression#evaluate evaluate} method * @throws XPathException if evaluation fails with a dynamic error */ /*@Nullable*/ public Object evaluateSingle(/*@NotNull*/ DynamicQueryContext env) throws XPathException { if (isUpdateQuery()) { throw new XPathException("Cannot call evaluateSingle() on an updating query"); } SequenceIterator iterator = iterator(env); Item item = iterator.next(); if (item == null) { return null; } return SequenceTool.convertToJava(item); }
/** * Execute the compiled Query, returning the first item in the result. * This is useful where it is known that the expression will only return * a singleton value (for example, a single node, or a boolean). * * @param env Provides the dynamic query evaluation context * @return The first item in the sequence returned by the expression. If the expression * returns an empty sequence, this method returns null. Otherwise, it returns the first * item in the result sequence, represented as a Java object using the same mapping as for * the {@link XQueryExpression#evaluate evaluate} method * @throws XPathException if evaluation fails with a dynamic error */ /*@Nullable*/ public Object evaluateSingle(/*@NotNull*/ DynamicQueryContext env) throws XPathException { if (isUpdateQuery()) { throw new XPathException("Cannot call evaluateSingle() on an updating query"); } SequenceIterator iterator = iterator(env); Item item = iterator.next(); if (item == null) { return null; } return SequenceTool.convertToJava(item); }
javaValue = ((GYearMonthValue) value).getPrimitiveStringValue().toString(); } else { javaValue = SequenceTool.convertToJava(value); javaValue = SequenceTool.convertToJava(value); addResultBytes (javaValue.toString().length() * 2);
public LiteralExpression exprFor (AtomicValue value) { ValueType type = valueTypeForItemType(value.getItemType()); if (value instanceof CalendarValue || value instanceof DurationValue || value instanceof BigIntegerValue) { //return new LiteralExpression(((CalendarValue)value).getCalendar(), type); // , value.getPrimitiveType().getQualifiedName().toString() return new LiteralExpression(value.getStringValue(), type); } if (value instanceof QNameValue) { return new LiteralExpression (qnameFor (((QNameValue) value).getStructuredQName()), type); } try { Object oval = SequenceTool.convertToJava(value); return new LiteralExpression(oval, type); } catch (XPathException e) { throw new LuxException (e); } } public AbstractExpression exprFor (NegateExpression expr) {