Example usage for java.lang Integer getInteger

List of usage examples for java.lang Integer getInteger

Introduction

In this page you can find the example usage for java.lang Integer getInteger.

Prototype

public static Integer getInteger(String nm) 

Source Link

Document

Determines the integer value of the system property with the specified name.

Usage

From source file:com.adeptj.runtime.server.Server.java

private int handlePortAvailability(Config httpConf) {
    Integer port = Integer.getInteger(Constants.SYS_PROP_SERVER_PORT);
    if (port == null) {
        LOGGER.warn("No port specified via system property: [{}], using default port: [{}]",
                Constants.SYS_PROP_SERVER_PORT, httpConf.getInt(Constants.KEY_PORT));
        port = httpConf.getInt(Constants.KEY_PORT);
    }/*from www. j a  v  a2 s.com*/
    // Note: Shall we do it ourselves or let server do it later? Problem may arise in OSGi Framework provisioning
    // as it is being started already and another server start(from same location) will again start new OSGi
    // Framework which may interfere with already started OSGi Framework as the bundle deployment, heap dump,
    // OSGi configurations directory is common, this is unknown at this moment but just to be on safer side doing this.
    if (Boolean.getBoolean(ServerConstants.SYS_PROP_CHECK_PORT) && !isPortAvailable(port)) {
        LOGGER.error("Port: [{}] already used, shutting down JVM!!", port);
        // Let the LOGBACK cleans up it's state.
        LogbackManager.getInstance().getLoggerContext().stop();
        System.exit(-1); // NOSONAR
    }
    return port;
}

From source file:com.taikang.dic.ltci.service.impl.AgencyStaffImpl.java

@Override
@Transactional/*from   www . j  av a 2s .c om*/
public boolean insertStaff(String path) throws Exception {

    //?---
    File agencyfile = new File(path);
    InputStream agencyIn = new FileInputStream(agencyfile);
    Workbook angencyWorkbook = Workbook.getWorkbook(agencyIn);

    //?Sheet
    int agencySheetNum = angencyWorkbook.getNumberOfSheets();
    logger.info("========sheet?" + agencySheetNum + "=========");
    //sheet
    for (int i = 0; i < agencySheetNum; i++) {
        Sheet sheet = angencyWorkbook.getSheet(i);
        //?Sheet?????????0?
        int rowNum = sheet.getRows();
        logger.info("===?" + rowNum + "========");
        //
        for (int j = 1; j < rowNum; j++) {
            int columnNum = sheet.getColumns();
            logger.info("===?" + columnNum + "========");
            StaffDO staffDO = new StaffDO();

            staffDO.setStaffid(UUID.randomUUID().toString().replaceAll("-", ""));
            staffDO.setIsValid(IsValidEnum.NO_DELETE.getValue());
            staffDO.setCreatedTime(new Date());
            staffDO.setOperatedTime(new Date());
            if (null == sheet.getCell(0, j).getContents() || "".equals(sheet.getCell(0, j).getContents())) {
                continue;
            }
            //
            for (int c = 0; c < columnNum; c++) {
                Cell cell = sheet.getCell(c, j); //
                String content = cell.getContents();
                //               logger.info("=====??" + content + "========");

                //??
                if ("".equals(content) || content == null) {
                    continue;
                }

                switch (c) {
                case 0:
                    staffDO.setEmpCode(content);
                    break;
                case 1:
                    staffDO.setStaffName(content);
                    break;
                case 2:
                    staffDO.setAgencyCode(content);
                    break;
                case 3:
                    staffDO.setAgencyName(content);
                    break;
                case 4:
                    staffDO.setStaffPhone(content);
                    break;
                case 5:
                    staffDO.setCredentialType(Integer.getInteger(content));
                    break;
                case 6:
                    staffDO.setCredentialNumber(content);
                    break;
                case 7:
                    staffDO.setCredentialValidityDate(DateFormatUtil.strToDateTime(content));
                    break;
                case 8:
                    staffDO.setStaffGender(Integer.getInteger(content));
                    break;
                case 9:
                    staffDO.setHighestEducation(content);
                    break;
                case 10:
                    staffDO.setAcquireDegree(content);
                    break;
                case 11:
                    staffDO.setDiplomaDate(DateFormatUtil.strToDateTime(content));
                    break;
                case 12:
                    staffDO.setDegreeDate(DateFormatUtil.strToDateTime(content));
                    break;
                case 13:
                    staffDO.setJobScope(content);
                    break;
                case 14:
                    staffDO.setStaffLevel(content);
                    break;
                case 15:
                    staffDO.setCategory(content);
                    break;
                case 16:
                    staffDO.setRemark(content);
                    break;
                case 17:
                    staffDO.setAuditState(Integer.parseInt(content));
                    break;
                case 18:
                    staffDO.setCreatedBy(content);
                    break;
                case 19:
                    staffDO.setCreatedOrg(content);
                    break;

                default:
                    break;
                }
            }
            String areaCode = staffDO.getAgencyCode();
            //? ?
            String staffCode = this.getStaffCode(areaCode);
            //orgCode??,????
            while (true) {
                StaffDOExample doExample = new StaffDOExample();
                com.taikang.dic.ltci.model.StaffDOExample.Criteria criteria = doExample.createCriteria();
                criteria.andStaffCodeEqualTo(staffCode);
                List<StaffDO> selectByExample = staffDAO.selectByExample(doExample);

                if (selectByExample.size() <= 0) {
                    //? ?code?? ????
                    break;
                }
                staffCode = this.getStaffCode(staffCode);
            }

            staffDO.setStaffCode(staffCode);
            logger.info("====???" + JsonUtils.makeJsonForObject(staffDO)
                    + "============");
            int insertLength = staffDAO.insertSelective(staffDO);
            if (insertLength < 0) {
                throw new InsertRepeatException("?");
            }
        }
    }
    return true;
}

