jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r772659 [1/3] - in /jackrabbit/trunk: jackrabbit-core/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetyp...
Date Thu, 07 May 2009 14:29:48 GMT
Author: angela
Date: Thu May  7 14:29:34 2009
New Revision: 772659

URL: http://svn.apache.org/viewvc?rev=772659&view=rev
Log:
JCR-2028: JSR 283 JCR Path

Added:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/InternalValueFactory.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/ValueFactoryImpl.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/value/
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/value/InternalValueFactoryTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/value/InternalValueTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/value/TestAll.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NameTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/PathTest.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/conversion/IdentifierResolver.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/AbstractQValue.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/AbstractQValueFactory.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/conversion/DummyIdentifierResolver.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/value/ValueFormatTest.java
    jackrabbit/trunk/jackrabbit-spi/src/test/java/org/apache/jackrabbit/spi/QValueTest.java
Modified:
    jackrabbit/trunk/jackrabbit-core/pom.xml
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/CachingHierarchyManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeDefStore.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeDefinitionImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/PropertyDefinitionImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/compact/CompactNodeTypeDefReader.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventState.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventStateCollection.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/BundleBinding.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/AggregateRuleImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NodeIndexer.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryResultImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/RowIteratorImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/Util.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBFileValue.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBInMemory.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBInTempFile.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/InternalValue.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/BufferedStringValue.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/DocViewImportHandler.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/ImportHandler.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/StringValue.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/SysViewImportHandler.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/TargetImportHandler.java
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/util/ISO8601.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/TestAll.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEventListener.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/conversion/CachingPathResolver.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/conversion/DefaultNamePathResolver.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/conversion/ParsingPathResolver.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/conversion/PathParser.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/conversion/PathResolver.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/PathFactoryLogger.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/name/PathBuilder.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/name/PathFactoryImpl.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/QValueFactoryImpl.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/QValueValue.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/ValueFactoryQImpl.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/ValueFormat.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/batch/ConsolidatedBatchTest.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/conversion/ParsingPathResolverTest.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/conversion/PathParserTest.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/name/PathFactoryTest.java
    jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/Path.java
    jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/PathFactory.java
    jackrabbit/trunk/jackrabbit-spi/src/test/java/org/apache/jackrabbit/spi/QValueFactoryTest.java
    jackrabbit/trunk/jackrabbit-spi/src/test/java/org/apache/jackrabbit/spi/TestAll.java
    jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
    jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2davex/QValueFactoryImpl.java
    jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java

Modified: jackrabbit/trunk/jackrabbit-core/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/pom.xml?rev=772659&r1=772658&r2=772659&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/pom.xml (original)
+++ jackrabbit/trunk/jackrabbit-core/pom.xml Thu May  7 14:29:34 2009
@@ -177,6 +177,14 @@
       <groupId>org.apache.jackrabbit</groupId>
       <artifactId>jackrabbit-spi</artifactId>
       <version>2.0-SNAPSHOT</version>
+      <classifier></classifier>
+    </dependency>
+      <dependency>
+      <groupId>org.apache.jackrabbit</groupId>
+      <artifactId>jackrabbit-spi</artifactId>
+      <version>2.0-SNAPSHOT</version>
+      <classifier>tests</classifier>
+      <scope>test</scope>
     </dependency>
     <dependency>
       <groupId>org.apache.jackrabbit</groupId>

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/CachingHierarchyManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/CachingHierarchyManager.java?rev=772659&r1=772658&r2=772659&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/CachingHierarchyManager.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/CachingHierarchyManager.java Thu May  7 14:29:34 2009
@@ -657,9 +657,11 @@
      * @param id    child node id
      *
      * @throws PathNotFoundException if the path was not found
+     * @throws RepositoryException If the path's direct ancestor cannot be determined.
+     * @throws ItemStateException If the id cannot be resolved to a NodeState.
      */
     private void nodeAdded(NodeState state, Path path, NodeId id)
