Package com.jdroid.java.exception

Examples of com.jdroid.java.exception.UnexpectedException


   */
  public static <T> T newInstance(Class<T> clazz) {
    try {
      return clazz.newInstance();
    } catch (Exception e) {
      throw new UnexpectedException("Unable to instantiate class [" + clazz.getSimpleName() + "]", e);
    }
  }
View Full Code Here


      Collection<Object> parameterValues) {
    try {
      Constructor<T> constructor = clazz.getConstructor(parameterTypes.toArray(new Class[0]));
      return constructor.newInstance(parameterValues.toArray(new Object[0]));
    } catch (Exception e) {
      throw new UnexpectedException("Unable to instantiate class [" + clazz.getSimpleName() + "]", e);
    }
  }
View Full Code Here

    Field field = ReflectionUtils.getField(object.getClass(), expression);
    field.setAccessible(true);
    try {
      field.set(object, value);
    } catch (SecurityException e) {
      throw new UnexpectedException(e);
    } catch (IllegalArgumentException e) {
      throw new UnexpectedException(e);
    } catch (IllegalAccessException e) {
      throw new UnexpectedException(e);
    } finally {
      field.setAccessible(false);
    }
  }
View Full Code Here

  public static Object get(Field field, Object object) {
    field.setAccessible(true);
    try {
      return field.get(object);
    } catch (IllegalArgumentException e) {
      throw new UnexpectedException(e);
    } catch (IllegalAccessException e) {
      throw new UnexpectedException(e);
    }
  }
View Full Code Here

   */
  public static Field getField(Object object, String fieldName) {
    try {
      return object.getClass().getDeclaredField(fieldName);
    } catch (SecurityException e) {
      throw new UnexpectedException(e);
    } catch (NoSuchFieldException e) {
      throw new UnexpectedException(e);
    }
  }
View Full Code Here

      if (clazz.getSuperclass() != null) {
        return ReflectionUtils.getField(clazz.getSuperclass(), fieldName);
      }
      // If the field wasn't found and the object doesn't have a
      // superclass, an exception is thrown
      throw new UnexpectedException("The class '" + clazz.getName() + "' doesn't have a field named '"
          + fieldName + "'.");
    }
  }
View Full Code Here

  public static Class<?> getType(Object object, String fieldName) {
    try {
      Field field = object.getClass().getDeclaredField(fieldName);
      return field.getType();
    } catch (SecurityException e) {
      throw new UnexpectedException(e);
    } catch (NoSuchFieldException e) {
      throw new UnexpectedException(e);
    }
  }
View Full Code Here

      KeyGenerator kgen = KeyGenerator.getInstance(AES);
      kgen.init(128, random); // 192 and 256 bits may not be available
      SecretKey skey = kgen.generateKey();
      return skey.getEncoded();
    } catch (NoSuchAlgorithmException e) {
      throw new UnexpectedException(e);
    }
  }
View Full Code Here

      Cipher cipher = Cipher.getInstance(AES);
      SecretKeySpec skeySpec = new SecretKeySpec(raw, AES);
      cipher.init(opMode, skeySpec);
      return cipher.doFinal(input);
    } catch (NoSuchAlgorithmException e) {
      throw new UnexpectedException(e);
    } catch (NoSuchPaddingException e) {
      throw new UnexpectedException(e);
    } catch (InvalidKeyException e) {
      throw new UnexpectedException(e);
    } catch (IllegalBlockSizeException e) {
      throw new UnexpectedException(e);
    } catch (BadPaddingException e) {
      throw new UnexpectedException(e);
    }
  }
View Full Code Here

        Properties properties = new Properties();
        inputStream = url.openStream();
        properties.load(inputStream);
        propertiesList.add(properties);
      } catch (IOException e) {
        throw new UnexpectedException("Cannot read from resource: " + resourceName, e);
      } finally {
        FileUtils.safeClose(inputStream);
      }
    }
  }
View Full Code Here

TOP

Related Classes of com.jdroid.java.exception.UnexpectedException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.