Class TokenPairExpressionIterator

  • All Implemented Interfaces:
    org.apache.camel.Expression, org.apache.camel.Predicate

    public class TokenPairExpressionIterator
    extends ExpressionAdapter
    Expression to walk a Message body using an Iterator, which grabs the content between a start and end token.

    The message body must be able to convert to InputStream type which is used as stream to access the message body.

    For splitting XML files use TokenXMLExpressionIterator instead.

    • Field Detail

      • startToken

        protected final String startToken
      • endToken

        protected final String endToken
      • includeTokens

        protected final boolean includeTokens
    • Constructor Detail

      • TokenPairExpressionIterator

        public TokenPairExpressionIterator​(String startToken,
                                           String endToken,
                                           boolean includeTokens)
    • Method Detail

      • init

        public void init​(org.apache.camel.CamelContext context)
        Specified by:
        init in interface org.apache.camel.Expression
        Specified by:
        init in interface org.apache.camel.Predicate
        Overrides:
        init in class ExpressionAdapter
      • matches

        public boolean matches​(org.apache.camel.Exchange exchange)
        Specified by:
        matches in interface org.apache.camel.Predicate
        Overrides:
        matches in class ExpressionSupport
      • doEvaluate

        protected Object doEvaluate​(org.apache.camel.Exchange exchange,
                                    boolean closeStream)
        Strategy to evaluate the exchange
        Parameters:
        exchange - the exchange
        closeStream - whether to close the stream before returning from this method.
        Returns:
        the evaluated value
      • createIterator

        protected Iterator<?> createIterator​(org.apache.camel.Exchange exchange,
                                             InputStream in,
                                             String charset)
        Strategy to create the iterator
        Parameters:
        exchange - the exchange
        in - input stream to iterate
        charset - charset
        Returns:
        the iterator