Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.core.variables/src/org/eclipse/core/variables/IStringVariableManager.java')
-rw-r--r--org.eclipse.core.variables/src/org/eclipse/core/variables/IStringVariableManager.java157
1 files changed, 157 insertions, 0 deletions
diff --git a/org.eclipse.core.variables/src/org/eclipse/core/variables/IStringVariableManager.java b/org.eclipse.core.variables/src/org/eclipse/core/variables/IStringVariableManager.java
new file mode 100644
index 000000000..06d2b33f8
--- /dev/null
+++ b/org.eclipse.core.variables/src/org/eclipse/core/variables/IStringVariableManager.java
@@ -0,0 +1,157 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.core.variables;
+
+import org.eclipse.core.runtime.CoreException;
+
+/**
+ * Regisitry for string variables.
+ *
+ * @since 3.0
+ */
+public interface IStringVariableManager {
+
+ /**
+ * Simple identifier constant (value <code>"dynamicVariables"</code>) for the
+ * context variables extension point.
+ */
+ public static final String EXTENSION_POINT_DYNAMIC_VARIABLES = "dynamicVariables"; //$NON-NLS-1$
+
+ /**
+ * Simple identifier constant (value <code>"valueVariables"</code>) for the
+ * value variables extension point.
+ */
+ public static final String EXTENSION_POINT_VALUE_VARIABLES = "valueVariables"; //$NON-NLS-1$
+
+ /**
+ * Returns all registered variables.
+ *
+ * @return a collection of all registered variables
+ */
+ public IStringVariable[] getVariables();
+
+ /**
+ * Returns all registered value variables.
+ *
+ * @return a collection of all registered value variables
+ */
+ public IValueVariable[] getValueVariables();
+
+ /**
+ * Returns the value variable with the given name, or <code>null</code>
+ * if none.
+ *
+ * @param name variable name
+ * @return the value variable with the given name, or <code>null</code>
+ * if none
+ */
+ public IValueVariable getValueVariable(String name);
+
+ /**
+ * Returns all registered dynamic variables.
+ *
+ * @return a collection of all registered dynamic variables
+ */
+ public IDynamicVariable[] getDynamicVariables();
+
+ /**
+ * Returns the dynamic variable with the given name or <code>null</code>
+ * if none.
+ *
+ * @param name variable name
+ * @return the dynamic variable with the given name or <code>null</code>
+ * if none
+ */
+ public IDynamicVariable getDynamicVariable(String name);
+
+ /**
+ * Recursively resolves and replaces all variable references in the given
+ * expression with their corresponding values. Reports errors for references
+ * to undefined variables (equivalent to calling
+ * <code>performStringSubstitution(expression, true)</code>).
+ *
+ * @param expression expression referencing variables
+ * @return expression with variable references replaced with variable values
+ * @throws CoreException if unable to resolve the value of one or more variables
+ */
+ public String performStringSubstitution(String expression) throws CoreException;
+
+ /**
+ * Recursively resolves and replaces all variable references in the given
+ * expression with their corresponding values. Allows the client to control
+ * whether references to undefeind variables are reported as an error (i.e.
+ * an exception is thrown).
+ *
+ * @param expression expression referencing variables
+ * @param reportUndefinedVariables whether a reference to an undefined variable
+ * is to be considered an error (i.e. throw an exception)
+ * @return expression with variable references replaced with variable values
+ * @throws CoreException if unable to resolve the value of one or more variables
+ */
+ public String performStringSubstitution(String expression, boolean reportUndefinedVariables) throws CoreException;
+
+ /**
+ * Returns a new value variable with the given name and description.
+ *
+ * @param name variable name, cannot be <code>null</code>
+ * @param description variable description, possibly <code>null</code>
+ * @return a new variable
+ * @exception CoreException if a variable already exists with the given name
+ */
+ public IValueVariable newValueVariable(String name, String description);
+
+ /**
+ * Adds the given variables to the variable registry.
+ *
+ * @param variables the variables to add
+ * @throws CoreException if one or more variables to add has a name collision with
+ * an existing variable
+ */
+ public void addVariables(IValueVariable[] variables) throws CoreException;
+
+ /**
+ * Removes the given variables from the registry. Has no effect for unregistered
+ * variables.
+ *
+ * @param variables variables to remove
+ */
+ public void removeVariables(IValueVariable[] variables);
+
+ /**
+ * Registers the given listener for value variable notifications. Has no effect
+ * if an identical listener is already registered.
+ *
+ * @param listener value variable listener to add
+ */
+ public void addValueVariableListener(IValueVariableListener listener);
+
+ /**
+ * Removes the given listener from the list of registered value variable
+ * listeners. Has no effect if an identical listener is not already registered.
+ *
+ * @param listener value variable listener to remove
+ */
+ public void removeValueVariableListener(IValueVariableListener listener);
+
+ /**
+ * Convenience method that returns an expression referencing the given
+ * variable and optional argument. For example, calling the method with
+ * a <code>varName</code> of <code>my_var</code> and an <code>argument</code>
+ * of <code>my_arg</code> results in the string <code>$(my_var:my_arg}</code>.
+ *
+ * @param varName variable name
+ * @param arg argument text or <code>null</code>
+ * @return an expression referencing the given variable and
+ * optional argument
+ */
+ public String generateVariableExpression(String varName, String arg);
+
+}

Back to the top