Interface IPathEntryVariableManager


  • public interface IPathEntryVariableManager
    Manages a collection of variables
    Since:
    3.0
    Restriction:
    This interface is not intended to be implemented by clients.
    Restriction:
    This interface is not intended to be extended by clients.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void addChangeListener​(IPathEntryVariableChangeListener listener)
      Registers the given listener to receive notification of changes to variables.
      org.eclipse.core.runtime.IPath getValue​(String name)
      Returns the value of the variable with the given name.
      String[] getVariableNames()
      Returns an array containing all defined variable names.
      boolean isDefined​(String name)
      Returns true if the given variable is defined and false otherwise.
      void removeChangeListener​(IPathEntryVariableChangeListener listener)
      Removes the given variable change listener from the listeners list.
      org.eclipse.core.runtime.IPath resolvePath​(org.eclipse.core.runtime.IPath path)
      Resolves a String potentially containing a variable reference, replacing the variable reference (if any) with the variable's value (which is a concrete absolute path).
      void setValue​(String name, org.eclipse.core.runtime.IPath value)
      Sets the variable with the given name to be the specified value.
    • Method Detail

      • setValue

        void setValue​(String name,
                      org.eclipse.core.runtime.IPath value)
               throws org.eclipse.core.runtime.CoreException
        Sets the variable with the given name to be the specified value. Depending on the value given and if the variable is currently defined or not, there are several possible outcomes for this operation:

        • A new variable will be created, if there is no variable defined with the given name, and the given value is not null.
        • The referred variable's value will be changed, if it already exists and the given value is not null.
        • The referred variable will be removed, if a variable with the given name is currently defined and the given value is null.
        • The call will be ignored, if a variable with the given name is not currently defined and the given value is null, or if it is defined but the given value is equal to its current value.

        If a variable is effectively changed, created or removed by a call to this method, notification will be sent to all registered listeners.

        Parameters:
        name - the name of the variable
        value - the value for the variable (may be null)
        Throws:
        org.eclipse.core.runtime.CoreException - if this method fails. Reasons include:
        • The variable name is not valid
        • The variable value is relative
      • getValue

        org.eclipse.core.runtime.IPath getValue​(String name)
        Returns the value of the variable with the given name. If there is no variable defined with the given name, returns null.
        Parameters:
        name - the name of the variable to return the value for
        Returns:
        the value for the variable, or null if there is no variable defined with the given name
      • getVariableNames

        String[] getVariableNames()
        Returns an array containing all defined variable names.
        Returns:
        an array containing all defined variable names
      • addChangeListener

        void addChangeListener​(IPathEntryVariableChangeListener listener)
        Registers the given listener to receive notification of changes to variables. The listener will be notified whenever a variable has been added, removed or had its value changed. Has no effect if an identical variable change listener is already registered.
        Parameters:
        listener - the listener
        See Also:
        IPathEntryVariableChangeListener
      • resolvePath

        org.eclipse.core.runtime.IPath resolvePath​(org.eclipse.core.runtime.IPath path)
        Resolves a String potentially containing a variable reference, replacing the variable reference (if any) with the variable's value (which is a concrete absolute path).

        If the given String is null then null will be returned. In all other cases the result will be non-null.

        For example, consider the following collection of path variables:

        • TEMP = c:/temp
        • BACKUP = /tmp/backup

        The following paths would be resolved as:

        c:/bin => c:/bin

        c:${TEMP} => c:/temp

        /TEMP => /TEMP

        ${TEMP}/foo => /temp/foo

        ${BACKUP} => /tmp/backup

        ${BACKUP}/bar.txt => /tmp/backup/bar.txt

        SOMEPATH/foo => SOMEPATH/foo

        Parameters:
        path - the path to be resolved
        Returns:
        the resolved path or null
      • isDefined

        boolean isDefined​(String name)
        Returns true if the given variable is defined and false otherwise. Returns false if the given name is not a valid path variable name.
        Parameters:
        name - the variable's name
        Returns:
        true if the variable exists, false otherwise