List of usage examples for java.lang IllegalArgumentException printStackTrace
public void printStackTrace()
From source file:geogebra.kernel.statistics.AlgoTMean2Estimate.java
protected final void compute() { try {//from w w w . ja v a 2s. c om // get statistics from sample data input if (input.length == 4) { size1 = geoList1.size(); if (!geoList1.isDefined() || size1 < 2) { result.setUndefined(); return; } size2 = geoList2.size(); if (!geoList2.isDefined() || size2 < 2) { result.setUndefined(); return; } val1 = new double[size1]; for (int i = 0; i < size1; i++) { GeoElement geo = geoList1.get(i); if (geo.isNumberValue()) { NumberValue num = (NumberValue) geo; val1[i] = num.getDouble(); } else { result.setUndefined(); return; } } val2 = new double[size2]; for (int i = 0; i < size2; i++) { GeoElement geo = geoList2.get(i); if (geo.isNumberValue()) { NumberValue num = (NumberValue) geo; val2[i] = num.getDouble(); } else { result.setUndefined(); return; } } stats = new SummaryStatistics(); for (int i = 0; i < val1.length; i++) { stats.addValue(val1[i]); } n1 = stats.getN(); var1 = stats.getVariance(); mean1 = stats.getMean(); stats.clear(); for (int i = 0; i < val2.length; i++) { stats.addValue(val2[i]); } n2 = stats.getN(); var2 = stats.getVariance(); mean2 = stats.getMean(); } else { mean1 = geoMean1.getDouble(); var1 = geoSD1.getDouble() * geoSD1.getDouble(); n1 = geoN1.getDouble(); mean2 = geoMean2.getDouble(); var2 = geoSD2.getDouble() * geoSD2.getDouble(); n2 = geoN2.getDouble(); } level = geoLevel.getDouble(); pooled = geoPooled.getBoolean(); // validate statistics if (level < 0 || level > 1 || var1 < 0 || n1 < 1 || var2 < 0 || n2 < 1) { result.setUndefined(); return; } // get interval estimate me = getMarginOfError(var1, n1, var2, n2, level, pooled); // return list = {low limit, high limit, difference, margin of error, df } difference = mean1 - mean2; result.clear(); boolean oldSuppress = cons.isSuppressLabelsActive(); cons.setSuppressLabelCreation(true); result.add(new GeoNumeric(cons, difference - me)); result.add(new GeoNumeric(cons, difference + me)); //result.add(new GeoNumeric(cons, difference)); //result.add(new GeoNumeric(cons, me)); //result.add(new GeoNumeric(cons, getDegreeOfFreedom(var1, var2, n1, n2, pooled))); cons.setSuppressLabelCreation(oldSuppress); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (MathException e) { e.printStackTrace(); } }
From source file:geogebra.common.kernel.statistics.AlgoTMean2Estimate.java
@Override public final void compute() { try {// w ww . j a v a 2 s .c o m // get statistics from sample data input if (input.length == 4) { size1 = geoList1.size(); if (!geoList1.isDefined() || size1 < 2) { result.setUndefined(); return; } size2 = geoList2.size(); if (!geoList2.isDefined() || size2 < 2) { result.setUndefined(); return; } val1 = new double[size1]; for (int i = 0; i < size1; i++) { GeoElement geo = geoList1.get(i); if (geo instanceof NumberValue) { NumberValue num = (NumberValue) geo; val1[i] = num.getDouble(); } else { result.setUndefined(); return; } } val2 = new double[size2]; for (int i = 0; i < size2; i++) { GeoElement geo = geoList2.get(i); if (geo instanceof NumberValue) { NumberValue num = (NumberValue) geo; val2[i] = num.getDouble(); } else { result.setUndefined(); return; } } stats = new SummaryStatistics(); for (int i = 0; i < val1.length; i++) { stats.addValue(val1[i]); } n1 = stats.getN(); var1 = stats.getVariance(); mean1 = stats.getMean(); stats.clear(); for (int i = 0; i < val2.length; i++) { stats.addValue(val2[i]); } n2 = stats.getN(); var2 = stats.getVariance(); mean2 = stats.getMean(); } else { mean1 = geoMean1.getDouble(); var1 = geoSD1.getDouble() * geoSD1.getDouble(); n1 = geoN1.getDouble(); mean2 = geoMean2.getDouble(); var2 = geoSD2.getDouble() * geoSD2.getDouble(); n2 = geoN2.getDouble(); } level = geoLevel.getDouble(); pooled = geoPooled.getBoolean(); // validate statistics if (level < 0 || level > 1 || var1 < 0 || n1 < 1 || var2 < 0 || n2 < 1) { result.setUndefined(); return; } // get interval estimate me = getMarginOfError(var1, n1, var2, n2, level, pooled); // return list = {low limit, high limit, difference, margin of // error, df } difference = mean1 - mean2; result.clear(); boolean oldSuppress = cons.isSuppressLabelsActive(); cons.setSuppressLabelCreation(true); result.add(new GeoNumeric(cons, difference - me)); result.add(new GeoNumeric(cons, difference + me)); // result.add(new GeoNumeric(cons, difference)); // result.add(new GeoNumeric(cons, me)); // result.add(new GeoNumeric(cons, getDegreeOfFreedom(var1, var2, // n1, n2, pooled))); cons.setSuppressLabelCreation(oldSuppress); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (MathException e) { e.printStackTrace(); } }
From source file:com.amazonaws.services.dynamodbv2.online.index.ViolationDetector.java
private void setConfigFile(String configFile) { try {// w w w. j a va 2 s. co m optionLoader = new OptionLoader(configFile); } catch (IllegalArgumentException iae) { logger.error("Exception!", iae); iae.printStackTrace(); System.exit(1); } }
From source file:com.android.wako.net.AsyncHttpGet.java
@Override boolean process() { try {/*from w w w.j a va 2s. c o m*/ if (parameter != null && parameter.size() > 0) { StringBuilder bulider = new StringBuilder(); for (RequestParameter p : parameter) { if (bulider.length() != 0) { bulider.append("&"); } bulider.append(Utils.encode(p.getName())); bulider.append("="); bulider.append(Utils.encode(p.getValue())); } url += "?" + bulider.toString(); } if (LogUtil.IS_LOG) LogUtil.d(TAG, "AsyncHttpGet request to url :" + url); request = new HttpGet(url); /* * if(Constants.isGzip){ request.addHeader("Accept-Encoding", * "gzip"); }else{ request.addHeader("Accept-Encoding", "default"); * } */ // httpClient.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, connectTimeout); // ? httpClient.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, readTimeout); HttpResponse response = httpClient.execute(request); int statusCode = response.getStatusLine().getStatusCode(); if (LogUtil.IS_LOG) LogUtil.d(TAG, "statusCode=" + statusCode); if (statusCode == HttpStatus.SC_OK) { InputStream is = response.getEntity().getContent(); BufferedInputStream bis = new BufferedInputStream(is); bis.mark(2); // ?? byte[] header = new byte[2]; int result = bis.read(header); // reset?? bis.reset(); // ?GZIP? int headerData = getShort(header); // Gzip ? ? 0x1f8b if (result != -1 && headerData == 0x1f8b) { if (LogUtil.IS_LOG) LogUtil.d(TAG, " use GZIPInputStream "); is = new GZIPInputStream(bis); } else { if (LogUtil.IS_LOG) LogUtil.d(TAG, " not use GZIPInputStream"); is = bis; } InputStreamReader reader = new InputStreamReader(is, "utf-8"); char[] data = new char[100]; int readSize; StringBuffer sb = new StringBuffer(); while ((readSize = reader.read(data)) > 0) { sb.append(data, 0, readSize); } ret = sb.toString(); bis.close(); reader.close(); return true; } else { mRetStatus = ResStatus.Error_Code; RequestException exception = new RequestException(RequestException.IO_EXCEPTION, "??,??" + statusCode); } if (LogUtil.IS_LOG) LogUtil.d(TAG, "AsyncHttpGet request to url :" + url + " finished !"); } catch (IllegalArgumentException e) { mRetStatus = ResStatus.Error_IllegalArgument; e.printStackTrace(); RequestException exception = new RequestException(RequestException.IO_EXCEPTION, Constants.ERROR_MESSAGE); if (LogUtil.IS_LOG) LogUtil.d(TAG, "AsyncHttpGet request to url :" + url + " onFail " + e.getMessage()); } catch (org.apache.http.conn.ConnectTimeoutException e) { mRetStatus = ResStatus.Error_Connect_Timeout; e.printStackTrace(); RequestException exception = new RequestException(RequestException.SOCKET_TIMEOUT_EXCEPTION, Constants.ERROR_MESSAGE); if (LogUtil.IS_LOG) LogUtil.d(TAG, "AsyncHttpGet request to url :" + url + " onFail " + e.getMessage()); } catch (java.net.SocketTimeoutException e) { mRetStatus = ResStatus.Error_Socket_Timeout; e.printStackTrace(); RequestException exception = new RequestException(RequestException.SOCKET_TIMEOUT_EXCEPTION, Constants.ERROR_MESSAGE); if (LogUtil.IS_LOG) LogUtil.d(TAG, "AsyncHttpGet request to url :" + url + " onFail " + e.getMessage()); } catch (UnsupportedEncodingException e) { mRetStatus = ResStatus.Error_Unsupport_Encoding; e.printStackTrace(); RequestException exception = new RequestException(RequestException.UNSUPPORTED_ENCODEING_EXCEPTION, "?"); if (LogUtil.IS_LOG) LogUtil.d(TAG, "AsyncHttpGet request to url :" + url + " UnsupportedEncodingException " + e.getMessage()); } catch (org.apache.http.conn.HttpHostConnectException e) { mRetStatus = ResStatus.Error_HttpHostConnect; e.printStackTrace(); RequestException exception = new RequestException(RequestException.CONNECT_EXCEPTION, ""); if (LogUtil.IS_LOG) LogUtil.d(TAG, "AsyncHttpGet request to url :" + url + " HttpHostConnectException " + e.getMessage()); } catch (ClientProtocolException e) { mRetStatus = ResStatus.Error_Client_Protocol; e.printStackTrace(); RequestException exception = new RequestException(RequestException.CLIENT_PROTOL_EXCEPTION, "??"); e.printStackTrace(); if (LogUtil.IS_LOG) LogUtil.d(TAG, "AsyncHttpGet request to url :" + url + " ClientProtocolException " + e.getMessage()); } catch (IOException e) { mRetStatus = ResStatus.Error_IOException; e.printStackTrace(); RequestException exception = new RequestException(RequestException.IO_EXCEPTION, "??"); e.printStackTrace(); if (LogUtil.IS_LOG) LogUtil.d(TAG, "AsyncHttpGet request to url :" + url + " IOException " + e.getMessage()); } catch (Exception e) { mRetStatus = ResStatus.Error_IOException; e.printStackTrace(); } return false; }
From source file:org.simbrain.plot.histogram.HistogramPanel.java
/** * Create the histogram panel based on the data. *//*from ww w .ja v a 2 s . c om*/ public void createHistogram() { try { if (this.getModel().getData() != null) { mainChart = ChartFactory.createHistogram(title, xAxisName, yAxisName, model.getDataSet(), PlotOrientation.VERTICAL, true, true, false); mainChart.setBackgroundPaint(UIManager.getColor("this.Background")); XYPlot plot = (XYPlot) mainChart.getPlot(); plot.setForegroundAlpha(0.75F); // Sets y-axis ticks to integers. NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); renderer.setShadowVisible(false); Iterator<ColoredDataSeries> series = model.getSeriesData().iterator(); for (int i = 0; i < model.getData().size(); i++) { if (i < colorPallet.length) { ColoredDataSeries s = series.next(); Color c = s.color; if (c == null) { c = assignColor(); s.color = c; } renderer.setSeriesPaint(i, c, true); } } } else { mainChart = ChartFactory.createHistogram(title, xAxisName, yAxisName, model.getDataSet(), PlotOrientation.VERTICAL, true, true, false); mainChart.setBackgroundPaint(UIManager.getColor("this.Background")); } } catch (IllegalArgumentException iaEx) { iaEx.printStackTrace(); JOptionPane.showMessageDialog(null, iaEx.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } catch (IllegalStateException isEx) { isEx.printStackTrace(); JOptionPane.showMessageDialog(null, isEx.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } mainPanel = new ChartPanel(mainChart); }
From source file:org.cloudifysource.dsl.ApplicationValidationTest.java
/******* * Tests the validation of an application with an empty name using DSL * parsing of a groovy file./* w w w . j a v a2s . c o m*/ * <p> * Should throw <code>DSLValidationException</code>. */ @Test public void testNameNotExistGroovyFileValidation() { final File applicationFile = new File(APPLICATION_WITHOUT_NAME_GROOVY); try { ServiceReader.getApplicationFromFile(applicationFile).getApplication(); Assert.fail("Application name is missing, IllegalArgumentException expected."); } catch (final IllegalArgumentException e) { // OK - the invalid application name caused the exception } catch (final Exception e) { Assert.fail("Application name is missing, IllegalArgumentException expected, instead " + e.getClass() + " was thrown."); e.printStackTrace(); } }
From source file:org.bohrmeista.chan.ui.activity.BaseActivity.java
/** * Set the url that Android Beam and the share action will send. * * @param url// w w w .j a v a2 s . c om */ public void setShareUrl(String url) { shareUrl = url; NfcAdapter adapter = NfcAdapter.getDefaultAdapter(this); if (adapter != null) { NdefRecord record = null; try { record = NdefRecord.createUri(url); } catch (IllegalArgumentException e) { e.printStackTrace(); return; } NdefMessage message = new NdefMessage(new NdefRecord[] { record }); try { adapter.setNdefPushMessage(message, this); } catch (Exception e) { } } Intent share = new Intent(android.content.Intent.ACTION_SEND); share.putExtra(android.content.Intent.EXTRA_TEXT, url); share.setType("text/plain"); if (shareActionProvider != null) { shareActionProvider.setShareIntent(share); } else { pendingShareActionProviderIntent = share; } }
From source file:geogebra.common.kernel.statistics.AlgoChiSquaredTest.java
@Override public final void compute() { int df;// www . j a v a 2 s . c o m int rows = geoList1.size(); int columns = 0; if (!geoList1.isDefined() || rows < 2) { result.setUndefined(); return; } if (geoList2 != null) { if (!geoList2.isDefined() || geoList2.size() != rows) { result.setUndefined(); return; } } double[][] observed = null; double[][] expected = null; double[][] diff = null; // store observed and expected values in arrays // Three cases must be handled: // 1) <List of Observed, List of Expected> (the GOF test) // 2) <Matrix of Observed, Matrix of Expected> // 3) <Matrix of Observed>, here we compute the expected counts based on // the hypothesis of independence: // expected count = row sum * column sum / grand total) // if list1 is not a matrix, then we have the two list case if (!geoList1.isMatrix()) { if (geoList2 == null) { result.setUndefined(); return; } columns = 1; df = rows - 1; observed = new double[rows][columns]; expected = new double[rows][columns]; for (int i = 0; i < rows; i++) { GeoElement geo = geoList1.get(i); GeoElement geo2 = geoList2.get(i); if (geo instanceof NumberValue && geo2 instanceof NumberValue) { observed[i][0] = ((NumberValue) geo).getDouble(); expected[i][0] = ((NumberValue) geo2).getDouble(); } else { result.setUndefined(); return; } } } else { // list1 is matrix columns = ((GeoList) geoList1.get(0)).size(); observed = new double[rows][columns]; expected = new double[rows][columns]; df = (columns - 1) * (rows - 1); for (int i = 0; i < rows; i++) { for (int j = 0; j < columns; j++) { // get observed values GeoElement geo = ((GeoList) geoList1.get(i)).get(j); if (geo instanceof NumberValue) { observed[i][j] = ((NumberValue) geo).getDouble(); } else { result.setUndefined(); return; } // get expected values if list2 exists (it must be a matrix) if (geoList2 != null) { GeoElement geo2 = ((GeoList) geoList2.get(i)).get(j); if (geo2 instanceof NumberValue) { expected[i][j] = ((NumberValue) geo2).getDouble(); } else { result.setUndefined(); return; } } } } // compute expected values if list2 is not given if (geoList2 == null) { double[] columnSum = new double[columns]; for (int j = 0; j < columns; j++) { columnSum[j] = 0; } double[] rowSum = new double[rows]; for (int i = 0; i < rows; i++) { rowSum[i] = 0; } double total = 0; for (int i = 0; i < rows; i++) { for (int j = 0; j < columns; j++) { rowSum[i] += observed[i][j]; columnSum[j] += observed[i][j]; total += observed[i][j]; } } for (int i = 0; i < rows; i++) { for (int j = 0; j < columns; j++) { expected[i][j] = rowSum[i] * columnSum[j] / total; } } } } // compute test statistic and chi-square contributions diff = new double[rows][columns]; testStat = 0; for (int i = 0; i < rows; i++) { for (int j = 0; j < columns; j++) { diff[i][j] = (observed[i][j] - expected[i][j]) * (observed[i][j] - expected[i][j]) / expected[i][j]; testStat += diff[i][j]; } } try { double leftArea = getChiSquaredDistribution(df).cumulativeProbability(testStat); p = 1 - leftArea; } catch (IllegalArgumentException e) { result.setUndefined(); e.printStackTrace(); } catch (MathException e) { result.setUndefined(); e.printStackTrace(); } // put results into the output list result.clear(); result.add(new GeoNumeric(cons, p)); result.add(new GeoNumeric(cons, testStat)); }
From source file:com.code.android.vibevault.FeaturedShowsScreen.java
/** Bookkeeping method to deal with dialogs over orientation changes. * *//*from ww w. j a va 2 s . c o m*/ private void onTaskCompleted() { this.refreshSelectedShowsList(); if (dialogShown) { try { dismissDialog(VibeVault.RETRIEVING_DIALOG_ID); } catch (IllegalArgumentException e) { e.printStackTrace(); } dialogShown = false; } }
From source file:at.alladin.rmbt.controlServer.QualityOfServiceResultResource.java
@Post("json") public String request(final String entity) { final String secret = getContext().getParameters().getFirstValue("RMBT_SECRETKEY"); addAllowOrigin();/* w w w.ja v a 2s . c o m*/ JSONObject request = null; final ErrorList errorList = new ErrorList(); final JSONObject answer = new JSONObject(); System.out.println(MessageFormat.format(labels.getString("NEW_QOS_RESULT"), getIP())); if (entity != null && !entity.isEmpty()) // try parse the string to a JSON object try { request = new JSONObject(entity); final String lang = request.optString("client_language"); // Load Language Files for Client final List<String> langs = Arrays .asList(settings.getString("RMBT_SUPPORTED_LANGUAGES").split(",\\s*")); if (langs.contains(lang)) { errorList.setLanguage(lang); labels = ResourceManager.getSysMsgBundle(new Locale(lang)); } // System.out.println(request.toString(4)); if (conn != null) { ResultOptions resultOptions = new ResultOptions(new Locale(lang)); conn.setAutoCommit(false); final Test test = new Test(conn); if (request.optString("test_token").length() > 0) { final String[] token = request.getString("test_token").split("_"); try { // Check if UUID final UUID testUuid = UUID.fromString(token[0]); final String data = token[0] + "_" + token[1]; final String hmac = Helperfunctions.calculateHMAC(secret, data); if (hmac.length() == 0) errorList.addError("ERROR_TEST_TOKEN"); if (token[2].length() > 0 && hmac.equals(token[2])) { final List<String> clientNames = Arrays .asList(settings.getString("RMBT_CLIENT_NAME").split(",\\s*")); final List<String> clientVersions = Arrays .asList(settings.getString("RMBT_VERSION_NUMBER").split(",\\s*")); if (test.getTestByUuid(testUuid) > 0) if (clientNames.contains(request.optString("client_name")) && clientVersions.contains(request.optString("client_version"))) { //save qos test results: JSONArray qosResult = request.optJSONArray("qos_result"); if (qosResult != null) { QoSTestResultDao resultDao = new QoSTestResultDao(conn); Set<String> excludeTestTypeKeys = new TreeSet<>(); excludeTestTypeKeys.add("test_type"); excludeTestTypeKeys.add("qos_test_uid"); for (int i = 0; i < qosResult.length(); i++) { JSONObject testObject = qosResult.optJSONObject(i); //String hstore = Helperfunctions.json2hstore(testObject, excludeTestTypeKeys); JSONObject resultJson = new JSONObject(testObject, JSONObject.getNames(testObject)); for (String excludeKey : excludeTestTypeKeys) { resultJson.remove(excludeKey); } QoSTestResult testResult = new QoSTestResult(); //testResult.setResults(hstore); testResult.setResults(resultJson.toString()); testResult.setTestType(testObject.getString("test_type")); testResult.setTestUid(test.getUid()); long qosTestId = testObject.optLong("qos_test_uid", Long.MIN_VALUE); testResult.setQoSTestObjectiveId(qosTestId); resultDao.save(testResult); } } QoSTestResultDao resultDao = new QoSTestResultDao(conn); PreparedStatement updateCounterPs = resultDao .getUpdateCounterPreparedStatement(); List<QoSTestResult> testResultList = resultDao.getByTestUid(test.getUid()); //map that contains all test types and their result descriptions determined by the test result <-> test objectives comparison Map<TestType, TreeSet<ResultDesc>> resultKeys = new HashMap<>(); //test description set: Set<String> testDescSet = new TreeSet<>(); //test summary set: Set<String> testSummarySet = new TreeSet<>(); //iterate through all result entries for (QoSTestResult testResult : testResultList) { //reset test counters testResult.setFailureCounter(0); testResult.setSuccessCounter(0); //get the correct class of the result; TestType testType = TestType .valueOf(testResult.getTestType().toUpperCase()); Class<? extends AbstractResult<?>> clazz = testType.getClazz(); //parse hstore data final JSONObject resultJson = new JSONObject(testResult.getResults()); AbstractResult<?> result = QoSUtil.HSTORE_PARSER.fromJSON(resultJson, clazz); result.setResultJson(resultJson); if (result != null) { //add each test description key to the testDescSet (to fetch it later from the db) if (testResult.getTestDescription() != null) { testDescSet.add(testResult.getTestDescription()); } if (testResult.getTestSummary() != null) { testSummarySet.add(testResult.getTestSummary()); } testResult.setResult(result); } //compare test results with expected results QoSUtil.compareTestResults(testResult, result, resultKeys, testType, resultOptions); //resultList.put(testResult.toJson()); //update all test results after the success and failure counters have been set resultDao.updateCounter(testResult, updateCounterPs); //System.out.println("UPDATING: " + testResult.toString()); } } else errorList.addError("ERROR_CLIENT_VERSION"); } else errorList.addError("ERROR_TEST_TOKEN_MALFORMED"); } catch (final IllegalArgumentException e) { e.printStackTrace(); errorList.addError("ERROR_TEST_TOKEN_MALFORMED"); } catch (HstoreParseException e) { e.printStackTrace(); errorList.addError("ERROR_DB_CONNECTION"); } catch (IllegalAccessException e) { e.printStackTrace(); errorList.addError("ERROR_TEST_TOKEN_MALFORMED"); } } else errorList.addError("ERROR_TEST_TOKEN_MISSING"); conn.commit(); } else errorList.addError("ERROR_DB_CONNECTION"); } catch (final JSONException e) { errorList.addError("ERROR_REQUEST_JSON"); //System.out.println("Error parsing JSDON Data " + e.toString()); e.printStackTrace(); } catch (final SQLException e) { //System.out.println("Error while storing data " + e.toString()); e.printStackTrace(); } else errorList.addErrorString("Expected request is missing."); try { answer.putOpt("error", errorList.getList()); } catch (final JSONException e) { System.out.println("Error saving ErrorList: " + e.toString()); } return answer.toString(); }