Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 58355279cdd531f4c4dd518152e856062c2068d5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*******************************************************************************
* Copyright (c) 2010 Composent, Inc. and others. All rights reserved. This
* program and the accompanying materials are made available under the terms of
* the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
*   Composent, Inc. - initial API and implementation
******************************************************************************/
package org.eclipse.ecf.provider.local.identity;

import java.net.URI;
import java.net.URL;
import org.eclipse.ecf.core.identity.*;

public class LocalNamespace extends Namespace {

	private static final long serialVersionUID = 3536863430112969997L;
	public static final String NAME = "ecf.namespace.local"; //$NON-NLS-1$
	public static final String SCHEME = "local"; //$NON-NLS-1$

	public LocalNamespace() {
		super(NAME, "Local Namespace"); //$NON-NLS-1$
	}

	public ID createInstance(Object[] parameters) throws IDCreateException {
		try {
			final String init = getInitStringFromExternalForm(parameters);
			if (init != null) {
				return new LocalID(this, init);
			}
			if (parameters != null) {
				if (parameters[0] instanceof URI)
					return new LocalID(this, ((URI) parameters[0]).toString());
				else if (parameters[0] instanceof String)
					return new LocalID(this, (String) parameters[0]);
				else if (parameters[0] instanceof URL)
					return new LocalID(this, ((URL) parameters[0]).toExternalForm());
				else if (parameters[0] instanceof LocalID)
					return (ID) parameters[0];
			}
			return new LocalID(this, IDFactory.getDefault().createGUID().getName());
		} catch (Exception e) {
			throw new IDCreateException("Could not create rest ID", e); //$NON-NLS-1$
		}
	}

	public String getScheme() {
		return SCHEME;
	}

}

Back to the top