Package java.lang.reflect

Examples of java.lang.reflect.Field$FieldData


    public static Method getReverseSetter(Class<?> primary, Class<?> target, String property) {
      Assert.notNull(target);
      Assert.notNull(primary);
      Assert.hasText(property);
      Method reverseSetter = null;
      Field collection = ClassUtils.getField(primary, property);
      if (collection != null) {
        OneToMany oneToMany = collection.getAnnotation(OneToMany.class);
      if (oneToMany != null) {
        String reverse = oneToMany.mappedBy();
        if (hasText(reverse)) {
          PropertyDescriptor reverseProperty = BeanUtils.getPropertyDescriptor(target, reverse);
          if (reverseProperty != null) reverseSetter = reverseProperty.getWriteMethod();
View Full Code Here


     */
    public final static Field getField(Class<?> clazz, String name) {
        Assert.notNull(clazz);
        Assert.notNull(name);
        Class<?> currentClass = clazz;
        Field field = null;
        while ((field == null) & (currentClass != null)) {
            try {
                field = currentClass.getDeclaredField(name);
            } catch (Exception e) {
                // Just omit
View Full Code Here

      try {
            Class<?> type = clazz;
            String[] parts = path.split("\\.");
            for (int index = 0; index < parts.length - 1; index++)
                type = new BeanWrapperImpl(type.newInstance()).getPropertyType(parts[index]);
            Field field = getField(type, parts[parts.length - 1]);
            Class<?> enumType = field.getType();
            return enumType.isEnum() && (position < enumType.getEnumConstants().length) ? enumType.getEnumConstants()[position] : null;
      } catch (Exception ex) {
            throw new IWebMvcException("Could not get enum value from [" + clazz.getName() + "] with position [" + position + "]", ex);
      }
    }
View Full Code Here

    public final static Field getField(Class<?> clazz, String name) {
        Assert.notNull(clazz);
        Assert.notNull(name);
        Class<?> currentClass = clazz;
        Field field = null;
        while ((field == null) & (currentClass != null)) {
            try {
                field = currentClass.getDeclaredField(name);
            } catch (Exception e) {
                // Just omit
View Full Code Here

   */
  public Paper createPaper(final String name)
  {
    try
    {
      final Field f = PageSize.class.getDeclaredField(name);
      final Object o = f.get(null);
      if (o instanceof PageSize == false)
      {
        // Log.debug ("Is no valid pageformat definition");
        return null;
      }
View Full Code Here

    try
    {
      final Field[] fields = PageSize.class.getFields();
      for (int i = 0; i < fields.length; i++)
      {
        final Field f = fields[i];
        if (Modifier.isPublic(f.getModifiers()) && Modifier.isStatic(f.getModifiers()))
        {
          final Object o = f.get(PageFormatFactory.getInstance());
          if (o instanceof PageSize)
          {
            final PageSize pageDef = (PageSize) o;
            if (pageDef.getWidth() == width && pageDef.getHeight() == height)
            {
              return f.getName();
            }
          }
        }
      }
    }
View Full Code Here

    {
      final ArrayList a = new ArrayList();
      final Field[] fields = PageSize.class.getFields();
      for (int i = 0; i < fields.length; i++)
      {
        final Field f = fields[i];
        if (Modifier.isPublic(f.getModifiers()) && Modifier.isStatic(f.getModifiers()))
        {
          final Object o = f.get(PageFormatFactory.getInstance());
          if (o instanceof PageSize)
          {
            a.add(f.getName());
          }
        }
      }

      return (String[]) a.toArray(new String[a.size()]);
View Full Code Here

        validator = new AJAXValidatorImpl();
        des = new DES3CiphererDecipherer();
        des.init();
        validator.decipherer = des;
        validator.validator = new AnnotatedValidator();
        Field f = AnnotatedValidator.class.getDeclaredField("validator");
        f.setAccessible(true);
        f.set(validator.validator, new ValidationVisitor());
        holder = new ContextHolder() {
            @Override
            public List<Locale> getAvailableLocales() {
                Locale l = new Locale();
                l.setDescription("English");
View Full Code Here

    // Methods for filling in strings using reflection:
    // ////////////////////////////////////////////////

    public void set(Object requestor, String field) {
        Class c = requestor.getClass();
        Field f = null;
        try {
            f = c.getField(field);
        } catch (NoSuchFieldException e) {
            // We'll try again below.
        } catch (SecurityException e) {
            RuntimeException r = new MissingResourceException("SecurityException trying to reflect on field field", c.getName(), field);
            r.initCause(e);
            throw r;
        }
        if (f == null) {
            try {
                f = c.getDeclaredField(field);
            } catch (NoSuchFieldException e) {
                RuntimeException r = new MissingResourceException("Can't find field via reflection", c.getName(), field);
                r.initCause(e);
                throw r;
            } catch (SecurityException e) {
                RuntimeException r = new MissingResourceException("SecurityException trying to reflect on field field", c.getName(), field);
                r.initCause(e);
                throw r;
            }
        }
        // Try to set it accessible:
        try {
            f.setAccessible(true);
        } catch (SecurityException e) {
            Debug.message(DEBUG, "Coudn't set field " + field + " accessible");
        }
        // Ok, now try to get the data:
        Class type = f.getType();
        Object fd = null;
        try {
            fd = f.get(requestor);
        } catch (IllegalArgumentException e) {
            RuntimeException r = new MissingResourceException("Couldn't get field", c.getName(), field);
            r.initCause(e);
            throw r;
        } catch (IllegalAccessException e) {
View Full Code Here

    @BeforeClass
    public static void setUpClass() throws Exception {
        controller = new EntityController();
        crypto = new DES3CiphererDecipherer().init();
        Field ciphererField = ClassUtils.getField(EntityController.class, "cipherer");
        ciphererField.setAccessible(true);
        ciphererField.set(controller, crypto);
        Field controllerField = ClassUtils.getField(EntityController.class, "decipherer");
        controllerField.setAccessible(true);
        controllerField.set(controller, crypto);
        Field contextField = ClassUtils.getField(EntityController.class, "context");
        contextField.setAccessible(true);
        contextField.set(controller, new ContextHolder() {
            @Override
            public List<Locale> getAvailableLocales() {
                Locale l = new Locale();
                l.setDescription("English");
                l.setLocale("en");
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.