KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > soto > state > cocoon > standalone > StateIdParser


1 package org.sapia.soto.state.cocoon.standalone;
2
3 /**
4  * @author Yanick Duchesne
5  *
6  * <dl>
7  * <dt><b>Copyright:</b><dd>Copyright &#169; 2002-2004 <a HREF="http://www.sapia-oss.org">Sapia Open Source Software</a>. All Rights Reserved.</dd></dt>
8  * <dt><b>License:</b><dd>Read the license.txt file of the jar or visit the
9  * <a HREF="http://www.sapia-oss.org/license.html">license page</a> at the Sapia OSS web site</dd></dt>
10  * </dl>
11  */

12 public class StateIdParser {
13     
14     private static final char DOT = '.';
15     private static final char SLASH = '/';
16     
17     static class Created{
18         public String JavaDoc state;
19         public String JavaDoc module;
20     }
21     
22     static Created parseStateFrom(String JavaDoc path){
23         
24         Created c = new Created();
25         
26         if(path.charAt(0) == SLASH){
27             path = path.substring(1);
28         }
29         
30         int idx = path.lastIndexOf(SLASH);
31         if(idx > 0){
32             path = path.substring(idx+1);
33         }
34         idx = path.lastIndexOf(DOT);
35         if(idx > 0){
36             c.module = path.substring(0, idx);
37             c.state = path.substring(idx+1);
38             return c;
39         }
40         else{
41             c.state = path;
42             return c;
43         }
44     }
45
46 }
47
Popular Tags