public void visitSerializableFields(Object object, ReflectionProvider.Visitor visitor) { for (Iterator iterator = fieldDictionary.fieldsFor(object.getClass()); iterator.hasNext();) { Field field = (Field) iterator.next(); if (!fieldModifiersSupported(field)) { continue; } validateFieldAccess(field); Object value = Fields.read(field, object); visitor.visit(field.getName(), field.getType(), field.getDeclaringClass(), value); } }
if (attributeMap == null) { attributeMap = new HashMap(); Field instanceMap = Fields.locate(type, Map.class, true); if (instanceMap != null) { try { Map map = (Map)Fields.read(instanceMap, null); if (map != null) { boolean valid = true; if(fields[i].getType() == type == Modifier.isStatic(fields[i].getModifiers())) { AttributedCharacterIterator.Attribute attribute = (AttributedCharacterIterator.Attribute)Fields.read(fields[i], null); attributeMap.put(toString(attribute), attribute);
public void writeField(Object object, String fieldName, Object value, Class definedIn) { Field field = fieldDictionary.field(object.getClass(), fieldName, definedIn); validateFieldAccess(field); Fields.write(field, object, value); }
public static Field find(final Class type, final String name) { try { final Field result = type.getDeclaredField(name); if (!result.isAccessible()) { result.setAccessible(true); } return result; } catch (final SecurityException e) { throw wrap("Cannot access field", type, name, e); } catch (final NoSuchFieldException e) { throw wrap("Cannot access field", type, name, e); } catch (final NoClassDefFoundError e) { throw wrap("Cannot access field", type, name, e); } }
private Field getField(Class definedIn, String fieldName) { return Fields.find(definedIn, fieldName); }
reader.moveUp(); if (HANDLER != null) { Fields.write(HANDLER, proxy, handler); } else { proxy = Proxy.newProxyInstance(classLoaderReference.getReference(), interfacesAsArray, handler);
public static void write(final Field field, final Object instance, final Object value) { try { field.set(instance, value); } catch (final SecurityException e) { throw wrap("Cannot write field", field.getType(), field.getName(), e); } catch (final IllegalArgumentException e) { throw wrap("Cannot write field", field.getType(), field.getName(), e); } catch (final IllegalAccessException e) { throw wrap("Cannot write field", field.getType(), field.getName(), e); } catch (final NoClassDefFoundError e) { throw wrap("Cannot write field", field.getType(), field.getName(), e); } }
private Field getField(Class definedIn, String fieldName) { return Fields.find(definedIn, fieldName); }
public boolean add(Object object) { if (object == null) { boolean containsNull = !map.containsKey(null); map.put(null, null); return containsNull; } Class itemType = object.getClass(); if (keyFieldName != null) { Field field = (Field)fieldCache.get(itemType); if (field == null) { field = reflectionProvider.getField(itemType, keyFieldName); fieldCache.put(itemType, field); } if (field != null) { Object key = Fields.read(field, object); return map.put(key, object) == null; } } else if (object instanceof Map.Entry) { final Map.Entry entry = (Map.Entry)object; return map.put(entry.getKey(), entry.getValue()) == null; } ConversionException exception = new ConversionException("Element is not defined as entry for implicit map"); exception.add("map-type", map.getClass().getName()); exception.add("element-type", object.getClass().getName()); throw exception; }
@Override public void writeField(final Object object, final String fieldName, final Object value, final Class<?> definedIn) { final Field field = fieldDictionary.field(object.getClass(), fieldName, definedIn); validateFieldAccess(field); Fields.write(field, object, value); }
if (attributeMap == null) { attributeMap = new HashMap(); Field instanceMap = Fields.locate(type, Map.class, true); if (instanceMap != null) { try { Map map = (Map)Fields.read(instanceMap, null); if (map != null) { boolean valid = true; if(fields[i].getType() == type == Modifier.isStatic(fields[i].getModifiers())) { AttributedCharacterIterator.Attribute attribute = (AttributedCharacterIterator.Attribute)Fields.read(fields[i], null); attributeMap.put(toString(attribute), attribute);
public static Object read(final Field field, final Object instance) { try { return field.get(instance); } catch (final SecurityException e) { throw wrap("Cannot read field", field.getType(), field.getName(), e); } catch (final IllegalArgumentException e) { throw wrap("Cannot read field", field.getType(), field.getName(), e); } catch (final IllegalAccessException e) { throw wrap("Cannot read field", field.getType(), field.getName(), e); } catch (final NoClassDefFoundError e) { throw wrap("Cannot read field", field.getType(), field.getName(), e); } }
public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) { final Properties properties = (Properties) source; Map map = sort ? (Map)new TreeMap(properties) : (Map)properties; for (Iterator iterator = map.entrySet().iterator(); iterator.hasNext();) { Map.Entry entry = (Map.Entry) iterator.next(); writer.startNode("property"); writer.addAttribute("name", entry.getKey().toString()); writer.addAttribute("value", entry.getValue().toString()); writer.endNode(); } if (defaultsField != null) { Properties defaults = (Properties)Fields.read(defaultsField, properties); if (defaults != null) { writer.startNode("defaults"); marshal(defaults, writer, context); writer.endNode(); } } }
public void writeField(Object object, String fieldName, Object value, Class definedIn) { Field field = fieldDictionary.field(object.getClass(), fieldName, definedIn); validateFieldAccess(field); Fields.write(field, object, value); }