Example usage for java.lang Integer decode

List of usage examples for java.lang Integer decode

Introduction

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

Prototype

public static Integer decode(String nm) throws NumberFormatException 

Source Link

Document

Decodes a String into an Integer .

Usage

From source file:net.firejack.platform.installation.processor.InstallSlaveProcessor.java

@Override
public void onApplicationEvent(InstallSlaveEvent event) {
    File keystore = InstallUtils.getKeyStore();

    String url = OpenFlameConfig.MASTER_URL.getValue();
    String admin = OpenFlameConfig.APP_ADMIN_NAME.getValue();
    String password = OpenFlameConfig.APP_ADMIN_PASSWORD.getValue();

    try {/*from ww w .j  av  a 2  s.  c  om*/
        if (keystore.exists()) {
            X500Name info = KeyUtils.getInfo(keystore);
            url = info.getDomain();
        }

        String hostName = InetAddress.getLocalHost().getHostName();

        KeyPair keyPair = KeyUtils.generate(keystore);

        if (keyPair == null) {
            throw new IllegalStateException("Key not found");
        }

        X509Certificate certificate = KeyUtils.generateCertificate(url, 1, keyPair);

        if (StringUtils.isBlank(password)) {
            String cert = new String(Base64.encode(certificate.getEncoded()));
            OPFEngine.init(url, OpenFlame.PACKAGE, hostName, cert);
        } else {
            OPFEngine.init(url, admin, password);
        }

        ServerNodeConfig config = new ServerNodeConfig();

        config.setServerName(hostName);
        //         config.setServerName(hostName + "_slave"); //TODO [CLUSTER] don't commit this line
        config.setHost(InetAddress.getLocalHost().getHostAddress());
        config.setPort(Integer.decode(OpenFlameConfig.PORT.getValue()));
        config.setNodeType(ServerNodeType.OPF_SLAVE);
        config.setLookup(OpenFlame.PACKAGE);
        config.setCert(certificate.getEncoded());

        InputStream stream = OPFEngine.RegistryService.registerSlaveNode(config);

        ByteArrayOutputStream output = new ByteArrayOutputStream();
        IOUtils.copy(stream, output);
        byte[] decrypted = KeyUtils.decrypt(keyPair.getPrivate(), output.toByteArray());

        Map<String, String> map = EnvironmentsUtils.convertFromXml(new ByteArrayInputStream(decrypted));
        ConfigContainer.putAll(map);

        source.refreshDBProperties();
        OPFEngine.release();

        KeyUtils.add(keystore, keyPair, url);
        FileUtils.deleteQuietly(InstallUtils.getPropEnv());
    } catch (Exception e) {
        logger.error(e);
        throw new IllegalStateException(e);
    }

    OPFEngine.initialize();
}

From source file:com.amazonaws.mobileconnectors.pinpoint.internal.core.configuration.AndroidPreferencesConfiguration.java

public Integer getInt(final String propertyName) {
    Integer value = null;//from   w  w w.j a va  2  s. c o  m
    String valueString = properties.get(propertyName);

    if (valueString != null) {
        try {
            value = Integer.decode(valueString);
        } catch (Exception ex) {
            // Do not log property due to potential sensitive information.
            log.error("Could not get Integer for property.");
        }
    }

    return value;
}

From source file:org.xronos.orcc.analysis.SimParser.java

