Hi!
Is there a way to get number of nodes for xpath query without iterating through
returned collection?
When I try to use count xpath function I'm getting an exception saying that
it's not supported.
This code works, but I feel that there must be a better solution.
final QueryManager queryManager =
getObjectContentManager().getQueryManager();
final Iterator objectIterator =
getObjectContentManager().getObjectIterator(queryManager.createQuery(
queryManager.createFilter(NewsComponentType.class).addJCRExpression(
"topicSet/collection-element/topic/collection-element/property/collection-element/@value='"
+ productType + "'")));
// returns wrong size in some cases, see NodeIteratorImpl#getSize
// return (int) ((RangeIterator) objectIterator).getSize();
return Iterators.size(objectIterator);