1# HG changeset patch 2# Parent 698e9f1d6348fc1066ceaac7d264cbbf63bdcd21 3diff --git a/src/main/java/org/yaml/snakeyaml/introspector/PropertyUtils.java b/src/main/java/org/yaml/snakeyaml/introspector/PropertyUtils.java 4--- a/src/main/java/org/yaml/snakeyaml/introspector/PropertyUtils.java 5+++ b/src/main/java/org/yaml/snakeyaml/introspector/PropertyUtils.java 6@@ -15,11 +15,7 @@ 7 */ 8 package org.yaml.snakeyaml.introspector; 9 10-import java.beans.IntrospectionException; 11-import java.beans.Introspector; 12-import java.beans.PropertyDescriptor; 13 import java.lang.reflect.Field; 14-import java.lang.reflect.Method; 15 import java.lang.reflect.Modifier; 16 import java.util.Collection; 17 import java.util.HashMap; 18@@ -37,64 +33,31 @@ 19 private BeanAccess beanAccess = BeanAccess.DEFAULT; 20 private boolean allowReadOnlyProperties = false; 21 22- protected Map<String, Property> getPropertiesMap(Class<?> type, BeanAccess bAccess) 23- throws IntrospectionException { 24+ protected Map<String, Property> getPropertiesMap(Class<?> type, BeanAccess bAccess) { 25 if (propertiesCache.containsKey(type)) { 26 return propertiesCache.get(type); 27 } 28 29 Map<String, Property> properties = new LinkedHashMap<String, Property>(); 30- boolean inaccessableFieldsExist = false; 31- switch (bAccess) { 32- case FIELD: 33- for (Class<?> c = type; c != null; c = c.getSuperclass()) { 34- for (Field field : c.getDeclaredFields()) { 35- int modifiers = field.getModifiers(); 36- if (!Modifier.isStatic(modifiers) && !Modifier.isTransient(modifiers) 37- && !properties.containsKey(field.getName())) { 38- properties.put(field.getName(), new FieldProperty(field)); 39- } 40+ for (Class<?> c = type; c != null; c = c.getSuperclass()) { 41+ for (Field field : c.getDeclaredFields()) { 42+ int modifiers = field.getModifiers(); 43+ if (!Modifier.isStatic(modifiers) && !Modifier.isTransient(modifiers) 44+ && !properties.containsKey(field.getName())) { 45+ properties.put(field.getName(), new FieldProperty(field)); 46 } 47 } 48- break; 49- default: 50- // add JavaBean properties 51- for (PropertyDescriptor property : Introspector.getBeanInfo(type) 52- .getPropertyDescriptors()) { 53- Method readMethod = property.getReadMethod(); 54- if (readMethod == null || !readMethod.getName().equals("getClass")) { 55- properties.put(property.getName(), new MethodProperty(property)); 56- } 57- } 58+ } 59 60- // add public fields 61- for (Class<?> c = type; c != null; c = c.getSuperclass()) { 62- for (Field field : c.getDeclaredFields()) { 63- int modifiers = field.getModifiers(); 64- if (!Modifier.isStatic(modifiers) && !Modifier.isTransient(modifiers)) { 65- if (Modifier.isPublic(modifiers)) { 66- properties.put(field.getName(), new FieldProperty(field)); 67- } else { 68- inaccessableFieldsExist = true; 69- } 70- } 71- } 72- } 73- break; 74- } 75- if (properties.isEmpty() && inaccessableFieldsExist) { 76- throw new YAMLException("No JavaBean properties found in " + type.getName()); 77- } 78 propertiesCache.put(type, properties); 79 return properties; 80 } 81 82- public Set<Property> getProperties(Class<? extends Object> type) throws IntrospectionException { 83+ public Set<Property> getProperties(Class<? extends Object> type) { 84 return getProperties(type, beanAccess); 85 } 86 87- public Set<Property> getProperties(Class<? extends Object> type, BeanAccess bAccess) 88- throws IntrospectionException { 89+ public Set<Property> getProperties(Class<? extends Object> type, BeanAccess bAccess) { 90 if (readableProperties.containsKey(type)) { 91 return readableProperties.get(type); 92 } 93@@ -103,8 +66,7 @@ 94 return properties; 95 } 96 97- protected Set<Property> createPropertySet(Class<? extends Object> type, BeanAccess bAccess) 98- throws IntrospectionException { 99+ protected Set<Property> createPropertySet(Class<? extends Object> type, BeanAccess bAccess) { 100 Set<Property> properties = new TreeSet<Property>(); 101 Collection<Property> props = getPropertiesMap(type, bAccess).values(); 102 for (Property property : props) { 103@@ -115,13 +77,11 @@ 104 return properties; 105 } 106 107- public Property getProperty(Class<? extends Object> type, String name) 108- throws IntrospectionException { 109+ public Property getProperty(Class<? extends Object> type, String name) { 110 return getProperty(type, name, beanAccess); 111 } 112 113- public Property getProperty(Class<? extends Object> type, String name, BeanAccess bAccess) 114- throws IntrospectionException { 115+ public Property getProperty(Class<? extends Object> type, String name, BeanAccess bAccess) { 116 Map<String, Property> properties = getPropertiesMap(type, bAccess); 117 Property property = properties.get(name); 118 if (property == null || !property.isWritable()) { 119