1 16 17 package org.apache.xerces.impl.xs.util; 18 19 import org.apache.xerces.xs.XSObject; 20 import org.apache.xerces.xs.XSTypeDefinition; 21 import org.apache.xerces.util.SymbolHash; 22 23 32 public class XSNamedMap4Types extends XSNamedMapImpl { 33 34 short fType; 36 37 44 public XSNamedMap4Types(String namespace, SymbolHash map, short type) { 45 super(namespace, map); 46 fType = type; 47 } 48 49 57 public XSNamedMap4Types(String [] namespaces, SymbolHash[] maps, int num, short type) { 58 super(namespaces, maps, num); 59 fType = type; 60 } 61 62 67 public synchronized int getLength() { 68 if (fLength == -1) { 69 int length = 0; 71 for (int i = 0; i < fNSNum; i++) 72 length += fMaps[i].getLength(); 73 int pos = 0; 75 XSObject[] array = new XSObject[length]; 76 for (int i = 0; i < fNSNum; i++) { 77 pos += fMaps[i].getValues(array, pos); 78 } 79 fLength = 0; 82 fArray = new XSObject[length]; 83 XSTypeDefinition type; 84 for (int i = 0; i < length; i++) { 85 type = (XSTypeDefinition)array[i]; 86 if (type.getTypeCategory() == fType) { 87 fArray[fLength++] = type; 88 } 89 } 90 } 91 return fLength; 92 } 93 94 104 public XSObject itemByName(String namespace, String localName) { 105 if (namespace != null) 106 namespace = namespace.intern(); 107 for (int i = 0; i < fNSNum; i++) { 108 if (namespace == fNamespaces[i]) { 109 XSTypeDefinition type = (XSTypeDefinition)fMaps[i].get(localName); 110 if (type.getTypeCategory() == fType) 112 return type; 113 return null; 114 } 115 } 116 return null; 117 } 118 119 129 public synchronized XSObject item(int index) { 130 if (fArray == null) { 131 getLength(); 132 } 133 if (index < 0 || index >= fLength) 134 return null; 135 return fArray[index]; 136 } 137 138 } | Popular Tags |