Example usage for java.util TreeSet removeAll

List of usage examples for java.util TreeSet removeAll

Introduction

In this page you can find the example usage for java.util TreeSet removeAll.

Prototype

boolean removeAll(Collection<?> c);

Source Link

Document

Removes from this set all of its elements that are contained in the specified collection (optional operation).

Usage

From source file:org.wso2.carbon.mdm.api.User.java

/**
 * Update user in user store/*from www  .  j  av  a2s . c om*/
 *
 * @param userWrapper Wrapper object representing input json payload
 * @return {Response} Status of the request wrapped inside Response object
 * @throws MDMAPIException
 */
@PUT
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
public Response updateUser(UserWrapper userWrapper, @QueryParam("username") String username)
        throws MDMAPIException {
    UserStoreManager userStoreManager = MDMAPIUtils.getUserStoreManager();
    ResponsePayload responsePayload = new ResponsePayload();
    try {
        if (userStoreManager.isExistingUser(userWrapper.getUsername())) {
            Map<String, String> defaultUserClaims = buildDefaultUserClaims(userWrapper.getFirstname(),
                    userWrapper.getLastname(), userWrapper.getEmailAddress());
            if (StringUtils.isNotEmpty(userWrapper.getPassword())) {
                // Decoding Base64 encoded password
                byte[] decodedBytes = Base64.decodeBase64(userWrapper.getPassword());
                userStoreManager.updateCredentialByAdmin(userWrapper.getUsername(),
                        new String(decodedBytes, "UTF-8"));
                log.debug("User credential of username: " + userWrapper.getUsername() + " has been changed");
            }
            List<String> listofFilteredRoles = getFilteredRoles(userStoreManager, userWrapper.getUsername());
            final String[] existingRoles = listofFilteredRoles.toArray(new String[listofFilteredRoles.size()]);

            /*
            Use the Set theory to find the roles to delete and roles to add
            The difference of roles in existingRolesSet and newRolesSet needed to be deleted
            new roles to add = newRolesSet - The intersection of roles in existingRolesSet and newRolesSet
            */
            final TreeSet<String> existingRolesSet = new TreeSet<>();
            Collections.addAll(existingRolesSet, existingRoles);
            final TreeSet<String> newRolesSet = new TreeSet<>();
            Collections.addAll(newRolesSet, userWrapper.getRoles());
            existingRolesSet.removeAll(newRolesSet);
            // Now we have the roles to delete
            String[] rolesToDelete = existingRolesSet.toArray(new String[existingRolesSet.size()]);
            List<String> roles = new ArrayList<>(Arrays.asList(rolesToDelete));
            roles.remove(ROLE_EVERYONE);
            rolesToDelete = new String[0];
            // Clearing and re-initializing the set
            existingRolesSet.clear();
            Collections.addAll(existingRolesSet, existingRoles);
            newRolesSet.removeAll(existingRolesSet);
            // Now we have the roles to add
            String[] rolesToAdd = newRolesSet.toArray(new String[newRolesSet.size()]);
            userStoreManager.updateRoleListOfUser(userWrapper.getUsername(), rolesToDelete, rolesToAdd);
            userStoreManager.setUserClaimValues(userWrapper.getUsername(), defaultUserClaims, null);
            // Outputting debug message upon successful addition of user
            if (log.isDebugEnabled()) {
                log.debug("User by username: " + userWrapper.getUsername() + " was successfully updated.");
            }
            // returning response with success state
            responsePayload.setStatusCode(HttpStatus.SC_CREATED);
            responsePayload.setMessageFromServer(
                    "User by username: " + userWrapper.getUsername() + " was successfully updated.");
            return Response.status(HttpStatus.SC_CREATED).entity(responsePayload).build();
        } else {
            if (log.isDebugEnabled()) {
                log.debug("User by username: " + userWrapper.getUsername()
                        + " doesn't exists. Therefore, request made to update user was refused.");
            }
            // returning response with bad request state
            responsePayload.setStatusCode(HttpStatus.SC_CONFLICT);
            responsePayload.setMessageFromServer("User by username: " + userWrapper.getUsername()
                    + " doesn't  exists. Therefore, request made to update user was refused.");
            return Response.status(HttpStatus.SC_CONFLICT).entity(responsePayload).build();
        }
    } catch (UserStoreException | UnsupportedEncodingException e) {
        String msg = "Exception in trying to update user by username: " + userWrapper.getUsername();
        log.error(msg, e);
        throw new MDMAPIException(msg, e);
    }
}

