Class ProtonScanningContext<Type>
java.lang.Object
org.apache.qpid.protonj2.codec.decoders.ProtonScanningContext<Type>
- All Implemented Interfaces:
- ScanningContext<Type>,- StreamScanningContext<Type>
public class ProtonScanningContext<Type>
extends Object
implements ScanningContext<Type>, StreamScanningContext<Type>
- 
Constructor SummaryConstructorsConstructorDescriptionProtonScanningContext(Class<?> expectedType, List<Type> entries, List<ProtonBuffer> encodedEntries) ProtonScanningContext(Class<?> expectedType, Type entry, ProtonBuffer encodedEntry) 
- 
Method SummaryModifier and TypeMethodDescriptionstatic ProtonScanningContext<String>createStringScanContext(String... entries) Creates a new scanning context for the given collection ofStringvalues.static ProtonScanningContext<String>createStringScanContext(Collection<String> entries) Creates a new scanning context for the given collection ofStringvalues.static ProtonScanningContext<Symbol>createSymbolScanContext(Collection<Symbol> entries) Creates a new scanning context for the given collection ofSymbolvalues.static ProtonScanningContext<Symbol>createSymbolScanContext(Symbol... entries) Creates a new scanning context for the given collection ofSymbolvalues.booleanAllows 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.booleanmatches(StreamTypeDecoder<?> typeDecoder, InputStream stream, int encodedSize, Consumer<Type> matchConsumer) Returns true if the encoded entry bytes match against the search domain of the scan matching context and calls the provided matchConsumerwith the original unencoded form of the matched entry.booleanmatches(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 matchConsumerwith the original unencoded form of the matched entry.voidreset()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.
- 
Constructor Details- 
ProtonScanningContext
- 
ProtonScanningContextpublic ProtonScanningContext(Class<?> expectedType, List<Type> entries, List<ProtonBuffer> encodedEntries) 
 
- 
- 
Method Details- 
resetpublic void reset()Description copied from interface:ScanningContextReset 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.ScanningContext.isComplete()should start returning false).- Specified by:
- resetin interface- ScanningContext<Type>
- Specified by:
- resetin interface- StreamScanningContext<Type>
 
- 
isCompletepublic boolean isComplete()Description copied from interface:ScanningContextAllows 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 toScanningContext.matches(TypeDecoder, ProtonBuffer, int, Consumer)should return false as the target has already been found.- Specified by:
- isCompletein interface- ScanningContext<Type>
- Specified by:
- isCompletein interface- StreamScanningContext<Type>
- Returns:
- true if the target of the matching context has already been found.
 
- 
matchespublic boolean matches(TypeDecoder<?> typeDecoder, ProtonBuffer candidate, int candidateLength, Consumer<Type> matchConsumer) Description copied from interface:ScanningContextReturns true if the encoded entry bytes match against the search domain of the scan matching context and calls the provided matchConsumerwith 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. - Specified by:
- matchesin interface- ScanningContext<Type>
- 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.
 
- 
matchespublic boolean matches(StreamTypeDecoder<?> typeDecoder, InputStream stream, int encodedSize, Consumer<Type> matchConsumer) Description copied from interface:StreamScanningContextReturns true if the encoded entry bytes match against the search domain of the scan matching context and calls the provided matchConsumerwith 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 implementation must not consume the encoded bytes which requires that the provided InputStreamsupport mark and reset of the stream position. The implementation should check for mark support in the provided stream and throw anUnsupportedOperationExceptionif it is not supported.- Specified by:
- matchesin interface- StreamScanningContext<Type>
- Parameters:
- typeDecoder- The stream type decoder of the encoded type that is contained in the buffer.
- stream- Buffer whose first read index is the start of the encoded bytes.
- encodedSize- 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.
 
- 
createStringScanContextCreates a new scanning context for the given collection ofStringvalues.- Parameters:
- entries- The- Stringentries that will be scanned for in the encoded- Map
- Returns:
- a StreamScanningContextfor the collection of string entries.
 
- 
createStringScanContextCreates a new scanning context for the given collection ofStringvalues.- Parameters:
- entries- The- Stringentries that will be scanned for in the encoded- Map
- Returns:
- a StreamScanningContextfor the collection of string entries.
 
- 
createSymbolScanContextCreates a new scanning context for the given collection ofSymbolvalues.- Parameters:
- entries- The- Symbolentries that will be scanned for in the encoded- Map
- Returns:
- a StreamScanningContextfor the collection of symbol entries.
 
- 
createSymbolScanContextCreates a new scanning context for the given collection ofSymbolvalues.- Parameters:
- entries- The- Symbolentries that will be scanned for in the encoded- Map
- Returns:
- a StreamScanningContextfor the collection of symbol entries.
 
 
-