You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-issues@jackrabbit.apache.org by "Michael Dürig (JIRA)" <ji...@apache.org> on 2012/09/27 20:51:07 UTC
[jira] [Created] (OAK-350) Unify PropertyState and CoreValue
Michael Dürig created OAK-350:
---------------------------------
Summary: Unify PropertyState and CoreValue
Key: OAK-350
URL: https://issues.apache.org/jira/browse/OAK-350
Project: Jackrabbit Oak
Issue Type: Improvement
Components: core
Reporter: Michael Dürig
With OAK-346 {{ValueImpl}} and {{ValueFactoryImpl}} are now part of the core. In order to reduce the number of separate representations of values, I propose to unify CoreValue with PropertyState and eventually deprecate and remove CoreValue.
I suggest to add generic methods to {{PropertyState}} for accessing the values directly instead of looping them through an additional container:
{code}
/**
* Value of this property.
* The type of the return value is determined by the target {@code type}
* argument. If {@code type.isArray()} is true, this method returns an
* {@code Iterable} of the {@link Type#getBaseType() base type} of
* {@code type} containing all values of this property.
* If the target type is not the same as the type of this property an attempt
* is made to convert the value to the target type. If the conversion fails an
* exception is thrown.
* @param type target type
* @param <T>
* @return the value of this property
* @throws IllegalStateException if {@code type.isArray() == false} and
* {@code this.isArray() == true}. In other words, when trying to convert
* from an array to an atom.
* @throws IllegalArgumentException if {@code type} refers to an unkown type.
* @throws NumberFormatException if conversion to a number failed.
* @throws UnsupportedOperationException if conversion to boolean failed.
*/
@Nonnull
<T> T getValue(Type<T> type);
/**
* Value at the given {@code index}.
* The type of the return value is determined by the target {@code type}
* argument.
* If the target type is not the same as the type of this property an attempt
* is made to convert the value to the target type. If the conversion fails an
* exception is thrown.
* @param type target type
* @param index
* @param <T>
* @return the value of this property at the given {@code index}
* @throws IndexOutOfBoundsException if {@code index} is less than {@code 0} or
* greater or equals {@code count()}.
* @throws IllegalArgumentException if {@code type} refers to an unkown type or if
* {@code type.isArray()} is true.
*/
@Nonnull
<T> T getValue(Type<T> type, int index);
{code}
See [PropertyState | https://github.com/mduerig/jackrabbit-oak/blob/unify-value-and-propertystate/oak-core/src/main/java/org/apache/jackrabbit/oak/api/PropertyState.java], [Type | https://github.com/mduerig/jackrabbit-oak/blob/unify-value-and-propertystate/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Type.java] and [Blob | https://github.com/mduerig/jackrabbit-oak/blob/unify-value-and-propertystate/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Blob.java] for the full proposal.
In addition of reducing the number of runtime instances this approach also simplifies client code:
{code}
String s = property.getValue().getString();
{code}
becomes
{code}
String s = property.getValue(STRING);
{code}
And even better for multi valued properties:
{code}
for(Value value : property.getValues()) {
String s = value.getString();
doSomething(s);
}
{code}
becomes
{code}
for(String s : property.getValue(STRINGS)) {
doSomething(s);
}
{code}
Furthermore this approach opens up the possibility for plugging in custom types later on by adding handlers for custom instances of {{Type}}.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (OAK-350) Unify PropertyState and CoreValue
Posted by "Michael Dürig (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/OAK-350?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13469315#comment-13469315 ]
Michael Dürig commented on OAK-350:
-----------------------------------
Revision 1394002 introduced the initial changes required:
* {{NodeBuilder}} and {{Tree}} now have methods for directly setting values instead of going through {{CoreValue}}.
* {{CoreValue}} is now deprecated
* Methods using {{CoreValue}} are deprecated when alternatives exist
The current {{PropertyState}} implementations are still based on {{CoreValue}} but I plan to gradually phase them out.
> Unify PropertyState and CoreValue
> ---------------------------------
>
> Key: OAK-350
> URL: https://issues.apache.org/jira/browse/OAK-350
> Project: Jackrabbit Oak
> Issue Type: Improvement
> Components: core
> Reporter: Michael Dürig
> Assignee: Michael Dürig
>
> With OAK-346 {{ValueImpl}} and {{ValueFactoryImpl}} are now part of the core. In order to reduce the number of separate representations of values, I propose to unify CoreValue with PropertyState and eventually deprecate and remove CoreValue.
> I suggest to add generic methods to {{PropertyState}} for accessing the values directly instead of looping them through an additional container:
> {code}
> /**
> * Value of this property.
> * The type of the return value is determined by the target {@code type}
> * argument. If {@code type.isArray()} is true, this method returns an
> * {@code Iterable} of the {@link Type#getBaseType() base type} of
> * {@code type} containing all values of this property.
> * If the target type is not the same as the type of this property an attempt
> * is made to convert the value to the target type. If the conversion fails an
> * exception is thrown.
> * @param type target type
> * @param <T>
> * @return the value of this property
> * @throws IllegalStateException if {@code type.isArray() == false} and
> * {@code this.isArray() == true}. In other words, when trying to convert
> * from an array to an atom.
> * @throws IllegalArgumentException if {@code type} refers to an unkown type.
> * @throws NumberFormatException if conversion to a number failed.
> * @throws UnsupportedOperationException if conversion to boolean failed.
> */
> @Nonnull
> <T> T getValue(Type<T> type);
> /**
> * Value at the given {@code index}.
> * The type of the return value is determined by the target {@code type}
> * argument.
> * If the target type is not the same as the type of this property an attempt
> * is made to convert the value to the target type. If the conversion fails an
> * exception is thrown.
> * @param type target type
> * @param index
> * @param <T>
> * @return the value of this property at the given {@code index}
> * @throws IndexOutOfBoundsException if {@code index} is less than {@code 0} or
> * greater or equals {@code count()}.
> * @throws IllegalArgumentException if {@code type} refers to an unkown type or if
> * {@code type.isArray()} is true.
> */
> @Nonnull
> <T> T getValue(Type<T> type, int index);
> {code}
> See [PropertyState | https://github.com/mduerig/jackrabbit-oak/blob/unify-value-and-propertystate/oak-core/src/main/java/org/apache/jackrabbit/oak/api/PropertyState.java], [Type | https://github.com/mduerig/jackrabbit-oak/blob/unify-value-and-propertystate/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Type.java] and [Blob | https://github.com/mduerig/jackrabbit-oak/blob/unify-value-and-propertystate/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Blob.java] for the full proposal.
> In addition of reducing the number of runtime instances this approach also simplifies client code:
> {code}
> String s = property.getValue().getString();
> {code}
> becomes
> {code}
> String s = property.getValue(STRING);
> {code}
> And even better for multi valued properties:
> {code}
> for(Value value : property.getValues()) {
> String s = value.getString();
> doSomething(s);
> }
> {code}
> becomes
> {code}
> for(String s : property.getValue(STRINGS)) {
> doSomething(s);
> }
> {code}
> Furthermore this approach opens up the possibility for plugging in custom types later on by adding handlers for custom instances of {{Type}}.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Updated] (OAK-350) Unify PropertyState and CoreValue
Posted by "Michael Dürig (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/OAK-350?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Michael Dürig updated OAK-350:
------------------------------
Component/s: jcr
> Unify PropertyState and CoreValue
> ---------------------------------
>
> Key: OAK-350
> URL: https://issues.apache.org/jira/browse/OAK-350
> Project: Jackrabbit Oak
> Issue Type: Improvement
> Components: core, jcr
> Reporter: Michael Dürig
> Assignee: Michael Dürig
>
> With OAK-346 {{ValueImpl}} and {{ValueFactoryImpl}} are now part of the core. In order to reduce the number of separate representations of values, I propose to unify CoreValue with PropertyState and eventually deprecate and remove CoreValue.
> I suggest to add generic methods to {{PropertyState}} for accessing the values directly instead of looping them through an additional container:
> {code}
> /**
> * Value of this property.
> * The type of the return value is determined by the target {@code type}
> * argument. If {@code type.isArray()} is true, this method returns an
> * {@code Iterable} of the {@link Type#getBaseType() base type} of
> * {@code type} containing all values of this property.
> * If the target type is not the same as the type of this property an attempt
> * is made to convert the value to the target type. If the conversion fails an
> * exception is thrown.
> * @param type target type
> * @param <T>
> * @return the value of this property
> * @throws IllegalStateException if {@code type.isArray() == false} and
> * {@code this.isArray() == true}. In other words, when trying to convert
> * from an array to an atom.
> * @throws IllegalArgumentException if {@code type} refers to an unkown type.
> * @throws NumberFormatException if conversion to a number failed.
> * @throws UnsupportedOperationException if conversion to boolean failed.
> */
> @Nonnull
> <T> T getValue(Type<T> type);
> /**
> * Value at the given {@code index}.
> * The type of the return value is determined by the target {@code type}
> * argument.
> * If the target type is not the same as the type of this property an attempt
> * is made to convert the value to the target type. If the conversion fails an
> * exception is thrown.
> * @param type target type
> * @param index
> * @param <T>
> * @return the value of this property at the given {@code index}
> * @throws IndexOutOfBoundsException if {@code index} is less than {@code 0} or
> * greater or equals {@code count()}.
> * @throws IllegalArgumentException if {@code type} refers to an unkown type or if
> * {@code type.isArray()} is true.
> */
> @Nonnull
> <T> T getValue(Type<T> type, int index);
> {code}
> See [PropertyState | https://github.com/mduerig/jackrabbit-oak/blob/unify-value-and-propertystate/oak-core/src/main/java/org/apache/jackrabbit/oak/api/PropertyState.java], [Type | https://github.com/mduerig/jackrabbit-oak/blob/unify-value-and-propertystate/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Type.java] and [Blob | https://github.com/mduerig/jackrabbit-oak/blob/unify-value-and-propertystate/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Blob.java] for the full proposal.
> In addition of reducing the number of runtime instances this approach also simplifies client code:
> {code}
> String s = property.getValue().getString();
> {code}
> becomes
> {code}
> String s = property.getValue(STRING);
> {code}
> And even better for multi valued properties:
> {code}
> for(Value value : property.getValues()) {
> String s = value.getString();
> doSomething(s);
> }
> {code}
> becomes
> {code}
> for(String s : property.getValue(STRINGS)) {
> doSomething(s);
> }
> {code}
> Furthermore this approach opens up the possibility for plugging in custom types later on by adding handlers for custom instances of {{Type}}.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Assigned] (OAK-350) Unify PropertyState and CoreValue
Posted by "Michael Dürig (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/OAK-350?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Michael Dürig reassigned OAK-350:
---------------------------------
Assignee: Michael Dürig
> Unify PropertyState and CoreValue
> ---------------------------------
>
> Key: OAK-350
> URL: https://issues.apache.org/jira/browse/OAK-350
> Project: Jackrabbit Oak
> Issue Type: Improvement
> Components: core
> Reporter: Michael Dürig
> Assignee: Michael Dürig
>
> With OAK-346 {{ValueImpl}} and {{ValueFactoryImpl}} are now part of the core. In order to reduce the number of separate representations of values, I propose to unify CoreValue with PropertyState and eventually deprecate and remove CoreValue.
> I suggest to add generic methods to {{PropertyState}} for accessing the values directly instead of looping them through an additional container:
> {code}
> /**
> * Value of this property.
> * The type of the return value is determined by the target {@code type}
> * argument. If {@code type.isArray()} is true, this method returns an
> * {@code Iterable} of the {@link Type#getBaseType() base type} of
> * {@code type} containing all values of this property.
> * If the target type is not the same as the type of this property an attempt
> * is made to convert the value to the target type. If the conversion fails an
> * exception is thrown.
> * @param type target type
> * @param <T>
> * @return the value of this property
> * @throws IllegalStateException if {@code type.isArray() == false} and
> * {@code this.isArray() == true}. In other words, when trying to convert
> * from an array to an atom.
> * @throws IllegalArgumentException if {@code type} refers to an unkown type.
> * @throws NumberFormatException if conversion to a number failed.
> * @throws UnsupportedOperationException if conversion to boolean failed.
> */
> @Nonnull
> <T> T getValue(Type<T> type);
> /**
> * Value at the given {@code index}.
> * The type of the return value is determined by the target {@code type}
> * argument.
> * If the target type is not the same as the type of this property an attempt
> * is made to convert the value to the target type. If the conversion fails an
> * exception is thrown.
> * @param type target type
> * @param index
> * @param <T>
> * @return the value of this property at the given {@code index}
> * @throws IndexOutOfBoundsException if {@code index} is less than {@code 0} or
> * greater or equals {@code count()}.
> * @throws IllegalArgumentException if {@code type} refers to an unkown type or if
> * {@code type.isArray()} is true.
> */
> @Nonnull
> <T> T getValue(Type<T> type, int index);
> {code}
> See [PropertyState | https://github.com/mduerig/jackrabbit-oak/blob/unify-value-and-propertystate/oak-core/src/main/java/org/apache/jackrabbit/oak/api/PropertyState.java], [Type | https://github.com/mduerig/jackrabbit-oak/blob/unify-value-and-propertystate/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Type.java] and [Blob | https://github.com/mduerig/jackrabbit-oak/blob/unify-value-and-propertystate/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Blob.java] for the full proposal.
> In addition of reducing the number of runtime instances this approach also simplifies client code:
> {code}
> String s = property.getValue().getString();
> {code}
> becomes
> {code}
> String s = property.getValue(STRING);
> {code}
> And even better for multi valued properties:
> {code}
> for(Value value : property.getValues()) {
> String s = value.getString();
> doSomething(s);
> }
> {code}
> becomes
> {code}
> for(String s : property.getValue(STRINGS)) {
> doSomething(s);
> }
> {code}
> Furthermore this approach opens up the possibility for plugging in custom types later on by adding handlers for custom instances of {{Type}}.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Resolved] (OAK-350) Unify PropertyState and CoreValue
Posted by "Michael Dürig (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/OAK-350?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Michael Dürig resolved OAK-350.
-------------------------------
Resolution: Fixed
Fix Version/s: 0.6
Fixed at revision 1397546.
> Unify PropertyState and CoreValue
> ---------------------------------
>
> Key: OAK-350
> URL: https://issues.apache.org/jira/browse/OAK-350
> Project: Jackrabbit Oak
> Issue Type: Improvement
> Components: core, jcr
> Reporter: Michael Dürig
> Assignee: Michael Dürig
> Fix For: 0.6
>
>
> With OAK-346 {{ValueImpl}} and {{ValueFactoryImpl}} are now part of the core. In order to reduce the number of separate representations of values, I propose to unify CoreValue with PropertyState and eventually deprecate and remove CoreValue.
> I suggest to add generic methods to {{PropertyState}} for accessing the values directly instead of looping them through an additional container:
> {code}
> /**
> * Value of this property.
> * The type of the return value is determined by the target {@code type}
> * argument. If {@code type.isArray()} is true, this method returns an
> * {@code Iterable} of the {@link Type#getBaseType() base type} of
> * {@code type} containing all values of this property.
> * If the target type is not the same as the type of this property an attempt
> * is made to convert the value to the target type. If the conversion fails an
> * exception is thrown.
> * @param type target type
> * @param <T>
> * @return the value of this property
> * @throws IllegalStateException if {@code type.isArray() == false} and
> * {@code this.isArray() == true}. In other words, when trying to convert
> * from an array to an atom.
> * @throws IllegalArgumentException if {@code type} refers to an unkown type.
> * @throws NumberFormatException if conversion to a number failed.
> * @throws UnsupportedOperationException if conversion to boolean failed.
> */
> @Nonnull
> <T> T getValue(Type<T> type);
> /**
> * Value at the given {@code index}.
> * The type of the return value is determined by the target {@code type}
> * argument.
> * If the target type is not the same as the type of this property an attempt
> * is made to convert the value to the target type. If the conversion fails an
> * exception is thrown.
> * @param type target type
> * @param index
> * @param <T>
> * @return the value of this property at the given {@code index}
> * @throws IndexOutOfBoundsException if {@code index} is less than {@code 0} or
> * greater or equals {@code count()}.
> * @throws IllegalArgumentException if {@code type} refers to an unkown type or if
> * {@code type.isArray()} is true.
> */
> @Nonnull
> <T> T getValue(Type<T> type, int index);
> {code}
> See [PropertyState | https://github.com/mduerig/jackrabbit-oak/blob/unify-value-and-propertystate/oak-core/src/main/java/org/apache/jackrabbit/oak/api/PropertyState.java], [Type | https://github.com/mduerig/jackrabbit-oak/blob/unify-value-and-propertystate/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Type.java] and [Blob | https://github.com/mduerig/jackrabbit-oak/blob/unify-value-and-propertystate/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Blob.java] for the full proposal.
> In addition of reducing the number of runtime instances this approach also simplifies client code:
> {code}
> String s = property.getValue().getString();
> {code}
> becomes
> {code}
> String s = property.getValue(STRING);
> {code}
> And even better for multi valued properties:
> {code}
> for(Value value : property.getValues()) {
> String s = value.getString();
> doSomething(s);
> }
> {code}
> becomes
> {code}
> for(String s : property.getValue(STRINGS)) {
> doSomething(s);
> }
> {code}
> Furthermore this approach opens up the possibility for plugging in custom types later on by adding handlers for custom instances of {{Type}}.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Comment Edited] (OAK-350) Unify PropertyState and CoreValue
Posted by "Michael Dürig (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/OAK-350?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13474969#comment-13474969 ]
Michael Dürig edited comment on OAK-350 at 10/12/12 1:09 PM:
-------------------------------------------------------------
This is basically resolved at revision 1397546. Remaining issues:
* The {{PropertyValue}} class introduced with OAK-371 is referenced in the Oak API (OAK-376).
* When setting binary properties, the binaries are currently kept in memory (OAK-375).
* Intergrate PropertyBuilder with NodeBuilder (OAK-372).
was (Author: mduerig):
This is basically resolved at revision 1397546. Remaining issues:
* The {{PropertyValue}} class introduced with OAK-371 is referenced in the Oak API.
* When setting binary properties, the binaries are currently kept in memory.
* Intergrate PropertyBuilder with NodeBuilder (OAK-372).
> Unify PropertyState and CoreValue
> ---------------------------------
>
> Key: OAK-350
> URL: https://issues.apache.org/jira/browse/OAK-350
> Project: Jackrabbit Oak
> Issue Type: Improvement
> Components: core, jcr
> Reporter: Michael Dürig
> Assignee: Michael Dürig
> Fix For: 0.6
>
>
> With OAK-346 {{ValueImpl}} and {{ValueFactoryImpl}} are now part of the core. In order to reduce the number of separate representations of values, I propose to unify CoreValue with PropertyState and eventually deprecate and remove CoreValue.
> I suggest to add generic methods to {{PropertyState}} for accessing the values directly instead of looping them through an additional container:
> {code}
> /**
> * Value of this property.
> * The type of the return value is determined by the target {@code type}
> * argument. If {@code type.isArray()} is true, this method returns an
> * {@code Iterable} of the {@link Type#getBaseType() base type} of
> * {@code type} containing all values of this property.
> * If the target type is not the same as the type of this property an attempt
> * is made to convert the value to the target type. If the conversion fails an
> * exception is thrown.
> * @param type target type
> * @param <T>
> * @return the value of this property
> * @throws IllegalStateException if {@code type.isArray() == false} and
> * {@code this.isArray() == true}. In other words, when trying to convert
> * from an array to an atom.
> * @throws IllegalArgumentException if {@code type} refers to an unkown type.
> * @throws NumberFormatException if conversion to a number failed.
> * @throws UnsupportedOperationException if conversion to boolean failed.
> */
> @Nonnull
> <T> T getValue(Type<T> type);
> /**
> * Value at the given {@code index}.
> * The type of the return value is determined by the target {@code type}
> * argument.
> * If the target type is not the same as the type of this property an attempt
> * is made to convert the value to the target type. If the conversion fails an
> * exception is thrown.
> * @param type target type
> * @param index
> * @param <T>
> * @return the value of this property at the given {@code index}
> * @throws IndexOutOfBoundsException if {@code index} is less than {@code 0} or
> * greater or equals {@code count()}.
> * @throws IllegalArgumentException if {@code type} refers to an unkown type or if
> * {@code type.isArray()} is true.
> */
> @Nonnull
> <T> T getValue(Type<T> type, int index);
> {code}
> See [PropertyState | https://github.com/mduerig/jackrabbit-oak/blob/unify-value-and-propertystate/oak-core/src/main/java/org/apache/jackrabbit/oak/api/PropertyState.java], [Type | https://github.com/mduerig/jackrabbit-oak/blob/unify-value-and-propertystate/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Type.java] and [Blob | https://github.com/mduerig/jackrabbit-oak/blob/unify-value-and-propertystate/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Blob.java] for the full proposal.
> In addition of reducing the number of runtime instances this approach also simplifies client code:
> {code}
> String s = property.getValue().getString();
> {code}
> becomes
> {code}
> String s = property.getValue(STRING);
> {code}
> And even better for multi valued properties:
> {code}
> for(Value value : property.getValues()) {
> String s = value.getString();
> doSomething(s);
> }
> {code}
> becomes
> {code}
> for(String s : property.getValue(STRINGS)) {
> doSomething(s);
> }
> {code}
> Furthermore this approach opens up the possibility for plugging in custom types later on by adding handlers for custom instances of {{Type}}.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (OAK-350) Unify PropertyState and CoreValue
Posted by "Michael Dürig (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/OAK-350?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13470259#comment-13470259 ]
Michael Dürig commented on OAK-350:
-----------------------------------
In revision 1394472 I removed all deprecated methods from {{Tree}}, {{NodeBuilder}} and {{PropertyState}}. The new static utility class {{CoreValues}} provides methods for adapting a {{PropertyState}} to a {{CoreValue}}. This serves as a temporary bridge until the {{CoreValue}} and {{PropertyState}} refactoring has been done.
> Unify PropertyState and CoreValue
> ---------------------------------
>
> Key: OAK-350
> URL: https://issues.apache.org/jira/browse/OAK-350
> Project: Jackrabbit Oak
> Issue Type: Improvement
> Components: core, jcr
> Reporter: Michael Dürig
> Assignee: Michael Dürig
>
> With OAK-346 {{ValueImpl}} and {{ValueFactoryImpl}} are now part of the core. In order to reduce the number of separate representations of values, I propose to unify CoreValue with PropertyState and eventually deprecate and remove CoreValue.
> I suggest to add generic methods to {{PropertyState}} for accessing the values directly instead of looping them through an additional container:
> {code}
> /**
> * Value of this property.
> * The type of the return value is determined by the target {@code type}
> * argument. If {@code type.isArray()} is true, this method returns an
> * {@code Iterable} of the {@link Type#getBaseType() base type} of
> * {@code type} containing all values of this property.
> * If the target type is not the same as the type of this property an attempt
> * is made to convert the value to the target type. If the conversion fails an
> * exception is thrown.
> * @param type target type
> * @param <T>
> * @return the value of this property
> * @throws IllegalStateException if {@code type.isArray() == false} and
> * {@code this.isArray() == true}. In other words, when trying to convert
> * from an array to an atom.
> * @throws IllegalArgumentException if {@code type} refers to an unkown type.
> * @throws NumberFormatException if conversion to a number failed.
> * @throws UnsupportedOperationException if conversion to boolean failed.
> */
> @Nonnull
> <T> T getValue(Type<T> type);
> /**
> * Value at the given {@code index}.
> * The type of the return value is determined by the target {@code type}
> * argument.
> * If the target type is not the same as the type of this property an attempt
> * is made to convert the value to the target type. If the conversion fails an
> * exception is thrown.
> * @param type target type
> * @param index
> * @param <T>
> * @return the value of this property at the given {@code index}
> * @throws IndexOutOfBoundsException if {@code index} is less than {@code 0} or
> * greater or equals {@code count()}.
> * @throws IllegalArgumentException if {@code type} refers to an unkown type or if
> * {@code type.isArray()} is true.
> */
> @Nonnull
> <T> T getValue(Type<T> type, int index);
> {code}
> See [PropertyState | https://github.com/mduerig/jackrabbit-oak/blob/unify-value-and-propertystate/oak-core/src/main/java/org/apache/jackrabbit/oak/api/PropertyState.java], [Type | https://github.com/mduerig/jackrabbit-oak/blob/unify-value-and-propertystate/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Type.java] and [Blob | https://github.com/mduerig/jackrabbit-oak/blob/unify-value-and-propertystate/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Blob.java] for the full proposal.
> In addition of reducing the number of runtime instances this approach also simplifies client code:
> {code}
> String s = property.getValue().getString();
> {code}
> becomes
> {code}
> String s = property.getValue(STRING);
> {code}
> And even better for multi valued properties:
> {code}
> for(Value value : property.getValues()) {
> String s = value.getString();
> doSomething(s);
> }
> {code}
> becomes
> {code}
> for(String s : property.getValue(STRINGS)) {
> doSomething(s);
> }
> {code}
> Furthermore this approach opens up the possibility for plugging in custom types later on by adding handlers for custom instances of {{Type}}.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (OAK-350) Unify PropertyState and CoreValue
Posted by "Michael Dürig (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/OAK-350?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13474969#comment-13474969 ]
Michael Dürig commented on OAK-350:
-----------------------------------
This is basically resolved at revision 1397546. Remaining issues:
* The {{PropertyValue}} class introduced with OAK-371 is referenced in the Oak API.
* When setting binary properties, the binaries are currently kept in memory.
* Intergrate PropertyBuilder with NodeBuilder (OAK-372).
> Unify PropertyState and CoreValue
> ---------------------------------
>
> Key: OAK-350
> URL: https://issues.apache.org/jira/browse/OAK-350
> Project: Jackrabbit Oak
> Issue Type: Improvement
> Components: core, jcr
> Reporter: Michael Dürig
> Assignee: Michael Dürig
>
> With OAK-346 {{ValueImpl}} and {{ValueFactoryImpl}} are now part of the core. In order to reduce the number of separate representations of values, I propose to unify CoreValue with PropertyState and eventually deprecate and remove CoreValue.
> I suggest to add generic methods to {{PropertyState}} for accessing the values directly instead of looping them through an additional container:
> {code}
> /**
> * Value of this property.
> * The type of the return value is determined by the target {@code type}
> * argument. If {@code type.isArray()} is true, this method returns an
> * {@code Iterable} of the {@link Type#getBaseType() base type} of
> * {@code type} containing all values of this property.
> * If the target type is not the same as the type of this property an attempt
> * is made to convert the value to the target type. If the conversion fails an
> * exception is thrown.
> * @param type target type
> * @param <T>
> * @return the value of this property
> * @throws IllegalStateException if {@code type.isArray() == false} and
> * {@code this.isArray() == true}. In other words, when trying to convert
> * from an array to an atom.
> * @throws IllegalArgumentException if {@code type} refers to an unkown type.
> * @throws NumberFormatException if conversion to a number failed.
> * @throws UnsupportedOperationException if conversion to boolean failed.
> */
> @Nonnull
> <T> T getValue(Type<T> type);
> /**
> * Value at the given {@code index}.
> * The type of the return value is determined by the target {@code type}
> * argument.
> * If the target type is not the same as the type of this property an attempt
> * is made to convert the value to the target type. If the conversion fails an
> * exception is thrown.
> * @param type target type
> * @param index
> * @param <T>
> * @return the value of this property at the given {@code index}
> * @throws IndexOutOfBoundsException if {@code index} is less than {@code 0} or
> * greater or equals {@code count()}.
> * @throws IllegalArgumentException if {@code type} refers to an unkown type or if
> * {@code type.isArray()} is true.
> */
> @Nonnull
> <T> T getValue(Type<T> type, int index);
> {code}
> See [PropertyState | https://github.com/mduerig/jackrabbit-oak/blob/unify-value-and-propertystate/oak-core/src/main/java/org/apache/jackrabbit/oak/api/PropertyState.java], [Type | https://github.com/mduerig/jackrabbit-oak/blob/unify-value-and-propertystate/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Type.java] and [Blob | https://github.com/mduerig/jackrabbit-oak/blob/unify-value-and-propertystate/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Blob.java] for the full proposal.
> In addition of reducing the number of runtime instances this approach also simplifies client code:
> {code}
> String s = property.getValue().getString();
> {code}
> becomes
> {code}
> String s = property.getValue(STRING);
> {code}
> And even better for multi valued properties:
> {code}
> for(Value value : property.getValues()) {
> String s = value.getString();
> doSomething(s);
> }
> {code}
> becomes
> {code}
> for(String s : property.getValue(STRINGS)) {
> doSomething(s);
> }
> {code}
> Furthermore this approach opens up the possibility for plugging in custom types later on by adding handlers for custom instances of {{Type}}.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira