Package com.fasterxml.jackson.core.format

# Class DataFormatMatcher

java.lang.Object
com.fasterxml.jackson.core.format.DataFormatMatcher

public class DataFormatMatcher extends Object
Result object constructed by `DataFormatDetector` when requested to detect format of given input data.

## Field Summary

Fields
Modifier and Type
Field
Description
`protected final byte[]`
`_bufferedData`
Content read during format matching process
`protected final int`
`_bufferedLength`
Number of bytes available in buffer.
`protected final int`
`_bufferedStart`
Pointer to the first byte in buffer available for reading
`protected final JsonFactory`
`_match`
Factory that produced sufficient match (if any)
`protected final MatchStrength`
`_matchStrength`
Strength of match with `_match`
`protected final InputStream`
`_originalStream`

## Constructor Summary

Constructors
Modifier
Constructor
Description
`protected`
`DataFormatMatcher(InputStream in, byte[] buffered, int bufferedStart, int bufferedLength, JsonFactory match, MatchStrength strength)`

## Method Summary

Modifier and Type
Method
Description
`JsonParser`
`createParserWithMatch()`
`InputStream`
`getDataStream()`
Method to use for accessing input for which format detection has been done.
`JsonFactory`
`getMatch()`
Accessor for `JsonFactory` that represents format that data matched.
`String`
`getMatchedFormatName()`
Accessor for getting brief textual name of matched format if any (null if none).
`MatchStrength`
`getMatchStrength()`
Method for accessing strength of the match, if any; if no match, will return `MatchStrength.INCONCLUSIVE`.
`boolean`
`hasMatch()`
Accessor to use to see if any formats matched well enough with the input data.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### _originalStream

protected final InputStream _originalStream

### _bufferedData

protected final byte[] _bufferedData
Content read during format matching process

### _bufferedStart

protected final int _bufferedStart
Pointer to the first byte in buffer available for reading

### _bufferedLength

protected final int _bufferedLength
Number of bytes available in buffer.

### _match

protected final JsonFactory _match
Factory that produced sufficient match (if any)

### _matchStrength

protected final MatchStrength _matchStrength
Strength of match with `_match`

## Constructor Details

### DataFormatMatcher

protected DataFormatMatcher(InputStream in, byte[] buffered, int bufferedStart, int bufferedLength, JsonFactory match, MatchStrength strength)

## Method Details

### hasMatch

public boolean hasMatch()
Accessor to use to see if any formats matched well enough with the input data.

Returns:
  Whether format has a match

### getMatchStrength

public MatchStrength getMatchStrength()
Method for accessing strength of the match, if any; if no match, will return `MatchStrength.INCONCLUSIVE`.

Returns:
  Strength of match

### getMatch

public JsonFactory getMatch()
Accessor for `JsonFactory` that represents format that data matched.

Returns:
  Relevant `JsonFactory` to indicate matched format

### getMatchedFormatName

public String getMatchedFormatName()
Accessor for getting brief textual name of matched format if any (null if none). Equivalent to:

       return hasMatch() ? getMatch().getFormatName() : null;

Returns:
  Name of the format that is acceptable match, if any; `null` if none

### createParserWithMatch

public JsonParser createParserWithMatch() throws IOException

Throws:
  `IOException`

### getDataStream

public InputStream getDataStream()
Method to use for accessing input for which format detection has been done. This must be used instead of using stream passed to detector unless given stream itself can do buffering. Stream will return all content that was read during matching process, as well as remaining contents of the underlying stream.

Returns:
  InputStream to use for reading actual content using format detected