Class PositionTrackingDataInputStream
java.lang.Object
de.pauleff.formats.binary.PositionTrackingDataInputStream
Enhanced DataInputStream wrapper that tracks read position for better error reporting.
Provides detailed context about where in the stream parsing errors occur.
- Author:
- Paul Ferlitz
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a position tracking input stream. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()createContextualError(String baseMessage) Creates a detailed error message with current parsing context.longReturns the current position in the stream.intReturns the current nesting depth in the NBT structure.bytereadByte()doublefloatvoidreadFully(byte[] b) voidreadFully(byte[] b, int off, int len) intreadInt()longreadLong()shortintintvoidsetCurrentContext(int depth, String tagName, int tagType) Sets the current tag context for error reporting.
-
Constructor Details
-
PositionTrackingDataInputStream
Creates a position tracking input stream.- Parameters:
in- The underlying input stream to wrap
-
-
Method Details
-
readFully
- Throws:
IOException
-
readFully
- Throws:
IOException
-
readByte
- Throws:
IOException
-
readUnsignedByte
- Throws:
IOException
-
readShort
- Throws:
IOException
-
readUnsignedShort
- Throws:
IOException
-
readInt
- Throws:
IOException
-
readLong
- Throws:
IOException
-
readFloat
- Throws:
IOException
-
readDouble
- Throws:
IOException
-
close
- Throws:
IOException
-
getBytesRead
public long getBytesRead()Returns the current position in the stream.- Returns:
- Number of bytes read so far
-
getTagDepth
public int getTagDepth()Returns the current nesting depth in the NBT structure.- Returns:
- Current tag depth (0 = root)
-
setCurrentContext
Sets the current tag context for error reporting.- Parameters:
depth- Current nesting depthtagName- Name of the tag being parsedtagType- Type ID of the tag being parsed
-
createContextualError
-