Package com.im.imjutil.exception

Examples of com.im.imjutil.exception.ValidationException


   * @param hexadecimal A string de bytes representados em hexadecimal.
   * @return O byte array resultante.
   */
  public static byte[] toHexabytes(String hexadecimal) {
    if (!Validator.isValid(hexadecimal)) {
      throw new ValidationException("String hexadecimal nulo ou vazio");
    }
    byte[] bytes = new byte[hexadecimal.length() / 2];
    for (int i = 0; i < bytes.length; ++i) {
      bytes[i] = (byte) Integer.parseInt(
          hexadecimal.substring(2*i, 2*i+2), 16);
View Full Code Here


   * @param base64 A string de bytes codificados em base64.
   * @return O byte array resultante.
   */
  public static String toBase64(byte[] bytes) {
    if (bytes == null || bytes.length == 0) {
      throw new ValidationException("Byte array nulo ou vazio");
    }
    return Base64Coder.encrypt(bytes);
  }
View Full Code Here

   * @param in O stream a ser convertido.
   * @return O array de bytes resultante.
   */
  public static byte[] toBytes(InputStream in) {
    if (in == null) {
      throw new ValidationException("O stream passado e nulo");
    }
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    try {
      InputStream is = new BufferedInputStream(in);
      byte[] buffer = new byte[4096];
View Full Code Here

   * @param file O arquivo a ser convertido.
   * @return O array de bytes resultante.
   */
  public static byte[] toBytes(File file) {
    if (file == null) {
      throw new ValidationException("O arquivo passado e nulo");
    }
    if (!file.exists()) {
      throw new ValidationException("O arquivo passado nao existe");
    }
    byte[] bytes;
    try {
      bytes = toBytes(new FileInputStream(file));
     
View Full Code Here

   * @param filename Nome do arquivo
   * @return O arquivo resultante
   */
  public static File toFile(byte[] bytes, String filename) {
    if (bytes == null || bytes.length == 0) {
      throw new ValidationException("Byte array nulo ou vazio");
    }
    try {
      File f = new File(filename);
      OutputStream os = new BufferedOutputStream(new FileOutputStream(f));
      os.write(bytes);
View Full Code Here

   * @param bytes O byte array a ser escrito no arquivo.
   * @return O arquivo resultante.
   */
  public static File toFile(byte[] bytes) {
    if (bytes == null || bytes.length == 0) {
      throw new ValidationException("Byte array nulo ou vazio");
    }
    try {
      File f = File.createTempFile("TempFile-", ".bin");
      OutputStream os = new BufferedOutputStream(new FileOutputStream(f));
      os.write(bytes);
View Full Code Here

  @Override
  public void setExpirationDate(Date date) {
    validateParam(date);
    Date current = new Date();
    if (current.after(date)) {
      throw new ValidationException(Convert.toString("Data invalida [",
          Format.toTimestamp(date), "] anterior a data corrente [",
          Format.toTimestamp(current), "]"));
    }
    this.expiration = date;
  }
View Full Code Here

   * @throws ValidationException A excessao lancada.
   */
  protected static void validateParam(Object obj)
      throws ValidationException {
    if (!Validator.isValid(obj)) {
      throw new ValidationException(
          "Parametro passado e nulo ou vazio");
    }
  }
View Full Code Here

   * @param runnable Objeto {@link Runnable} a ser executado.
   * @throws ValidationException Caso o objeto passado for {@code nulo}.
   */
  public Runner(Runnable runnable) {
    if (runnable == null) {
      throw new ValidationException("Runnable nao definido");
    }
    this.runnable = runnable;
    this.continuous = false;
    this.running = false;
    this.sleep = 0;
View Full Code Here

    if (!active) {
      throw new TransactionException(
          "Nao e possivel adicionar acoes em uma transacao inativa");
    }
    if (action == null) {
      throw new ValidationException("O parametro action e nulo");
    }
    actions.add(action);
  }
View Full Code Here

TOP

Related Classes of com.im.imjutil.exception.ValidationException

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.