-            throws PathNotFoundException, ItemStateException {
+            throws RepositoryException, ItemStateException {
 
         // assert: synchronized (cacheMonitor)
         PathMap.Element element = null;
@@ -699,10 +701,12 @@
      * @param path  node path
      * @param id    node id
      *
-     * @throws PathNotFoundException if the path was not found
+     * @throws PathNotFoundException if the path was not found.
+     * @throws RepositoryException If the path's direct ancestor cannot be determined.
+     * @throws ItemStateException If the id cannot be resolved to a NodeState.
      */
     private void nodeRemoved(NodeState state, Path path, NodeId id)
-            throws PathNotFoundException, ItemStateException {
+            throws RepositoryException, ItemStateException {
 
         // assert: synchronized (cacheMonitor)
         PathMap.Element parent = pathCache.map(path.getAncestor(1), true);

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java?rev=772659&r1=772658&r2=772659&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java Thu May  7 14:29:34 2009
@@ -48,6 +48,7 @@
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.Path;
 import org.apache.jackrabbit.spi.commons.name.NameConstants;
+import org.apache.jackrabbit.spi.commons.value.ValueFormat;
 import org.apache.jackrabbit.value.ValueHelper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -248,10 +249,10 @@
             throw new ValueFormatException(msg + this);
         }
 
-        // check protected flag and for retention/hold      
+        // check protected flag and for retention/hold
         int options = ItemValidator.CHECK_CONSTRAINTS;
         session.getValidator().checkModify(this, options, Permission.NONE);
-        
+
         // make sure the parent is checked-out and neither locked nor under retention
         options = ItemValidator.CHECK_VERSIONING | ItemValidator.CHECK_LOCK |
                 ItemValidator.CHECK_HOLD | ItemValidator.CHECK_RETENTION;
@@ -345,7 +346,7 @@
         if (reqType != PropertyType.NAME) {
             // type conversion required
             Value targetValue = ValueHelper.convert(
-                    InternalValue.create(name).toJCRValue(session),
+                    ValueFormat.getJCRValue(InternalValue.create(name), session, session.getValueFactory()),
                     reqType, session.getValueFactory());
             internalValue = InternalValue.create(targetValue, session, rep.getDataStore());
         } else {
@@ -396,7 +397,7 @@
                     if (reqType != PropertyType.NAME) {
                         // type conversion required
                         Value targetValue = ValueHelper.convert(
-                                InternalValue.create(name).toJCRValue(session),
+                                ValueFormat.getJCRValue(InternalValue.create(name), session, session.getValueFactory()),
                                 reqType, session.getValueFactory());
                         internalValue = InternalValue.create(targetValue, session, rep.getDataStore());
                     } else {
@@ -467,14 +468,14 @@
         InternalValue[] internals = internalGetValues();
         Value[] values = new Value[internals.length];
         for (int i = 0; i < internals.length; i++) {
-            values[i] = internals[i].toJCRValue(session);
+            values[i] = ValueFormat.getJCRValue(internals[i], session, session.getValueFactory());
         }
         return values;
     }
 
     public Value getValue() throws RepositoryException {
         try {
-            return internalGetValue().toJCRValue(session);
+            return ValueFormat.getJCRValue(internalGetValue(), session, session.getValueFactory());
         } catch (RuntimeException e) {
             String msg = "Internal error while retrieving value of " + this;
             log.error(msg, e);

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java?rev=772659&r1=772658&r2=772659&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java Thu May  7 14:29:34 2009
@@ -49,6 +49,7 @@
 import org.apache.jackrabbit.core.xml.SessionImporter;
 import org.apache.jackrabbit.core.retention.RetentionManagerImpl;
 import org.apache.jackrabbit.core.retention.RetentionRegistry;
+import org.apache.jackrabbit.core.value.ValueFactoryImpl;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.Path;
 import org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver;
@@ -56,9 +57,9 @@
 import org.apache.jackrabbit.spi.commons.conversion.MalformedPathException;
 import org.apache.jackrabbit.spi.commons.conversion.NameException;
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
+import org.apache.jackrabbit.spi.commons.conversion.IdentifierResolver;
 import org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver;
 import org.apache.jackrabbit.uuid.UUID;
-import org.apache.jackrabbit.value.ValueFactoryImpl;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.xml.sax.ContentHandler;
@@ -107,7 +108,7 @@
  * A <code>SessionImpl</code> ...
  */
 public class SessionImpl extends AbstractSession
-        implements javax.jcr.Session, JackrabbitSession, NamespaceResolver, NamePathResolver, Dumpable {
+        implements javax.jcr.Session, JackrabbitSession, NamespaceResolver, NamePathResolver, IdentifierResolver, Dumpable {
 
     private static Logger log = LoggerFactory.getLogger(SessionImpl.class);
 
@@ -276,7 +277,7 @@
 
         userId = retrieveUserId(subject);
 
-        namePathResolver = new DefaultNamePathResolver(this, true);
+        namePathResolver = new DefaultNamePathResolver(this, this, true);
         ntMgr = new NodeTypeManagerImpl(rep.getNodeTypeRegistry(), this, rep.getDataStore());
         String wspName = wspConfig.getName();
         wsp = createWorkspaceInstance(wspConfig,
@@ -751,6 +752,33 @@
         return namePathResolver.getQPath(path);
     }
 
+    public Path getQPath(String path, boolean normalizeIdentifier) throws MalformedPathException, IllegalNameException, NamespaceException {
+        return namePathResolver.getQPath(path, normalizeIdentifier);
+    }
+
+    //---------------------------------------------------< IdentifierResolver >
+    /**
+     * @see IdentifierResolver#getPath(String)
+     */
+    public Path getPath(String identifier) throws MalformedPathException {
+        try {
+            return getHierarchyManager().getPath(NodeId.valueOf(identifier));
+        } catch (RepositoryException e) {
+            throw new MalformedPathException("Identifier '" + identifier + "' cannot be resolved.");
+        }
+    }
+
+    /**
+     * @see IdentifierResolver#checkFormat(String)
+     */
+    public void checkFormat(String identifier) throws MalformedPathException {
+        try {
+            NodeId.valueOf(identifier);
+        } catch (IllegalArgumentException e) {
+            throw new MalformedPathException("Invalid identifier: " + identifier);
+        }
+    }
+
     //----------------------------------------------------< JackrabbitSession >
     /**
      * @see JackrabbitSession#getPrincipalManager()
@@ -1217,7 +1245,7 @@
     public ValueFactory getValueFactory()
             throws UnsupportedRepositoryOperationException, RepositoryException {
         if (valueFactory == null) {
-            valueFactory = ValueFactoryImpl.getInstance();
+            valueFactory = new ValueFactoryImpl(this);
         }
         return valueFactory;
     }
@@ -1568,5 +1596,4 @@
             logout();
         }
     }
-
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java?rev=772659&r1=772658&r2=772659&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java Thu May  7 14:29:34 2009
@@ -53,7 +53,6 @@
 
 import javax.jcr.ItemNotFoundException;
 import javax.jcr.Node;
-import javax.jcr.PathNotFoundException;
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
@@ -1069,7 +1068,7 @@
             if (parent != null) {
                 refresh(parent);
             }
-        } catch (PathNotFoundException e) {
+        } catch (RepositoryException e) {
             log.warn("Unable to determine path of added node's parent.", e);
         } finally {
             release();
@@ -1091,7 +1090,7 @@
             if (parent != null) {
                 refresh(parent);
             }
-        } catch (PathNotFoundException e) {
+        } catch (RepositoryException e) {
             log.warn("Unable to determine path of moved node's parent.", e);
         } finally {
             release();
@@ -1112,7 +1111,7 @@
             if (parent != null) {
                 refresh(parent);
             }
-        } catch (PathNotFoundException e) {
+        } catch (RepositoryException e) {
             log.warn("Unable to determine path of removed node's parent.", e);
         } finally {
             release();

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeDefStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeDefStore.java?rev=772659&r1=772658&r2=772659&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeDefStore.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeDefStore.java Thu May  7 14:29:34 2009
@@ -21,7 +21,6 @@
 import org.apache.jackrabbit.core.nodetype.compact.CompactNodeTypeDefReader;
 import org.apache.jackrabbit.core.nodetype.compact.ParseException;
 import org.apache.jackrabbit.spi.Name;
-import org.apache.jackrabbit.spi.commons.name.NameConstants;
 
 import javax.jcr.NamespaceRegistry;
 import javax.jcr.RepositoryException;

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeDefinitionImpl.java?rev=772659&r1=772658&r2=772659&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeDefinitionImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeDefinitionImpl.java Thu May  7 14:29:34 2009
@@ -23,6 +23,7 @@
 import org.slf4j.LoggerFactory;
 
 import javax.jcr.NamespaceException;
+import javax.jcr.ValueFactory;
 import javax.jcr.nodetype.NodeDefinition;
 import javax.jcr.nodetype.PropertyDefinition;
 
@@ -39,10 +40,12 @@
     private final NodeTypeDef ntd;
     // resolver used to translate qualified names to JCR names
     private final NamePathResolver resolver;
+    private final ValueFactory valueFactory;
 
-    public NodeTypeDefinitionImpl(NodeTypeDef ntd, NamePathResolver resolver) {
+    public NodeTypeDefinitionImpl(NodeTypeDef ntd, NamePathResolver resolver, ValueFactory valueFactory) {
         this.ntd = ntd;
         this.resolver = resolver;
+        this.valueFactory = valueFactory;
     }
 
     //---------------------------------------------------< NodeTypeDefinition >
@@ -162,7 +165,7 @@
         PropDef[] pda = ntd.getPropertyDefs();
         PropertyDefinition[] propDefs = new PropertyDefinition[pda.length];
         for (int i = 0; i < pda.length; i++) {
-            propDefs[i] = new PropertyDefinitionImpl(pda[i], null, resolver);
+            propDefs[i] = new PropertyDefinitionImpl(pda[i], null, resolver, valueFactory);
         }
         return propDefs;
     }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.java?rev=772659&r1=772658&r2=772659&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.java Thu May  7 14:29:34 2009
@@ -175,7 +175,7 @@
             if (pdi == null) {
                 PropDef pd = ntReg.getPropDef(id);
                 if (pd != null) {
-                    pdi = new PropertyDefinitionImpl(pd, this, session);
+                    pdi = new PropertyDefinitionImpl(pd, this, session, valueFactory);
                     pdCache.put(id, pdi);
                 }
             }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/PropertyDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/PropertyDefinitionImpl.java?rev=772659&r1=772658&r2=772659&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/PropertyDefinitionImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/PropertyDefinitionImpl.java Thu May  7 14:29:34 2009
@@ -18,11 +18,13 @@
 
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
+import javax.jcr.ValueFactory;
 import javax.jcr.nodetype.PropertyDefinition;
 
 import org.apache.jackrabbit.core.value.InternalValue;
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
 import org.apache.jackrabbit.spi.commons.query.qom.Operator;
+import org.apache.jackrabbit.spi.commons.value.ValueFormat;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -40,16 +42,20 @@
      */
     private static Logger log = LoggerFactory.getLogger(PropertyDefinitionImpl.class);
 
+    private final ValueFactory valueFactory;
+
     /**
      * Package private constructor
      *
      * @param propDef    property definition
      * @param ntMgr      node type manager
      * @param resolver   name resolver
+     * @param valueFactory
      */
     PropertyDefinitionImpl(PropDef propDef, NodeTypeManagerImpl ntMgr,
-                           NamePathResolver resolver) {
+                           NamePathResolver resolver, ValueFactory valueFactory) {
         super(propDef, ntMgr, resolver);
+        this.valueFactory = valueFactory;
     }
 
     /**
@@ -73,7 +79,7 @@
         Value[] values = new Value[defVals.length];
         for (int i = 0; i < defVals.length; i++) {
             try {
-                values[i] = defVals[i].toJCRValue(resolver);
+                values[i] = ValueFormat.getJCRValue(defVals[i], resolver, valueFactory);
             } catch (RepositoryException re) {
                 // should never get here
                 String propName = (getName() == null) ? "[null]" : getName();

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/compact/CompactNodeTypeDefReader.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/compact/CompactNodeTypeDefReader.java?rev=772659&r1=772658&r2=772659&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/compact/CompactNodeTypeDefReader.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/compact/CompactNodeTypeDefReader.java Thu May  7 14:29:34 2009
@@ -42,6 +42,7 @@
 import javax.jcr.RepositoryException;
 import javax.jcr.ValueFormatException;
 import javax.jcr.Value;
+import javax.jcr.ValueFactory;
 import javax.jcr.version.OnParentVersionAction;
 import java.io.Reader;
 import java.util.ArrayList;
@@ -193,12 +194,13 @@
      * Returns the list of parsed node type definitions.
      *
      * @param resolver name resolver
+     * @param valueFactory the value factory used to create the property definitions.
      * @return a List of NodeTypeDefinitions objects
      */
-    public List getNodeTypeDefinitions(NamePathResolver resolver) {
+    public List getNodeTypeDefinitions(NamePathResolver resolver, ValueFactory valueFactory) {
         List l = new ArrayList(nodeTypeDefs.size());
         for (Iterator iter = nodeTypeDefs.iterator(); iter.hasNext();) {
-            l.add(new NodeTypeDefinitionImpl((NodeTypeDef) iter.next(), resolver));
+            l.add(new NodeTypeDefinitionImpl((NodeTypeDef) iter.next(), resolver, valueFactory));
         }
         return l;
     }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventImpl.java?rev=772659&r1=772658&r2=772659&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventImpl.java Thu May  7 14:29:34 2009
@@ -28,6 +28,7 @@
 import org.apache.jackrabbit.spi.commons.conversion.MalformedPathException;
 import org.apache.jackrabbit.spi.Path;
 import org.apache.jackrabbit.spi.commons.name.PathFactoryImpl;
+import org.apache.jackrabbit.spi.commons.value.ValueFormat;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -147,7 +148,7 @@
             InternalValue value = (InternalValue) entry.getValue();
             String strValue = null;
             if (value != null) {
-                strValue = value.toJCRValue(session).getString();
+                strValue = ValueFormat.getJCRValue(value, session, session.getValueFactory()).getString();
             }
             info.put(entry.getKey(), strValue);
         }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventState.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventState.java?rev=772659&r1=772658&r2=772659&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventState.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventState.java Thu May  7 14:29:34 2009
@@ -31,7 +31,7 @@
 import org.slf4j.Logger;
 
 import javax.jcr.Session;
-import javax.jcr.PathNotFoundException;
+import javax.jcr.RepositoryException;
 import javax.jcr.nodetype.NoSuchNodeTypeException;
 import java.util.Set;
 import java.util.HashSet;
@@ -374,7 +374,7 @@
             info.put(DEST_ABS_PATH, InternalValue.create(destPath));
             es.setInfo(info);
             return es;
-        } catch (PathNotFoundException e) {
+        } catch (RepositoryException e) {
             // should never happen actually
             String msg = "Unable to resolve parent for path: " + destPath;
             log.error(msg);

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventStateCollection.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventStateCollection.java?rev=772659&r1=772658&r2=772659&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventStateCollection.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventStateCollection.java Thu May  7 14:29:34 2009
@@ -36,7 +36,6 @@
 import org.slf4j.LoggerFactory;
 
 import javax.jcr.NamespaceException;
-import javax.jcr.PathNotFoundException;
 import javax.jcr.RepositoryException;
 import javax.jcr.observation.ObservationManager;
 
@@ -628,7 +627,7 @@
     private Path getParent(Path p) throws ItemStateException {
         try {
             return p.getAncestor(1);
-        } catch (PathNotFoundException e) {
+        } catch (RepositoryException e) {
             // should never happen actually
             String msg = "Unable to resolve parent for path: " + p;
             log.error(msg);

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/BundleBinding.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/BundleBinding.java?rev=772659&r1=772658&r2=772659&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/BundleBinding.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/BundleBinding.java Thu May  7 14:29:34 2009
@@ -673,13 +673,28 @@
                     }
                     break;
                 case PropertyType.DOUBLE:
-                    out.writeDouble(val.getDouble());
+                    try {
+                        out.writeDouble(val.getDouble());
+                    } catch (RepositoryException e) {
+                        // should never occur
+                        throw new IOException("Unexpected error while writing DOUBLE value.");
+                    }
                     break;
                 case PropertyType.LONG:
-                    out.writeLong(val.getLong());
+                    try {
+                        out.writeLong(val.getLong());
+                    } catch (RepositoryException e) {
+                        // should never occur
+                        throw new IOException("Unexpected error while writing LONG value.");
+                    }
                     break;
                 case PropertyType.BOOLEAN:
-                    out.writeBoolean(val.getBoolean());
+                    try {
+                        out.writeBoolean(val.getBoolean());
+                    } catch (RepositoryException e) {
+                        // should never occur
+                        throw new IOException("Unexpected error while writing BOOLEAN value.");
+                    }
                     break;
                 case PropertyType.NAME:
                     writeQName(out, val.getQName());
@@ -701,7 +716,6 @@
      * Write a small binary value and return the data.
      *
      * @param out the output stream to write
-     * @param size the size
      * @param blobVal the binary value
      * @param state the property state (for error messages)
      * @param i the index (for error messages)

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/AggregateRuleImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/AggregateRuleImpl.java?rev=772659&r1=772658&r2=772659&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/AggregateRuleImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/AggregateRuleImpl.java Thu May  7 14:29:34 2009
@@ -38,7 +38,6 @@
 
 import javax.jcr.RepositoryException;
 import javax.jcr.NamespaceException;
-import javax.jcr.PathNotFoundException;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -96,12 +95,13 @@
      *                                characters.
      * @throws NamespaceException if a node type contains an unknown
      *                                prefix.
+     * @throws RepositoryException If another error occurs.
      */
     AggregateRuleImpl(Node config,
                       NameResolver resolver,
                       ItemStateManager ism,
                       HierarchyManager hmgr) throws MalformedPathException,
-            IllegalNameException, NamespaceException, PathNotFoundException {
+            IllegalNameException, NamespaceException, RepositoryException {
         this.resolver = resolver;
         this.nodeTypeName = getNodeTypeName(config);
         this.nodeIncludes = getNodeIncludes(config);
@@ -252,10 +252,12 @@
      *                                characters.
      * @throws NamespaceException if the node type contains an unknown
      *                                prefix.
+     * @throws RepositoryException If the PropertyInclude cannot be builded
+     * due to unknown ancestor relationship.
      */
     private PropertyInclude[] getPropertyIncludes(Node config) throws
             MalformedPathException, IllegalNameException, NamespaceException,
-            PathNotFoundException {
+            RepositoryException {
         List includes = new ArrayList();
         NodeList childNodes = config.getChildNodes();
         for (int i = 0; i < childNodes.getLength(); i++) {
@@ -442,7 +444,7 @@
         private final Name propertyName;
 
         PropertyInclude(Path pattern)
-                throws PathNotFoundException {
+                throws RepositoryException {
             super(pattern.getAncestor(1), null);
             this.propertyName = pattern.getNameElement().getName();
         }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NodeIndexer.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NodeIndexer.java?rev=772659&r1=772658&r2=772659&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NodeIndexer.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NodeIndexer.java Thu May  7 14:29:34 2009
@@ -286,7 +286,7 @@
      * @param value the internal jackrabbit value.
      * @param name  the name of the property.
      */
-    private void addValue(Document doc, InternalValue value, Name name) {
+    private void addValue(Document doc, InternalValue value, Name name) throws RepositoryException {
         String fieldName = name.getLocalName();
         try {
             fieldName = resolver.getJCRName(name);

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryResultImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryResultImpl.java?rev=772659&r1=772658&r2=772659&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryResultImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryResultImpl.java Thu May  7 14:29:34 2009
@@ -225,7 +225,7 @@
         }
         return new RowIteratorImpl(getScoreNodes(), selectProps,
                 selectorNames, itemMgr,
-                index.getContext().getHierarchyManager(), session,
+                index.getContext().getHierarchyManager(), session, session.getValueFactory(),
                 excerptProvider, spellSuggestion);
     }
 

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/RowIteratorImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/RowIteratorImpl.java?rev=772659&r1=772658&r2=772659&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/RowIteratorImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/RowIteratorImpl.java Thu May  7 14:29:34 2009
@@ -42,6 +42,7 @@
 import javax.jcr.PathNotFoundException;
 import javax.jcr.NamespaceException;
 import javax.jcr.Node;
+import javax.jcr.ValueFactory;
 import javax.jcr.query.Row;
 import javax.jcr.query.RowIterator;
 import java.util.Arrays;
@@ -64,11 +65,6 @@
     private static final Logger log = LoggerFactory.getLogger(RowIteratorImpl.class);
 
     /**
-     * The QValue factory.
-     */
-    private static final QValueFactory QVALUE_FACTORY = QValueFactoryImpl.getInstance();
-
-    /**
      * The name of the excerpt function without prefix but with left parenthesis.
      */
     private static final String EXCERPT_FUNC_LPAR = "excerpt(";
@@ -159,6 +155,7 @@
                     ItemManager itemMgr,
                     HierarchyManager hmgr,
                     NamePathResolver resolver,
+                    ValueFactory valueFactory,
                     ExcerptProvider exProvider,
                     SpellSuggestion spellSuggestion) {
         this.scoreNodes = scoreNodes;
@@ -169,7 +166,12 @@
         this.resolver = resolver;
         this.excerptProvider = exProvider;
         this.spellSuggestion = spellSuggestion;
-        this.valueFactory = new ValueFactoryQImpl(QVALUE_FACTORY, resolver);
+        if (valueFactory instanceof ValueFactoryQImpl) {
+            this.valueFactory = (ValueFactoryQImpl) valueFactory;
+        } else {
+            QValueFactory qvf = QValueFactoryImpl.getInstance();
+            this.valueFactory = new ValueFactoryQImpl(qvf, resolver);
+        }
     }
 
     /**
@@ -362,7 +364,7 @@
                     }
                 }
                 if (NameConstants.JCR_PATH.equals(prop)) {
-                    QValue p = QVALUE_FACTORY.create(hmgr.getPath(sn[0].getNodeId()));
+                    QValue p = valueFactory.getQValueFactory().create(hmgr.getPath(sn[0].getNodeId()));
                     return valueFactory.createValue(p);
                 } else if (getNodeImpl().hasProperty(prop)) {
                     Property p = getNodeImpl().getProperty(prop);

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/Util.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/Util.java?rev=772659&r1=772658&r2=772659&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/Util.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/Util.java Thu May  7 14:29:34 2009
@@ -138,8 +138,9 @@
      *
      * @param value an internal value.
      * @return a comparable for the given <code>value</code>.
+     * @throws RepositoryException if retrieving the <code>Comparable</code> fails.
      */
-    public static Comparable getComparable(InternalValue value) {
+    public static Comparable getComparable(InternalValue value) throws RepositoryException {
         switch (value.getType()) {
             case PropertyType.BINARY:
                 return null;
@@ -152,13 +153,13 @@
             case PropertyType.LONG:
                 return new Long(value.getLong());
             case PropertyType.NAME:
-                return value.getQName().toString();
+                return value.getName().toString();
             case PropertyType.PATH:
                 return value.getPath().toString();
             case PropertyType.REFERENCE:
             case PropertyType.STRING:
                 return value.getString();
-            // TODO: JSR 283 now node types
+            // TODO: JSR 283 adds new property types
             default:
                 return null;
         }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBFileValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBFileValue.java?rev=772659&r1=772658&r2=772659&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBFileValue.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBFileValue.java Thu May  7 14:29:34 2009
@@ -19,6 +19,8 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.UnsupportedEncodingException;
 
 import javax.jcr.RepositoryException;
 
@@ -45,6 +47,39 @@
     public abstract InputStream getStream() throws RepositoryException;
 
     /**
+     * Returns a String representation of this value.
+     *
+     * @return String representation of this value.
+     * @throws RepositoryException
+     */
+    public String getString() throws RepositoryException {
+        // TODO: review again. currently the getString method of the JCR Value is delegated to the QValue.
+        InputStream stream = getStream();
+        try {
+            ByteArrayOutputStream out = new ByteArrayOutputStream();
+            byte[] buffer = new byte[8192];
+            int read;
+            while ((read = stream.read(buffer)) > 0) {
+                out.write(buffer, 0, read);
+            }
+            byte[] data = out.toByteArray();
+            return new String(data, "UTF-8");
+        } catch (UnsupportedEncodingException e) {
+            throw new RepositoryException("UTF-8 not supported on this platform", e);
+        } catch (IOException e) {
+            throw new RepositoryException("conversion from stream to string failed", e);
+        } finally {
+            try {
+                if (stream != null) {
+                    stream.close();
+                }
+            } catch (IOException e) {
+                // ignore
+            }
+        }
+    }
+
+    /**
      * Returns the length of this <code>BLOBFileValue</code>.
      *
      * @return The length, in bytes, of this <code>BLOBFileValue</code>,

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBInMemory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBInMemory.java?rev=772659&r1=772658&r2=772659&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBInMemory.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBInMemory.java Thu May  7 14:29:34 2009
@@ -20,8 +20,10 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.jcr.RepositoryException;
 import java.io.ByteArrayInputStream;
 import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
 import java.util.Arrays;
 
 /**
@@ -157,6 +159,17 @@
     /**
      * {@inheritDoc}
      */
+    public String getString() throws RepositoryException {
+        try {
+            return new String(data, "UTF-8");
+        } catch (UnsupportedEncodingException e) {
+            throw new RepositoryException("UTF-8 not supported on this platform", e);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
     public String toString() {
         StringBuffer buff = new StringBuffer(PREFIX.length() + 2 * data.length);
         buff.append(PREFIX);

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBInTempFile.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBInTempFile.java?rev=772659&r1=772658&r2=772659&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBInTempFile.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBInTempFile.java Thu May  7 14:29:34 2009
@@ -48,7 +48,8 @@
      * The input stream is always closed by this method.
      *
      * @param in the input stream
-     * @throws IOException
+     * @param temp
+     * @throws RepositoryException
      */
     private BLOBInTempFile(InputStream in, boolean temp) throws RepositoryException {
         this.temp = temp;

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/InternalValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/InternalValue.java?rev=772659&r1=772658&r2=772659&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/InternalValue.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/InternalValue.java Thu May  7 14:29:34 2009
@@ -25,29 +25,29 @@
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
 import org.apache.jackrabbit.spi.Path;
 import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.QValue;
 import org.apache.jackrabbit.util.ISO8601;
 import org.apache.jackrabbit.uuid.UUID;
-import org.apache.jackrabbit.value.BooleanValue;
-import org.apache.jackrabbit.value.DateValue;
-import org.apache.jackrabbit.value.DoubleValue;
-import org.apache.jackrabbit.value.LongValue;
-import org.apache.jackrabbit.value.NameValue;
-import org.apache.jackrabbit.value.PathValue;
-import org.apache.jackrabbit.value.ReferenceValue;
 import org.apache.jackrabbit.value.StringValue;
 import org.apache.jackrabbit.spi.commons.name.PathFactoryImpl;
 import org.apache.jackrabbit.spi.commons.name.NameFactoryImpl;
+import org.apache.jackrabbit.spi.commons.value.ValueFactoryQImpl;
+import org.apache.jackrabbit.spi.commons.value.AbstractQValue;
+import org.apache.jackrabbit.spi.commons.value.QValueValue;
 
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
 import javax.jcr.ValueFormatException;
+import javax.jcr.Session;
+import javax.jcr.ValueFactory;
 
 import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.SequenceInputStream;
+import java.io.UnsupportedEncodingException;
 import java.util.Calendar;
 
 /**
@@ -69,7 +69,7 @@
  * </table>
  * </pre>
  */
-public class InternalValue {
+public class InternalValue extends AbstractQValue {
 
     public static final InternalValue[] EMPTY_ARRAY = new InternalValue[0];
 
@@ -88,9 +88,6 @@
      */
     private static final int MIN_BLOB_FILE_SIZE = 1024;
 
-    private Object val;
-    private final int type;
-
     //------------------------------------------------------< factory methods >
     /**
      * Create a new internal value from the given JCR value.
@@ -116,9 +113,6 @@
      */
     public static InternalValue create(Value value, NamePathResolver resolver, DataStore store)
             throws ValueFormatException, RepositoryException {
-        if (value == null) {
-            throw new IllegalArgumentException("null value");
-        }
         switch (value.getType()) {
             case PropertyType.BINARY:
                 InternalValue result;
@@ -164,13 +158,31 @@
                 return create(new UUID(value.getString()));
             case PropertyType.NAME:
                 try {
-                    return create(resolver.getQName(value.getString()));
+                    if (value instanceof QValueValue) {
+                        QValue qv = ((QValueValue) value).getQValue();
+                        if (qv instanceof InternalValue) {
+                            return (InternalValue) qv;
+                        } else {
+                            return create(qv.getName());
+                        }
+                    } else {
+                        return create(resolver.getQName(value.getString()));
+                    }
                 } catch (NameException e) {
                     throw new ValueFormatException(e.getMessage());
                 }
             case PropertyType.PATH:
                 try {
-                    return create(resolver.getQPath(value.getString()));
+                    if (value instanceof QValueValue) {
+                        QValue qv = ((QValueValue) value).getQValue();
+                        if (qv instanceof InternalValue) {
+                            return (InternalValue) qv;
+                        } else {
+                            return create(qv.getPath());
+                        }
+                    } else {
+                        return create(resolver.getQPath(value.getString(), false));
+                    }
                 } catch (MalformedPathException mpe) {
                     throw new ValueFormatException(mpe.getMessage());
                 }
@@ -372,30 +384,42 @@
      * @param resolver
      * @return
      * @throws RepositoryException
+     * @deprecated
      */
     public Value toJCRValue(NamePathResolver resolver)
             throws RepositoryException {
-        switch (type) {
-            case PropertyType.BINARY:
-                return new BinaryValueImpl((BLOBFileValue) val);
-            case PropertyType.BOOLEAN:
-                return new BooleanValue(((Boolean) val));
-            case PropertyType.DATE:
-                return new DateValue((Calendar) val);
-            case PropertyType.DOUBLE:
-                return new DoubleValue((Double) val);
-            case PropertyType.LONG:
-                return new LongValue((Long) val);
-            case PropertyType.REFERENCE:
-                return ReferenceValue.valueOf(val.toString());
-            case PropertyType.PATH:
-                return PathValue.valueOf(resolver.getJCRPath((Path) val));
-            case PropertyType.NAME:
-                return NameValue.valueOf(resolver.getJCRName((Name) val), false);
-            case PropertyType.STRING:
-                return new StringValue((String) val);
-            default:
-                throw new RepositoryException("illegal internal value type");
+        ValueFactory vf;
+        if (resolver instanceof Session) {
+            vf = ((Session) resolver).getValueFactory();
+        } else {
+            vf = new ValueFactoryImpl(resolver);
+        }
+
+        if (vf instanceof ValueFactoryQImpl) {
+            return ((ValueFactoryQImpl) vf).createValue(this);
+        } else {
+            switch (type) {
+                case PropertyType.BINARY:
+                    return vf.createValue(((BLOBFileValue) val).getStream());
+                case PropertyType.BOOLEAN:
+                    return vf.createValue(((Boolean) val).booleanValue());
+                case PropertyType.DATE:
+                    return vf.createValue((Calendar) val);
+                case PropertyType.DOUBLE:
+                    return vf.createValue(((Double) val).doubleValue());
+                case PropertyType.LONG:
+                    return vf.createValue(((Long) val).longValue());
+                case PropertyType.REFERENCE:
+                    return vf.createValue(val.toString(), PropertyType.REFERENCE);
+                case PropertyType.PATH:
+                    return vf.createValue(resolver.getJCRPath((Path) val), PropertyType.PATH);
+                case PropertyType.NAME:
+                    return vf.createValue(resolver.getJCRName((Name) val), PropertyType.NAME);
+                case PropertyType.STRING:
+                    return new StringValue((String) val);
+                default:
+                    throw new RepositoryException("illegal internal value type");
+            }
         }
     }
 
@@ -417,50 +441,16 @@
         return (UUID) val;
     }
 
-    public boolean getBoolean() {
-        assert val != null && type == PropertyType.BOOLEAN;
-        return ((Boolean) val).booleanValue();
-    }
-
     public Name getQName() {
         assert val != null && type == PropertyType.NAME;
         return (Name) val;
     }
 
-    public Path getPath() {
-        assert val != null && type == PropertyType.PATH;
-        return (Path) val;
-    }
-
-    public long getLong() {
-        assert val != null && type == PropertyType.LONG;
-        return ((Long) val).longValue();
-    }
-
-    public double getDouble() {
-        assert val != null && type == PropertyType.DOUBLE;
-        return ((Double) val).doubleValue();
-    }
-
     public Calendar getDate() {
         assert val != null && type == PropertyType.DATE;
         return (Calendar) val;
     }
 
-    public String getString() {
-        assert val != null && type == PropertyType.STRING;
-        return (String) val;
-    }
-
-    /**
-     * Get the type of this value.
-     *
-     * @return the type
-     */
-    public int getType() {
-        return type;
-    }
-
     /**
      * Create a copy of this object. Immutable values will return itself,
      * while mutable values will return a copy.
@@ -548,71 +538,42 @@
         }
     }
 
-    /**
-     * {@inheritDoc}
-     */
-    public boolean equals(Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (obj instanceof InternalValue) {
-            InternalValue other = (InternalValue) obj;
-            return val.equals(other.val);
-        }
-        return false;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public int hashCode() {
-        return val.hashCode();
-    }
 
     //-------------------------------------------------------< implementation >
     private InternalValue(String value) {
-        val = value;
-        type = PropertyType.STRING;
+        super(value, PropertyType.STRING);
     }
 
     private InternalValue(Name value) {
-        val = value;
-        type = PropertyType.NAME;
+        super(value);
     }
 
     private InternalValue(long value) {
-        val = new Long(value);
-        type = PropertyType.LONG;
+        super(new Long(value));
     }
 
     private InternalValue(double value) {
-        val = new Double(value);
-        type = PropertyType.DOUBLE;
+        super(new Double(value));
     }
 
     private InternalValue(Calendar value) {
-        val = value;
-        type = PropertyType.DATE;
+        super(value, PropertyType.DATE);
     }
 
     private InternalValue(boolean value) {
-        val = Boolean.valueOf(value);
-        type = PropertyType.BOOLEAN;
+        super(Boolean.valueOf(value));
     }
 
     private InternalValue(BLOBFileValue value) {
-        val = value;
-        type = PropertyType.BINARY;
+        super(value, PropertyType.BINARY);
     }
 
     private InternalValue(Path value) {
-        val = value;
-        type = PropertyType.PATH;
+        super(value);
     }
 
     private InternalValue(UUID value) {
-        val = value;
-        type = PropertyType.REFERENCE;
+        super(value, PropertyType.REFERENCE);
     }
 
     /**
@@ -697,4 +658,44 @@
         val = getBLOBFileValue(dataStore, v.getStream(), false);
     }
 
+    //-------------------------------------------------------------< QValue >---
+    /**
+     * @see org.apache.jackrabbit.spi.QValue#getLength()
+     */
+    public long getLength() throws RepositoryException {
+        if (PropertyType.BINARY == type) {
+            return ((BLOBFileValue) val).getLength();
+        } else {
+            return super.getLength();
+        }
+    }
+
+    /**
+     * @see org.apache.jackrabbit.spi.QValue#getString()
+     */
+    public String getString() throws RepositoryException {
+        if (type == PropertyType.BINARY) {
+            return ((BLOBFileValue) val).getString();
+        } else if (type == PropertyType.DATE) {
+            return ISO8601.format(((Calendar) val));
+        } else {
+            return toString();
+        }
+    }
+
+    /**
+     * @see org.apache.jackrabbit.spi.QValue#getStream()
+     */
+    public InputStream getStream() throws RepositoryException {
+        if (type == PropertyType.BINARY) {
+            return ((BLOBFileValue) val).getStream();
+        } else {
+            try {
+                // convert via string
+                return new ByteArrayInputStream(getString().getBytes(InternalValueFactory.DEFAULT_ENCODING));
+            } catch (UnsupportedEncodingException e) {
+                throw new RepositoryException(InternalValueFactory.DEFAULT_ENCODING + " is not supported encoding on this platform", e);
+            }
+        }
+    }
 }

Added: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/InternalValueFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/InternalValueFactory.java?rev=772659&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/InternalValueFactory.java (added)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/InternalValueFactory.java Thu May  7 14:29:34 2009
@@ -0,0 +1,141 @@
+/*
+ * 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.core.value;
+
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.Path;
+import org.apache.jackrabbit.spi.QValue;
+import org.apache.jackrabbit.spi.QValueFactory;
+import org.apache.jackrabbit.spi.commons.name.NameFactoryImpl;
+import org.apache.jackrabbit.spi.commons.name.PathFactoryImpl;
+import org.apache.jackrabbit.spi.commons.value.AbstractQValueFactory;
+import org.apache.jackrabbit.util.ISO8601;
+import org.apache.jackrabbit.uuid.UUID;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.ValueFormatException;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.io.FileInputStream;
+import java.util.Calendar;
+
+/**
+ * <code>InternalValueFactory</code>...
+ */
+public final class InternalValueFactory extends AbstractQValueFactory {
+
+    /**
+     * logger instance
+     */
+    private static final Logger log = LoggerFactory.getLogger(InternalValueFactory.class);
+
+    private static final QValueFactory INSTANCE = new InternalValueFactory();
+
+    private InternalValueFactory() {
+    }
+
+    public static QValueFactory getInstance() {
+        return INSTANCE;
+    }
+
+    public QValue create(String value, int type) throws ValueFormatException, RepositoryException {
+        if (value == null) {
+            throw new IllegalArgumentException("Cannot create QValue from null value.");
+        }
+        try {
+            switch (type) {
+                case PropertyType.BOOLEAN:
+                    return InternalValue.create(Boolean.valueOf(value).booleanValue());
+                case PropertyType.DATE: {
+                    Calendar cal = ISO8601.parse(value);
+                    if (cal == null) {
+                        throw new ValueFormatException("not a valid date: " + value);
+                    }
+                    return InternalValue.create(cal);
+                }
+                case PropertyType.DOUBLE:
+                    return InternalValue.create(Double.parseDouble(value));
+                case PropertyType.LONG:
+                    return InternalValue.create(Long.parseLong(value));
+                case PropertyType.PATH:
+                    return InternalValue.create(PathFactoryImpl.getInstance().create(value));
+                case PropertyType.NAME:
+                    return InternalValue.create(NameFactoryImpl.getInstance().create(value));
+                case PropertyType.STRING:
+                    return InternalValue.create(value);
+                case PropertyType.REFERENCE:
+                    return InternalValue.create(new UUID(value));
+                case PropertyType.BINARY:
+                    return InternalValue.create(value.getBytes("UTF-8"));
+                // default: invalid type specified -> see below.
+            }
+        } catch (IllegalArgumentException ex) {
+            // given String value cannot be converted to Long/Double/Path/Name
+            throw new ValueFormatException(ex);
+        } catch (UnsupportedEncodingException ex) {
+            throw new RepositoryException(ex);
+        }
+
+        // invalid type specified:
+        throw new IllegalArgumentException("illegal type " + type);    }
+
+    public QValue create(Calendar value) throws RepositoryException {
+        return InternalValue.create(value);
+    }
+
+    public QValue create(double value) throws RepositoryException {
+        return InternalValue.create(value);
+    }
+
+    public QValue create(long value) throws RepositoryException {
+        return InternalValue.create(value);
+    }
+
+    public QValue create(boolean value) throws RepositoryException {
+        return InternalValue.create(value);
+    }
+
+    public QValue create(Name value) throws RepositoryException {
+        return InternalValue.create(value);
+    }
+
+    public QValue create(Path value) throws RepositoryException {
+        return InternalValue.create(value);
+    }
+
+    public QValue create(byte[] value) throws RepositoryException {
+        return InternalValue.create(value);
+    }
+
+    public QValue create(InputStream value) throws RepositoryException, IOException {
+        return InternalValue.create(value);
+    }
+
+    public QValue create(File value) throws RepositoryException, IOException {
+        if (InternalValue.USE_DATA_STORE) {
+            InputStream in = new FileInputStream(value);
+            return InternalValue.createTemporary(in);
+        } else {
+            return InternalValue.create(value);
+        }
+    }
+}
\ No newline at end of file

Added: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/ValueFactoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/ValueFactoryImpl.java?rev=772659&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/ValueFactoryImpl.java (added)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/ValueFactoryImpl.java Thu May  7 14:29:34 2009
@@ -0,0 +1,88 @@
+/*
+ * 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.core.value;
+
+import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
+import org.apache.jackrabbit.spi.commons.value.ValueFactoryQImpl;
+import org.apache.jackrabbit.spi.QValue;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.jcr.Value;
+import javax.jcr.PropertyType;
+import javax.jcr.ValueFormatException;
+import javax.jcr.RepositoryException;
+import java.io.InputStream;
+import java.io.IOException;
+
+/**
+ * <code>ValueFactoryImpl</code>...
+ */
+public class ValueFactoryImpl extends ValueFactoryQImpl {
+
+    /**
+     * logger instance
+     */
+    private static final Logger log = LoggerFactory.getLogger(ValueFactoryImpl.class);
+
+    /**
+     * Constructs a new <code>ValueFactoryQImpl</code> based
+     * on an existing SPI <code>QValueFactory</code> and a
+     * <code>NamePathResolver</code>.
+     *
+     * @param resolver wrapped <code>NamePathResolver</code>
+     */
+    public ValueFactoryImpl(NamePathResolver resolver) {
+        super(InternalValueFactory.getInstance(), resolver);
+    }
+
+    public Value createValue(QValue qvalue) {
+        if (qvalue instanceof InternalValue && PropertyType.BINARY == qvalue.getType()) {
+            try {
+                return new BinaryValueImpl(((InternalValue) qvalue).getBLOBFileValue());
+            } catch (RepositoryException e) {
+                // should not get here
+                log.error(e.getMessage());
+            }
+        }
+        return super.createValue(qvalue);
+    }
+
+    public Value createValue(InputStream value) {
+        try {
+            InternalValue qvalue = (InternalValue) getQValueFactory().create(value);
+            return new BinaryValueImpl(qvalue.getBLOBFileValue());
+        } catch (IOException ex) {
+            throw new RuntimeException(ex);
+        } catch (RepositoryException ex) {
+            throw new RuntimeException(ex);
+        }
+    }
+
+    public Value createValue(String value, int type) throws ValueFormatException {
+        if (PropertyType.BINARY == type) {
+            try {
+                InternalValue qvalue = (InternalValue) getQValueFactory().create(value, type);                
+                return new BinaryValueImpl(qvalue.getBLOBFileValue());
+            } catch (RepositoryException e) {
+                throw new ValueFormatException(e);
+            }
+        } else {
+            return super.createValue(value, type);
+        }
+    }
+}
\ No newline at end of file

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/BufferedStringValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/BufferedStringValue.java?rev=772659&r1=772658&r2=772659&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/BufferedStringValue.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/BufferedStringValue.java Thu May  7 14:29:34 2009
@@ -20,8 +20,8 @@
 import org.apache.jackrabbit.util.Base64;
 import org.apache.jackrabbit.util.TransientFileFactory;
 import org.apache.jackrabbit.value.ValueHelper;
-import org.apache.jackrabbit.value.ValueFactoryImpl;
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
+import org.apache.jackrabbit.spi.commons.value.ValueFormat;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -29,6 +29,7 @@
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
 import javax.jcr.ValueFormatException;
+import javax.jcr.ValueFactory;
 
 import java.io.BufferedInputStream;
 import java.io.BufferedOutputStream;
@@ -86,6 +87,7 @@
     private Writer writer;
 
     private final NamePathResolver nsContext;
+    private final ValueFactory valueFactory;
     
     /**
      * Whether the value is base64 encoded.
@@ -96,12 +98,13 @@
      * Constructs a new empty <code>BufferedStringValue</code>.
      * @param nsContext
      */
-    protected BufferedStringValue(NamePathResolver nsContext) {
+    protected BufferedStringValue(NamePathResolver nsContext, ValueFactory valueFactory) {
         buffer = new StringWriter();
         length = 0;
         tmpFile = null;
         writer = null;
         this.nsContext = nsContext;
+        this.valueFactory = valueFactory;
     }
 
     /**
@@ -243,26 +246,26 @@
                 // current namespace context of xml document
                 InternalValue ival =
                     InternalValue.create(ValueHelper.convert(
-                            retrieve(), targetType, ValueFactoryImpl.getInstance()), nsContext);
+                            retrieve(), targetType, valueFactory), nsContext);
                 // convert InternalValue to Value using this
                 // session's namespace mappings
-                return ival.toJCRValue(resolver);
+                return ValueFormat.getJCRValue(ival, resolver, valueFactory);
             } else if (targetType == PropertyType.BINARY) {
                 if (length() < 0x10000) {
                     // < 65kb: deserialize BINARY type using String
-                    return ValueHelper.deserialize(retrieve(), targetType, false, ValueFactoryImpl.getInstance());
+                    return ValueHelper.deserialize(retrieve(), targetType, false, valueFactory);
                 } else {
                     // >= 65kb: deserialize BINARY type using Reader
                     Reader reader = reader();
                     try {
-                        return ValueHelper.deserialize(reader, targetType, false, ValueFactoryImpl.getInstance());
+                        return ValueHelper.deserialize(reader, targetType, false, valueFactory);
                     } finally {
                         reader.close();
                     }
                 }
             } else {
                 // all other types
-                return ValueHelper.deserialize(retrieveString(), targetType, false, ValueFactoryImpl.getInstance());
+                return ValueHelper.deserialize(retrieveString(), targetType, false, valueFactory);
             }
         } catch (IOException e) {
             String msg = "failed to retrieve serialized value";
@@ -307,7 +310,7 @@
                 // convert serialized value to InternalValue using
                 // current namespace context of xml document
                 return InternalValue.create(ValueHelper.convert(
-                        retrieveString(), type, ValueFactoryImpl.getInstance()), nsContext);
+                        retrieveString(), type, valueFactory), nsContext);
             }
         } catch (IOException e) {
             throw new RepositoryException("Error accessing property value", e);

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/DocViewImportHandler.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/DocViewImportHandler.java?rev=772659&r1=772658&r2=772659&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/DocViewImportHandler.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/DocViewImportHandler.java Thu May  7 14:29:34 2009
@@ -32,6 +32,7 @@
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
 import javax.jcr.NamespaceException;
+import javax.jcr.ValueFactory;
 import java.io.IOException;
 import java.io.Reader;
 import java.util.ArrayList;
@@ -59,8 +60,8 @@
      *
      * @param importer
      */
-    DocViewImportHandler(Importer importer) {
-        super(importer);
+    DocViewImportHandler(Importer importer, ValueFactory valueFactory) {
+        super(importer, valueFactory);
     }
 
     /**
@@ -102,7 +103,7 @@
     private void appendCharacters(char[] ch, int start, int length)
             throws SAXException {
         if (textHandler == null) {
-            textHandler = new BufferedStringValue(resolver);
+            textHandler = new BufferedStringValue(resolver, valueFactory);
         }
         try {
             textHandler.append(ch, start, length);
@@ -250,7 +251,7 @@
                 // see also DocViewSAXEventGenerator#leavingProperties(Node, int)
                 // todo proper multi-value serialization support
                 propValues = new TextValue[1];
-                propValues[0] = new StringValue(attrValue, resolver);
+                propValues[0] = new StringValue(attrValue, resolver, valueFactory);
 
                 if (propName.equals(NameConstants.JCR_PRIMARYTYPE)) {
                     // jcr:primaryType

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/ImportHandler.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/ImportHandler.java?rev=772659&r1=772658&r2=772659&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/ImportHandler.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/ImportHandler.java Thu May  7 14:29:34 2009
@@ -20,6 +20,7 @@
 
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
+import javax.jcr.ValueFactory;
 
 import org.apache.jackrabbit.commons.NamespaceHelper;
 import org.apache.jackrabbit.spi.Name;
@@ -55,6 +56,8 @@
 
     private final NamespaceHelper helper;
 
+    private final ValueFactory valueFactory;
+
     protected Locator locator;
 
     private TargetImportHandler targetHandler = null;
@@ -72,6 +75,7 @@
         this.importer = importer;
         this.helper = new NamespaceHelper(session);
         this.localNamespaceMappings = helper.getNamespaces();
+        this.valueFactory = session.getValueFactory();
     }
 
     //---------------------------------------------------------< ErrorHandler >
@@ -149,9 +153,9 @@
             // the namespace of the first element determines the type of XML
             // (system view/document view)
             if (Name.NS_SV_URI.equals(namespaceURI)) {
-                targetHandler = new SysViewImportHandler(importer);
+                targetHandler = new SysViewImportHandler(importer, valueFactory);
             } else {
-                targetHandler = new DocViewImportHandler(importer);
+                targetHandler = new DocViewImportHandler(importer, valueFactory);
             }
 
             targetHandler.startDocument();

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/StringValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/StringValue.java?rev=772659&r1=772658&r2=772659&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/StringValue.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/StringValue.java Thu May  7 14:29:34 2009
@@ -19,13 +19,14 @@
 import org.apache.jackrabbit.core.value.InternalValue;
 import org.apache.jackrabbit.util.Base64;
 import org.apache.jackrabbit.value.ValueHelper;
-import org.apache.jackrabbit.value.ValueFactoryImpl;
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
+import org.apache.jackrabbit.spi.commons.value.ValueFormat;
 
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
 import javax.jcr.ValueFormatException;
+import javax.jcr.ValueFactory;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 
@@ -37,16 +38,20 @@
     private final String value;
 
     private final NamePathResolver nsContext;
+    private final ValueFactory valueFactory;
 
     /**
      * Constructs a new <code>StringValue</code> representing the given
      * value.
      *
      * @param value
+     * @param nsContext
+     * @param valueFactory
      */
-    protected StringValue(String value, NamePathResolver nsContext) {
+    protected StringValue(String value, NamePathResolver nsContext, ValueFactory valueFactory) {
         this.value = value;
         this.nsContext = nsContext;
+        this.valueFactory = valueFactory;
     }
 
     //--------------------------------------------------------< TextValue >
@@ -62,13 +67,13 @@
             // current namespace context of xml document
             InternalValue ival =
                     InternalValue.create(ValueHelper.convert(
-                            value, type, ValueFactoryImpl.getInstance()), nsContext);
+                            value, type, valueFactory), nsContext);
             // convert InternalValue to Value using this
             // session's namespace mappings
-            return ival.toJCRValue(resolver);
+            return ValueFormat.getJCRValue(ival, resolver, valueFactory);
         } else {
             // all other types
-            return ValueHelper.deserialize(value, type, false, ValueFactoryImpl.getInstance());
+            return ValueHelper.deserialize(value, type, false, valueFactory);
         }
     }
 
@@ -85,7 +90,7 @@
                 // convert serialized value to InternalValue using
                 // current namespace context of xml document
                 return InternalValue.create(ValueHelper.convert(
-                        value, targetType, ValueFactoryImpl.getInstance()), nsContext);
+                        value, targetType, valueFactory), nsContext);
             }
         } catch (IOException e) {
             throw new RepositoryException("Error decoding Base64 content", e);

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/SysViewImportHandler.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/SysViewImportHandler.java?rev=772659&r1=772658&r2=772659&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/SysViewImportHandler.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/SysViewImportHandler.java Thu May  7 14:29:34 2009
@@ -28,6 +28,7 @@
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
 import javax.jcr.NamespaceException;
+import javax.jcr.ValueFactory;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Iterator;
@@ -60,8 +61,8 @@
      *
      * @param importer
      */
-    SysViewImportHandler(Importer importer) {
-        super(importer);
+    SysViewImportHandler(Importer importer, ValueFactory valueFactory) {
+        super(importer, valueFactory);
     }
 
     private void processNode(ImportState state, boolean start, boolean end)
@@ -172,7 +173,7 @@
             }
         } else if (name.equals(NameConstants.SV_VALUE)) {
             // sv:value element
-            currentPropValue = new BufferedStringValue(resolver);
+            currentPropValue = new BufferedStringValue(resolver, valueFactory);
             String xsiType = atts.getValue("xsi:type");
             currentPropValue.setBase64("xs:base64Binary".equals(xsiType));
         } else {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/TargetImportHandler.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/TargetImportHandler.java?rev=772659&r1=772658&r2=772659&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/TargetImportHandler.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/TargetImportHandler.java Thu May  7 14:29:34 2009
@@ -24,6 +24,7 @@
 import java.util.Map;
 
 import javax.jcr.RepositoryException;
+import javax.jcr.ValueFactory;
 
 /**
  * <code>TargetImportHandler</code> serves as the base class for the concrete
@@ -34,6 +35,8 @@
 
     protected final Importer importer;
 
+    protected final ValueFactory valueFactory;
+
     /**
      * The current namespace context. A new namespace context is created
      * for each XML element and the parent reference is used to link the
@@ -45,8 +48,9 @@
 
     protected NamePathResolver resolver;
 
-    protected TargetImportHandler(Importer importer) {
+    protected TargetImportHandler(Importer importer, ValueFactory valueFactory) {
         this.importer = importer;
+        this.valueFactory = valueFactory;
     }
 
     /**

Added: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/value/InternalValueFactoryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/value/InternalValueFactoryTest.java?rev=772659&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/value/InternalValueFactoryTest.java (added)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/value/InternalValueFactoryTest.java Thu May  7 14:29:34 2009
@@ -0,0 +1,46 @@
+/*
+ * 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.core.value;
+
+import org.apache.jackrabbit.spi.QValueFactoryTest;
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.commons.name.PathFactoryImpl;
+import org.apache.jackrabbit.spi.commons.name.NameFactoryImpl;
+import org.apache.jackrabbit.uuid.UUID;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * <code>InternalValueFactoryTest</code>...
+ */
+public class InternalValueFactoryTest extends QValueFactoryTest {
+
+    /**
+     * logger instance
+     */
+    private static final Logger log = LoggerFactory.getLogger(InternalValueFactoryTest.class);
+
+    protected void setUp() throws Exception {
+        factory = InternalValueFactory.getInstance();
+        rootPath = PathFactoryImpl.getInstance().getRootPath();
+        testName = NameFactoryImpl.getInstance().create(Name.NS_JCR_URI, "data");
+        reference = UUID.randomUUID().toString();
+    }
+
+    protected void tearDown() throws Exception {
+    }
+}
\ No newline at end of file

Added: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/value/InternalValueTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/value/InternalValueTest.java?rev=772659&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/value/InternalValueTest.java (added)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/value/InternalValueTest.java Thu May  7 14:29:34 2009
@@ -0,0 +1,46 @@
+/*
+ * 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.core.value;
+
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.QValueTest;
+import org.apache.jackrabbit.spi.commons.name.PathFactoryImpl;
+import org.apache.jackrabbit.spi.commons.name.NameFactoryImpl;
+import org.apache.jackrabbit.uuid.UUID;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * <code>InternalValueFactoryTest</code>...
+ */
+public class InternalValueTest extends QValueTest {
+
+    /**
+     * logger instance
+     */
+    private static final Logger log = LoggerFactory.getLogger(InternalValueTest.class);
+
+    protected void setUp() throws Exception {
+        factory = InternalValueFactory.getInstance();
+        rootPath = PathFactoryImpl.getInstance().getRootPath();
+        testName = NameFactoryImpl.getInstance().create(Name.NS_JCR_URI, "data");
+        reference = UUID.randomUUID().toString();
+    }
+
+    protected void tearDown() throws Exception {
+    }
+}
\ No newline at end of file



Mime
View raw message