propertyMap = new SingleKeyHashMap(); List ret = new ArrayList(propertyMap.size()); for (ComplexKeyHashMap.EntryIterator iter = propertyMap.getEntrySetIterator(); iter.hasNext();) { MetaProperty element = (MetaProperty) ((SingleKeyHashMap.Entry) iter.next()).value; if (element instanceof CachedField) continue;
/** * @see MetaObjectProtocol#getMetaProperty(String) */ public MetaProperty getMetaProperty(String name) { SingleKeyHashMap propertyMap = classPropertyIndex.getNotNull(theCachedClass); if (propertyMap.containsKey(name)) { return (MetaProperty) propertyMap.get(name); } else if (staticPropertyIndex.containsKey(name)) { return (MetaProperty) staticPropertyIndex.get(name); } else { propertyMap = classPropertyIndexForSuper.getNotNull(theCachedClass); if (propertyMap.containsKey(name)) return (MetaProperty) propertyMap.get(name); else { CachedClass superClass = theCachedClass; while (superClass != null && superClass != ReflectionCache.OBJECT_CLASS) { final MetaBeanProperty property = findPropertyInClassHierarchy(name, superClass); if (property != null) { onSuperPropertyFoundInHierarchy(property); return property; } superClass = superClass.getCachedSuperClass(); } return null; } } }
public Object copy(Object value) { return SingleKeyHashMap.copy(new SingleKeyHashMap(false), (SingleKeyHashMap) value, NAME_INDEX_COPIER); } };
private static void createMetaBeanProperty(SingleKeyHashMap propertyIndex, String propName, boolean isGetter, MetaMethod propertyMethod) { // is this property already accounted for? MetaProperty mp = (MetaProperty) propertyIndex.get(propName); MetaProperty newMp = makeReplacementMetaProperty(mp, propName, isGetter, propertyMethod); if (newMp!=mp) { propertyIndex.put(propName, newMp); } }
public Entry getOrPut(Object key) { int h = hash (key.hashCode()); final ComplexKeyHashMap.Entry[] t = table; final int index = h & (t.length - 1); ComplexKeyHashMap.Entry e = t[index]; for (; e != null; e = e.next) if (e.hash == h && ((Entry) e).key.equals(key)) return (Entry) e; Entry entry = new Entry(); entry.next = t [index]; entry.hash = h; entry.key = key; t[index] = entry; if ( ++size == threshold ) resize(2* t.length); return entry; }
private static void copyNonPrivateFields(SingleKeyHashMap from, SingleKeyHashMap to, CachedClass klass) { for (ComplexKeyHashMap.EntryIterator iter = from.getEntrySetIterator(); iter.hasNext();) { SingleKeyHashMap.Entry entry = (SingleKeyHashMap.Entry) iter.next(); CachedField mfp = (CachedField) entry.getValue(); if (!inheritedOrPublic(mfp) && !packageLocal(mfp, klass)) continue; to.put(entry.getKey(), mfp); } }
SingleKeyHashMap map = new SingleKeyHashMap(); map.put("length", arrayLengthProperty); classPropertyIndex.put(theCachedClass, map);
public void put(Object key, Object value) { getOrPut(key).value = value; }
public boolean containsKey(String name) { return get(name) != null; }
SingleKeyHashMap propertyMap = classPropertyIndex.getNullable(theCachedClass); List ret = new ArrayList(propertyMap.size()); for (ComplexKeyHashMap.EntryIterator iter = propertyMap.getEntrySetIterator(); iter.hasNext();) { MetaProperty element = (MetaProperty) ((SingleKeyHashMap.Entry) iter.next()).value; if (element instanceof CachedField) continue;
public SingleKeyHashMap getNotNull(CachedClass key) { Entry res = getOrPut(key); if (res.value == null) { res.value = new SingleKeyHashMap(); } return (SingleKeyHashMap) res.value; }
public final Object get(Object key) { int h = hash (key.hashCode()); ComplexKeyHashMap.Entry e = table [h & (table.length-1)]; for (; e != null; e = e.next) if (e.hash == h && ((Entry) e).key.equals(key)) return ((Entry)e).value; return null; }
public Entry putCopyOfUnexisting(Entry ee) { int h = ee.hash; final ComplexKeyHashMap.Entry[] t = table; final int index = h & (t.length - 1); Entry entry = new Entry(); entry.next = t [index]; entry.hash = h; entry.key = ee.key; entry.value = ee.value; t[index] = entry; if ( ++size == threshold ) resize(2* t.length); return entry; }
private static void addFields(final CachedClass klass, SingleKeyHashMap propertyIndex) { CachedField[] fields = klass.getFields(); for (CachedField field : fields) { propertyIndex.put(field.getName(), field); } }
MethodIndex copy() { return (MethodIndex) SingleKeyHashMap.copy(new MethodIndex(false), this, METHOD_INDEX_COPIER); }
public void iterate() { final ComplexKeyHashMap.Entry[] table = metaMethodIndex.methodHeaders.getTable(); int len = table.length; for (int i = 0; i != len; ++i) { for (SingleKeyHashMap.Entry classEntry = (SingleKeyHashMap.Entry) table[i]; classEntry != null; classEntry = (SingleKeyHashMap.Entry) classEntry.next) { Class clazz = (Class) classEntry.getKey(); if (skipClass(clazz)) continue; MetaMethodIndex.Header header = (MetaMethodIndex.Header) classEntry.getValue(); for (MetaMethodIndex.Entry nameEntry = header.head; nameEntry != null; nameEntry = nameEntry.nextClassEntry) { methodNameAction(clazz, nameEntry); } } } }
private void makeStaticPropertyIndex() { SingleKeyHashMap propertyMap = classPropertyIndex.getNotNull(theCachedClass); for (ComplexKeyHashMap.EntryIterator iter = propertyMap.getEntrySetIterator(); iter.hasNext();) { SingleKeyHashMap.Entry entry = ((SingleKeyHashMap.Entry) iter.next()); MetaProperty mp = (MetaProperty) entry.getValue(); if (mp instanceof CachedField) { CachedField mfp = (CachedField) mp; if (!mfp.isStatic()) continue; } else if (mp instanceof MetaBeanProperty) { MetaProperty result = establishStaticMetaProperty(mp); if (result == null) continue; else { mp = result; } } else if (mp instanceof MultipleSetterProperty) { MultipleSetterProperty msp = (MultipleSetterProperty) mp; mp = msp.createStaticVersion(); } else { continue; // ignore all other types } staticPropertyIndex.put(entry.getKey(), mp); } }
/** * Adds a new MetaBeanProperty to this MetaClass * * @param mp The MetaBeanProperty */ public void addMetaBeanProperty(MetaBeanProperty mp) { MetaProperty staticProperty = establishStaticMetaProperty(mp); if (staticProperty != null) { staticPropertyIndex.put(mp.getName(), mp); } else { SingleKeyHashMap propertyMap = classPropertyIndex.getNotNull(theCachedClass); //keep field CachedField field; MetaProperty old = (MetaProperty) propertyMap.get(mp.getName()); if (old != null) { if (old instanceof MetaBeanProperty) { field = ((MetaBeanProperty) old).getField(); } else if (old instanceof MultipleSetterProperty) { field = ((MultipleSetterProperty)old).getField(); } else { field = (CachedField) old; } mp.setField(field); } // put it in the list // this will overwrite a possible field property propertyMap.put(mp.getName(), mp); } }
public Entry getOrPut(Object key) { int h = hash (key.hashCode()); final ComplexKeyHashMap.Entry[] t = table; final int index = h & (t.length - 1); ComplexKeyHashMap.Entry e = t[index]; for (; e != null; e = e.next) if (e.hash == h && ((Entry) e).key.equals(key)) return (Entry) e; Entry entry = new Entry(); entry.next = t [index]; entry.hash = h; entry.key = key; t[index] = entry; if ( ++size == threshold ) resize(2* t.length); return entry; }
SingleKeyHashMap map = new SingleKeyHashMap(); map.put("length", arrayLengthProperty); classPropertyIndex.put(theCachedClass, map);