From source file:com.gnadenheimer.mg3.utils.Utils.java

public void printNotaDeCredito(TblNotasDeCredito notaDeCredito) {
    try {// w ww .j  av a2 s. c  o m

        Map parameters = new HashMap();
        parameters.put("nota_de_credito_nro", notaDeCredito.getNro());
        parameters.put("factura_nro", notaDeCredito.getNroFactura().getNro());
        parameters.put("fechahora", java.sql.Date.valueOf(notaDeCredito.getFechahora().toLocalDate()));
        parameters.put("razon_social", notaDeCredito.getNroFactura().getRazonSocial());
        parameters.put("ruc", notaDeCredito.getNroFactura().getRuc());
        parameters.put("domicilio", notaDeCredito.getNroFactura().getDomicilio());
        parameters.put("box", notaDeCredito.getNroFactura().getCasillaDeCorreo() == null ? ""
                : notaDeCredito.getNroFactura().getCasillaDeCorreo().toString());
        parameters.put("importe_aporte", notaDeCredito.getNroFactura().getImporteAporte());
        parameters.put("importe_donacion", notaDeCredito.getNroFactura().getImporteDonacion());
        parameters.put("usuario", notaDeCredito.getIdUser().getNombrecompleto());

        /*String reportFactura = Preferences.userRoot().node("MG").get("formateFactura", "Preimpreso sin rejilla").equals("Preimpreso sin rejilla")
            ? "nota_de_credito_con_rejilla"
            : "nota_de_credito";*/
        JasperReport report = JasperCompileManager
                .compileReport(getClass().getResourceAsStream("/reports/nota_de_credito_con_rejilla.jrxml"));

        JasperPrint jasperPrint = JasperFillManager.fillReport(report, parameters, new JREmptyDataSource());

        //JasperViewer jReportsViewer = new JasperViewer(jasperPrint, false);
        //jReportsViewer.setVisible(true);
        jasperPrint.setLeftMargin(
                Integer.getInteger(Preferences.userRoot().node("MG").get("facturaLeftMargin", "0")));
        jasperPrint.setTopMargin(
                Integer.getInteger(Preferences.userRoot().node("MG").get("facturaTopMargin", "0")));
        JasperPrintManager.printReport(jasperPrint, false);
    } catch (Exception ex) {
        App.showException(Thread.currentThread().getStackTrace()[1].getMethodName(), ex.getMessage(), ex);
        LOGGER.error(Thread.currentThread().getStackTrace()[1].getMethodName(), ex);
    }
}

From source file:io.seldon.api.controller.JsClientController.java

