public ValueRepresentation convert(Object object, XPathContext context) throws XPathException { Item[] array = new Item[((Collection)object).size()]; int a = 0; for (Iterator i=((Collection)object).iterator(); i.hasNext(); ) { Object obj = i.next(); JPConverter itemConverter = allocate(obj.getClass(), context.getConfiguration()); try { Item item = Value.asItem(itemConverter.convert(obj, context)); if (item != null) { array[a++] = item; } } catch (XPathException e) { throw new XPathException( "Returned Collection contains an object that cannot be converted to an Item (" + obj.getClass() + "): " + e.getMessage(), SaxonErrorCode.SXJE0051); } } return new SequenceExtent(array, 0, a); }
public Sequence<?> convert(Object object, XPathContext context) throws XPathException { List<Item<?>> list = new ArrayList<>(((Collection) object).size()); int a = 0; for (Object obj : (Collection) object) { JPConverter itemConverter = allocate(obj.getClass(), null, context.getConfiguration()); try { Item<?> item = SequenceTool.asItem(itemConverter.convert(obj, context)); if (item != null) { list.add(item); } } catch (XPathException e) { throw new XPathException( "Returned Collection contains an object that cannot be converted to an Item (" + obj.getClass() + "): " + e.getMessage(), SaxonErrorCode.SXJE0051); } } return new SequenceExtent<>(list); }
public Sequence<?> convert(Object object, XPathContext context) throws XPathException { List<Item<?>> list = new ArrayList<>(((Collection) object).size()); int a = 0; for (Object obj : (Collection) object) { JPConverter itemConverter = allocate(obj.getClass(), null, context.getConfiguration()); try { Item<?> item = SequenceTool.asItem(itemConverter.convert(obj, context)); if (item != null) { list.add(item); } } catch (XPathException e) { throw new XPathException( "Returned Collection contains an object that cannot be converted to an Item (" + obj.getClass() + "): " + e.getMessage(), SaxonErrorCode.SXJE0051); } } return new SequenceExtent<>(list); }
public Sequence<?> convert(Object object, XPathContext context) throws XPathException { Class theClass = object.getClass(); JPConverter instanceConverter = allocate(theClass, null, context.getConfiguration()); if (instanceConverter instanceof FromObject) { instanceConverter = new ExternalObjectWrapper( context.getConfiguration().getJavaExternalObjectType(theClass)); } return instanceConverter.convert(object, context); }
aSequences[nIndex] = aConverter.convert (aArg, aXPathContext); ++nIndex;
aSequences[nIndex] = aConverter.convert (aArg, aXPathContext); ++nIndex;
@Override public Sequence<?> call(XPathContext context, Sequence[] arguments) throws XPathException { Configuration config = context.getConfiguration(); Object value = resolver.resolveVariable(name.toJaxpQName()); if (value == null) { return EmptySequence.getInstance(); } JPConverter converter = JPConverter.allocate(value.getClass(), null, config); return converter.convert(value, context); }
public Sequence<?> convert(Object object, XPathContext context) throws XPathException { Object[] arrayObject = (Object[]) object; List<Item<?>> newArray = new ArrayList<>(arrayObject.length); int a = 0; for (Object member : arrayObject) { if (member != null) { try { Item<?> newItem = SequenceTool.asItem(itemConverter.convert(member, context)); if (newItem != null) { newArray.add(newItem); } } catch (XPathException e) { throw new XPathException( "Returned array contains an object that cannot be converted to an Item (" + member.getClass() + "): " + e.getMessage(), SaxonErrorCode.SXJE0051); } } else { throw new XPathException("Returned array contains null values: cannot convert to items", SaxonErrorCode.SXJE0051); } } return new SequenceExtent<>(newArray); }
public Sequence<?> convert(Object object, XPathContext context) throws XPathException { Object[] arrayObject = (Object[]) object; List<Item<?>> newArray = new ArrayList<>(arrayObject.length); int a = 0; for (Object member : arrayObject) { if (member != null) { try { Item<?> newItem = SequenceTool.asItem(itemConverter.convert(member, context)); if (newItem != null) { newArray.add(newItem); } } catch (XPathException e) { throw new XPathException( "Returned array contains an object that cannot be converted to an Item (" + member.getClass() + "): " + e.getMessage(), SaxonErrorCode.SXJE0051); } } else { throw new XPathException("Returned array contains null values: cannot convert to items", SaxonErrorCode.SXJE0051); } } return new SequenceExtent<>(newArray); }
@Override public Sequence<?> call(XPathContext context, Sequence[] arguments) throws XPathException { Configuration config = context.getConfiguration(); Object value = resolver.resolveVariable(name.toJaxpQName()); if (value == null) { return EmptySequence.getInstance(); } JPConverter converter = JPConverter.allocate(value.getClass(), null, config); return converter.convert(value, context); }
public Sequence<?> convert(Object object, XPathContext context) throws XPathException { Class theClass = object.getClass(); JPConverter instanceConverter = allocate(theClass, null, context.getConfiguration()); if (instanceConverter instanceof FromObject) { instanceConverter = new ExternalObjectWrapper( context.getConfiguration().getJavaExternalObjectType(theClass)); } return instanceConverter.convert(object, context); }
public ValueRepresentation convert(Object object, XPathContext context) throws XPathException { Object[] arrayObject = (Object[])object; Item[] newArray = new Item[arrayObject.length]; int a = 0; for (int i = 0; i < arrayObject.length; i++){ try { Item newItem = Value.asItem(itemConverter.convert(arrayObject[i], context)); if (newItem != null) { newArray[a++] = newItem; } } catch (XPathException e) { throw new XPathException( "Returned array contains an object that cannot be converted to an Item (" + arrayObject[i].getClass() + "): " + e.getMessage(), SaxonErrorCode.SXJE0051); } } return new SequenceExtent(newArray, 0, a); }
return converter.convert(result, context); } catch (XPathFunctionException e) { throw new XPathException(e);
return converter.convert(result, context); } catch (XPathFunctionException e) { throw new XPathException(e);
try { JPConverter converter = JPConverter.allocate(node.getClass(), null, config); NodeInfo nodeInfo = (NodeInfo) converter.convert(node, new EarlyEvaluationContext(config)); return XdmItem.wrapItem(nodeInfo); } catch (XPathException e) {
public static AtomicValue convertToAtomicValue(Object value) throws TransformerException { if (value instanceof java.util.Date) { //special handling for time types java.util.Date d = (java.util.Date)value; DateTimeValue tdv = DateTimeValue.fromJavaDate(d); if (value instanceof Date) { value = new DateValue(tdv.getYear(), tdv.getMonth(), tdv.getDay(), tdv.getTimezoneInMinutes(), true); } else if (value instanceof Time) { value = new TimeValue(tdv.getHour(), tdv.getMinute(), tdv.getSecond(), tdv.getMicrosecond(), tdv.getTimezoneInMinutes()); } else if (value instanceof Timestamp) { Timestamp ts = (Timestamp)value; value = tdv.add(DayTimeDurationValue.fromMicroseconds(ts.getNanos() / 1000)); } return (AtomicValue)value; } JPConverter converter = JPConverter.allocate(value.getClass(), null, null); return (AtomicValue)converter.convert(value, null); }
resultIterator = (SequenceIterator)result; } else { resultIterator = Value.asIterator(resultConverter.convert(result, context));
public static AtomicValue convertToAtomicValue(Object value) throws TransformerException { if (value instanceof java.util.Date) { //special handling for time types java.util.Date d = (java.util.Date)value; DateTimeValue tdv = DateTimeValue.fromJavaDate(d); if (value instanceof Date) { value = new DateValue(tdv.getYear(), tdv.getMonth(), tdv.getDay(), tdv.getTimezoneInMinutes(), true); } else if (value instanceof Time) { value = new TimeValue(tdv.getHour(), tdv.getMinute(), tdv.getSecond(), tdv.getMicrosecond(), tdv.getTimezoneInMinutes()); } else if (value instanceof Timestamp) { Timestamp ts = (Timestamp)value; value = tdv.add(DayTimeDurationValue.fromMicroseconds(ts.getNanos() / 1000)); } return (AtomicValue)value; } JPConverter converter = JPConverter.allocate(value.getClass(), null); return (AtomicValue)converter.convert(value, null); }
public static AtomicValue convertToAtomicValue(Object value) throws TransformerException { if (value instanceof java.util.Date) { //special handling for time types java.util.Date d = (java.util.Date)value; DateTimeValue tdv = DateTimeValue.fromJavaDate(d); if (value instanceof Date) { value = new DateValue(tdv.getYear(), tdv.getMonth(), tdv.getDay(), tdv.getTimezoneInMinutes(), true); } else if (value instanceof Time) { value = new TimeValue(tdv.getHour(), tdv.getMinute(), tdv.getSecond(), tdv.getMicrosecond(), tdv.getTimezoneInMinutes()); } else if (value instanceof Timestamp) { Timestamp ts = (Timestamp)value; value = tdv.add(DayTimeDurationValue.fromMicroseconds(ts.getNanos() / 1000)); } return (AtomicValue)value; } JPConverter converter = JPConverter.allocate(value.getClass(), null, null); return (AtomicValue)converter.convert(value, null); }
return SequenceTool.asItem(jp.convert(value, new EarlyEvaluationContext(config))); } else if (value instanceof Source) { return sourceToNode((Source) value, config);