jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1394245 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/identifier/ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/ oak-core/src/main/java/org/apache/jackrabbit/oak/query/ oak-core/src/ma...
Date Thu, 04 Oct 2012 20:22:20 GMT
Author: mduerig
Date: Thu Oct  4 20:22:19 2012
New Revision: 1394245

URL: http://svn.apache.org/viewvc?rev=1394245&view=rev
Log:
OAK-350: Unify PropertyState and CoreValue
- Replace CoreValue.getString with PropertyState.getValue(Type)

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/identifier/IdentifierManager.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/NamespaceValidator.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/Namespaces.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/ReadWriteNamespaceRegistry.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/Query.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/FullTextSearchImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/LowerCaseImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/PropertyValueImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/UpperCaseImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeValidator.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/AuthorizableImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/IndexUtils.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/principal/TreeBasedPrincipal.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/NodeUtil.java
    jackrabbit/oak/trunk/oak-http/src/main/java/org/apache/jackrabbit/oak/http/TextRepresentation.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/identifier/IdentifierManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/identifier/IdentifierManager.java?rev=1394245&r1=1394244&r2=1394245&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/identifier/IdentifierManager.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/identifier/IdentifierManager.java
Thu Oct  4 20:22:19 2012
@@ -46,6 +46,8 @@ import org.apache.jackrabbit.oak.plugins
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import static org.apache.jackrabbit.oak.api.Type.STRING;
+
 /**
  * IdentifierManager...
  */
@@ -100,7 +102,7 @@ public class IdentifierManager {
             // TODO and a relative path irrespective of the accessibility of the parent node(s)
             return tree.getPath();
         } else {
-            return property.getValue().getString();
+            return property.getValue(STRING);
         }
     }
 
@@ -243,7 +245,7 @@ public class IdentifierManager {
                     return false;
                 }
                 else {
-                    return uuid.equals(pState.getValue().getString());
+                    return uuid.equals(pState.getValue(STRING));
                 }
             }
         });
