Package javax.jcr.query

Examples of javax.jcr.query.Row


            super(collection);
            this.size = size;
        }

        public Row nextRow() {
            Row next = super.nextRow();
            if (commonPathPrefix != null) {
                next = new RowAdapter(next, commonPathPrefix);
            } else {
                next = new RowAdapter(next, ".");
            }
View Full Code Here


         * Fetches the next {@link Row}.
         */
        private void fetchNext() {
            next = null;
            while (next == null && rows.hasNext()) {
                Row r = rows.nextRow();
                try {
                    if (filter.include(r)) {
                        next = r;
                        return;
                    }
View Full Code Here

                };

                public ValueMap next() {
                    final Map<String, Object> row = new HashMap<String, Object>();
                    try {
                        Row jcrRow = rows.nextRow();
                        boolean didPath = false;
                        boolean didScore = false;
                        Value[] values = jcrRow.getValues();
                        for (int i = 0; i < values.length; i++) {
                            Value v = values[i];
                            if (v != null) {
                                String colName = colNames[i];
                                row.put(colName,
                                    JcrResourceUtil.toJavaObject(values[i]));
                                if (colName.equals(QUERY_COLUMN_PATH)) {
                                    didPath = true;
                                }
                                if (colName.equals(QUERY_COLUMN_SCORE)) {
                                    didScore = true;
                                }
                            }
                        }
                        if (!didPath) {
                            row.put(QUERY_COLUMN_PATH, jcrRow.getPath());
                        }
                        if (!didScore) {
                            row.put(QUERY_COLUMN_SCORE, jcrRow.getScore());
                        }

                    } catch (RepositoryException re) {
                        log.error(
                            "queryResources$next: Problem accessing row values",
View Full Code Here

                    printIndentation + printIndentStep);
            Set<Row> allRows = new TreeSet<Row>(new RowPathComparator(
                    Arrays.asList(merger.getSelectorNames())));
            RowIterator ri1 = branch1.getRows();
            while (ri1.hasNext()) {
                Row r = ri1.nextRow();
                allRows.add(r);
            }
            log.debug("{} SQL2 JOIN executed first branch, took {} ms.",
                    genString(printIndentation), System.currentTimeMillis()
                            - bTime);

            // second branch
            bTime = System.currentTimeMillis();
            QueryResult branch2 = execute(merger,
                    csInfo.getRightInnerConstraints(), isOuterJoin,
                    printIndentation + printIndentStep);
            RowIterator ri2 = branch2.getRows();
            while (ri2.hasNext()) {
                Row r = ri2.nextRow();
                allRows.add(r);
            }
            log.debug("{} SQL2 JOIN executed second branch, took {} ms.",
                    genString(printIndentation), System.currentTimeMillis()
                            - bTime);
View Full Code Here

    private static String getPaths(Query q) throws RepositoryException {
        QueryResult r = q.execute();
        RowIterator it = r.getRows();
        StringBuilder buff = new StringBuilder();
        if (it.hasNext()) {
            Row row = it.nextRow();
            if (buff.length() > 0) {
                buff.append(", ");
            }
            buff.append(row.getPath());
        }
        return buff.toString();
    }
View Full Code Here

        Query q = qm.createQuery("select text from [nt:base] where id = $id", Query.JCR_SQL2);
        q.bindValue("id", vf.createValue("1"));
        QueryResult r = q.execute();
        RowIterator it = r.getRows();
        assertTrue(it.hasNext());
        Row row = it.nextRow();
        assertEquals("hello_world", row.getValue("text").getString());
        String[] columns = r.getColumnNames();
        assertEquals(1, columns.length);
        assertEquals("text", columns[0]);
        assertFalse(it.hasNext());
View Full Code Here

        for (int i = -1; i < 5; i++) {
            QueryResult r = q.execute();
            RowIterator it = r.getRows();
            assertEquals(3, r.getRows().getSize());
            assertEquals(3, r.getNodes().getSize());
            Row row;
            try {
                it.skip(i);
                assertTrue(i >= 0 && i <= 3);
            } catch (IllegalArgumentException e) {
                assertEquals(-1, i);
            } catch (NoSuchElementException e) {
                assertTrue(i >= 2);
            }
            if (i <= 0) {
                assertTrue(it.hasNext());
                row = it.nextRow();
                assertEquals("1", row.getValue("id").getString());
            }
            if (i <= 1) {
                assertTrue(it.hasNext());
                row = it.nextRow();
                assertEquals("2", row.getValue("id").getString());
            }
            if (i <= 2) {
                assertTrue(it.hasNext());
                row = it.nextRow();
                assertEquals("3", row.getValue("id").getString());
            }
            assertFalse(it.hasNext());
        }
    }
View Full Code Here

                QueryResult r = q.execute();
                RowIterator it = r.getRows();
                int l = Math.min(Math.max(0, 3 - offset), limit);
                assertEquals(l, r.getRows().getSize());
                assertEquals(l, r.getNodes().getSize());
                Row row;
               
                for (int x = offset + 1, i = 0; i < limit && x < 4; i++, x++) {
                    assertTrue(it.hasNext());
                    row = it.nextRow();
                    assertEquals("" + x, row.getValue("id").getString());
                }
                assertFalse(it.hasNext());
            }
        }
    }
View Full Code Here

                Query.JCR_SQL2);

        QueryResult r = q.execute();
        RowIterator it = r.getRows();
        assertTrue(it.hasNext());
        Row row = it.nextRow();
        assertEquals("p1 p2", row.getValues()[0].getString());
    }
View Full Code Here

        n2.setProperty("desc", "Description");
        session.save();

        Query q;
        RowIterator it;
        Row row;
        String s;
       
        String xpath = "//*[jcr:contains(., 'hello')]/rep:excerpt(.) order by jcr:path descending";
       
        q = qm.createQuery(xpath, "xpath");
        it = q.execute().getRows();
        row = it.nextRow();
        s = row.getValue("rep:excerpt(.)").getString();
        assertTrue(s, s.indexOf("<strong>hello</strong> world") >= 0);
        assertTrue(s, s.indexOf("description") >= 0);
        row = it.nextRow();
        s = row.getValue("rep:excerpt(.)").getString();
        // TODO is this expected?
        assertTrue(s, s.indexOf("Hello World") >= 0);
        assertTrue(s, s.indexOf("Description") >= 0);
       
        xpath = "//*[jcr:contains(., 'hello')]/rep:excerpt(.) order by jcr:path descending";

        q = qm.createQuery(xpath, "xpath");
        it = q.execute().getRows();
        row = it.nextRow();
        s = row.getValue("rep:excerpt(text)").getString();
        assertTrue(s, s.indexOf("<strong>hello</strong> world") >= 0);
        assertTrue(s, s.indexOf("description") < 0);
        row = it.nextRow();
        s = row.getValue("rep:excerpt(text)").getString();
        // TODO is this expected?
        assertTrue(s, s.indexOf("Hello World") >= 0);
        assertTrue(s, s.indexOf("Description") < 0);
    }
View Full Code Here

TOP

Related Classes of javax.jcr.query.Row

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.