1 19 20 package org.netbeans.modules.java.bridge; 21 22 import java.util.*; 24 import java.util.Iterator ; 25 26 import org.openide.src.*; 27 28 import javax.jmi.reflect.RefObject; 29 30 import org.netbeans.jmi.javamodel.JavaClass; 31 import org.netbeans.modules.javacore.jmiimpl.javamodel.JavaClassImpl; 32 33 class ClassesCollection extends ObjectsCollection { 34 35 static final ClassElement[] EMPTY = new ClassElement[0]; 36 37 public ClassesCollection(FeaturesCollection members) { 38 super (members); 39 } 40 41 public RefObject createFeature(RefObject parent, Element elem) { 42 return members.createClass ((ClassElement) elem); 43 } 44 45 public Element [] getEmptyArray () { 46 return EMPTY; 47 } 48 49 public String getPropertyName () { 50 return ElementProperties.PROP_CLASSES; 51 } 52 53 public boolean isOfType (RefObject feature) { 54 return feature instanceof JavaClass; 55 } 56 57 public Element createElement (RefObject innerClass) { 58 return (ClassElement) members.model.createInnerClass (members.getParentClass (), (JavaClass)innerClass).getElement (); 59 } 60 61 public ClassElement getClass(Identifier name) { 62 members.repository.beginTrans(false); 63 try { 64 if (isValid()) { 65 String simpleName = name.getName(); 66 JavaClass innerClass = members.javaClass.getInnerClass(simpleName, false); 67 if (innerClass == null) 68 return null; 69 String fqn = name.getFullName (); 70 if (!fqn.equals (name.getName ()) && !fqn.equals (innerClass.getName ())) 71 return null; 72 return (ClassElement) cachedElement (innerClass); 73 } else { 74 return null; 75 } 76 } finally { 77 members.repository.endTrans(); 78 } 79 } 80 81 public ClassElement[] getClasses () { 82 return (ClassElement[]) getElements (); 83 } 84 85 public boolean matches (Element elem, RefObject f) { 86 JavaClass javaClass = (JavaClass) f; 87 ClassElement classElem = (ClassElement) elem; 88 String simpleName = javaClass.getSimpleName(); 89 return classElem.getName ().getName ().equals (simpleName); 90 } 91 92 public int getPositionalValue () { 93 return ObjectsCollection.POS_VAL_CLASS; 94 } 95 } 96 | Popular Tags |