KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > gumby > tags > support > ScopeIdParser


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

18 public class ScopeIdParser {
19
20   public static final int ID = 0;
21   public static final int SCOPE = 1;
22
23   /**
24    * @param idAndScope
25    * a string that represents an id/scope combination, in the format:
26    * <code>id:scope</code>. The scope is optional.
27    * @return an array of strings of length 1 if no scope was specified (the
28    * array will contain the id). Otherwise, an array of strings of
29    * length 2 that will hold the id at the first position, and the scope
30    * at the second.
31    */

32   public static String JavaDoc[] parse(String JavaDoc idAndScope) {
33     int i = idAndScope.indexOf(':');
34     if(i < 0) {
35       return new String JavaDoc[] { idAndScope };
36     }
37     return new String JavaDoc[] { idAndScope.substring(0, i),
38         idAndScope.substring(i + 1) };
39   }
40
41 }
42
Popular Tags