class TapeLibraryStatusParser {

    public TapeLibraryState parse(String output) {
        ParametersChecker.checkParameter("Output param is required", output);

        final TapeLibraryState tapeLibraryState = new TapeLibraryState(StatusCode.OK);
        for (String s : output.split("\\|")) {

            // Slots
            if (s.trim().startsWith(STORAGE_ELEMENT)) {
                TapeSlot tapeSlot = new TapeSlot();
                tapeLibraryState.addToSlots(tapeSlot);

                extractSlotIndexAndType(s, tapeSlot);

                if (s.contains(EMPTY)) {
                    continue;
                }

                TapeCartridge cartridge = new TapeCartridge();
                tapeSlot.setTape(cartridge);

                extractSlotVolumeTag(s, cartridge);

                // Drives
            } else if (s.trim().startsWith(DATA_TRANSFER_ELEMENT)) {
                TapeDrive tapeDrive = new TapeDrive();
                tapeLibraryState.addToDrives(tapeDrive);
                extractDriveIndex(s, tapeDrive);

                if (s.contains(EMPTY)) {
                    continue;
                }

                TapeCartridge cartridge = new TapeCartridge();
                tapeDrive.setTape(cartridge);

                extractCartridgeSlotIndex(s, cartridge);

                extractDriveVolumeTag(s, cartridge);

            } else if (s.trim().startsWith(STORAGE_CHANGER)) {
                extractHeader(tapeLibraryState, s);

            }
        }

        return tapeLibraryState;
    }

}