From source file:com.joliciel.jochre.graphics.WhiteAreaFinder.java

List<Rectangle> getWhiteAreas(ImageGrid imageGrid, int blackThreshold, List<? extends Rectangle> blackAreas,
        int left, int top, int right, int bottom, double minWhiteAreaWidth, double minWhiteAreaHeight) {
    // figure out white areas based on shapes, not isPixelBlack
    List<Rectangle> whiteAreas = new ArrayList<Rectangle>();
    List<WhiteArea> openWhiteAreas = new ArrayList<WhiteArea>();
    TreeSet<Rectangle> blackAreasToConsider = new TreeSet<Rectangle>(new RectangleTopToBottomComparator());
    if (blackAreas != null)
        blackAreasToConsider.addAll(blackAreas);

    // stop "false" column separators from appearing at the top row, below a series of titles
    // these can be recognise because they radically narrow what is already a long strip
    // Now - doing this by getting horizontal boxes first
    //      double minRatioForExtension = 0.5;

    for (int y = top; y <= bottom; y++) {
        // get all white horizontal lines on current row
        List<WhiteLine> whiteLines = new ArrayList<WhiteLine>();
        boolean[] pixels = new boolean[right + 1];
        List<Rectangle> blackAreasToRemove = new ArrayList<Rectangle>();
        for (Rectangle blackArea : blackAreasToConsider) {
            if (blackArea.getBottom() < y)
                blackAreasToRemove.add(blackArea);
            if (blackArea.getTop() > y)
                break;
            if (blackArea.getBottom() >= y) {
                int maxLeft = blackArea.getLeft() > left ? blackArea.getLeft() : left;
                int minRight = blackArea.getRight() < right ? blackArea.getRight() : right;
                for (int i = maxLeft; i <= minRight; i++) {
                    pixels[i] = true;/* ww w .j a v a 2  s.  c o m*/
                }
            }
        }
        blackAreasToConsider.removeAll(blackAreasToRemove);
        boolean inWhite = false;
        int startWhite = 0;
        for (int x = left; x <= right; x++) {
            boolean isBlack = pixels[x];
            // alternate method to a list of rectangles: get black pixel directly
            if (imageGrid != null) {
                isBlack = imageGrid.isPixelBlack(x, y, blackThreshold);
            }
            if (!inWhite && !isBlack) {
                startWhite = x;
                inWhite = true;
            } else if (inWhite && isBlack) {
                WhiteLine whiteLine = new WhiteLine(startWhite, x - 1);
                whiteLines.add(whiteLine);
                inWhite = false;
            }
        }
        if (inWhite) {
            WhiteLine whiteLine = new WhiteLine(startWhite, right);
            whiteLines.add(whiteLine);
        }

        // check if the white horizontal lines extend existing rectangles
        List<WhiteArea> currentWhiteAreas = new ArrayList<WhiteArea>();
        for (WhiteLine whiteLine : whiteLines) {
            for (WhiteArea whiteArea : openWhiteAreas) {
                int maxLeft = whiteLine.start >= whiteArea.getLeft() ? whiteLine.start : whiteArea.getLeft();
                int minRight = whiteLine.end <= whiteArea.getRight() ? whiteLine.end : whiteArea.getRight();
                if (minRight - maxLeft >= minWhiteAreaWidth) {
                    // there is an overlap that's wide enough, add it
                    // but first check the ratio is above the minimum
                    //                  if ((double)(minRight - maxLeft) / (double) (whiteArea.getRight() - whiteArea.getLeft()) > minRatioForExtension) {
                    WhiteArea newWhiteArea = new WhiteArea(maxLeft, whiteArea.getTop(), minRight, y);
                    currentWhiteAreas.add(newWhiteArea);
                    //                  }
                }
            }
            WhiteArea whiteLineArea = new WhiteArea(whiteLine.start, y, whiteLine.end, y);
            currentWhiteAreas.add(whiteLineArea);
        }
        currentWhiteAreas.addAll(openWhiteAreas);

        // get rid of white areas with full overlap
        List<WhiteArea> whiteAreasToDelete = new ArrayList<WhiteArea>();
        for (int i = 0; i < currentWhiteAreas.size() - 1; i++) {
            WhiteArea whiteArea1 = currentWhiteAreas.get(i);
            for (int j = i + 1; j < currentWhiteAreas.size(); j++) {
                WhiteArea whiteArea2 = currentWhiteAreas.get(j);
                if (whiteArea1.getLeft() >= whiteArea2.getLeft() && whiteArea1.getTop() >= whiteArea2.getTop()
                        && whiteArea1.getRight() <= whiteArea2.getRight()
                        && whiteArea1.getBottom() <= whiteArea2.getBottom()) {
                    whiteAreasToDelete.add(whiteArea1);
                } else if (whiteArea2.getLeft() >= whiteArea1.getLeft()
                        && whiteArea2.getTop() >= whiteArea1.getTop()
                        && whiteArea2.getRight() <= whiteArea1.getRight()
                        && whiteArea2.getBottom() <= whiteArea1.getBottom()) {
                    whiteAreasToDelete.add(whiteArea2);
                }
            }
        }
        currentWhiteAreas.removeAll(whiteAreasToDelete);

        openWhiteAreas = new ArrayList<WhiteArea>();
        for (WhiteArea whiteArea : currentWhiteAreas) {
            if (whiteArea.getBottom() < y
                    && (whiteArea.getBottom() - whiteArea.getTop() >= minWhiteAreaHeight)) {
                LOG.debug("Adding " + whiteArea.toString());
                whiteAreas.add(whiteArea);
            } else if (whiteArea.getBottom() == y) {
                openWhiteAreas.add(whiteArea);
            }
        }
    }
    for (WhiteArea whiteArea : openWhiteAreas) {
        if (whiteArea.getBottom() - whiteArea.getTop() >= minWhiteAreaHeight) {
            LOG.debug("Adding " + whiteArea.toString());
            whiteAreas.add(whiteArea);
        }
    }
    return whiteAreas;
}

