01: /*******************************************************************************
02: * Copyright (c) 2004, 2006 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.intro.config;
11:
12: import org.eclipse.ui.internal.intro.impl.model.url.IntroURL;
13: import org.eclipse.ui.internal.intro.impl.model.url.IntroURLParser;
14:
15: /**
16: * Factory class used to create instances of an Intro URL. Instances of intro
17: * URLs need to be created if you need to programatically construct and execute
18: * a valid Intro URL.
19: * <p>
20: * This class provides all its functionality via static members. It is not
21: * intended to be instantiated.
22: * </p>
23: *
24: * @see IIntroURL
25: * @since 3.0
26: */
27: public final class IntroURLFactory {
28:
29: /**
30: * Non-instantiable.
31: */
32: private IntroURLFactory() {
33: // do nothing
34: }
35:
36: /**
37: * Parses the given string, and returns an IntroURL if the string is a valid
38: * Intro URL. Returns null in all other cases. Example usage:
39: *
40: * <pre>
41: * StringBuffer url = new StringBuffer();
42: * url.append("http://org.eclipse.ui.intro/showStandby?");
43: * url.append("pluginId=org.eclipse.pde.ui");
44: * url.append("&");
45: * url.append("partId=org.eclipse.pde.ui.sampleStandbyPart");
46: * url.append("&");
47: * url.append("input=");
48: * url.append(sampleId);
49: * IIntroURL introURL = IntroURLFactory.createIntroURL(url.toString());
50: * if (introURL != null) {
51: * introURL.execute();
52: * }
53: * </pre>
54: *
55: * @param url
56: * the url to construct an IntroURL from
57: * @return an IntroURL, or <code>null</code> if the url is invalid
58: */
59: public static IIntroURL createIntroURL(String url) {
60: IntroURLParser parser = new IntroURLParser(url);
61: if (parser.hasIntroUrl()) {
62: IntroURL introURL = parser.getIntroURL();
63: return introURL;
64: }
65: return null;
66: }
67:
68: }
|