All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.zeroturnaround.zip.ZTZipReflectionUtil Maven / Gradle / Ivy

Go to download

The project is intended to have a small, easy and fast library to process ZIP archives. Either create, modify or explode them. On disk or in memory.

There is a newer version: 1.17
Show newest version
package org.zeroturnaround.zip;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

class ZTZipReflectionUtil {

  private ZTZipReflectionUtil() {
  }

  static  Class getClassForName(String name, Class clazz) {
    try {
      return Class.forName(name).asSubclass(clazz);
    }
    catch (ClassNotFoundException e) {
      throw new ZipException(e);
    }
    catch (ClassCastException e) {
      throw new ZipException(e);
    }
  }

  static Method getDeclaredMethod(Class clazz, String methodName, Class... parameterTypes) {
    try {
      return clazz.getDeclaredMethod(methodName, parameterTypes);
    }
    catch (NoSuchMethodException e) {
      throw new ZipException(e);
    }
  }

  static Object invoke(Method method, Object obj, Object... args) throws ZipException {
    try {
      return method.invoke(obj, args);
    }
    catch (IllegalAccessException e) {
      throw new ZipException(e);
    }
    catch (InvocationTargetException e) {
      throw new ZipException(e);
    }
    catch (IllegalArgumentException e) {
      throw new ZipException(e);
    }
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy