1 19 20 package org.netbeans.modules.java.bridge; 21 22 import java.util.Iterator ; 23 import javax.jmi.reflect.RefObject; 24 import org.netbeans.jmi.javamodel.Field; 25 import org.openide.src.*; 26 27 class FieldsCollection extends ObjectsCollection { 28 29 static final FieldElement[] EMPTY = new FieldElement[0]; 30 31 public FieldsCollection(FeaturesCollection members) { 32 super(members); 33 } 34 35 public RefObject createFeature(RefObject parent, Element elem) { 36 Field res = members.createField ((FieldElement) elem); 37 return res; 39 } 40 41 public Element [] getEmptyArray () { 42 return EMPTY; 43 } 44 45 public String getPropertyName () { 46 return ElementProperties.PROP_FIELDS; 47 } 48 49 public boolean isOfType (RefObject feature) { 50 return feature instanceof Field; 51 } 52 53 public Element createElement (RefObject field) { 54 return members.model.createField (members.getParentClass (), (Field)field).getElement (); 55 } 56 57 public FieldElement getField(Identifier name) { 58 members.repository.beginTrans(false); 59 try { 60 if (isValid()) { 61 String fieldName = name.getName(); 62 Field field = members.javaClass.getField (fieldName, false); 63 return field == null ? null : (FieldElement)cachedElement (field); 64 } else { 65 return null; 66 } 67 } finally { 68 members.repository.endTrans(); 69 } 70 } 71 72 public FieldElement [] getFields() { 73 return (FieldElement []) getElements (); 74 } 75 76 public boolean matches (Element elem, RefObject f) { 77 Field field = (Field) f; 78 FieldElement fieldElem = (FieldElement) elem; 79 return field.getName ().equals (fieldElem.getName ().getName ()); 80 } 81 82 public int getPositionalValue () { 83 return ObjectsCollection.POS_VAL_FIELD; 84 } 85 86 } 87 | Popular Tags |