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
.
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.
|
Modifier and Type | Method and Description |
---|---|
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.
|
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(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 String getName()
public String getDefaultValue()
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
otherwiseGuidelines for using Eclipse APIs. Copyright (c) IBM Corp. and others 2000, 2006. All rights reserved.