KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > oddjob > arooa > xml > NamespaceHelper


1 package org.oddjob.arooa.xml;
2
3 /**
4  * Utility functions to help with the namespace.
5  */

6 public class NamespaceHelper {
7
8     /**
9      * extract a uri from a component name
10      *
11      * @param componentName The stringified form for {uri, name}
12      * @return The uri or "" if not present
13      */

14     public static String JavaDoc extractUriFromComponentName(String JavaDoc componentName) {
15         if (componentName == null) {
16             return "";
17         }
18         int index = componentName.lastIndexOf(':');
19         if (index == -1) {
20             return "";
21         }
22         return componentName.substring(0, index);
23     }
24     
25     /**
26      * extract the element name from a component name
27      *
28      * @param componentName The stringified form for {uri, name}
29      * @return The element name of the component
30      */

31     public static String JavaDoc extractNameFromComponentName(String JavaDoc componentName) {
32         int index = componentName.lastIndexOf(':');
33         if (index == -1) {
34             return componentName;
35         }
36         return componentName.substring(index+1);
37     }
38
39 }
40
Popular Tags