Search in sources :

Example 86 with QValue

use of org.apache.jackrabbit.spi.QValue in project jackrabbit by apache.

the class DateConstraintTest method createNonMatchingValues.

protected QValue[] createNonMatchingValues() throws RepositoryException {
    Calendar cd = Calendar.getInstance();
    cd.setTimeInMillis(997);
    return new QValue[] { valueFactory.create(cd) };
}
Also used : QValue(org.apache.jackrabbit.spi.QValue) Calendar(java.util.Calendar)

Example 87 with QValue

use of org.apache.jackrabbit.spi.QValue in project jackrabbit by apache.

the class ValueConstraintTest method testCheckWrongValueType.

public void testCheckWrongValueType() throws RepositoryException {
    QValue val = createOtherValueType();
    String[] qDefs = getQDefinitions();
    for (int i = 0; i < qDefs.length; i++) {
        ValueConstraint vc = createValueConstraint(qDefs[i]);
        try {
            vc.check(val);
            fail("ValueConstraint.check() with non-matching value should throw ConstraintViolationException.");
        } catch (RepositoryException e) {
        //ok
        }
    }
}
Also used : QValue(org.apache.jackrabbit.spi.QValue) RepositoryException(javax.jcr.RepositoryException)

Example 88 with QValue

use of org.apache.jackrabbit.spi.QValue in project jackrabbit by apache.

the class ValueFormatTest method testDecimal.

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));
}
Also used : QValue(org.apache.jackrabbit.spi.QValue) QValue(org.apache.jackrabbit.spi.QValue) Value(javax.jcr.Value) BigDecimal(java.math.BigDecimal)

Example 89 with QValue

use of org.apache.jackrabbit.spi.QValue in project jackrabbit by apache.

the class QValueTest method testNameValueType.

public void testNameValueType() throws IOException, RepositoryException {
    QValue v = factory.create(NameConstants.JCR_DATA);
    assertTrue(v.getType() == PropertyType.NAME);
    v = factory.create(NameConstants.JCR_DATA.toString(), PropertyType.NAME);
    assertTrue(v.getType() == PropertyType.NAME);
}
Also used : QValue(org.apache.jackrabbit.spi.QValue)

Example 90 with QValue

use of org.apache.jackrabbit.spi.QValue in project jackrabbit by apache.

the class QValueTest method testBinaryFromInputStream.

public void testBinaryFromInputStream() throws RepositoryException, IOException {
    InputStream in = new ByteArrayInputStream(new byte[] { 'a', 'b', 'c' });
    QValue v = factory.create(in);
    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()));
}
Also used : QValue(org.apache.jackrabbit.spi.QValue) ByteArrayInputStream(java.io.ByteArrayInputStream) BufferedInputStream(java.io.BufferedInputStream) ObjectInputStream(java.io.ObjectInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Aggregations

QValue (org.apache.jackrabbit.spi.QValue)125 Name (org.apache.jackrabbit.spi.Name)40 RepositoryException (javax.jcr.RepositoryException)23 Value (javax.jcr.Value)21 NodeId (org.apache.jackrabbit.spi.NodeId)21 Batch (org.apache.jackrabbit.spi.Batch)19 PropertyInfo (org.apache.jackrabbit.spi.PropertyInfo)18 QPropertyDefinition (org.apache.jackrabbit.spi.QPropertyDefinition)12 IOException (java.io.IOException)9 ArrayList (java.util.ArrayList)9 ByteArrayOutputStream (java.io.ByteArrayOutputStream)8 ValueFormatException (javax.jcr.ValueFormatException)8 Path (org.apache.jackrabbit.spi.Path)8 QValueConstraint (org.apache.jackrabbit.spi.QValueConstraint)8 HashMap (java.util.HashMap)7 ValueConstraint (org.apache.jackrabbit.spi.commons.nodetype.constraint.ValueConstraint)7 InputStream (java.io.InputStream)5 Node (javax.jcr.Node)5 ConstraintViolationException (javax.jcr.nodetype.ConstraintViolationException)5 PropertyId (org.apache.jackrabbit.spi.PropertyId)5