1 11 package org.eclipse.jdt.internal.core; 12 13 import org.eclipse.jdt.core.IJavaElement; 14 15 19 class JavaElementInfo { 20 21 26 protected IJavaElement[] children; 27 28 31 static Object [] NO_NON_JAVA_RESOURCES = new Object [] {}; 32 33 protected JavaElementInfo() { 34 this.children = JavaElement.NO_ELEMENTS; 35 } 36 public void addChild(IJavaElement child) { 37 int length = this.children.length; 38 if (length == 0) { 39 this.children = new IJavaElement[] {child}; 40 } else { 41 for (int i = 0; i < length; i++) { 42 if (children[i].equals(child)) 43 return; } 45 System.arraycopy(this.children, 0, this.children = new IJavaElement[length+1], 0, length); 46 this.children[length] = child; 47 } 48 } 49 public Object clone() { 50 try { 51 return super.clone(); 52 } 53 catch (CloneNotSupportedException e) { 54 throw new Error (); 55 } 56 } 57 public IJavaElement[] getChildren() { 58 return this.children; 59 } 60 public void removeChild(IJavaElement child) { 61 for (int i = 0, length = this.children.length; i < length; i++) { 62 IJavaElement element = this.children[i]; 63 if (element.equals(child)) { 64 if (length == 1) { 65 this.children = JavaElement.NO_ELEMENTS; 66 } else { 67 IJavaElement[] newChildren = new IJavaElement[length-1]; 68 System.arraycopy(this.children, 0, newChildren , 0, i); 69 if (i < length-1) 70 System.arraycopy(this.children, i+1, newChildren, i, length-1-i); 71 this.children = newChildren; 72 } 73 break; 74 } 75 } 76 } 77 public void setChildren(IJavaElement[] children) { 78 this.children = children; 79 } 80 } 81 | Popular Tags |