Search in sources :

Example 56 with ValueFactory

use of javax.jcr.ValueFactory in project jackrabbit by apache.

the class NameTest method testExpandedNameValueProperty.

/**
     * Expanded names must always be resolved.
     * Test setting a NAME-value property.
     *
     * @throws RepositoryException
     */
public void testExpandedNameValueProperty() throws RepositoryException {
    ValueFactory vf = superuser.getValueFactory();
    Value nameValue = vf.createValue(Workspace.NAME_VERSION_STORAGE_NODE, PropertyType.NAME);
    Property p = testRootNode.setProperty(propertyName1, nameValue);
    assertEquals(PropertyType.NAME, p.getType());
    assertEquals(nameValue.getString(), p.getValue().getString());
    assertEquals(nameValue, p.getValue());
    assertEquals("jcr:versionStorage", p.getString());
}
Also used : Value(javax.jcr.Value) ValueFactory(javax.jcr.ValueFactory) Property(javax.jcr.Property)

Example 57 with ValueFactory

use of javax.jcr.ValueFactory in project jackrabbit by apache.

the class NameTest method testExpandedNameValue.

/**
     * Expanded names must always be resolved.
     * Test NAME-value creation.
     * 
     * @throws RepositoryException
     */
public void testExpandedNameValue() throws RepositoryException {
    ValueFactory vf = superuser.getValueFactory();
    Value nameValue = vf.createValue(Workspace.NAME_VERSION_STORAGE_NODE, PropertyType.NAME);
    assertEquals(PropertyType.NAME, nameValue.getType());
    assertEquals(nameValue.getString(), vf.createValue("jcr:versionStorage", PropertyType.NAME).getString());
    assertEquals(nameValue, vf.createValue("jcr:versionStorage", PropertyType.NAME));
    assertEquals("jcr:versionStorage", nameValue.getString());
}
Also used : Value(javax.jcr.Value) ValueFactory(javax.jcr.ValueFactory)

Example 58 with ValueFactory

use of javax.jcr.ValueFactory in project jackrabbit by apache.

the class TestContentLoader method addPropertyTestData.

/**
     * Creates a boolean, double, long, calendar and a path property at the
     * given node.
     */
private void addPropertyTestData(Node node) throws RepositoryException {
    node.setProperty("boolean", true);
    node.setProperty("double", Math.PI);
    node.setProperty("long", 90834953485278298l);
    Calendar c = Calendar.getInstance();
    c.set(2005, 6, 18, 17, 30);
    node.setProperty("calendar", c);
    ValueFactory factory = node.getSession().getValueFactory();
    node.setProperty("path", factory.createValue("/", PropertyType.PATH));
    node.setProperty("multi", new String[] { "one", "two", "three" });
}
Also used : Calendar(java.util.Calendar) ValueFactory(javax.jcr.ValueFactory)

Example 59 with ValueFactory

use of javax.jcr.ValueFactory in project jackrabbit by apache.

the class LowerCaseOperand method getValues.

/**
     * {@inheritDoc}
     */
public Value[] getValues(ScoreNode sn, EvaluationContext context) throws RepositoryException {
    ValueFactory vf = context.getSession().getValueFactory();
    Value[] values = operand.getValues(sn, context);
    for (int i = 0; i < values.length; i++) {
        values[i] = vf.createValue(values[i].getString().toLowerCase());
    }
    return values;
}
Also used : Value(javax.jcr.Value) ValueFactory(javax.jcr.ValueFactory)

Example 60 with ValueFactory

use of javax.jcr.ValueFactory in project jackrabbit by apache.

the class UpperCaseOperand method getValues.

/**
     * {@inheritDoc}
     */
public Value[] getValues(ScoreNode sn, EvaluationContext context) throws RepositoryException {
    ValueFactory vf = context.getSession().getValueFactory();
    Value[] values = operand.getValues(sn, context);
    for (int i = 0; i < values.length; i++) {
        values[i] = vf.createValue(values[i].getString().toUpperCase());
    }
    return values;
}
Also used : Value(javax.jcr.Value) ValueFactory(javax.jcr.ValueFactory)

Aggregations

ValueFactory (javax.jcr.ValueFactory)105 Value (javax.jcr.Value)51 Node (javax.jcr.Node)50 Session (javax.jcr.Session)40 Test (org.junit.Test)17 RepositoryException (javax.jcr.RepositoryException)16 InputStream (java.io.InputStream)13 AccessControlManager (javax.jcr.security.AccessControlManager)13 HashMap (java.util.HashMap)12 Privilege (javax.jcr.security.Privilege)12 Property (javax.jcr.Property)11 ByteArrayInputStream (java.io.ByteArrayInputStream)10 Query (javax.jcr.query.Query)8 Calendar (java.util.Calendar)7 QueryManager (javax.jcr.query.QueryManager)7 RowIterator (javax.jcr.query.RowIterator)7 AbstractRepositoryTest (org.apache.jackrabbit.oak.jcr.AbstractRepositoryTest)7 NodeIterator (javax.jcr.NodeIterator)6 JackrabbitNode (org.apache.jackrabbit.api.JackrabbitNode)6 IOException (java.io.IOException)5