jackrabbit-oak-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Dürig (JIRA) <j...@apache.org>
Subject [jira] [Comment Edited] (OAK-350) Unify PropertyState and CoreValue
Date Fri, 12 Oct 2012 13:11:02 GMT

    [ 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

Mime
View raw message