diff options
Diffstat (limited to 'src/patches/android/PropertyUtils.patch')
-rw-r--r-- | src/patches/android/PropertyUtils.patch | 161 |
1 files changed, 63 insertions, 98 deletions
diff --git a/src/patches/android/PropertyUtils.patch b/src/patches/android/PropertyUtils.patch index dc72ef3c..9a9d6013 100644 --- a/src/patches/android/PropertyUtils.patch +++ b/src/patches/android/PropertyUtils.patch @@ -1,12 +1,12 @@ -# HG changeset patch -# Parent 698e9f1d6348fc1066ceaac7d264cbbf63bdcd21 diff --git a/src/main/java/org/yaml/snakeyaml/introspector/PropertyUtils.java b/src/main/java/org/yaml/snakeyaml/introspector/PropertyUtils.java +index 8afc5761..208c9351 100644 --- a/src/main/java/org/yaml/snakeyaml/introspector/PropertyUtils.java +++ b/src/main/java/org/yaml/snakeyaml/introspector/PropertyUtils.java -@@ -15,11 +15,7 @@ +@@ -13,12 +13,7 @@ */ package org.yaml.snakeyaml.introspector; +-import java.beans.FeatureDescriptor; -import java.beans.IntrospectionException; -import java.beans.Introspector; -import java.beans.PropertyDescriptor; @@ -15,104 +15,69 @@ diff --git a/src/main/java/org/yaml/snakeyaml/introspector/PropertyUtils.java b/ import java.lang.reflect.Modifier; import java.util.Collection; import java.util.HashMap; -@@ -37,64 +33,31 @@ - private BeanAccess beanAccess = BeanAccess.DEFAULT; - private boolean allowReadOnlyProperties = false; - -- protected Map<String, Property> getPropertiesMap(Class<?> type, BeanAccess bAccess) -- throws IntrospectionException { -+ protected Map<String, Property> getPropertiesMap(Class<?> type, BeanAccess bAccess) { - if (propertiesCache.containsKey(type)) { - return propertiesCache.get(type); - } - - Map<String, Property> properties = new LinkedHashMap<String, Property>(); -- boolean inaccessableFieldsExist = false; -- switch (bAccess) { -- case FIELD: -- for (Class<?> c = type; c != null; c = c.getSuperclass()) { -- for (Field field : c.getDeclaredFields()) { -- int modifiers = field.getModifiers(); -- if (!Modifier.isStatic(modifiers) && !Modifier.isTransient(modifiers) -- && !properties.containsKey(field.getName())) { -- properties.put(field.getName(), new FieldProperty(field)); -- } -+ for (Class<?> c = type; c != null; c = c.getSuperclass()) { -+ for (Field field : c.getDeclaredFields()) { -+ int modifiers = field.getModifiers(); -+ if (!Modifier.isStatic(modifiers) && !Modifier.isTransient(modifiers) -+ && !properties.containsKey(field.getName())) { -+ properties.put(field.getName(), new FieldProperty(field)); - } - } -- break; -- default: -- // add JavaBean properties -- for (PropertyDescriptor property : Introspector.getBeanInfo(type) -- .getPropertyDescriptors()) { -- Method readMethod = property.getReadMethod(); -- if (readMethod == null || !readMethod.getName().equals("getClass")) { -- properties.put(property.getName(), new MethodProperty(property)); -- } -- } -+ } +@@ -65,47 +60,14 @@ public class PropertyUtils { + } -- // add public fields -- for (Class<?> c = type; c != null; c = c.getSuperclass()) { -- for (Field field : c.getDeclaredFields()) { -- int modifiers = field.getModifiers(); -- if (!Modifier.isStatic(modifiers) && !Modifier.isTransient(modifiers)) { -- if (Modifier.isPublic(modifiers)) { -- properties.put(field.getName(), new FieldProperty(field)); -- } else { -- inaccessableFieldsExist = true; -- } -- } -- } -- } -- break; + Map<String, Property> properties = new LinkedHashMap<String, Property>(); +- boolean inaccessableFieldsExist = false; +- if (bAccess == BeanAccess.FIELD) { +- for (Class<?> c = type; c != null; c = c.getSuperclass()) { ++ for (Class<?> c = type; c != null; c = c.getSuperclass()) { + for (Field field : c.getDeclaredFields()) { +- int modifiers = field.getModifiers(); +- if (!Modifier.isStatic(modifiers) && !Modifier.isTransient(modifiers) +- && !properties.containsKey(field.getName())) { +- properties.put(field.getName(), new FieldProperty(field)); +- } - } -- if (properties.isEmpty() && inaccessableFieldsExist) { -- throw new YAMLException("No JavaBean properties found in " + type.getName()); +- } +- } else {// add JavaBean properties +- try { +- for (PropertyDescriptor property : Introspector.getBeanInfo(type) +- .getPropertyDescriptors()) { +- Method readMethod = property.getReadMethod(); +- if ((readMethod == null || !readMethod.getName().equals("getClass")) +- && !isTransient(property)) { +- properties.put(property.getName(), new MethodProperty(property)); +- } - } - propertiesCache.put(type, properties); - return properties; - } - -- public Set<Property> getProperties(Class<? extends Object> type) throws IntrospectionException { -+ public Set<Property> getProperties(Class<? extends Object> type) { - return getProperties(type, beanAccess); - } - -- public Set<Property> getProperties(Class<? extends Object> type, BeanAccess bAccess) -- throws IntrospectionException { -+ public Set<Property> getProperties(Class<? extends Object> type, BeanAccess bAccess) { - if (readableProperties.containsKey(type)) { - return readableProperties.get(type); - } -@@ -103,8 +66,7 @@ - return properties; - } - -- protected Set<Property> createPropertySet(Class<? extends Object> type, BeanAccess bAccess) -- throws IntrospectionException { -+ protected Set<Property> createPropertySet(Class<? extends Object> type, BeanAccess bAccess) { - Set<Property> properties = new TreeSet<Property>(); - Collection<Property> props = getPropertiesMap(type, bAccess).values(); - for (Property property : props) { -@@ -115,13 +77,11 @@ - return properties; +- } catch (IntrospectionException e) { +- throw new YAMLException(e); +- } +- +- // add public fields +- for (Class<?> c = type; c != null; c = c.getSuperclass()) { +- for (Field field : c.getDeclaredFields()) { +- int modifiers = field.getModifiers(); +- if (!Modifier.isStatic(modifiers) && !Modifier.isTransient(modifiers)) { +- if (Modifier.isPublic(modifiers)) { +- properties.put(field.getName(), new FieldProperty(field)); +- } else { +- inaccessableFieldsExist = true; +- } +- } +- } +- } +- } +- if (properties.isEmpty() && inaccessableFieldsExist) { +- throw new YAMLException("No JavaBean properties found in " + type.getName()); ++ int modifiers = field.getModifiers(); ++ if (!Modifier.isStatic(modifiers) && !Modifier.isTransient(modifiers) ++ && !properties.containsKey(field.getName())) { ++ properties.put(field.getName(), new FieldProperty(field)); ++ } ++ } } + propertiesCache.put(type, properties); + return properties; +@@ -113,10 +75,6 @@ public class PropertyUtils { -- public Property getProperty(Class<? extends Object> type, String name) -- throws IntrospectionException { -+ public Property getProperty(Class<? extends Object> type, String name) { - return getProperty(type, name, beanAccess); - } + private static final String TRANSIENT = "transient"; -- public Property getProperty(Class<? extends Object> type, String name, BeanAccess bAccess) -- throws IntrospectionException { -+ public Property getProperty(Class<? extends Object> type, String name, BeanAccess bAccess) { - Map<String, Property> properties = getPropertiesMap(type, bAccess); - Property property = properties.get(name); - if (property == null || !property.isWritable()) { +- private boolean isTransient(FeatureDescriptor fd) { +- return Boolean.TRUE.equals(fd.getValue(TRANSIENT)); +- } +- + public Set<Property> getProperties(Class<? extends Object> type) { + return getProperties(type, beanAccess); + } |