} else if (outerElement.equals(BugCollection.ERRORS_ELEMENT_NAME)) { if (qName.equals(BugCollection.ANALYSIS_ERROR_ELEMENT_NAME) || qName.equals(BugCollection.ERROR_ELEMENT_NAME)) { analysisError = new AnalysisError("Unknown error"); stackTrace.clear(); }
	public void startElement(String uri, String name, String qName, Attributes attributes)		throws SAXException {		// URI should always be empty.		// So, qName is the name of the element.		if (elementStack.isEmpty()) {			// We should be parsing the outer BugCollection element.			if (!qName.equals("BugCollection"))				throw new SAXException(						"Invalid top-level element (expected BugCollection, saw " + qName + ")");			String timestamp = attributes.getValue("timestamp");			long tsval = -1L;			try {				tsval = Long.parseLong(timestamp);			} catch (NumberFormatException e) {				// Ignore			}			if (tsval < 0L) {				tsval = System.currentTimeMillis();			}			bugCollection.setTimestamp(tsval);		} else {			String outerElement = elementStack.get(elementStack.size() - 1);			if (outerElement.equals("BugCollection")) {				// Parsing a top-level element of the BugCollection				if (qName.equals("Project")) {					// Project element					String filename = attributes.getValue("filename");					if (filename != null)						project.setProjectFileName(filename);				} else if (qName.equals("BugInstance")) {					// BugInstance element - get required type and priority attributes					String type = getRequiredAttribute(attributes, "type", qName);					String priority = getRequiredAttribute(attributes, "priority", qName);					try {						int prio = Integer.parseInt(priority);						bugInstance = new BugInstance(type, prio);					} catch (NumberFormatException e) {						throw new SAXException("BugInstance with invalid priority value \"" +							priority + "\"", e);					}										String uniqueId = attributes.getValue("uid");					if (uniqueId != null) {						bugInstance.setUniqueId(uniqueId);					}										String activeIntervalCollection = attributes.getValue("active");					if (activeIntervalCollection != null) {						try {							bugInstance.setActiveIntervalCollection(TimestampIntervalCollection.decode(activeIntervalCollection));						} catch (InvalidTimestampIntervalException e) {							// Whoops, we lost the active history for this BugInstance.							// Add the current timestamp.							TimestampIntervalCollection activeCollection = new TimestampIntervalCollection();							activeCollection.add(									new TimestampInterval(bugCollection.getTimestamp(), bugCollection.getTimestamp()));							bugInstance.setActiveIntervalCollection(activeCollection);						}					}				}			} else if (outerElement.equals("BugInstance")) {				// Parsing an attribute or property of a BugInstance				BugAnnotation bugAnnotation = null;				if (qName.equals("Class")) {					String className = getRequiredAttribute(attributes, "classname", qName);					bugAnnotation = new ClassAnnotation(className);				} else if (qName.equals("Method") || qName.equals("Field")) {					String classname = getRequiredAttribute(attributes, "classname", qName);					String fieldOrMethodName = getRequiredAttribute(attributes, "name", qName);					String signature = getRequiredAttribute(attributes, "signature", qName);					if (qName.equals("Method")) {						// Save in field in case of nested SourceLine elements.						methodAnnotation =							new MethodAnnotation(classname, fieldOrMethodName, signature);						bugAnnotation = methodAnnotation;					} else {						String isStatic = getRequiredAttribute(attributes, "isStatic", qName);						bugAnnotation = new FieldAnnotation(classname, fieldOrMethodName, signature,							Boolean.valueOf(isStatic).booleanValue());					}				} else if (qName.equals("SourceLine")) {					bugAnnotation = createSourceLineAnnotation(qName, attributes);				} else if (qName.equals("Int")) {					try {						String value = getRequiredAttribute(attributes, "value", qName);						String role = attributes.getValue("role");						bugAnnotation = new IntAnnotation(Integer.parseInt(value));						if (role != null)							bugAnnotation.setDescription(role);					} catch (NumberFormatException e) {						throw new SAXException("Bad integer value in Int");					}				} else if (qName.equals("Property")) {					// A BugProperty.					String propName = getRequiredAttribute(attributes, "name", qName);					String propValue = getRequiredAttribute(attributes, "value", qName);					bugInstance.setProperty(propName, propValue);				}				if (bugAnnotation != null)					bugInstance.add(bugAnnotation);			} else if (outerElement.equals("Method")) {				if (qName.equals("SourceLine")) {					// Method elements can contain nested SourceLine elements.					methodAnnotation.setSourceLines(createSourceLineAnnotation(qName, attributes));				}			}		}		textBuffer.delete(0, textBuffer.length());		elementStack.add(qName);	}