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.ocs.dynamo.ui.composite.table.CustomTreeTable.java

/**
 * Returns the default precision/* ww  w.ja  v a2  s  . c o m*/
 * 
 * @return
 */
protected int getDefaultPrecision() {
    Integer i = Integer.getInteger(DynamoConstants.SP_DECIMAL_PRECISION);
    return i == null ? EntityModel.DEFAULT_PRECISION : i;
}

From source file:org.kuali.coeus.common.framework.person.KcPerson.java

/**
 * Calculates the age based on a date of birth and the current system date.
 * @param dob the date of birth//from  ww w . j  a  va 2s.com
 * @return the age in days
 */
private Integer calcAge(Date dob) {
    return Integer.getInteger(DurationFormatUtils.formatPeriod(dob.getTime(), new Date().getTime(), "y"));
}

From source file:org.egov.works.web.actions.estimate.FinancialDetailAction.java

public String viewDepositWorksFolioReport() throws ValidationException {
    Fund fund = null;/*www .jav  a  2  s .  c o  m*/
    CChartOfAccounts coa = null;
    try {
        final AbstractEstimate abstractEstimate = new AbstractEstimate();
        final Accountdetailtype accountdetailtype = (Accountdetailtype) persistenceService
                .find("from Accountdetailtype where name=?", "DEPOSITCODE");
        fund = (Fund) persistenceService.find("from Fund where id=?", financialDetail.getFund().getId());
        coa = (CChartOfAccounts) persistenceService.find("from CChartOfAccounts where id=?",
                financialDetail.getCoa().getId());
        final Map<String, Object> reportParams = getDepositFolioDetails(abstractEstimate, fund, coa,
                accountdetailtype, depositCodeId, asOnDate);
        totalDepositAmount = (BigDecimal) reportParams.get("totalDeposit");

        if (latestCumulative != 0.00D || totalDepositAmount != BigDecimal.ZERO) {
            final BudgetFolioDetail e = new BudgetFolioDetail();
            e.setSrlNo(Integer.getInteger(""));
            e.setBudgetApprNo("<b>Latest Status :</b>");
            e.setEstimateNo("");
            e.setNameOfWork("");
            e.setEstimateDate("");
            e.setCumulativeTotal(latestCumulative);
            e.setBalanceAvailable(totalDepositAmount);
            e.setCumulativeExpensesIncurred(latestCumulativeExpense);
            e.setActualBalanceAvailable(totalDepositAmount.doubleValue() - latestCumulativeExpense);
            final List<BudgetFolioDetail> tempList = new ArrayList<BudgetFolioDetail>();
            tempList.add(e);
            if (approvedBudgetFolioDetails == null || approvedBudgetFolioDetails.isEmpty())
                approvedBudgetFolioDetails = new ArrayList<BudgetFolioDetail>();
            else
                approvedBudgetFolioDetails.add(e);
        } else
            approvedBudgetFolioDetails = new ArrayList<BudgetFolioDetail>();
    } catch (final ValidationException e) {
        logger.error("GlCodeValidation >>" + e.getErrors().get(0).getMessage());
        addFieldError("glCodeValidate", e.getErrors().get(0).getMessage());
    }
    return RESULTS;
}

From source file:it.cineca.iris.restclient.main.Command.java

/**
 * Test upload file/*w w  w .j  av a2  s. c o m*/
 * 
 * @param itemId
 * @throws JsonParseException
 * @throws JsonMappingException
 * @throws IOException
 */
