You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by re...@apache.org on 2009/04/29 19:13:15 UTC
svn commit: r769837 - in /jackrabbit/trunk:
jackrabbit-api/src/main/java/org/apache/jackrabbit/api/jsr283/
jackrabbit-core/src/main/java/org/apache/jackrabbit/core/
Author: reschke
Date: Wed Apr 29 17:13:15 2009
New Revision: 769837
URL: http://svn.apache.org/viewvc?rev=769837&view=rev
Log:
JCR-1609: add missing methods to new property types to o.a.j.api.jsr283.Node, add method stubs in -core.
Added:
jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/jsr283/Binary.java (with props)
Modified:
jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/jsr283/Node.java
jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
Added: jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/jsr283/Binary.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/jsr283/Binary.java?rev=769837&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/jsr283/Binary.java (added)
+++ jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/jsr283/Binary.java Wed Apr 29 17:13:15 2009
@@ -0,0 +1,76 @@
+/*
+ * 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.api.jsr283;
+
+import java.io.InputStream;
+import java.io.IOException;
+
+import javax.jcr.Property;
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+import javax.jcr.ValueFactory;
+
+/**
+ * A <code>Binary</code> object holds a JCR property value of type
+ * <code>BINARY</code>. The <code>Binary</code> interface and the related
+ * methods in {@link Property}, {@link Value} and {@link ValueFactory} replace
+ * the deprecated {@link Value#getStream} and {@link Property#getStream}
+ * methods.
+ *
+ * @since JCR 2.0
+ */
+public interface Binary {
+
+ /**
+ * Returns an {@link InputStream} representation of this value. Each call to
+ * <code>getStream()</code> returns a new stream. The API consumer is
+ * responsible for calling <code>close()</code> on the returned stream.
+ *
+ * @return A stream representation of this value.
+ *
+ * @throws RepositoryException if an error occurs.
+ */
+ InputStream getStream() throws RepositoryException;
+
+ /**
+ * Reads successive bytes from the specified <code>position</code> in this
+ * <code>Binary</code> into the passed byte array until either the byte
+ * array is full or the end of the <code>Binary</code> is encountered.
+ *
+ * @param b the buffer into which the data is read.
+ * @param position the position in this Binary from which to start reading
+ * bytes.
+ *
+ * @return the number of bytes read into the buffer, or -1 if there is no
+ * more data because the end of the Binary has been reached.
+ *
+ * @throws IOException if an I/O error occurs.
+ * @throws NullPointerException if b is null.
+ * @throws IllegalArgumentException if offset is negative.
+ * @throws RepositoryException if another error occurs.
+ */
+ int read(byte[] b, long position) throws IOException, RepositoryException;
+
+ /**
+ * Returns the size of this <code>Binary</code> value in bytes.
+ *
+ * @return the size of this value in bytes.
+ *
+ * @throws RepositoryException if an error occurs.
+ */
+ long getSize() throws RepositoryException;
+}
\ No newline at end of file
Propchange: jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/jsr283/Binary.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/jsr283/Binary.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/jsr283/Binary.java
------------------------------------------------------------------------------
svn:keywords = author date id revision url
Modified: jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/jsr283/Node.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/jsr283/Node.java?rev=769837&r1=769836&r2=769837&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/jsr283/Node.java (original)
+++ jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/jsr283/Node.java Wed Apr 29 17:13:15 2009
@@ -16,10 +16,15 @@
*/
package org.apache.jackrabbit.api.jsr283;
+import java.math.BigDecimal;
+
import javax.jcr.NodeIterator;
+import javax.jcr.Property;
import javax.jcr.RepositoryException;
import javax.jcr.PropertyIterator;
import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.Value;
+import javax.jcr.ValueFormatException;
import javax.jcr.lock.LockException;
import javax.jcr.nodetype.ConstraintViolationException;
import javax.jcr.nodetype.NoSuchNodeTypeException;
@@ -181,6 +186,60 @@
public void setPrimaryType(String nodeTypeName) throws NoSuchNodeTypeException, VersionException, ConstraintViolationException, LockException, RepositoryException;
/**
+ * The behavior of this method is identical to that of {@link
+ * #setProperty(String name, Value value)} except that the value is
+ * specified as a {@link BigDecimal} and, if possible, the type assigned to
+ * the property is <code>DECIMAL</code>, otherwise a best-effort conversion
+ * is attempted.
+ *
+ * @param name The name of a property of this node
+ * @param value The value to assigned
+ *
+ * @return The updated <code>Property</code> object
+ *
+ * @throws ValueFormatException if <code>value</code> cannot be converted to
+ * the type of the specified property or if the property already exists and
+ * is multi-valued.
+ * @throws VersionException if this node is read-only due to a checked-in node and
+ * this implementation performs this validation immediately.
+ * @throws LockException if a lock prevents the setting of the property and
+ * this implementation performs this validation immediately.
+ * @throws ConstraintViolationException if the change would violate a
+ * node-type or other constraint and this implementation performs this
+ * validation immediately.
+ * @throws RepositoryException if another error occurs.
+ * @since JCR 2.0
+ */
+ public Property setProperty(String name, BigDecimal value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException;
+
+ /**
+ * The behavior of this method is identical to that of {@link
+ * #setProperty(String name, Value value)} except that the value is
+ * specified as a {@link Binary} and, if possible, the type assigned to the
+ * property is <code>BINARY</code>, otherwise a best-effort conversion is
+ * attempted.
+ *
+ * @param name The name of a property of this node
+ * @param value The value to assigned
+ *
+ * @return The updated <code>Property</code> object
+ *
+ * @throws ValueFormatException if <code>value</code> cannot be converted to
+ * the type of the specified property or if the property already exists and
+ * is multi-valued.
+ * @throws VersionException if this node is read-only due to a checked-in node and
+ * this implementation performs this validation immediately.
+ * @throws LockException if a lock prevents the setting of the property and
+ * this implementation performs this validation immediately.
+ * @throws ConstraintViolationException if the change would violate a
+ * node-type or other constraint and this implementation performs this
+ * validation immediately.
+ * @throws RepositoryException if another error occurs.
+ * @since JCR 2.0
+ */
+ public Property setProperty(String name, Binary value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException;
+
+ /**
* Returns an iterator over all nodes that are in the shared set of this
* node. If this node is not shared then the returned iterator contains
* only this node.
Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java?rev=769837&r1=769836&r2=769837&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java Wed Apr 29 17:13:15 2009
@@ -57,7 +57,7 @@
import org.apache.jackrabbit.util.ChildrenCollectorFilter;
import org.apache.jackrabbit.uuid.UUID;
import org.apache.jackrabbit.value.ValueHelper;
-import org.apache.jackrabbit.api.jsr283.InvalidLifecycleTransitionException;
+import org.apache.jackrabbit.api.jsr283.Binary;
import org.apache.jackrabbit.api.jsr283.version.VersionManager;
import org.apache.jackrabbit.api.jsr283.lock.LockManager;
import org.slf4j.Logger;
@@ -95,6 +95,7 @@
import javax.jcr.version.VersionHistory;
import javax.jcr.version.VersionIterator;
import java.io.InputStream;
+import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
@@ -1690,6 +1691,16 @@
return prop;
}
+ public Property setProperty(String name, BigDecimal value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
+ // TODO
+ throw new RuntimeException("Not implemented yet, see JCR-1609");
+ }
+
+ public Property setProperty(String name, Binary value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
+ // TODO
+ throw new RuntimeException("Not implemented yet, see JCR-1609");
+ }
+
/**
* @see ItemImpl#getQName()
*/
@@ -4827,5 +4838,4 @@
public String toString() {
return "node " + super.toString();
}
-
}