Package org.exist.dom

Examples of org.exist.dom.NodeProxy


       
        for (SequenceIterator nodesIter = args[1].iterate(); nodesIter.hasNext(); ) {
            NodeValue nv = (NodeValue) nodesIter.nextItem();
            if (nv.getImplementationType() == NodeValue.IN_MEMORY_NODE)
                throw new XPathException(this, "Cannot create order-index on an in-memory node");
            NodeProxy node = (NodeProxy) nv;
            SortItem si = new SortItemImpl(node);
         
           
           
            if (LOG.isDebugEnabled() && ++c % logChunk == 0) {
View Full Code Here


    @Override
    public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException {
        if (args[1].isEmpty())
            return Sequence.EMPTY_SEQUENCE;
        String id = args[0].getStringValue();
        NodeProxy node = (NodeProxy) args[1].itemAt(0);
        SortIndexWorker index = (SortIndexWorker)
            context.getBroker().getIndexController().getWorkerByIndexId(SortIndex.ID);
        long pos = 0;
        try {
            pos = index.getIndex(id, node);
View Full Code Here

                this.nodeIdValues.get(doc, ref);
                int units = ByteConversion.byteToShort(ref.bytes, ref.offset);
                NodeId nodeId = db.getNodeFactory().createFromData(units, ref.bytes, ref.offset + 2);
                //LOG.info("doc: " + docId + "; node: " + nodeId.toString() + "; units: " + units);

                NodeProxy storedNode = new NodeProxy(storedDocument, nodeId);
                if (qname != null)
                    storedNode.setNodeType(qname.getNameType() == ElementValue.ATTRIBUTE ? Node.ATTRIBUTE_NODE : Node.ELEMENT_NODE);

                LuceneMatch match = worker. new LuceneMatch(contextId, nodeId, query);
                match.setScore(score);
                storedNode.addMatch(match);
                callback.found(storedNode, score);
                //resultSet.add(storedNode, sizeHint);

            } catch (IOException e) {
                e.printStackTrace();
View Full Code Here

            result = NodeSets.fmapNodes(nodes, new F<NodeProxy, NodeProxy>() {

                @Override
                public NodeProxy f(NodeProxy a) {
                    NodeProxy before = nodesContainingFirstINgrams.get(a);
                    if (before != null) {
                        return getContinuousMatches(before, a);
                    } else {
                        return null;
                    }
View Full Code Here

      return args[0];
   
    NodeValue nv = (NodeValue) args[0].itemAt(0);
    if (!nv.isPersistentSet())
      return nv;
    NodeProxy node = (NodeProxy) nv;
   
    String matchStr = null;
    NodeId nodeId = null;
    try {
      for (EmbeddedXMLStreamReader reader = context.getBroker().getXMLStreamReader(node, true); reader.hasNext(); ) {
          int status = reader.next();
          if (status == XMLStreamConstants.CHARACTERS) {
            matchStr = reader.getText();
            nodeId = (NodeId) reader.getProperty(ExtendedXMLStreamReader.PROPERTY_NODE_ID);
            break;
          }
      }
    } catch (IOException e) {
      throw new XPathException(this, ErrorCodes.FOER0000, "Exception caught while reading document");
    } catch (XMLStreamException e) {
      throw new XPathException(this, ErrorCodes.FOER0000, "Exception caught while reading document");
    }
   
    if (nodeId != null) {
      Match match = new NGramMatch(getContextId(), node.getNodeId(), matchStr);
      match.addOffset(0, matchStr.length());
      node.addMatch(match);
    }
    return node;
  }
View Full Code Here

            Match nextMatch = this.match;
            while (nextMatch != null) {
                if (proxy.getNodeId().isDescendantOf(nextMatch.getNodeId())) {
                    if (ancestors == null)
                        ancestors = new ExtArrayNodeSet();
                    ancestors.add(new NodeProxy(proxy.getDocument(), nextMatch.getNodeId()));
                }
                nextMatch = nextMatch.getNextMatch();
            }
            if (ancestors != null && !ancestors.isEmpty()) {
                for (NodeProxy p : ancestors) {
View Full Code Here

                        super.characters(s.substring(offset.getOffset(), offset.getOffset() + offset.getLength()));
                        super.endElement(MATCH_ELEMENT);
                    } else {
                        try {
                            callback.match(nextListener, s.substring(offset.getOffset(), offset.getOffset() + offset.getLength()),
                                    new NodeProxy(getCurrentNode()));
                        } catch (XPathException e) {
                            throw new SAXException("An error occurred while calling match callback: " + e.getMessage(), e);
                        }
                    }
                    pos = offset.getOffset() + offset.getLength();
View Full Code Here

                    NodeId previous = null;
                    for (int m = 0; m < occurrences; m++) {
                        NodeId nodeId = index.getBrokerPool().getNodeFactory().createFromStream(previous, is);
                        previous = nodeId;
                        int freq = is.readInt();
                        NodeProxy storedNode = new NodeProxy(storedDocument, nodeId);
                        // if a context set is specified, we can directly check if the
                        // matching node is a descendant of one of the nodes
                        // in the context set.
                        if (contextSet != null) {
                            int sizeHint = contextSet.getSizeHint(storedDocument);
                            if (returnAncestor) {
                                NodeProxy parentNode = contextSet.parentWithChild(storedNode, false, true, NodeProxy.UNKNOWN_NODE_LEVEL);
                                if (parentNode != null) {
                                    readMatches(ngram, is, nodeId, freq, parentNode);
                                    resultSet.add(parentNode, sizeHint);
                                } else
                                    is.skip(freq);
View Full Code Here

                        int freq = is.readInt();
                        is.skip(freq);
                        boolean include = true;
                        //TODO : revisit
                        if (contextSet != null) {
                            NodeProxy parentNode = contextSet.parentWithChild(storedDocument, nodeId, false, true);
                            include = (parentNode != null);
                        }
                        if (include) {
                            Occurrences oc = map.get(term);
                            if (oc == null) {
View Full Code Here

            assertNotNull(xquery);
            // test element ids
            Sequence seq = xquery.execute("doc('/db/test/test_string.xml')/test/para",
                    null, AccessContext.TEST);
            assertEquals(3, seq.getItemCount());
            NodeProxy comment = (NodeProxy) seq.itemAt(0);
            assertEquals(comment.getNodeId().toString(), "1.1");
            comment = (NodeProxy) seq.itemAt(1);
            assertEquals(comment.getNodeId().toString(), "1.3");
            comment = (NodeProxy) seq.itemAt(2);
            assertEquals(comment.getNodeId().toString(), "1.5");

            seq = xquery.execute("doc('/db/test/test_string.xml')/test//a",
                    null, AccessContext.TEST);
            assertEquals(1, seq.getItemCount());
            NodeProxy a = (NodeProxy) seq.itemAt(0);
            assertEquals("1.3.2", a.getNodeId().toString());

            // test attribute id
            seq = xquery.execute("doc('/db/test/test_string.xml')/test//a/@href",
                    null, AccessContext.TEST);
            assertEquals(1, seq.getItemCount());
            NodeProxy href = (NodeProxy) seq.itemAt(0);
            System.out.println(StorageAddress.toString(href.getInternalAddress()));
            assertEquals("1.3.2.1", href.getNodeId().toString());
            // test Attr deserialization
            Attr attr = (Attr) href.getNode();
            System.out.println(StorageAddress.toString(((StoredNode)attr).getInternalAddress()));
            // test Attr fields
            assertEquals(attr.getNodeName(), "href");
            assertEquals(attr.getName(), "href");
            assertEquals(attr.getValue(), "#");
             // test DOMFile.getNodeValue()
            assertEquals(href.getStringValue(), "#");

            // test text node
            seq = xquery.execute("doc('/db/test/test_string.xml')/test//b/text()",
                    null, AccessContext.TEST);
            assertEquals(1, seq.getItemCount());
            NodeProxy text = (NodeProxy) seq.itemAt(0);
            assertEquals("1.5.2.1", text.getNodeId().toString());
            // test DOMFile.getNodeValue()
            assertEquals(text.getStringValue(), "paragraph");
            // test Text deserialization
            Text node = (Text) text.getNode();
            assertEquals(node.getNodeValue(), "paragraph");
            assertEquals(node.getData(), "paragraph");
        } catch (Exception e) {
            e.printStackTrace();
            fail(e.getMessage());
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.