KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > intro > config > IntroURLFactory


1 /*******************************************************************************
2  * Copyright (c) 2004, 2006 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.intro.config;
13
14 import org.eclipse.ui.internal.intro.impl.model.url.IntroURL;
15 import org.eclipse.ui.internal.intro.impl.model.url.IntroURLParser;
16
17 /**
18  * Factory class used to create instances of an Intro URL. Instances of intro
19  * URLs need to be created if you need to programatically construct and execute
20  * a valid Intro URL.
21  * <p>
22  * This class provides all its functionality via static members. It is not
23  * intended to be instantiated.
24  * </p>
25  *
26  * @see IIntroURL
27  * @since 3.0
28  */

29 public final class IntroURLFactory {
30
31     /**
32      * Non-instantiable.
33      */

34     private IntroURLFactory() {
35         // do nothing
36
}
37
38
39     /**
40      * Parses the given string, and returns an IntroURL if the string is a valid
41      * Intro URL. Returns null in all other cases. Example usage:
42      *
43      * <pre>
44      * StringBuffer url = new StringBuffer();
45      * url.append(&quot;http://org.eclipse.ui.intro/showStandby?&quot;);
46      * url.append(&quot;pluginId=org.eclipse.pde.ui&quot;);
47      * url.append(&quot;&amp;&quot;);
48      * url.append(&quot;partId=org.eclipse.pde.ui.sampleStandbyPart&quot;);
49      * url.append(&quot;&amp;&quot;);
50      * url.append(&quot;input=&quot;);
51      * url.append(sampleId);
52      * IIntroURL introURL = IntroURLFactory.createIntroURL(url.toString());
53      * if (introURL != null) {
54      * introURL.execute();
55      * }
56      * </pre>
57      *
58      * @param url
59      * the url to construct an IntroURL from
60      * @return an IntroURL, or <code>null</code> if the url is invalid
61      */

62     public static IIntroURL createIntroURL(String JavaDoc url) {
63         IntroURLParser parser = new IntroURLParser(url);
64         if (parser.hasIntroUrl()) {
65             IntroURL introURL = parser.getIntroURL();
66             return introURL;
67         }
68         return null;
69     }
70
71 }
72
Popular Tags