1 57 58 package com.sun.org.apache.xerces.internal.impl.xs.util; 59 60 import com.sun.org.apache.xerces.internal.xs.XSObject; 61 import com.sun.org.apache.xerces.internal.xs.XSTypeDefinition; 62 import com.sun.org.apache.xerces.internal.util.SymbolHash; 63 64 71 public class XSNamedMap4Types extends XSNamedMapImpl { 72 73 short fType; 75 76 83 public XSNamedMap4Types(String namespace, SymbolHash map, short type) { 84 super(namespace, map); 85 fType = type; 86 } 87 88 96 public XSNamedMap4Types(String [] namespaces, SymbolHash[] maps, int num, short type) { 97 super(namespaces, maps, num); 98 fType = type; 99 } 100 101 106 public synchronized int getLength() { 107 if (fLength == -1) { 108 int length = 0; 110 for (int i = 0; i < fNSNum; i++) 111 length += fMaps[i].getLength(); 112 int pos = 0; 114 XSObject[] array = new XSObject[length]; 115 for (int i = 0; i < fNSNum; i++) { 116 pos += fMaps[i].getValues(array, pos); 117 } 118 fLength = 0; 121 fArray = new XSObject[length]; 122 XSTypeDefinition type; 123 for (int i = 0; i < length; i++) { 124 type = (XSTypeDefinition)array[i]; 125 if (type.getTypeCategory() == fType) { 126 fArray[fLength++] = type; 127 } 128 } 129 } 130 return fLength; 131 } 132 133 143 public XSObject itemByName(String namespace, String localName) { 144 if (namespace != null) 145 namespace = namespace.intern(); 146 for (int i = 0; i < fNSNum; i++) { 147 if (namespace == fNamespaces[i]) { 148 XSTypeDefinition type = (XSTypeDefinition)fMaps[i].get(localName); 149 if (type.getTypeCategory() == fType) 151 return type; 152 return null; 153 } 154 } 155 return null; 156 } 157 158 168 public synchronized XSObject item(int index) { 169 if (fArray == null) { 170 getLength(); 171 } 172 if (index < 0 || index >= fLength) 173 return null; 174 return fArray[index]; 175 } 176 177 } | Popular Tags |