Example usage for java.lang NumberFormatException getLocalizedMessage

List of usage examples for java.lang NumberFormatException getLocalizedMessage

Introduction

In this page you can find the example usage for java.lang NumberFormatException getLocalizedMessage.

Prototype

public String getLocalizedMessage() 

Source Link

Document

Creates a localized description of this throwable.

Usage

From source file:org.openestate.io.is24_csv.records.GrundstueckGewerbe.java

public BigDecimal getGeschossflaechenzahl() {
    try {/* w  ww.j  a va2  s .c  om*/
        return Is24CsvFormat.parseDecimal(this.get(FIELD_GESCHOSSFLAECHENZAHL));
    } catch (NumberFormatException ex) {
        LOGGER.warn("Can't read 'Geschossflaechenzahl'!");
        LOGGER.warn("> " + ex.getLocalizedMessage(), ex);
        return null;
    }
}

From source file:org.pentaho.platform.engine.services.actionsequence.ActionParameter.java

public ActionParameter(final String name, final String type, final Object value, final List variables,
        final Object defaultValue) {
    this.name = name;
    this.value = value;
    this.type = type;
    this.variables = variables;

    // DM - get this working here for now - should be it's own factory - fix
    // up all the conversions
    this.defaultValue = null;
    if (defaultValue != null) {
        if ("string".equalsIgnoreCase(type)) { //$NON-NLS-1$ 
            this.defaultValue = defaultValue.toString();
        } else if ("string-list".equalsIgnoreCase(type) || "property-map-list".equalsIgnoreCase(type)) { //$NON-NLS-1$ //$NON-NLS-2$ 
            if (defaultValue instanceof List) {
                this.defaultValue = defaultValue;
            }/*from   w  w w. j a  v a  2s  . c  om*/
        } else if ("property-map".equalsIgnoreCase(type)) { //$NON-NLS-1$
            if (defaultValue instanceof Map) {
                this.defaultValue = defaultValue;
            }
        } else if ("result-set".equalsIgnoreCase(type)) { //$NON-NLS-1$
            if (defaultValue instanceof IPentahoResultSet) {
                this.defaultValue = defaultValue;
            }
        } else if ("long".equalsIgnoreCase(type)) { //$NON-NLS-1$ 
            try {
                this.defaultValue = Long.valueOf(defaultValue.toString());
            } catch (NumberFormatException e) {
                // @todo: throw an exception
                ActionParameter.logger.error(e.getLocalizedMessage());
            }
        } else if ("integer".equalsIgnoreCase(type)) { //$NON-NLS-1$ 
            try {
                this.defaultValue = Integer.valueOf(defaultValue.toString());
            } catch (NumberFormatException e) {
                // @todo: throw an exception
                ActionParameter.logger.error(e.getLocalizedMessage());
            }
        }
    }
    if ((value == null) && (defaultValue != null)) {
        promptType = IActionParameter.PROMPT_NEEDED;
    }
}

From source file:de.fhg.fokus.odp.portal.datasets.searchresults.BrowseDataSetsSearchResults.java

/**
 * This method adds the screenname of all users, which commented this
 * dataset, to a String array and returns this array.
 * //w ww. j a v  a  2 s.  c  o m
 * @param comments
 *            the {@link JSONArray}
 * @return array filled with screennames of commenters
 */
private String[] getCommentersScreennames(JSONArray comments) {

    String[] commentersNames = new String[comments.size()];
    for (int i = 0; i < comments.size(); i++) {
        String userId = (String) ((JSONObject) comments.get(i)).get("userId");
        try {
            commentersNames[i] = UserLocalServiceUtil.getUserById(Long.parseLong(userId)).getScreenName();
        } catch (NumberFormatException e) {
            LOGGER.error(e.getLocalizedMessage(), e);
        } catch (PortalException e) {
            LOGGER.error(e.getLocalizedMessage(), e);
        } catch (SystemException e) {
            LOGGER.error(e.getLocalizedMessage(), e);
        }
    }
    return commentersNames;
}

From source file:org.kalypso.model.hydrology.internal.postprocessing.LzsToGml.java

