1 11 package org.eclipse.help.internal.workingset; 12 13 import java.util.Arrays ; 14 import java.util.HashMap ; 15 16 import org.eclipse.core.runtime.*; 17 import org.eclipse.help.*; 18 19 22 public class AdaptableTocsArray implements IAdaptable { 23 24 IToc[] element; 25 AdaptableToc[] children; 26 HashMap map; 27 28 31 public AdaptableTocsArray(IToc[] tocs) { 32 this.element = tocs; 33 } 34 35 38 public Object getAdapter(Class adapter) { 39 if (adapter == IToc[].class) 40 return element; 41 return null; 42 } 43 44 public IAdaptable[] getChildren() { 45 46 if (children == null) { 47 children = new AdaptableToc[element.length]; 48 for (int i = 0; i < element.length; i++) { 49 children[i] = new AdaptableToc(element[i]); 50 children[i].setParent(this); 51 } 52 } 53 return children; 54 55 } 56 57 public AdaptableToc getAdaptableToc(String href) { 58 if (map == null) { 59 getChildren(); map = new HashMap (children.length); 61 for (int i = 0; i < children.length; i++) 62 map.put(children[i].getHref(), children[i]); 63 } 64 return (AdaptableToc) map.get(href); 65 } 66 67 IToc[] asArray() { 68 return element; 69 } 70 71 79 public boolean equals(Object object) { 80 if (this == object) { 81 return true; 82 } 83 if (!(object instanceof AdaptableTocsArray)) { 84 return false; 85 } 86 87 AdaptableTocsArray res = (AdaptableTocsArray) object; 88 return (Arrays.equals(asArray(), res.asArray())); 89 90 } 91 92 97 public int hashCode() { 98 if (element == null) 99 return -1; 100 return element.hashCode(); 101 } 102 } 103 104 | Popular Tags |