You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by an...@apache.org on 2009/06/03 15:52:51 UTC

svn commit: r781377 - in /jackrabbit/trunk/jackrabbit-jcr-commons/src: main/java/org/apache/jackrabbit/ main/java/org/apache/jackrabbit/name/ main/java/org/apache/jackrabbit/util/ main/java/org/apache/jackrabbit/value/ test/java/org/apache/jackrabbit/n...

Author: angela
Date: Wed Jun  3 13:52:50 2009
New Revision: 781377

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

Removed:
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/BaseException.java
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/name/AbstractNamespaceResolver.java
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/name/CachingNameResolver.java
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/name/CachingPathResolver.java
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/name/GenerationalCache.java
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/name/NameCache.java
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/name/NamePathResolver.java
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/name/NameResolver.java
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/name/NamespaceListener.java
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/name/NamespaceResolver.java
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/name/NoPrefixDeclaredException.java
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/name/ParsingNameResolver.java
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/name/ParsingPathResolver.java
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/name/Path.java
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/name/PathResolver.java
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/name/QName.java
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/name/SessionNamespaceResolver.java
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/name/UnknownPrefixException.java
    jackrabbit/trunk/jackrabbit-jcr-commons/src/test/java/org/apache/jackrabbit/name/
Modified:
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/name/IllegalNameException.java
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/name/NameException.java
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/name/NameFormat.java
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/name/PathFormat.java
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/util/ISO9075.java
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/NameValue.java
    jackrabbit/trunk/jackrabbit-jcr-commons/src/test/java/org/apache/jackrabbit/util/ISO9075Test.java
    jackrabbit/trunk/jackrabbit-jcr-commons/src/test/java/org/apache/jackrabbit/util/TextTest.java

Modified: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/name/IllegalNameException.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/name/IllegalNameException.java?rev=781377&r1=781376&r2=781377&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/name/IllegalNameException.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/name/IllegalNameException.java Wed Jun  3 13:52:50 2009
@@ -19,9 +19,7 @@
 /**
  * Thrown when an illegal JCR name string is encountered. This exception is
  * thrown when attempting to parse a JCR name string that does not match the
- * JCR name syntax, or is otherwise not a legal name. Note that an
- * {@link UnknownPrefixException} is thrown if the prefix of the JCR name
- * string is syntactically valid but not bound to any namespace.
+ * JCR name syntax, or is otherwise not a legal name.
  * <p>
  * See the section 4.6 of the JCR 1.0 specification for details of the
  * JCR name syntax.

Modified: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/name/NameException.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/name/NameException.java?rev=781377&r1=781376&r2=781377&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/name/NameException.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/name/NameException.java Wed Jun  3 13:52:50 2009
@@ -16,8 +16,6 @@
  */
 package org.apache.jackrabbit.name;
 
-import org.apache.jackrabbit.BaseException;
-
 /**
  * Base class for exceptions about malformed or otherwise
  * invalid JCR names and paths.
@@ -26,7 +24,7 @@
  *             the org.apache.jackrabbit.spi.commons.conversion package of
  *             the jackrabbit-spi-commons component.
  */
