Class AbstractIDValueConverter

  • All Implemented Interfaces:
    IValueConverter<java.lang.String>, IValueConverter.RuleSpecific
    Direct Known Subclasses:
    IDValueConverter, IgnoreCaseIDValueConverter

    public abstract class AbstractIDValueConverter
    extends AbstractLexerBasedConverter<java.lang.String>
    Abstract implementation of a value converter that escapes a string based on a set of values. The strategy to compute this values and how the string is found in this set is the responsibility of the concrete implementation. A common use-case is to collect the keywords in a grammar and match the string against these keywords or to use some ignore-case matching algorithm against the list of normalized keywords.
    • Constructor Detail

      • AbstractIDValueConverter

        protected AbstractIDValueConverter()
    • Method Detail

      • computeValuesToEscape

        protected abstract java.util.Set<java.lang.String> computeValuesToEscape​(Grammar grammar)
      • getValuesToEscape

        protected java.util.Set<java.lang.String> getValuesToEscape()
      • mustEscape

        protected abstract boolean mustEscape​(java.lang.String value)
      • getInvalidCharactersMessage

        protected java.lang.String getInvalidCharactersMessage​(java.lang.String value,
                                                               java.util.Set<java.lang.Character> invalidChars)
      • collectInvalidCharacters

        protected java.util.Set<java.lang.Character> collectInvalidCharacters​(java.lang.String value)
      • toValue

        public java.lang.String toValue​(java.lang.String string,
                                        INode node)
        Description copied from interface: IValueConverter

        Creates 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.

        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 not hidden.
        node - the parsed node including hidden parts.
        Returns:
        the new value or null.
      • setGrammarAccess

        public void setGrammarAccess​(IGrammarAccess grammarAccess)