jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r785535 - in /jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons: nodetype/compact/CompactNodeTypeDefWriter.java value/ValueFormat.java
Date Wed, 17 Jun 2009 10:06:59 GMT
Author: angela
Date: Wed Jun 17 10:06:58 2009
New Revision: 785535

URL: http://svn.apache.org/viewvc?rev=785535&view=rev
Log:
JCR-2152: ValueFormat should provide method getJCRString


Modified:
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/compact/CompactNodeTypeDefWriter.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/ValueFormat.java

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/compact/CompactNodeTypeDefWriter.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/compact/CompactNodeTypeDefWriter.java?rev=785535&r1=785534&r2=785535&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/compact/CompactNodeTypeDefWriter.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/compact/CompactNodeTypeDefWriter.java
Wed Jun 17 10:06:58 2009
@@ -26,7 +26,6 @@
 import javax.jcr.NamespaceException;
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
-import javax.jcr.Value;
 import javax.jcr.ValueFactory;
 import javax.jcr.version.OnParentVersionAction;
 
@@ -291,8 +290,8 @@
             for (int i = 0; i < dva.length; i++) {
                 out.write(delim);
                 try {
-                    Value v = ValueFormat.getJCRValue(dva[i], npResolver, valueFactory);
-                    out.write(escape(v.getString()));
+                    String str = ValueFormat.getJCRString(dva[i], npResolver);
+                    out.write(escape(str));
                 } catch (RepositoryException e) {
                     out.write(escape(dva[i].toString()));
                 }

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/ValueFormat.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/ValueFormat.java?rev=785535&r1=785534&r2=785535&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/ValueFormat.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/ValueFormat.java
Wed Jun 17 10:06:58 2009
@@ -189,4 +189,46 @@
             return jcrValue;
         }
     }
+
+    /**
+     * Returns the JCR string representation of the given <code>QValue</code>.
+     * This method is a shortcut for
+     * {@link #getJCRValue(QValue, NamePathResolver, ValueFactory)} followed by
+     * {@link Value#getString()}.
+     *
+     * @param qualifiedValue
+     * @param resolver
+     * @return the JCR String representation for the given <code>qualifiedValue</code>.
+     * @throws RepositoryException
+     */
+    public static String getJCRString(QValue qualifiedValue,
+                                      NamePathResolver resolver) throws RepositoryException
{
+        String jcrString;
+        int propertyType = qualifiedValue.getType();
+        switch (propertyType) {
+            case PropertyType.STRING:
+            case PropertyType.REFERENCE:
+            case PropertyType.WEAKREFERENCE:
+            case PropertyType.URI:
+            case PropertyType.BOOLEAN:
+            case PropertyType.DATE:
+            case PropertyType.DOUBLE:
+            case PropertyType.LONG:
+            case PropertyType.DECIMAL:
+            case PropertyType.BINARY:
+                jcrString = qualifiedValue.getString();
+                break;
+            case PropertyType.PATH:
+                Path qPath = qualifiedValue.getPath();
+                jcrString = resolver.getJCRPath(qPath);
+                break;
+            case PropertyType.NAME:
+                Name qName = qualifiedValue.getName();
+                jcrString = resolver.getJCRName(qName);
+                break;
+            default:
+                throw new RepositoryException("illegal internal value type");
+        }
+        return jcrString;
+    }
 }
\ No newline at end of file



Mime
View raw message