KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > menus > MenuLocationURI


1 /*******************************************************************************
2  * Copyright (c) 2006, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.ui.internal.menus;
13
14 import org.eclipse.ui.internal.util.Util;
15
16 /**
17  * Basic implementation of the java.net.URI api. This is
18  * needed because the java 'foundation' doesn't contain
19  * the actual <code>java.net.URI</code> class.
20  * <p>
21  * The expected format for URI Strings managed by this class is:
22  * </p><p>
23  * "[scheme]:[path]?[query]"
24  * </p><p>
25  * with the 'query' format being "[id1]=[val1]&[id2]=[val2]..."
26  * </p>
27  * @since 3.3
28  *
29  */

30 public class MenuLocationURI {
31
32     private String JavaDoc rawString;
33     
34     /**
35      * @param uriDef
36      */

37     public MenuLocationURI(String JavaDoc uriDef) {
38         rawString = uriDef;
39     }
40
41     /**
42      * @return The query part of the uri (i.e. the
43      * part after the '?').
44      */

45     public String JavaDoc getQuery() {
46         // Trim off the scheme
47
String JavaDoc[] vals = Util.split(rawString, '?');
48         return vals[1];
49     }
50
51     /**
52      * @return The scheme part of the uri (i.e. the
53      * part before the ':').
54      */

55     public String JavaDoc getScheme() {
56         String JavaDoc[] vals = Util.split(rawString, ':');
57         return vals[0];
58     }
59
60     /**
61      * @return The path part of the uri (i.e. the
62      * part between the ':' and the '?').
63      */

64     public String JavaDoc getPath() {
65         // Trim off the scheme
66
String JavaDoc[] vals = Util.split(rawString, ':');
67         if (vals[1] == null)
68             return null;
69         
70         // Now, trim off any query
71
vals = Util.split(vals[1], '?');
72         return vals[0];
73     }
74
75     /* (non-Javadoc)
76      * @see java.lang.Object#toString()
77      */

78     public String JavaDoc toString() {
79         return rawString;
80     }
81
82     /**
83      * @return the full URI definition string
84      */

85     public String JavaDoc getRawString() {
86         return rawString;
87     }
88 }
89
Popular Tags