private void testUpload(String location, String fileName)
        throws JsonParseException, JsonMappingException, IOException {
    System.out.println("\n-----------------------------------------------------------");
    System.out.println("Upload Attachment from Item: ");
    System.out.println("-----------------------------------------------------------");

    String type = "items/";

    Integer itemId = null;
    String handle = null;

    createTestFile(fileName);

    InputStream targetStream = new FileInputStream(fileName);

    BitstreamOptionsDTO bitstreamOptionsDTO = new BitstreamOptionsDTO();
    bitstreamOptionsDTO.setDescription("Test file");
    bitstreamOptionsDTO.setPolicyKey("openAccess");

    if (location != null) {
        location = location.substring(location.indexOf(type) + type.length());

        if (location.indexOf("/") < 0) {
            itemId = Integer.getInteger(location);
        } else {
            handle = location;
        }
    } else if (!itemsDTO.isEmpty()) {
        itemId = itemsDTO.get(0).getId();
    }

    if (itemId != null) {
        System.out.println("\nItem: " + String.valueOf(itemId));
        System.out.println("\nUpload file...");

        Response response = cl.uploadStream(itemId, bitstreamOptionsDTO, targetStream, fileName);

        System.out.println("Location: " + response.getHeaderString("location"));
    }

    if (handle != null) {
        System.out.println("\nHandle: " + handle);
        System.out.println("\nUpload file...");

        Response response = cl.uploadStream(handle, bitstreamOptionsDTO, targetStream, fileName);

        System.out.println("Location: " + response.getHeaderString("location"));

    } else {
        System.out.println("No Item");
    }
}

From source file:Presentacion.FUsuarios.java

private void btnRegistrarClienteMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnRegistrarClienteMouseClicked
    if (fc == null || !fc.getSelectedFile().isFile()) {
        JOptionPane.showMessageDialog(this, "Debe seleccionar una imagen", "Alerta",
                JOptionPane.WARNING_MESSAGE);
    } else {/*from  www.j  av  a 2s.  co  m*/

        if (txtApellido.getText().isEmpty() || txtDireccion.getText().isEmpty() || txtEmail.getText().isEmpty()
                || txtNickName.getText().isEmpty() || txtNombre.getText().isEmpty()) {
            JOptionPane.showMessageDialog(this, "Debe ingresar todos los datos", "Alerta",
                    JOptionPane.WARNING_MESSAGE);
        } else {
            webservice.Cliente user = new Cliente();
            user.setDireccion(txtDireccion.getText());
            user.setEmail(txtEmail.getText());
            user.setNickname(txtNickName.getText());
            user.setNombre(txtNombre.getText());
            user.setApellido(txtApellido.getText());

            //PORCEDIMIENTO PARA ENCRIPTAR LA CLAVE INGRESADA CUANDO INICIA SESIN UN USUARIO.
            String pass = jPasswordField2.getText();
            String encriptMD5 = DigestUtils.md5Hex(pass);
            pass = "md5:" + encriptMD5;

            user.setPassword(pass);

            try {
                int year = Integer.getInteger(drpYear.getToolTipText());
                int day = Integer.getInteger(drpDay.getModel().getValue().toString());
                int month = Integer.getInteger(drpMes.getValue().toString());

                GregorianCalendar c = new GregorianCalendar();
                c.setTime(new Date(year, month, day));
                XMLGregorianCalendar date2 = DatatypeFactory.newInstance().newXMLGregorianCalendar(c);

                user.setFechaNac(date2);
            } catch (Exception ex) {
                GregorianCalendar c = new GregorianCalendar();
                c.setTime(Date.from(Instant.EPOCH));

                try {
                    XMLGregorianCalendar date2 = DatatypeFactory.newInstance().newXMLGregorianCalendar(c);
                    user.setFechaNac(date2);
                } catch (Exception ex2) {
                    System.out.println("Error en fecha");
                }
            }

            user.setImagen(txtNickName.getText() + ".jpg");

            QuickOrderWebService webService = new QuickOrderWebService();
            ControllerInterface port = webService.getQuickOrderWebServicePort();

            String result = port.registrarCliente(user);
            if (result.isEmpty()) {

                JOptionPane.showMessageDialog(this, "Usuario ingresado correctamente");
                txtApellido.setText("");
                txtDireccion.setText("");
                txtEmail.setText("");
                txtNickName.setText("");
                txtNombre.setText("");
                jPasswordField2.setText("");
            } else {
                if (result.equals("emailError1")) {
                    JOptionPane.showMessageDialog(this,
                            "El email ya se encuentra registrado, por favor ingrese otro.", "Alerta",
                            JOptionPane.WARNING_MESSAGE);
                }
                if (result.equals("nicknameError1")) {
                    JOptionPane.showMessageDialog(this,
                            "El nickname no se encuentra disponible, por favor ingrese otro.", "Alerta",
                            JOptionPane.WARNING_MESSAGE);
                } else {
                    JOptionPane.showMessageDialog(this, "Error al ingresar el cliente", "Error",
                            JOptionPane.ERROR_MESSAGE);
                }
            }

        }
    }
}

