Class TokenSink

  • Direct Known Subclasses:
    TokenIterator, TokenList

    public abstract class TokenSink
    extends java.lang.Object
    Abstract class for objects that can have tokens added to them.
    • Field Detail

      • DEFAULT_POSITION_INCREMENT

        protected static final int DEFAULT_POSITION_INCREMENT
        Default position increment (1).
        See Also:
        Constant Field Values
    • Constructor Detail

      • TokenSink

        public TokenSink()
    • Method Detail

      • startScope

        public void startScope​(java.lang.String name,
                               int startOffset)
        Add a TokenAnnotation.SCOPE_START token to the token list.
      • startLanguageRegion

        public Token startLanguageRegion​(java.util.Locale locale)
        Start a language region for locale.

        A null locale will be encoded as an empty string.

        Since:
        5.5.0 patch 95
      • endScope

        public void endScope​(java.lang.String name,
                             int endOffset)
        Add an TokenAnnotation.SCOPE_END token to the token list.
      • add

        public final void add​(java.lang.String t)
        Appends a token using the default position increment.
        Parameters:
        t - The string value of a Token to add
      • add

        public final void add​(java.lang.String t,
                              int increment)
        Appends a token.
        Parameters:
        t - The string value of a Token to add
        increment - The position increment for the newly added token
      • add

        public final void add​(Token t)
        Appends a token using the default position increment.
        Parameters:
        t - The Token to add to this TokenList
      • add

        public abstract void add​(Token t,
                                 int increment)
        Appends a token.
        Parameters:
        t - The Token to add
        increment - The position increment for the newly added token
      • add

        public final void add​(TokenList tokens)
        Adds all Tokens for the passed in TokenList to this TokenList.

        The first Token copied from the passed in TokenList will have the default position increment in this TokenList.

        NOTE: The tokens in the passed in TokenList will be cloned prior to adding to this TokenList. Modifications to the passed in TokenList after calling add(TokenList) will not impact this TokenList.

        Parameters:
        tokens - The TokenList to copy onto the end of this TokenList.
      • add

        public void add​(TokenList tokens,
                        int increment)
        Adds all Tokens for the passed in TokenList

        NOTE: The tokens in the passed in TokenList will be cloned prior to being added. Modifications to the passed in TokenList after calling add(TokenList) will not impact this TokenSink.

        Parameters:
        tokens - The TokenList to add.
        increment - The increment for the first Token added from tokens
      • append

        public TokenSink append​(java.lang.String t)
        Appends a token to this TokenList using the default position increment.
        Parameters:
        t - The string value of a Token to add to this TokenList
        Returns:
        this (supports call chaining)
      • append

        public TokenSink append​(java.lang.String t,
                                int increment)
        Appends a token.
        Parameters:
        t - The string value of a Token to add
        increment - The position increment for the Token to add
        Returns:
        this (supports call chaining)
      • append

        public TokenSink append​(Token t)
        Appends a token using the default position increment.
        Parameters:
        t - The Token to add
        Returns:
        this (supports call chaining)
      • append

        public TokenSink append​(Token t,
                                int increment)
        Appends a token.
        Parameters:
        t - The Token to add to this TokenList
        increment - The position increment for the Token to add
        Returns:
        this (supports call chaining)