Interface ScanningContext<Type>

Type Parameters:
Type - The concrete type of the entries to be scanned.
All Known Implementing Classes:
ProtonScanningContext

public interface ScanningContext<Type>
A search context used when scanning encoded AMQP types for entries or sections that match any of a predetermined set of possible values usually made up of type encodings that would match the incoming encoded data.

A scanning context is typically created with both the encoded and unencoded form of the value to be scanned for so that a call to the match function can provide an callback that will be provided the value to be sought without the need to perform a complete decode of the scanned data.

The context is a single threaded actor whose state can be modified during the scanning cycle in order to optimize the number of comparisons done as the scan progresses. The caller must ensure a context is not passed to scanning operations that are occurring concurrently.

  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Allows for the scanner to optimize reading of encoded data by determining if the target of the matching context has been found in which case the scanner can consume any remaining encoded bytes without regard for the matcher.
    boolean
    matches(TypeDecoder<?> typeDecoder, ProtonBuffer candidate, int candidateLength, Consumer<Type> matchConsumer)
    Returns true if the encoded entry bytes match against the search domain of the scan matching context and calls the provided match Consumer with the original unencoded form of the matched entry.
    void
    Reset the context to its original state at the end of a complete scan which should allow the context to be used again when a new scan is started (e.g.
  • Method Details

    • reset

      void reset()
      Reset the context to its original state at the end of a complete scan which should allow the context to be used again when a new scan is started (e.g. isComplete() should start returning false).
    • isComplete

      boolean isComplete()
      Allows for the scanner to optimize reading of encoded data by determining if the target of the matching context has been found in which case the scanner can consume any remaining encoded bytes without regard for the matcher. In this state any call to matches(TypeDecoder, ProtonBuffer, int, Consumer) should return false as the target has already been found.
      Returns:
      true if the target of the matching context has already been found.
    • matches

      boolean matches(TypeDecoder<?> typeDecoder, ProtonBuffer candidate, int candidateLength, Consumer<Type> matchConsumer)
      Returns true if the encoded entry bytes match against the search domain of the scan matching context and calls the provided match Consumer with the original unencoded form of the matched entry. The caller must provide the size of the encoded value being checked to allow for pass of the source bytes without copying which could contain more entries following the candidate value in question.

      The matcher must not alter the read offset of the provided buffer, doing so can corrupt the buffer state and likely cause decode exceptions on follow on decode operations.

      Parameters:
      typeDecoder - The type decoder of the encoded type that is contained in the buffer.
      candidate - Buffer whose first read index is the start of the encoded bytes.
      candidateLength - The region of the candidate buffer that contains the encoded bytes
      matchConsumer - An optional consumer that should be called if a match is found.
      Returns:
      true if the candidate matches a target in the search domain.