public static void load(ClassData k) throws ClassNotFoundException, IOException { ClassData kp; String sname; sname = k.supername; // name of superclass if (k.superclass == null && sname != null) { // there is a superclass and it has not been linked in for (kp = previous; kp != null; kp = kp.superclass) if (kp.name.equals(sname)) break; if (kp != null) k.superclass = kp; // found in existing chain else { // not found; find and load superclass from file ClassFile cf = ClassFile.find(sname); k.superclass = ClassData.forStream(null, cf, false); // System.out.println (sname + " from " + cf.dir); /* Resulting class has to have the right name. */ if (!sname.equals(k.superclass.name)) { throw new ClassNotFoundException(sname); } load(k.superclass); // load superclass's superclasses } } k.state = ClassData.RES_SUPERCLASSES; k.buildTables(); // fill in method table IHash.mark(null, k); // mark interfaces previous = k; // remember class just loaded }
public void startElement(String uri, String localName, String name, Attributes attributes) throws SAXException { if (collectText) { if (collectHTML) { text.append("<").append(localName); int nAttributes = attributes.getLength(); for (int i = 0; i < nAttributes; i++) { String qname = attributes.getQName(i); String value = attributes.getValue(i); text.append(" ").append(qname).append("=\"").append(value).append("\""); } } pendingEndElement = true; } else { Integer stateObj = null; pushState(); if (NAMESPACE_API.equals(uri)) { stateObj = (Integer) states.get(localName); if (stateObj != null) { int state = stateObj.intValue(); switch (state) { case STATE_ABOUTME: { startCollectingText(localName, attributes); break; } case STATE_ALIAS: { Alias alias = new Alias(); this.currentObject = alias; addCollectionElement(TAG_ALIAS, alias); alias.name = attributes.getValue(ATTRIBUTE_ALAIS_NAME); alias.datatype = attributes.getValue(ATTRIBUTE_ALAIS_TYPE); break; } case STATE_ANCESTOR: { Ancestor ancestor = new Ancestor(); this.currentObject = ancestor; addCollectionElement(TAG_ANCESTOR, ancestor); ancestor.dataType = attributes.getValue(ATTRIBUTE_ANCESTOR_DATATYPE); break; } case STATE_API: { this.apis.libraryVersion = attributes.getValue(ATTRIBUTE_API_VERSION); this.apis.language = attributes.getValue(ATTRIBUTE_API_LANGUAGE); this.apis.getterPattern = attributes.getValue(ATTRIBUTE_API_GETTERPATTERN); this.apis.setterPattern = attributes.getValue(ATTRIBUTE_API_SETTERPATTERN); this.apis.setterPattern = attributes.getValue(ATTRIBUTE_API_SETTERPATTERN); this.apis.spec = attributes.getValue(ATTRIBUTE_API_SPEC); this.collections = new HashMap(); break; } case STATE_AUTHOR: { Author author = new Author(); this.currentObject = author; author.email = attributes.getValue(ATTRIBUTE_AUTHOR_EMAIL); author.location = attributes.getValue(ATTRIBUTE_AUTHOR_LOCATION); author.name = attributes.getValue(ATTRIBUTE_AUTHOR_NAME); author.organization = attributes.getValue(ATTRIBUTE_AUTHOR_ORGANIZATION); author.photo = attributes.getValue(ATTRIBUTE_AUTHOR_PHOTO); author.type = attributes.getValue(ATTRIBUTE_AUTHOR_TYPE); author.website = attributes.getValue(ATTRIBUTE_AUTHOR_WEBSITE); addCollectionElement(TAG_AUTHOR, author); break; } case STATE_AVAILABLE: { DepreciatedOrAvailable available = new DepreciatedOrAvailable(); if (this.currentObject instanceof VersionableElement) ((VersionableElement) this.currentObject).available = available; available.version = attributes.getValue(ATTRIBUTE_AVAILABLE_VERSION); startCollectingText(localName, attributes); break; } case STATE_CLASS: case STATE_INTERFACE: { ClassData clazz = new ClassData(); this.currentObject = clazz; if (STATE_INTERFACE == state) { clazz.isInterface = true; addCollectionElement(TAG_INTERFACE, clazz); } else addCollectionElement(TAG_CLASS, clazz); clazz.name = attributes.getValue(ATTRIBUTE_CLASS_NAME); clazz.superclass = attributes.getValue(ATTRIBUTE_CLASS_SUPERCLASS); clazz.visibility = attributes.getValue(ATTRIBUTE_CLASS_VISIBILITY); clazz.getterPattern = attributes.getValue(ATTRIBUTE_CLASS_GETTERPATTERN); clazz.setterPattern = attributes.getValue(ATTRIBUTE_CLASS_SETTERPATTERN); this.collections = new HashMap(); break; } case STATE_CONSTRUCTOR: case STATE_METHOD: { Method method = new Method(); if (STATE_CONSTRUCTOR == state) { method.isContructor = true; addCollectionElement(TAG_CONSTRUCTOR, method); } else addCollectionElement(TAG_METHOD, method); this.currentObject = method; method.scope = attributes.getValue(ATTRIBUTE_CONSTRUCTOR_SCOPE); method.visibility = attributes.getValue(ATTRIBUTE_CONSTRUCTOR_VISIBILITY); method.name = attributes.getValue(ATTRIBUTE_METHOD_NAME); this.collections = new HashMap(); break; } case STATE_DEPRECIATED: { DepreciatedOrAvailable depreciated = new DepreciatedOrAvailable(); if (this.currentObject instanceof VersionableElement) ((VersionableElement) this.currentObject).depreciated = depreciated; depreciated.isDepreciated = true; depreciated.version = attributes.getValue(ATTRIBUTE_DEPRECIATED_VERSION); startCollectingText(localName, attributes); break; } case STATE_DESCRIPTION: { startCollectingText(localName, attributes); break; } case STATE_ENUM: { Enum enumData = new Enum(); this.currentObject = enumData; addCollectionElement(TAG_ENUM, enumData); enumData.name = attributes.getValue(ATTRIBUTE_ENUM_NAME); enumData.datatype = attributes.getValue(ATTRIBUTE_ENUM_DATATYPE); break; } case STATE_EVENT: { Event event = new Event(); this.currentObject = event; addCollectionElement(TAG_EVENT, event); this.collections = new HashMap(); break; } case STATE_EXCEPTION: { Exception exception = new Exception(); this.currentObject = exception; addCollectionElement(TAG_EXCEPTION, exception); this.collections = new HashMap(); break; } case STATE_FIELD: case STATE_PROPERTY: { Property property = new Property(); this.currentObject = property; if (STATE_FIELD == state) { property.isField = true; addCollectionElement(TAG_FIELD, property); } else addCollectionElement(TAG_PROPERTY, property); property.name = attributes.getValue(ATTRIBUTE_FIELD_NAME); property.dataType = attributes.getValue(ATTRIBUTE_FIELD_DATATYPE); property.scope = attributes.getValue(ATTRIBUTE_FIELD_SCOPE); property.visibility = attributes.getValue(ATTRIBUTE_FIELD_VISIBILITY); this.collections = new HashMap(); break; } case STATE_INCLUDE: { String src = attributes.getValue(ATTRIBUTE_INCLUDE_SRC); handleInclude(src); break; } case STATE_MIX: { Mix mix = new Mix(); addCollectionElement(TAG_MIX, mix); this.currentObject = mix; mix.datatype = attributes.getValue(ATTRIBUTE_MIX_DATATYPE); mix.fromScope = attributes.getValue(ATTRIBUTE_MIX_FROMSCOPE); mix.toScope = attributes.getValue(ATTRIBUTE_MIX_TOSCOPE); break; } case STATE_MIXIN: { Mixin mixin = new Mixin(); addCollectionElement(TAG_MIXIN, mixin); this.currentObject = mixin; mixin.name = attributes.getValue(ATTRIBUTE_MIXIN_NAME); mixin.scope = attributes.getValue(ATTRIBUTE_MIXIN_SCOPE); mixin.visibility = attributes.getValue(ATTRIBUTE_MIXIN_VISIBILITY); break; } case STATE_NAMESPACE: { Namespace namespace = new Namespace(); addCollectionElement(TAG_NAMESPACE, namespace); this.currentObject = namespace; namespace.name = attributes.getValue(ATTRIBUTE_NAMESPACE_NAME); namespace.visibility = attributes.getValue(ATTRIBUTE_NAMESPACE_VISIBILITY); break; } case STATE_PARAMETER: { Parameter parameter = new Parameter(); this.currentObject = parameter; addCollectionElement(TAG_PARAMETER, parameter); parameter.name = attributes.getValue(ATTRIBUTE_PARAMETER_NAME); parameter.dataType = attributes.getValue(ATTRIBUTE_PARAMETER_DATATYPE); parameter.usage = attributes.getValue(ATTRIBUTE_PARAMETER_USAGE); this.collections = new HashMap(); break; } case STATE_QOUTE: { startCollectingText(localName, attributes); break; } case STATE_RETURNS: { ReturnsData returnData = new ReturnsData(); if (this.currentObject instanceof Method) ((Method) this.currentObject).returns = returnData; else if (this.currentObject instanceof Event) ((Event) this.currentObject).returns = returnData; else if (this.currentObject instanceof Exception) ((Exception) this.currentObject).returns = returnData; this.currentObject = returnData; returnData.dataType = attributes.getValue(ATTRIBUTE_RETURNS_DATATYPE); break; } } this.currentState = state; } } } }