jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r605171 - in /jackrabbit/trunk: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/InternalValue.java jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/NameValue.java
Date Tue, 18 Dec 2007 10:28:33 GMT
Author: mreutegg
Date: Tue Dec 18 02:28:31 2007
New Revision: 605171

URL: http://svn.apache.org/viewvc?rev=605171&view=rev
Log:
JCR-1273: Unnecessary parsing of Name value

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/InternalValue.java
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/NameValue.java

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=605171&r1=605170&r2=605171&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
Tue Dec 18 02:28:31 2007
@@ -377,7 +377,7 @@
             case PropertyType.PATH:
                 return PathValue.valueOf(resolver.getJCRPath((Path) val));
             case PropertyType.NAME:
-                return NameValue.valueOf(resolver.getJCRName((Name) val));
+                return NameValue.valueOf(resolver.getJCRName((Name) val), false);
             case PropertyType.STRING:
                 return new StringValue((String) val);
             default:

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=605171&r1=605170&r2=605171&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 Dec 18 02:28:31 2007
@@ -51,11 +51,33 @@
      *                              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 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) {
-            try {
-                NameFormat.checkFormat(s);
-            } catch (IllegalNameException ine) {
-                throw new ValueFormatException(ine.getMessage());
+            if (checkFormat) {
+                try {
+                    NameFormat.checkFormat(s);
+                } catch (IllegalNameException ine) {
+                    throw new ValueFormatException(ine.getMessage());
+                }
             }
             return new NameValue(s);
         } else {



Mime
View raw message