From source file:org.apache.solr.cloud.ZkController.java

/**
 * Publish core state to overseer./*from  ww  w. j a  v  a2s.  c om*/
 */
public void publish(final CoreDescriptor cd, final Replica.State state, boolean updateLastState,
        boolean forcePublish) throws KeeperException, InterruptedException {
    if (!forcePublish) {
        try (SolrCore core = cc.getCore(cd.getName())) {
            if (core == null || core.isClosed()) {
                return;
            }
            MDCLoggingContext.setCore(core);
        }
    } else {
        MDCLoggingContext.setCoreDescriptor(cd);
    }
    try {
        String collection = cd.getCloudDescriptor().getCollectionName();

        log.debug("publishing state={}", state.toString());
        // System.out.println(Thread.currentThread().getStackTrace()[3]);
        Integer numShards = cd.getCloudDescriptor().getNumShards();
        if (numShards == null) { // XXX sys prop hack
            log.debug("numShards not found on descriptor - reading it from system property");
            numShards = Integer.getInteger(ZkStateReader.NUM_SHARDS_PROP);
        }

        assert collection != null && collection.length() > 0;

        String shardId = cd.getCloudDescriptor().getShardId();

        String coreNodeName = cd.getCloudDescriptor().getCoreNodeName();
        // If the leader initiated recovery, then verify that this replica has performed
        // recovery as requested before becoming active; don't even look at lirState if going down
        if (state != Replica.State.DOWN) {
            final Replica.State lirState = getLeaderInitiatedRecoveryState(collection, shardId, coreNodeName);
            if (lirState != null) {
                if (state == Replica.State.ACTIVE) {
                    // trying to become active, so leader-initiated state must be recovering
                    if (lirState == Replica.State.RECOVERING) {
                        updateLeaderInitiatedRecoveryState(collection, shardId, coreNodeName,
                                Replica.State.ACTIVE, cd, true);
                    } else if (lirState == Replica.State.DOWN) {
                        throw new SolrException(ErrorCode.INVALID_STATE, "Cannot publish state of core '"
                                + cd.getName() + "' as active without recovering first!");
                    }
                } else if (state == Replica.State.RECOVERING) {
                    // if it is currently DOWN, then trying to enter into recovering state is good
                    if (lirState == Replica.State.DOWN) {
                        updateLeaderInitiatedRecoveryState(collection, shardId, coreNodeName,
                                Replica.State.RECOVERING, cd, true);
                    }
                }
            }
        }

        Map<String, Object> props = new HashMap<>();
        props.put(Overseer.QUEUE_OPERATION, "state");
        props.put(ZkStateReader.STATE_PROP, state.toString());
        props.put(ZkStateReader.BASE_URL_PROP, getBaseUrl());
        props.put(ZkStateReader.CORE_NAME_PROP, cd.getName());
        props.put(ZkStateReader.ROLES_PROP, cd.getCloudDescriptor().getRoles());
        props.put(ZkStateReader.NODE_NAME_PROP, getNodeName());
        props.put(ZkStateReader.SHARD_ID_PROP, cd.getCloudDescriptor().getShardId());
        props.put(ZkStateReader.COLLECTION_PROP, collection);
        if (numShards != null) {
            props.put(ZkStateReader.NUM_SHARDS_PROP, numShards.toString());
        }
        if (coreNodeName != null) {
            props.put(ZkStateReader.CORE_NODE_NAME_PROP, coreNodeName);
        }
        try (SolrCore core = cc.getCore(cd.getName())) {
            if (core != null && core.getDirectoryFactory().isSharedStorage()) {
                if (core != null && core.getDirectoryFactory().isSharedStorage()) {
                    props.put("dataDir", core.getDataDir());
                    UpdateLog ulog = core.getUpdateHandler().getUpdateLog();
                    if (ulog != null) {
                        props.put("ulogDir", ulog.getLogDir());
                    }
                }
            }
        }

        ZkNodeProps m = new ZkNodeProps(props);

        if (updateLastState) {
            cd.getCloudDescriptor().lastPublished = state;
        }
        overseerJobQueue.offer(Utils.toJSON(m));
    } finally {
        MDCLoggingContext.clear();
    }
}