-public class NameException extends BaseException {
+public class NameException extends Exception {
 
     /**
      * Creates a NameException with the given error message.

Modified: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/name/NameFormat.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/name/NameFormat.java?rev=781377&r1=781376&r2=781377&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/name/NameFormat.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/name/NameFormat.java Wed Jun  3 13:52:50 2009
@@ -18,7 +18,6 @@
 
 import org.apache.jackrabbit.util.XMLChar;
 
-import javax.jcr.NamespaceException;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -56,73 +55,6 @@
     };
 
     /**
-     * Converts the <code>jcrName</code> to its corresponding <code>QName</code>.
-     * If the <code>resolver</code> passed is also an instance of
-     * {@link NameCache} then this method first attempts to find the
-     * corresponding <code>QName</code> in the cache. If it cannot be found then
-     * the <code>jcrName</code> is parsed and the corresponding
-     * <code>QName</code> constructed.
-     *
-     * @param jcrName  the JCR-style name to be parsed
-     * @param resolver <code>NamespaceResolver</code> used for resolving
-     *                 prefixes into namespace URIs
-     * @return the resulting <code>QName</code>
-     * @throws IllegalNameException If <code>jcrName</code> is not a valid
-     *                              JCR-style name.
-     */
-    public static QName parse(String jcrName, NamespaceResolver resolver)
-            throws IllegalNameException, UnknownPrefixException {
-
-        if (resolver instanceof NameCache) {
-            QName name = ((NameCache) resolver).retrieveName(jcrName);
-            if (name == null) {
-                name = parseIgnoreCache(jcrName, resolver);
-                ((NameCache) resolver).cacheName(jcrName, name);
-            }
-            return name;
-        } else {
-            return parseIgnoreCache(jcrName, resolver);
-        }
-    }
-
-    /**
-     * Converts each JCR-style name in the passed array to its corresponding
-     * <code>QName</code> and returns the resulting <code>QName</code> array.
-     * If the <code>resolver</code> passed is also an instance of
-     * {@link NameCache} then this method first attempts to find the
-     * corresponding <code>QName</code> in the cache. If it cannot be found then
-     * the <code>jcrName</code> is parsed and the corresponding
-     * <code>QName</code> constructed.
-     *
-     * @param jcrNames the array of JCR-style names to be parsed
-     * @param resolver <code>NamespaceResolver</code> used for resolving
-     *                 prefixes into namespace URIs
-     * @return the resulting <code>QName</code> array
-     * @throws IllegalNameException If any of the passed names is not a valid
-     *                              JCR-style name.
-     */
-    public static QName[] parse(String jcrNames[], NamespaceResolver resolver)
-            throws IllegalNameException, UnknownPrefixException {
-
-        QName[] ret = new QName[jcrNames.length];
-        if (resolver instanceof NameCache) {
-            for (int i = 0; i < ret.length; i++) {
-                QName name = ((NameCache) resolver).retrieveName(jcrNames[i]);
-                if (name == null) {
-                    name = parseIgnoreCache(jcrNames[i], resolver);
-                    ((NameCache) resolver).cacheName(jcrNames[i], name);
-                }
-                ret[i] = name;
-            }
-        } else {
-            for (int i = 0; i < ret.length; i++) {
-                ret[i] = parseIgnoreCache(jcrNames[i], resolver);
-            }
-        }
-        return ret;
-    }
-
-    /**
      * Checks if <code>jcrName</code> is a valid JCR-style name.
      *
      * @param jcrName the name to be checked
@@ -133,135 +65,7 @@
         doParse(jcrName);
     }
 
-    /**
-     * Formats the given <code>QName</code> to produce a string representation,
-     * i.e. JCR-style name. If the <code>resolver</code> passed is also an
-     * instance of {@link NameCache} then this method first attempts to find the
-     * corresponding JCR-style name in the cache. If it cannot be found then
-     * a new string representation is constructed.
-     *
-     * @param qName    the <code>QName</code> to format
-     * @param resolver <code>NamespaceResolver</code> used for resolving
-     *                 namespace URIs into prefixes
-     * @return the string representation (JCR-style name) of the given
-     *         <code>QName</code>
-     * @throws NoPrefixDeclaredException if a namespace can not be resolved
-     * @see #format(QName, NamespaceResolver, StringBuffer)
-     */
-    public static String format(QName qName, NamespaceResolver resolver)
-            throws NoPrefixDeclaredException {
-
-        if (resolver instanceof NameCache) {
-            String jcrName = ((NameCache) resolver).retrieveName(qName);
-            if (jcrName == null) {
-                StringBuffer buf = new StringBuffer();
-                formatIgnoreCache(qName, resolver, buf);
-                jcrName = buf.toString();
-                ((NameCache) resolver).cacheName(jcrName, qName);
-            }
-            return jcrName;
-
-        } else {
-            StringBuffer buf = new StringBuffer();
-            formatIgnoreCache(qName, resolver, buf);
-            return buf.toString();
-        }
-    }
-
-    /**
-     * Same as {@link #format(QName, NamespaceResolver)} except that this
-     * method takes an array of <code>QName</code>s and returns an array of
-     * corresponding string representations.
-     *
-     * @param qNames   the array <code>QName</code>s to format
-     * @param resolver <code>NamespaceResolver</code> used for resolving
-     *                 namespace URIs into prefixes
-     * @return the array of corresponding string representations
-     * @throws NoPrefixDeclaredException if a namespace can not be resolved
-     * @see #format(QName, NamespaceResolver)
-     */
-    public static String[] format(QName[] qNames, NamespaceResolver resolver)
-            throws NoPrefixDeclaredException {
-        String[] ret = new String[qNames.length];
-        if (resolver instanceof NameCache) {
-            for (int i = 0; i < ret.length; i++) {
-                String jcrName = ((NameCache) resolver).retrieveName(qNames[i]);
-                if (jcrName == null) {
-                    StringBuffer buf = new StringBuffer();
-                    formatIgnoreCache(qNames[i], resolver, buf);
-                    jcrName = buf.toString();
-                    ((NameCache) resolver).cacheName(jcrName, qNames[i]);
-                }
-                ret[i] = jcrName;
-            }
-        } else {
-            for (int i = 0; i < ret.length; i++) {
-                StringBuffer buf = new StringBuffer();
-                formatIgnoreCache(qNames[i], resolver, buf);
-                ret[i] = buf.toString();
-            }
-        }
-        return ret;
-    }
-
-    /**
-     * Same as {@link #format(QName, NamespaceResolver)} except that this
-     * method appends the JCR-style name to the given <code>buffer</code> rather
-     * than returning it directly.
-     *
-     * @param qName    the <code>QName</code> to format
-     * @param resolver <code>NamespaceResolver</code> used for resolving
-     *                 namespace URIs into prefixes
-     * @param buffer   StringBuffer where the string representation should be
-     *                 appended to
-     * @throws NoPrefixDeclaredException if a namespace can not be resolved
-     */
-    public static void format(QName qName, NamespaceResolver resolver,
-                              StringBuffer buffer)
-            throws NoPrefixDeclaredException {
-
-        if (resolver instanceof NameCache) {
-            String jcrName = ((NameCache) resolver).retrieveName(qName);
-            if (jcrName == null) {
-                int l = buffer.length();
-                formatIgnoreCache(qName, resolver, buffer);
-                ((NameCache) resolver).cacheName(buffer.substring(l), qName);
-            } else {
-                buffer.append(jcrName);
-            }
-        } else {
-            formatIgnoreCache(qName, resolver, buffer);
-        }
-    }
-
     //-------------------------------------------------------< implementation >
-    /**
-     * Converts the <code>jcrName</code> to its corresponding <code>QName</code>.
-     * <p/>
-     * Note that unlike {@link #parse(String, NamespaceResolver)} this method
-     * always constructs a new <code>QName</code>, ignoring potential caching
-     * capabilities of the passed <code>resolver</code>.
-     *
-     * @param jcrName  the JCR-style name to be parsed
-     * @param resolver <code>NamespaceResolver</code> used for resolving
-     *                 prefixes into namespace URIs
-     * @return the resulting <code>QName</code>
-     * @throws IllegalNameException If <code>jcrName</code> is not a valid
-     *                              JCR-style name.
-     * @see #parse(String, NamespaceResolver)
-     */
-    private static QName parseIgnoreCache(String jcrName,
-                                          NamespaceResolver resolver)
-            throws IllegalNameException, UnknownPrefixException {
-        String[] parts = doParse(jcrName);
-        String uri;
-        try {
-            uri = resolver.getURI(parts[0]);
-        } catch (NamespaceException nse) {
-            throw new UnknownPrefixException(parts[0]);
-        }
-        return new QName(uri, parts[1]);
-    }
 
     /**
      * Parses the <code>jcrName</code> and returns an array of two strings:
@@ -315,42 +119,4 @@
 
         return new String[]{prefix, localName};
     }
-
-    /**
-     * Formats the given <code>QName</code> to produce a string representation,
-     * i.e. JCR-style name.
-     * <p/>
-     * Note that unlike {@link #format(QName, NamespaceResolver)} this method
-     * always constructs a new <code>String</code>, ignoring potential caching
-     * capabilities of the passed <code>resolver</code>.
-     *
-     * @param qName    the <code>QName</code> to format
-     * @param resolver <code>NamespaceResolver</code> used for resolving
-     *                 namespace URIs into prefixes
-     * @param buffer   StringBuffer where the prefixed JCR name should be
-     *                 appended to
-     * @throws NoPrefixDeclaredException if a namespace can not be resolved
-     * @see #format(QName, NamespaceResolver)
-     */
-    private static void formatIgnoreCache(QName qName,
-                                          NamespaceResolver resolver,
-                                          StringBuffer buffer)
-            throws NoPrefixDeclaredException {
-        // prefix
-        String prefix;
-        try {
-            prefix = resolver.getPrefix(qName.getNamespaceURI());
-        } catch (NamespaceException nse) {
-            throw new NoPrefixDeclaredException("no prefix declared for URI: "
-                    + qName.getNamespaceURI());
-        }
-        if (prefix.length() == 0) {
-            // default prefix (empty string)
-        } else {
-            buffer.append(prefix);
-            buffer.append(':');
-        }
-        // name
-        buffer.append(qName.getLocalName());
-    }
 }

Modified: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/name/PathFormat.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/name/PathFormat.java?rev=781377&r1=781376&r2=781377&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/name/PathFormat.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/name/PathFormat.java Wed Jun  3 13:52:50 2009
@@ -17,15 +17,12 @@
 package org.apache.jackrabbit.name;
 
 import org.apache.jackrabbit.util.Text;
-import org.apache.jackrabbit.util.XMLChar;
 
-import javax.jcr.NamespaceException;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 /**
- * <code>PathFormat</code> formats a {@link Path} using a
- * {@link NamespaceResolver}.
+ * <code>PathFormat</code> checks the formt .
  *
  * @deprecated Use the PathResolver interface from
  *             the org.apache.jackrabbit.spi.commons.conversion package of
@@ -62,54 +59,19 @@
     };
 
     /**
-     * Parses <code>jcrPath</code> into a qualified path using
-     * <code>resolver</code> to convert prefixes into namespace URI's.
-     *
-     * @param jcrPath the jcr path.
-     * @param resolver the namespace resolver.
-     * @return qualified path.
-     * @throws MalformedPathException if <code>jcrPath</code> is malformed.
-     */
-    public static Path parse(String jcrPath, NamespaceResolver resolver)
-            throws MalformedPathException {
-        return parse(null, jcrPath, resolver);
-    }
-
-    /**
-     * Parses the give <code>jcrPath</code> and returns a <code>Path</code>. If
-     * <code>parent</code> is not <code>null</code>, it is prepended to the
-     * returned list. If <code>resolver</code> is <code>null</code>, this method
-     * only checks the format of the string and returns <code>null</code>.
+     * Checks if <code>jcrPath</code> is a valid JCR-style absolute or relative
+     * path.
      *
-     * @param parent   the parent path
-     * @param jcrPath  the JCR path
-     * @param resolver the namespace resolver to get prefixes for namespace
-     *                 URI's.
-     * @return the fully qualified Path.
-     * @throws MalformedPathException if <code>jcrPath</code> is malformed.
+     * @param jcrPath the path to be checked
+     * @throws MalformedPathException If <code>jcrPath</code> is not a valid
+     *                                JCR-style path.
      */
-    public static Path parse(Path parent, String jcrPath, NamespaceResolver resolver)
-            throws MalformedPathException {
-        // shortcut
-        if ("/".equals(jcrPath)) {
-            return Path.ROOT;
-        }
-
+    public static void checkFormat(String jcrPath) throws MalformedPathException {
         // split path into path elements
         String[] elems = Text.explode(jcrPath, '/', true);
         if (elems.length == 0) {
             throw new MalformedPathException("empty path");
         }
-
-        Path.PathBuilder pathBuilder;
-        if (parent != null) {
-            // a parent path was specified; the 'jcrPath' argument is assumed
-            // to be a relative path
-            pathBuilder = new Path.PathBuilder(parent);
-        } else {
-            pathBuilder = new Path.PathBuilder();
-        }
-
         for (int i = 0; i < elems.length; i++) {
             // validate & parse path element
             String prefix;
@@ -119,10 +81,6 @@
             String elem = elems[i];
             if (i == 0 && elem.length() == 0) {
                 // path is absolute, i.e. the first element is the root element
-                if (parent != null) {
-                    throw new MalformedPathException("'" + jcrPath + "' is not a relative path");
-                }
-                pathBuilder.addLast(Path.ROOT_ELEMENT);
                 continue;
             }
             if (elem.length() == 0 && i == elems.length - 1) {
@@ -131,145 +89,12 @@
             }
             Matcher matcher = (Matcher) PATH_ELEMENT_MATCHER.get();
             matcher.reset(elem);
-            if (matcher.matches()) {
-                if (resolver == null) {
-                    // check only
-                    continue;
-                }
-
-                if (matcher.group(1) != null) {
-                    // group 1 is .
-                    pathBuilder.addLast(Path.CURRENT_ELEMENT);
-                } else if (matcher.group(2) != null) {
-                    // group 2 is ..
-                    pathBuilder.addLast(Path.PARENT_ELEMENT);
-                } else {
-                    // element is a name
-
-                    // check for prefix (group 3)
-                    if (matcher.group(3) != null) {
-                        // prefix specified
-                        // group 4 is namespace prefix excl. delimiter (colon)
-                        prefix = matcher.group(4);
-                        // check if the prefix is a valid XML prefix
-                        if (!XMLChar.isValidNCName(prefix)) {
-                            // illegal syntax for prefix
-                            throw new MalformedPathException("'" + jcrPath + "' is not a valid path: '"
-                                    + elem + "' specifies an illegal namespace prefix");
-                        }
-                    } else {
-                        // no prefix specified
-                        prefix = "";
-                    }
-
-                    // group 5 is localName
-                    localName = matcher.group(5);
-
-                    // check for index (group 6)
-                    if (matcher.group(6) != null) {
-                        // index specified
-                        // group 7 is index excl. brackets
-                        index = Integer.parseInt(matcher.group(7));
-                    } else {
-                        // no index specified
-                        index = org.apache.jackrabbit.name.Path.INDEX_UNDEFINED;
-                    }
-
-                    String nsURI;
-                    try {
-                        nsURI = resolver.getURI(prefix);
-                    } catch (NamespaceException nse) {
-                        // unknown prefix
-                        throw new MalformedPathException("'" + jcrPath + "' is not a valid path: '"
-                                + elem + "' specifies an unmapped namespace prefix");
-                    }
-
-                    if (index == org.apache.jackrabbit.name.Path.INDEX_UNDEFINED) {
-                        pathBuilder.addLast(new QName(nsURI, localName));
-                    } else {
-                        pathBuilder.addLast(new QName(nsURI, localName), index);
-                    }
-                }
-            } else {
+            
+            if (!matcher.matches()) {
                 // illegal syntax for path element
                 throw new MalformedPathException("'" + jcrPath + "' is not a valid path: '"
                         + elem + "' is not a legal path element");
             }
         }
-        if (resolver != null) {
-            return pathBuilder.getPath();
-        } else {
-            return null;
-        }
-    }
-
-    /**
-     * Checks if <code>jcrPath</code> is a valid JCR-style absolute or relative
-     * path.
-     *
-     * @param jcrPath the path to be checked
-     * @throws MalformedPathException If <code>jcrPath</code> is not a valid
-     *                                JCR-style path.
-     */
-    public static void checkFormat(String jcrPath) throws MalformedPathException {
-        parse(null, jcrPath, null);
-    }
-
-    /**
-     * Returns a string representation of the qualified <code>path</code> in the
-     * JCR path format.
-     *
-     * @param path the qualified path to resolve.
-     * @param resolver the namespace resolver.
-     * @return JCR the formatted path.
-     * @throws NoPrefixDeclaredException if a namespace can not be resolved
-     */
-    public static String format(Path path, NamespaceResolver resolver)
-            throws NoPrefixDeclaredException {
-        if (path.denotesRoot()) {
-            // shortcut
-            return "/";
-        }
-        StringBuffer sb = new StringBuffer();
-        for (int i = 0; i < path.getLength(); i++) {
-            if (i > 0) {
-                sb.append('/');
-            }
-            // name
-            format(path.getElement(i), resolver, sb);
-        }
-        return sb.toString();
-    }
-
-    //-----------------------------------------------------------< internal >---
-
-    /**
-     * Appends the JCR name representation of this path element to the given
-     * string buffer.
-     *
-     * @param element  the path element to format.
-     * @param resolver namespace resolver
-     * @param buf      string buffer where the JCR name representation should be
-     *                 appended to
-     * @throws NoPrefixDeclaredException if the namespace of the path element
-     *                                   name can not be resolved
-     */
-    private static void format(Path.PathElement element,
-                               NamespaceResolver resolver, StringBuffer buf)
-            throws NoPrefixDeclaredException {
-        // name
-        NameFormat.format(element.getName(), resolver, buf);
-        // index
-        int index = element.getIndex();
-        /**
-         * FIXME the [1] subscript should only be suppressed if the item
-         * in question can't have same-name siblings.
-         */
-        //if (index > 0) {
-        if (index > org.apache.jackrabbit.name.Path.INDEX_DEFAULT) {
-            buf.append('[');
-            buf.append(index);
-            buf.append(']');
-        }
     }
 }

Modified: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/util/ISO9075.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/util/ISO9075.java?rev=781377&r1=781376&r2=781377&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/util/ISO9075.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/util/ISO9075.java Wed Jun  3 13:52:50 2009
@@ -16,8 +16,6 @@
  */
 package org.apache.jackrabbit.util;
 
-import org.apache.jackrabbit.name.QName;
-
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -25,11 +23,7 @@
  * Implements the encode and decode routines as specified for XML name to SQL
  * identifier conversion in ISO 9075-14:2003.<br/>
  * If a character <code>c</code> is not valid at a certain position in an XML 1.0
- * NCName it is encoded in the form: '_x' + hexValueOf(c) + '_'
- * <p/>
- * Note that only the local part of a {@link org.apache.jackrabbit.name.QName}
- * is encoded / decoded. A URI namespace will always be valid and does not
- * need encoding.
+ * NCName it is encoded in the form: '_x' + hexValueOf(c) + '_'.
  */
 public class ISO9075 {
 
@@ -46,21 +40,6 @@
     private static final String HEX_DIGITS = "0123456789abcdefABCDEF";
 
     /**
-     * Encodes the local part of <code>name</code> as specified in ISO 9075.
-     * @param name the <code>QName</code> to encode.
-     * @return the encoded <code>QName</code> or <code>name</code> if it does
-     *   not need encoding.
-     */
-    public static QName encode(QName name) {
-        String encoded = encode(name.getLocalName());
-        if (encoded == name.getLocalName()) {
-            return name;
-        } else {
-            return new QName(name.getNamespaceURI(), encoded);
-        }
-    }
-
-    /**
      * Encodes <code>name</code> as specified in ISO 9075.
      * @param name the <code>String</code> to encode.
      * @return the encoded <code>String</code> or <code>name</code> if it does
@@ -138,20 +117,6 @@
 
     /**
      * Decodes the <code>name</code>.
-     * @param name the <code>QName</code> to decode.
-     * @return the decoded <code>QName</code>.
-     */
-    public static QName decode(QName name) {
-        String decoded = decode(name.getLocalName());
-        if (decoded == name.getLocalName()) {
-            return name;
-        } else {
-            return new QName(name.getNamespaceURI(), decoded);
-        }
-    }
-
-    /**
-     * Decodes the <code>name</code>.
      * @param name the <code>String</code> to decode.
      * @return the decoded <code>String</code>.
      */

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=781377&r1=781376&r2=781377&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 Wed Jun  3 13:52:50 2009
@@ -18,9 +18,6 @@
 
 import org.apache.jackrabbit.name.NameFormat;
 import org.apache.jackrabbit.name.IllegalNameException;
-import org.apache.jackrabbit.name.QName;
-import org.apache.jackrabbit.name.NamespaceResolver;
-import org.apache.jackrabbit.name.NoPrefixDeclaredException;
 
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
@@ -86,27 +83,6 @@
         }
     }
 
-    /**
-     * Returns a new <code>NameValue</code> initialized to the value represented
-     * by the specified <code>QName</code> formatted to a string using the
-     * specified <code>resolver</code>.
-     *
-     * @param name     the name to format.
-     * @param resolver a namespace resolver the resolve the URI in the name to a
-     *                 prefix.
-     * @return a newly constructed <code>NameValue</code> representing the the
-     *         specified value.
-     * @throws ValueFormatException If the <code>QName</code> contains a URI
-     *                              that is not known to <code>resolver</code>.
-     */
-    public static NameValue valueOf(QName name, NamespaceResolver resolver)
-            throws ValueFormatException {
-        try {
-            return new NameValue(NameFormat.format(name, resolver));
-        } catch (NoPrefixDeclaredException e) {
-            throw new ValueFormatException(e.getMessage());
-        }
-    }
 
     /**
      * Protected constructor creating a <code>NameValue</code> object

Modified: jackrabbit/trunk/jackrabbit-jcr-commons/src/test/java/org/apache/jackrabbit/util/ISO9075Test.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/test/java/org/apache/jackrabbit/util/ISO9075Test.java?rev=781377&r1=781376&r2=781377&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-commons/src/test/java/org/apache/jackrabbit/util/ISO9075Test.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-commons/src/test/java/org/apache/jackrabbit/util/ISO9075Test.java Wed Jun  3 13:52:50 2009
@@ -16,7 +16,6 @@
  */
 package org.apache.jackrabbit.util;
 
-import org.apache.jackrabbit.name.QName;
 import junit.framework.TestCase;
 
 /**
@@ -61,37 +60,4 @@
         assertEquals("year/_x0032_007", ISO9075.encodePath("year/2007"));
         assertEquals("year/_x0032_007[2]", ISO9075.encodePath("year/2007[2]"));
     }
-
-    /**
-     * This is a disabled brute force test. It tests permutations of characters:
-     * <code>' ', '_', 'x', '0', '2', 'a', 'b', '{'</code>, encodes and decodes
-     * the sequences and test whether the initial sequence equals the resulting
-     * sequence that went through the encoding / decoding process.
-     * </p>
-     * The test takes about 30 seconds on my 1.2G P3.
-     * </p>
-     * To enable the test remove the 'disabled_' refix from the method name.
-     */
-    public void disabled_testBrute() {
-        char[] chars = new char[] {' ', '_', 'x', '0', '2', 'a', 'b', '{'};
-        long start = Long.parseLong("1000000", 8);
-        long end = Long.parseLong("7777777", 8);
-        for (long i = start; i < end; i++) {
-            String s = Long.toString(i, chars.length);
-            StringBuffer b = new StringBuffer(s.length());
-            for (int j = 0; j < s.length(); j++) {
-                b.append(chars[s.charAt(j) - '0']);
-            }
-            // encode and decode
-            QName initial = new QName("", b.toString());
-            if ((i % 100000) == 0) {
-                System.out.println(initial);
-            }
-            QName encoded = ISO9075.encode(initial);
-            assertTrue(XMLChar.isValidName(encoded.getLocalName()));
-            QName decoded = ISO9075.decode(encoded);
-            assertEquals(initial, decoded);
-        }
-    }
-
 }

Modified: jackrabbit/trunk/jackrabbit-jcr-commons/src/test/java/org/apache/jackrabbit/util/TextTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/test/java/org/apache/jackrabbit/util/TextTest.java?rev=781377&r1=781376&r2=781377&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-commons/src/test/java/org/apache/jackrabbit/util/TextTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-commons/src/test/java/org/apache/jackrabbit/util/TextTest.java Wed Jun  3 13:52:50 2009
@@ -22,9 +22,6 @@
 
 import junit.framework.TestCase;
 
-import org.apache.jackrabbit.name.IllegalNameException;
-import org.apache.jackrabbit.name.NameFormat;
-
 /**
  * Test cases for the Text utility class.
  */
@@ -32,11 +29,6 @@
 
     private void checkEscape(String name) {
         String escaped = Text.escapeIllegalJcrChars(name);
-        try {
-            NameFormat.checkFormat(escaped);
-        } catch (IllegalNameException e) {
-            fail("Illegal name: " + escaped);
-        }
         assertEquals(name, Text.unescapeIllegalJcrChars(escaped));
     }