public static String toString(byte[] data, byte encodingFlag) throws ItlException, UnsupportedEncodingException { switch (encodingFlag) { case 0: // Seems only to be used for URLs return new String(data, "us-ascii"); case 1: return new String(data, "utf-16be"); case 2: return new String(data, "utf-8"); case 3: return new String(data, "windows-1252"); default: throw new ItlException("Unknown encoding type " + encodingFlag + " for string: " + new String(data)); } }
static void expectZeroBytes(Input di, int count, String where) throws IOException, ItlException { byte[] ba = new byte[count]; di.readFully(ba); for (int i = 0; i < ba.length; i++) { byte b = ba[i]; if (b != 0x00) { throw new ItlException("Expected " + count + " zero bytes" + where + ". Was: 0x" + Integer.toHexString(b) + " at offset " + i); } } }
} catch (GeneralSecurityException gse) { if (mode == Cipher.DECRYPT_MODE) { throw new ItlException("Unable to decrypt library", gse); } else if (mode == Cipher.ENCRYPT_MODE) { throw new ItlException("Unable to encrypt library", gse); } else { throw new ItlException("Unable to perform operation", gse);
throw new ItlException("Error when unzipping the file contents", ioe);
boolean endCurrentPlaylist(boolean foundPlaylist) throws ItlException { // Ensure that when a playlist ends that the correct number of playlist // items were found and if the current playlist is not the desired // playlist null out the current playlist/title so it gets ignored if (currentPlaylistItems != null) { List<Integer> items = currentPlaylistItems.getItemIds(); int expectedCount = currentPlaylistItems.getExpectedItemCount(); if (expectedCount != items.size()) { throw new ItlException("Expected " + expectedCount + " playlist items, got " + items.size()); } if (!foundPlaylist) { currentPlaylistItems = null; currentPlaylistTitle = null; } } return foundPlaylist; } }
private static byte[] deflate(byte[] orig) throws ItlException { try { DeflaterInputStream isDeflater = new DeflaterInputStream(new ByteArrayInputStream(orig), new Deflater()); ByteArrayOutputStream osCompressed = new ByteArrayOutputStream(orig.length); byte[] deflated = new byte[orig.length]; int iCompressed; while(true) { iCompressed = isDeflater.read(deflated, 0, orig.length); if (iCompressed == -1) break; osCompressed.write(deflated, 0, iCompressed); } deflated = osCompressed.toByteArray(); osCompressed.close(); isDeflater.close(); return deflated; } catch (IOException ioe) { throw new ItlException("Error when zipping the file contents", ioe); } }
throw new ItlException("Playlist item outside playlist content");
private void readHptm(Input di, int length) throws IOException, ItlException { byte[] unknown = new byte[16]; di.readFully(unknown); int key = di.readInt(); // System.out.println(" Key: " + key); if (currentPlaylist == null) { throw new ItlException("Playlist item outside playlist content"); } currentPlaylist.addItem(key); di.skipBytes(length - 28); }
throw new ItlException("Playlist title defined twice"); (!currentPlaylistItems.getItemIds().isEmpty()))) throw new ItlException("Playlist items not continuous"); foundPlaylist = true; } else { throw new ItlException("Playlist title without defined playlist"); (!currentPlaylistItems.getItemIds().isEmpty()))) throw new ItlException("Playlist items not continuous"); throw new ItlException("Playlist info without defined playlist"); throw new ItlException("Unhandled type: " + type); } else { throw new ItlException("Library format not understood; bad decryption (unhandled type: " + type + ")");
String trackTitle = readGenericHohm(di); if (currentTrack == null) { throw new ItlException("Title with no track defined"); String albumTitle = readGenericHohm(di); if (currentTrack == null) { throw new ItlException("Album title with no track defined"); String artist = readGenericHohm(di); if (currentTrack == null) { throw new ItlException("Artist with no track defined"); String genre = readGenericHohm(di); if (currentTrack == null) { throw new ItlException("genre with no track defined"); String kind = readGenericHohm(di); if (currentTrack == null) { throw new ItlException("kind with no track defined"); throw new ItlException("Podcast URL with no track defined"); String location = readGenericHohm(di); if (currentTrack == null) { throw new ItlException("kind with no track defined"); throw new ItlException("URL with no track defined"); throw new ItlException("Podcast URL with no track defined");