@@ -255,7 +257,7 @@ public class IdentifierManager {
         // TODO use NodeType.isNodeType to determine type membership instead of equality
on type names
         PropertyState pType = tree.getProperty(JcrConstants.JCR_PRIMARYTYPE);
         if (pType != null) {
-            String primaryType = pType.getValue().getString();
+            String primaryType = pType.getValue(STRING);
             if (ntName.equals(primaryType)) {
                 return true;
             }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/NamespaceValidator.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/NamespaceValidator.java?rev=1394245&r1=1394244&r2=1394245&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/NamespaceValidator.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/NamespaceValidator.java
Thu Oct  4 20:22:19 2012
@@ -19,12 +19,12 @@ package org.apache.jackrabbit.oak.plugin
 import java.util.Locale;
 import java.util.Map;
 
-import javax.jcr.PropertyType;
-
 import org.apache.jackrabbit.oak.api.CommitFailedException;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.spi.commit.DefaultValidator;
 
+import static org.apache.jackrabbit.oak.api.Type.STRING;
+
 class NamespaceValidator extends DefaultValidator {
 
     private final Map<String, String> map;
@@ -46,14 +46,13 @@ class NamespaceValidator extends Default
             throw new NamespaceValidatorException(
                     "Namespace mapping already registered", prefix);
         } else if (Namespaces.isValidPrefix(prefix)) {
-            if (after.isArray()
-                    || after.getValue().getType() != PropertyType.STRING) {
+            if (after.isArray() || !STRING.equals(after.getType())) {
                 throw new NamespaceValidatorException(
                         "Invalid namespace mapping", prefix);
             } else if (prefix.toLowerCase(Locale.ENGLISH).startsWith("xml")) {
                 throw new NamespaceValidatorException(
                         "XML prefixes are reserved", prefix);
-            } else if (map.containsValue(after.getValue().getString())) {
+            } else if (map.containsValue(after.getValue(STRING))) {
                 throw modificationNotAllowed(prefix);
             }
         } else {

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/Namespaces.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/Namespaces.java?rev=1394245&r1=1394244&r2=1394245&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/Namespaces.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/Namespaces.java
Thu Oct  4 20:22:19 2012
@@ -20,13 +20,13 @@ import java.util.HashMap;
 import java.util.Map;
 
 import javax.jcr.NamespaceRegistry;
-import javax.jcr.PropertyType;
 
 import org.apache.jackrabbit.JcrConstants;
-import org.apache.jackrabbit.oak.api.CoreValue;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Tree;
 
+import static org.apache.jackrabbit.oak.api.Type.STRING;
+
 /**
  * Internal static utility class for managing the persisted namespace registry.
  */
@@ -59,9 +59,9 @@ class Namespaces implements NamespaceCon
                 for (PropertyState property : namespaces.getProperties()) {
                     String prefix = property.getName();
                     if (!property.isArray() && isValidPrefix(prefix)) {
-                        CoreValue value = property.getValue();
-                        if (value.getType() == PropertyType.STRING) {
-                            map.put(prefix, value.getString());
+                        String value = property.getValue(STRING);
+                        if (STRING.equals(property.getType())) {
+                            map.put(prefix, value);
                         }
                     }
                 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/ReadWriteNamespaceRegistry.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/ReadWriteNamespaceRegistry.java?rev=1394245&r1=1394244&r2=1394245&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/ReadWriteNamespaceRegistry.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/ReadWriteNamespaceRegistry.java
Thu Oct  4 20:22:19 2012
@@ -25,6 +25,8 @@ import org.apache.jackrabbit.oak.api.Pro
 import org.apache.jackrabbit.oak.api.Root;
 import org.apache.jackrabbit.oak.api.Tree;
 
+import static org.apache.jackrabbit.oak.api.Type.STRING;
+
 /**
  * Writable namespace registry. Mainly for use to implement the full JCR API.
  */
@@ -76,7 +78,7 @@ public abstract class ReadWriteNamespace
                     getOrCreate(root, JcrConstants.JCR_SYSTEM, REP_NAMESPACES);
             // remove existing mapping to given uri
             for (PropertyState p : namespaces.getProperties()) {
-                if (!p.isArray() && p.getValue().getString().equals(uri)) {
+                if (!p.isArray() && p.getValue(STRING).equals(uri)) {
                     namespaces.removeProperty(p.getName());
                 }
             }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/Query.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/Query.java?rev=1394245&r1=1394244&r2=1394245&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/Query.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/Query.java
Thu Oct  4 20:22:19 2012
@@ -418,12 +418,8 @@ public class Query {
     }
 
     public static int getType(PropertyState p, int ifUnknown) {
-        if (!p.isArray()) {
-            return p.getValue().getType();
-        }
-        Iterator<CoreValue> it = p.getValues().iterator();
-        if (it.hasNext()) {
-            return it.next().getType();
+        if (p.count() > 0) {
+            return p.getType().tag();
         }
         return ifUnknown;
     }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/FullTextSearchImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/FullTextSearchImpl.java?rev=1394245&r1=1394244&r2=1394245&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/FullTextSearchImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/FullTextSearchImpl.java
Thu Oct  4 20:22:19 2012
@@ -20,12 +20,16 @@ package org.apache.jackrabbit.oak.query.
 
 import java.text.ParseException;
 import java.util.ArrayList;
+
 import org.apache.jackrabbit.oak.api.CoreValue;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Tree;
 import org.apache.jackrabbit.oak.query.ast.ComparisonImpl.LikePattern;
 import org.apache.jackrabbit.oak.query.index.FilterImpl;
 
+import static org.apache.jackrabbit.oak.api.Type.STRING;
+import static org.apache.jackrabbit.oak.api.Type.STRINGS;
+
 /**
  * A fulltext "contains(...)" condition.
  */
@@ -102,11 +106,11 @@ public class FullTextSearchImpl extends 
 
     private static void appendString(StringBuilder buff, PropertyState p) {
         if (p.isArray()) {
-            for (CoreValue v : p.getValues()) {
-                buff.append(v.getString()).append(' ');
+            for (String v : p.getValue(STRINGS)) {
+                buff.append(v).append(' ');
             }
         } else {
-            buff.append(p.getValue().getString()).append(' ');
+            buff.append(p.getValue(STRING)).append(' ');
         }
     }
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/LowerCaseImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/LowerCaseImpl.java?rev=1394245&r1=1394244&r2=1394245&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/LowerCaseImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/LowerCaseImpl.java
Thu Oct  4 20:22:19 2012
@@ -20,9 +20,11 @@ package org.apache.jackrabbit.oak.query.
 
 import org.apache.jackrabbit.oak.api.CoreValue;
 import org.apache.jackrabbit.oak.api.PropertyState;
-import org.apache.jackrabbit.oak.plugins.memory.SinglePropertyState;
+import org.apache.jackrabbit.oak.plugins.memory.PropertyStates;
 import org.apache.jackrabbit.oak.query.index.FilterImpl;
 
+import static org.apache.jackrabbit.oak.api.Type.STRING;
+
 /**
  * The function "lower(..)".
  */
@@ -56,9 +58,8 @@ public class LowerCaseImpl extends Dynam
         }
         // TODO what is the expected result of LOWER(x) for an array property?
         // currently throws an exception
-        String value = p.getValue().getString();
-        CoreValue v = query.getValueFactory().createValue(value.toLowerCase());
-        return new SinglePropertyState(p.getName(), v);
+        String value = p.getValue(STRING);
+        return PropertyStates.stringProperty(p.getName(), value.toLowerCase());
     }
 
     @Override

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/PropertyValueImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/PropertyValueImpl.java?rev=1394245&r1=1394244&r2=1394245&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/PropertyValueImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/PropertyValueImpl.java
Thu Oct  4 20:22:19 2012
@@ -19,9 +19,10 @@
 package org.apache.jackrabbit.oak.query.ast;
 
 import java.util.ArrayList;
-import java.util.List;
 import java.util.Locale;
+
 import javax.jcr.PropertyType;
+
 import org.apache.jackrabbit.oak.api.CoreValue;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Tree;
@@ -134,16 +135,7 @@ public class PropertyValueImpl extends D
         if (propertyType == PropertyType.UNDEFINED) {
             return true;
         }
-        if (state.isArray()) {
-            List<CoreValue> values = state.getValues();
-            if (values.isEmpty()) {
-                // TODO how to retrieve the property type of an empty multi-value property?
-                // currently it matches all property types
-                return true;
-            }
-            return values.get(0).getType() == propertyType;
-        }
-        return state.getValue().getType() == propertyType;
+        return state.getType().tag() == propertyType;
     }
 
     public void bindSelector(SourceImpl source) {

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/UpperCaseImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/UpperCaseImpl.java?rev=1394245&r1=1394244&r2=1394245&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/UpperCaseImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/UpperCaseImpl.java
Thu Oct  4 20:22:19 2012
@@ -20,9 +20,11 @@ package org.apache.jackrabbit.oak.query.
 
 import org.apache.jackrabbit.oak.api.CoreValue;
 import org.apache.jackrabbit.oak.api.PropertyState;
-import org.apache.jackrabbit.oak.plugins.memory.SinglePropertyState;
+import org.apache.jackrabbit.oak.plugins.memory.PropertyStates;
 import org.apache.jackrabbit.oak.query.index.FilterImpl;
 
+import static org.apache.jackrabbit.oak.api.Type.STRING;
+
 /**
  * The function "upper(..)".
  */
@@ -56,9 +58,8 @@ public class UpperCaseImpl extends Dynam
         }
         // TODO what is the expected result of UPPER(x) for an array property?
         // currently throws an exception
-        String value = p.getValue().getString();
-        CoreValue v = query.getValueFactory().createValue(value.toUpperCase());
-        return new SinglePropertyState(p.getName(), v);
+        String value = p.getValue(STRING);
+        return PropertyStates.stringProperty(p.getName(), value.toUpperCase());
     }
 
     @Override

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeValidator.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeValidator.java?rev=1394245&r1=1394244&r2=1394245&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeValidator.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeValidator.java
Thu Oct  4 20:22:19 2012
@@ -19,6 +19,7 @@ package org.apache.jackrabbit.oak.securi
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
+
 import javax.jcr.RepositoryException;
 
 import org.apache.jackrabbit.JcrConstants;
@@ -32,6 +33,8 @@ import org.apache.jackrabbit.oak.spi.sec
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.apache.jackrabbit.util.Text;
 
+import static org.apache.jackrabbit.oak.api.Type.STRING;
+
 /**
  * PrivilegeValidator... TODO
  */
@@ -90,7 +93,7 @@ class PrivilegeValidator implements Priv
         // primary node type name must be rep:privilege
         Tree tree = new ReadOnlyTree(null, name, after);
         PropertyState primaryType = tree.getProperty(JcrConstants.JCR_PRIMARYTYPE);
-        if (primaryType == null || !NT_REP_PRIVILEGE.equals(primaryType.getValue().getString()))
{
+        if (primaryType == null || !NT_REP_PRIVILEGE.equals(primaryType.getValue(STRING)))
{
             throw new CommitFailedException("Privilege definition must have primary node
type set to rep:privilege");
         }
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/AuthorizableImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/AuthorizableImpl.java?rev=1394245&r1=1394244&r2=1394245&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/AuthorizableImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/AuthorizableImpl.java
Thu Oct  4 20:22:19 2012
@@ -20,6 +20,7 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
+
 import javax.annotation.Nonnull;
 import javax.jcr.Node;
 import javax.jcr.Property;
@@ -42,6 +43,8 @@ import org.apache.jackrabbit.util.Text;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import static org.apache.jackrabbit.oak.api.Type.STRING;
+
 /**
  * AuthorizableImpl...
  */
@@ -325,7 +328,7 @@ abstract class AuthorizableImpl implemen
     String getPrincipalName() throws RepositoryException {
         Tree tree = getTree();
         if (tree.hasProperty(REP_PRINCIPAL_NAME)) {
-            return tree.getProperty(REP_PRINCIPAL_NAME).getValue().getString();
+            return tree.getProperty(REP_PRINCIPAL_NAME).getValue(STRING);
         } else {
             String msg = "Authorizable without principal name " + getID();
             log.warn(msg);

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/IndexUtils.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/IndexUtils.java?rev=1394245&r1=1394244&r2=1394245&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/IndexUtils.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/IndexUtils.java
Thu Oct  4 20:22:19 2012
@@ -31,6 +31,7 @@ import org.apache.jackrabbit.oak.spi.sta
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 
 import static org.apache.jackrabbit.oak.api.Type.BOOLEAN;
+import static org.apache.jackrabbit.oak.api.Type.STRING;
 import static org.apache.jackrabbit.oak.spi.query.IndexDefinition.INDEX_DATA_CHILD_NAME;
 import static org.apache.jackrabbit.oak.spi.query.IndexDefinition.TYPE_PROPERTY_NAME;
 import static org.apache.jackrabbit.oak.spi.query.IndexDefinition.UNIQUE_PROPERTY_NAME;
@@ -54,7 +55,7 @@ public class IndexUtils {
         PropertyState typeProp = ns.getProperty(TYPE_PROPERTY_NAME);
         String type = TYPE_UNKNOWN;
         if (typeProp != null && !typeProp.isArray()) {
-            type = typeProp.getValue().getString();
+            type = typeProp.getValue(STRING);
         }
 
         boolean unique = false;
@@ -66,7 +67,7 @@ public class IndexUtils {
         Map<String, String> props = new HashMap<String, String>();
         for (PropertyState ps : ns.getProperties()) {
             if (ps != null && !ps.isArray()) {
-                String v = ps.getValue().getString();
+                String v = ps.getValue(STRING);
                 props.put(ps.getName(), v);
             }
         }
@@ -74,9 +75,8 @@ public class IndexUtils {
         if (ns.hasChildNode(INDEX_DATA_CHILD_NAME)) {
             PropertyState ps = ns.getChildNode(INDEX_DATA_CHILD_NAME)
                     .getProperty(LuceneIndexConstants.INDEX_UPDATE);
-            if (ps != null && ps.getValue() != null) {
-                props.put(LuceneIndexConstants.INDEX_UPDATE, ps.getValue()
-                        .getString());
+            if (ps != null) {
+                props.put(LuceneIndexConstants.INDEX_UPDATE, ps.getValue(STRING));
             }
         }
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/principal/TreeBasedPrincipal.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/principal/TreeBasedPrincipal.java?rev=1394245&r1=1394244&r2=1394245&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/principal/TreeBasedPrincipal.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/principal/TreeBasedPrincipal.java
Thu Oct  4 20:22:19 2012
@@ -27,6 +27,8 @@ import org.apache.jackrabbit.oak.spi.sec
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import static org.apache.jackrabbit.oak.api.Type.STRING;
+
 /**
  * TreeBasedPrincipal...
  */
@@ -46,7 +48,7 @@ public class TreeBasedPrincipal implemen
         if (prop == null) {
             throw new IllegalArgumentException("Tree doesn't have rep:principalName property");
         }
-        this.principalName = prop.getValue().getString();
+        this.principalName = prop.getValue(STRING);
         this.tree = tree;
         this.pathMapper = pathMapper;
     }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/NodeUtil.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/NodeUtil.java?rev=1394245&r1=1394244&r2=1394245&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/NodeUtil.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/NodeUtil.java
Thu Oct  4 20:22:19 2012
@@ -27,6 +27,7 @@ import javax.jcr.RepositoryException;
 import javax.jcr.Value;
 import javax.jcr.ValueFactory;
 
+import com.google.common.collect.Iterables;
 import com.google.common.collect.Lists;
 import org.apache.jackrabbit.JcrConstants;
 import org.apache.jackrabbit.oak.api.ContentSession;
@@ -34,6 +35,7 @@ import org.apache.jackrabbit.oak.api.Cor
 import org.apache.jackrabbit.oak.api.CoreValueFactory;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Tree;
+import org.apache.jackrabbit.oak.api.Type;
 import org.apache.jackrabbit.oak.namepath.NameMapper;
 import org.apache.jackrabbit.oak.namepath.NamePathMapper;
 import org.apache.jackrabbit.oak.plugins.memory.MemoryValueFactory;
@@ -48,6 +50,7 @@ import static org.apache.jackrabbit.oak.
 import static org.apache.jackrabbit.oak.api.Type.NAME;
 import static org.apache.jackrabbit.oak.api.Type.NAMES;
 import static org.apache.jackrabbit.oak.api.Type.STRINGS;
+import static org.apache.jackrabbit.oak.api.Type.STRING;
 
 /**
  * Utility class for accessing and writing typed content of a tree.
@@ -138,7 +141,7 @@ public class NodeUtil {
     public String getString(String name, String defaultValue) {
         PropertyState property = tree.getProperty(name);
         if (property != null && !property.isArray()) {
-            return property.getValue().getString();
+            return property.getValue(Type.STRING);
         } else {
             return defaultValue;
         }
@@ -154,12 +157,7 @@ public class NodeUtil {
             return null;
         }
 
-        List<CoreValue> values = property.getValues();
-        String[] strings = new String[values.size()];
-        for (int i = 0; i < strings.length; i++) {
-            strings[i] = values.get(i).getString();
-        }
-        return strings;
+        return Iterables.toArray(property.getValue(STRINGS), String.class);
     }
 
     public void setStrings(String name, String... values) {
@@ -173,7 +171,7 @@ public class NodeUtil {
     public String getName(String name, String defaultValue) {
         PropertyState property = tree.getProperty(name);
         if (property != null && !property.isArray()) {
-            return mapper.getJcrName(property.getValue().getString());
+            return mapper.getJcrName(property.getValue(STRING));
         } else {
             return defaultValue;
         }
@@ -241,20 +239,17 @@ public class NodeUtil {
     }
 
     public void setValues(String name, String[] values, int type) {
-        List<CoreValue> cvs = Lists.newArrayList();
-        for (String value : values) {
-            cvs.add(factory.createValue(value, type));
-        }
-        tree.setProperty(new MultiPropertyState(name, cvs));
+        tree.setProperty(name, Arrays.asList(values), STRINGS);
     }
 
     public Value[] getValues(String name, ValueFactory vf) {
         PropertyState property = tree.getProperty(name);
         if (property != null) {
+            int type = property.getType().tag();
             List<Value> values = Lists.newArrayList();
-            for (CoreValue value : property.getValues()) {
+            for (String value : property.getValue(STRINGS)) {
                 try {
-                    values.add(vf.createValue(value.getString(), value.getType()));
+                    values.add(vf.createValue(value, type));
                 } catch (RepositoryException e) {
                     log.warn("Unable to convert a default value", e);
                 }

Modified: jackrabbit/oak/trunk/oak-http/src/main/java/org/apache/jackrabbit/oak/http/TextRepresentation.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-http/src/main/java/org/apache/jackrabbit/oak/http/TextRepresentation.java?rev=1394245&r1=1394244&r2=1394245&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-http/src/main/java/org/apache/jackrabbit/oak/http/TextRepresentation.java
(original)
+++ jackrabbit/oak/trunk/oak-http/src/main/java/org/apache/jackrabbit/oak/http/TextRepresentation.java
Thu Oct  4 20:22:19 2012
@@ -21,11 +21,14 @@ import java.io.PrintWriter;
 
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.jackrabbit.oak.api.CoreValue;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Tree;
+import org.apache.jackrabbit.oak.api.Type;
 import org.apache.tika.mime.MediaType;
 
+import static org.apache.jackrabbit.oak.api.Type.STRING;
+import static org.apache.jackrabbit.oak.api.Type.STRINGS;
+
 class TextRepresentation implements Representation {
 
     @Override
@@ -41,12 +44,12 @@ class TextRepresentation implements Repr
             writer.print(property.getName());
             writer.print(": ");
             if (property.isArray()) {
-                for (CoreValue value : property.getValues()) {
-                    writer.print(value.getString());
+                for (String value : property.getValue(STRINGS)) {
+                    writer.print(value);
                     writer.print(", ");
                 }
             } else {
-                writer.print(property.getValue().getString());
+                writer.print(property.getValue(STRING));
             }
             writer.print('\n');
         }
@@ -64,12 +67,12 @@ class TextRepresentation implements Repr
             throws IOException {
         PrintWriter writer = startResponse(response);
         if (property.isArray()) {
-            for (CoreValue value : property.getValues()) {
-                writer.print(value.getString());
+            for (String value : property.getValue(Type.STRINGS)) {
+                writer.print(value);
                 writer.print('\n');
             }
         } else {
-            writer.print(property.getValue().getString());
+            writer.print(property.getValue(STRING));
         }
     }
 

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java?rev=1394245&r1=1394244&r2=1394245&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java
Thu Oct  4 20:22:19 2012
@@ -42,6 +42,8 @@ import org.apache.jackrabbit.oak.api.Tre
 import org.apache.jackrabbit.oak.plugins.memory.MultiPropertyState;
 import org.apache.jackrabbit.oak.plugins.memory.SinglePropertyState;
 
+import static org.apache.jackrabbit.oak.api.Type.STRINGS;
+
 /**
  * {@code NodeDelegate} serve as internal representations of {@code Node}s.
  * Most methods of this class throw an {@code InvalidItemStateException}
@@ -172,8 +174,7 @@ public class NodeDelegate extends ItemDe
                 final Map<String, NodeDelegate> ordered =
                         new LinkedHashMap<String, NodeDelegate>();
 
-                for (CoreValue value : order.getValues()) {
-                    String name = value.getString();
+                for (String name : order.getValue(STRINGS)) {
                     Tree child = tree.getChild(name);
                     if (child != null && !name.startsWith(":")) {
                         ordered.put(name, new NodeDelegate(sessionDelegate, child));
@@ -219,8 +220,7 @@ public class NodeDelegate extends ItemDe
 
             PropertyState property = tree.getProperty(PropertyState.OAK_CHILD_ORDER);
             if (property != null) {
-                for (CoreValue value : property.getValues()) {
-                    String name = value.getString();
+                for (String name : property.getValue(STRINGS)) {
                     if (!name.equals(source) && !added.contains(property)
                             && !name.startsWith(":")) {
                         if (name.equals(target)) {



Mime
View raw message