Search in sources :

Example 41 with QValue

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

the class QValueTest method testUriValueType.

public void testUriValueType() throws RepositoryException, URISyntaxException {
    QValue v = factory.create(URI_STRING, PropertyType.URI);
    assertTrue("Type of a date value must be PropertyType.URI.", v.getType() == PropertyType.URI);
}
Also used : QValue(org.apache.jackrabbit.spi.QValue)

Example 42 with QValue

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

the class QValueTest method testCreateTrueBooleanValue.

public void testCreateTrueBooleanValue() throws RepositoryException {
    QValue v = factory.create(true);
    assertEquals("Boolean value must be true", Boolean.TRUE.toString(), v.getString());
    assertEquals("Boolean value must be true", true, v.getBoolean());
}
Also used : QValue(org.apache.jackrabbit.spi.QValue)

Example 43 with QValue

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

the class QValueTest method testEmptyBinaryFromInputStream.

public void testEmptyBinaryFromInputStream() throws RepositoryException, IOException {
    InputStream in = new ByteArrayInputStream(new byte[0]);
    QValue v = factory.create(in);
    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()));
}
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)

Example 44 with QValue

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

the class QValueTest method testCreateFalseBooleanValue.

public void testCreateFalseBooleanValue() throws RepositoryException {
    QValue v = factory.create(false);
    assertEquals("Boolean value must be false", Boolean.FALSE.toString(), v.getString());
    assertEquals("Boolean value must be false", false, v.getBoolean());
}
Also used : QValue(org.apache.jackrabbit.spi.QValue)

Example 45 with QValue

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

the class NodeState method getAllNodeTypeNames.

/**
     * TODO: clarify usage
     * In case the status of the given node state is not {@link Status#EXISTING}
     * the transiently added mixin types are taken into account as well.
     *
     * @return
     */
public synchronized Name[] getAllNodeTypeNames() {
    Name[] allNtNames;
    if (getStatus() == Status.EXISTING) {
        allNtNames = getNodeTypeNames();
    } else {
        // TODO: check if correct (and only used for creating new)
        Name primaryType = getNodeTypeName();
        // default
        allNtNames = new Name[] { primaryType };
        try {
            PropertyEntry pe = getNodeEntry().getPropertyEntry(NameConstants.JCR_MIXINTYPES, true);
            if (pe != null) {
                PropertyState mixins = pe.getPropertyState();
                QValue[] values = mixins.getValues();
                allNtNames = new Name[values.length + 1];
                for (int i = 0; i < values.length; i++) {
                    allNtNames[i] = values[i].getName();
                }
                allNtNames[values.length] = primaryType;
            }
        // else: no jcr:mixinTypes property exists -> ignore
        } catch (RepositoryException e) {
        // unexpected error: ignore
        }
    }
    return allNtNames;
}
Also used : QValue(org.apache.jackrabbit.spi.QValue) PropertyEntry(org.apache.jackrabbit.jcr2spi.hierarchy.PropertyEntry) RepositoryException(javax.jcr.RepositoryException) Name(org.apache.jackrabbit.spi.Name)

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