private void readCatchmentStartCondition(final Catchment catchment) throws Exception {
    final InitialValues initialValues = (InitialValues) m_lzWorkspace.getRootFeature();

    final IFeatureBindingCollection<org.kalypso.model.hydrology.binding.initialValues.Catchment> catchments = initialValues
            .getCatchments();//from  w w w.  j ava 2s .c  o  m
    final org.kalypso.model.hydrology.binding.initialValues.Catchment iniCatchment = catchments
            .addNew(org.kalypso.model.hydrology.binding.initialValues.Catchment.FEATURE_CATCHMENT);
    iniCatchment.setNaCatchmentID(catchment);

    final int asciiID = m_idManager.getAsciiID(catchment);
    iniCatchment.setName(Integer.toString(asciiID)); //$NON-NLS-1$ //$NON-NLS-2$
    final String fileName = String.format("we%s.lzs", asciiID); //$NON-NLS-1$
    final File lzsFile = new File(m_lzsimDir, fileName);

    FileReader fileReader = null;
    try {
        fileReader = new FileReader(lzsFile);
        readLzsFile(fileReader, catchment, iniCatchment);
        fileReader.close();
    } catch (final NumberFormatException e) {
        m_logger.severe(String.format(Messages.getString("LzsToGml.0"), e.getLocalizedMessage())); //$NON-NLS-1$
    } catch (final IOException e) {
        m_logger.warning(
                Messages.getString("org.kalypso.convert.namodel.manager.LzsimManager.27", catchment.getName())); //$NON-NLS-1$
    } finally {
        IOUtils.closeQuietly(fileReader);
    }
}

From source file:com.qut.middleware.esoemanager.manager.logic.impl.ServiceCryptoImpl.java

public KeyStoreBean retrieveKeystore(String serviceID, String keypairName)
        throws RetrieveServiceCryptoException {
    List<Map<String, Object>> keyStoreData;
    byte[] rawKeyStore;
    String keyStorePassphrase;//  w ww  . j  a  v  a 2s .co m
    KeyStore keyStore;

    KeyStoreBean result = new KeyStoreBean();

    try {
        Integer entID = new Integer(serviceID);
        if (entID.intValue() == this.esoeENTID) {
            Integer descID = this.managerDAO.getDescID(entID, Constants.IDP_DESCRIPTOR);
            keyStoreData = this.managerDAO.queryKeystoreBinary(descID);
        } else {
            Integer descID = this.managerDAO.getDescID(entID, Constants.SP_DESCRIPTOR);
            keyStoreData = this.managerDAO.queryKeystoreBinary(descID);
        }

        if (keyStoreData == null || keyStoreData.size() == 0) {
            this.logger.info("No key data returned for provided descriptor");
            throw new RetrieveKeystoreException("No key data returned for provided descriptor");
        }

        rawKeyStore = (byte[]) keyStoreData.get(0).get(Constants.FIELD_PKI_KEYSTORE);
        keyStorePassphrase = (String) keyStoreData.get(0).get(Constants.FIELD_PKI_KEYSTORE_PASSPHRASE);

        keyStore = this.cryptoProcessor.generateKeyStore();
        ByteArrayInputStream in = new ByteArrayInputStream(rawKeyStore);
        keyStore.load(in, keyStorePassphrase.toCharArray());

        result.setKeyStore(keyStore);
        result.setPassphrase(keyStorePassphrase);

        return result;
    } catch (NumberFormatException e) {
        throw new RetrieveServiceCryptoException(e.getLocalizedMessage(), e);
    } catch (NoSuchAlgorithmException e) {
        throw new RetrieveServiceCryptoException(e.getLocalizedMessage(), e);
    } catch (CertificateException e) {
        throw new RetrieveServiceCryptoException(e.getLocalizedMessage(), e);
    } catch (ManagerDAOException e) {
        throw new RetrieveServiceCryptoException(e.getLocalizedMessage(), e);
    } catch (RetrieveKeystoreException e) {
        throw new RetrieveServiceCryptoException(e.getLocalizedMessage(), e);
    } catch (CryptoException e) {
        throw new RetrieveServiceCryptoException(e.getLocalizedMessage(), e);
    } catch (IOException e) {
        throw new RetrieveServiceCryptoException(e.getLocalizedMessage(), e);
    }

}

From source file:org.apache.openaz.xacml.admin.view.components.EnumerationEditorComponent.java

