List of usage examples for java.lang IllegalArgumentException printStackTrace
public void printStackTrace()
From source file:com.test.xujixiao.xjx.widget.view.BaseZoomableImageView.java
protected boolean isScrollOver(float distanceX) { try {//from w w w. j ava 2s. c o m if (mDisplayMatrix != null) { float m_x = getValue(mDisplayMatrix, Matrix.MTRANS_X); //? float width = getWidth() - m_x; //width ?+? //mBitmap.getWidth() * getValue(mDisplayMatrix, Matrix.MSCALE_X) ? //width == mBitmap.getWidth() * getValue(mDisplayMatrix, Matrix.MSCALE_X) ???? == 0?? if ((m_x == 0 && distanceX <= 0) // || (width == mBitmap.getWidth() //?? * getValue(mDisplayMatrix, Matrix.MSCALE_X) && distanceX >= 0)) { System.out.println("ScrollOver"); return true; } } } catch (IllegalArgumentException e) { Log.v("Vincent", "isScrollOver"); e.printStackTrace(); } return false; }
From source file:com.c4fcm.actionpath.MainActivity.java
/** * Called when the user clicks the "Remove geofence 1" button * @param view The view that triggered this callback *//*from w ww .j a v a 2 s . c o m*/ public void onUnregisterGeofence1Clicked(View view) { /* * Remove the geofence by creating a List of geofences to * remove and sending it to Location Services. The List * contains the id of geofence 1 ("1"). * The removal happens asynchronously; Location Services calls * onRemoveGeofencesByPendingIntentResult() (implemented in * the current Activity) when the removal is done. */ // Create a List of 1 Geofence with the ID "1" and store it in the global list mGeofenceIdsToRemove = Collections.singletonList("1"); /* * Record the removal as remove by list. If a connection error occurs, * the app can automatically restart the removal if Google Play services * can fix the error */ mRemoveType = GeofenceUtils.REMOVE_TYPE.LIST; /* * Check for Google Play services. Do this after * setting the request type. If connecting to Google Play services * fails, onActivityResult is eventually called, and it needs to * know what type of request was in progress. */ if (!servicesConnected()) { return; } // Try to remove the geofence try { mGeofenceRemover.removeGeofencesById(mGeofenceIdsToRemove); // Catch errors with the provided geofence IDs } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (UnsupportedOperationException e) { // Notify user that previous request hasn't finished. Toast.makeText(this, R.string.remove_geofences_already_requested_error, Toast.LENGTH_LONG).show(); } }
From source file:com.netsteadfast.greenstep.base.action.BaseSupportAction.java
@Deprecated protected void checkFields(String[] fieldsName, String[] msg, Class<IActionFieldsCheckUtils>[] checkUtilsClass, String[] methodsName, List<String> fieldsId) throws ControllerException, InstantiationException, IllegalAccessException { if (fieldsName == null || msg == null || checkUtilsClass == null || (fieldsName.length != msg.length) || (fieldsName.length != checkUtilsClass.length)) { throw new java.lang.IllegalArgumentException("check filed args error!"); }/*from w w w.j a va 2 s.co m*/ StringBuilder exceptionMsg = new StringBuilder(); for (int i = 0; i < fieldsName.length; i++) { String value = this.getFields().get(fieldsName[i]); IActionFieldsCheckUtils checkUtils = checkUtilsClass[i].newInstance(); if (methodsName != null && methodsName.length == checkUtilsClass.length) { Method methods[] = checkUtils.getClass().getMethods(); for (Method method : methods) { if (method.getName().equals(methodsName[i])) { try { if (!(Boolean) method.invoke(null, value)) { if (fieldsId != null) { fieldsId.add(fieldsName[i]); } exceptionMsg.append(msg[i]); } } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } } } } else { if (!checkUtils.check(value)) { if (fieldsId != null) { fieldsId.add(fieldsName[i]); } exceptionMsg.append(msg[i]); } } } if (exceptionMsg.length() > 0) { throw new ControllerException(exceptionMsg.toString()); } }
From source file:com.mhise.util.MHISEUtil.java
public static boolean saveImportedCertificateToDevice(String certificate, String password, Context ctx, String certName) {//from www .ja v a 2 s . co m boolean isPasswordCorrect = false; byte[] certificatebytes = null; try { certificatebytes = Base64.decode(certificate, Base64.DEFAULT); } catch (IllegalArgumentException e) { // TODO: handle exception Logger.debug("MHISEUtil-->saveImportedCertificateToDevice", "" + e); } KeyStore localTrustStore = null; try { localTrustStore = KeyStore.getInstance("PKCS12"); } catch (KeyStoreException e) { // TODO Auto-generated catch block e.printStackTrace(); } InputStream is = new ByteArrayInputStream(certificatebytes); try { localTrustStore.load(is, password.toCharArray()); isPasswordCorrect = true; } catch (NoSuchAlgorithmException e) { // TODO Auto-generated catch block e.printStackTrace(); return false; } catch (CertificateException e) { // TODO Auto-generated catch block e.printStackTrace(); return false; } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); return false; } OutputStream fos = null; try { //<<<<<<< .mine //SharedPreferences sharedPreferences = ctx.getSharedPreferences(Constants.PREFS_NAME,Context.MODE_PRIVATE); //String storeName =sharedPreferences.getString(Constants.KEY_CERT_NAME, null); File _mobiusDirectory = new File(Constants.defaultP12StorePath); if (!_mobiusDirectory.exists()) { _mobiusDirectory.mkdir(); } File file = new File(Constants.defaultP12StorePath + certName); fos = new FileOutputStream(file); //fos = ctx.openFileOutput(Constants.defaultP12StoreName, Context.MODE_PRIVATE); localTrustStore.store(fos, MHISEUtil.getStrongPassword(certName).toCharArray()); /*//======= //SharedPreferences sharedPreferences = ctx.getSharedPreferences(Constants.PREFS_NAME,Context.MODE_PRIVATE); //String storeName =sharedPreferences.getString(Constants.KEY_CERT_NAME, null); File file = new File(Constants.defaultP12StorePath+certName); fos = new FileOutputStream(file); //fos = ctx.openFileOutput(Constants.defaultP12StoreName, Context.MODE_PRIVATE); localTrustStore.store(fos,MHISEUtil.getStrongPassword(certName).toCharArray()); >>>>>>> .r4477*/ fos.close(); Enumeration<String> aliases = null; try { aliases = localTrustStore.aliases(); } catch (KeyStoreException e) { // TODO Auto-generated catch block e.printStackTrace(); } //boolean isInstalledCertificateValid = false; while (aliases.hasMoreElements()) { String alias = aliases.nextElement(); java.security.cert.X509Certificate cert = null; try { cert = (X509Certificate) localTrustStore.getCertificate(alias); } catch (KeyStoreException e) { // TODO Auto-generated catch block e.printStackTrace(); } SharedPreferences sharedPreferences1 = ctx.getSharedPreferences(Constants.PREFS_NAME, Context.MODE_PRIVATE); SharedPreferences.Editor editor = sharedPreferences1.edit(); Log.i("Imported certificate serial number", "" + cert.getSerialNumber().toString(16)); editor.putString(Constants.KEY_SERIAL_NUMBER, "" + cert.getSerialNumber().toString(16)); editor.commit(); } } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (KeyStoreException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (NoSuchAlgorithmException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (CertificateException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return isPasswordCorrect; }
From source file:io.github.jeremgamer.maintenance.Maintenance.java
public void backupProcess(CommandSender sender) { Calendar cal = Calendar.getInstance(); DateFormat dateFormat = new SimpleDateFormat("yyyy MM dd - HH mm ss"); String zipFile = new File("").getAbsolutePath() + "/backups/" + dateFormat.format(cal.getTime()) + ".zip"; File zip = new File(zipFile); String srcDir = new File("").getAbsolutePath(); try {/* w w w. jav a2 s.c o m*/ try { zip.createNewFile(); } catch (IOException e) { e.printStackTrace(); } File dir = new File(srcDir); List<File> filesList = (List<File>) FileUtils.listFilesAndDirs(dir, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE); File[] files = filesList.toArray(new File[filesList.size()]); OutputStream out = new FileOutputStream(zip); ArchiveOutputStream zipOutput = new ZipArchiveOutputStream(out); String filePath; for (int i = 0; i < files.length; i++) { if (files[i].isDirectory()) { } else if (files[i].getAbsolutePath().contains(new File("").getAbsolutePath() + "\\backups\\")) { } else { filePath = files[i].getAbsolutePath().substring(srcDir.length() + 1); try { ZipArchiveEntry entry = new ZipArchiveEntry(filePath); entry.setSize(new File(files[i].getAbsolutePath()).length()); zipOutput.putArchiveEntry(entry); IOUtils.copy(new FileInputStream(files[i].getAbsolutePath()), zipOutput); zipOutput.closeArchiveEntry(); } catch (IOException e) { e.printStackTrace(); } } } zipOutput.finish(); zipOutput.close(); out.close(); } catch (IOException ioe) { ioe.printStackTrace(); } catch (IllegalArgumentException iae) { iae.printStackTrace(); } sender.sendMessage(getConfig().getString("backupSuccess").replaceAll("&", "")); getLogger().info("Backup success!"); }
From source file:bammerbom.ultimatecore.bukkit.resources.utils.BossbarUtil.java
public Object getSpawnPacket() { Class<?> Entity = Util.getCraftClass("Entity"); Class<?> EntityLiving = Util.getCraftClass("EntityLiving"); Class<?> EntityEnderDragon = Util.getCraftClass("EntityEnderDragon"); Object packet = null;//from w ww. ja va2s . c om try { this.dragon = EntityEnderDragon.getConstructor(new Class[] { Util.getCraftClass("World") }) .newInstance(new Object[] { getWorld() }); Method setLocation = Util.getMethod(EntityEnderDragon, "setLocation", new Class[] { Double.TYPE, Double.TYPE, Double.TYPE, Float.TYPE, Float.TYPE }); setLocation.invoke(this.dragon, new Object[] { Integer.valueOf(getX()), Integer.valueOf(getY()), Integer.valueOf(getZ()), Integer.valueOf(getPitch()), Integer.valueOf(getYaw()) }); Method setInvisible = Util.getMethod(EntityEnderDragon, "setInvisible", new Class[] { Boolean.TYPE }); setInvisible.invoke(this.dragon, new Object[] { Boolean.valueOf(isVisible()) }); Method setCustomName = Util.getMethod(EntityEnderDragon, "setCustomName", new Class[] { String.class }); setCustomName.invoke(this.dragon, new Object[] { this.name }); Method setHealth = Util.getMethod(EntityEnderDragon, "setHealth", new Class[] { Float.TYPE }); setHealth.invoke(this.dragon, new Object[] { Float.valueOf(this.health) }); Field motX = Util.getField(Entity, "motX"); motX.set(this.dragon, Byte.valueOf(getXvel())); Field motY = Util.getField(Entity, "motY"); motY.set(this.dragon, Byte.valueOf(getYvel())); Field motZ = Util.getField(Entity, "motZ"); motZ.set(this.dragon, Byte.valueOf(getZvel())); Method getId = Util.getMethod(EntityEnderDragon, "getId", new Class[0]); this.id = ((Number) getId.invoke(this.dragon, new Object[0])).intValue(); Class<?> PacketPlayOutSpawnEntityLiving = Util.getCraftClass("PacketPlayOutSpawnEntityLiving"); packet = PacketPlayOutSpawnEntityLiving.getConstructor(new Class[] { EntityLiving }) .newInstance(new Object[] { this.dragon }); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (SecurityException e) { e.printStackTrace(); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); } return packet; }
From source file:net.cloudpath.xpressconnect.screens.GetCredentials.java
public int isConnectionFound() { List localList = ((WifiManager) getSystemService("wifi")).getConfiguredNetworks(); if (localList == null) { Util.log(this.mLogger, "No networks in the network list. (So the network isn't found.)"); return -1; }/* w w w . jav a 2 s . c o m*/ if (this.mParser == null) { Util.log(this.mLogger, "Parser isn't bound in isConnectionFound()!"); return -2; } if (this.mParser.selectedProfile == null) { Util.log(this.mLogger, "No profile is selected in isConnectionFound()!"); return -2; } if (this.mFailure == null) { Util.log(this.mLogger, "Failure class is null in isConnectionFound()!"); return -2; } Util.log(this.mLogger, "Your device currently has " + localList.size() + " wireless network(s) configured."); int i = 0; if (i < localList.size()) { WifiConfigurationProxy localWifiConfigurationProxy; SettingElement localSettingElement; try { localWifiConfigurationProxy = new WifiConfigurationProxy((WifiConfiguration) localList.get(i), this.mLogger); localSettingElement = this.mParser.selectedProfile.getSetting(1, 40001); if (localSettingElement == null) { Util.log(this.mLogger, "Unable to locate the SSID element!"); this.mFailure.setFailReason(FailureReason.useErrorIcon, getResources() .getString(this.mParcelHelper.getIdentifier("xpc_no_ssid_defined", "string")), 6); return -2; } } catch (IllegalArgumentException localIllegalArgumentException) { Util.log(this.mLogger, "IllegalArgumentException in isConnectionFound()!"); localIllegalArgumentException.printStackTrace(); return -2; } catch (NoSuchFieldException localNoSuchFieldException) { Util.log(this.mLogger, "NoSuchFieldException in isConnectionFound()!"); localNoSuchFieldException.printStackTrace(); return -2; } catch (ClassNotFoundException localClassNotFoundException) { Util.log(this.mLogger, "ClassNotFoundException in isConnectionFound()!"); localClassNotFoundException.printStackTrace(); return -2; } catch (IllegalAccessException localIllegalAccessException) { Util.log(this.mLogger, "IllegalAccessException in isConnectionFound()!"); localIllegalAccessException.printStackTrace(); return -2; } String[] arrayOfString; if (localSettingElement.additionalValue != null) { arrayOfString = localSettingElement.additionalValue.split(":"); if (arrayOfString.length != 3) { Util.log(this.mLogger, "The SSID element provided in the configuration file is invalid!"); this.mFailure.setFailReason(FailureReason.useErrorIcon, getResources() .getString(this.mParcelHelper.getIdentifier("xpc_ssid_element_invalid", "string")), 6); return -2; } if (this.mParser.savedConfigInfo != null) this.mParser.savedConfigInfo.ssid = arrayOfString[2]; if (localWifiConfigurationProxy.getSsid() != null) break label429; Util.log(this.mLogger, "SSID was null parsing network string."); } label429: while (!localWifiConfigurationProxy.getSsid().equals("\"" + arrayOfString[2] + "\"")) { i++; break; } Util.log(this.mLogger, "Our SSID already exists. It will be replaced."); return localWifiConfigurationProxy.getNetworkId(); } return -1; }
From source file:de.bund.bfr.fskml.MetadataDocument.java
private void addDependentVariable(final Model model, final Variable v) { if (StringUtils.isEmpty(v.name)) return;/* w ww .j ava 2 s .c om*/ Parameter param = model.createParameter(PMFUtil.createId(v.name)); param.setName(v.name); // Write unit if v.unit is not null if (StringUtils.isNotEmpty(v.unit)) { try { param.setUnits(PMFUtil.createId(v.unit)); } catch (IllegalArgumentException e) { e.printStackTrace(); } } // Write min and max values if not null if (StringUtils.isNoneEmpty(v.min, v.max)) { try { double min = Double.parseDouble(v.min); double max = Double.parseDouble(v.max); LimitsConstraint lc = new LimitsConstraint(v.name.replaceAll("\\.", "\\_"), min, max); if (lc.getConstraint() != null) { model.addConstraint(lc.getConstraint()); } } catch (NumberFormatException e) { e.printStackTrace(); } } }
From source file:com.hihsoft.baseclass.web.controller.BaseController.java
/** * ???(xiaojf?)//w w w.j av a2 s .c o m */ @Override protected void bind(final HttpServletRequest request, final Object command) { final PropertyDescriptor[] pds = BeanUtils.getPropertyDescriptors(command.getClass()); for (final PropertyDescriptor pd : pds) { final Class<?> clas = pd.getPropertyType();// ?class final boolean isSimpleProperty = BeanUtils.isSimpleProperty(clas); final boolean isInterface = clas.isInterface(); final boolean hasConstruct = clas.getConstructors().length == 0 ? false : true; if (!isSimpleProperty && !isInterface && hasConstruct) { // try { pd.getWriteMethod().invoke(command, clas.newInstance()); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InvocationTargetException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InstantiationException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } try { super.bind(request, command); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:clus.statistic.CombStat.java
/** * Returns a number of attributes with significantly different distributions */// ww w.j a v a 2 s . c om public int signDifferent() { int sign_diff = 0; // Nominal attributes for (int i = 0; i < m_ClassStat.getNbAttributes(); i++) { if (SignDifferentNom(i)) { sign_diff++; } } // Numeric attributes for (int i = 0; i < m_RegStat.getNbAttributes(); i++) { try { if (SignDifferentNum(i)) { sign_diff++; } } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (MathException e) { e.printStackTrace(); } } System.out.println("Nb.sig.atts: " + sign_diff); return sign_diff; }