View Javadoc

1   /*** 
2   * This program is licensed under Common Public License Version 0.5.
3   *
4   * For License Information and conditions of use, see "LICENSE" in packaged
5   */
6   
7   package net.wangs.xmlutil;
8   
9   import java.util.Vector;
10  import java.util.StringTokenizer;
11  /*** 
12  * @author <a href="mailto:yuqingwang_99@yahoo.com">Yuqing Wang</a>
13  */
14  public class XStringParser {
15      /***
16      * Parse String into Vector. Token is _pathToken= "/"
17      * <pre>
18      * For example, "/AAA/BBB/CCC" is parsed into 
19      *       AAA
20      *       BBB
21      *       CCC
22      * The token at the beginning of string is not requied but is recommended.
23      * </pre>
24      * @param string - Directory style path to represent XML tree path
25      * @return Vector of XML tag name
26      */
27      public static Vector parseXString(String path) {
28          Vector vector = new Vector();
29          String tag = null;
30  
31          StringTokenizer tokenizer = new StringTokenizer (path, _pathToken);
32  
33          while (tokenizer.hasMoreTokens()) {
34              tag = tokenizer.nextToken();
35              vector.add(tag);
36          }
37  
38          return vector;
39      }
40  
41      /***
42      * @return String "/"
43      */
44      public static String getPathToken() {
45          return _pathToken;
46      }
47  
48      private static final String _pathToken = "/";
49  }