Class RegistryReader
- java.lang.Object
-
- net.enilink.commons.util.extensions.RegistryReader
-
- All Implemented Interfaces:
EventListener,org.eclipse.core.runtime.IRegistryChangeListener
public abstract class RegistryReader extends Object implements org.eclipse.core.runtime.IRegistryChangeListener
Template implementation of a registry reader that creates objects representing registry contents. Typically, an extension contains one element, but this reader handles multiple elements per extension. To start reading the extensions from the registry for an extension point, call the methodreadRegistry. To read children of an IConfigurationElement, call the methodreadElementChildrenfrom your implementation of the methodreadElement, as it will not be done by default.
-
-
Field Summary
Fields Modifier and Type Field Description protected static StringTAG_DESCRIPTION
-
Constructor Summary
Constructors Modifier Constructor Description protectedRegistryReader(String pluginId, String extensionPoint)The constructor.protectedRegistryReader(org.eclipse.core.runtime.IExtensionRegistry registry, String pluginId, String extensionPoint)The constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected StringgetDescription(org.eclipse.core.runtime.IConfigurationElement config)This method extracts description as a subelement of the given element.protected static voidlogError(org.eclipse.core.runtime.IConfigurationElement element, String text)Logs the error in the workbench log using the provided text and the information in the configuration element.protected static voidlogMissingAttribute(org.eclipse.core.runtime.IConfigurationElement element, String attributeName)Logs a very common registry error when a required attribute is missing.protected static voidlogMissingElement(org.eclipse.core.runtime.IConfigurationElement element, String elementName)Logs a very common registry error when a required child is missing.protected static voidlogUnknownElement(org.eclipse.core.runtime.IConfigurationElement element)Logs a registry error when the configuration element is unknown.protected org.eclipse.core.runtime.IExtension[]orderExtensions(org.eclipse.core.runtime.IExtension[] extensions)Apply a reproducable order to the list of extensions provided, such that the order will not change as extensions are added or removed.protected booleanreadElement(org.eclipse.core.runtime.IConfigurationElement element)Implement this method to read element's attributes.protected booleanreadElement(org.eclipse.core.runtime.IConfigurationElement element, boolean add)Implement this method to read element attributes for the purpose of adding or removing their registrations.protected voidreadElementChildren(org.eclipse.core.runtime.IConfigurationElement element, boolean add)Read the element's children.protected voidreadElements(org.eclipse.core.runtime.IConfigurationElement[] elements, boolean add)Read each element one at a time by calling the subclass implementation ofreadElement.protected voidreadExtension(org.eclipse.core.runtime.IExtension extension, boolean add)Read one extension by looping through its configuration elements.voidreadRegistry()Start the registry reading process using the supplied plugin ID and extension point.voidregisterListener()Registers change listener to extension registryvoidregistryChanged(org.eclipse.core.runtime.IRegistryChangeEvent event)voidunregisterListener()Unregisters change listener from extension registry
-
-
-
Field Detail
-
TAG_DESCRIPTION
protected static final String TAG_DESCRIPTION
- See Also:
- Constant Field Values
-
-
Method Detail
-
getDescription
protected String getDescription(org.eclipse.core.runtime.IConfigurationElement config)
This method extracts description as a subelement of the given element.- Returns:
- description string if defined, or empty string if not.
-
logError
protected static void logError(org.eclipse.core.runtime.IConfigurationElement element, String text)Logs the error in the workbench log using the provided text and the information in the configuration element.
-
logMissingAttribute
protected static void logMissingAttribute(org.eclipse.core.runtime.IConfigurationElement element, String attributeName)Logs a very common registry error when a required attribute is missing.
-
logMissingElement
protected static void logMissingElement(org.eclipse.core.runtime.IConfigurationElement element, String elementName)Logs a very common registry error when a required child is missing.
-
logUnknownElement
protected static void logUnknownElement(org.eclipse.core.runtime.IConfigurationElement element)
Logs a registry error when the configuration element is unknown.
-
orderExtensions
protected org.eclipse.core.runtime.IExtension[] orderExtensions(org.eclipse.core.runtime.IExtension[] extensions)
Apply a reproducable order to the list of extensions provided, such that the order will not change as extensions are added or removed.
-
readElement
protected boolean readElement(org.eclipse.core.runtime.IConfigurationElement element)
Implement this method to read element's attributes. If children should also be read, then implementor is responsible for callingreadElementChildren. Implementor is also responsible for logging missing attributes.- Returns:
- true if element was recognized, false if not.
-
readElement
protected boolean readElement(org.eclipse.core.runtime.IConfigurationElement element, boolean add)Implement this method to read element attributes for the purpose of adding or removing their registrations. If this element has child elements, the reader will recursively cycle through them and will call this method, so don't do it here.
-
readElementChildren
protected void readElementChildren(org.eclipse.core.runtime.IConfigurationElement element, boolean add)Read the element's children. This is called by the subclass' readElement method when it wants to read the children of the element.
-
readElements
protected void readElements(org.eclipse.core.runtime.IConfigurationElement[] elements, boolean add)Read each element one at a time by calling the subclass implementation ofreadElement. Logs an error if the element was not recognized.
-
readExtension
protected void readExtension(org.eclipse.core.runtime.IExtension extension, boolean add)Read one extension by looping through its configuration elements.
-
readRegistry
public void readRegistry()
Start the registry reading process using the supplied plugin ID and extension point.
-
registerListener
public void registerListener()
Registers change listener to extension registry
-
unregisterListener
public void unregisterListener()
Unregisters change listener from extension registry
-
registryChanged
public void registryChanged(org.eclipse.core.runtime.IRegistryChangeEvent event)
- Specified by:
registryChangedin interfaceorg.eclipse.core.runtime.IRegistryChangeListener
-
-