private ItemBean createItem(ConsumerBean c, String itemId, String title, String type, String category,
        String subcategory, String tags, String imgUrl) {
    ItemBean item = null;// w w  w  . j a v  a  2 s.c  om

    try {
        item = itemService.getItem(c, itemId, false);
    } catch (APIException e) {
        //item does not exist
        return item;
    }

    //item not imported yet
    if (item.getType() == Constants.ITEM_NOT_VALID) {
        return null;
    }
    //Item Type
    int iType = item.getType();
    if (type != null && type.length() > 0) {
        iType = Integer.getInteger(type);
    }

    //Attributes
    final Map<String, String> attributes = item.getAttributesName();
    final Map<String, String> newAttributes = new HashMap<>();
    //title
    if (title != null && title.length() > 0 && !title.equals(attributes.get(Constants.ITEM_ATTR_TITLE))) {
        newAttributes.put(Constants.ITEM_ATTR_TITLE, title.trim());
    }
    //image
    if (imgUrl != null && imgUrl.length() > 0 && !imgUrl.equals(attributes.get(Constants.ITEM_ATTR_IMG))) {
        newAttributes.put(Constants.ITEM_ATTR_IMG, imgUrl.trim());
    }
    //category
    if (category != null && category.length() > 0
            && !category.equals(attributes.get(Constants.ITEM_ATTR_CAT))) {
        newAttributes.put(Constants.ITEM_ATTR_CAT, category.trim());
    }
    //subcategory
    if (subcategory != null && subcategory.length() > 0
            && !subcategory.equals(attributes.get(Constants.ITEM_ATTR_SUBCAT))) {
        newAttributes.put(Constants.ITEM_ATTR_SUBCAT, subcategory.trim());

    }
    //tags
    if (tags != null && tags.length() > 0 && !tags.equals(attributes.get(Constants.ITEM_ATTR_TAGS))) {
        newAttributes.put(Constants.ITEM_ATTR_TAGS, tags.trim());
    }

    //Check if the item needs to be updated
    boolean update = false;
    if (iType != item.getType()) {
        item.setType(iType);
        update = true;
    }
    if (newAttributes.size() > 0) {
        item.setAttributesName(newAttributes);
        update = true;
    }
    if (update) {
        return item;
    } else {
        return null;
    }
}

From source file:com.gnadenheimer.mg.utils.Utils.java

public void printNotaDeCredito(TblNotasDeCredito notaDeCredito) {
    try {//  w ww  .  ja v  a2 s .  co  m

        Map parameters = new HashMap();
        parameters.put("nota_de_credito_nro", notaDeCredito.getNro());
        parameters.put("factura_nro", notaDeCredito.getNroFactura().getNro());
        parameters.put("fechahora", java.sql.Date.valueOf(notaDeCredito.getFechahora().toLocalDate()));
        parameters.put("razon_social", notaDeCredito.getNroFactura().getRazonSocial());
        parameters.put("ruc", notaDeCredito.getNroFactura().getRuc());
        parameters.put("domicilio", notaDeCredito.getNroFactura().getDomicilio());
        parameters.put("box", notaDeCredito.getNroFactura().getCasillaDeCorreo() == null ? ""
                : notaDeCredito.getNroFactura().getCasillaDeCorreo().toString());
        parameters.put("importe_aporte", notaDeCredito.getNroFactura().getImporteAporte());
        parameters.put("importe_donacion", notaDeCredito.getNroFactura().getImporteDonacion());
        parameters.put("usuario", notaDeCredito.getIdUser().getNombrecompleto());

        String reportNC = Preferences.userRoot().node("MG").get("formatoFactura", "Preimpreso sin rejilla");
        switch (reportNC) {
        case "Preimpreso sin rejilla":
            reportNC = "nota_de_credito_con_rejilla";
            break;
        case "Preimpreso con rejilla":
            reportNC = "nota_de_credito";
            break;
        case "Preimpreso sin rejilla Bethel":
            reportNC = "nota_de_credito_con_rejilla_bethel";
            break;
        default:
            break;
        }
        JasperReport report = JasperCompileManager
                .compileReport(getClass().getResourceAsStream("/reports/" + reportNC + ".jrxml"));
        JasperPrint jasperPrint = JasperFillManager.fillReport(report, parameters, new JREmptyDataSource());

        //JasperViewer jReportsViewer = new JasperViewer(jasperPrint, false);
        //jReportsViewer.setVisible(true);
        jasperPrint.setLeftMargin(
                Integer.getInteger(Preferences.userRoot().node("MG").get("facturaLeftMargin", "0")));
        jasperPrint.setTopMargin(
                Integer.getInteger(Preferences.userRoot().node("MG").get("facturaTopMargin", "0")));
        JasperPrintManager.printReport(jasperPrint, false);
    } catch (Exception ex) {
        JOptionPane.showMessageDialog(null,
                Thread.currentThread().getStackTrace()[1].getMethodName() + " - " + ex.getMessage());
        LOGGER.error(Thread.currentThread().getStackTrace()[1].getMethodName(), ex);
    }
}

