AppVersion appVersion = new AppVersion(Long.valueOf(sequence).longValue());
AppVersion appVersion = new AppVersion(Long.valueOf(sequence));
	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 = parseLong(sequence, 0L);			bugCollection.setSequenceNumber(seqval);						// Read and set timestamp.			String timestamp = attributes.getValue("timestamp");			long tsval = parseLong(timestamp, -1L);			bugCollection.setTimestamp(tsval);						// Set release name, if present.			String releaseName = attributes.getValue("release");			bugCollection.setReleaseName((releaseName != null) ? 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 firstVersion = attributes.getValue("first");					if (firstVersion != null) {						bugInstance.setFirstVersion(Long.parseLong(firstVersion));					}					String lastVersion = attributes.getValue("last");					if (lastVersion != null) {						bugInstance.setLastVersion(Long.parseLong(lastVersion));					}										if (bugInstance.getLastVersion() >= 0 &&							bugInstance.getFirstVersion() > bugInstance.getLastVersion())						throw new IllegalStateException("huh");										String introducedByChange = attributes.getValue("introducedByChange");					if (introducedByChange != null) {						bugInstance.setIntroducedByChangeOfExistingClass(Boolean.parseBoolean(introducedByChange));					}					String removedByChange = attributes.getValue("removedByChange");					if (removedByChange != null) {						bugInstance.setRemovedByChangeOfPersistingClass(Boolean.parseBoolean(removedByChange));					}														} 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("LocalVariable")) {					try {						String varName = getRequiredAttribute(attributes, "name", qName);						int register = Integer.parseInt(getRequiredAttribute(attributes, "register", qName));						int pc = Integer.parseInt(getRequiredAttribute(attributes, "pc", qName));						bugAnnotation = new LocalVariableAnnotation(varName, register, pc);					} catch (NumberFormatException e) {						throw new SAXException("Invalid integer value in attribute of LocalVariable element");					}				} 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(//							XFactory.createXMethod(classHash.getClassName(), methodName, methodSig, isStatic),//							hash);//				}			} else if (outerElement.equals("ClassFeatures")) {				if (qName.equals(ClassFeatureSet.ELEMENT_NAME)) {					String className = getRequiredAttribute(attributes, "class", qName);					classFeatureSet = new ClassFeatureSet();					classFeatureSet.setClassName(className);				}			} else if (outerElement.equals(ClassFeatureSet.ELEMENT_NAME)) {				if (qName.equals(ClassFeatureSet.FEATURE_ELEMENT_NAME)) {					String value = getRequiredAttribute(attributes, "value", qName);					classFeatureSet.addFeature(value);				}			} 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");						String codeSize = attributes.getValue("codeSize");						String numClasses = attributes.getValue("numClasses");						AppVersion appVersion = new AppVersion(Long.valueOf(sequence).longValue());						if (timestamp != null)							appVersion.setTimestamp(Long.valueOf(timestamp).longValue());						if (releaseName != null)							appVersion.setReleaseName(releaseName);						if (codeSize != null)							appVersion.setCodeSize(Integer.parseInt(codeSize));						if (numClasses != null)							appVersion.setNumClasses(Integer.parseInt(numClasses));												bugCollection.addAppVersion(appVersion);					} catch (NumberFormatException e) {						throw new SAXException("Invalid AppVersion element", e);					}				}			}		}		textBuffer.delete(0, textBuffer.length());		elementStack.add(qName);	}