public abstract class Namespace extends Object implements Serializable, org.eclipse.core.runtime.IAdaptable
This class and subclasses define a namespace for the creation and management
of ID instances. Creation of ID instances is accomplished via the
createInstance(Object[]) method, implemented by subclasses of this
Namespace superclass.
All Namespace instances must have a unique name passed to the Namespace upon construction.
Typically Namespace instances are created via plugins that define extensions of the org.eclipse.ecf.namespace extension point. For example, to define a new Namespace subclass XMPPNamespace with name "ecf.xmpp" and add it to the ECF extension registry:
<extension
point="org.eclipse.ecf.namespace">
<namespace
class="XMPPNamespace"
name="ecf.xmpp"/>
</extension>
ID,
Serialized Form| Modifier and Type | Field and Description |
|---|---|
static String |
SCHEME_SEPARATOR |
| Constructor and Description |
|---|
Namespace() |
Namespace(String name,
String desc) |
| Modifier and Type | Method and Description |
|---|---|
abstract ID |
createInstance(Object[] parameters)
Make an instance of this namespace.
|
boolean |
equals(Object other)
Override of Object.equals.
|
Object |
getAdapter(Class adapter) |
protected int |
getCompareToForObject(BaseID first,
BaseID second)
The default implementation of this method is to call
first.namespaceCompareTo(second).
|
String |
getDescription()
Get the description, associated with this Namespace.
|
protected int |
getHashCodeForID(BaseID id)
The default implementation of this method is to call id.namespaceHashCode().
|
protected String |
getInitStringFromExternalForm(Object[] args) |
String |
getName()
Get the name of this namespace.
|
protected String |
getNameForID(BaseID id)
The default implementation of this method is to call id.namespaceGetName().
|
abstract String |
getScheme()
Get the primary scheme associated with this namespace.
|
Class<?>[][] |
getSupportedParameterTypes()
Get the supported parameter types for IDs created via subsequent calls to
createInstance(Object[]). |
String[] |
getSupportedSchemes()
Get an array of schemes supported by this Namespace instance.
|
int |
hashCode()
Hashcode implementation.
|
boolean |
initialize(String n,
String desc) |
protected boolean |
testIDEquals(BaseID first,
BaseID second)
Test whether two IDs are equal to one another.
|
protected String |
toExternalForm(BaseID id)
The default implementation of this method is to call
id.namespaceToExternalForm().
|
String |
toString() |
public static final String SCHEME_SEPARATOR
public boolean equals(Object other)
public int hashCode()
protected boolean testIDEquals(BaseID first, BaseID second)
first - the first ID. Must not be null.second - the second ID. Must not be null.true if this ID is equal to the given ID.
false otherwise.protected String getNameForID(BaseID id)
id - the ID to get the name for. Must not be null.protected int getCompareToForObject(BaseID first, BaseID second)
first - the first id to compare. Must not be null.second - the second id to compare. Must not be null.Comparable.protected int getHashCodeForID(BaseID id)
id - the id in this Namespace to get the hashcode for. Must not be
null.protected String toExternalForm(BaseID id)
id - the id in this Namespace to convert to external form.createInstance(Object[]) as a single String parameter, and
should result in a valid ID instance of the appropriate Namespace.public String getName()
null.null,
and the returned value should be a globally unique name for this
Namespace subclass.public String getDescription()
null.null.public abstract ID createInstance(Object[] parameters) throws IDCreateException
See
getSupportedParameterTypes() to get information relevant to
deciding what parameter types are expected by this method.
parameters - an Object[] of parameters for creating ID instances. May be null.IDCreateException - if construction failspublic abstract String getScheme()
null scheme
identifier. Note that the returned scheme should not contain the
Namespace.SCHEME_SEPARATOR (\":\").null.public String[] getSupportedSchemes()
null, but returned array may be of length 0.public Class<?>[][] getSupportedParameterTypes()
createInstance(Object[]). Callers may use this method to determine
the available parameter types, and then create and pass in conforming Object
arrays to to createInstance(Object[]).
An empty two-dimensional array (new Class[0][0]) is the default returned by this abstract superclass. This means that the Object [] passed to
createInstance(Object[]) will be ignored.
Subsclasses should override this method to specify the parameters that they will accept in calls to
createInstance(Object[]). The rows of the
returned Class array are the acceptable types for a given invocation of
createInstance.
Consider the following example:
public Class[][] getSupportedParameterTypes() {
return new Class[][] { { String.class }, { String.class, String.class } };
}
The above means that there are two acceptable values for the Object [] passed
into createInstance(Object[]): 1) a single String, and 2) two
Strings. These would therefore be acceptable as input to createInstance:
ID newID1 = namespace.createInstance(new Object[] { "Hello" });
ID newID2 = namespace.createInstance(new Object[] { "Hello", "There"}};
createInstance(Object[]). If zero-length
Class arrays are returned (i.e. Class[0][0]), then Object []
parameters to createInstance(Object[]) will be ignored.public Object getAdapter(Class adapter)
getAdapter in interface org.eclipse.core.runtime.IAdaptableprotected String getInitStringFromExternalForm(Object[] args)
Copyright © 2004–2020 Eclipse Foundation. All rights reserved.