From source file:io.adeptj.runtime.server.Server.java

private int handlePortAvailability(Config httpConf) {
    Integer port = Integer.getInteger(SYS_PROP_SERVER_PORT);
    if (port == null) {
        LOGGER.warn("No port specified via system property: [{}], using default port: [{}]",
                SYS_PROP_SERVER_PORT, httpConf.getInt(KEY_PORT));
        port = httpConf.getInt(KEY_PORT);
    }//from   ww w  . j  a v  a 2 s. c  o m
    // Note: Shall we do it ourselves or let server do it later? Problem may arise in OSGi Framework provisioning
    // as it is being started already and another server start(from same location) will again start new OSGi
    // Framework which may interfere with already started OSGi Framework as the bundle deployment, heap dump,
    // OSGi configurations directory is common, this is unknown at this moment but just to be on safer side doing this.
    if (Boolean.getBoolean(SYS_PROP_CHECK_PORT) && !isPortAvailable(port)) {
        LOGGER.error("Port: [{}] already used, shutting down JVM!!", port);
        // Let the LOGBACK cleans up it's state.
        LogbackManager.INSTANCE.getLoggerContext().stop();
        System.exit(-1); // NOSONAR
    }
    return port;
}

From source file:hu.elte.ik.robotika.futar.vertx.backend.verticle.HTTPVerticle.java

