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:org.extremecomponents.tree.TreeModelUtils.java

public static Object findByIdentifierOrReference(TableModel model, List searchList, Object bean) {
    if (searchList.contains(bean)) {
        return bean; // Not the identifier but the actual bean reference
    }/*from   ww  w  .ja  v a  2 s.  c  om*/

    String identifier = model.getTableHandler().getTable().getAttributeAsString(TreeConstants.IDENTIFIER);

    for (int i = 0; i < searchList.size(); i++) {
        Object row = searchList.get(i);
        try {
            if (bean.equals(BeanUtils.getProperty(row, identifier))) {
                return row;
            }
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        }
    }
    return null;
}

From source file:szjy.advtech.BuildInfo.java

/**
 * Get boolean of field from Class/*from w  w  w.  j  a  va  2 s  .  c  om*/
 * @param c
 * @param fieldName
 * @param defaultReturn
  * @return
  */
private static boolean getClassFieldBoolean(Class c, String fieldName, boolean defaultReturn) {
    boolean ret = defaultReturn;
    Field field = getClassField(c, fieldName);

    if (null != field) {
        try {
            ret = field.getBoolean(c);
        } catch (IllegalAccessException iae) {
            iae.printStackTrace();
        }
    }

    return ret;
}

From source file:szjy.advtech.BuildInfo.java

/**
 * Get string of field from Class//from w ww  . j a v a  2 s. c o m
 * @param c
 * @param fieldName
 * @param defaultReturn
  * @return
  */
private static String getClassFieldString(Class c, String fieldName, String defaultReturn) {
    String ret = defaultReturn;
    Field field = getClassField(c, fieldName);

    if (null != field) {
        try {
            ret = (String) field.get(c);
        } catch (IllegalAccessException iae) {
            iae.printStackTrace();
        }
    }

    return ret;
}

From source file:szjy.advtech.BuildInfo.java

/**
 * Get int of field from Class//from  w w  w. ja  v  a 2 s  .c om
 * @param c
 * @param fieldName
 * @param defaultReturn
  * @return
  */
private static int getClassFieldInt(Class c, String fieldName, int defaultReturn) {
    int ret = defaultReturn;
    Field field = getClassField(c, fieldName);

    if (null != field) {
        try {
            ret = field.getInt(c);
        } catch (IllegalAccessException iae) {
            iae.printStackTrace();
        }
    }

    return ret;
}

From source file:org.lman.json.JsonConverter.java

