Package java.lang.reflect

Examples of java.lang.reflect.Field$FieldData


*/
public class LoggingHelper {
    public static void injectLogger(PlexusContainer container, Project project) {
        try {
            WagonManager wagonManager = (WagonManager) container.lookup(WagonManager.ROLE);
            Field field = DefaultWagonManager.class.getDeclaredField("downloadMonitor");
            field.setAccessible(true);
            AntDownloadMonitor antDownloadMonitor = (AntDownloadMonitor) field.get(wagonManager);
            antDownloadMonitor.setProject(project);
        } catch (ComponentLookupException e) {
            throw new RuntimeException(e);
        } catch (IllegalAccessException e) {
            throw new RuntimeException(e);
View Full Code Here


        registerFactory(modelFactory.getName(), null, modelFactory);
    }

    public static void setProp(Class c, Object obj, String fieldName, Object value) {
        try {
            Field f = c.getDeclaredField(fieldName);
            f.setAccessible(true); // solution
            f.set(obj, value); // IllegalAccessException
            // production code should handle these exceptions more gracefully
        } catch (NoSuchFieldException e) {
            throw new RuntimeException(e);
        } catch (IllegalArgumentException e) {
           throw new RuntimeException(e);
View Full Code Here

        }
    }

    public static Object getProp(Class c, Object obj, String fieldName) {
        try {
            Field f = c.getDeclaredField(fieldName);
            f.setAccessible(true); // solution
            return f.get(obj); // IllegalAccessException
            // production code should handle these exceptions more gracefully
        } catch (NoSuchFieldException e) {
            throw new RuntimeException(e);
        } catch (IllegalArgumentException e) {
            throw new RuntimeException(e);
View Full Code Here

        String descriptor = imports[i++];
        Address imported = getAddress().resolve(pathinfo);
        _dependencies.put(imported, new Dependency(imported, descriptor, _location));
      }
     
      Field field;
     
      field = scriptclass.getDeclaredField("_module");
      field.set(null, this);
     
      field = scriptclass.getDeclaredField("_type");
      field.set(null, new AnyScope(this));

    } catch (Throwable t) {
      anvil.Log.log().error("Initialization of "+scriptclass.getName()+" failed", t);
    }
   
View Full Code Here

      if (cls != Any.class) {
        Field[] fields = cls.getDeclaredFields();
        Object obj;
        n = fields.length;
        for(int i=0; i<n; i++) {
          Field field = fields[i];
          String name = field.getName();
          int mod = field.getModifiers();
          if (name.startsWith("p_")) {
            continue;
          }
          if (name.startsWith("_")) {
            continue;
          }
          if (name.equals("newInstance")) {
            continue;
          }
          if (Modifier.isPublic(mod) && Modifier.isStatic(mod) && Modifier.isFinal(mod)) {
            try {
              obj = field.get(null);
              if (obj instanceof Any) {
                if (_document != null) {
                  doc = _document.findFirst(Doc.T_CONST, name);
                } else {
                  doc = null;
View Full Code Here

        int cursorType = getModeCursor().getType();

        Field[] cFields = Cursor.class.getFields();
        for (int i = 0; i < cFields.length; i++) {
            Field f = cFields[i];

            String name = f.getName();
            if (name.endsWith("_CURSOR")) {
                try {
                    int testType = f.getInt(null);
                    if (testType == cursorType) {
                        props.put(prefix + CursorIDProperty, name);
                        break;
                    }
                } catch (IllegalArgumentException e) {
View Full Code Here

                "com.bbn.openmap.util.propertyEditor.ComboBoxPropertyEditor");

        StringBuffer cOptions = new StringBuffer();
        Field[] cFields = Cursor.class.getFields();
        for (int i = 0; i < cFields.length; i++) {
            Field f = cFields[i];

            String name = f.getName();
            if (name.endsWith("_CURSOR")) {
                String cName = f.getName();
                props.put(CursorIDProperty + "." + cName, cName);
                cOptions.append(" " + cName);
            }
        }
View Full Code Here

        try {
            Class<?> type = entityClass;
            String[] parts = path.split("\\.");
            for (int index = 0; index < parts.length - 1; index++) type = getType(type, parts[index]);
            if (logger.isDebugEnabled()) logger.debug("Obtained super type [" + type + "] for enum at [" + entityClass + "." + path + "]");
            Field field = ClassUtils.getField(type, parts[parts.length - 1]);
            EntityFilter filter = field.getAnnotation(EntityFilter.class);
            String[] values = filter == null ? null : filter.values();
            if ((values == null) || (values.length <= 0)) {
              Class<?> enumType = field.getType();
              if (enumType.isEnum()) {
                    Object[] constants = enumType.getEnumConstants();
                    values = new String[constants.length];
                    for (int index = 0; index < constants.length; index++)
                        values[index] = enumType.getSimpleName() + "." + constants[index].toString();
View Full Code Here

    }

    protected Class<?> getType(Class<?> clazz, String path) throws BeansException, InstantiationException, IllegalAccessException {
        int indexCollection = path.indexOf("[");
        String sanitizedPath = indexCollection > 0 ? path.substring(0, indexCollection) : path;
      Field field = ClassUtils.getField(clazz, sanitizedPath);
        return field != null ? extractCollectionType ? ClassUtils.getGenericType(field) : field.getType() : null;
    }
View Full Code Here

      return ClassUtils.getField(clazz, path);
    }

    @Override public void doTag() throws JspException {
        try {
            Field type = null;
            for (String part : path.split("\\.")) type = getField(type == null ? entityClass : type.getType(), part);
            Class<?> genericType = ClassUtils.getGenericType(type);
            if (logger.isDebugEnabled()) logger.debug("Obtained generic type [" + type + "] for [" + entityClass + "." + path + "] collection");
            getJspContext().setAttribute(property, genericType);
        } catch (Exception ex) {
            if (logger.isDebugEnabled()) logger.debug("Could not obtain the type of [" + path + "] in class [" + entityClass + "]: " + ex.getMessage());
View Full Code Here

TOP

Related Classes of java.lang.reflect.Field$FieldData

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.