jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r782925 - in /jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit: name/ value/AbstractValueFactory.java value/NameValue.java value/PathValue.java value/ValueFactoryImpl.java
Date Tue, 09 Jun 2009 09:13:26 GMT
Author: angela
Date: Tue Jun  9 09:13:24 2009
New Revision: 782925

URL: http://svn.apache.org/viewvc?rev=782925&view=rev
Log:
JCR-2109: Remove deprecated classes in jcr-commons

Added:
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/AbstractValueFactory.java
      - copied, changed from r781342, jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/ValueFactoryImpl.java
Removed:
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/name/
Modified:
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/NameValue.java
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/PathValue.java
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/ValueFactoryImpl.java

Copied: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/AbstractValueFactory.java
(from r781342, jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/ValueFactoryImpl.java)
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/AbstractValueFactory.java?p2=jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/AbstractValueFactory.java&p1=jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/ValueFactoryImpl.java&r1=781342&r2=782925&rev=782925&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/ValueFactoryImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/AbstractValueFactory.java
Tue Jun  9 09:13:24 2009
@@ -34,23 +34,33 @@
  *
  * @see javax.jcr.Session#getValueFactory()
  */
-public class ValueFactoryImpl implements ValueFactory {
-
-    private static final ValueFactory valueFactory = new ValueFactoryImpl();
+public abstract class AbstractValueFactory implements ValueFactory {
 
     /**
      * Constructs a <code>ValueFactory</code> object.
      */
-    protected ValueFactoryImpl() {
+    protected AbstractValueFactory() {
     }
 
-    //--------------------------------------------------------------------------
     /**
+     * Checks the format of the given string representing a path value.
+     * Implementations must assert that the given value is a valid jcr path.
      *
+     * @param pathValue
+     * @throws javax.jcr.ValueFormatException If the given <code>pathValue</code>
+     * isn't a valid jcr path.
      */
-    public static ValueFactory getInstance() {
-        return valueFactory;
-    }
+    protected abstract void checkPathFormat(String pathValue) throws ValueFormatException;
+
+    /**
+     * Checks the format of the given string representing a name value.
+     * Implementations must assert that the given value is a valid jcr name.
+     *
+     * @param nameValue
+     * @throws javax.jcr.ValueFormatException  If the given <code>pathValue</code>
+     * isn't a valid jcr name.
+     */
+    protected abstract void checkNameFormat(String nameValue) throws ValueFormatException;
 
     //---------------------------------------------------------< ValueFactory >
     /**
@@ -128,9 +138,11 @@
                 val = DateValue.valueOf(value);
                 break;
             case PropertyType.NAME:
+                checkNameFormat(value);
                 val = NameValue.valueOf(value);
                 break;
             case PropertyType.PATH:
+                checkPathFormat(value);
                 val = PathValue.valueOf(value);
                 break;
             case PropertyType.URI:
@@ -188,4 +200,4 @@
         }
     }
 
-}
+}
\ No newline at end of file

Modified: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/NameValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/NameValue.java?rev=782925&r1=782924&r2=782925&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/NameValue.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/NameValue.java
Tue Jun  9 09:13:24 2009
@@ -16,9 +16,6 @@
  */
 package org.apache.jackrabbit.value;
 
-import org.apache.jackrabbit.name.NameFormat;
-import org.apache.jackrabbit.name.IllegalNameException;
-
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
 import javax.jcr.ValueFormatException;
@@ -49,34 +46,7 @@
      *                              name.
      */
     public static NameValue valueOf(String s) throws ValueFormatException {
-        return valueOf(s, true);
-    }
-
-    /**
-     * Returns a new <code>NameValue</code> initialized to the value represented
-     * by the specified <code>String</code>.
-     * <p/>
-     * If <code>checkFormat</code> is <code>true</code> specified
-     * <code>String</code> must be a valid JCR name, otherwise the string is
-     * used as is.
-     *
-     * @param s           the string to be parsed.
-     * @param checkFormat if the format should be checked.
-     * @return a newly constructed <code>NameValue</code> representing the
-     *         specified value.
-     * @throws javax.jcr.ValueFormatException If the format should be checked
-     *                                        and the <code>String</code> is
not
-     *                                        a valid name.
-     */
-    public static NameValue valueOf(String s, boolean checkFormat) throws ValueFormatException
{
         if (s != null) {
-            if (checkFormat) {
-                try {
-                    NameFormat.checkFormat(s);
-                } catch (IllegalNameException ine) {
-                    throw new ValueFormatException(ine.getMessage());
-                }
-            }
             return new NameValue(s);
         } else {
             throw new ValueFormatException("not a valid name format: " + s);

Modified: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/PathValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/PathValue.java?rev=782925&r1=782924&r2=782925&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/PathValue.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/PathValue.java
Tue Jun  9 09:13:24 2009
@@ -16,9 +16,6 @@
  */
 package org.apache.jackrabbit.value;
 
-import org.apache.jackrabbit.name.MalformedPathException;
-import org.apache.jackrabbit.name.PathFormat;
-
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
 import javax.jcr.ValueFormatException;
@@ -51,11 +48,6 @@
      */
     public static PathValue valueOf(String s) throws ValueFormatException {
         if (s != null) {
-            try {
-                PathFormat.checkFormat(s);
-            } catch (MalformedPathException mpe) {
-                throw new ValueFormatException(mpe.getMessage());
-            }
             return new PathValue(s);
         } else {
             throw new ValueFormatException("not a valid path format: " + s);

Modified: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/ValueFactoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/ValueFactoryImpl.java?rev=782925&r1=782924&r2=782925&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/ValueFactoryImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/ValueFactoryImpl.java
Tue Jun  9 09:13:24 2009
@@ -16,25 +16,16 @@
  */
 package org.apache.jackrabbit.value;
 
-import java.io.InputStream;
-import java.io.IOException;
-import java.math.BigDecimal;
-import java.util.Calendar;
-
-import javax.jcr.Binary;
-import javax.jcr.Node;
-import javax.jcr.PropertyType;
-import javax.jcr.RepositoryException;
-import javax.jcr.Value;
 import javax.jcr.ValueFactory;
 import javax.jcr.ValueFormatException;
 
 /**
- * This class implements the <code>ValueFactory</code> interface.
+ * Simple extension of the <code>AbstractValueFactory</code> that omits any
+ * validation checks for path and name values.
  *
  * @see javax.jcr.Session#getValueFactory()
  */
-public class ValueFactoryImpl implements ValueFactory {
+public class ValueFactoryImpl extends AbstractValueFactory {
 
     private static final ValueFactory valueFactory = new ValueFactoryImpl();
 
@@ -44,7 +35,6 @@
     protected ValueFactoryImpl() {
     }
 
-    //--------------------------------------------------------------------------
     /**
      *
      */
@@ -52,140 +42,17 @@
         return valueFactory;
     }
 
-    //---------------------------------------------------------< ValueFactory >
     /**
-     * {@inheritDoc}
+     * @see AbstractValueFactory#checkPathFormat(String)
      */
-    public Value createValue(boolean value) {
-        return new BooleanValue(value);
+    protected void checkPathFormat(String pathValue) throws ValueFormatException {
+        // ignore
     }
 
     /**
-     * {@inheritDoc}
+     * @see AbstractValueFactory#checkNameFormat(String)
      */
-    public Value createValue(Calendar value) {
-        return new DateValue(value);
+    protected void checkNameFormat(String nameValue) throws ValueFormatException {
+        // ignore
     }
-
-    /**
-     * {@inheritDoc}
-     */
-    public Value createValue(double value) {
-        return new DoubleValue(value);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public Value createValue(InputStream value) {
-        return new BinaryValue(value);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public Value createValue(long value) {
-        return new LongValue(value);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public Value createValue(Node value) throws RepositoryException {
-        return createValue(value, false);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public Value createValue(String value) {
-        return new StringValue(value);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public Value createValue(String value, int type)
-            throws ValueFormatException {
-        Value val;
-        switch (type) {
-            case PropertyType.STRING:
-                val = new StringValue(value);
-                break;
-            case PropertyType.BOOLEAN:
-                val = BooleanValue.valueOf(value);
-                break;
-            case PropertyType.DOUBLE:
-                val = DoubleValue.valueOf(value);
-                break;
-            case PropertyType.LONG:
-                val = LongValue.valueOf(value);
-                break;
-            case PropertyType.DECIMAL:
-                val = DecimalValue.valueOf(value);
-                break;
-            case PropertyType.DATE:
-                val = DateValue.valueOf(value);
-                break;
-            case PropertyType.NAME:
-                val = NameValue.valueOf(value);
-                break;
-            case PropertyType.PATH:
-                val = PathValue.valueOf(value);
-                break;
-            case PropertyType.URI:
-                val = URIValue.valueOf(value);
-                break;
-            case PropertyType.REFERENCE:
-                val = ReferenceValue.valueOf(value);
-                break;
-            case PropertyType.WEAKREFERENCE:
-                val = WeakReferenceValue.valueOf(value);
-                break;
-            case PropertyType.BINARY:
-                val = new BinaryValue(value);
-                break;
-            default:
-                throw new IllegalArgumentException("Invalid type constant: " + type);
-        }
-        return val;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public Binary createBinary(InputStream stream) throws RepositoryException {
-        try {
-            return new BinaryImpl(stream);
-        } catch (IOException e) {
-            throw new RepositoryException("failed to create Binary instance", e);
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public Value createValue(Binary value) {
-        return new BinaryValue(value);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public Value createValue(BigDecimal value) {
-        return new DecimalValue(value);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public Value createValue(Node node, boolean weak)
-            throws RepositoryException {
-        if (weak) {
-            return new WeakReferenceValue(node);
-        } else {
-            return new ReferenceValue(node);
-        }
-    }
-
 }



Mime
View raw message