Package org.owasp.dependencycheck.utils
Class JsonArrayFixingInputStream
- java.lang.Object
-
- java.io.InputStream
-
- org.owasp.dependencycheck.utils.JsonArrayFixingInputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public class JsonArrayFixingInputStream extends java.io.InputStreamFixes a poorly formatted jSON array such as those returned bygo list -json -m all.Example:
{ "name1": "value" } { "name2" : "value" }Would be transformed into:[{ "name1": "value" }, { "name2" : "value" }]Note that this is a naive implementation and will incorrectly transform a stream if there are '}' contained within the names of values.
- Author:
- Jeremy Long
-
-
Constructor Summary
Constructors Constructor Description JsonArrayFixingInputStream(java.io.InputStream in)Constructs a new filtering input stream used to fix a poorly formatted JSON array.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intavailable()voidclose()protected booleanisWhiteSpace(byte c)Tests if the byte passed in is a white space character.booleanmarkSupported()intread()intread(byte[] b)intread(byte[] b, int off, int len)longskip(long n)
-
-
-
Method Detail
-
read
public int read() throws java.io.IOException- Specified by:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
read
public int read(byte[] b) throws java.io.IOException- Overrides:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
read
public int read(byte[] b, int off, int len) throws java.io.IOException- Overrides:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
skip
public long skip(long n) throws java.io.IOException- Overrides:
skipin classjava.io.InputStream- Throws:
java.io.IOException
-
available
public int available() throws java.io.IOException- Overrides:
availablein classjava.io.InputStream- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.InputStream- Throws:
java.io.IOException
-
markSupported
public boolean markSupported()
- Overrides:
markSupportedin classjava.io.InputStream
-
isWhiteSpace
protected boolean isWhiteSpace(byte c)
Tests if the byte passed in is a white space character.- Parameters:
c- the byte representing the character to test- Returns:
trueif the byte is white space; otherwisefalse
-
-