Example usage for java.lang IllegalAccessException printStackTrace

List of usage examples for java.lang IllegalAccessException printStackTrace

Introduction

In this page you can find the example usage for java.lang IllegalAccessException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:me.anon.lib.Views.java

/**
 * Resets all @InjectView annotated members to null.
 * Use this in the `onDestroyView()` of your fragment
 * @param target The target class/*w ww  . j a  v  a 2s. c  o m*/
 */
public static void reset(Object target) {
    ArrayList<Field> fields = new ArrayList<Field>();
    Class objOrSuper = target.getClass();

    if (!objOrSuper.isAnnotationPresent(Injectable.class)) {
        Log.e("InjectView", "No Injectable annotation for class " + objOrSuper);
        return;
    }

    while (objOrSuper.isAnnotationPresent(Injectable.class)) {
        for (Field field : objOrSuper.getDeclaredFields()) {
            if (field.isAnnotationPresent(InjectView.class)
                    || field.isAnnotationPresent(InjectFragment.class)) {
                fields.add(field);
            }
        }

        objOrSuper = objOrSuper.getSuperclass();
    }

    for (Field field : fields) {
        Annotation annotation = field.getAnnotation(InjectView.class);

        if (annotation == null) {
            annotation = field.getAnnotation(InjectFragment.class);
        }

        if (annotation != null) {
            try {
                field.setAccessible(true);
                field.set(target, null);
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
        }
    }
}

From source file:org.rti.zcore.dar.utils.TestPatientUtils.java

/**
 * Used for testing the app - creating test patients.
 * Takes either the id field of the form or the form's classname.
 * @param modCfg// w w  w  .  jav  a2s. c  om
 * @param formId
 * @return
 */
public static DynaActionForm createDynaForm(ModuleConfig modCfg, String formId) {
    String formName = null;
    try {
        Long formIdLong = Long.valueOf(formId);
        formName = DynaSiteObjects.getFormIdClassNameMap().get(formIdLong);
    } catch (NumberFormatException e1) {
        formName = DynaSiteObjects.getFormIdClassNameMap().get(formId);
    }
    //FormBeanConfig formCfg = modCfg.findFormBeanConfig("form" + formId);
    FormBeanConfig formCfg = modCfg.findFormBeanConfig(formName);
    DynaActionFormClass dynaClass = DynaActionFormClass.createDynaActionFormClass(formCfg);
    DynaActionForm dynaForm = null;
    try {
        dynaForm = (DynaActionForm) dynaClass.newInstance();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    } catch (InstantiationException e) {
        e.printStackTrace();
    }
    dynaForm.set("date_visit", DateUtils.getNow().toString());
    return dynaForm;
}

From source file:org.rti.zcore.dar.utils.TestPatientUtils.java

/**
 * Creates PatientRegistration DynaActionForm object for creating test patients.
 * @param conn TODO/*from   w w w.  j  ava  2 s .  c o  m*/
 * @param modCfg
 * @param firstName
 * @param siteId
 * @return
 */
public static DynaActionForm createPatient(Connection conn, ModuleConfig modCfg, String firstName,
        Long siteId) {
    FormBeanConfig formBeanConfig = modCfg.findFormBeanConfig("PatientRegistration");
    DynaActionForm dynaForm = null;
    DynaActionFormClass dynaClass = DynaActionFormClass.createDynaActionFormClass(formBeanConfig);
    try {
        dynaForm = (DynaActionForm) dynaClass.newInstance();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    } catch (InstantiationException e) {
        e.printStackTrace();
    }

    // create random number
    Random generator = new Random();

    int first = generator.nextInt(100000);
    int sur = generator.nextInt(10000);
    int addNum = generator.nextInt(10000);
    int age = generator.nextInt(40) + 13;
    String birthDate = DateUtils.generateBirthdate(age).toString();
    String countryIdDate = birthDate.replace("-", "").substring(2);
    String countryId = countryIdDate + "-" + "1" + "111" + "-" + "0" + "8" + "0";
    PatientRegistration registration = new PatientRegistration();
    registration.setSurname("Patient" + sur);
    if (firstName != null) {
        registration.setForenames(firstName + first);
    } else {
        registration.setForenames("Test" + first);
    }
    registration.setCountry_id_number(countryId);
    registration.setAge_at_first_attendence(Integer.valueOf(String.valueOf(age)));
    //registration.setField19(addNum + " Park Place");
    registration.setBirth_date(java.sql.Date.valueOf(birthDate));
    registration.setSex(Integer.valueOf(1));
    registration.setAddress_1(age + " Maple street");
    // create the zeprsId
    Publisher publisher = null;
    Integer siteInstanceId = 0;
    try {
        publisher = PubSubUtils.getPublisher();
    } catch (FileNotFoundException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    } catch (IOException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
    if (publisher != null) {
        siteInstanceId = publisher.getSiteInstanceId();
    }

    String districtId = "1000";

    Site site = (Site) DynaSiteObjects.getClinicMap().get(siteId);
    String zepSiteId = site.getSiteAlphaId();
    String zePatientId = PatientId.setPatientId(conn, districtId, zepSiteId + siteInstanceId);
    String zeprsId = PatientRecordUtils.createZeprsId(districtId, zepSiteId + siteInstanceId, zePatientId);
    registration.setPatient_id_number(zeprsId);
    //registration.setField13("5040");
    //registration.setField1511(site.getSiteAlphaId().substring(0, 3));

    Map regMap = new HashMap();

    try {
        regMap = BeanUtils.describe(registration);
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    } catch (InvocationTargetException e) {
        e.printStackTrace();
    } catch (NoSuchMethodException e) {
        e.printStackTrace();
    }

    Set dynaSet = dynaForm.getMap().entrySet();
    for (Iterator iterator = dynaSet.iterator(); iterator.hasNext();) {
        Map.Entry entry = (Map.Entry) iterator.next();
        String key = (String) entry.getKey();
        dynaForm.set(key, regMap.get(key));
    }

    dynaForm.set("date_visit", DateUtils.getNow().toString());
    return dynaForm;
}

From source file:org.java.plugin.boot.Boot.java

private static BootErrorHandler getErrorHandlerInstance(final String handler, final boolean isServiceApp) {
    if (handler != null) {
        try {//  w w  w .j  a  va 2  s  .c o  m
            return (BootErrorHandler) Class.forName(handler).newInstance();
        } catch (InstantiationException ie) {
            System.err.println("failed instantiating error handler " //$NON-NLS-1$
                    + handler);
            ie.printStackTrace();
        } catch (IllegalAccessException iae) {
            System.err.println("failed instantiating error handler " //$NON-NLS-1$
                    + handler);
            iae.printStackTrace();
        } catch (ClassNotFoundException cnfe) {
            System.err.println("failed instantiating error handler " //$NON-NLS-1$
                    + handler);
            cnfe.printStackTrace();
        }
    }
    return isServiceApp ? new BootErrorHandlerConsole() : (BootErrorHandler) new BootErrorHandlerGui();
}

From source file:org.rti.zcore.dar.utils.TestPatientUtils.java

/**
 *
 * @param conn//from   ww  w.j a v  a2s .com
 * @param firstName
 * @param siteId
 * @param child
 * @return
 */
public static Map createPatient(Connection conn, String firstName, Long siteId, boolean child) {

    Publisher publisher;
    Integer siteInstanceId = 0;
    try {
        publisher = PubSubUtils.getPublisher();
        siteInstanceId = publisher.getSiteInstanceId();
    } catch (IOException e1) {
        log.debug(e1);
    }
    // create random number
    Random generator = new Random();

    int first = generator.nextInt(100000);
    int sur = generator.nextInt(10000);
    int addNum = generator.nextInt(10000);
    int age = 0;
    String childAgeStr = Constants.CHILD_AGE;
    Integer childAge = 14;
    if (childAgeStr != null) {
        childAge = Integer.valueOf(childAgeStr);
    }
    if (child) {
        age = generator.nextInt(childAge);
    } else {
        age = generator.nextInt(40) + 15;
    }
    String birthDate = DateUtils.generateBirthdate(age).toString();
    String countryIdDate = birthDate.replace("-", "").substring(2);
    String countryId = countryIdDate + "-" + "1" + "111" + "-" + "0" + "8" + "0";
    PatientRegistration registration = new PatientRegistration();
    registration.setSurname("Patient" + sur + "-" + siteInstanceId);
    if (firstName != null) {
        if (child) {
            registration.setForenames("Child" + first);
        } else {
            registration.setForenames(firstName + first);
        }
    } else {
        registration.setForenames("Test" + first);
    }
    registration.setCountry_id_number(countryId);
    registration.setAge_at_first_attendence(age);
    if (childAgeStr != null) {
        if (age > childAge) {
            registration.setAge_category(3283);
        } else {
            registration.setAge_category(3284);
        }
    }
    //registration.setField19(addNum + " Park Place");
    registration.setBirth_date(java.sql.Date.valueOf(birthDate));
    registration.setSex(Integer.valueOf(1));
    registration.setAddress_1(age + " Maple street");
    // create the zeprsId
    String districtId = "1000";

    Site site = (Site) DynaSiteObjects.getClinicMap().get(siteId);
    String zepSiteId = site.getSiteAlphaId();
    String zePatientId = PatientId.setPatientId(conn, districtId, zepSiteId + siteInstanceId);
    String zeprsId = PatientRecordUtils.createZeprsId(districtId, zepSiteId + siteInstanceId, zePatientId);
    registration.setPatient_id_number(zeprsId);
    registration.setDateVisit(DateUtils.getNow());
    //registration.setField13("5040");
    //registration.setField1511(site.getSiteAlphaId().substring(0, 3));

    Map regMap = new HashMap();

    try {
        regMap = BeanUtils.describe(registration);
        //BeanUtils.copyProperties(regMap, registration);
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    } catch (InvocationTargetException e) {
        e.printStackTrace();
    } catch (NoSuchMethodException e) {
        e.printStackTrace();
    }

    Map formData = new HashMap();

    Form form = (Form) DynaSiteObjects.getForms().get(new Long("1"));
    Set<PageItem> pageItems = form.getPageItems();
    for (PageItem pageItem : pageItems) {
        if (pageItem.getForm_field().isEnabled()) {
            String key = pageItem.getForm_field().getIdentifier();
            formData.put(key, regMap.get(key));
        }
    }
    formData.put("date_visit", DateUtils.getNow());

    /*Set dynaSet = dynaForm.getMap().entrySet();
    for (Iterator iterator = dynaSet.iterator(); iterator.hasNext();) {
       Map.Entry entry = (Map.Entry) iterator.next();
       String key = (String) entry.getKey();
       dynaForm.set(key, regMap.get(key));
    }
            
    dynaForm.set("date_visit", DateUtils.getNow().toString());*/
    return formData;
}

From source file:org.java.plugin.boot.Boot.java

private static Application initApplication(final BootErrorHandler errorHandler, final ExtendedProperties props,
        final String[] args) throws Exception {
    ApplicationInitializer appInitializer = null;
    String className = props.getProperty(PARAM_APP_INITIALIZER);
    if (className != null) {
        try {/*from w  ww .  j a v  a2  s  . c  o  m*/
            appInitializer = (ApplicationInitializer) Class.forName(className).newInstance();
        } catch (InstantiationException ie) {
            System.err.println("failed instantiating application initializer " //$NON-NLS-1$
                    + className);
            ie.printStackTrace();
        } catch (IllegalAccessException iae) {
            System.err.println("failed instantiating application initializer " //$NON-NLS-1$
                    + className);
            iae.printStackTrace();
        } catch (ClassNotFoundException cnfe) {
            System.err.println("failed instantiating application initializer " //$NON-NLS-1$
                    + className);
            cnfe.printStackTrace();
        }
    }
    if (appInitializer == null) {
        appInitializer = new DefaultApplicationInitializer();
    }
    appInitializer.configure(props);
    Application result = appInitializer.initApplication(errorHandler, args);
    if (result == null) {
        throw new Exception(ResourceManager.getMessage(Boot.PACKAGE_NAME, "bootAppInitFailed")); //$NON-NLS-1$
    }
    return result;
}

From source file:com.helpinput.utils.Utils.java

@SuppressWarnings("unchecked")
public static <T> T InvokedMethod(Object target, Method method, Object... agrs) {
    if (method != null)
        try {/*from   w  ww  . j a v  a2s. c om*/
            return (T) method.invoke(target, agrs);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
    return null;
}

From source file:edu.umass.cs.reconfiguration.AbstractReconfiguratorDB.java

protected static Object autoInvokeMethod(Object target, BasicReconfigurationPacket<?> rcPacket,
        boolean recovery, Stringifiable<?> unstringer) {
    try {//  w w  w . j  a  v  a  2 s. co  m
        return target.getClass()
                .getMethod(
                        ReconfigurationPacket.HANDLER_METHOD_PREFIX
                                + ReconfigurationPacket.getPacketTypeClassName(rcPacket.getType()),
                        ReconfigurationPacket.getPacketTypeClass(rcPacket.getType()), boolean.class)
                .invoke(target, rcPacket, recovery);
    } catch (NoSuchMethodException nsme) {
        nsme.printStackTrace();
    } catch (InvocationTargetException ite) {
        ite.printStackTrace();
    } catch (IllegalAccessException iae) {
        iae.printStackTrace();
    }
    return null;
}

From source file:com.helpinput.core.Utils.java

@SuppressWarnings("unchecked")
public static <T> T InvokedMethod(Object target, Method method, Object... args) {
    if (method != null)
        try {//  w w w  .ja  v  a2 s .co m
            return (T) method.invoke(target, args);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
    return null;
}

From source file:edu.ku.brc.af.ui.forms.FormHelper.java

/**
  * Creates a new data object and initializes it.
  * @param newDataClass class of new Object to be created and initialized
  * @param overrideAddKids whether to override the business rules as to whether to add children
  * @param busRules the business rules from the view
 */// w  ww .  ja  v a  2s  .co  m
public static FormDataObjIFace createAndNewDataObj(final Class<?> newDataClass, final Boolean overrideAddKids,
        final BusinessRulesIFace busRules) {
    try {
        FormDataObjIFace formDataObj = (FormDataObjIFace) newDataClass.newInstance();
        formDataObj.initialize();
        BusinessRulesIFace br = busRules != null ? busRules
                : DBTableIdMgr.getInstance().getBusinessRule(newDataClass);
        if (((overrideAddKids != null && overrideAddKids) || overrideAddKids == null) && br != null) {
            br.addChildrenToNewDataObjects(formDataObj);
        }
        CommandDispatcher.dispatch(new CommandAction("Data", "NewObjDataCreated", formDataObj));

        return formDataObj;

    } catch (IllegalAccessException ex) {
        edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
        edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(FormHelper.class, ex);
        ex.printStackTrace();

    } catch (InstantiationException ex) {
        edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
        edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(FormHelper.class, ex);
        ex.printStackTrace();
    }
    return null;
}