jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r220026 - /incubator/jackrabbit/trunk/commons/src/java/org/apache/jackrabbit/util/Text.java
Date Thu, 21 Jul 2005 09:57:38 GMT
Author: tripod
Date: Thu Jul 21 02:57:36 2005
New Revision: 220026

URL: http://svn.apache.org/viewcvs?rev=220026&view=rev
Log:
- adding useful namespace related methods

Modified:
    incubator/jackrabbit/trunk/commons/src/java/org/apache/jackrabbit/util/Text.java

Modified: incubator/jackrabbit/trunk/commons/src/java/org/apache/jackrabbit/util/Text.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/commons/src/java/org/apache/jackrabbit/util/Text.java?rev=220026&r1=220025&r2=220026&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/commons/src/java/org/apache/jackrabbit/util/Text.java (original)
+++ incubator/jackrabbit/trunk/commons/src/java/org/apache/jackrabbit/util/Text.java Thu Jul
21 02:57:36 2005
@@ -449,6 +449,43 @@
     }
 
     /**
+     * Returns the namespace prefix of the given <code>qname</code>. If the
+     * prefix is missing, an empty string is returned. Please note, that this
+     * method does not validate the name or prefix.
+     * </p>
+     * the qname has the format: qname := [prefix ':'] local;
+     *
+     * @param qname a qualified name
+     * @return the prefix of the name or "".
+     *
+     * @see #getLocalName(String)
+     *
+     * @throws NullPointerException if <code>qname</code> is <code>null</code>
+     */
+    public static String getNamespacePrefix(String qname) {
+        int pos = qname.indexOf(':');
+        return pos >=0 ? qname.substring(0, pos) : "";
+    }
+
+    /**
+     * Returns the local name of the given <code>qname</code>. Please note, that
+     * this method does not validate the name.
+     * </p>
+     * the qname has the format: qname := [prefix ':'] local;
+     *
+     * @param qname a qualified name
+     * @return the localname
+     *
+     * @see #getNamespacePrefix(String)
+     *
+     * @throws NullPointerException if <code>qname</code> is <code>null</code>
+     */
+    public static String getLocalName(String qname) {
+        int pos = qname.indexOf(':');
+        return pos >=0 ? qname.substring(pos+1) : qname;
+    }
+
+    /**
      * Returns the name part of the path, delimited by the given <code>delim</code>
      *
      * @param path the path



Mime
View raw message