From source file:pku.sei.checkedcoverage.slicing.Slicer.java

/**
 * select the last location that was not checked, and create new slice criterion for it.
 * remove the relative lines from unchecked lines, until all location are sliced.
 * @return the new created slice location for every class.
 *//*from   w w w .j  a  v  a2s . c  om*/
public static HashMap<String, TreeSet<Long>> sliceForUnchecked() {
    System.out.println("Trying to add checks");
    HashMap<String, TreeSet<Long>> sliceCreated = new HashMap<String, TreeSet<Long>>();
    HashMap<String, HashSet<Instruction>> uncheckedMap = getUncheckedMap();
    Iterator<String> it = uncheckedMap.keySet().iterator();
    List<String> cris = new ArrayList<String>();
    int crisNr = 0;
    while (it.hasNext()) {
        String key = it.next();
        sliceCreated.put(key, new TreeSet<Long>());
        HashSet<Instruction> insts = uncheckedMap.get(key);
        TreeSet<Integer> unchecked = new TreeSet<Integer>();
        HashMap<Integer, String> critInfoMap = new HashMap<Integer, String>();
        HashMap<Integer, HashSet<String>> varsMap = new HashMap<Integer, HashSet<String>>();
        for (Instruction inst : insts) {
            if (inst.getType().equals(InstructionType.FIELD) || inst.getType().equals(InstructionType.VAR)) {
                unchecked.add(inst.getLineNumber());
                if (!critInfoMap.containsKey(inst.getLineNumber())) {
                    critInfoMap.put(inst.getLineNumber(),
                            inst.getMethod().getReadClass().getName() + "." + inst.getMethod().getName());
                }
                if (!varsMap.containsKey(inst.getLineNumber())) {
                    varsMap.put(inst.getLineNumber(), new HashSet<String>());
                }
                if (inst.getType().equals(InstructionType.FIELD)) {
                    FieldInstruction fieldinst = (FieldInstruction) inst;
                    varsMap.get(inst.getLineNumber()).add(fieldinst.getFieldName());
                } else if (inst.getType().equals(InstructionType.VAR)) {
                    VarInstruction varinst = (VarInstruction) inst;
                    if (varinst.getOpcode() == Opcodes.DSTORE || varinst.getOpcode() == Opcodes.ASTORE
                            || varinst.getOpcode() == Opcodes.LSTORE || varinst.getOpcode() == Opcodes.ISTORE
                            || varinst.getOpcode() == Opcodes.FSTORE || varinst.getOpcode() == Opcodes.RET) {
                        String varname = inst.getMethod().getLocalVariables()[varinst.getLocalVarIndex()]
                                .getName();
                        varsMap.get(inst.getLineNumber()).add(varname);
                    }
                }
            }
        }
        while (!unchecked.isEmpty()) {
            int last = unchecked.last();
            String cri = critInfoMap.get(last) + ":" + last + ":*";
            cris.add(cri);
            System.out.println(++crisNr + " new check(s) added!" + cri);
            unchecked.removeAll(sliceUnchecked(cri));
            sliceCreated.get(key).add((long) last);
            unchecked.remove(last);
        }
    }
    System.out.println("Done!");
    return sliceCreated;
}

