Utility class that provides generic services to reflection classes. It handles all polymorphism issues in the #wrap(Object) and #unwrap(TemplateModel) methods. @author Attila Szegedi @version $Id: BeansWrapper.java,v 1.91.2.13 2007/04/02 13:08:59 szegedia Exp $
| 113 | * @version $Id: BeansWrapper.java,v 1.91.2.13 2007/04/02 13:08:59 szegedia Exp $ |
| 114 | */ |
| 115 | public class BeansWrapper implements ObjectWrapper |
| 116 | { |
| 117 | static final Object CAN_NOT_UNWRAP = new Object(); |
| 118 | private static final Class BIGINTEGER_CLASS = java.math.BigInteger.class; |
| 119 | private static final Class BOOLEAN_CLASS = Boolean.class; |
| 120 | private static final Class CHARACTER_CLASS = Character.class; |
| 121 | private static final Class COLLECTION_CLASS = Collection.class; |
| 122 | private static final Class DATE_CLASS = Date.class; |
| 123 | private static final Class HASHADAPTER_CLASS = HashAdapter.class; |
| 124 | private static final Class ITERABLE_CLASS; |
| 125 | private static final Class LIST_CLASS = List.class; |
| 126 | private static final Class MAP_CLASS = Map.class; |
| 127 | private static final Class NUMBER_CLASS = Number.class; |
| 128 | private static final Class OBJECT_CLASS = Object.class; |
| 129 | private static final Class SEQUENCEADAPTER_CLASS = SequenceAdapter.class; |
| 130 | private static final Class SET_CLASS = Set.class; |
| 131 | private static final Class SETADAPTER_CLASS = SetAdapter.class; |
| 132 | private static final Class STRING_CLASS = String.class; |
| 133 | static { |
| 134 | Class iterable; |
| 135 | try { |
| 136 | iterable = Class.forName("java.lang.Iterable"); |
| 137 | } |
| 138 | catch(ClassNotFoundException e) { |
| 139 | // We're running on a pre-1.5 JRE |
| 140 | iterable = null; |
| 141 | } |
| 142 | ITERABLE_CLASS = iterable; |
| 143 | } |
| 144 | |
| 145 | // When this property is true, some things are stricter. This is mostly to |
| 146 | // catch anomalous things in development that can otherwise be valid situations |
| 147 | // for our users. |
| 148 | private static final boolean DEVELOPMENT = "true".equals(SecurityUtilities.getSystemProperty("freemarker.development")); |
| 149 | |
| 150 | private static final Constructor ENUMS_MODEL_CTOR = enumsModelCtor(); |
| 151 | |
| 152 | private static final Logger logger = Logger.getLogger("freemarker.beans"); |
| 153 | |
| 154 | private static final Set UNSAFE_METHODS = createUnsafeMethodsSet(); |
| 155 | |
| 156 | static final Object GENERIC_GET_KEY = new Object(); |
| 157 | private static final Object CONSTRUCTORS = new Object(); |
| 158 | private static final Object ARGTYPES = new Object(); |
| 159 | |
| 160 | private static final boolean javaRebelAvailable = isJavaRebelAvailable(); |
| 161 | |
| 162 | /** |
| 163 | * The default instance of BeansWrapper |
| 164 | */ |
| 165 | private static final BeansWrapper INSTANCE = new BeansWrapper(); |
| 166 | |
| 167 | /** |
| 168 | * Used for synchronization by {@link #genericClassIntrospectionCache}, |
| 169 | * {@link #staticModels} and {@link #enumModels} (and by any similar future |
| 170 | * fields). The primary goal of using a common monitor is to prevent |
| 171 | * deadlocks when these objects call each other. |
| 172 | */ |
nothing calls this directly
no test coverage detected
searching dependent graphs…