jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r783786 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core: nodetype/ persistence/bundle/util/ query/lucene/ value/ version/
Date Thu, 11 Jun 2009 14:21:39 GMT
Author: thomasm
Date: Thu Jun 11 14:21:39 2009
New Revision: 783786

URL: http://svn.apache.org/viewvc?rev=783786&view=rev
Log:
JCR-2144 InternalValue refactoring

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/ValueConstraint.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/NodeIndexer.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/BLOBInDataStore.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/BLOBInResource.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/BLOBValue.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/version/InternalFrozenNodeImpl.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/ValueConstraint.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/ValueConstraint.java?rev=783786&r1=783785&r2=783786&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/ValueConstraint.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/ValueConstraint.java
Thu Jun 11 14:21:39 2009
@@ -636,7 +636,7 @@
         }
         switch (value.getType()) {
             case PropertyType.NAME:
-                Name n = value.getQName();
+                Name n = value.getName();
                 if (!name.equals(n)) {
                     throw new ConstraintViolationException(n
                             + " does not satisfy the constraint '"

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=783786&r1=783785&r2=783786&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 Jun 11 14:21:39 2009
@@ -713,7 +713,12 @@
                     }
                     break;
                 case PropertyType.NAME:
-                    writeQName(out, val.getQName());
+                    try {
+                        writeQName(out, val.getName());
+                    } catch (RepositoryException e) {
+                        // should never occur
+                        throw new IOException("Unexpected error while writing NAME value.");
+                    }
                     break;
                 case PropertyType.WEAKREFERENCE:
                 case PropertyType.REFERENCE:

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=783786&r1=783785&r2=783786&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 Jun 11 14:21:39 2009
@@ -360,7 +360,7 @@
                 if (name.equals(NameConstants.JCR_PRIMARYTYPE)
                         || name.equals(NameConstants.JCR_MIXINTYPES)
                         || isIndexed(name)) {
-                    addNameValue(doc, fieldName, value.getQName());
+                    addNameValue(doc, fieldName, value.getName());
                 }
                 break;
             case PropertyType.DECIMAL:

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=783786&r1=783785&r2=783786&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 Jun 11 14:21:39 2009
@@ -18,14 +18,12 @@
 
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.OutputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.UnsupportedEncodingException;
 
 import javax.jcr.RepositoryException;
 import javax.jcr.Binary;
 
-import org.apache.commons.io.IOUtils;
 import org.apache.jackrabbit.core.data.DataIdentifier;
 
 /**
@@ -46,7 +44,7 @@
      * @return String representation of this value.
      * @throws RepositoryException
      */
-    public String getString() throws RepositoryException {
+    String getString() throws RepositoryException {
         // TODO: review again. currently the getString method of the JCR Value is delegated
to the QValue.
         InputStream stream = getStream();
         try {
@@ -105,7 +103,7 @@
      *
      * @return true if the object is immutable
      */
-    public abstract boolean isImmutable();
+    abstract boolean isImmutable();
 
     /**
      * {@inheritDoc}
@@ -117,24 +115,6 @@
      */
     public abstract String toString();
 
-    /*
-     * Spools the contents of this <code>BLOBFileValue</code> to the given
-     * output stream.
-     *
-     * @param out output stream
-     * @throws RepositoryException if the input stream for this
-     *                             <code>BLOBFileValue</code> could not be obtained
-     * @throws IOException         if an error occurs while while spooling
-     */
-    public void spool(OutputStream out) throws RepositoryException, IOException {
-        InputStream in = getStream();
-        try {
-            IOUtils.copy(in, out);
-        } finally {
-            IOUtils.closeQuietly(in);
-        }
-    }
-
     /**
      * {@inheritDoc}
      */
@@ -147,13 +127,13 @@
      * @return true if the value is small
      */
     public abstract boolean isSmall();
-    
+
     /**
      * Get the data identifier if one is available.
-     * 
+     *
      * @return the data identifier or null
      */
-    public DataIdentifier getDataIdentifier() {
+    DataIdentifier getDataIdentifier() {
         return null;
     }
 

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBInDataStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBInDataStore.java?rev=783786&r1=783785&r2=783786&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBInDataStore.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBInDataStore.java
Thu Jun 11 14:21:39 2009
@@ -60,15 +60,12 @@
     public void discard() {
         // do nothing
     }
-    
+
     public DataIdentifier getDataIdentifier() {
         return identifier;
     }
 
-    /**
-     * {@inheritDoc}
-     */
-    public boolean isImmutable() {
+    boolean isImmutable() {
         return true;
     }
 
@@ -113,7 +110,7 @@
         DataIdentifier identifier = new DataIdentifier(id);
         return new BLOBInDataStore(store, identifier);
     }
-    
+
     static BLOBInDataStore getInstance(DataStore store, DataIdentifier identifier) {
         return new BLOBInDataStore(store, identifier);
     }

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=783786&r1=783785&r2=783786&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 Jun 11 14:21:39 2009
@@ -135,10 +135,7 @@
         // the data will be garbage collected
     }
 
-    /**
-     * {@inheritDoc}
-     */
-    public boolean isImmutable() {
+    boolean isImmutable() {
         return true;
     }
 

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBInResource.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBInResource.java?rev=783786&r1=783785&r2=783786&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBInResource.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBInResource.java
Thu Jun 11 14:21:39 2009
@@ -102,10 +102,7 @@
         // this instance is not backed by temporarily allocated resource/buffer
     }
 
-    /**
-     * {@inheritDoc}
-     */
-    public boolean isImmutable() {
+    boolean isImmutable() {
         // delete will modify the state.
         return false;
     }

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=783786&r1=783785&r2=783786&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 Jun 11 14:21:39 2009
@@ -123,10 +123,7 @@
         }
     }
 
-    /**
-     * {@inheritDoc}
-     */
-    public boolean isImmutable() {
+    boolean isImmutable() {
         // discard and delete can modify the state.
         return false;
     }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBValue.java?rev=783786&r1=783785&r2=783786&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBValue.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBValue.java
Thu Jun 11 14:21:39 2009
@@ -285,10 +285,7 @@
         }
     }
 
-    /**
-     * {@inheritDoc}
-     */
-    public boolean isImmutable() {
+    boolean isImmutable() {
         // delete will modify the state
         return false;
     }

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=783786&r1=783785&r2=783786&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 Jun 11 14:21:39 2009
@@ -147,13 +147,13 @@
                         }
                     }
                     if (blob == null) {
-                        blob = getBLOBFileValue(store, value.getStream(), true);
+                        blob = getBLOBFileValue(store, value.getBinary().getStream(), true);
                     }
                     result = new InternalValue(blob);
                 } else if (value instanceof BLOBFileValue) {
                     result = new InternalValue((BLOBFileValue) value);
                 } else {
-                    InputStream stream = value.getStream();
+                    InputStream stream = value.getBinary().getStream();
                     try {
                         result = createTemporary(stream);
                     } finally {
@@ -217,7 +217,7 @@
                 throw new IllegalArgumentException("illegal value");
         }
     }
-    
+
     static InternalValue getInternalValue(DataIdentifier identifier, DataStore store) throws
DataStoreException {
         // access the record to ensure it is not garbage collected
         if (store.getRecordIfStored(identifier) != null) {
@@ -315,32 +315,12 @@
     }
 
     /**
-     * Create an internal value that is backed by a temporary file
-     * (if data store usage is disabled or the store is null)
-     * or in the data store if it is not null and enabled.
-     *
-     * @param value the stream
-     * @param store the data store or null to use a temporary file
-     * @return the internal value
-     */
-    public static InternalValue createTemporary(InputStream value, DataStore store) throws
RepositoryException {
-        if (USE_DATA_STORE) {
-            return new InternalValue(getBLOBFileValue(store, value, true));
-        }
-        try {
-            return new InternalValue(new BLOBValue(value, true));
-        } catch (IOException e) {
-            throw new RepositoryException("Error creating temporary file", e);
-        }
-    }
-
-    /**
      * Create an internal value that is stored in the data store (if enabled).
-     * 
+     *
      * @param value the input stream
      * @return the internal value
      */
-    public static InternalValue create(InputStream value, DataStore store) throws RepositoryException
{
+    static InternalValue create(InputStream value, DataStore store) throws RepositoryException
{
         if (USE_DATA_STORE) {
             return new InternalValue(getBLOBFileValue(store, value, false));
         }
@@ -508,14 +488,6 @@
         }
     }
 
-    /**
-     * @deprecated
-     * @return the internal object
-     */
-    public Object internalValue() {
-        return val;
-    }
-
     public BLOBFileValue getBLOBFileValue() {
         assert val != null && type == PropertyType.BINARY;
         return (BLOBFileValue) val;
@@ -526,11 +498,6 @@
         return (UUID) val;
     }
 
-    public Name getQName() {
-        assert val != null && type == PropertyType.NAME;
-        return (Name) val;
-    }
-
     public Calendar getDate() {
         assert val != null && type == PropertyType.DATE;
         return (Calendar) val;

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalFrozenNodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalFrozenNodeImpl.java?rev=783786&r1=783785&r2=783786&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalFrozenNodeImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalFrozenNodeImpl.java
Thu Jun 11 14:21:39 2009
@@ -123,7 +123,7 @@
                 }
             } else if (prop.getName().equals(NameConstants.JCR_FROZENPRIMARYTYPE)) {
                 // special property
-                frozenPrimaryType = node.getPropertyValue(NameConstants.JCR_FROZENPRIMARYTYPE).getQName();
+                frozenPrimaryType = node.getPropertyValue(NameConstants.JCR_FROZENPRIMARYTYPE).getName();
             } else if (prop.getName().equals(NameConstants.JCR_FROZENMIXINTYPES)) {
                 // special property
                 InternalValue[] values = node.getPropertyValues(NameConstants.JCR_FROZENMIXINTYPES);
@@ -132,7 +132,7 @@
                 } else {
                     frozenMixinTypes = new Name[values.length];
                     for (int j = 0; j < values.length; j++) {
-                        frozenMixinTypes[j] = values[j].getQName();
+                        frozenMixinTypes[j] = values[j].getName();
                     }
                 }
             } else if (prop.getName().equals(NameConstants.JCR_PRIMARYTYPE)) {



Mime
View raw message