@Override
public void start() {

    init();/*from   w  ww.  j a  v  a 2s  .  com*/
    HttpServer http = vertx.createHttpServer();
    Router router = Router.router(vertx);

    // Setup websocket connection handling
    router.route("/eventbus/*").handler(eventBusHandler());

    router.route("/ws").handler(this::handleWebSocketConnection);

    // Handle robot position data
    router.route("/api/robotposition/:data").handler(this::handleRobotPositionData);

    // Setup http session auth handling
    router.route().handler(CookieHandler.create());
    router.route().handler(BodyHandler.create());
    router.route().handler(SessionHandler.create(LocalSessionStore.create(vertx)));

    // Simple auth service which uses a properties file for user/role info
    AuthProvider authProvider = ShiroAuth.create(vertx, ShiroAuthRealmType.PROPERTIES, new JsonObject());

    // We need a user session handler too to make sure the user is stored in
    // the session between requests
    router.route().handler(UserSessionHandler.create(authProvider));

    // Any requests to URI starting '/rest/' require login
    router.route("/rest/*").handler(SimpleAuthHandler.create(authProvider));

    // Serve the static private pages from directory 'rest'
    // user/getAll TEST page
    router.route("/rest/user/getAll").handler(this::getAllUser);

    // Preload
    router.route("/rest/info").handler(this::getInfo);

    router.route("/loginhandler").handler(SimpleLoginHandler.create(authProvider));

    router.route("/logout").handler(context -> {
        context.clearUser();
        // Status OK
        context.response().setStatusCode(HttpStatus.SC_OK).end();
    });

    router.route().handler(StaticHandler.create().setWebRoot(webRoot));
    http.websocketHandler(ws -> {
        String id = java.util.UUID.randomUUID().toString();
        ws.handler(buffer -> {
            try {
                JsonObject response = new JsonObject(buffer.toString());
                if (response.getString("action") != null && response.getString("action").equals("login.robot")
                        && sockets.get(id) == null) {
                    log.info("robot logged in:" + id);
                    sockets.put(id, ws);
                    JsonObject pb = new JsonObject();
                    pb.put("robotId", id);
                    vertx.eventBus().publish("new.robot", Json.encode(pb));
                } else if (response.getString("action") != null
                        && response.getString("action").equals("found.bluetooth")) {
                    log.info("found.bluetooth");
                    JsonObject pb = response.getJsonObject("data");
                    if (placedBTDevices.get(pb.getString("address")) == null
                            && newBTDevices.get(pb.getString("address")) == null) {
                        JsonObject data = new JsonObject(Json.encode(pb));
                        data.remove("rssi");
                        newBTDevices.put(pb.getString("address"), data);
                        log.info("New bt device: " + buffer);
                        vertx.eventBus().publish("new.bt.device", Json.encode(data));
                    }

                    btData.get(id).remove(pb.getString("address"));

                    log.info("Update bt data: " + id + " " + pb.getString("address") + " "
                            + pb.getInteger("rssi"));
                    double x = (pb.getInteger("rssi") - (-40.0)) / ((-10.0) * 2.0);
                    log.info("sub calc res: " + x);
                    double d = Math.pow(10.0, x);
                    //RSSI (dBm) = -10n log10(d) + A
                    log.info("the calculated distance is around: " + d + "m");
                    btData.get(id).put(pb.getString("address"), d * 27);
                } else if (response.getString("action") != null
                        && response.getString("action").equals("start.bluetooth.scan")) {
                    log.info("start.bluetooth.scan");
                    btData.remove(id);
                    btData.put(id, new LinkedHashMap<String, Double>());

                } else if (response.getString("action") != null
                        && response.getString("action").equals("finished.bluetooth.scan")) {
                    log.info("finished.bluetooth.scan");
                    if (btData.get(id).size() >= 3) {
                        double x0 = 0, y0 = 0, r0 = 0, x1 = 0, y1 = 0, r1 = 0, x2 = 0, y2 = 0, r2 = 0;
                        int i = 0;
                        for (Map.Entry<String, Double> entry : btData.get(id).entrySet()) {
                            String key = entry.getKey();
                            JsonObject placedBT = placedBTDevices.get(key);
                            if (placedBT == null) {
                                log.info("placedBT is null, the key was: " + key);
                                continue;
                            }
                            double value = entry.getValue();
                            if (i == 0) {

                                x0 = placedBT.getDouble("x");
                                y0 = placedBT.getDouble("y");
                                r0 = value;
                                log.info("fill first circle x: " + x0 + " y: " + y0 + " r: " + r0);
                            } else if (i == 1) {

                                x1 = placedBT.getDouble("x");
                                y1 = placedBT.getDouble("y");
                                r1 = value;
                                log.info("fill second circle x: " + x1 + " y: " + y1 + " r: " + r1);
                            } else if (i == 2) {

                                x2 = placedBT.getDouble("x");
                                y2 = placedBT.getDouble("y");
                                r2 = value;
                                log.info("fill third circle x: " + x2 + " y: " + y2 + " r: " + r2);
                            } else {
                                break;
                            }
                            i++;
                        }

                        if (i == 3) {
                            log.info("start calculation");
                            if (calculateThreeCircleIntersection(x0, y0, r0, x1, y1, r1, x2, y2, r2, id)) {
                                log.info("solved circle intersection");
                            } else {
                                log.info("cannot solve circle interseciton");
                            }
                        } else {
                            log.info("there was not enough BT device: " + i);
                        }

                    } else {
                        log.info("There is not enough BT data to calculate the location of the robot.");
                    }
                }

                log.info("got the following message from " + id + ": " + Json.encode(response));

            } catch (Exception e) {
                log.info("Cannot process the following buffer: " + buffer);
                log.error(e);
            }
        });
        ws.endHandler(e -> {
            JsonObject response = new JsonObject();
            response.put("robotId", id);
            vertx.eventBus().publish("logout.robot", Json.encode(response));
            sockets.remove(id);
            positionedRobots.remove(id);
            btData.remove(id);
            log.info("The following robot logged out: " + id);
        });
    }).requestHandler(router::accept).listen(Integer.getInteger("http.port"),
            System.getProperty("http.address", "0.0.0.0"));
}

From source file:org.openmrs.module.htmlformentry.element.PatientDetailSubmissionElement.java

