Package org.eclipse.xtext.conversion
Interface IValueConverter<Type>
-
- All Known Implementing Classes:
AbstractIDValueConverter,AbstractLexerBasedConverter,AbstractNullSafeConverter,AbstractToStringConverter,AbstractValueConverter,DefaultTerminalConverter,EFactoryValueConverter,IDValueConverter,IgnoreCaseIDValueConverter,INTValueConverter,KeywordAlternativeConverter,KeywordBasedValueConverter,QualifiedNameInStaticImportValueConverter,QualifiedNameValueConverter,STRINGValueConverter
public interface IValueConverter<Type>AValueConverteris used to create a semantic value from an input string or node and vice versa.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceIValueConverter.RuleSpecificValue converters that rely on information about the actual rule that is converted, may implement this interface.
-
Field Summary
Fields Modifier and Type Field Description static IValueConverter<? extends java.lang.Object>NO_OP_CONVERTER
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.StringtoString(Type value)Transforms the given value to a string that is conformant to the expected terminal or data type rule.TypetoValue(java.lang.String string, INode node)Creates a value from the given input.
-
-
-
Field Detail
-
NO_OP_CONVERTER
static final IValueConverter<? extends java.lang.Object> NO_OP_CONVERTER
-
-
Method Detail
-
toValue
Type toValue(java.lang.String string, INode node) throws ValueConverterException
Creates a value from the given input. The input is conformant to a data type or terminal rule.
The given
stringornodemay be null but not both of them.- Parameters:
string- the string that was inferred from the node. Usually the node's text but may be reduced to the parts of the node that are nothidden.node- the parsed node including hidden parts.- Returns:
- the new value or
null. - Throws:
ValueConverterException- indicates that the string or node did not fulfil the expected format.
-
toString
java.lang.String toString(Type value) throws ValueConverterException
Transforms the given value to a string that is conformant to the expected terminal or data type rule.- Parameters:
value- the to-be-transformed value- Returns:
- a string represenation for that value.
- Throws:
ValueConverterException- indicates that the value cannot be converted to a valid string.
-
-