Package org.owasp.dependencycheck.xml
Class XmlInputStream
- java.lang.Object
-
- java.io.InputStream
-
- java.io.FilterInputStream
-
- org.owasp.dependencycheck.xml.XmlInputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
@NotThreadSafe public class XmlInputStream extends java.io.FilterInputStreamCleans up often very bad XML. Primarily, this will convert named HTM entities into their HTM encoded Unicode code point representation.- Strips leading white space
- Recodes £ etc to &#...;
- Recodes lone & as &
This is a slightly modified (class/method rename) from an SO answer: https://stackoverflow.com/questions/7286428/help-the-java-sax-parser-to-understand-bad-xml
- Author:
- https://stackoverflow.com/users/823393/oldcurmudgeon
-
-
Constructor Summary
Constructors Constructor Description XmlInputStream(java.io.InputStream in)Constructs a new XML Input Stream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intlength()NB: This is a Troll length (i.e. it goes 1, 2, many) so 2 actually means "at least 2"intread()Reads the next byte.intread(@org.jetbrains.annotations.NotNull byte[] data, int offset, int length)Reads the next length of bytes from the stream into the given byte array at the given offset.java.lang.StringtoString()To string implementation.-
Methods inherited from class java.io.FilterInputStream
available, close, mark, markSupported, read, reset, skip
-
-
-
-
Method Detail
-
length
public int length()
NB: This is a Troll length (i.e. it goes 1, 2, many) so 2 actually means "at least 2"- Returns:
- the length
-
read
public int read() throws java.io.IOExceptionReads the next byte.- Overrides:
readin classjava.io.FilterInputStream- Returns:
- the byte read
- Throws:
java.io.IOException- thrown when there is an problem reading
-
read
public int read(@NotNull @org.jetbrains.annotations.NotNull byte[] data, int offset, int length) throws java.io.IOExceptionReads the next length of bytes from the stream into the given byte array at the given offset.- Overrides:
readin classjava.io.FilterInputStream- Parameters:
data- the buffer to store the data readoffset- the offset in the buffer to start writinglength- the length of data to read- Returns:
- the number of bytes read
- Throws:
java.io.IOException- thrown when there is an issue with the underlying stream
-
toString
public java.lang.String toString()
To string implementation.- Overrides:
toStringin classjava.lang.Object- Returns:
- a string representation of the data given and read from the stream.
-
-