Package org.jacoco.core.internal
Class ContentTypeDetector
- java.lang.Object
-
- org.jacoco.core.internal.ContentTypeDetector
-
public class ContentTypeDetector extends java.lang.Object
Detector for content types of binary streams based on a magic headers.
-
-
Field Summary
Fields Modifier and Type Field Description private static int
BUFFER_SIZE
static int
CLASSFILE
File type Java classstatic int
GZFILE
File type GZIP compressed Dataprivate java.io.InputStream
in
static int
PACK200FILE
File type Pack200 archiveprivate int
type
static int
UNKNOWN
Unknown file typestatic int
ZIPFILE
File type ZIP archive
-
Constructor Summary
Constructors Constructor Description ContentTypeDetector(java.io.InputStream in)
Creates a new detector based on the given input.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static int
determineType(java.io.InputStream in)
java.io.InputStream
getInputStream()
Returns an input stream instance to read the complete content (including the header) of the underlying stream.int
getType()
Returns the detected file type.private static int
readInt(java.io.InputStream in)
-
-
-
Field Detail
-
UNKNOWN
public static final int UNKNOWN
Unknown file type- See Also:
- Constant Field Values
-
CLASSFILE
public static final int CLASSFILE
File type Java class- See Also:
- Constant Field Values
-
ZIPFILE
public static final int ZIPFILE
File type ZIP archive- See Also:
- Constant Field Values
-
GZFILE
public static final int GZFILE
File type GZIP compressed Data- See Also:
- Constant Field Values
-
PACK200FILE
public static final int PACK200FILE
File type Pack200 archive- See Also:
- Constant Field Values
-
BUFFER_SIZE
private static final int BUFFER_SIZE
- See Also:
- Constant Field Values
-
in
private final java.io.InputStream in
-
type
private final int type
-
-
Constructor Detail
-
ContentTypeDetector
public ContentTypeDetector(java.io.InputStream in) throws java.io.IOException
Creates a new detector based on the given input. To process the complete original input afterwards use the stream returned bygetInputStream()
.- Parameters:
in
- input to read the header from- Throws:
java.io.IOException
- if the stream can't be read
-
-
Method Detail
-
determineType
private static int determineType(java.io.InputStream in) throws java.io.IOException
- Throws:
java.io.IOException
-
readInt
private static int readInt(java.io.InputStream in) throws java.io.IOException
- Throws:
java.io.IOException
-
getInputStream
public java.io.InputStream getInputStream()
Returns an input stream instance to read the complete content (including the header) of the underlying stream.- Returns:
- input stream containing the complete content
-
getType
public int getType()
Returns the detected file type.- Returns:
- file type
-
-