org.eclipse.cdt.internal.core
Class PathEntryVariableManager

java.lang.Object
  extended by org.eclipse.cdt.internal.core.PathEntryVariableManager
All Implemented Interfaces:
IPathEntryVariableManager

public class PathEntryVariableManager
extends java.lang.Object
implements IPathEntryVariableManager

Core's implementation of IPathEntryVariableManager.


Method Summary
 void addChangeListener(IPathEntryVariableChangeListener listener)
          Registers the given listener to receive notification of changes to variables.
 org.eclipse.core.runtime.IPath getValue(java.lang.String varName)
          Note that if a user changes the key in the preferences file to be invalid and then calls #getValue using that key, they will get the value back for that.
 java.lang.String[] getVariableNames()
          Returns an array containing all defined variable names.
 boolean isDefined(java.lang.String varName)
          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(java.lang.String varName, org.eclipse.core.runtime.IPath newValue)
          Sets the variable with the given name to be the specified value.
 void shutdown()
           
 void startup()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getValue

public org.eclipse.core.runtime.IPath getValue(java.lang.String varName)
Note that if a user changes the key in the preferences file to be invalid and then calls #getValue using that key, they will get the value back for that. But then if they try and call #setValue using the same key it will throw an exception. We may want to revisit this behaviour in the future.

Specified by:
getValue in interface IPathEntryVariableManager
Parameters:
varName - 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
See Also:
org.eclipse.core.resources.IPathEntryVariableManager#getValue(String)

setValue

public void setValue(java.lang.String varName,
                     org.eclipse.core.runtime.IPath newValue)
              throws org.eclipse.core.runtime.CoreException
Description copied from interface: IPathEntryVariableManager
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:

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

Specified by:
setValue in interface IPathEntryVariableManager
Parameters:
varName - the name of the variable
newValue - 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
See Also:
org.eclipse.core.resources.IPathEntryVariableManager#setValue(String, IPath)

resolvePath

public org.eclipse.core.runtime.IPath resolvePath(org.eclipse.core.runtime.IPath path)
Description copied from interface: IPathEntryVariableManager
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:

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

Specified by:
resolvePath in interface IPathEntryVariableManager
Parameters:
path - the path to be resolved
Returns:
the resolved path or null
See Also:
org.eclipse.core.resources.IPathEntryVariableManager#resolvePath(IPath)

getVariableNames

public java.lang.String[] getVariableNames()
Description copied from interface: IPathEntryVariableManager
Returns an array containing all defined variable names.

Specified by:
getVariableNames in interface IPathEntryVariableManager
Returns:
an array containing all defined variable names
See Also:
IPathVariableManager.getPathVariableNames()

addChangeListener

public void addChangeListener(IPathEntryVariableChangeListener listener)
Description copied from interface: IPathEntryVariableManager
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.

Specified by:
addChangeListener in interface IPathEntryVariableManager
Parameters:
listener - the listener
See Also:
IPathEntryVariableManager#addChangeListener(IPathEntryVariableChangeListener)

removeChangeListener

public void removeChangeListener(IPathEntryVariableChangeListener listener)
Description copied from interface: IPathEntryVariableManager
Removes the given variable change listener from the listeners list. Has no effect if an identical listener is not registered.

Specified by:
removeChangeListener in interface IPathEntryVariableManager
Parameters:
listener - the listener
See Also:
IPathEntryVariableManager#removeChangeListener(IPathEntryVariableChangeListener)

isDefined

public boolean isDefined(java.lang.String varName)
Description copied from interface: IPathEntryVariableManager
Returns true if the given variable is defined and false otherwise. Returns false if the given name is not a valid path variable name.

Specified by:
isDefined in interface IPathEntryVariableManager
Parameters:
varName - the variable's name
Returns:
true if the variable exists, false otherwise
See Also:
IPathVariableManager.isDefined(String)

startup

public void startup()

shutdown

public void shutdown()