private void parseHead(String line) throws PuzzleFormatException,
            PuzzleException {
        //"puzzle name" puzzleSetName xDimension yDimension
        if (preferredDimension != null) {
            throw new PuzzleFormatException("The puzzle seems to have two headers.");
        }
        String xDimension = "";
        String yDimension = "";
        String pN = "";
        String pS = "";
        String[] tokens;
        Dimension panelSize;
        String[] dequoted = cull(line.split("\""));
        //If there are two strings in dequoted, the puzzle is nameless.
        //That's fine.
        if (dequoted.length == 2) {
            tokens = cull(line.split("[ \t]+"));
            if (tokens.length == 4) {
                //The puzzle is part of a set. Remember this.
                pS = tokens[1].trim();
                xDimension = tokens[2].trim();
                yDimension = tokens[3].trim();
            } else if (tokens.length == 3) {
                xDimension = tokens[1].trim();
                yDimension = tokens[2].trim();
            } else {
                throw new PuzzleException("Puzzle's header is invalid.");
            }
        } else if (dequoted.length == 3) {
            //If there are exactly three strings in dequoted,
            //the puzzle has a name.
            pN = dequoted[1];
            tokens = cull(dequoted[2].split("[ \t]+"));

            if (tokens.length == 4) {
                //The puzzle is part of a set. Remember this.
                pS = tokens[1].trim();
                xDimension = tokens[2].trim();
                yDimension = tokens[3].trim();
            } else if (tokens.length == 3) {
                xDimension = tokens[1].trim();
                yDimension = tokens[2].trim();
            } else {
                throw new PuzzleException("Puzzle's header is invalid.");
            }
        } else {
            throw new PuzzleException("Puzzle's header is too long.");
        }

        try {
            panelSize = new Dimension(Integer.parseInt(xDimension),
                    Integer.parseInt(yDimension));
        } catch (Exception ex) {
            throw new PuzzleException("Puzzle dimensions couldn't be "
                    + "converted to integers: " + xDimension + ", "
                    + yDimension);
        }
        this.preferredDimension = panelSize;
        this.puzzleName = pN;
        this.puzzleSet = pS;
    }