private static void writeJson(JsonView json, final JSONStringer out)
        throws IllegalAccessException, JSONException {
    switch (json.getType()) {
    case NULL:/*from  ww  w . j  a  va 2  s.co  m*/
        out.value(null);
        break;

    case BOOLEAN:
        out.value(json.asBoolean());
        break;

    case NUMBER:
        out.value(json.asNumber());
        break;

    case STRING:
        out.value(json.asString());
        break;

    case ARRAY:
        out.array();
        json.asArrayForeach(new ArrayVisitor() {
            @Override
            public void visit(JsonView value, int index) {
                if (value.isNull())
                    return;

                try {
                    writeJson(value, out);
                } catch (IllegalAccessException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (JSONException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        });
        out.endArray();
        break;

    case OBJECT:
        out.object();
        try {
            json.asObjectForeach(new ObjectVisitor() {
                @Override
                public void visit(String key, JsonView value) {
                    if (value.isTransient() || value.isNull())
                        return;

                    try {
                        out.key(key);
                        writeJson(value, out);
                    } catch (JSONException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    } catch (IllegalAccessException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                }
            });
        } catch (Exception e) {
        }
        out.endObject();
        break;
    }
}

From source file:im.r_c.android.dbox.SQLBuilder.java

static ContentValues buildContentValues(TableInfo tableInfo, Object obj) {
    ContentValues values = new ContentValues();
    for (ColumnInfo ci : tableInfo.mColumnMap.values()) {
        if (TableInfo.COLUMN_ID.equals(ci.mName)) {
            continue;
        }//from w w w.j a  v  a  2 s  .  co  m

        try {
            switch (ci.mType) {
            case ColumnInfo.TYPE_BOOLEAN:
                values.put(ci.mName, ci.mField.getBoolean(obj) ? 1 : 0);
                break;
            case ColumnInfo.TYPE_BYTE:
                values.put(ci.mName, ci.mField.getByte(obj));
                break;
            case ColumnInfo.TYPE_SHORT:
                values.put(ci.mName, ci.mField.getShort(obj));
                break;
            case ColumnInfo.TYPE_INT:
                values.put(ci.mName, ci.mField.getInt(obj));
                break;
            case ColumnInfo.TYPE_LONG:
                values.put(ci.mName, ci.mField.getLong(obj));
                break;
            case ColumnInfo.TYPE_FLOAT:
                values.put(ci.mName, ci.mField.getFloat(obj));
                break;
            case ColumnInfo.TYPE_DOUBLE:
                values.put(ci.mName, ci.mField.getDouble(obj));
                break;
            case ColumnInfo.TYPE_STRING:
                values.put(ci.mName, (String) ci.mField.get(obj));
                break;
            case ColumnInfo.TYPE_DATE:
                Date date = (Date) ci.mField.get(obj);
                values.put(ci.mName, date.getTime());
                break;
            case ColumnInfo.TYPE_BYTE_ARRAY:
                values.put(ci.mName, (byte[]) ci.mField.get(obj));
                break;
            }
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
    }

    if (values.size() != tableInfo.mColumnMap.size() - 1) {
        // "values" contains all column values of the table except "id",
        // so normally this block will NEVER be executed.
        throw new UnknownError();
    }

    return values;
}

From source file:org.opennms.features.reporting.sdo.SDOMapper.java

public static RemoteReportSDO getSDO(Object bean) {
    RemoteReportSDO reportResult = new RemoteReportSDO();
    try {//  w w w .ja  v  a2 s  . c  o m
        BeanUtils.copyProperties(reportResult, bean);
    } catch (IllegalAccessException e) {
        logger.debug(
                "getSDObyConnectReport IllegalAssessException while copyProperties from '{}' to '{}' with exception.",
                reportResult, bean);
        logger.error("getSDObyConnectReport IllegalAssessException while copyProperties '{}'", e);
        e.printStackTrace();
    } catch (InvocationTargetException e) {
        logger.debug(
                "getSDObyConnectReport InvocationTargetException while copyProperties from '{}' to '{}' with exception.",
                reportResult, bean);
        logger.error("getSDObyConnectReport InvocationTargetException while copyProperties '{}'", e);
        e.printStackTrace();
    }
    return reportResult;
}

From source file:com.fenlisproject.elf.core.framework.ElfBinder.java

public static void bindView(Object receiver, View parentView) {
    Field[] fields = receiver.getClass().getDeclaredFields();
    for (Field field : fields) {
        field.setAccessible(true);/*  w  w w.ja  v  a  2  s .c o  m*/
        ViewId viewId = field.getAnnotation(ViewId.class);
        if (viewId != null) {
            try {
                View view = null;
                if (receiver instanceof Activity) {
                    view = ((Activity) receiver).findViewById(viewId.value());
                } else if (receiver instanceof Dialog) {
                    view = ((Dialog) receiver).findViewById(viewId.value());
                } else if (parentView != null) {
                    view = parentView.findViewById(viewId.value());
                }
                if (view != null) {
                    field.set(receiver, view);
                }
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
        }
    }
}

From source file:com.fenlisproject.elf.core.framework.ElfBinder.java

public static void bindAnimation(Object receiver) {
    Field[] fields = receiver.getClass().getDeclaredFields();
    for (Field field : fields) {
        field.setAccessible(true);//from w w w.  java  2s  .  co  m
        AnimationResourceId animResId = field.getAnnotation(AnimationResourceId.class);
        if (animResId != null) {
            try {
                Context context = null;
                if (receiver instanceof Activity) {
                    context = (Activity) receiver;
                } else if (receiver instanceof Fragment) {
                    context = ((Fragment) receiver).getActivity();
                } else if (receiver instanceof Dialog) {
                    context = ((Dialog) receiver).getContext();
                }
                if (context != null) {
                    Animation anim = AnimationUtils.loadAnimation(context, animResId.value());
                    field.set(receiver, anim);
                }
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
        }
    }
}

From source file:com.aw.support.reflection.MethodInvoker.java

public static List getAttributes(Object target) {
    logger.info("searching attributes " + target.getClass().getName());
    List attributes = new ArrayList();
    List<Field> forms = new ArrayList();
    Class cls = target.getClass();
    Field[] fields = cls.getFields();
    for (int i = 0; i < fields.length; i++) {
        if ((fields[i].getName().startsWith("txt") || fields[i].getName().startsWith("chk"))
                && !fields[i].getName().startsWith("chkSel")) {
            attributes.add(fields[i]);// ww  w .  j  av  a  2 s  .c o  m
        }
        if ((fields[i].getType().getSimpleName().startsWith("Frm"))) {
            forms.add(fields[i]);
        }
    }
    if (forms.size() > 0) {
        for (Field field : forms) {
            try {
                Object formToBeChecked = field.get(target);
                if (formToBeChecked != null) {
                    List formAttributes = getAttributes(formToBeChecked);
                    if (formAttributes.size() > 0) {
                        attributes.addAll(formAttributes);
                    }
                } else {
                    logger.warn("FRM NULL:" + field.getName());
                }
            } catch (IllegalAccessException e) {
                e.printStackTrace();
                throw new AWSystemException("Problems getting value for:<" + field.getName() + ">", e);
            }
        }
    }
    return attributes;
}