Skip to main content
summaryrefslogtreecommitdiffstats
blob: 7ed809c2dc815474c61e4d8bcd3423bf1fdea708 (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
package org.eclipse.ecf.internal.storage;

import org.eclipse.ecf.core.*;
import org.eclipse.ecf.core.identity.*;
import org.eclipse.ecf.core.provider.BaseContainerInstantiator;

public class StorableContainerInstantiator extends BaseContainerInstantiator {

	private static long nextBaseContainerID = 0L;

	public IContainer createInstance(ContainerTypeDescription description, Object[] parameters) throws ContainerCreateException {
		try {
			if (parameters != null && parameters.length > 0) {
				if (parameters[0] instanceof ID)
					return new StorableBaseContainer((ID) parameters[0]);
				if (parameters[0] instanceof String)
					return new StorableBaseContainer(IDFactory.getDefault().createStringID((String) parameters[0]));
			}
		} catch (IDCreateException e) {
			throw new ContainerCreateException("Could not create StorableBaseContainer"); //$NON-NLS-1$
		}
		return new StorableBaseContainer(nextBaseContainerID++);
	}

}

Back to the top