From source file:org.hfoss.posit.android.sync.Communicator.java

/**
 * The data has the form: [attr=value, ...] or 'null'
 * @param cv//w w w . j  a  va  2s  . c om
 * @param data
 */
static private void addExtraDataToContentValues(ContentValues cv, String data) {
    Log.i(TAG, "data = " + data + " " + data.length());
    if (data.equals("null"))
        return;
    data = data.trim();
    data = data.substring(1, data.length() - 1);
    StringTokenizer st = new StringTokenizer(data, ",");
    while (st.hasMoreElements()) {
        String attrvalpair = (String) st.nextElement();
        String attr = attrvalpair.substring(0, attrvalpair.indexOf("="));
        attr = attr.trim();
        String val = attrvalpair.substring(attrvalpair.indexOf("=") + 1);
        val = val.trim();
        Log.i(TAG, "Putting " + attr + "=" + val + " into CV");
        if (Integer.getInteger(val) != null)
            cv.put(attr, Integer.parseInt(val));
        //         else if (Boolean.getBoolean(val) != null)
        //            cv.put(attr, Boolean.parseBoolean(val))
        //         else if (Double.getDouble(val) != null))
        //            cv.put(attr, Double.parseDouble(val))
        else
            cv.put(attr, val);
    }

}

From source file:org.apache.hadoop.hbase.ipc.HBaseServer.java

protected HBaseServer(String bindAddress, int port, Class<? extends Writable> paramClass, int handlerCount,
        int priorityHandlerCount, Configuration conf, String serverName, int highPriorityLevel)
        throws IOException {
    this.bindAddress = bindAddress;
    this.conf = conf;
    this.port = port;
    this.paramClass = paramClass;
    this.handlerCount = handlerCount;
    this.priorityHandlerCount = priorityHandlerCount;
    this.socketSendBufferSize = 0;

    // temporary backward compatibility
    String oldMaxQueueSize = this.conf.get("ipc.server.max.queue.size");
    if (oldMaxQueueSize == null) {
        this.maxQueueLength = this.conf.getInt("ipc.server.max.callqueue.length",
                handlerCount * DEFAULT_MAX_CALLQUEUE_LENGTH_PER_HANDLER);
    } else {/*from   w  w  w  . j a  v  a  2 s  . c  o  m*/
        LOG.warn("ipc.server.max.queue.size was renamed " + "ipc.server.max.callqueue.length, "
                + "please update your configuration");
        this.maxQueueLength = Integer.getInteger(oldMaxQueueSize);
    }

    this.maxQueueSize = this.conf.getInt("ipc.server.max.callqueue.size", DEFAULT_MAX_CALLQUEUE_SIZE);
    this.readThreads = conf.getInt("ipc.server.read.threadpool.size", 10);
    this.callQueue = new LinkedBlockingQueue<Call>(maxQueueLength);
    if (priorityHandlerCount > 0) {
        this.priorityCallQueue = new LinkedBlockingQueue<Call>(maxQueueLength); // TODO hack on size
    } else {
        this.priorityCallQueue = null;
    }
    this.highPriorityLevel = highPriorityLevel;
    this.maxIdleTime = 2 * conf.getInt("ipc.client.connection.maxidletime", 1000);
    this.maxConnectionsToNuke = conf.getInt("ipc.client.kill.max", 10);
    this.thresholdIdleConnections = conf.getInt("ipc.client.idlethreshold", 4000);
    this.purgeTimeout = conf.getLong("ipc.client.call.purge.timeout", 2 * HConstants.DEFAULT_HBASE_RPC_TIMEOUT);
    this.numOfReplicationHandlers = conf.getInt("hbase.regionserver.replication.handler.count", 3);
    if (numOfReplicationHandlers > 0) {
        this.replicationQueue = new LinkedBlockingQueue<Call>(maxQueueSize);
    }
    // Start the listener here and let it bind to the port
    listener = new Listener();
    this.port = listener.getAddress().getPort();
    this.rpcMetrics = new HBaseRpcMetrics(serverName, Integer.toString(this.port));
    this.tcpNoDelay = conf.getBoolean("ipc.server.tcpnodelay", false);
    this.tcpKeepAlive = conf.getBoolean("ipc.server.tcpkeepalive", true);

    this.warnDelayedCalls = conf.getInt(WARN_DELAYED_CALLS, DEFAULT_WARN_DELAYED_CALLS);
    this.delayedCalls = new AtomicInteger(0);

    // Create the responder here
    responder = new Responder();
}

