Class DataFormatReaders
- java.lang.Object
-
- com.fasterxml.jackson.databind.deser.DataFormatReaders
-
public class DataFormatReaders extends java.lang.Object
Alternative toDataFormatDetector
that needs to be used when using data-binding.- Since:
- 2.1
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
DataFormatReaders.AccessorForReader
We need sub-class here as well, to be able to access efficiently.static class
DataFormatReaders.Match
Result class, similar toDataFormatMatcher
-
Field Summary
Fields Modifier and Type Field Description protected int
_maxInputLookahead
Maximum number of leading bytes of the input that we can read to determine data format.protected com.fasterxml.jackson.core.format.MatchStrength
_minimalMatch
Strength of minimal match we accept as the answer, unless better matches are found.protected com.fasterxml.jackson.core.format.MatchStrength
_optimalMatch
Strength of match we consider to be good enough to be used without checking any other formats.protected ObjectReader[]
_readers
Ordered list of readers which both represent data formats to detect (in precedence order, starting with highest) and contain factories used for actual detection.static int
DEFAULT_MAX_INPUT_LOOKAHEAD
By default we will look ahead at most 64 bytes; in most cases, much less (4 bytes or so) is needed, but we will allow bit more leniency to support data formats that need more complex heuristics.
-
Constructor Summary
Constructors Constructor Description DataFormatReaders(ObjectReader... detectors)
DataFormatReaders(java.util.Collection<ObjectReader> detectors)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DataFormatReaders.Match
findFormat(byte[] fullInputData)
Method to call to find format that given content (full document) has, as per configuration of this detector instance.DataFormatReaders.Match
findFormat(byte[] fullInputData, int offset, int len)
Method to call to find format that given content (full document) has, as per configuration of this detector instance.DataFormatReaders.Match
findFormat(java.io.InputStream in)
Method to call to find format that content (accessible via givenInputStream
) given has, as per configuration of this detector instance.java.lang.String
toString()
DataFormatReaders
with(DeserializationConfig config)
DataFormatReaders
with(ObjectReader[] readers)
DataFormatReaders
withMaxInputLookahead(int lookaheadBytes)
DataFormatReaders
withMinimalMatch(com.fasterxml.jackson.core.format.MatchStrength minMatch)
DataFormatReaders
withOptimalMatch(com.fasterxml.jackson.core.format.MatchStrength optMatch)
DataFormatReaders
withType(JavaType type)
-
-
-
Field Detail
-
DEFAULT_MAX_INPUT_LOOKAHEAD
public static final int DEFAULT_MAX_INPUT_LOOKAHEAD
By default we will look ahead at most 64 bytes; in most cases, much less (4 bytes or so) is needed, but we will allow bit more leniency to support data formats that need more complex heuristics.- See Also:
- Constant Field Values
-
_readers
protected final ObjectReader[] _readers
Ordered list of readers which both represent data formats to detect (in precedence order, starting with highest) and contain factories used for actual detection.
-
_optimalMatch
protected final com.fasterxml.jackson.core.format.MatchStrength _optimalMatch
Strength of match we consider to be good enough to be used without checking any other formats. Default value isMatchStrength.SOLID_MATCH
,
-
_minimalMatch
protected final com.fasterxml.jackson.core.format.MatchStrength _minimalMatch
Strength of minimal match we accept as the answer, unless better matches are found. Default value isMatchStrength.WEAK_MATCH
,
-
_maxInputLookahead
protected final int _maxInputLookahead
Maximum number of leading bytes of the input that we can read to determine data format.Default value is
DEFAULT_MAX_INPUT_LOOKAHEAD
.
-
-
Constructor Detail
-
DataFormatReaders
public DataFormatReaders(ObjectReader... detectors)
-
DataFormatReaders
public DataFormatReaders(java.util.Collection<ObjectReader> detectors)
-
-
Method Detail
-
withOptimalMatch
public DataFormatReaders withOptimalMatch(com.fasterxml.jackson.core.format.MatchStrength optMatch)
-
withMinimalMatch
public DataFormatReaders withMinimalMatch(com.fasterxml.jackson.core.format.MatchStrength minMatch)
-
with
public DataFormatReaders with(ObjectReader[] readers)
-
withMaxInputLookahead
public DataFormatReaders withMaxInputLookahead(int lookaheadBytes)
-
with
public DataFormatReaders with(DeserializationConfig config)
-
withType
public DataFormatReaders withType(JavaType type)
-
findFormat
public DataFormatReaders.Match findFormat(java.io.InputStream in) throws java.io.IOException
Method to call to find format that content (accessible via givenInputStream
) given has, as per configuration of this detector instance.- Returns:
- Matcher object which contains result; never null, even in cases where no match (with specified minimal match strength) is found.
- Throws:
java.io.IOException
-
findFormat
public DataFormatReaders.Match findFormat(byte[] fullInputData) throws java.io.IOException
Method to call to find format that given content (full document) has, as per configuration of this detector instance.- Returns:
- Matcher object which contains result; never null, even in cases where no match (with specified minimal match strength) is found.
- Throws:
java.io.IOException
-
findFormat
public DataFormatReaders.Match findFormat(byte[] fullInputData, int offset, int len) throws java.io.IOException
Method to call to find format that given content (full document) has, as per configuration of this detector instance.- Returns:
- Matcher object which contains result; never null, even in cases where no match (with specified minimal match strength) is found.
- Throws:
java.io.IOException
- Since:
- 2.1
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-