Esempio n. 1
0
 public static Sequence atomize(Sequence input) throws XPathException {
   if (input.hasOne()) return input.itemAt(0).atomize();
   Item next;
   ValueSequence result = new ValueSequence();
   for (SequenceIterator i = input.iterate(); i.hasNext(); ) {
     next = i.nextItem();
     result.add(next.atomize());
   }
   return result;
 }
 /* (non-Javadoc)
  * @see org.exist.xquery.value.AbstractSequence#addAll(org.exist.xquery.value.Sequence)
  */
 public void addAll(Sequence other) throws XPathException {
   if (other.hasOne()) {
     add(other.itemAt(0));
   } else if (!other.isEmpty()) {
     for (final SequenceIterator i = other.iterate(); i.hasNext(); ) {
       final Item next = i.nextItem();
       if (next != null) {
         add(next);
       }
     }
   }
 }
 public Entry(Item item) throws XPathException {
   this.item = item;
   values = new AtomicValue[groupSpecs.length];
   for (int i = 0; i < groupSpecs.length; i++) {
     final Sequence seq = groupSpecs[i].getGroupExpression().eval(null);
     values[i] = AtomicValue.EMPTY_VALUE;
     // TODO : get rid of getLength()
     if (seq.hasOne()) {
       values[i] = seq.itemAt(0).atomize();
     } else if (seq.hasMany()) {
       throw new XPathException(
           "expected a single value for group by expression "
               + ExpressionDumper.dump(groupSpecs[i].getGroupExpression())
               + " ; found: "
               + seq.getItemCount());
     }
   }
 }