@Override
public void validate(Object value) throws InvalidValueException {
    if (value == null || value.toString().length() == 0) {
        return;/*from  w  ww  .  j a  v a  2s.  c  o  m*/
    }
    if (datatype.equals(XACML3.ID_DATATYPE_INTEGER)) {
        try {
            Integer.parseInt(value.toString());
        } catch (NumberFormatException e) {
            throw new InvalidValueException(e.getLocalizedMessage());
        }
        return;
    }
    if (datatype.equals(XACML3.ID_DATATYPE_DOUBLE)) {
        try {
            Double.parseDouble(value.toString());
        } catch (NumberFormatException e) {
            throw new InvalidValueException(e.getLocalizedMessage());
        }
        return;
    }
}

From source file:com.qut.middleware.esoemanager.manager.logic.impl.ServiceCryptoImpl.java

public void createServiceKey(String serviceID) throws ServiceCryptoCreationException {
    String keyStorePassphrase;/*www . j  ava2  s . c o  m*/
    String keyPairName;
    String keyPairPassphrase;
    String keyPairSubjectDN;
    KeyPair spKeyPair;
    KeyStore keyStore;
    byte[] keyStoreBytes;

    try {
        Integer entID = new Integer(serviceID);

        if (entID.intValue() == this.esoeENTID) {
            keyPairSubjectDN = this.generateSubjectDN(this.esoeEntityID);
        } else {
            String serviceURL = null;
            Map<String, Object> description = this.managerDAO.queryServiceDescription(entID);
            if (description == null)
                throw new ServiceCryptoCreationException("Unable to retrieve serviceURL for this service");

            serviceURL = (String) description.get(Constants.FIELD_SERVICE_URL);
            keyPairSubjectDN = this.generateSubjectDN(serviceURL);
        }

        keyPairName = this.identifierGenerator.generateXMLKeyName();

        keyStorePassphrase = this.generatePassphrase();
        keyPairPassphrase = this.generatePassphrase();

        keyStore = this.cryptoProcessor.generateKeyStore();
        spKeyPair = this.cryptoProcessor.generateKeyPair();
        this.cryptoProcessor.addKeyPair(keyStore, keyStorePassphrase, spKeyPair, keyPairName, keyPairPassphrase,
                keyPairSubjectDN);
        keyStoreBytes = this.cryptoProcessor.convertKeystoreByteArray(keyStore, keyStorePassphrase);

        X509Certificate certificate = (X509Certificate) keyStore.getCertificate(keyPairName);

        /* Determine expiry date of PKI data */
        Calendar expiryDate = Calendar.getInstance();
        expiryDate.add(Calendar.YEAR, this.cryptoProcessor.getCertExpiryIntervalInYears());

        if (entID.intValue() == this.esoeENTID) {
            /** Commit key data to IDP reference */
            Integer descID_IDP = this.managerDAO.getDescID(entID, Constants.IDP_DESCRIPTOR);
            this.managerDAO.insertPublicKey(descID_IDP, expiryDate.getTime(), keyPairName,
                    this.cryptoProcessor.getCertIssuerDN(), certificate.getSerialNumber().toString(),
                    this.cryptoProcessor.convertPublicKeyByteArray(spKeyPair.getPublic()));

            this.managerDAO.insertPKIData(descID_IDP, expiryDate.getTime(), keyStoreBytes, keyStorePassphrase,
                    keyPairName, keyPairPassphrase);

            /** Commit key data to PDP reference */
            Integer descID_PDP = this.managerDAO.getDescID(entID, Constants.LXACML_PDP_DESCRIPTOR);
            this.managerDAO.insertPublicKey(descID_PDP, expiryDate.getTime(), keyPairName,
                    this.cryptoProcessor.getCertIssuerDN(), certificate.getSerialNumber().toString(),
                    this.cryptoProcessor.convertPublicKeyByteArray(spKeyPair.getPublic()));

            this.managerDAO.insertPKIData(descID_PDP, expiryDate.getTime(), keyStoreBytes, keyStorePassphrase,
                    keyPairName, keyPairPassphrase);

            /** Commit key data to Attribute Authority reference */
            Integer descID_AA = this.managerDAO.getDescID(entID, Constants.ATTRIBUTE_AUTHORITY_DESCRIPTOR);
            this.managerDAO.insertPublicKey(descID_AA, expiryDate.getTime(), keyPairName,
                    this.cryptoProcessor.getCertIssuerDN(), certificate.getSerialNumber().toString(),
                    this.cryptoProcessor.convertPublicKeyByteArray(spKeyPair.getPublic()));

            this.managerDAO.insertPKIData(descID_AA, expiryDate.getTime(), keyStoreBytes, keyStorePassphrase,
                    keyPairName, keyPairPassphrase);
        } else {
            Integer descID = this.managerDAO.getDescID(entID, Constants.SP_DESCRIPTOR);
            this.managerDAO.insertPublicKey(descID, expiryDate.getTime(), keyPairName,
                    this.cryptoProcessor.getCertIssuerDN(), certificate.getSerialNumber().toString(),
                    this.cryptoProcessor.convertPublicKeyByteArray(spKeyPair.getPublic()));
            this.managerDAO.insertPKIData(descID, expiryDate.getTime(), keyStoreBytes, keyStorePassphrase,
                    keyPairName, keyPairPassphrase);
        }

    } catch (NumberFormatException e) {
        throw new ServiceCryptoCreationException(e.getLocalizedMessage(), e);
    } catch (ManagerDAOException e) {
        throw new ServiceCryptoCreationException(e.getLocalizedMessage(), e);
    } catch (CryptoException e) {
        throw new ServiceCryptoCreationException(e.getLocalizedMessage(), e);
    } catch (KeyStoreException e) {
        throw new ServiceCryptoCreationException("Could not obtain certificate from new keystore.", e);
    }
}

