01: /*******************************************************************************
02: * Copyright (c) 2006, 2007 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.ui.internal.menus;
11:
12: import org.eclipse.ui.internal.util.Util;
13:
14: /**
15: * Basic implementation of the java.net.URI api. This is
16: * needed because the java 'foundation' doesn't contain
17: * the actual <code>java.net.URI</code> class.
18: * <p>
19: * The expected format for URI Strings managed by this class is:
20: * </p><p>
21: * "[scheme]:[path]?[query]"
22: * </p><p>
23: * with the 'query' format being "[id1]=[val1]&[id2]=[val2]..."
24: * </p>
25: * @since 3.3
26: *
27: */
28: public class MenuLocationURI {
29:
30: private String rawString;
31:
32: /**
33: * @param uriDef
34: */
35: public MenuLocationURI(String uriDef) {
36: rawString = uriDef;
37: }
38:
39: /**
40: * @return The query part of the uri (i.e. the
41: * part after the '?').
42: */
43: public String getQuery() {
44: // Trim off the scheme
45: String[] vals = Util.split(rawString, '?');
46: return vals[1];
47: }
48:
49: /**
50: * @return The scheme part of the uri (i.e. the
51: * part before the ':').
52: */
53: public String getScheme() {
54: String[] vals = Util.split(rawString, ':');
55: return vals[0];
56: }
57:
58: /**
59: * @return The path part of the uri (i.e. the
60: * part between the ':' and the '?').
61: */
62: public String getPath() {
63: // Trim off the scheme
64: String[] vals = Util.split(rawString, ':');
65: if (vals[1] == null)
66: return null;
67:
68: // Now, trim off any query
69: vals = Util.split(vals[1], '?');
70: return vals[0];
71: }
72:
73: /* (non-Javadoc)
74: * @see java.lang.Object#toString()
75: */
76: public String toString() {
77: return rawString;
78: }
79:
80: /**
81: * @return the full URI definition string
82: */
83: public String getRawString() {
84: return rawString;
85: }
86: }
|