From source file:com.joliciel.jochre.boundaries.SplitCandidateFinderImpl.java

@Override
public List<Split> findSplitCandidates(Shape shape) {
    List<Split> splitCandidates = new ArrayList<Split>();

    // generate a list giving the total distance from the top and bottom to the shape's edge
    // the hypothesis is that splits almost always occur at x-coordinates
    // where there's a summit in the distance to the shape's edge, between two valleys
    int[] edgeDistances = new int[shape.getWidth()];
    int[][] verticalContour = shape.getVerticalContour();
    for (int x = 0; x < shape.getWidth(); x++) {
        int edgeDistance = verticalContour[x][0] + ((shape.getHeight() - 1) - verticalContour[x][1]);
        if (edgeDistance > shape.getHeight() - 1)
            edgeDistance = shape.getHeight() - 1;

        edgeDistances[x] = edgeDistance;
    }//from  w  w w .  ja  va2s.c  om

    int[] maximaMinima = new int[shape.getWidth()];
    int lastDistance = -1;
    boolean rising = true;
    int i = 0;
    for (int edgeDistance : edgeDistances) {
        if (lastDistance >= 0) {
            if (edgeDistance < lastDistance && rising) {
                maximaMinima[i - 1] = 1;
            }
            if (edgeDistance > lastDistance && !rising) {
                maximaMinima[i - 1] = -1;
            }
        }
        if (edgeDistance > lastDistance) {
            rising = true;
        } else if (edgeDistance < lastDistance) {
            rising = false;
        }

        lastDistance = edgeDistance;
        i++;
    }
    maximaMinima[0] = 1;
    if (rising)
        maximaMinima[shape.getWidth() - 1] = 1;
    else
        maximaMinima[shape.getWidth() - 1] = -1;

    for (int x = 0; x < shape.getWidth(); x++) {
        String maxMin = "";
        if (maximaMinima[x] < 0)
            maxMin = " min";
        if (maximaMinima[x] > 0)
            maxMin = " max";
        LOG.trace("edgeDistance[" + x + "]: " + edgeDistances[x] + maxMin);
    }

    boolean haveMinimum = false;
    int lastMaximum = -1;
    int lastMinValue = 0;
    int lastMaxValue = 0;
    TreeSet<SplitCandidateValue> splitCandidateValues = new TreeSet<SplitCandidateFinderImpl.SplitCandidateValue>();
    for (i = 0; i < shape.getWidth(); i++) {
        if (maximaMinima[i] < 0) {
            haveMinimum = true;
            if (lastMaximum > 0) {
                double diff = (double) ((lastMaxValue - lastMinValue) + (lastMaxValue - edgeDistances[i]))
                        / 2.0;
                splitCandidateValues.add(new SplitCandidateValue(lastMaximum, diff));
            }
            lastMinValue = edgeDistances[i];
        }
        if (maximaMinima[i] > 0) {
            if (haveMinimum) {
                lastMaximum = i;
                lastMaxValue = edgeDistances[i];
            }
            haveMinimum = false;
        }
    }

    List<SplitCandidateValue> candidatesToRemove = new ArrayList<SplitCandidateFinderImpl.SplitCandidateValue>();
    for (SplitCandidateValue thisValue : splitCandidateValues) {
        if (candidatesToRemove.contains(thisValue))
            continue;
        for (SplitCandidateValue otherValue : splitCandidateValues) {
            if (candidatesToRemove.contains(otherValue))
                continue;
            if (otherValue.equals(thisValue))
                break;
            int distance = thisValue.getPosition() - otherValue.getPosition();
            if (distance < 0)
                distance = 0 - distance;
            if (distance < this.minDistanceBetweenSplits) {
                LOG.trace("Removing candidate " + otherValue.getPosition() + ", distance=" + distance);
                candidatesToRemove.add(otherValue);
            }
        }
    }
    splitCandidateValues.removeAll(candidatesToRemove);

    TreeMap<Integer, Split> splitCandidateMap = new TreeMap<Integer, Split>();
    for (SplitCandidateValue candidateValue : splitCandidateValues) {
        Split splitCandidate = boundaryServiceInternal.getEmptySplit(shape);
        splitCandidate.setPosition(candidateValue.getPosition());
        splitCandidateMap.put(candidateValue.getPosition(), splitCandidate);
    }

    for (Split split : splitCandidateMap.values())
        splitCandidates.add(split);
    return splitCandidates;
}

