Package org.exist.dom

Examples of org.exist.dom.NodeProxy


  }

  private void getId(NodeSet result, DocumentSet docs, String id) throws XPathException {
    final NodeSet attribs = context.getBroker().getValueIndex().find(context.getWatchDog(), Constants.EQ, docs, null, -1, null, new StringValue(id, Type.ID));
    NodeProxy p;
    for (final NodeProxy n : attribs) {
      p = new NodeProxy(n.getDocument(), n.getNodeId().getParentId(), Node.ELEMENT_NODE);
      result.add(p);
    }
  }
View Full Code Here


            if (!Type.subTypeOf(item.getType(), Type.NODE))
                {throw new XPathException(this, ErrorCodes.XPTY0004,  "Item is not a node; got '" + item + "'", seq);}
            final Sequence s = item.toSequence();

            if (s.isPersistentSet()) {
                final NodeProxy p = s.toNodeSet().get(0);
                result.add(new NodeProxy(p.getDocument()));
            } else {
                if (seq.hasOne() && item.getType() == Type.ATTRIBUTE) {
                  result.add(item);
                } else {
                  result.add(((NodeImpl)item).getDocument());
View Full Code Here

                } catch (final BTreeException bte) {
                    LOG.error("report me", bte);
                }
            } while (parentPointer == KEY_NOT_FOUND);
            try {
                final NodeProxy parent = new NodeProxy(doc, nodeID, parentPointer);
                final EmbeddedXMLStreamReader cursor = broker.getXMLStreamReader(parent, true);
                while(cursor.hasNext()) {
                    final int status = cursor.next();
                    if (status != XMLStreamReader.END_ELEMENT) {
                        final NodeId nextId = (NodeId) cursor.getProperty(EmbeddedXMLStreamReader.PROPERTY_NODE_ID);
View Full Code Here

            if (StorageAddress.hasAddress(address))
                {recordPos = findRecord(address);}
            if (recordPos == null) {
                // fallback to a BTree lookup if the node could not be found
                // by its storage address
                address = findValue(broker, new NodeProxy(node));
                if (address == BTree.KEY_NOT_FOUND) {
                    LOG.error("Node value not found: " + node);
                    //TODO : throw exception ? -pb
                    return null;
                }
View Full Code Here

      } else {
          result = contextSequence.toNodeSet().copy();

          if (inPredicate) {
            for (final SequenceIterator i = result.iterate(); i.hasNext();) {
              final NodeProxy item = (NodeProxy) i.nextItem();
//              item.addContextNode(getExpressionId(), item);
              if (contextId != Expression.NO_CONTEXT_ID)
                            {item.addContextNode(contextId, item);}
              else
                {item.addContextNode(getExpressionId(), item);}
            }
          }

          // evaluate argument expression
          final Sequence argSeq = arg.eval(result);
View Full Code Here

            try {
                if (!context.inProtectedMode() && !dlock.hasLock()) {
                    dlock.acquire(Lock.READ_LOCK);
                    lockAcquired = true;
                }
                result.add(new NodeProxy(doc)); // , -1, Node.DOCUMENT_NODE));
            } catch (final LockException e) {
                throw new XPathException(e.getMessage());
            } finally {
                if (lockAcquired)
                    {dlock.release(Lock.READ_LOCK);}
View Full Code Here

        if (node != null) {
            RecordPos rec = null;
            if (StorageAddress.hasAddress(node.getInternalAddress()))
                {rec = db.findRecord(node.getInternalAddress());}
            if (rec == null) {
                final long addr = db.findValue(broker, new NodeProxy(node));
                if (addr == BTree.KEY_NOT_FOUND)
                    {return false;}
                rec = db.findRecord(addr);
            }
            pageNum = rec.getPage().getPageNum();
View Full Code Here

            String xml[] = null;
            if (Type.subTypeOf(qr.getItemType(), Type.NODE)) {
                // Fix typecast exception RMT
//        NodeList resultSet = (NodeSet)qr;
                final ExtArrayNodeSet hitsByDoc = new ExtArrayNodeSet();
                NodeProxy p;
                String ppath;
                for (final SequenceIterator i = qr.iterate(); i.hasNext(); ) {
//        for (Iterator i = ((NodeSet) resultSet).iterator(); i.hasNext();) {
                    p = (NodeProxy) i.nextItem();
                    ///TODO : use dedicated function in XmldbURI
                    ppath = p.getDocument().getCollection().getURI().toString() + '/' + p.getDocument().getFileURI();
                    if (ppath.equals(path))
                        {hitsByDoc.add(p);}
                }
                --start;
                if (start < 0 || start > hitsByDoc.getLength())
                    {throw new RemoteException(
                            "index " + start + "out of bounds (" + hitsByDoc.getLength() + ")");}
                if (start + howmany >= hitsByDoc.getLength())
                    {howmany = hitsByDoc.getLength() - start;}
                final Serializer serializer = broker.getSerializer();
                serializer.reset();
                serializer.setProperty(OutputKeys.INDENT, indent ? "yes" : "no");
                serializer.setProperty(EXistOutputKeys.EXPAND_XINCLUDES, xinclude ? "yes" : "no");
                serializer.setProperty(EXistOutputKeys.HIGHLIGHT_MATCHES, highlight);
               
                xml = new String[howmany];
                int j=0;
                for (int i = start; i < start + howmany; i++) {
                    final NodeProxy proxy = ((NodeSet) hitsByDoc).get(i);
                    if (proxy == null)
                        {throw new RuntimeException("not found: " + start);}
                    xml[j] = serializer.serialize(proxy);
                    j++; // update count number of results
                }
View Full Code Here

      for (final SequenceIterator i = results.iterate(); i.hasNext(); ) {
          final Item item = i.nextItem();
          if(Type.subTypeOf(item.getType(), Type.NODE)) {
              final NodeValue node = (NodeValue)item;
              if(node.getImplementationType() == NodeValue.PERSISTENT_NODE) {
                  final NodeProxy p = (NodeProxy)node;
                  if ((documents = (TreeMap) collections.get(p.getDocument().getCollection().getURI())) == null) {
                      documents = new TreeMap();
                      collections.put(p.getDocument().getCollection().getURI(), documents);
                  }
                  if ((hits = (Integer) documents.get(p.getDocument().getFileURI())) == null)
                      documents.put(p.getDocument().getFileURI(), Integer.valueOf(1));
                  else
                      documents.put(p.getDocument().getFileURI(), Integer.valueOf(hits.intValue() + 1));
              }
          }
      }
    } catch (final XPathException e) {
      throw new RemoteException(e.getMessage());
View Full Code Here

        Terms terms = fields.terms(RangeIndexWorker.FIELD_ID);
        if (terms != null) {
            TermsEnum termsEnum = terms.iterator(null);
            DocsEnum docs = null;
            for (NodeSetIterator i = contextSet.iterator(); i.hasNext(); ) {
                NodeProxy node = i.next();
                BytesRef lowerBound = new BytesRef(LuceneUtil.createId(node.getDoc().getDocId(), node.getNodeId()));
                BytesRef upperBound = new BytesRef(LuceneUtil.createId(node.getDoc().getDocId(), node.getNodeId().nextSibling()));

                if (termsEnum.seekCeil(lowerBound, false) != TermsEnum.SeekStatus.END) {
                    do {
                        BytesRef nextId = termsEnum.term();
                        if (nextId.compareTo(upperBound) < 0) {
View Full Code Here

TOP

Related Classes of org.exist.dom.NodeProxy

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.