@SuppressWarnings("unused")
@Override/*from   www.  j av  a  2s . c om*/
public Collection<FormSubmissionError> validateSubmission(FormEntryContext context,
        HttpServletRequest request) {
    List<FormSubmissionError> ret = new ArrayList<FormSubmissionError>();

    List<FormSubmissionError> ageOrBirthdDateErrorMessage = new ArrayList<FormSubmissionError>();

    validateMandatoryField(context, request, genderWidget, genderErrorWidget, ret);

    if (required) {
        validateMandatoryField(context, request, identifierTypeValueWidget, identifierTypeValueErrorWidget,
                ret);
    }

    validateMandatoryField(context, request, identifierLocationWidget, identifierLocationErrorWidget, ret);

    if (nameWidget != null) {
        PersonName personName = nameWidget.getValue(context, request);
        if (!StringUtils.hasText(personName.getGivenName())
                || !StringUtils.hasText(personName.getFamilyName())) {
            ret.add(new FormSubmissionError(context.getFieldName(nameErrorWidget),
                    Context.getMessageSourceService().getMessage("htmlformentry.error.name.required")));
        }
    }

    if (ageWidget != null && validateMandatoryField(context, request, ageWidget, ageErrorWidget,
            ageOrBirthdDateErrorMessage)) {
        try {
            Number value = (Number) ageWidget.getValue(context, request);
        } catch (Exception e) {
            ret.add(new FormSubmissionError(context.getFieldName(ageErrorWidget), e.getMessage()));
        }
    }

    if (birthDateWidget != null && validateMandatoryField(context, request, birthDateWidget,
            birthDateErrorWidget, ageOrBirthdDateErrorMessage)) {
        try {
            if (birthDateWidget.getValue(context, request) != null
                    && OpenmrsUtil.compare((Date) birthDateWidget.getValue(context, request), new Date()) > 0) {
                ret.add(new FormSubmissionError(context.getFieldName(birthDateErrorWidget),
                        Context.getMessageSourceService().getMessage("htmlformentry.error.cannotBeInFuture")));
            }
        } catch (Exception e) {
            ret.add(new FormSubmissionError(context.getFieldName(birthDateErrorWidget), e.getMessage()));
        }
    }

    if (ageWidget != null && birthDateWidget != null) {
        if (ageOrBirthdDateErrorMessage.size() > 1) {
            ret.add(new FormSubmissionError(context.getFieldName(ageErrorWidget),
                    Context.getMessageSourceService().getMessage("Person.birthdate.required")));
        }
    } else {
        ret.addAll(ageOrBirthdDateErrorMessage);
    }

    if (identifierTypeWidget != null && identifierTypeValueWidget != null) {
        String identifierTypeId = (String) identifierTypeWidget.getValue(context, request);
        String identifierValue = (String) identifierTypeValueWidget.getValue(context, request);
        if (StringUtils.hasText(identifierValue)) {
            try {
                validateIdentifier(Integer.getInteger(identifierTypeId), identifierValue);
            } catch (Exception e) {
                ret.add(new FormSubmissionError(context.getFieldName(identifierTypeValueErrorWidget),
                        e.getMessage()));
            }
        }
    }

    return ret;
}

From source file:org.crank.javax.faces.component.MenuRenderer.java

void renderSelect(FacesContext context, UIComponent component) throws IOException {

    ResponseWriter writer = context.getResponseWriter();
    assert (writer != null);

    if (logger.isLoggable(Level.FINER)) {
        logger.log(Level.FINER, "Rendering 'select'");
    }/* w  w  w .  ja  v  a2s  . c  om*/
    writer.startElement("select", component);
    writeIdAttributeIfNecessary(context, writer, component);
    writer.writeAttribute("name", component.getClientId(context), "clientId");
    // render styleClass attribute if present.
    String styleClass = null;
    if (null != (styleClass = (String) component.getAttributes().get("styleClass"))) {
        writer.writeAttribute("class", styleClass, "styleClass");
    }
    if (!getMultipleText(component).equals("")) {
        writer.writeAttribute("multiple", true, "multiple");
    }

    // Determine how many option(s) we need to render, and update
    // the component's "size" attribute accordingly;  The "size"
    // attribute will be rendered as one of the "pass thru" attributes
    int itemCount = getOptionNumber(context, component);
    if (logger.isLoggable(Level.FINE)) {
        logger.fine("Rendering " + itemCount + " options");
    }
    // If "size" is *not* set explicitly, we have to default it correctly
    Integer size = Integer.getInteger((String) component.getAttributes().get("size"));
    if (size == null || size == Integer.MIN_VALUE) {
        //TODO: HACK... need to 'cifer why the size isn't getting processed correctly from the tag - Paul T.
        if (itemCount > 20) {
            size = 20;
        } else {
            size = itemCount;
        }
    }
    writeDefaultSize(writer, size);

    RenderKitUtils.renderPassThruAttributes(context, writer, component, new String[] { "size" });
    RenderKitUtils.renderXHTMLStyleBooleanAttributes(writer, component);
    // Now, render the "options" portion...
    renderOptions(context, component);

    writer.endElement("select");

}

From source file:org.eclairjs.nashorn.Utils.java

public static int toInt(Object num) {
    int x;//from   ww  w . ja v  a2 s.co m
    if (num instanceof Long) {
        x = ((Long) num).intValue();
    } else if (num instanceof Double) {
        x = ((Double) num).intValue();
    } else if (num instanceof String) {
        x = Integer.getInteger((String) num);
    } else {
        x = (int) num;
    }
    return x;
}