From source file:com.hortonworks.hbase.replication.bridge.HBaseServer.java

protected HBaseServer(String bindAddress, int port, Class<? extends Writable> paramClass, int handlerCount,
        int priorityHandlerCount, Configuration conf, String serverName, int highPriorityLevel)
        throws IOException {
    this.bindAddress = bindAddress;
    this.conf = conf;
    this.port = port;
    this.paramClass = paramClass;
    this.handlerCount = handlerCount;
    this.priorityHandlerCount = priorityHandlerCount;
    this.socketSendBufferSize = 0;

    // temporary backward compatibility
    String oldMaxQueueSize = this.conf.get("ipc.server.max.queue.size");
    if (oldMaxQueueSize == null) {
        this.maxQueueLength = this.conf.getInt("ipc.server.max.callqueue.length",
                handlerCount * DEFAULT_MAX_CALLQUEUE_LENGTH_PER_HANDLER);
    } else {/*from w  ww .  ja  v  a 2  s . c  o m*/
        LOG.warn("ipc.server.max.queue.size was renamed " + "ipc.server.max.callqueue.length, "
                + "please update your configuration");
        this.maxQueueLength = Integer.getInteger(oldMaxQueueSize);
    }

    this.maxQueueSize = this.conf.getInt("ipc.server.max.callqueue.size", DEFAULT_MAX_CALLQUEUE_SIZE);
    this.readThreads = conf.getInt("ipc.server.read.threadpool.size", 10);
    this.callQueue = new LinkedBlockingQueue<Call>(maxQueueLength);
    if (priorityHandlerCount > 0) {
        this.priorityCallQueue = new LinkedBlockingQueue<Call>(maxQueueLength); // TODO hack on size
    } else {
        this.priorityCallQueue = null;
    }
    this.highPriorityLevel = highPriorityLevel;
    this.maxIdleTime = 2 * conf.getInt("ipc.client.connection.maxidletime", 1000);
    this.maxConnectionsToNuke = conf.getInt("ipc.client.kill.max", 10);
    this.thresholdIdleConnections = conf.getInt("ipc.client.idlethreshold", 4000);
    this.purgeTimeout = conf.getLong("ipc.client.call.purge.timeout", 2 * HConstants.DEFAULT_HBASE_RPC_TIMEOUT);
    this.numOfReplicationHandlers = conf.getInt("hbase.regionserver.replication.handler.count", 3);
    if (numOfReplicationHandlers > 0) {
        this.replicationQueue = new LinkedBlockingQueue<Call>(maxQueueSize);
    }
    // Start the listener here and let it bind to the port
    listener = new Listener();
    this.port = listener.getAddress().getPort();
    this.rpcMetrics = new HBaseRpcMetrics(serverName, Integer.toString(this.port));
    this.tcpNoDelay = conf.getBoolean("ipc.server.tcpnodelay", false);
    this.tcpKeepAlive = conf.getBoolean("ipc.server.tcpkeepalive", true);

    this.warnDelayedCalls = conf.getInt(WARN_DELAYED_CALLS, DEFAULT_WARN_DELAYED_CALLS);
    this.delayedCalls = new AtomicInteger(0);

    this.responseQueuesSizeThrottler = new SizeBasedThrottler(
            conf.getLong(RESPONSE_QUEUES_MAX_SIZE, DEFAULT_RESPONSE_QUEUES_MAX_SIZE));

    // Create the responder here
    responder = new Responder();
}