public class TemplateVariable extends Object
TemplateVariable
represents a set of positions into a
TemplateBuffer
with identical content each. TemplateVariableResolver
s
can be used to resolve a template variable to a symbol available from the
TemplateContext
. A resolved variable may have one or more possible
values
which may be presented to the user as choices. If there is no user
interaction the default value
is chosen as textual representation of
the variable.
Clients may instantiate and extend this class.
TemplateVariableResolver
,
TemplateBuffer
Constructor and Description |
---|
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.
|
TemplateVariable(TemplateVariableType type,
String name,
String defaultValue,
int[] offsets)
Creates a template variable.
|
Modifier and Type | Method and Description |
---|---|
String |
getDefaultValue()
Returns the default value of the variable.
|
int |
getLength()
Returns the length of the variable's default value.
|
String |
getName()
Returns the name of the variable.
|
int[] |
getOffsets()
Returns the offsets of the variable.
|
String |
getType()
Returns the type name of the variable.
|
String[] |
getValues()
Returns the possible values for this variable.
|
TemplateVariableType |
getVariableType()
Returns the type of the variable.
|
boolean |
isResolved()
Returns
true if the variable has been resolved, false
otherwise. |
boolean |
isUnambiguous()
Returns
true if the variable is unambiguously resolved, false otherwise. |
void |
setOffsets(int[] offsets)
Sets the offsets of the variable.
|
void |
setResolved(boolean resolved)
Sets the resolved flag of the variable.
|
void |
setUnambiguous(boolean unambiguous)
Sets the isUnambiguous flag of the variable.
|
void |
setValue(String value)
Resolves the variable to a single value.
|
void |
setValues(String[] values)
Resolves the variable to several possible values for this variable, with the first being the
default value.
|
public TemplateVariable(String type, String defaultValue, int[] offsets)
type
- the type of the variabledefaultValue
- the default value of the variableoffsets
- the array of offsets of the variablepublic TemplateVariable(String type, String name, String defaultValue, int[] offsets)
type
- the type of the variablename
- the name of the variabledefaultValue
- the default value of the variableoffsets
- the array of offsets of the variablepublic TemplateVariable(TemplateVariableType type, String name, String defaultValue, int[] offsets)
type
- the type of the variablename
- the name of the variabledefaultValue
- the default value of the variableoffsets
- the array of offsets of the variablepublic TemplateVariable(String type, String[] values, int[] offsets)
type
- the type of the template variablevalues
- the values available at this variable, non-emptyoffsets
- the array of offsets of the variablepublic TemplateVariable(String type, String name, String[] values, int[] offsets)
type
- the type of the variablename
- the name of the variablevalues
- the values available at this variable, non-emptyoffsets
- the array of offsets of the variablepublic String getType()
public TemplateVariableType getVariableType()
public String getName()
public String getDefaultValue()
getValues()
.public String[] getValues()
public int getLength()
public void setOffsets(int[] offsets)
offsets
- the new offsets of the variablepublic int[] getOffsets()
public final void setValue(String value)
setValues(new String[] { value })
.value
- the new default valuepublic void setValues(String[] values)
values
- a non-empty array of valuespublic void setUnambiguous(boolean unambiguous)
unambiguous
- the new unambiguous state of the variablepublic boolean isUnambiguous()
true
if the variable is unambiguously resolved, false
otherwise.true
if the variable is unambiguously resolved, false
otherwisepublic void setResolved(boolean resolved)
resolved
- the new resolved statepublic boolean isResolved()
true
if the variable has been resolved, false
otherwise.true
if the variable has been resolved, false
otherwise
Copyright (c) 2000, 2014 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.