List of usage examples for java.lang NumberFormatException NumberFormatException
public NumberFormatException()
NumberFormatException
with no detail message. From source file:ac.robinson.mediaphone.MediaPhoneActivity.java
private void loadAllPreferences() { SharedPreferences mediaPhoneSettings = PreferenceManager .getDefaultSharedPreferences(MediaPhoneActivity.this); Resources res = getResources(); // bluetooth observer configureBluetoothObserver(mediaPhoneSettings, res); // importing confirmation boolean confirmImporting = res.getBoolean(R.bool.default_confirm_importing); try {/*ww w . jav a2 s . c o m*/ confirmImporting = mediaPhoneSettings.getBoolean(getString(R.string.key_confirm_importing), confirmImporting); } catch (Exception e) { confirmImporting = res.getBoolean(R.bool.default_confirm_importing); } MediaPhone.IMPORT_CONFIRM_IMPORTING = confirmImporting; // delete after import boolean deleteAfterImport = res.getBoolean(R.bool.default_delete_after_importing); try { deleteAfterImport = mediaPhoneSettings.getBoolean(getString(R.string.key_delete_after_importing), deleteAfterImport); } catch (Exception e) { deleteAfterImport = res.getBoolean(R.bool.default_delete_after_importing); } MediaPhone.IMPORT_DELETE_AFTER_IMPORTING = deleteAfterImport; // minimum frame duration TypedValue resourceValue = new TypedValue(); res.getValue(R.attr.default_minimum_frame_duration, resourceValue, true); float minimumFrameDuration; try { minimumFrameDuration = mediaPhoneSettings.getFloat(getString(R.string.key_minimum_frame_duration), resourceValue.getFloat()); if (minimumFrameDuration <= 0) { throw new NumberFormatException(); } } catch (Exception e) { minimumFrameDuration = resourceValue.getFloat(); } MediaPhone.PLAYBACK_EXPORT_MINIMUM_FRAME_DURATION = Math.round(minimumFrameDuration * 1000); // word duration res.getValue(R.attr.default_word_duration, resourceValue, true); float wordDuration; try { wordDuration = mediaPhoneSettings.getFloat(getString(R.string.key_word_duration), resourceValue.getFloat()); if (wordDuration <= 0) { throw new NumberFormatException(); } } catch (Exception e) { wordDuration = resourceValue.getFloat(); } MediaPhone.PLAYBACK_EXPORT_WORD_DURATION = Math.round(wordDuration * 1000); // screen orientation int requestedOrientation = res.getInteger(R.integer.default_screen_orientation); try { String requestedOrientationString = mediaPhoneSettings .getString(getString(R.string.key_screen_orientation), null); requestedOrientation = Integer.valueOf(requestedOrientationString); } catch (Exception e) { requestedOrientation = res.getInteger(R.integer.default_screen_orientation); } setRequestedOrientation(requestedOrientation); // other preferences loadPreferences(mediaPhoneSettings); }
From source file:dhbw.ka.mwi.businesshorizon2.ui.process.parameter.ParameterPresenter.java
/** * Methode die sich nach der Auswahl der zu Vorherzusagenden Perioden um die * davon abhaengigen Objekte kuemmert. Konkret wird aus dem String des * Eingabefelds der Integer-Wert gezogen und geprueft ob der eingegebene * Wert groesser 0 ist. Ist einer der beiden Kriterien nicht erfuellt wird * eine ClassCastException geworfen, die zu einer Fehlermeldung auf der * Benutzeroberflaecher fuehrt.//from ww w . j a v a 2 s . c o m * * @author Christian Scherer * @param numberPeriodsToForecast * Anzahl der Perioden die in die Vorhergesagt werden sollen */ public void numberPeriodsToForecastChosen_deterministic(String periodsToForecast_deterministic) { logger.debug("Anwender-Eingabe zu deterministischen Perioden die vorherzusagen sind"); int periodsToForecast_deterministicInt; try { periodsToForecast_deterministicInt = Integer.parseInt(periodsToForecast_deterministic); if (periodsToForecast_deterministicInt > 0) { periodsToForecast_deterministicValid = true; getView().setComponentError(false, "periodsToForecast_deterministic", ""); this.projectProxy.getSelectedProject() .setPeriodsToForecast_deterministic(periodsToForecast_deterministicInt); logger.debug("Anzahl Perioden die vorherzusagen sind in das Projekt-Objekten gesetzt"); } else { throw new NumberFormatException(); } } catch (NumberFormatException nfe) { periodsToForecast_deterministicValid = false; getView().setComponentError(true, "periodsToForecast_deterministic", errorMessagePeriodsToForecast_deterministic); getView().showErrorMessage(errorMessagePeriodsToForecast_deterministic); logger.debug( "Keine gueltige Eingabe in Feld 'Anzahl zu prognostizierender Perioden' bei den deterministischen Verfahren"); } eventBus.fireEvent(new ValidateContentStateEvent()); }
From source file:de.helmholtz_muenchen.ibis.knime.preferences.KNIMEPreferencePage.java
public boolean performOk() { OVERWRITE = checkOverwrite.getSelection(); IBISKNIMENodesPlugin.setBooleanPreference(IBISKNIMENodesPlugin.OVERWRITE, OVERWRITE); try {// w ww . jav a 2 s. co m REF_GENOME = IO.processFilePath(refGenome.getText()); if (!REF_GENOME.equals("") && !FileValidator.checkFastaFormat(REF_GENOME)) { JOptionPane.showMessageDialog(null, "Reference (genome) sequence file is not in FastA format or does not contain nucleotide sequences!", "Error", JOptionPane.ERROR_MESSAGE); return false; } IBISKNIMENodesPlugin.setStringPreference(IBISKNIMENodesPlugin.REF_GENOME, REF_GENOME); RES_HAPMAP = IO.processFilePath(res_hapmap.getText()); IBISKNIMENodesPlugin.setStringPreference(IBISKNIMENodesPlugin.RES_HAPMAP, RES_HAPMAP); RES_OMNI = IO.processFilePath(res_omni.getText()); IBISKNIMENodesPlugin.setStringPreference(IBISKNIMENodesPlugin.RES_OMNI, RES_OMNI); RES_1000G_SNPS = IO.processFilePath(res_1000G_SNPS.getText()); IBISKNIMENodesPlugin.setStringPreference(IBISKNIMENodesPlugin.RES_1000G_SNPS, RES_1000G_SNPS); RES_1000G_INDELS = IO.processFilePath(res_1000G_Indels.getText()); IBISKNIMENodesPlugin.setStringPreference(IBISKNIMENodesPlugin.RES_1000G_INDELS, RES_1000G_INDELS); RES_DBSNP = IO.processFilePath(res_dbsnp.getText()); IBISKNIMENodesPlugin.setStringPreference(IBISKNIMENodesPlugin.RES_DBSNP, RES_DBSNP); RES_MILLS = IO.processFilePath(res_mills.getText()); IBISKNIMENodesPlugin.setStringPreference(IBISKNIMENodesPlugin.RES_MILLS, RES_MILLS); } catch (InvalidSettingsException e1) { } USE_HTE = checkHTE.getSelection(); IBISKNIMENodesPlugin.setBooleanPreference(IBISKNIMENodesPlugin.USE_HTE, USE_HTE); if (!USE_HTE) { IBISKNIMENodesPlugin.setBooleanPreference(IBISKNIMENodesPlugin.NOTIFY, USE_HTE); return super.performOk(); } THRESHOLD = thresholdText.getText(); try { int n = Integer.parseInt(THRESHOLD); if (n < 0) { throw (new NumberFormatException()); } } catch (NumberFormatException e) { JOptionPane.showMessageDialog(null, "Threshold has to be a positive integer.", "Error", JOptionPane.ERROR_MESSAGE); return false; } IBISKNIMENodesPlugin.setStringPreference(IBISKNIMENodesPlugin.THRESHOLD, THRESHOLD); try { DB_FILE = IO.processFilePath(dbFile.getText()); } catch (InvalidSettingsException e1) { } if (DB_FILE.equals("")) { JOptionPane.showMessageDialog(null, "HTE requires a SQLite database. Please create a new one or choose an existing one.", "Error", JOptionPane.ERROR_MESSAGE); return false; } IBISKNIMENodesPlugin.setStringPreference(IBISKNIMENodesPlugin.DB_FILE, DB_FILE); EMAILHOST = email_host.getText(); IBISKNIMENodesPlugin.setStringPreference(IBISKNIMENodesPlugin.EMAIL_HOST, EMAILHOST); EMAILSENDER = email_sender.getText(); IBISKNIMENodesPlugin.setStringPreference(IBISKNIMENodesPlugin.EMAIL_SENDER, EMAILSENDER); EMAILRECEIVER = email_receiver.getText(); IBISKNIMENodesPlugin.setStringPreference(IBISKNIMENodesPlugin.EMAIL_RECEIVER, EMAILRECEIVER); NOTIFY = checkNotify.getSelection(); IBISKNIMENodesPlugin.setBooleanPreference(IBISKNIMENodesPlugin.NOTIFY, NOTIFY); if (NOTIFY) { if (EMAILHOST.equals("")) { JOptionPane.showMessageDialog(null, "Email host is required for Email notification!", "Error", JOptionPane.ERROR_MESSAGE); return false; } if (EMAILSENDER.equals("")) { JOptionPane.showMessageDialog(null, "Email sender is required for Email notification!", "Error", JOptionPane.ERROR_MESSAGE); return false; } try { new InternetAddress(EMAILRECEIVER).validate(); } catch (AddressException e) { JOptionPane.showMessageDialog(null, "Enter valid Email address.", "Error", JOptionPane.ERROR_MESSAGE); return false; } } return super.performOk(); }
From source file:com.funambol.admin.settings.panels.EditServerConfigurationPanel.java
/** * Validates the inputs anf throws an Exception in case of any invalid data. * * @throws IllegalArgumentException in case of invalid input *///from w w w. j ava 2 s .co m private void validateInput() throws IllegalArgumentException { String value = null; value = man.getText(); if (StringUtils.isEmpty(value)) { String msg = MessageFormat.format(Bundle.getMessage(Bundle.ERROR_EMPTY_INPUT), new String[] { Bundle.getMessage(Bundle.LABEL_MAN) }); throw new IllegalArgumentException(msg); } value = mod.getText(); if (StringUtils.isEmpty(value)) { String msg = MessageFormat.format(Bundle.getMessage(Bundle.ERROR_EMPTY_INPUT), new String[] { Bundle.getMessage(Bundle.LABEL_MOD) }); throw new IllegalArgumentException(msg); } value = swV.getText(); if (StringUtils.isEmpty(value)) { String msg = MessageFormat.format(Bundle.getMessage(Bundle.ERROR_EMPTY_INPUT), new String[] { Bundle.getMessage(Bundle.LABEL_SWV) }); throw new IllegalArgumentException(msg); } value = hwV.getText(); if (StringUtils.isEmpty(value)) { String msg = MessageFormat.format(Bundle.getMessage(Bundle.ERROR_EMPTY_INPUT), new String[] { Bundle.getMessage(Bundle.LABEL_HWV) }); throw new IllegalArgumentException(msg); } value = fwV.getText(); if (StringUtils.isEmpty(value)) { String msg = MessageFormat.format(Bundle.getMessage(Bundle.ERROR_EMPTY_INPUT), new String[] { Bundle.getMessage(Bundle.LABEL_FWV) }); throw new IllegalArgumentException(msg); } value = oem.getText(); if (StringUtils.isEmpty(value)) { String msg = MessageFormat.format(Bundle.getMessage(Bundle.ERROR_EMPTY_INPUT), new String[] { Bundle.getMessage(Bundle.LABEL_OEM) }); throw new IllegalArgumentException(msg); } value = devId.getText(); if (StringUtils.isEmpty(value)) { String msg = MessageFormat.format(Bundle.getMessage(Bundle.ERROR_EMPTY_INPUT), new String[] { Bundle.getMessage(Bundle.LABEL_DEV_ID) }); throw new IllegalArgumentException(msg); } value = devTyp.getText(); if (StringUtils.isEmpty(value)) { String msg = MessageFormat.format(Bundle.getMessage(Bundle.ERROR_EMPTY_INPUT), new String[] { Bundle.getMessage(Bundle.LABEL_DEV_TYP) }); throw new IllegalArgumentException(msg); } value = verDTD.getText(); if (StringUtils.isEmpty(value)) { String msg = MessageFormat.format(Bundle.getMessage(Bundle.ERROR_EMPTY_INPUT), new String[] { Bundle.getMessage(Bundle.LABEL_VER_DTD) }); throw new IllegalArgumentException(msg); } value = serverUri.getText(); if (StringUtils.isNotEmpty(value)) { try { // // Checks if serverURI is a well formed URI. // Used the URL because the URI does not throw // URISyntaxException in some cases when expected // (see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4668181) // URL url = new URL(value); // // The serverUri must start with http:// or https:// in order to // be used as a valid URL // if (!value.startsWith("http://") && !value.startsWith("https://")) { throw new MalformedURLException(); } } catch (MalformedURLException e) { String msg = MessageFormat.format(Bundle.getMessage(Bundle.ERROR_SERVER_URI_NOT_VALID), new String[] { value }); throw new IllegalArgumentException(msg); } } value = officer.getText(); if (StringUtils.isEmpty(value)) { String msg = MessageFormat.format(Bundle.getMessage(Bundle.ERROR_EMPTY_INPUT), new String[] { Bundle.getMessage(Bundle.LABEL_OFFICER) }); throw new IllegalArgumentException(msg); } value = deviceInventory.getText(); if (StringUtils.isEmpty(value)) { String msg = MessageFormat.format(Bundle.getMessage(Bundle.ERROR_EMPTY_INPUT), new String[] { Bundle.getMessage(Bundle.LABEL_DEVICE_INVENTORY) }); throw new IllegalArgumentException(msg); } value = handler.getText(); if (StringUtils.isEmpty(value)) { String msg = MessageFormat.format(Bundle.getMessage(Bundle.ERROR_EMPTY_INPUT), new String[] { Bundle.getMessage(Bundle.LABEL_HANDLER) }); throw new IllegalArgumentException(msg); } value = strategy.getText(); if (StringUtils.isEmpty(value)) { String msg = MessageFormat.format(Bundle.getMessage(Bundle.ERROR_EMPTY_INPUT), new String[] { Bundle.getMessage(Bundle.LABEL_STRATEGY) }); throw new IllegalArgumentException(msg); } value = userManager.getText(); if (StringUtils.isEmpty(value)) { String msg = MessageFormat.format(Bundle.getMessage(Bundle.ERROR_EMPTY_INPUT), new String[] { Bundle.getMessage(Bundle.LABEL_USER_MANAGER) }); throw new IllegalArgumentException(msg); } value = smsService.getText(); if (StringUtils.isEmpty(value)) { String msg = MessageFormat.format(Bundle.getMessage(Bundle.ERROR_EMPTY_INPUT), new String[] { Bundle.getMessage(Bundle.LABEL_SMS_SERVICE) }); throw new IllegalArgumentException(msg); } try { int i = Integer.parseInt(minMaxMsgSize.getText()); if (i < 1 || i > 100000) { throw new NumberFormatException(); } } catch (NumberFormatException e) { String msg = MessageFormat.format(Bundle.getMessage(Bundle.ERROR_NUMERIC_INPUT), new String[] { Bundle.getMessage(Bundle.LABEL_MIN_MAX_MSG_SIZE), "1", String.valueOf("100000") }); throw new IllegalArgumentException(msg); } }
From source file:org.shampoo.goldenembed.parser.GoldenEmbedParserMain.java
private int readBuffer(byte[] readBytes, String filePath) { int bufPos = 0; GPS gps = new GPS(); byte[] bufToSend; byte[] timeStamp; long secs = 0; if ((pos + bufPos + 64) >= readBytes.length - 1) { System.out.println("\n\nTotal Failed Checksums: " + totalChecksumError + " Out of Total ANT Messages: " + totalTrans);//from w w w .ja v a2s. co m System.out.println("% ANT Failure: " + (totalChecksumError / totalTrans) * 100.0); System.out.println("Total Failed GPS: " + totalGPSError + " Out of Total ANT Messages: " + totalTrans); System.out.println("% GPS Failure: " + (totalGPSError / totalTrans) * 100.0); System.out.println("Total Failed Messages: " + (totalChecksumError + totalGPSError) + " Out of Total ANT Messages: " + totalTrans); System.out.println("% Failure: " + ((totalChecksumError + totalGPSError) / totalTrans) * 100.0); System.out.println("Total CAD or Watt Spikes: " + totalSpikes); writeOutGCRecords(); System.exit(0); } Byte aByte = new Byte(readBytes[pos + bufPos + 1]); int size = aByte.intValue(); if (size < 0) { pos++; // We failed a checksum skip.. while (readBytes[pos] != MESG_TX_SYNC) { pos++; } totalChecksumError++; return pos; } bufToSend = new byte[size + 4]; for (; bufPos < bufToSend.length; bufPos++) bufToSend[bufPos] = readBytes[bufPos + pos]; if (ANTrxHandler(bufToSend, gc) == true) { pos++; // We failed a checksum skip.. while (readBytes[pos] != MESG_TX_SYNC) pos++; return pos; } pos = (pos + size + 4); try { if (isGPS) { // Now Parse GPS gps = new GPS().GPSHandler(readBytes, pos); pos += 22; // All GPS data // Get the intial elevation from Google use Lat and Lon if (altiPressure == null && serializedElevationPath == null) { altiPressure = new AltitudePressure(GoogleElevation .getElevation(Float.valueOf(gps.getLatitude()), Float.valueOf(gps.getLongitude()))); } int pressureCounter = 0; byte[] pressureByte = new byte[16]; while (readBytes[pos] != 0x07) { if (pressureCounter == 15) throw new NumberFormatException(); pressureByte[pressureCounter++] = readBytes[pos++]; } pos++; // skip the delimeter String strPressure = convertBytesToString(pressureByte); float pressure = Float.parseFloat(strPressure); strPressure = convertBytesToString(pressureByte); pressure = Float.parseFloat(strPressure); if (serializedElevationPath == null) gc.setElevation(altiPressure.altiCalc(pressure / 100.0f)); timeStamp = new byte[6]; for (int i = 0; i < 6; i++) timeStamp[i] = readBytes[pos++]; secs = parseTimeStamp(timeStamp, gc); } else { timeStamp = new byte[3]; for (int i = 0; i < 3; i++) timeStamp[i] = readBytes[pos++]; secs = parseTimeStamp(timeStamp, gc); } if (rideDate == null && isGPS == true) createRideDate(gps, timeStamp); else if (rideDate == null) createRideDate(); gc.setLatitude(gps.getLatitude()); gc.setLongitude(gps.getLongitude()); gc.setSpeed(gps.getSpeed() * KNOTS_TO_KILOMETERS); gc.setDistance(gc.getDistance() + (gc.getSpeed() * (gc.getSecs() - gc.getPrevSpeedSecs()) / 3600.0)); gc.setPrevSpeedSecs(gc.getSecs()); if (secs > 86400) // Only fools ride for more then 24hrs a time.. throw new NumberFormatException(); gc.setSecs(secs); gc.setDate(gps.getDate()); // If we haven't created the file, create it if (outFile == null && outGCFilePath != null) { if (isGPS) initOutFile(gps, outGCFilePath, timeStamp); else createGCOutFile(); } if (gc.getPrevsecs() != gc.getSecs()) { gc.setWatts((int) Round(power.getWatts() / power.getTotalWattCounter(), 0)); gc.setCad((int) Round(power.getRpm() / power.getTotalCadCounter(), 0)); GoldenCheetah _gc = gc.clone(gc); gcArray.add(_gc); gc.setPrevsecs(gc.getSecs()); gc.newWatts = false; } } catch (NumberFormatException e) { while (readBytes[pos] != MESG_TX_SYNC) pos++; totalGPSError++; return pos; } catch (StringIndexOutOfBoundsException ex) { while (readBytes[pos] != MESG_TX_SYNC) pos++; totalGPSError++; } return pos; }
From source file:jp.terasoluna.fw.web.struts.form.FieldChecksExTest08.java
/** * testValidateByteRange08()//from ww w . ja v a 2 s .co m * <br><br> * * (??n) * <br> * _?FF * <br><br> * l?F(?) bean:String:""<br> * (?) va:not null<br> * (?) field:not null<br> * var:minByte="abc"<br> * var:maxByte="def"<br> * encoding="test-encoding"<br> * Msg("message","message")<br> * (?) errors:not null<br> * ActionMessage("testMessage")<br> * (?) validator:not null<br> * (?) request:not null<br> * * <br> * l?F(l) boolean:true<br> * (?) ?O:?Ox?FG?[<br> * ?bZ?[W?F""<br> * O?FNumberFormatException<br> * ?Ox?Fx??<br> * ?bZ?[W?F<br> * "test-encoding is not supported."<br> * (?) errors:not null<br> * (vf)<br> * * <br> * fieldminByte?AmaxByte?l?A?A0?A * Integer.MAX_VALUEvZ?smF?B * <br> * * @throws Exception ?\bh?O */ public void testValidateByteRange08() throws Exception { //eXgf?[^? // ++++ beanIuWFNg ++++ String bean = ""; // ++++ ??IuWFNg ValidatorAction va = new ValidatorAction(); va.setName("message"); // ++++ ?tB?[h? Field field = new Field(); Var var = new Var(); var.setName("maxByte"); var.setValue("abc"); field.addVar(var); var = new Var(); var.setName("minByte"); var.setValue("def"); field.addVar(var); var = new Var(); var.setName("encoding"); var.setValue("test-encoding"); field.addVar(var); // ?bZ?[W? Msg msg = new Msg(); msg.setKey("message"); msg.setName("message"); msg.setResource(false); field.addMsg(msg); // G?[? ActionMessages errors = new ActionMessages(); // [HTTPNGXg MockHttpServletRequest request = new MockHttpServletRequest(); // ValidatorResourcesCX^X ValidatorResources validatorResources = new ValidatorResources(); // ValidatorCX^X Validator validator = new Validator(validatorResources); // eXg?s boolean result = FieldChecksEx.validateByteRange(bean, va, field, errors, validator, request); // eXgmF // truep?B assertTrue(result); // G?[??B assertTrue(errors.isEmpty()); // G?[?O`FbN assertTrue(LogUTUtil.checkError("", new NumberFormatException())); // x???O`FbN assertTrue(LogUTUtil.checkWarn("test-encoding is not supported.")); }
From source file:dhbw.ka.mwi.businesshorizon2.ui.process.parameter.ParameterPresenter.java
/** * Methode die sich nach der Auswahl der anzugebenden vergangenen * Perioden um die davon abhaengigen Objekte kuemmert. Diese muessen laut * Fachkonzept groesser 3 Perioden betragen und groesser als die Anzahl * einbezogener Perioden sein//w w w. jav a2 s .c o m * * @author Marcel Rosenberger * @param specifiedPastPeriods * die Anzahl der Perioden der Vergangenheit die angegeben werden mssen */ public void specifiedPastPeriodsChosen(String specifiedPastPeriods) { logger.debug("Anwender-Eingabe zu anzugebenden Perioden der Vergangenheit "); int specifiedPastPeriodsInt; int relevantPastPeriodsInt; try { specifiedPastPeriodsInt = Integer.parseInt(specifiedPastPeriods); relevantPastPeriodsInt = this.projectProxy.getSelectedProject().getRelevantPastPeriods(); if (specifiedPastPeriodsInt > 3 && specifiedPastPeriodsInt > relevantPastPeriodsInt) { specifiedPastPeriodsValid = true; getView().setComponentError(false, "specifiedPastPeriods", ""); this.projectProxy.getSelectedProject().setSpecifiedPastPeriods(specifiedPastPeriodsInt); logger.debug("Anzahl anzugebender Vergangenheits-Perioden sind in das Projekt-Objekten gesetzt"); } else { throw new NumberFormatException(); } } catch (NumberFormatException nfe) { specifiedPastPeriodsValid = false; getView().setComponentError(true, "specifiedPastPeriods", errorMessageSpecifiedPastPeriods); getView().showErrorMessage(errorMessageSpecifiedPastPeriods); logger.debug("Keine gueltige Eingabe in Feld 'Anzahl anzugebender, vergangener Perioden'"); } eventBus.fireEvent(new ValidateContentStateEvent()); }
From source file:dhbw.ka.mwi.businesshorizon2.ui.process.parameter.ParameterPresenter.java
/** * Methode die sich nach der Auswahl der zu beachtenenden vergangenen * Perioden um die davon abhaengigen Objekte kuemmert. Diese muessen laut * Fachkonzept groesser 2 Perioden betragen und kleiner als die * Anzahl anzugebender Perioden sein./*from www . j a v a2 s .co m*/ * * @author Christian Scherer, Marcel Rosenberger * @param relevantPastPeriods * die Anzahl der Perioden der Vergangenheit die einbezogen * werden sollen */ public void relevantPastPeriodsChosen(String relevantPastPeriods) { logger.debug("Anwender-Eingabe zu relevanter Perioden der Vergangenheit "); int relevantPastPeriodsInt; int specifiedPastPeriodsInt; try { relevantPastPeriodsInt = Integer.parseInt(relevantPastPeriods); specifiedPastPeriodsInt = this.projectProxy.getSelectedProject().getSpecifiedPastPeriods(); if (relevantPastPeriodsInt > 2 && specifiedPastPeriodsInt > relevantPastPeriodsInt) { relevantPastPeriodsValid = true; getView().setComponentError(false, "relevantPastPeriods", ""); this.projectProxy.getSelectedProject().setRelevantPastPeriods(relevantPastPeriodsInt); logger.debug("Anzahl relevanter Perioden der Vergangenheit sind in das Projekt-Objekten gesetzt"); } else { throw new NumberFormatException(); } } catch (NumberFormatException nfe) { relevantPastPeriodsValid = false; getView().setComponentError(true, "relevantPastPeriods", errorMessageRelevantPastPeriods); getView().showErrorMessage(errorMessageRelevantPastPeriods); logger.debug("Keine gueltige Eingabe in Feld 'Anzahl einbezogener, vergangener Perioden'"); } eventBus.fireEvent(new ValidateContentStateEvent()); }
From source file:dhbw.ka.mwi.businesshorizon2.ui.process.parameter.ParameterPresenter.java
/** * Methode die sich nach der Auswahl des Basisjahrs um die davon abhaengigen * Objekte kuemmert. Wenn ein int Wert vorliegt wird geprueft ob es sich bei * der Eingegebenen Zahl um ein Jahr groesser dem aktuellen Jahr-1 handelt * /*from w w w . j av a 2s . c o m*/ * @author Christian Scherer * @param basisYear * das Basis-Jahr, auf das die Cashflows abgezinst werden */ public void basisYearChosen(String basisYear) { logger.debug("Anwender-Eingabe zu relevanter Perioden der Vergangenheit "); int basisYearInt; try { basisYearInt = Integer.parseInt(basisYear); if (basisYearInt > 1900) { basisYearValid = true; getView().setComponentError(false, "basisYear", ""); this.projectProxy.getSelectedProject().setBasisYear(basisYearInt); logger.debug("Basisjahr in das Projekt-Objekten gesetzt"); } else { throw new NumberFormatException(); } } catch (NumberFormatException nfe) { basisYearValid = false; getView().setComponentError(true, "basisYear", errorMessageBasisYear); getView().showErrorMessage(errorMessageBasisYear); logger.debug("Keine gueltige Eingabe in Feld 'Wahl des Basisjahr'"); } eventBus.fireEvent(new ValidateContentStateEvent()); }
From source file:net.sf.webissues.core.WebIssuesTaskDataHandler.java
private void validateAttribute(TaskRepository repository, String value, Attribute key) throws CoreException { if (key.isRequired() && Util.isNullOrBlank(value)) { throw new CoreException(RepositoryStatus.createStatus(repository.getRepositoryUrl(), IStatus.ERROR, WebIssuesCorePlugin.ID_PLUGIN, key.getName() + " is a required attribute.")); }/*from ww w .j a va2 s . c o m*/ if (!Util.isNullOrBlank(value)) { if (key.getType().equals(Attribute.AttributeType.NUMERIC)) { if (key.getDecimalPlaces() > 0) { try { double i = Double.parseDouble(value); int idx = value.indexOf('.'); if (idx != -1) { if ((value.length() - idx - 1) > key.getDecimalPlaces()) { throw new NumberFormatException(); } } if (i < key.getMinValue() || i > key.getMaxValue()) { throw new NumberFormatException(); } } catch (NumberFormatException nfe) { throw new CoreException(RepositoryStatus.createStatus(repository.getRepositoryUrl(), IStatus.ERROR, WebIssuesCorePlugin.ID_PLUGIN, key.getName() + " must be a floating point number between " + key.getMinValue() + " and " + key.getMaxValue() + " with a maximum of " + key.getDecimalPlaces() + " decimal places")); } } else { try { long i = Long.parseLong(value); if (i < key.getMinValue() || i > key.getMaxValue()) { throw new NumberFormatException(); } } catch (NumberFormatException nfe) { throw new CoreException(RepositoryStatus.createStatus(repository.getRepositoryUrl(), IStatus.ERROR, WebIssuesCorePlugin.ID_PLUGIN, key.getName() + " must be an integer number between " + key.getMinValue() + " and " + key.getMaxValue())); } } } if (key.getType().equals(Attribute.AttributeType.TEXT)) { if (value.length() > key.getMaxLength()) { throw new CoreException(RepositoryStatus.createStatus(repository.getRepositoryUrl(), IStatus.ERROR, WebIssuesCorePlugin.ID_PLUGIN, key.getName() + " exceeds the maximum length of " + key.getMaxLength())); } } } }