From source file:ch.admin.suis.msghandler.checker.StatusCheckerSessionImpl.java

/**
 * Looks into the internal DB and selects the IDs of the messages that
 * have the status SENT or FORWARDED. Then this method checks the receipts directory
 * of the Sedex adapter to see, for which message there is already a receipt.
 * The list of the found receipt is then returned. If there are no receipts, this
 * method returns an empty collection./*from w  w w.j a v a  2s . c o  m*/
 *
 * @see ch.admin.suis.msghandler.checker.StatusCheckerSession#getMessagesIds()
 */
@Override
public Collection<Receipt> getMessagesIds() throws LogServiceException {
    ArrayList<Receipt> receipts = new ArrayList<>();

    // the internal DB
    final LogService logService = context.getLogService();

    // the Sedex adapter's receipt directory
    File receiptsDir = new File(
            context.getClientConfiguration().getSedexAdapterConfiguration().getReceiptDir());

    // get the messages that have either FORWARDED or SENT as their status
    TreeSet<String> sentIds = new TreeSet<>(logService.getSentMessages());

    // loop over the files in the receipts directory
    // check for the files over there
    DirectoryStream<Path> files = FileUtils.listFiles(receiptsDir, FileFilters.XML_FILTER_PATH);

    if (files == null) {
        LOG.error("an I/O error occured while reading the receipts from the Sedex adapter; "
                + "check the message handler configuration to see whether the specified 'receipts' directory "
                + "for the Sedex Adapter actually exists");
        return Collections.emptyList();
    }

    //
    ArrayList<String> toBeRemoved = new ArrayList<>();
    // for each receipt found
    for (Path path : files) {
        try (InputStream reader = Files.newInputStream(path)) {
            Receipt receipt = Receipt.createFrom(reader);
            if (!sentIds.contains(receipt.getMessageId())) {
                continue;
            }
            // get the sent date for this receipt (it is not unfortunately in the receipt XML)
            receipt.setSentDate(ISO8601Utils.format(logService.getSentDate(receipt.getMessageId())));
            receipt.setReceiptFile(path.toFile());
            receipts.add(receipt);// add it now
            LOG.info(MessageFormat.format("message ID {0}: receipt found", receipt.getMessageId()));
            // set to remove the id from the tree
            toBeRemoved.add(receipt.getMessageId());
        } catch (FileNotFoundException e) {
            LOG.error("cannot find the file " + path.toString() + "; is it already removed?", e);
        } catch (IOException e) {
            LOG.error("cannot read the file " + path.toString(), e);
        } catch (JAXBException e) {
            LOG.error("cannot parse the file " + path.toString(), e);
        } catch (LogServiceException e) {
            closeStream(files);
            throw e; // In order to keep the current exception flow
        }

    }
    closeStream(files);

    // remove from the list
    sentIds.removeAll(toBeRemoved);

    // now, lets look at what has remained to find out, whether the Sedex adapter has just sent the files
    // but not received the receipt (look only at forwarded messages that are not "transparent")
    final File outputDir = new File(
            context.getClientConfiguration().getSedexAdapterConfiguration().getOutputDir());

    for (final String messageId : logService.getMessages(LogStatus.FORWARDED)) {

        // Skips execution if not all of the conditions below match
        if (sentIds.contains(messageId) && !logService.isTransparent(messageId)
                && !new File(outputDir, FileUtils.getDataFilename(messageId)).exists()) {

            // the envelope that we have created
            final Message message = getSentMessage(messageId);
            if (message == null) {
                // the file is send by the adapter but there is no receipt yet
                LOG.warn(MessageFormat.format(
                        "message ID {0}: message sent by the Sedex adapter, but there is no envelope in the Sedex sent directory",
                        messageId));
                continue;
            }
            // For each recipient, we generate a receipt
            for (String recipientId : message.getRecipientIds()) {
                receipts.add(generateReceipt(message, recipientId, messageId));
            }
            LOG.info("message has been sent by the Sedex adapter: " + messageId);

            // remove the id from the tree
            sentIds.remove(messageId);

        }

    }
    /* TODO sort out the receipts so that we can reliably process the situation where
         there is more than one receipt pro message*/
    return receipts;
}