From source file:org.apache.hadoop.fs.loadGenerator.LoadGeneratorMR.java

/** 
 * Parse the command line arguments and initialize the data.
 * Only parse the first arg: -mr <numMapTasks> <mrOutDir> (MUST be first three Args)
 * The rest are parsed by the Parent LoadGenerator
 **///ww  w.  j a  v  a  2  s.  com

private int parseArgsMR(String[] args) throws IOException {
    try {
        if (args.length >= 3 && args[0].equals("-mr")) {
            numMapTasks = Integer.parseInt(args[1]);
            mrOutDir = args[2];
            if (mrOutDir.startsWith("-")) {
                System.err.println("Missing output file parameter, instead got: " + mrOutDir);
                System.err.println(USAGE);
                return -1;
            }
        } else {
            System.err.println(USAGE);
            ToolRunner.printGenericCommandUsage(System.err);
            return -1;
        }
        String[] strippedArgs = new String[args.length - 3];
        for (int i = 0; i < strippedArgs.length; i++) {
            strippedArgs[i] = args[i + 3];
        }
        super.parseArgs(true, strippedArgs); // Parse normal LoadGenerator args
    } catch (NumberFormatException e) {
        System.err.println("Illegal parameter: " + e.getLocalizedMessage());
        System.err.println(USAGE);
        return -1;
    }
    return 0;
}

From source file:com.netxforge.oss2.config.SnmpEventInfo.java

private int computeIntValue(String parmContent) throws IllegalArgumentException {
    int val = 0;
    try {/*from ww w  .ja  va 2s . c om*/
        val = Integer.parseInt(parmContent);
    } catch (NumberFormatException e) {
        log().error("computeIntValue: parm value passed in the event isn't a valid number.", e);
        throw new IllegalArgumentException(e.getLocalizedMessage());
    }
    return val;
}

From source file:fr.sanofi.fcl4transmart.controllers.listeners.geneExpression.SelectGeneRawFileListener.java

public boolean checkFormat(File file) {
    try {/*w  ww. j a v  a 2 s.co m*/
        BufferedReader br = new BufferedReader(new FileReader(file));
        String line = br.readLine();
        line = br.readLine();
        //split must has a limit to take into account empty strings
        int columnsNbr = line.split("\t", -1).length;
        if (columnsNbr < 2) {
            this.selectRawFileUI.displayMessage("Error:\nAt least two columns are required");
            br.close();
            return false;
        }
        while ((line = br.readLine()) != null) {
            if (line.compareTo("") != 0) {
                String[] fields = line.split("\t", -1);
                if (fields.length != columnsNbr) {
                    this.selectRawFileUI.displayMessage("Error:\nLines have no the same number of columns");
                    br.close();
                    return false;
                }
                for (int i = 1; i < fields.length; i++) {
                    try {
                        Double.valueOf(fields[i]);
                    } catch (NumberFormatException e) {
                        this.selectRawFileUI.displayMessage("Error:\nIntensity values are to be numbers");
                        br.close();
                        return false;
                    }
                }
            }
        }
        br.close();
    } catch (Exception e) {
        selectRawFileUI.displayMessage("Error: " + e.getLocalizedMessage());
        e.printStackTrace();
        return false;
    }
    return true;
}