KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > util > xml > XmlUtil


1 package org.sapia.util.xml;
2
3
4 /**
5  * This class contains some utility methods use by the Sapia XML tools.
6  *
7  * @author Jean-Cedric Desrochers
8  * <dl>
9  * <dt><b>Copyright:</b><dd>Copyright &#169; 2002-2003 <a HREF="http://www.sapia-oss.org">Sapia Open Source Software</a>. All Rights Reserved.</dd></dt>
10  * <dt><b>License:</b><dd>Read the license.txt file of the jar or visit the
11  * <a HREF="http://www.sapia-oss.org/license.html">license page</a> at the Sapia OSS web site</dd></dt>
12  * </dl>
13  */

14 public class XmlUtil {
15   /** Defines the ":" delimiter that separates local name and prefix */
16   private static final char PREFIX_SEPARATOR = ':';
17
18   /**
19    * Extract the namespace prefix from the qualified element name passed in.
20    * If the the qualified name passed in is null, it returns null.
21    *
22    * @param aQualifiedName The qualified name from which to extract the prefix.
23    * @return The extracted prefix or null if the qualified name is null;
24    */

25   public static String JavaDoc extractPrefix(String JavaDoc aQualifiedName) {
26     String JavaDoc aPrefix = null;
27
28     if (aQualifiedName != null) {
29       int anIndex = aQualifiedName.indexOf(PREFIX_SEPARATOR);
30
31       if (anIndex > -1) {
32         aPrefix = aQualifiedName.substring(0, anIndex);
33       }
34     }
35
36     return aPrefix;
37   }
38 }
39
Popular Tags