} else if (outerElement.equals(BugCollection.HISTORY_ELEMENT_NAME)) { if (qName.equals(AppVersion.ELEMENT_NAME)) { try { String sequence = getRequiredAttribute(attributes, "sequence", qName); String timestamp = attributes.getValue("timestamp"); String releaseName = attributes.getValue("release"); AppVersion appVersion = new AppVersion(Long.valueOf(sequence).longValue()); if (timestamp != null) appVersion.setTimestamp(Long.valueOf(timestamp).longValue()); if (releaseName != null) appVersion.setReleaseName(releaseName); bugCollection.addAppVersion(appVersion); } catch (NumberFormatException e) { throw new SAXException("Invalid AppVersion element", e); } }
	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 + ")");						// Read and set the sequence number.			String sequence = attributes.getValue("sequence");			long seqval = -1L;			try {				if (sequence != null)					seqval = Long.parseLong(sequence);			} catch (NumberFormatException e) {				// Ignore			}						// If we can't get the sequence number, or it is not present,			// just use 0.			if (seqval < 0L) {				seqval = 0L;			}			bugCollection.setSequenceNumber(seqval);						// Set release name, if present.			String releaseName = attributes.getValue("release");			if (releaseName != null) {				bugCollection.setReleaseName(releaseName);			}		} 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(Project.FILENAME_ATTRIBUTE_NAME);					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(SequenceIntervalCollection.decode(activeIntervalCollection));						} catch (InvalidSequenceIntervalException e) {							// Whoops, we lost the active history for this BugInstance.							// Add the current sequence.							SequenceIntervalCollection activeCollection = new SequenceIntervalCollection();							activeCollection.add(									new SequenceInterval(bugCollection.getSequenceNumber(), bugCollection.getSequenceNumber()));							bugInstance.setActiveIntervalCollection(activeCollection);						}					}				} else if (qName.equals("FindBugsSummary")) {					String timestamp = getRequiredAttribute(attributes, "timestamp", qName);					try {						bugCollection.getProjectStats().setTimestamp(timestamp);					} catch (java.text.ParseException e) {						throw new SAXException("Unparseable sequence number: '" + timestamp + "'", e);					}				}			} 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")) {						String isStatic = attributes.getValue("isStatic");						if (isStatic == null) {							isStatic = "false"; // Hack for old data						}						// Save in field in case of nested SourceLine elements.						methodAnnotation =							new MethodAnnotation(classname, fieldOrMethodName, signature, Boolean.valueOf(isStatic).booleanValue());												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);						bugAnnotation = new IntAnnotation(Integer.parseInt(value));					} 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) {					setAnnotationRole(attributes, bugAnnotation);					bugInstance.add(bugAnnotation);				}			} else if (outerElement.equals("Method")) {				if (qName.equals("SourceLine")) {					// Method elements can contain nested SourceLine elements.					methodAnnotation.setSourceLines(createSourceLineAnnotation(qName, attributes));				}			} 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();				}			} else if (outerElement.equals("PackageStats")) {				if (qName.equals("ClassStats")) {					String className = getRequiredAttribute(attributes, "class", qName);					Boolean isInterface = Boolean.valueOf(						getRequiredAttribute(attributes, "interface", qName));					int size = Integer.valueOf(						getRequiredAttribute(attributes, "size", qName));					bugCollection.getProjectStats().addClass(className, isInterface, size);				}			} else if (outerElement.equals(BugCollection.CLASS_HASHES_ELEMENT_NAME)) {				if (qName.equals(ClassHash.CLASS_HASH_ELEMENT_NAME)) {					String className = getRequiredAttribute(attributes, "class", qName);					byte[] hash = extractHash(qName, attributes);					classHash = new ClassHash(className, hash);					bugCollection.setClassHash(className, classHash);				}			} else if (outerElement.equals(ClassHash.CLASS_HASH_ELEMENT_NAME)) {				if (qName.equals(ClassHash.METHOD_HASH_ELEMENT_NAME) && classHash != null) {					String methodName = getRequiredAttribute(attributes, "name", qName);					String methodSig = getRequiredAttribute(attributes, "signature", qName);					boolean isStatic = Boolean.valueOf(getRequiredAttribute(attributes, "isStatic", qName)).booleanValue();					byte[] hash = extractHash(qName, attributes);					classHash.setMethodHash(							XMethodFactory.createXMethod(classHash.getClassName(), methodName, methodSig, isStatic),							hash);				}			}		}		textBuffer.delete(0, textBuffer.length());		elementStack.add(qName);	}