|
Eclipse Platform Release 3.6 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface IPathVariableManager
Manages a collection of path variables and resolves paths containing a variable reference.
A path variable is a pair of non-null elements (name,value) where name is
a case-sensitive string (containing only letters, digits and the underscore
character, and not starting with a digit), and value is an absolute
IPath
object.
Path variables allow for the creation of relative paths whose exact location in the file system depends on the value of a variable. A variable reference may only appear as the first segment of a relative path.
IPath
Method Summary | |
---|---|
void |
addChangeListener(IPathVariableChangeListener listener)
Registers the given listener to receive notification of changes to path variables. |
String |
convertFromUserEditableFormat(String value,
boolean locationFormat,
IResource resource)
Converts the user editable format to the internal format. |
URI |
convertToRelative(URI path,
IResource resource,
boolean force,
String variableHint)
Convert an absolute path to path variable relative path. |
String |
convertToUserEditableFormat(String value,
boolean locationFormat)
Converts the internal format of the linked resource location if the PARENT variables is used. |
IPathVariable |
getPathVariable(String name,
IResource resource)
Returns the IPathVariable interface for the variable with the given name. |
String[] |
getPathVariableNames()
Deprecated. use getPathVariableNames(IResource) instead. |
String[] |
getPathVariableNames(IResource resource)
Returns an array containing all defined path variable names. |
IPath |
getValue(String name)
Deprecated. use getValue(String, IResource) instead. |
URI |
getValue(String name,
IResource resource)
Returns the value of the path variable with the given name. |
URI |
getVariableRelativePathLocation(URI location,
IResource resource)
Returns a variable relative path equivalent to an absolute path for a file or folder in the file system, according to the variables defined in this project PathVariableManager. |
boolean |
isDefined(String name)
Deprecated. use isDefined(String, IResource) instead. |
boolean |
isDefined(String name,
IResource resource)
Returns true if the given variable is defined and
false otherwise. |
void |
removeChangeListener(IPathVariableChangeListener listener)
Removes the given path variable change listener from the listeners list. |
IPath |
resolvePath(IPath path)
Deprecated. use resolveURI(URI, IResource) instead. |
URI |
resolveURI(URI uri)
Deprecated. use resolveURI(URI, IResource) instead. |
URI |
resolveURI(URI uri,
IResource resource)
Resolves a relative URI object potentially containing a
variable reference as its first segment, replacing the variable reference
(if any) with the variable's value (which is a concrete absolute URI). |
void |
setValue(String name,
IPath value)
Deprecated. use setValue(String, IResource, URI) instead.
|
void |
setValue(String name,
IResource resource,
URI value)
Sets the path variable with the given name to be the specified value. |
IStatus |
validateName(String name)
Validates the given name as the name for a path variable. |
IStatus |
validateValue(IPath path)
Validates the given path as the value for a path variable. |
IStatus |
validateValue(URI path)
Validates the given path as the value for a path variable. |
Method Detail |
---|
URI convertToRelative(URI path, IResource resource, boolean force, String variableHint) throws CoreException
path
- The absolute path to be convertedresource
- the resource for which this variable is setforce
- Set to true if intermediate path variables need to be created if the path is relative only to a parent of an existing path variable.variableHint
- The name of the variable to which the path should be relative to, or null for the nearest one.
CoreException
- if this method fails. Reasons include:
void setValue(String name, IPath value) throws CoreException
null
.
null
.null
.
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.
name
- the name of the variablevalue
- the value for the variable (may be null
)
CoreException
- if this method fails. Reasons include:void setValue(String name, IResource resource, URI value) throws CoreException
null
.
null
.null
.
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.
name
- the name of the variableresource
- the resource for which this variable is setvalue
- the value for the variable (may be null
)
CoreException
- if this method fails. Reasons include:
IPathVariable getPathVariable(String name, IResource resource)
null
.
name
- the name of the variable to return the value for
null
if there is no
variable defined with the given nameIPath getValue(String name)
null
.
name
- the name of the variable to return the value for
null
if there is no
variable defined with the given nameURI getValue(String name, IResource resource)
null
.
name
- the name of the variable to return the value forresource
- the resource for which this variable is resolved
null
if there is no
variable defined with the given nameString[] getPathVariableNames()
String[] getPathVariableNames(IResource resource)
void addChangeListener(IPathVariableChangeListener listener)
listener
- the listenerIPathVariableChangeListener
void removeChangeListener(IPathVariableChangeListener listener)
listener
- the listenerIPathVariableChangeListener
URI resolveURI(URI uri)
URI
object potentially containing a
variable reference as its first segment, replacing the variable reference
(if any) with the variable's value (which is a concrete absolute URI).
If the given URI is absolute or has a non- null
device then
no variable substitution is done and that URI is returned as is. If the
given URI is relative and has a null
device, but the first
segment does not correspond to a defined variable, then the URI is
returned as is.
If the given URI is null
then null
will be
returned. In all other cases the result will be non-null
.
uri
- the URI to be resolved
null
URI resolveURI(URI uri, IResource resource)
URI
object potentially containing a
variable reference as its first segment, replacing the variable reference
(if any) with the variable's value (which is a concrete absolute URI).
If the given URI is absolute or has a non- null
device then
no variable substitution is done and that URI is returned as is. If the
given URI is relative and has a null
device, but the first
segment does not correspond to a defined variable, then the URI is
returned as is.
If the given URI is null
then null
will be
returned. In all other cases the result will be non-null
.
uri
- the URI to be resolvedresource
- the resource for which this variable is resolved
null
IPath resolvePath(IPath path)
IPath
object potentially containing a
variable reference as its first segment, replacing the variable reference
(if any) with the variable's value (which is a concrete absolute path).
If the given path is absolute or has a non- null
device then
no variable substitution is done and that path is returned as is. If the
given path is relative and has a null
device, but the first
segment does not correspond to a defined variable, then the path is
returned as is.
If the given path 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 => c:/temp
TEMP/foo => c:/temp/foo
BACKUP => /tmp/backup
BACKUP/bar.txt => /tmp/backup/bar.txt
SOMEPATH/foo => SOMEPATH/foo
path
- the path to be resolved
null
boolean isDefined(String name)
true
if the given variable is defined and
false
otherwise. Returns false
if the given
name is not a valid path variable name.
name
- the variable's name
true
if the variable exists, false
otherwiseboolean isDefined(String name, IResource resource)
true
if the given variable is defined and
false
otherwise. Returns false
if the given
name is not a valid path variable name.
name
- the variable's nameresource
- the resource for which this variable is resolved
true
if the variable exists, false
otherwiseIStatus validateName(String name)
name
- a possibly valid path variable name
IStatus.OK
if
the given name is a valid path variable name, otherwise a status
object indicating what is wrong with the stringIStatus.OK
IStatus validateValue(IPath path)
path
- a possibly valid path variable value
IStatus.OK
if the given
path is a valid path variable value, otherwise a status object indicating
what is wrong with the valueIPath.isValidPath(String)
,
IStatus.OK
IStatus validateValue(URI path)
path
- a possibly valid path variable value
IStatus.OK
if the given
path is a valid path variable value, otherwise a status object indicating
what is wrong with the valueIPath.isValidPath(String)
,
IStatus.OK
URI getVariableRelativePathLocation(URI location, IResource resource)
location
- a path in the local file systemresource
- the resource for which this variable is resolved
null
if no such path is availableString convertToUserEditableFormat(String value, boolean locationFormat)
value
- the value encoded using OS string (as returned from Path.toOSString())locationFormat
- indicates whether the value contains a string that is stored in the linked resource location rather than in the path variable value
String convertFromUserEditableFormat(String value, boolean locationFormat, IResource resource)
value
- the value encoded using OS string (as returned from Path.toOSString())locationFormat
- indicates whether the value contains a string that is stored in the linked resource location rather than in the path variable valueresource
- the resource for which this variable is resolved
|
Eclipse Platform Release 3.6 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Guidelines for using Eclipse APIs.
Copyright (c) Eclipse contributors and others 2000, 2010. All rights reserved.