Package org.apache.jackrabbit.spi

Examples of org.apache.jackrabbit.spi.QValue


        f.deleteOnExit();
        FileWriter fw = new FileWriter(f);
        fw.write("abc");
        fw.close();

        QValue v = factory.create(f);

        assertEquals(PropertyType.BINARY, v.getType());
        assertEquals(3, v.getLength());

        assertEquals("abc", v.getString());

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        spool(out, v.getStream());
        assertEquals("abc", new String(out.toByteArray()));
    }
View Full Code Here


    public void testEmptyBinaryFromFile() throws RepositoryException, IOException {
        File f = File.createTempFile("QValueFactoryImplTest", ".txt");
        f.deleteOnExit();

        QValue v = factory.create(f);

        assertEquals(PropertyType.BINARY, v.getType());
        assertEquals(0, v.getLength());

        assertEquals("", v.getString());

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        spool(out, v.getStream());
        assertEquals("", new String(out.toByteArray()));
    }
View Full Code Here

        for (int i = 0; i < size; i++) {
            out.write(stuff);
        }
        out.close();
        InputStream in = new FileInputStream(tmp);
        QValue v = factory.create(in);
        in.close();
        tmp.delete();
        ByteArrayOutputStream bout = new ByteArrayOutputStream();
        ObjectOutputStream oout = new ObjectOutputStream(bout);
        oout.writeObject(v);
        oout.close();
        ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
        ObjectInputStream oin = new ObjectInputStream(bin);
        QValue serValue = (QValue) oin.readObject();
        try {
            InputStream in1 = new BufferedInputStream(v.getStream());
            InputStream in2 = new BufferedInputStream(serValue.getStream());
            int i;
            while ((i = in1.read()) > -1) {
                assertEquals(i, in2.read());
            }
            assertEquals(in2.read(), -1);
            in1.close();
            in2.close();
        } finally {
            v.discard();
            serValue.discard();
        }
    }
View Full Code Here

            NodeId parentId = operation.getParentId();
            Name propertyName = operation.getPropertyName();
            if (operation.isMultiValued()) {
                batch.addProperty(parentId, propertyName, operation.getValues());
            } else {
                QValue value = operation.getValues()[0];
                batch.addProperty(parentId, propertyName, value);
            }
        }
View Full Code Here

        // an identifier based path
        l.add("["+ UUID.randomUUID().toString()+"]");


        for (String jcrPath : l) {
            QValue qv = ValueFormat.getQValue(jcrPath, PropertyType.PATH, resolver, qvFactory);
            assertFalse(qv.getPath().isNormalized());
            assertEquals("Path values must not be normalized",jcrPath, ValueFormat.getJCRValue(qv, resolver, vFactory).getString());
        }
    }
View Full Code Here

    public void testDecimal() throws RepositoryException {
        BigDecimal bd = new BigDecimal(Double.MIN_VALUE);

        Value v = vFactory.createValue(bd);
        QValue qv = qvFactory.create(bd);

        assertEquals(v, ValueFormat.getJCRValue(qv, resolver, vFactory));
        assertEquals(qv, ValueFormat.getQValue(v, resolver, qvFactory));
    }
View Full Code Here

    public void testURI() throws RepositoryException, URISyntaxException {
        URI uri = new URI("http://jackrabbit.apache.org");

        Value v = vFactory.createValue("http://jackrabbit.apache.org", PropertyType.URI);
        QValue qv = qvFactory.create(uri);

        assertEquals(v, ValueFormat.getJCRValue(qv, resolver, vFactory));
        assertEquals(qv, ValueFormat.getQValue(v, resolver, qvFactory));
        assertEquals(qv, ValueFormat.getQValue("http://jackrabbit.apache.org", PropertyType.URI, resolver, qvFactory));
    }
View Full Code Here

    public void testWeakReferences() throws RepositoryException {
        String reference = UUID.randomUUID().toString();

        Value v = vFactory.createValue(reference, PropertyType.WEAKREFERENCE);
        QValue qv = qvFactory.create(reference, PropertyType.WEAKREFERENCE);

        assertEquals(v, ValueFormat.getJCRValue(qv, resolver, vFactory));
        assertEquals(qv, ValueFormat.getQValue(v, resolver, qvFactory));
        assertEquals(qv, ValueFormat.getQValue(reference, PropertyType.WEAKREFERENCE, resolver, qvFactory));       
    }
View Full Code Here

        Value[] values = resultProp.getValues();
        String[] names = resultProp.getColumnNames();
        String[] selectorNames = resultProp.getSelectorNames();
        for (int i = 0; i < values.length; i++) {
            try {
                QValue v = (values[i] == null) ? null : ValueFormat.getQValue(values[i], resolver, qValueFactory);
                Name s = (selectorNames[i] == null) ? null : resolver.getQName(selectorNames[i]);
                if (jcrScore.equals(names[i])) {
                    Double score = 0.0;
                    if (v != null) {
                        score = v.getDouble();
                    }
                    scores.put(s, score);
                } else if (jcrPath.equals(names[i])) {
                    NodeId id = null;
                    if (v != null) {
                        id = idFactory.createNodeId((String) null, v.getPath());
                    }
                    nodeIds.put(s, id);
                }
                qValues.put(names[i], v);
            } catch (RepositoryException e) {
View Full Code Here

        QPropertyDefinition def = getApplicablePropertyDefinition(qName, type, false);
        int targetType = def.getRequiredType();
        if (targetType == PropertyType.UNDEFINED) {
            targetType = type;
        }
        QValue qvs;
        if (targetType == PropertyType.UNDEFINED) {
            qvs = ValueFormat.getQValue(value, session.getNamePathResolver(), session.getQValueFactory());
            targetType = qvs.getType();
        } else {
            Value targetValue = ValueHelper.convert(value, targetType, session.getValueFactory());
            qvs = ValueFormat.getQValue(targetValue, session.getNamePathResolver(), session.getQValueFactory());
        }
        return createProperty(qName, targetType, def, new QValue[] {qvs});
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.spi.QValue

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.