public void createMaps() {

    for (Actor actor : network.getAllActors()) {
        Map<Action, SummaryStatistics> aTimeGoDone = new HashMap<Action, SummaryStatistics>();
        for (Action action : actor.getActions()) {
            OrccLogger.noticeln("Parsing weight: " + actor.getSimpleName() + "_" + action.getName());
            SummaryStatistics tGoDone = new SummaryStatistics();

            File actionFile = new File(
                    path + File.separator + actor.getSimpleName() + "_" + action.getName() + ".txt");
            try {
                FileInputStream iStream = new FileInputStream(actionFile);
                BufferedReader iBuffer = new BufferedReader(new InputStreamReader(iStream));
                String str;/*www  . ja v a2 s .c o m*/
                int startTime = 0;
                Boolean fromOneZero = false;
                while ((str = iBuffer.readLine()) != null) {

                    int fIdx = str.indexOf(';', 0);
                    String stringTime = str.substring(0, fIdx);
                    int sIdx = str.indexOf(';', fIdx + 1);
                    String stringGo = str.substring(fIdx + 1, sIdx);
                    int tIdx = str.indexOf(';', sIdx + 1);
                    String stringDone = str.substring(sIdx + 1, tIdx);

                    int intTime = Integer.decode(stringTime);
                    int intGo = Integer.decode(stringGo);
                    int intDone = Integer.decode(stringDone);

                    if (intGo == 1 && intDone == 0) {
                        startTime = intTime;
                        fromOneZero = true;
                    } else if (intGo == 1 && intDone == 1) {
                        if (fromOneZero) {
                            tGoDone.addValue((intTime - startTime) / 100);
                            startTime = intTime;
                        } else {
                            tGoDone.addValue(0);
                        }
                    } else if (intGo == 0 && intDone == 1) {
                        fromOneZero = false;
                        tGoDone.addValue((intTime - startTime) / 100);
                    }

                }
                iBuffer.close();
                aTimeGoDone.put(action, tGoDone);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        statistics.put(actor, aTimeGoDone);
    }
}

From source file:org.ohmage.prompt.singlechoicecustom.SingleChoiceCustomPrompt.java

@Override
protected Object getTypeSpecificResponseObject() {

    if (mSelectedIndex >= 0 && mSelectedIndex < mChoices.size()) {
        return Integer.decode(mChoices.get(mSelectedIndex).key);
    } else if (mSelectedIndex >= 0 && mSelectedIndex < mChoices.size() + mCustomChoices.size()) {
        return Integer.decode(mCustomChoices.get(mSelectedIndex - mChoices.size()).key);
    } else {//from  w  w  w  . j  a va2s.  c  om
        return null;
    }
}

From source file:org.patientview.patientview.logon.PatientEditAction.java

public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    String username = BeanUtils.getProperty(form, "username");
    String password = BeanUtils.getProperty(form, "password");
    String firstName = BeanUtils.getProperty(form, "firstName");
    String lastName = BeanUtils.getProperty(form, "lastName");
    String email = BeanUtils.getProperty(form, "email");
    boolean emailverified = "true".equals(BeanUtils.getProperty(form, "emailverified"));
    String nhsno = BeanUtils.getProperty(form, "nhsno");
    String unitcode = BeanUtils.getProperty(form, "unitcode");
    String overrideDuplicateNhsno = BeanUtils.getProperty(form, "overrideDuplicateNhsno");
    boolean firstlogon = "true".equals(BeanUtils.getProperty(form, "firstlogon"));
    boolean dummypatient = "true".equals(BeanUtils.getProperty(form, "dummypatient"));
    Calendar lastlogoncal = createDatestamp(BeanUtils.getProperty(form, "lastlogon"));
    Date lastlogon = lastlogoncal == null ? null : lastlogoncal.getTime();
    String failedlogonsstring = BeanUtils.getProperty(form, "failedlogons");
    int failedlogons = Integer.decode(failedlogonsstring);
    boolean accountlocked = "true".equals(BeanUtils.getProperty(form, "accountlocked"));
    String mappingToFind = "";

    List duplicateUsers = findDuplicateUsers(nhsno, username);

    if (!duplicateUsers.isEmpty() && !overrideDuplicateNhsno.equals("on")) {
        request.setAttribute(LogonUtils.NHSNO_ALREADY_EXISTS, nhsno);
        mappingToFind = "input";
        NhsnoUnitcode nhsnoThing = new NhsnoUnitcode(nhsno, unitcode);
        request.setAttribute("nhsnot", nhsnoThing);
    } else {//  w  ww .jav  a 2s  .  c om

        PatientLogon patient = new PatientLogon(username, password, firstName, lastName, email, emailverified,
                firstlogon, dummypatient, lastlogon, failedlogons, accountlocked);
        LegacySpringUtils.getUserManager().saveUserFromPatient(patient);

        List<UserMapping> userMappings = findUsersSiblings(username, unitcode);

        for (UserMapping userMapping : userMappings) {
            userMapping.setNhsno(nhsno);
            LegacySpringUtils.getUserManager().save(userMapping);
        }

        Unit unit = LegacySpringUtils.getUnitManager().get(unitcode);

        if (unit != null) {
            request.setAttribute("unit", unit);
        }

        List patients = LegacySpringUtils.getPatientManager().getUnitPatientsAllWithTreatmentDao(unitcode);
        PagedListHolder pagedListHolder = new PagedListHolder(patients);
        request.getSession().setAttribute("patients", pagedListHolder);
        mappingToFind = "success";
    }

    return mapping.findForward(mappingToFind);
}

From source file:com.aurel.track.fieldType.runtime.renderer.ParentRendererRT.java

@Override
public Object decodeJsonValue(String value, Integer fieldID, WorkItemContext workItemContext)
        throws TypeConversionException {
    Integer result = null;/*from ww  w.  j a va2s.  com*/
    if (value != null) {
        try {
            result = Integer.decode(value);
        } catch (NumberFormatException ex) {
            throw new TypeConversionException("common.err.invalid.number", ex);
        }
    }
    return result;
}

From source file:it.cilea.osd.jdyna.controller.DecoratorPropertiesDefinitionController.java

protected ModelAndView handleDelete(HttpServletRequest request) {
    Map<String, Object> model = new HashMap<String, Object>();
    String paramOTipologiaProprietaId = request.getParameter("pDId");
    String boxId = request.getParameter("boxId");
    String tabId = request.getParameter("tabId");
    Integer tipologiaProprietaId = Integer.decode(paramOTipologiaProprietaId);

    try {/*from  w  w w . j  a  v a2 s.c  om*/

        TP tip = applicationService.get(targetModel, tipologiaProprietaId);

        //cancello tutte le proprieta' salvate in passato
        applicationService.<it.cilea.osd.jdyna.model.Property<TP>, TP>deleteAllProprietaByTipologiaProprieta(
                tip.getPropertyHolderClass(), tip);
        //cancello se fanno parte di qualche property holder      
        IContainable containable = applicationService.findContainableByDecorable(tip.getDecoratorClass(),
                tipologiaProprietaId);
        applicationService.<H, T>deleteContainableInPropertyHolder(holderModel, containable);
        if (TypedBox.class.isAssignableFrom(holderModel)) {
            TypedBox box = (TypedBox) applicationService.get(holderModel, Integer.parseInt(boxId));
            box.getTypeDef().getMask().remove(tip);
        }

        applicationService.delete(tip.getDecoratorClass(), containable.getId());

        saveMessage(request, getText("action.propertiesdefinition.deleted", request.getLocale()));
    } catch (Exception ecc) {
        saveMessage(request, getText("action.propertiesdefinition.deleted.noSuccess", request.getLocale()));
    }

    return new ModelAndView(getListView() + "?id=" + boxId + "&tabId=" + tabId + "&path="
            + Utils.getAdminSpecificPath(request, null), model);
}

From source file:org.ohmage.prompt.multichoicecustom.MultiChoiceCustomPrompt.java

@Override
protected Object getTypeSpecificResponseObject() {
    JSONArray jsonArray = new JSONArray();
    for (int index : mSelectedIndexes) {
        if (index >= 0 && index < mChoices.size()) {
            jsonArray.put(Integer.decode(mChoices.get(index).key));
        } else if (index < mChoices.size() + mCustomChoices.size()) {
            jsonArray.put(Integer.decode(mCustomChoices.get(index - mChoices.size()).key));
        }// www .j  av  a 2  s.c  o m
    }
    return jsonArray;
}

From source file:com.aurel.track.fieldType.bulkSetters.ParentBulkSetter.java

@Override
public Object fromDisplayString(Map<String, String> displayStringMap, Locale locale) {
    if (displayStringMap == null) {
        return null;
    }/*from www.  ja v  a 2 s  . co  m*/
    switch (getRelation()) {
    case BulkRelations.SET_TO:
        String displayString = displayStringMap.get(getKeyPrefix());
        if (displayString != null) {
            try {
                return Integer.decode(displayString);
            } catch (NumberFormatException ex) {
                LOGGER.info("Parsing the parentID " + displayString + " failed with ");
            }
        }
    }
    return null;
}

From source file:org.squale.squaleweb.resources.WebMessages.java

/**
 * @param pKey la cl/*from ww  w. j av a2s  . c om*/
 * @return le rsultat aprs conversion dans le int associ
 */
public static int getInt(String pKey) {
    return Integer.decode(getString(pKey)).intValue();
}