All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.jackrabbit.spi.QValueFactory Maven / Gradle / Ivy

There is a newer version: 2.0.10
Show newest version
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.jackrabbit.spi;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.Calendar;
import java.math.BigDecimal;
import java.net.URI;

import javax.jcr.RepositoryException;
import javax.jcr.ValueFormatException;

/**
 * QValueFactory defines methods to create QValue
 * instances.
 */
public interface QValueFactory {

    /**
     * Create a new QValue using the given String representation
     * of the value and its {@link javax.jcr.PropertyType type}.
     *
     * @param value String representation of the new QValue. Note,
     * that the given String must never be null.
     * @param type A valid {@link javax.jcr.PropertyType type}.
     * @return a new QValue.
     * @throws ValueFormatException If the given value cannot be
     * converted to the specified type.
     * @throws RepositoryException If another error occurs.
     * @see QValue#getType()
     */
    public QValue create(String value, int type) throws ValueFormatException, RepositoryException;

    /**
     * Create a new QValue with type {@link javax.jcr.PropertyType#DATE}.
     *
     * @param value A non-null Calendar object acting as value
     * of the new QValue.
     * @return a new QValue.
     */
    public QValue create(Calendar value) throws RepositoryException;

    /**
     * Create a new QValue with type {@link javax.jcr.PropertyType#DOUBLE}.
     *
     * @param value A double containing the value
     * of the new QValue.
     * @return a new QValue.
     */
    public QValue create(double value) throws RepositoryException;

    /**
     * Create a new QValue with type {@link javax.jcr.PropertyType#LONG}.
     *
     * @param value A long containing the value
     * of the new QValue.
     * @return a new QValue.
     */
    public QValue create(long value) throws RepositoryException;

    /**
     * Create a new QValue with type {@link javax.jcr.PropertyType#BOOLEAN}.
     *
     * @param value A boolean containing the value
     * of the new QValue.
     * @return a new QValue.
     */
    public QValue create(boolean value) throws RepositoryException;

    /**
     * Create a new QValue with type {@link javax.jcr.PropertyType#NAME}.
     *
     * @param value A non-null Name.
     * @return a new QValue.
     */
    public QValue create(Name value) throws RepositoryException;

    /**
     * Create a new QValue with type {@link javax.jcr.PropertyType#PATH}.
     *
     * @param value A non-null Path.
     * @return a new QValue.
     */
    public QValue create(Path value) throws RepositoryException;

    /**
     * Create a new QValue with type {@link javax.jcr.PropertyType#DECIMAL}.
     *
     * @param value A non-null BigDecimal.
     * @return a new QValue.
     */
    public QValue create(BigDecimal value) throws RepositoryException;

    /**
     * Create a new QValue with type {@link javax.jcr.PropertyType#URI}.
     *
     * @param value A non-null URI.
     * @return a new QValue.
     */
    public QValue create(URI value) throws RepositoryException;

    /**
     * Create a new QValue with type {@link javax.jcr.PropertyType#BINARY}.
     *
     * @param value
     * @return a new QValue.
     */
    public QValue create(byte[] value) throws RepositoryException;

    /**
     * Creates a QValue that contains the given binary stream.
     * The given stream is consumed and closed by this method. The type of the
     * resulting QValue will be {@link javax.jcr.PropertyType#BINARY}.
     *
     * @param value binary stream
     * @return a new binary QValue.
     * @throws RepositoryException if the value could not be created
     * @throws IOException if the stream can not be consumed
     */
    public QValue create(InputStream value) throws RepositoryException, IOException;

    /**
     * Create a new QValue with type {@link javax.jcr.PropertyType#BINARY}.
     *
     * @param value
     * @return a new binary QValue.
     * @throws IOException
     */
    public QValue create(File value) throws RepositoryException, IOException;

    /**
     * Given the QPropertyDefinition of an autocreated
     * property, compute suitable values to be used in transient space until
     * the newly created node gets saved.
     *
     * @param propertyDefinition definition of property for which values should be created
     * @return computed value
     * @throws RepositoryException
     */
    public QValue[] computeAutoValues(QPropertyDefinition propertyDefinition) throws RepositoryException;
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy