Eclipse Platform
Release 3.0

org.eclipse.jface.text.templates
Class TemplateVariable

java.lang.Object
  extended byorg.eclipse.jface.text.templates.TemplateVariable

public class TemplateVariable
extends Object

A TemplateVariable represents a set of positions into a TemplateBuffer with identical content each. TemplateVariableResolvers can be used to resolve a template variable to a symbol available from the TemplateContext.

Clients may instantiate and extend this class.

Since:
3.0
See Also:
TemplateVariableResolver, TemplateBuffer

Constructor Summary
TemplateVariable(String type, String[] values, int[] offsets)
          Creates a template variable with multiple possible values.
TemplateVariable(String type, String defaultValue, int[] offsets)
          Creates a template variable.
TemplateVariable(String type, String name, String[] values, int[] offsets)
          Creates a template variable with multiple possible values.
TemplateVariable(String type, String name, String defaultValue, int[] offsets)
          Creates a template variable.
 
Method Summary
 String getDefaultValue()
          Returns the default value of the variable.
 int getLength()
          Returns the length of the variable.
 String getName()
          Returns the name of the variable.
 int[] getOffsets()
          Returns the offsets of the variable.
 String getType()
          Returns the type of the variable.
 String[] getValues()
          Returns the possible values for this variable.
 boolean isUnambiguous()
          Returns true if the variable is unambiguously resolved, false otherwise.
 void setOffsets(int[] offsets)
          Sets the offsets of the variable.
 void setUnambiguous(boolean unambiguous)
          Sets the isUnambiguous flag of the variable.
 void setValue(String value)
          Sets the default value for this variable.
 void setValues(String[] values)
          Sets the possible values for this variable, with the first being the default value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TemplateVariable

public TemplateVariable(String type,
                        String defaultValue,
                        int[] offsets)
Creates a template variable. The type is used as the name of the variable.

Parameters:
type - the type of the variable
defaultValue - the default value of the variable
offsets - the array of offsets of the variable

TemplateVariable

public TemplateVariable(String type,
                        String name,
                        String defaultValue,
                        int[] offsets)
Creates a template variable.

Parameters:
type - the type of the variable
name - the name of the variable
defaultValue - the default value of the variable
offsets - the array of offsets of the variable

TemplateVariable

public TemplateVariable(String type,
                        String[] values,
                        int[] offsets)
Creates a template variable with multiple possible values. The type is used as the name of the template.

Parameters:
type - the type of the template variable
values - the values available at this variable, non-empty
offsets - the array of offsets of the variable

TemplateVariable

public TemplateVariable(String type,
                        String name,
                        String[] values,
                        int[] offsets)
Creates a template variable with multiple possible values.

Parameters:
type - the type of the variable
name - the name of the variable
values - the values available at this variable, non-empty
offsets - the array of offsets of the variable
Method Detail

getType

public String getType()
Returns the type of the variable.

Returns:
the type of the variable

getName

public String getName()
Returns the name of the variable.

Returns:
the name of the variable

getDefaultValue

public String getDefaultValue()
Returns the default value of the variable.

Returns:
the default value of the variable

getValues

public String[] getValues()
Returns the possible values for this variable. The returned array is owned by this variable and must not be modified.

Returns:
the possible values for this variable

getLength

public int getLength()
Returns the length of the variable.

Returns:
the length of the variable

setOffsets

public void setOffsets(int[] offsets)
Sets the offsets of the variable.

Parameters:
offsets - the new offsets of the variable

getOffsets

public int[] getOffsets()
Returns the offsets of the variable.

Returns:
the length of the variable

setValue

public final void setValue(String value)
Sets the default value for this variable. This is a shortcut for setValues(new String[] { value }).

Parameters:
value - the new default value

setValues

public void setValues(String[] values)
Sets the possible values for this variable, with the first being the default value.

Parameters:
values - a non-empty array of values

setUnambiguous

public void setUnambiguous(boolean unambiguous)
Sets the isUnambiguous flag of the variable.

Parameters:
unambiguous - the new unambiguous state of the variable

isUnambiguous

public boolean isUnambiguous()
Returns true if the variable is unambiguously resolved, false otherwise.

Returns:
true if the variable is unambiguously resolved, false otherwise

Eclipse Platform
Release 3.0

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp. and others 2000, 2004. All rights reserved.