@Test public void testVerifyVorbisHeaderCapturePatternInvalidHeaderQuite() throws ParserException { ParsableByteArray header = new ParsableByteArray( new byte[] {0x01, 'v', 'o', 'r', 'b', 'i', 's'}); assertThat(verifyVorbisHeaderCapturePattern(0x99, header, true)).isFalse(); }
public static boolean verifyVorbisHeaderCapturePattern(int headerType, ParsableByteArray header, boolean quiet) throws ParserException { if (header.bytesLeft() < 7) { if (quiet) { return false; } else { throw new ParserException("too short header: " + header.bytesLeft()); } } if (header.readUnsignedByte() != headerType) { if (quiet) { return false; } else { throw new ParserException("expected header type " + Integer.toHexString(headerType)); } } if (!(header.readUnsignedByte() == 'v' && header.readUnsignedByte() == 'o' && header.readUnsignedByte() == 'r' && header.readUnsignedByte() == 'b' && header.readUnsignedByte() == 'i' && header.readUnsignedByte() == 's')) { if (quiet) { return false; } else { throw new ParserException("expected characters 'vorbis'"); } } return true; }
VorbisUtil { public static boolean verifyVorbisHeaderCapturePattern(int headerType, ParsableByteArray header, boolean quiet) throws ParserException { if (header.bytesLeft() < 7) { if (quiet) { return false; } else { throw new ParserException("too short header: " + header.bytesLeft()); } } if (header.readUnsignedByte() != headerType) { if (quiet) { return false; } else { throw new ParserException("expected header type " + Integer.toHexString(headerType)); } } if (!(header.readUnsignedByte() == 'v' && header.readUnsignedByte() == 'o' && header.readUnsignedByte() == 'r' && header.readUnsignedByte() == 'b' && header.readUnsignedByte() == 'i' && header.readUnsignedByte() == 's')) { if (quiet) { return false; } else { throw new ParserException("expected characters 'vorbis'"); } } return true; } }
VorbisUtil { public static boolean verifyVorbisHeaderCapturePattern(int headerType, ParsableByteArray header, boolean quiet) throws ParserException { if (header.bytesLeft() < 7) { if (quiet) { return false; } else { throw new ParserException("too short header: " + header.bytesLeft()); } } if (header.readUnsignedByte() != headerType) { if (quiet) { return false; } else { throw new ParserException("expected header type " + Integer.toHexString(headerType)); } } if (!(header.readUnsignedByte() == 'v' && header.readUnsignedByte() == 'o' && header.readUnsignedByte() == 'r' && header.readUnsignedByte() == 'b' && header.readUnsignedByte() == 'i' && header.readUnsignedByte() == 's')) { if (quiet) { return false; } else { throw new ParserException("expected characters 'vorbis'"); } } return true; } private  VorbisUtil(); }
VorbisUtil { public static boolean verifyVorbisHeaderCapturePattern(int headerType, ParsableByteArray header, boolean quiet) throws ParserException { if (header.bytesLeft() < 7) { if (quiet) { return false; } else { throw new ParserException("too short header: " + header.bytesLeft()); } } if (header.readUnsignedByte() != headerType) { if (quiet) { return false; } else { throw new ParserException("expected header type " + Integer.toHexString(headerType)); } } if (!(header.readUnsignedByte() == 'v' && header.readUnsignedByte() == 'o' && header.readUnsignedByte() == 'r' && header.readUnsignedByte() == 'b' && header.readUnsignedByte() == 'i' && header.readUnsignedByte() == 's')) { if (quiet) { return false; } else { throw new ParserException("expected characters 'vorbis'"); } } return true; } private  VorbisUtil(); static int iLog(int x); static VorbisIdHeader readVorbisIdentificationHeader(ParsableByteArray headerData); static CommentHeader readVorbisCommentHeader(ParsableByteArray headerData); static boolean verifyVorbisHeaderCapturePattern(int headerType, ParsableByteArray header,
      boolean quiet); static Mode[] readVorbisModes(ParsableByteArray headerData, int channels); }
VorbisUtil { public static boolean verifyVorbisHeaderCapturePattern(int headerType, ParsableByteArray header, boolean quiet) throws ParserException { if (header.bytesLeft() < 7) { if (quiet) { return false; } else { throw new ParserException("too short header: " + header.bytesLeft()); } } if (header.readUnsignedByte() != headerType) { if (quiet) { return false; } else { throw new ParserException("expected header type " + Integer.toHexString(headerType)); } } if (!(header.readUnsignedByte() == 'v' && header.readUnsignedByte() == 'o' && header.readUnsignedByte() == 'r' && header.readUnsignedByte() == 'b' && header.readUnsignedByte() == 'i' && header.readUnsignedByte() == 's')) { if (quiet) { return false; } else { throw new ParserException("expected characters 'vorbis'"); } } return true; } private  VorbisUtil(); static int iLog(int x); static VorbisIdHeader readVorbisIdentificationHeader(ParsableByteArray headerData); static CommentHeader readVorbisCommentHeader(ParsableByteArray headerData); static boolean verifyVorbisHeaderCapturePattern(int headerType, ParsableByteArray header,
      boolean quiet); static Mode[] readVorbisModes(ParsableByteArray headerData, int channels);  }