public class KeywordBasedValueConverter extends AbstractValueConverter<String> implements IValueConverter.RuleSpecific
This IValueConverter ensures that the given string value fulfills a
data type rule that consists only of an alternative of keywords.
It converts the value to a string. The implementation supports the following patterns:
RuleName: 'keyword'; RuleName: 'keyword' | 'other' | 'more';Clients who want to implement case insensitive languages have to override
toEscapedString(String) and keywordToString(Keyword). Clients
who want to convert the value to another data type may use this implementation
as a delegate.IValueConverter.RuleSpecificNO_OP_CONVERTER| Constructor and Description |
|---|
KeywordBasedValueConverter() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
assertValidValue(String value) |
protected String |
keywordToString(Keyword keyword) |
void |
setRule(AbstractRule rule) |
protected String |
toEscapedString(String value) |
String |
toString(String value)
Transforms the given value to a string that is conformant to the expected
terminal or data type rule.
|
String |
toValue(String string,
INode node)
Creates a value from the given input.
|
public String toValue(String string, INode node) throws ValueConverterException
IValueConverterCreates a value from the given input. The input is conformant to a data type or terminal rule.
The given string
or node may be null but not both of them.
toValue in interface IValueConverter<String>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 not
hidden.node - the parsed node including hidden parts.null.ValueConverterException - indicates that the string or node did not fulfil
the expected format.public String toString(String value) throws ValueConverterException
IValueConvertertoString in interface IValueConverter<String>value - the to-be-transformed valueValueConverterException - indicates that the value cannot be converted to a valid string.protected void assertValidValue(String value)
public void setRule(AbstractRule rule)
setRule in interface IValueConverter.RuleSpecificIllegalArgumentException - if the rule is not a datatype rule or does not fulfill
the pattern RuleName: 'keyword' | 'other';
Copyright © 2015. All Rights Reserved.