From source file:library.Form_Library.java

License:asdf

private void fillData(File file) {
    Workbook workbook = null;/*from  w  ww  .j  av a 2  s  .  co  m*/
    try {
        try {
            workbook = Workbook.getWorkbook(file);
        } catch (IOException ex) {
            Logger.getLogger(Form_Library.class.getName()).log(Level.SEVERE, null, ex);
        }
        Sheet sheet = workbook.getSheet(0);

        ArrayList<Integer> trung = new ArrayList();
        TreeSet<Integer> kotrung = new TreeSet();
        for (int j = 1; j < sheet.getRows(); j++) {
            if (!sheet.getCell(0, j).getContents().startsWith("BK-")) {
                break;
            }
            for (int k = 0; k < dmBook.getRowCount(); k++) {
                if (sheet.getCell(0, j).getContents().equalsIgnoreCase(dmBook.getValueAt(k, 0).toString())) {
                    dmBook.setValueAt(Integer.parseInt((Integer.parseInt(dmBook.getValueAt(k, 7).toString())
                            + Integer.parseInt(sheet.getCell(7, j).getContents())) + ""), k, 7);
                    BookList.updateQuantity(Integer.parseInt(dmBook.getValueAt(k, 7).toString()),
                            dmBook.getValueAt(k, 0).toString());
                    trung.add(j);
                    System.out.println("====" + j);
                    break;
                } else {
                    System.out.println("====" + j);
                    kotrung.add(j);
                }
            }

        }
        kotrung.removeAll(trung);
        for (Integer integer : trung) {
            System.out.println(integer);
        }
        for (Integer integer : kotrung) {
            System.out.println(integer);
        }
        for (Integer j : kotrung) {
            if (!sheet.getCell(0, j).getContents().startsWith("BK-")) {
                break;
            }
            String BookID = "";
            String bookName = "", authorID = "", publisherID = "", supplierID = "", categoryID = "", shelf = "",
                    image = "";
            int price = 0, quantity = 0, rowNum = 0, colNum = 0;
            Vector d = new Vector();
            for (int i = 0; i < sheet.getColumns(); i++) {
                Cell cell = sheet.getCell(i, j);

                if (i == 0) {
                    BookID += sheet.getCell(i, j).getContents();
                } else if (i == 1) {
                    bookName += sheet.getCell(i, j).getContents();
                } else if (i == 2) {
                    authorID += sheet.getCell(i, j).getContents();
                } else if (i == 3) {
                    publisherID += sheet.getCell(i, j).getContents();
                } else if (i == 4) {
                    supplierID += sheet.getCell(i, j).getContents();
                } else if (i == 5) {
                    categoryID += sheet.getCell(i, j).getContents();
                } else if (i == 6) {
                    price = Integer.parseInt(sheet.getCell(i, j).getContents());
                } else if (i == 7) {
                    quantity = Integer.parseInt(sheet.getCell(i, j).getContents());
                } else if (i == 8) {
                    shelf += sheet.getCell(i, j).getContents();
                } else if (i == 9) {
                    rowNum = Integer.parseInt(sheet.getCell(i, j).getContents());
                } else if (i == 10) {
                    colNum = Integer.parseInt(sheet.getCell(i, j).getContents());
                } else if (i == 11) {
                    image += sheet.getCell(i, j).getContents();
                }

                d.add(cell.getContents());
                System.out.println(cell.getContents());
            }
            Book book = new Book(BookID, bookName, authorID, publisherID, supplierID, categoryID, price,
                    quantity, shelf, rowNum, colNum, image);
            BookList.add(book);
            System.out.println(d.get(0));
            d.add("\n");
            dmBook.addRow(d);
        }

    } catch (BiffException e) {
        e.printStackTrace();
    }
}