@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 ItemType getItemType() { return itemConverter.getItemType(); }
return StaticProperty.ALLOWS_ZERO_OR_MORE; } else { return resultConverter.getCardinality();
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); }
resultConverter = JPConverter.allocate(theClass, config); } else if (theMethod instanceof Method) { Class resultClass = ((Method)theMethod).getReturnType(); resultConverter = JPConverter.allocate(resultClass, config); } else if (theMethod instanceof Field) { Class resultClass = ((Field)theMethod).getType(); resultConverter = JPConverter.allocate(resultClass, config); } else { throw new AssertionError("Unknown component type"); ItemType resultType = resultConverter.getItemType(); checkForNodes = resultType == AnyItemType.getInstance() || resultType instanceof NodeTest; resetLocalStaticProperties();
return new FromObjectArray(allocate(itemClass, config));
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); }
return new FromObjectArray(allocate(itemClass, null, config));
@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 { 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); }
return new FromObjectArray(allocate(itemClass, null, config));
public ItemType getItemType() { return itemConverter.getItemType(); }
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 ItemType getItemType() { return itemConverter.getItemType(); }
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); }
/** * Determine the data type of the expression, if possible. All expressions return * sequences, in general; this method determines the type of the items within the * sequence, assuming that (a) this is known in advance, and (b) it is the same for * all items in the sequence. * * <p>This method will always return a result, though it may be the best approximation * that is available at the time.</p> * * @return the item type * @param th the type hierarchy cache */ public ItemType getItemType(TypeHierarchy th) { //return convertClassToType(getReturnClass()); if (resultConverter == null) { return AnyItemType.getInstance(); } else { return resultConverter.getItemType(); } }
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); }