private void readSignatureMarkerAndVersionIfNeeded() throws IOException { if (readSignatureMarker) { readSignatureMarker = false; final byte marker = input.readByte(); if (marker != TokenTypes.SIGNATURE_MARKER) { throw new InvalidNormalizedNodeStreamException(String.format( "Invalid signature marker: %d", marker)); } final short version = input.readShort(); if (version != TokenTypes.LITHIUM_VERSION) { throw new InvalidNormalizedNodeStreamException(String.format("Unhandled stream version %s", version)); } } }
private void readSignatureMarkerAndVersionIfNeeded() throws IOException { if(readSignatureMarker) { readSignatureMarker = false; final byte marker = input.readByte(); if (marker != TokenTypes.SIGNATURE_MARKER) { throw new InvalidNormalizedNodeStreamException(String.format( "Invalid signature marker: %d", marker)); } final short version = input.readShort(); if (version != TokenTypes.LITHIUM_VERSION) { throw new InvalidNormalizedNodeStreamException(String.format("Unhandled stream version %s", version)); } } }
public static NormalizedNodeDataInput newDataInput(@Nonnull final DataInput input) throws IOException { final byte marker = input.readByte(); if (marker != TokenTypes.SIGNATURE_MARKER) { throw new InvalidNormalizedNodeStreamException(String.format("Invalid signature marker: %d", marker)); } final short version = input.readShort(); switch (version) { case TokenTypes.LITHIUM_VERSION: return new NormalizedNodeInputStreamReader(input, true); default: throw new InvalidNormalizedNodeStreamException(String.format("Unhandled stream version %s", version)); } }
/** * Creates a new {@link NormalizedNodeDataInput} instance that reads from the given input. This method first reads * and validates that the input contains a valid NormalizedNode stream. * * @param input the DataInput to read from * @return a new {@link NormalizedNodeDataInput} instance * @throws IOException if an error occurs reading from the input */ public static NormalizedNodeDataInput newDataInput(@Nonnull final DataInput input) throws IOException { final byte marker = input.readByte(); if (marker != TokenTypes.SIGNATURE_MARKER) { throw new InvalidNormalizedNodeStreamException(String.format("Invalid signature marker: %d", marker)); } final short version = input.readShort(); switch (version) { case TokenTypes.LITHIUM_VERSION: return new NormalizedNodeInputStreamReader(input, true); default: throw new InvalidNormalizedNodeStreamException(String.format("Unhandled stream version %s", version)); } }