You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by md...@apache.org on 2012/10/12 13:59:29 UTC
svn commit: r1397529 - in
/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/value:
ValueFactoryImpl.java ValueImpl.java
Author: mduerig
Date: Fri Oct 12 11:59:29 2012
New Revision: 1397529
URL: http://svn.apache.org/viewvc?rev=1397529&view=rev
Log:
OAK-350: Unify PropertyState and CoreValue
Javadoc
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/value/ValueFactoryImpl.java
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/value/ValueImpl.java
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/value/ValueFactoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/value/ValueFactoryImpl.java?rev=1397529&r1=1397528&r2=1397529&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/value/ValueFactoryImpl.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/value/ValueFactoryImpl.java Fri Oct 12 11:59:29 2012
@@ -62,10 +62,25 @@ public class ValueFactoryImpl implements
this.namePathMapper = namePathMapper;
}
+ /**
+ * Utility method for creating a {@code Value} based on a {@code PropertyState}.
+ * @param property The property state
+ * @param namePathMapper The name/path mapping used for converting JCR names/paths to
+ * the internal representation.
+ * @return New {@code Value} instance
+ * @throws IllegalArgumentException if {@code property.isArray()} is {@code true}.
+ */
public static Value createValue(PropertyState property, NamePathMapper namePathMapper) {
return new ValueImpl(property, namePathMapper);
}
+ /**
+ * Utility method for creating {@code Value}s based on a {@code PropertyState}.
+ * @param property The property state
+ * @param namePathMapper The name/path mapping used for converting JCR names/paths to
+ * the internal representation.
+ * @return A list of new {@code Value} instances
+ */
public static List<Value> createValues(PropertyState property, NamePathMapper namePathMapper) {
List<Value> values = Lists.newArrayList();
for (int i = 0; i < property.count(); i++) {
@@ -93,6 +108,7 @@ public class ValueFactoryImpl implements
return new ErrorValue(e, PropertyType.BINARY);
}
}
+
@Override
public Value createValue(Binary value) {
try {
@@ -242,6 +258,10 @@ public class ValueFactoryImpl implements
//------------------------------------------------------------< ErrorValue >---
+ /**
+ * Instances of this class represent a {@code Value} which couldn't be retrieved.
+ * All its accessors throw a {@code RepositoryException}.
+ */
private static class ErrorValue implements Value {
private final Exception exception;
private final int type;
@@ -300,6 +320,10 @@ public class ValueFactoryImpl implements
return new RepositoryException("Inaccessible value", exception);
}
+ /**
+ * Error values are never equal.
+ * @return {@code false}
+ */
@Override
public boolean equals(Object obj) {
return false;
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/value/ValueImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/value/ValueImpl.java?rev=1397529&r1=1397528&r2=1397529&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/value/ValueImpl.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/value/ValueImpl.java Fri Oct 12 11:59:29 2012
@@ -42,7 +42,7 @@ import org.slf4j.LoggerFactory;
import static com.google.common.base.Preconditions.checkArgument;
/**
- * ValueImpl...
+ * Implementation of {@link Value} based on {@code PropertyState}.
*/
public class ValueImpl implements Value {
private static final Logger log = LoggerFactory.getLogger(ValueImpl.class);
@@ -53,13 +53,28 @@ public class ValueImpl implements Value
private InputStream stream = null;
- ValueImpl(PropertyState propertyState, int index, NamePathMapper namePathMapper) {
- checkArgument(index < propertyState.count());
- this.propertyState = propertyState;
+ /**
+ * Create a new {@code Value} instance
+ * @param property The property state this instance is based on
+ * @param index The index
+ * @param namePathMapper The name/path mapping used for converting JCR names/paths to
+ * the internal representation.
+ * @throws IllegalArgumentException if {@code index < propertyState.count()}
+ */
+ ValueImpl(PropertyState property, int index, NamePathMapper namePathMapper) {
+ checkArgument(index < property.count());
+ this.propertyState = property;
this.index = index;
this.namePathMapper = namePathMapper;
}
+ /**
+ * Create a new {@code Value} instance
+ * @param property The property state this instance is based on
+ * @param namePathMapper The name/path mapping used for converting JCR names/paths to
+ * the internal representation.
+ * @throws IllegalArgumentException if {@code property.isArray()} is {@code true}.
+ */
ValueImpl(PropertyState property, NamePathMapper namePathMapper) {
this(checkSingleValued(property), 0, namePathMapper);
}